@khanacademy/perseus 20.4.0 → 20.5.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 +61 -12
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +62 -12
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +1 -1
- package/dist/widgets/interactive-graphs/graphs/index.d.ts +1 -0
- package/dist/widgets/interactive-graphs/graphs/ray.d.ts +5 -0
- package/dist/widgets/interactive-graphs/graphs/types.d.ts +2 -2
- package/dist/widgets/interactive-graphs/types.d.ts +5 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var caretDown = require('@phosphor-icons/core/assets/regular/caret-down.svg');
|
|
|
33
33
|
var caretUp = require('@phosphor-icons/core/assets/regular/caret-up.svg');
|
|
34
34
|
var debounce$1 = require('lodash.debounce');
|
|
35
35
|
var mafs = require('mafs');
|
|
36
|
+
var wonderBlocksTokens = require('@khanacademy/wonder-blocks-tokens');
|
|
36
37
|
var wonderBlocksIcon = require('@khanacademy/wonder-blocks-icon');
|
|
37
38
|
var questionIcon = require('@phosphor-icons/core/regular/question.svg');
|
|
38
39
|
var wonderBlocksTypography = require('@khanacademy/wonder-blocks-typography');
|
|
@@ -28278,6 +28279,18 @@ class Graph extends React__namespace.Component {
|
|
|
28278
28279
|
}
|
|
28279
28280
|
}
|
|
28280
28281
|
|
|
28282
|
+
/**
|
|
28283
|
+
* Takes a style object with color names and converts them to actual
|
|
28284
|
+
* Wonder Blocks color values. This way, we can use colors and their
|
|
28285
|
+
* names in the editor UI without having to convert them back and forth.
|
|
28286
|
+
*/
|
|
28287
|
+
function convertStyle(style) {
|
|
28288
|
+
return {
|
|
28289
|
+
...style,
|
|
28290
|
+
stroke: wonderBlocksTokens.color[style?.stroke || "blue"],
|
|
28291
|
+
fill: wonderBlocksTokens.color[style?.fill || "blue"]
|
|
28292
|
+
};
|
|
28293
|
+
}
|
|
28281
28294
|
const GraphLockedLayer = props => {
|
|
28282
28295
|
const {
|
|
28283
28296
|
lockedFigures
|
|
@@ -28291,7 +28304,7 @@ const GraphLockedLayer = props => {
|
|
|
28291
28304
|
x: x,
|
|
28292
28305
|
y: y,
|
|
28293
28306
|
svgCircleProps: {
|
|
28294
|
-
style: figure.style
|
|
28307
|
+
style: convertStyle(figure.style)
|
|
28295
28308
|
}
|
|
28296
28309
|
});
|
|
28297
28310
|
}
|
|
@@ -28571,7 +28584,8 @@ const LinearGraph = props => {
|
|
|
28571
28584
|
};
|
|
28572
28585
|
const LineView = props => {
|
|
28573
28586
|
const {
|
|
28574
|
-
onMoveLine
|
|
28587
|
+
onMoveLine,
|
|
28588
|
+
onMovePoint,
|
|
28575
28589
|
collinearPair: [start, end],
|
|
28576
28590
|
range,
|
|
28577
28591
|
stroke
|
|
@@ -28579,7 +28593,7 @@ const LineView = props => {
|
|
|
28579
28593
|
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(MovableLine, {
|
|
28580
28594
|
start: start,
|
|
28581
28595
|
end: end,
|
|
28582
|
-
onMove:
|
|
28596
|
+
onMove: onMoveLine,
|
|
28583
28597
|
extend: {
|
|
28584
28598
|
start: true,
|
|
28585
28599
|
end: true,
|
|
@@ -28589,18 +28603,49 @@ const LineView = props => {
|
|
|
28589
28603
|
}), /*#__PURE__*/React__namespace.createElement(StyledMovablePoint, {
|
|
28590
28604
|
point: start,
|
|
28591
28605
|
onMove: newPoint => {
|
|
28592
|
-
|
|
28606
|
+
onMovePoint(0, newPoint);
|
|
28593
28607
|
},
|
|
28594
28608
|
color: stroke
|
|
28595
28609
|
}), /*#__PURE__*/React__namespace.createElement(StyledMovablePoint, {
|
|
28596
28610
|
point: end,
|
|
28597
28611
|
onMove: newPoint => {
|
|
28598
|
-
|
|
28612
|
+
onMovePoint(1, newPoint);
|
|
28599
28613
|
},
|
|
28600
28614
|
color: stroke
|
|
28601
28615
|
}));
|
|
28602
28616
|
};
|
|
28603
28617
|
|
|
28618
|
+
const RayGraph = props => {
|
|
28619
|
+
const {
|
|
28620
|
+
dispatch
|
|
28621
|
+
} = props;
|
|
28622
|
+
const {
|
|
28623
|
+
coords: lines,
|
|
28624
|
+
range
|
|
28625
|
+
} = props.graphState;
|
|
28626
|
+
|
|
28627
|
+
// a ray only has one line
|
|
28628
|
+
const [start, end] = lines[0];
|
|
28629
|
+
const handleMoveLine = delta => dispatch(moveSegment(0, delta));
|
|
28630
|
+
const handleMovePoint = (newPoint, pointIndex) => dispatch(moveControlPoint(0, pointIndex, newPoint));
|
|
28631
|
+
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(MovableLine, {
|
|
28632
|
+
start: start,
|
|
28633
|
+
end: end,
|
|
28634
|
+
onMove: handleMoveLine,
|
|
28635
|
+
extend: {
|
|
28636
|
+
end: true,
|
|
28637
|
+
start: false,
|
|
28638
|
+
range
|
|
28639
|
+
}
|
|
28640
|
+
}), /*#__PURE__*/React__namespace.createElement(StyledMovablePoint, {
|
|
28641
|
+
point: start,
|
|
28642
|
+
onMove: newPoint => handleMovePoint(newPoint, 0)
|
|
28643
|
+
}), /*#__PURE__*/React__namespace.createElement(StyledMovablePoint, {
|
|
28644
|
+
point: end,
|
|
28645
|
+
onMove: newPoint => handleMovePoint(newPoint, 1)
|
|
28646
|
+
}));
|
|
28647
|
+
};
|
|
28648
|
+
|
|
28604
28649
|
const renderLineLabel = (n, _ref) => {
|
|
28605
28650
|
let [min, max] = _ref;
|
|
28606
28651
|
return n !== -1 && n !== min && n !== max;
|
|
@@ -28725,11 +28770,11 @@ function updateAtIndex(args) {
|
|
|
28725
28770
|
}
|
|
28726
28771
|
function setAtIndex(args) {
|
|
28727
28772
|
const {
|
|
28728
|
-
array,
|
|
28773
|
+
array = [],
|
|
28729
28774
|
index,
|
|
28730
28775
|
newValue
|
|
28731
28776
|
} = args;
|
|
28732
|
-
const copy = [...
|
|
28777
|
+
const copy = [...array];
|
|
28733
28778
|
copy[index] = newValue;
|
|
28734
28779
|
// restoring readonly to array
|
|
28735
28780
|
return copy;
|
|
@@ -28775,16 +28820,16 @@ function initializeGraphState(params) {
|
|
|
28775
28820
|
range
|
|
28776
28821
|
})
|
|
28777
28822
|
};
|
|
28778
|
-
// Ray can also fall through into this case-- same type, same default coords
|
|
28779
28823
|
case "linear":
|
|
28780
28824
|
case "linear-system":
|
|
28825
|
+
case "ray":
|
|
28781
28826
|
return {
|
|
28782
28827
|
type: graph.type,
|
|
28783
28828
|
hasBeenInteractedWith: false,
|
|
28784
28829
|
range,
|
|
28785
28830
|
snapStep,
|
|
28786
|
-
//
|
|
28787
|
-
// system has two tuples of points.
|
|
28831
|
+
// Linear and ray graphs have a single tuple of points, while a
|
|
28832
|
+
// linear system has two tuples of points.
|
|
28788
28833
|
coords: getLineCoords(graph, range, step)
|
|
28789
28834
|
};
|
|
28790
28835
|
}
|
|
@@ -28829,9 +28874,9 @@ function getGradableGraph(state, initialGraph) {
|
|
|
28829
28874
|
...initialGraph,
|
|
28830
28875
|
coords: state.coords
|
|
28831
28876
|
};
|
|
28832
|
-
// RAY has the same type as below; can fall through
|
|
28833
28877
|
// coords: CollinearTuple
|
|
28834
28878
|
case state.type === "linear" && initialGraph.type === "linear":
|
|
28879
|
+
case state.type === "ray" && initialGraph.type === "ray":
|
|
28835
28880
|
return {
|
|
28836
28881
|
...initialGraph,
|
|
28837
28882
|
coords: state.coords?.[0]
|
|
@@ -29556,6 +29601,11 @@ const renderGraph = props => {
|
|
|
29556
29601
|
graphState: state,
|
|
29557
29602
|
dispatch: dispatch
|
|
29558
29603
|
});
|
|
29604
|
+
case "ray":
|
|
29605
|
+
return /*#__PURE__*/React__namespace.createElement(RayGraph, {
|
|
29606
|
+
graphState: state,
|
|
29607
|
+
dispatch: dispatch
|
|
29608
|
+
});
|
|
29559
29609
|
default:
|
|
29560
29610
|
return new wonderStuffCore.UnreachableCaseError(type);
|
|
29561
29611
|
}
|
|
@@ -41568,7 +41618,7 @@ const init = function (options) {
|
|
|
41568
41618
|
|
|
41569
41619
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
41570
41620
|
const libName = "@khanacademy/perseus";
|
|
41571
|
-
const libVersion = "20.
|
|
41621
|
+
const libVersion = "20.5.0";
|
|
41572
41622
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
41573
41623
|
|
|
41574
41624
|
const apiVersion = {
|