@khanacademy/perseus 19.3.0 → 19.4.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/graph.d.ts +3 -2
- package/dist/es/index.js +70 -3
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +75 -2
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +13 -2
- package/dist/util/test-utils.d.ts +12 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { Coord } from "../interactive2/types";
|
|
3
|
-
import type { PerseusImageBackground } from "../perseus-types";
|
|
3
|
+
import type { PerseusImageBackground, LockedFigure } from "../perseus-types";
|
|
4
4
|
import type { GridDimensions } from "../util";
|
|
5
5
|
type Props = {
|
|
6
6
|
box: [number, number];
|
|
@@ -9,7 +9,7 @@ type Props = {
|
|
|
9
9
|
step: [number, number];
|
|
10
10
|
gridStep: [number, number];
|
|
11
11
|
snapStep: [number, number];
|
|
12
|
-
markings:
|
|
12
|
+
markings: "graph" | "grid" | "none";
|
|
13
13
|
backgroundImage: PerseusImageBackground;
|
|
14
14
|
showProtractor: boolean;
|
|
15
15
|
showRuler: boolean;
|
|
@@ -17,6 +17,7 @@ type Props = {
|
|
|
17
17
|
rulerTicks: number;
|
|
18
18
|
instructions?: string;
|
|
19
19
|
isMobile: boolean;
|
|
20
|
+
lockedFigures?: ReadonlyArray<LockedFigure>;
|
|
20
21
|
onGraphieUpdated?: (graphie: any) => void;
|
|
21
22
|
onClick?: (Coord: any) => void;
|
|
22
23
|
onMouseDown?: (Coord: any) => void;
|
package/dist/es/index.js
CHANGED
|
@@ -28042,6 +28042,33 @@ class Graph extends React.Component {
|
|
|
28042
28042
|
allowScratchpad: true,
|
|
28043
28043
|
setDrawingAreaAvailable: this.props.setDrawingAreaAvailable
|
|
28044
28044
|
});
|
|
28045
|
+
|
|
28046
|
+
// Maybe move this out later
|
|
28047
|
+
if (this.props.lockedFigures) {
|
|
28048
|
+
for (const lockedFigure of this.props.lockedFigures) {
|
|
28049
|
+
switch (lockedFigure.type) {
|
|
28050
|
+
case "point":
|
|
28051
|
+
graphie.circle(
|
|
28052
|
+
// center
|
|
28053
|
+
lockedFigure.coord,
|
|
28054
|
+
// radius
|
|
28055
|
+
0.2,
|
|
28056
|
+
// style
|
|
28057
|
+
lockedFigure.style);
|
|
28058
|
+
break;
|
|
28059
|
+
default:
|
|
28060
|
+
/**
|
|
28061
|
+
* Devlopment-time future-proofing: This `never` should
|
|
28062
|
+
* fail during type-checking if we add a new locked
|
|
28063
|
+
* shape type and forget to handle it in any other
|
|
28064
|
+
* switch case here.
|
|
28065
|
+
*/
|
|
28066
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28067
|
+
lockedFigure.type;
|
|
28068
|
+
throw new Error(`Unknown locked shape type: ${lockedFigure.type}`);
|
|
28069
|
+
}
|
|
28070
|
+
}
|
|
28071
|
+
}
|
|
28045
28072
|
this._updateProtractor();
|
|
28046
28073
|
this._updateRuler();
|
|
28047
28074
|
|
|
@@ -29422,7 +29449,8 @@ class InteractiveGraph extends React.Component {
|
|
|
29422
29449
|
onMouseDown: onMouseDown,
|
|
29423
29450
|
onGraphieUpdated: this.setGraphie,
|
|
29424
29451
|
setDrawingAreaAvailable: this.props.apiOptions.setDrawingAreaAvailable,
|
|
29425
|
-
isMobile: isMobile
|
|
29452
|
+
isMobile: isMobile,
|
|
29453
|
+
lockedFigures: this.props.lockedFigures
|
|
29426
29454
|
}));
|
|
29427
29455
|
}
|
|
29428
29456
|
static getQuadraticCoefficients(coords) {
|
|
@@ -41552,7 +41580,7 @@ const init = function init(options) {
|
|
|
41552
41580
|
|
|
41553
41581
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
41554
41582
|
const libName = "@khanacademy/perseus";
|
|
41555
|
-
const libVersion = "19.
|
|
41583
|
+
const libVersion = "19.4.0";
|
|
41556
41584
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
41557
41585
|
|
|
41558
41586
|
const apiVersion = {
|
|
@@ -44557,6 +44585,45 @@ function parsePerseusItem(json) {
|
|
|
44557
44585
|
return JSON.parse(json);
|
|
44558
44586
|
}
|
|
44559
44587
|
|
|
44588
|
+
const genericPerseusItemData = {
|
|
44589
|
+
question: {
|
|
44590
|
+
content: "",
|
|
44591
|
+
images: {},
|
|
44592
|
+
widgets: {}
|
|
44593
|
+
},
|
|
44594
|
+
answerArea: {
|
|
44595
|
+
calculator: false,
|
|
44596
|
+
chi2Table: false,
|
|
44597
|
+
periodicTable: false,
|
|
44598
|
+
tTable: false,
|
|
44599
|
+
zTable: false,
|
|
44600
|
+
financialCalculatorMonthlyPayment: false,
|
|
44601
|
+
financialCalculatorTotalAmount: false,
|
|
44602
|
+
financialCalculatorTimeToPayOff: false,
|
|
44603
|
+
periodicTableWithKey: false
|
|
44604
|
+
},
|
|
44605
|
+
itemDataVersion: {
|
|
44606
|
+
major: 0,
|
|
44607
|
+
minor: 1
|
|
44608
|
+
},
|
|
44609
|
+
hints: [],
|
|
44610
|
+
_multi: null,
|
|
44611
|
+
answer: null
|
|
44612
|
+
};
|
|
44613
|
+
|
|
44614
|
+
/**
|
|
44615
|
+
* Generate a Perseus item object for testing purposes.
|
|
44616
|
+
*
|
|
44617
|
+
* In order to better type Perseus objects used in testing, this function
|
|
44618
|
+
* uses a basic Perseus object and updates it with custom values as needed.
|
|
44619
|
+
*
|
|
44620
|
+
* @param {Partial<PerseusItem>} customFields
|
|
44621
|
+
* @returns PerseusItem
|
|
44622
|
+
*/
|
|
44623
|
+
function generateTestPerseusItem(customFields = {}) {
|
|
44624
|
+
return _extends({}, genericPerseusItemData, customFields);
|
|
44625
|
+
}
|
|
44626
|
+
|
|
44560
44627
|
const EditorJsonify = {
|
|
44561
44628
|
serialize: function () {
|
|
44562
44629
|
// Omit props that get passed to all widgets
|
|
@@ -44565,5 +44632,5 @@ const EditorJsonify = {
|
|
|
44565
44632
|
}
|
|
44566
44633
|
};
|
|
44567
44634
|
|
|
44568
|
-
export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemExtras, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, getAnswersFromWidgets, globalConstants, globalStyles, iconPaths as icons, init, injectWidgets, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, mediaQueries, parsePerseusItem, plotterPlotTypes, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
|
|
44635
|
+
export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemExtras, JiptParagraphs, KhanColors, KhanMath, context as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, generateTestPerseusItem, genericPerseusItemData, getAnswersFromWidgets, globalConstants, globalStyles, iconPaths as icons, init, injectWidgets, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, libVersion, mediaQueries, parsePerseusItem, plotterPlotTypes, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
|
|
44569
44636
|
//# sourceMappingURL=index.js.map
|