@khanacademy/perseus 33.1.0 → 33.2.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 +84 -34
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +84 -34
- package/dist/index.js.map +1 -1
- package/dist/util/colors.d.ts +5 -13
- package/dist/widgets/interactive-graphs/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/es/index.js
CHANGED
|
@@ -8673,10 +8673,10 @@ var Raphael$1 = (function () {
|
|
|
8673
8673
|
* provided on KhanUtil.
|
|
8674
8674
|
*/
|
|
8675
8675
|
const KhanColors = {
|
|
8676
|
-
BLUE:
|
|
8676
|
+
BLUE: color.blue,
|
|
8677
8677
|
ORANGE: "#FFA500",
|
|
8678
8678
|
PINK: "#FF00AF",
|
|
8679
|
-
GREEN:
|
|
8679
|
+
GREEN: color.green,
|
|
8680
8680
|
PURPLE: "#9D38BD",
|
|
8681
8681
|
RED: "#DF0030",
|
|
8682
8682
|
GRAY: "gray",
|
|
@@ -8752,11 +8752,9 @@ const KhanColors = {
|
|
|
8752
8752
|
// of any redesigns.
|
|
8753
8753
|
_BACKGROUND: "#FDFDFD",
|
|
8754
8754
|
// TODO(eater): Get rid of this altogether.
|
|
8755
|
-
INTERACTING:
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
// KA_GREEN
|
|
8759
|
-
DYNAMIC: "#6495ED" // BLUE
|
|
8755
|
+
INTERACTING: color.green,
|
|
8756
|
+
INTERACTIVE: color.green,
|
|
8757
|
+
DYNAMIC: color.blue
|
|
8760
8758
|
};
|
|
8761
8759
|
|
|
8762
8760
|
// DrawingTransform is responsible for transforming from "math coordinates"
|
|
@@ -10036,21 +10034,50 @@ const setLabelMargins = function setLabelMargins(span, size) {
|
|
|
10036
10034
|
});
|
|
10037
10035
|
} else {
|
|
10038
10036
|
var _$container$css, _$container$width, _$span$css;
|
|
10039
|
-
|
|
10037
|
+
// We are using jQuery to collect information and calculate a scale
|
|
10038
|
+
// since we don't have a way to pass it to this function.
|
|
10039
|
+
// We need the width of the container in order to calculate the scale to apply to the label.
|
|
10040
|
+
// Unfortunately, the DOM tree leading to the label is not consistent.
|
|
10041
|
+
// Therefore, we need to check different elements and different style properties to get the width of the container.
|
|
10042
|
+
// Some graphie labels exist within an ".svg-image" container, and others do not.
|
|
10043
|
+
// All graphie labels have a ".graphie" container.
|
|
10044
|
+
// When a label has an ".svg-image" container,
|
|
10045
|
+
// the width information in the ".graphie" element is expressed as a percentage instead of pixels,
|
|
10046
|
+
// so we can't use it.
|
|
10047
|
+
// Instead, the ".svg-image" container can be used to get the width information.
|
|
10048
|
+
// The following lines determine which container element to use for the width measurement.
|
|
10049
|
+
const $svgImage = $span.closest(".svg-image");
|
|
10050
|
+
const $graphie = $span.closest(".graphie");
|
|
10051
|
+
// If an ".svg-image" container exists in the DOM tree, then use it, otherwise use the ".graphie" container.
|
|
10052
|
+
const $container = $svgImage.length > 0 ? $svgImage : $graphie;
|
|
10053
|
+
|
|
10040
10054
|
// Ensuring that the line-height of the text doesn't throw off placement of the text element.
|
|
10041
10055
|
// Inherited line-height values can really mess up placement.
|
|
10042
10056
|
$container.css("line-height", "normal");
|
|
10043
10057
|
|
|
10044
|
-
// The
|
|
10045
|
-
//
|
|
10046
|
-
const
|
|
10058
|
+
// The expected width of the graphie is found in the "max-width" property on ".svg-image" containers,
|
|
10059
|
+
// and is found in the "width" property on ".graphie" containers.
|
|
10060
|
+
const widthValues = (_$container$css = $container.css(["max-width", "width"])) != null ? _$container$css : {
|
|
10061
|
+
// The browser will always return a value, but tests won't, so ensuring something is returned.
|
|
10062
|
+
"max-width": "0px"
|
|
10063
|
+
};
|
|
10064
|
+
const expectedWidth =
|
|
10065
|
+
// Verified in Chrome, Firefox, and Safari - all return the same "none" value if the property does not exist.
|
|
10066
|
+
widthValues["max-width"] !== "none" ? widthValues["max-width"] : widthValues["width"];
|
|
10047
10067
|
// We can calculate the true scale of the graphie by taking actual width and dividing by the expected width.
|
|
10048
|
-
// NOTE: Using '
|
|
10049
|
-
|
|
10068
|
+
// NOTE: Using 'replace' to remove the "px" unit from the end of the expected width value.
|
|
10069
|
+
let scale = ((_$container$width = $container.width()) != null ? _$container$width : 0) / parseInt(expectedWidth.replace(/px$/, "")) * 100;
|
|
10070
|
+
// If something failed in the calculation, then default to 100% scale.
|
|
10071
|
+
if (isNaN(scale)) {
|
|
10072
|
+
scale = 100;
|
|
10073
|
+
} else if (scale === 0) {
|
|
10074
|
+
scale = 100;
|
|
10075
|
+
}
|
|
10050
10076
|
|
|
10051
10077
|
// Any padding needs to be scaled accordingly.
|
|
10052
|
-
const
|
|
10053
|
-
const
|
|
10078
|
+
const padding = (_$span$css = $span.css("padding")) != null ? _$span$css : "0px";
|
|
10079
|
+
const currentPadding = padding !== "none" ? padding : "0px";
|
|
10080
|
+
const newPadding = Math.round(parseInt(currentPadding.replace(/px$/, "")) * scale) / 100;
|
|
10054
10081
|
|
|
10055
10082
|
// "multipliers" basically move the position of the text by using 1, 0, -1
|
|
10056
10083
|
// 'margin-left' and 'margin-top' are used to position the text.
|
|
@@ -31657,7 +31684,8 @@ function UnlimitedPointGraph(props) {
|
|
|
31657
31684
|
const [[left, top]] = useTransformVectorsToPixels([minX, maxY]);
|
|
31658
31685
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("rect", {
|
|
31659
31686
|
style: {
|
|
31660
|
-
fill: "rgba(0,0,0,0)"
|
|
31687
|
+
fill: "rgba(0,0,0,0)",
|
|
31688
|
+
cursor: "crosshair"
|
|
31661
31689
|
},
|
|
31662
31690
|
width: widthPx,
|
|
31663
31691
|
height: heightPx,
|
|
@@ -31942,23 +31970,42 @@ const MafsGraph = props => {
|
|
|
31942
31970
|
dispatch
|
|
31943
31971
|
}))))), renderGraphControls({
|
|
31944
31972
|
state,
|
|
31945
|
-
dispatch
|
|
31973
|
+
dispatch,
|
|
31974
|
+
width
|
|
31946
31975
|
})));
|
|
31947
31976
|
};
|
|
31948
|
-
const renderPointGraphControls = props => /*#__PURE__*/React.createElement(
|
|
31977
|
+
const renderPointGraphControls = props => /*#__PURE__*/React.createElement(View, {
|
|
31978
|
+
style: {
|
|
31979
|
+
flexDirection: "row",
|
|
31980
|
+
width: props.width
|
|
31981
|
+
}
|
|
31982
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
31949
31983
|
kind: "secondary",
|
|
31950
31984
|
style: {
|
|
31951
31985
|
width: "100%",
|
|
31952
31986
|
marginLeft: "20px"
|
|
31953
31987
|
},
|
|
31988
|
+
tabIndex: 0,
|
|
31954
31989
|
onClick: () => {
|
|
31955
31990
|
props.dispatch(actions.pointGraph.addPoint([0, 0]));
|
|
31956
31991
|
}
|
|
31957
|
-
}, "Add Point")
|
|
31992
|
+
}, "Add Point"), (props.state.focusedPointIndex !== null || props.state.previouslyFocusedPointIndex !== null) && /*#__PURE__*/React.createElement(Button, {
|
|
31993
|
+
kind: "secondary",
|
|
31994
|
+
color: "destructive",
|
|
31995
|
+
tabIndex: 0,
|
|
31996
|
+
style: {
|
|
31997
|
+
width: "100%",
|
|
31998
|
+
marginLeft: "20px"
|
|
31999
|
+
},
|
|
32000
|
+
onClick: event => {
|
|
32001
|
+
props.dispatch(actions.pointGraph.removePoint(props.state.previouslyFocusedPointIndex));
|
|
32002
|
+
}
|
|
32003
|
+
}, "Remove Point"));
|
|
31958
32004
|
const renderGraphControls = props => {
|
|
31959
32005
|
const {
|
|
31960
32006
|
state,
|
|
31961
|
-
dispatch
|
|
32007
|
+
dispatch,
|
|
32008
|
+
width
|
|
31962
32009
|
} = props;
|
|
31963
32010
|
const {
|
|
31964
32011
|
type
|
|
@@ -31968,7 +32015,8 @@ const renderGraphControls = props => {
|
|
|
31968
32015
|
if (state.numPoints === "unlimited") {
|
|
31969
32016
|
return renderPointGraphControls({
|
|
31970
32017
|
state,
|
|
31971
|
-
dispatch
|
|
32018
|
+
dispatch,
|
|
32019
|
+
width
|
|
31972
32020
|
});
|
|
31973
32021
|
}
|
|
31974
32022
|
return null;
|
|
@@ -32137,7 +32185,8 @@ function initializeGraphState(params) {
|
|
|
32137
32185
|
type: graph.type,
|
|
32138
32186
|
coords: getPointCoords(graph, range, step),
|
|
32139
32187
|
numPoints: graph.numPoints || 0,
|
|
32140
|
-
focusedPointIndex: null
|
|
32188
|
+
focusedPointIndex: null,
|
|
32189
|
+
previouslyFocusedPointIndex: null
|
|
32141
32190
|
});
|
|
32142
32191
|
case "circle":
|
|
32143
32192
|
return _extends({}, shared, {
|
|
@@ -32430,6 +32479,7 @@ function doBlurPoint(state, action) {
|
|
|
32430
32479
|
switch (state.type) {
|
|
32431
32480
|
case "point":
|
|
32432
32481
|
return _extends({}, state, {
|
|
32482
|
+
previouslyFocusedPointIndex: state.focusedPointIndex,
|
|
32433
32483
|
focusedPointIndex: null
|
|
32434
32484
|
});
|
|
32435
32485
|
default:
|
|
@@ -32474,7 +32524,6 @@ function doMovePointInFigure(state, action) {
|
|
|
32474
32524
|
}
|
|
32475
32525
|
case "angle":
|
|
32476
32526
|
case "circle":
|
|
32477
|
-
throw new Error("FIXME implement circle reducer");
|
|
32478
32527
|
case "point":
|
|
32479
32528
|
case "polygon":
|
|
32480
32529
|
case "quadratic":
|
|
@@ -32785,7 +32834,8 @@ function doRemovePoint(state, action) {
|
|
|
32785
32834
|
}
|
|
32786
32835
|
return _extends({}, state, {
|
|
32787
32836
|
coords: state.coords.filter((_, i) => i !== action.index),
|
|
32788
|
-
focusedPointIndex: null
|
|
32837
|
+
focusedPointIndex: null,
|
|
32838
|
+
previouslyFocusedPointIndex: null
|
|
32789
32839
|
});
|
|
32790
32840
|
}
|
|
32791
32841
|
const getDeltaVertex = (maxMoves, minMoves, delta) => {
|
|
@@ -39612,15 +39662,15 @@ const TickMarks = Graphie.createSimpleClass((graphie, props) => {
|
|
|
39612
39662
|
|
|
39613
39663
|
// Render the text labels
|
|
39614
39664
|
results.push(graphie.style(props.isMobile ? {
|
|
39615
|
-
color: KhanColors.
|
|
39665
|
+
color: KhanColors.BLUE
|
|
39616
39666
|
} : {}, () => _label(graphie, props.labelStyle, leftLabel, leftLabel, base)));
|
|
39617
39667
|
results.push(graphie.style(props.isMobile ? {
|
|
39618
|
-
color: KhanColors.
|
|
39668
|
+
color: KhanColors.BLUE
|
|
39619
39669
|
} : {}, () => _label(graphie, props.labelStyle, rightLabel, rightLabel, base)));
|
|
39620
39670
|
|
|
39621
39671
|
// Render the labels' lines
|
|
39622
39672
|
graphie.style({
|
|
39623
|
-
stroke:
|
|
39673
|
+
stroke: KhanColors.BLUE,
|
|
39624
39674
|
strokeWidth: 3.5
|
|
39625
39675
|
}, () => {
|
|
39626
39676
|
results.push(graphie.line([leftLabel, -0.2], [leftLabel, 0.2]));
|
|
@@ -39787,21 +39837,21 @@ class NumberLine extends React.Component {
|
|
|
39787
39837
|
if (isOpen) {
|
|
39788
39838
|
fill = KhanColors._BACKGROUND;
|
|
39789
39839
|
} else if (props.static) {
|
|
39790
|
-
fill = KhanColors.
|
|
39840
|
+
fill = KhanColors.BLUE;
|
|
39791
39841
|
} else {
|
|
39792
|
-
fill = KhanColors.
|
|
39842
|
+
fill = KhanColors.GREEN;
|
|
39793
39843
|
}
|
|
39794
39844
|
const normalStyle = {
|
|
39795
39845
|
fill: fill,
|
|
39796
|
-
stroke: props.static ? KhanColors.
|
|
39846
|
+
stroke: props.static ? KhanColors.BLUE : KhanColors.GREEN,
|
|
39797
39847
|
"stroke-width": isOpen ? 3 : 1
|
|
39798
39848
|
};
|
|
39799
39849
|
const highlightStyle = {
|
|
39800
|
-
fill: isOpen ? KhanColors._BACKGROUND : KhanColors.
|
|
39850
|
+
fill: isOpen ? KhanColors._BACKGROUND : KhanColors.GREEN,
|
|
39801
39851
|
"stroke-width": isOpen ? 3 : 1
|
|
39802
39852
|
};
|
|
39803
39853
|
const mobileDotStyle = props.isInequality ? {
|
|
39804
|
-
stroke: KhanColors.
|
|
39854
|
+
stroke: KhanColors.GREEN,
|
|
39805
39855
|
"fill-opacity": isOpen ? 0 : 1
|
|
39806
39856
|
} : {};
|
|
39807
39857
|
return /*#__PURE__*/React.createElement(MovablePoint
|
|
@@ -39859,7 +39909,7 @@ class NumberLine extends React.Component {
|
|
|
39859
39909
|
const end = this._getInequalityEndpoint(props);
|
|
39860
39910
|
const style = {
|
|
39861
39911
|
arrows: "->",
|
|
39862
|
-
stroke: this.props.apiOptions.isMobile ? KhanColors.
|
|
39912
|
+
stroke: this.props.apiOptions.isMobile ? KhanColors.GREEN : KhanColors.BLUE,
|
|
39863
39913
|
strokeWidth: 3.5
|
|
39864
39914
|
};
|
|
39865
39915
|
const isGreater = ["ge", "gt"].includes(props.rel);
|
|
@@ -44616,7 +44666,7 @@ const init = function init(options) {
|
|
|
44616
44666
|
|
|
44617
44667
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44618
44668
|
const libName = "@khanacademy/perseus";
|
|
44619
|
-
const libVersion = "33.
|
|
44669
|
+
const libVersion = "33.2.0";
|
|
44620
44670
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44621
44671
|
|
|
44622
44672
|
const apiVersion = {
|