@khanacademy/perseus-editor 5.1.4 → 5.2.1
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/components/blur-input.d.ts +2 -0
- package/dist/components/link.d.ts +2 -0
- package/dist/components/locked-point-settings.d.ts +1 -0
- package/dist/es/index.js +56 -9
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +58 -9
- package/dist/index.js.map +1 -1
- package/dist/widgets/interactive-graph-editor.d.ts +2290 -856
- package/dist/widgets/unit-editor.d.ts +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -70,7 +70,7 @@ var i18n__namespace = /*#__PURE__*/_interopNamespace(i18n$1);
|
|
|
70
70
|
|
|
71
71
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
72
72
|
const libName = "@khanacademy/perseus-editor";
|
|
73
|
-
const libVersion = "5.1
|
|
73
|
+
const libVersion = "5.2.1";
|
|
74
74
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
75
75
|
|
|
76
76
|
function _extends() {
|
|
@@ -30353,11 +30353,14 @@ function getDefaultFigureForFigureType(type) {
|
|
|
30353
30353
|
*
|
|
30354
30354
|
* Used in the interactive graph editor's locked figures section.
|
|
30355
30355
|
*/
|
|
30356
|
+
const possibleColors = ["purple", "blue", "teal", "green", "gold", "red", "pink"];
|
|
30356
30357
|
const LockedPointSettings = props => {
|
|
30357
30358
|
const {
|
|
30358
30359
|
coord,
|
|
30359
|
-
|
|
30360
|
-
|
|
30360
|
+
style,
|
|
30361
|
+
onChangeColor,
|
|
30362
|
+
onChangeCoord,
|
|
30363
|
+
onRemove
|
|
30361
30364
|
} = props;
|
|
30362
30365
|
const [coordState, setCoordState] = React__namespace.useState([
|
|
30363
30366
|
// Using strings to make it easier to work with the text fields.
|
|
@@ -30368,6 +30371,7 @@ const LockedPointSettings = props => {
|
|
|
30368
30371
|
const ids = wonderBlocksCore.useUniqueIdWithMock();
|
|
30369
30372
|
const xCoordId = ids.get("x-coord");
|
|
30370
30373
|
const yCoordId = ids.get("y-coord");
|
|
30374
|
+
const colorSelectId = ids.get("color-select");
|
|
30371
30375
|
function handleBlur() {
|
|
30372
30376
|
const validCoord = [getValidNumberFromString(coordState[0]), getValidNumberFromString(coordState[1])];
|
|
30373
30377
|
|
|
@@ -30376,7 +30380,7 @@ const LockedPointSettings = props => {
|
|
|
30376
30380
|
// Update the graph with the new coordinates.
|
|
30377
30381
|
onChangeCoord(validCoord);
|
|
30378
30382
|
}
|
|
30379
|
-
function
|
|
30383
|
+
function handleCoordChange(newValue, coordIndex) {
|
|
30380
30384
|
const newCoord = [...coordState];
|
|
30381
30385
|
newCoord[coordIndex] = newValue;
|
|
30382
30386
|
setCoordState(newCoord);
|
|
@@ -30398,7 +30402,7 @@ const LockedPointSettings = props => {
|
|
|
30398
30402
|
}, "x Coordinate"), /*#__PURE__*/React__namespace.createElement(wonderBlocksForm.TextField, {
|
|
30399
30403
|
id: xCoordId,
|
|
30400
30404
|
value: coordState[0],
|
|
30401
|
-
onChange: newValue =>
|
|
30405
|
+
onChange: newValue => handleCoordChange(newValue, 0),
|
|
30402
30406
|
onBlur: handleBlur,
|
|
30403
30407
|
style: styles$d.textField
|
|
30404
30408
|
})), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
@@ -30410,10 +30414,32 @@ const LockedPointSettings = props => {
|
|
|
30410
30414
|
}, "y Coordinate"), /*#__PURE__*/React__namespace.createElement(wonderBlocksForm.TextField, {
|
|
30411
30415
|
id: yCoordId,
|
|
30412
30416
|
value: coordState[1],
|
|
30413
|
-
onChange: newValue =>
|
|
30417
|
+
onChange: newValue => handleCoordChange(newValue, 1),
|
|
30414
30418
|
onBlur: handleBlur,
|
|
30415
30419
|
style: styles$d.textField
|
|
30416
|
-
})))
|
|
30420
|
+
}))), /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
30421
|
+
style: styles$d.row
|
|
30422
|
+
}, /*#__PURE__*/React__namespace.createElement(wonderBlocksTypography.LabelMedium, {
|
|
30423
|
+
htmlFor: colorSelectId,
|
|
30424
|
+
style: styles$d.label,
|
|
30425
|
+
tag: "label"
|
|
30426
|
+
}, "Color"), /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.SingleSelect, {
|
|
30427
|
+
id: colorSelectId,
|
|
30428
|
+
selectedValue: style?.fill || "blue",
|
|
30429
|
+
onChange: onChangeColor
|
|
30430
|
+
// Placeholder is required, but never gets used.
|
|
30431
|
+
,
|
|
30432
|
+
placeholder: ""
|
|
30433
|
+
}, possibleColors.map(colorName => /*#__PURE__*/React__namespace.createElement(wonderBlocksDropdown.OptionItem, {
|
|
30434
|
+
key: colorName,
|
|
30435
|
+
value: colorName,
|
|
30436
|
+
label: colorName,
|
|
30437
|
+
leftAccessory: /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
30438
|
+
style: [styles$d.colorCircle, {
|
|
30439
|
+
backgroundColor: wonderBlocksTokens.color[colorName]
|
|
30440
|
+
}]
|
|
30441
|
+
})
|
|
30442
|
+
}, colorName)))));
|
|
30417
30443
|
};
|
|
30418
30444
|
const styles$d = aphrodite.StyleSheet.create({
|
|
30419
30445
|
container: {
|
|
@@ -30432,6 +30458,14 @@ const styles$d = aphrodite.StyleSheet.create({
|
|
|
30432
30458
|
},
|
|
30433
30459
|
textField: {
|
|
30434
30460
|
width: wonderBlocksTokens.spacing.xxxLarge_64
|
|
30461
|
+
},
|
|
30462
|
+
colorCircle: {
|
|
30463
|
+
// Add a white border so that the color circle is visible when
|
|
30464
|
+
// the dropdown option is highlighted with its blue background.
|
|
30465
|
+
border: `2px solid ${wonderBlocksTokens.color.offWhite}`,
|
|
30466
|
+
borderRadius: "50%",
|
|
30467
|
+
width: wonderBlocksTokens.spacing.large_24,
|
|
30468
|
+
height: wonderBlocksTokens.spacing.large_24
|
|
30435
30469
|
}
|
|
30436
30470
|
});
|
|
30437
30471
|
|
|
@@ -30481,13 +30515,28 @@ const LockedFiguresSection = props => {
|
|
|
30481
30515
|
};
|
|
30482
30516
|
onChange(newProps);
|
|
30483
30517
|
}
|
|
30518
|
+
function changeColor(index, colorName) {
|
|
30519
|
+
const lockedFigures = figures || [];
|
|
30520
|
+
const newProps = {
|
|
30521
|
+
lockedFigures: [...lockedFigures.slice(0, index), {
|
|
30522
|
+
...lockedFigures[index],
|
|
30523
|
+
style: {
|
|
30524
|
+
...lockedFigures[index].style,
|
|
30525
|
+
fill: colorName,
|
|
30526
|
+
stroke: colorName
|
|
30527
|
+
}
|
|
30528
|
+
}, ...lockedFigures.slice(index + 1)]
|
|
30529
|
+
};
|
|
30530
|
+
onChange(newProps);
|
|
30531
|
+
}
|
|
30484
30532
|
return /*#__PURE__*/React__namespace.createElement(wonderBlocksCore.View, {
|
|
30485
30533
|
style: styles$c.container
|
|
30486
30534
|
}, figures?.map((figure, index) => /*#__PURE__*/React__namespace.createElement(LockedFigureSettings, _extends({
|
|
30487
30535
|
key: `${uniqueId}-locked-${figure}-${index}`
|
|
30488
30536
|
}, figure, {
|
|
30489
|
-
|
|
30490
|
-
onChangeCoord: coord => changeCoord(index, coord)
|
|
30537
|
+
onChangeColor: color => changeColor(index, color),
|
|
30538
|
+
onChangeCoord: coord => changeCoord(index, coord),
|
|
30539
|
+
onRemove: () => removeLockedFigure(index)
|
|
30491
30540
|
}))), /*#__PURE__*/React__namespace.createElement(LockedFigureSelect, {
|
|
30492
30541
|
id: `${uniqueId}-select`,
|
|
30493
30542
|
onChange: addLockedFigure
|