@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/index.js
CHANGED
|
@@ -8780,10 +8780,10 @@ var Raphael$1 = (function () {
|
|
|
8780
8780
|
* provided on KhanUtil.
|
|
8781
8781
|
*/
|
|
8782
8782
|
const KhanColors = {
|
|
8783
|
-
BLUE:
|
|
8783
|
+
BLUE: wonderBlocksTokens.color.blue,
|
|
8784
8784
|
ORANGE: "#FFA500",
|
|
8785
8785
|
PINK: "#FF00AF",
|
|
8786
|
-
GREEN:
|
|
8786
|
+
GREEN: wonderBlocksTokens.color.green,
|
|
8787
8787
|
PURPLE: "#9D38BD",
|
|
8788
8788
|
RED: "#DF0030",
|
|
8789
8789
|
GRAY: "gray",
|
|
@@ -8859,11 +8859,9 @@ const KhanColors = {
|
|
|
8859
8859
|
// of any redesigns.
|
|
8860
8860
|
_BACKGROUND: "#FDFDFD",
|
|
8861
8861
|
// TODO(eater): Get rid of this altogether.
|
|
8862
|
-
INTERACTING:
|
|
8863
|
-
|
|
8864
|
-
|
|
8865
|
-
// KA_GREEN
|
|
8866
|
-
DYNAMIC: "#6495ED" // BLUE
|
|
8862
|
+
INTERACTING: wonderBlocksTokens.color.green,
|
|
8863
|
+
INTERACTIVE: wonderBlocksTokens.color.green,
|
|
8864
|
+
DYNAMIC: wonderBlocksTokens.color.blue
|
|
8867
8865
|
};
|
|
8868
8866
|
|
|
8869
8867
|
// DrawingTransform is responsible for transforming from "math coordinates"
|
|
@@ -10147,21 +10145,50 @@ const setLabelMargins = function (span, size) {
|
|
|
10147
10145
|
marginTop: -height / 2 - y * scale
|
|
10148
10146
|
});
|
|
10149
10147
|
} else {
|
|
10150
|
-
|
|
10148
|
+
// We are using jQuery to collect information and calculate a scale
|
|
10149
|
+
// since we don't have a way to pass it to this function.
|
|
10150
|
+
// We need the width of the container in order to calculate the scale to apply to the label.
|
|
10151
|
+
// Unfortunately, the DOM tree leading to the label is not consistent.
|
|
10152
|
+
// Therefore, we need to check different elements and different style properties to get the width of the container.
|
|
10153
|
+
// Some graphie labels exist within an ".svg-image" container, and others do not.
|
|
10154
|
+
// All graphie labels have a ".graphie" container.
|
|
10155
|
+
// When a label has an ".svg-image" container,
|
|
10156
|
+
// the width information in the ".graphie" element is expressed as a percentage instead of pixels,
|
|
10157
|
+
// so we can't use it.
|
|
10158
|
+
// Instead, the ".svg-image" container can be used to get the width information.
|
|
10159
|
+
// The following lines determine which container element to use for the width measurement.
|
|
10160
|
+
const $svgImage = $span.closest(".svg-image");
|
|
10161
|
+
const $graphie = $span.closest(".graphie");
|
|
10162
|
+
// If an ".svg-image" container exists in the DOM tree, then use it, otherwise use the ".graphie" container.
|
|
10163
|
+
const $container = $svgImage.length > 0 ? $svgImage : $graphie;
|
|
10164
|
+
|
|
10151
10165
|
// Ensuring that the line-height of the text doesn't throw off placement of the text element.
|
|
10152
10166
|
// Inherited line-height values can really mess up placement.
|
|
10153
10167
|
$container.css("line-height", "normal");
|
|
10154
10168
|
|
|
10155
|
-
// The
|
|
10156
|
-
//
|
|
10157
|
-
const
|
|
10169
|
+
// The expected width of the graphie is found in the "max-width" property on ".svg-image" containers,
|
|
10170
|
+
// and is found in the "width" property on ".graphie" containers.
|
|
10171
|
+
const widthValues = $container.css(["max-width", "width"]) ?? {
|
|
10172
|
+
// The browser will always return a value, but tests won't, so ensuring something is returned.
|
|
10173
|
+
"max-width": "0px"
|
|
10174
|
+
};
|
|
10175
|
+
const expectedWidth =
|
|
10176
|
+
// Verified in Chrome, Firefox, and Safari - all return the same "none" value if the property does not exist.
|
|
10177
|
+
widthValues["max-width"] !== "none" ? widthValues["max-width"] : widthValues["width"];
|
|
10158
10178
|
// We can calculate the true scale of the graphie by taking actual width and dividing by the expected width.
|
|
10159
|
-
// NOTE: Using '
|
|
10160
|
-
|
|
10179
|
+
// NOTE: Using 'replace' to remove the "px" unit from the end of the expected width value.
|
|
10180
|
+
let scale = ($container.width() ?? 0) / parseInt(expectedWidth.replace(/px$/, "")) * 100;
|
|
10181
|
+
// If something failed in the calculation, then default to 100% scale.
|
|
10182
|
+
if (isNaN(scale)) {
|
|
10183
|
+
scale = 100;
|
|
10184
|
+
} else if (scale === 0) {
|
|
10185
|
+
scale = 100;
|
|
10186
|
+
}
|
|
10161
10187
|
|
|
10162
10188
|
// Any padding needs to be scaled accordingly.
|
|
10163
|
-
const
|
|
10164
|
-
const
|
|
10189
|
+
const padding = $span.css("padding") ?? "0px";
|
|
10190
|
+
const currentPadding = padding !== "none" ? padding : "0px";
|
|
10191
|
+
const newPadding = Math.round(parseInt(currentPadding.replace(/px$/, "")) * scale) / 100;
|
|
10165
10192
|
|
|
10166
10193
|
// "multipliers" basically move the position of the text by using 1, 0, -1
|
|
10167
10194
|
// 'margin-left' and 'margin-top' are used to position the text.
|
|
@@ -31990,7 +32017,8 @@ function UnlimitedPointGraph(props) {
|
|
|
31990
32017
|
const [[left, top]] = useTransformVectorsToPixels([minX, maxY]);
|
|
31991
32018
|
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("rect", {
|
|
31992
32019
|
style: {
|
|
31993
|
-
fill: "rgba(0,0,0,0)"
|
|
32020
|
+
fill: "rgba(0,0,0,0)",
|
|
32021
|
+
cursor: "crosshair"
|
|
31994
32022
|
},
|
|
31995
32023
|
width: widthPx,
|
|
31996
32024
|
height: heightPx,
|
|
@@ -32274,23 +32302,42 @@ const MafsGraph = props => {
|
|
|
32274
32302
|
dispatch
|
|
32275
32303
|
}))))), renderGraphControls({
|
|
32276
32304
|
state,
|
|
32277
|
-
dispatch
|
|
32305
|
+
dispatch,
|
|
32306
|
+
width
|
|
32278
32307
|
})));
|
|
32279
32308
|
};
|
|
32280
|
-
const renderPointGraphControls = props => /*#__PURE__*/React__namespace.createElement(
|
|
32309
|
+
const renderPointGraphControls = props => /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
32310
|
+
style: {
|
|
32311
|
+
flexDirection: "row",
|
|
32312
|
+
width: props.width
|
|
32313
|
+
}
|
|
32314
|
+
}, /*#__PURE__*/React__namespace.createElement(Button__default["default"], {
|
|
32281
32315
|
kind: "secondary",
|
|
32282
32316
|
style: {
|
|
32283
32317
|
width: "100%",
|
|
32284
32318
|
marginLeft: "20px"
|
|
32285
32319
|
},
|
|
32320
|
+
tabIndex: 0,
|
|
32286
32321
|
onClick: () => {
|
|
32287
32322
|
props.dispatch(actions.pointGraph.addPoint([0, 0]));
|
|
32288
32323
|
}
|
|
32289
|
-
}, "Add Point")
|
|
32324
|
+
}, "Add Point"), (props.state.focusedPointIndex !== null || props.state.previouslyFocusedPointIndex !== null) && /*#__PURE__*/React__namespace.createElement(Button__default["default"], {
|
|
32325
|
+
kind: "secondary",
|
|
32326
|
+
color: "destructive",
|
|
32327
|
+
tabIndex: 0,
|
|
32328
|
+
style: {
|
|
32329
|
+
width: "100%",
|
|
32330
|
+
marginLeft: "20px"
|
|
32331
|
+
},
|
|
32332
|
+
onClick: event => {
|
|
32333
|
+
props.dispatch(actions.pointGraph.removePoint(props.state.previouslyFocusedPointIndex));
|
|
32334
|
+
}
|
|
32335
|
+
}, "Remove Point"));
|
|
32290
32336
|
const renderGraphControls = props => {
|
|
32291
32337
|
const {
|
|
32292
32338
|
state,
|
|
32293
|
-
dispatch
|
|
32339
|
+
dispatch,
|
|
32340
|
+
width
|
|
32294
32341
|
} = props;
|
|
32295
32342
|
const {
|
|
32296
32343
|
type
|
|
@@ -32300,7 +32347,8 @@ const renderGraphControls = props => {
|
|
|
32300
32347
|
if (state.numPoints === "unlimited") {
|
|
32301
32348
|
return renderPointGraphControls({
|
|
32302
32349
|
state,
|
|
32303
|
-
dispatch
|
|
32350
|
+
dispatch,
|
|
32351
|
+
width
|
|
32304
32352
|
});
|
|
32305
32353
|
}
|
|
32306
32354
|
return null;
|
|
@@ -32474,7 +32522,8 @@ function initializeGraphState(params) {
|
|
|
32474
32522
|
type: graph.type,
|
|
32475
32523
|
coords: getPointCoords(graph, range, step),
|
|
32476
32524
|
numPoints: graph.numPoints || 0,
|
|
32477
|
-
focusedPointIndex: null
|
|
32525
|
+
focusedPointIndex: null,
|
|
32526
|
+
previouslyFocusedPointIndex: null
|
|
32478
32527
|
};
|
|
32479
32528
|
case "circle":
|
|
32480
32529
|
return {
|
|
@@ -32771,6 +32820,7 @@ function doBlurPoint(state, action) {
|
|
|
32771
32820
|
case "point":
|
|
32772
32821
|
return {
|
|
32773
32822
|
...state,
|
|
32823
|
+
previouslyFocusedPointIndex: state.focusedPointIndex,
|
|
32774
32824
|
focusedPointIndex: null
|
|
32775
32825
|
};
|
|
32776
32826
|
default:
|
|
@@ -32817,7 +32867,6 @@ function doMovePointInFigure(state, action) {
|
|
|
32817
32867
|
}
|
|
32818
32868
|
case "angle":
|
|
32819
32869
|
case "circle":
|
|
32820
|
-
throw new Error("FIXME implement circle reducer");
|
|
32821
32870
|
case "point":
|
|
32822
32871
|
case "polygon":
|
|
32823
32872
|
case "quadratic":
|
|
@@ -33143,7 +33192,8 @@ function doRemovePoint(state, action) {
|
|
|
33143
33192
|
return {
|
|
33144
33193
|
...state,
|
|
33145
33194
|
coords: state.coords.filter((_, i) => i !== action.index),
|
|
33146
|
-
focusedPointIndex: null
|
|
33195
|
+
focusedPointIndex: null,
|
|
33196
|
+
previouslyFocusedPointIndex: null
|
|
33147
33197
|
};
|
|
33148
33198
|
}
|
|
33149
33199
|
const getDeltaVertex = (maxMoves, minMoves, delta) => {
|
|
@@ -39967,15 +40017,15 @@ const TickMarks = Graphie.createSimpleClass((graphie, props) => {
|
|
|
39967
40017
|
|
|
39968
40018
|
// Render the text labels
|
|
39969
40019
|
results.push(graphie.style(props.isMobile ? {
|
|
39970
|
-
color: KhanColors.
|
|
40020
|
+
color: KhanColors.BLUE
|
|
39971
40021
|
} : {}, () => _label(graphie, props.labelStyle, leftLabel, leftLabel, base)));
|
|
39972
40022
|
results.push(graphie.style(props.isMobile ? {
|
|
39973
|
-
color: KhanColors.
|
|
40023
|
+
color: KhanColors.BLUE
|
|
39974
40024
|
} : {}, () => _label(graphie, props.labelStyle, rightLabel, rightLabel, base)));
|
|
39975
40025
|
|
|
39976
40026
|
// Render the labels' lines
|
|
39977
40027
|
graphie.style({
|
|
39978
|
-
stroke:
|
|
40028
|
+
stroke: KhanColors.BLUE,
|
|
39979
40029
|
strokeWidth: 3.5
|
|
39980
40030
|
}, () => {
|
|
39981
40031
|
results.push(graphie.line([leftLabel, -0.2], [leftLabel, 0.2]));
|
|
@@ -40162,21 +40212,21 @@ class NumberLine extends React__namespace.Component {
|
|
|
40162
40212
|
if (isOpen) {
|
|
40163
40213
|
fill = KhanColors._BACKGROUND;
|
|
40164
40214
|
} else if (props.static) {
|
|
40165
|
-
fill = KhanColors.
|
|
40215
|
+
fill = KhanColors.BLUE;
|
|
40166
40216
|
} else {
|
|
40167
|
-
fill = KhanColors.
|
|
40217
|
+
fill = KhanColors.GREEN;
|
|
40168
40218
|
}
|
|
40169
40219
|
const normalStyle = {
|
|
40170
40220
|
fill: fill,
|
|
40171
|
-
stroke: props.static ? KhanColors.
|
|
40221
|
+
stroke: props.static ? KhanColors.BLUE : KhanColors.GREEN,
|
|
40172
40222
|
"stroke-width": isOpen ? 3 : 1
|
|
40173
40223
|
};
|
|
40174
40224
|
const highlightStyle = {
|
|
40175
|
-
fill: isOpen ? KhanColors._BACKGROUND : KhanColors.
|
|
40225
|
+
fill: isOpen ? KhanColors._BACKGROUND : KhanColors.GREEN,
|
|
40176
40226
|
"stroke-width": isOpen ? 3 : 1
|
|
40177
40227
|
};
|
|
40178
40228
|
const mobileDotStyle = props.isInequality ? {
|
|
40179
|
-
stroke: KhanColors.
|
|
40229
|
+
stroke: KhanColors.GREEN,
|
|
40180
40230
|
"fill-opacity": isOpen ? 0 : 1
|
|
40181
40231
|
} : {};
|
|
40182
40232
|
return /*#__PURE__*/React__namespace.createElement(MovablePoint
|
|
@@ -40236,7 +40286,7 @@ class NumberLine extends React__namespace.Component {
|
|
|
40236
40286
|
const end = this._getInequalityEndpoint(props);
|
|
40237
40287
|
const style = {
|
|
40238
40288
|
arrows: "->",
|
|
40239
|
-
stroke: this.props.apiOptions.isMobile ? KhanColors.
|
|
40289
|
+
stroke: this.props.apiOptions.isMobile ? KhanColors.GREEN : KhanColors.BLUE,
|
|
40240
40290
|
strokeWidth: 3.5
|
|
40241
40291
|
};
|
|
40242
40292
|
const isGreater = ["ge", "gt"].includes(props.rel);
|
|
@@ -44972,7 +45022,7 @@ const init = function (options) {
|
|
|
44972
45022
|
|
|
44973
45023
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44974
45024
|
const libName = "@khanacademy/perseus";
|
|
44975
|
-
const libVersion = "33.
|
|
45025
|
+
const libVersion = "33.2.0";
|
|
44976
45026
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44977
45027
|
|
|
44978
45028
|
const apiVersion = {
|