@khanacademy/perseus-editor 5.1.3 → 5.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/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/package.json +2 -2
|
@@ -3,6 +3,7 @@ import type { LockedPoint } from "@khanacademy/perseus";
|
|
|
3
3
|
export type Props = LockedPoint & {
|
|
4
4
|
onRemove: () => void;
|
|
5
5
|
onChangeCoord: (coord: [number, number]) => void;
|
|
6
|
+
onChangeColor: (color: string) => void;
|
|
6
7
|
};
|
|
7
8
|
declare const LockedPointSettings: (props: Props) => JSX.Element;
|
|
8
9
|
export default LockedPointSettings;
|
package/dist/es/index.js
CHANGED
|
@@ -30,7 +30,7 @@ import * as i18n$1 from '@khanacademy/wonder-blocks-i18n';
|
|
|
30
30
|
|
|
31
31
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
32
32
|
const libName = "@khanacademy/perseus-editor";
|
|
33
|
-
const libVersion = "5.
|
|
33
|
+
const libVersion = "5.2.0";
|
|
34
34
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
35
35
|
|
|
36
36
|
function _extends() {
|
|
@@ -30277,11 +30277,14 @@ function getDefaultFigureForFigureType(type) {
|
|
|
30277
30277
|
*
|
|
30278
30278
|
* Used in the interactive graph editor's locked figures section.
|
|
30279
30279
|
*/
|
|
30280
|
+
const possibleColors = ["purple", "blue", "teal", "green", "gold", "red", "pink"];
|
|
30280
30281
|
const LockedPointSettings = props => {
|
|
30281
30282
|
const {
|
|
30282
30283
|
coord,
|
|
30283
|
-
|
|
30284
|
-
|
|
30284
|
+
style,
|
|
30285
|
+
onChangeColor,
|
|
30286
|
+
onChangeCoord,
|
|
30287
|
+
onRemove
|
|
30285
30288
|
} = props;
|
|
30286
30289
|
const [coordState, setCoordState] = React.useState([
|
|
30287
30290
|
// Using strings to make it easier to work with the text fields.
|
|
@@ -30292,6 +30295,7 @@ const LockedPointSettings = props => {
|
|
|
30292
30295
|
const ids = useUniqueIdWithMock();
|
|
30293
30296
|
const xCoordId = ids.get("x-coord");
|
|
30294
30297
|
const yCoordId = ids.get("y-coord");
|
|
30298
|
+
const colorSelectId = ids.get("color-select");
|
|
30295
30299
|
function handleBlur() {
|
|
30296
30300
|
const validCoord = [getValidNumberFromString(coordState[0]), getValidNumberFromString(coordState[1])];
|
|
30297
30301
|
|
|
@@ -30300,7 +30304,7 @@ const LockedPointSettings = props => {
|
|
|
30300
30304
|
// Update the graph with the new coordinates.
|
|
30301
30305
|
onChangeCoord(validCoord);
|
|
30302
30306
|
}
|
|
30303
|
-
function
|
|
30307
|
+
function handleCoordChange(newValue, coordIndex) {
|
|
30304
30308
|
const newCoord = [...coordState];
|
|
30305
30309
|
newCoord[coordIndex] = newValue;
|
|
30306
30310
|
setCoordState(newCoord);
|
|
@@ -30322,7 +30326,7 @@ const LockedPointSettings = props => {
|
|
|
30322
30326
|
}, "x Coordinate"), /*#__PURE__*/React.createElement(TextField, {
|
|
30323
30327
|
id: xCoordId,
|
|
30324
30328
|
value: coordState[0],
|
|
30325
|
-
onChange: newValue =>
|
|
30329
|
+
onChange: newValue => handleCoordChange(newValue, 0),
|
|
30326
30330
|
onBlur: handleBlur,
|
|
30327
30331
|
style: styles$d.textField
|
|
30328
30332
|
})), /*#__PURE__*/React.createElement(View, {
|
|
@@ -30334,10 +30338,32 @@ const LockedPointSettings = props => {
|
|
|
30334
30338
|
}, "y Coordinate"), /*#__PURE__*/React.createElement(TextField, {
|
|
30335
30339
|
id: yCoordId,
|
|
30336
30340
|
value: coordState[1],
|
|
30337
|
-
onChange: newValue =>
|
|
30341
|
+
onChange: newValue => handleCoordChange(newValue, 1),
|
|
30338
30342
|
onBlur: handleBlur,
|
|
30339
30343
|
style: styles$d.textField
|
|
30340
|
-
})))
|
|
30344
|
+
}))), /*#__PURE__*/React.createElement(View, {
|
|
30345
|
+
style: styles$d.row
|
|
30346
|
+
}, /*#__PURE__*/React.createElement(LabelMedium, {
|
|
30347
|
+
htmlFor: colorSelectId,
|
|
30348
|
+
style: styles$d.label,
|
|
30349
|
+
tag: "label"
|
|
30350
|
+
}, "Color"), /*#__PURE__*/React.createElement(SingleSelect, {
|
|
30351
|
+
id: colorSelectId,
|
|
30352
|
+
selectedValue: (style == null ? void 0 : style.fill) || "blue",
|
|
30353
|
+
onChange: onChangeColor
|
|
30354
|
+
// Placeholder is required, but never gets used.
|
|
30355
|
+
,
|
|
30356
|
+
placeholder: ""
|
|
30357
|
+
}, possibleColors.map(colorName => /*#__PURE__*/React.createElement(OptionItem, {
|
|
30358
|
+
key: colorName,
|
|
30359
|
+
value: colorName,
|
|
30360
|
+
label: colorName,
|
|
30361
|
+
leftAccessory: /*#__PURE__*/React.createElement(View, {
|
|
30362
|
+
style: [styles$d.colorCircle, {
|
|
30363
|
+
backgroundColor: color[colorName]
|
|
30364
|
+
}]
|
|
30365
|
+
})
|
|
30366
|
+
}, colorName)))));
|
|
30341
30367
|
};
|
|
30342
30368
|
const styles$d = StyleSheet.create({
|
|
30343
30369
|
container: {
|
|
@@ -30356,6 +30382,14 @@ const styles$d = StyleSheet.create({
|
|
|
30356
30382
|
},
|
|
30357
30383
|
textField: {
|
|
30358
30384
|
width: spacing.xxxLarge_64
|
|
30385
|
+
},
|
|
30386
|
+
colorCircle: {
|
|
30387
|
+
// Add a white border so that the color circle is visible when
|
|
30388
|
+
// the dropdown option is highlighted with its blue background.
|
|
30389
|
+
border: `2px solid ${color.offWhite}`,
|
|
30390
|
+
borderRadius: "50%",
|
|
30391
|
+
width: spacing.large_24,
|
|
30392
|
+
height: spacing.large_24
|
|
30359
30393
|
}
|
|
30360
30394
|
});
|
|
30361
30395
|
|
|
@@ -30404,13 +30438,26 @@ const LockedFiguresSection = props => {
|
|
|
30404
30438
|
};
|
|
30405
30439
|
onChange(newProps);
|
|
30406
30440
|
}
|
|
30441
|
+
function changeColor(index, colorName) {
|
|
30442
|
+
const lockedFigures = figures || [];
|
|
30443
|
+
const newProps = {
|
|
30444
|
+
lockedFigures: [...lockedFigures.slice(0, index), _extends({}, lockedFigures[index], {
|
|
30445
|
+
style: _extends({}, lockedFigures[index].style, {
|
|
30446
|
+
fill: colorName,
|
|
30447
|
+
stroke: colorName
|
|
30448
|
+
})
|
|
30449
|
+
}), ...lockedFigures.slice(index + 1)]
|
|
30450
|
+
};
|
|
30451
|
+
onChange(newProps);
|
|
30452
|
+
}
|
|
30407
30453
|
return /*#__PURE__*/React.createElement(View, {
|
|
30408
30454
|
style: styles$c.container
|
|
30409
30455
|
}, figures == null ? void 0 : figures.map((figure, index) => /*#__PURE__*/React.createElement(LockedFigureSettings, _extends({
|
|
30410
30456
|
key: `${uniqueId}-locked-${figure}-${index}`
|
|
30411
30457
|
}, figure, {
|
|
30412
|
-
|
|
30413
|
-
onChangeCoord: coord => changeCoord(index, coord)
|
|
30458
|
+
onChangeColor: color => changeColor(index, color),
|
|
30459
|
+
onChangeCoord: coord => changeCoord(index, coord),
|
|
30460
|
+
onRemove: () => removeLockedFigure(index)
|
|
30414
30461
|
}))), /*#__PURE__*/React.createElement(LockedFigureSelect, {
|
|
30415
30462
|
id: `${uniqueId}-select`,
|
|
30416
30463
|
onChange: addLockedFigure
|