@khanacademy/perseus-core 26.3.1 → 27.0.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.
Files changed (41) hide show
  1. package/dist/data-schema.d.ts +31 -3
  2. package/dist/es/index.item-splitting.js +3 -3
  3. package/dist/es/index.item-splitting.js.map +1 -1
  4. package/dist/es/index.js +7 -7
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/index.item-splitting.js +3 -3
  7. package/dist/index.item-splitting.js.map +1 -1
  8. package/dist/index.js +7 -7
  9. package/dist/index.js.map +1 -1
  10. package/dist/parse-perseus-json/perseus-parsers/interactive-graph-user-input.d.ts +15 -0
  11. package/dist/parse-perseus-json/perseus-parsers/interactive-graph-widget.d.ts +62 -17
  12. package/dist/parse-perseus-json/perseus-parsers/numeric-input-widget.d.ts +0 -1
  13. package/dist/widgets/categorizer/index.d.ts +2 -1
  14. package/dist/widgets/core-widget-registry.d.ts +1 -1
  15. package/dist/widgets/cs-program/index.d.ts +1 -1
  16. package/dist/widgets/dropdown/index.d.ts +2 -1
  17. package/dist/widgets/expression/index.d.ts +2 -1
  18. package/dist/widgets/free-response/free-response-util.d.ts +1 -2
  19. package/dist/widgets/free-response/index.d.ts +2 -1
  20. package/dist/widgets/grapher/index.d.ts +2 -1
  21. package/dist/widgets/group/group-util.d.ts +1 -2
  22. package/dist/widgets/group/index.d.ts +2 -1
  23. package/dist/widgets/iframe/index.d.ts +1 -1
  24. package/dist/widgets/image/index.d.ts +1 -1
  25. package/dist/widgets/input-number/index.d.ts +2 -1
  26. package/dist/widgets/input-number/input-number-util.d.ts +1 -2
  27. package/dist/widgets/interactive-graph/index.d.ts +2 -1
  28. package/dist/widgets/label-image/index.d.ts +2 -1
  29. package/dist/widgets/logic-export.types.d.ts +4 -4
  30. package/dist/widgets/matcher/index.d.ts +2 -1
  31. package/dist/widgets/matrix/index.d.ts +2 -1
  32. package/dist/widgets/number-line/index.d.ts +2 -1
  33. package/dist/widgets/numeric-input/index.d.ts +2 -1
  34. package/dist/widgets/numeric-input/numeric-input-util.d.ts +1 -2
  35. package/dist/widgets/orderer/index.d.ts +2 -1
  36. package/dist/widgets/plotter/index.d.ts +2 -1
  37. package/dist/widgets/radio/index.d.ts +2 -1
  38. package/dist/widgets/sorter/index.d.ts +2 -1
  39. package/dist/widgets/table/index.d.ts +2 -1
  40. package/dist/widgets/table/table-util.d.ts +1 -2
  41. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
+ import type { InputNumberPublicWidgetOptions } from "./input-number-util";
1
2
  import type { PerseusInputNumberWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type InputNumberDefaultWidgetOptions = Pick<PerseusInputNumberWidgetOptions, "value" | "simplify" | "size" | "inexact" | "maxError" | "answerType" | "rightAlign">;
4
- declare const inputNumberWidgetLogic: WidgetLogic;
5
+ declare const inputNumberWidgetLogic: WidgetLogic<PerseusInputNumberWidgetOptions, InputNumberPublicWidgetOptions>;
5
6
  export default inputNumberWidgetLogic;
@@ -3,10 +3,9 @@ import type { PerseusInputNumberWidgetOptions } from "../../data-schema";
3
3
  * For details on the individual options, see the
4
4
  * PerseusInputNumberWidgetOptions type
5
5
  */
6
- type InputNumberPublicWidgetOptions = Pick<PerseusInputNumberWidgetOptions, "answerType" | "inexact" | "maxError" | "rightAlign" | "simplify" | "size">;
6
+ export type InputNumberPublicWidgetOptions = Pick<PerseusInputNumberWidgetOptions, "answerType" | "inexact" | "maxError" | "rightAlign" | "simplify" | "size">;
7
7
  /**
8
8
  * Given a PerseusInputNumberWidgetOptions object, return a new object with only
9
9
  * the public options that should be exposed to the client.
10
10
  */
11
11
  export declare function getInputNumberPublicWidgetOptions(options: PerseusInputNumberWidgetOptions): InputNumberPublicWidgetOptions;
12
- export {};
@@ -1,5 +1,6 @@
1
+ import type { InteractiveGraphPublicWidgetOptions } from "./interactive-graph-util";
1
2
  import type { PerseusInteractiveGraphWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type InteractiveGraphDefaultWidgetOptions = Pick<PerseusInteractiveGraphWidgetOptions, "labels" | "labelLocation" | "lockedFigures" | "range" | "step" | "backgroundImage" | "markings" | "showAxisArrows" | "showAxisTicks" | "showTooltips" | "showProtractor" | "graph" | "correct">;
4
- declare const interactiveGraphWidgetLogic: WidgetLogic;
5
+ declare const interactiveGraphWidgetLogic: WidgetLogic<PerseusInteractiveGraphWidgetOptions, InteractiveGraphPublicWidgetOptions>;
5
6
  export default interactiveGraphWidgetLogic;
@@ -1,5 +1,6 @@
1
+ import type { LabelImagePublicWidgetOptions } from "./label-image-util";
1
2
  import type { PerseusLabelImageWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type LabelImageDefaultWidgetOptions = Pick<PerseusLabelImageWidgetOptions, "choices" | "imageAlt" | "imageUrl" | "imageWidth" | "imageHeight" | "markers" | "multipleAnswers" | "hideChoicesFromInstructions">;
4
- declare const labelImageWidgetLogic: WidgetLogic;
5
+ declare const labelImageWidgetLogic: WidgetLogic<PerseusLabelImageWidgetOptions, LabelImagePublicWidgetOptions>;
5
6
  export default labelImageWidgetLogic;
@@ -18,7 +18,7 @@ import type { getPlotterPublicWidgetOptions } from "./plotter/plotter-util";
18
18
  import type { getRadioPublicWidgetOptions } from "./radio/radio-util";
19
19
  import type { getSorterPublicWidgetOptions } from "./sorter/sorter-util";
20
20
  import type { getTablePublicWidgetOptions } from "./table/table-util";
21
- import type { PerseusWidgetOptions, Version } from "../data-schema";
21
+ import type { Version } from "../data-schema";
22
22
  import type { Alignment } from "../types";
23
23
  export type WidgetOptionsUpgradeMap = {
24
24
  [targetMajorVersion: string]: (arg1: any) => any;
@@ -30,17 +30,17 @@ export type WidgetOptionsUpgradeMap = {
30
30
  * so reliant on a set group of widgets
31
31
  */
32
32
  export type PublicWidgetOptionsFunction = typeof getCategorizerPublicWidgetOptions | typeof getCSProgramPublicWidgetOptions | typeof getDropdownPublicWidgetOptions | typeof getExpressionPublicWidgetOptions | typeof getFreeResponsePublicWidgetOptions | typeof getGrapherPublicWidgetOptions | typeof getGroupPublicWidgetOptions | typeof getIFramePublicWidgetOptions | typeof getInputNumberPublicWidgetOptions | typeof getInteractiveGraphPublicWidgetOptions | typeof getLabelImagePublicWidgetOptions | typeof getMatcherPublicWidgetOptions | typeof getMatrixPublicWidgetOptions | typeof getNumberLinePublicWidgetOptions | typeof getNumericInputPublicWidgetOptions | typeof getOrdererPublicWidgetOptions | typeof getPlotterPublicWidgetOptions | typeof getRadioPublicWidgetOptions | typeof getSorterPublicWidgetOptions | typeof getTablePublicWidgetOptions;
33
- export type WidgetLogic = {
33
+ export type WidgetLogic<TWidgetOptions = never, TPublicWidgetOptions = never> = {
34
34
  name: string;
35
35
  version?: Version;
36
36
  defaultWidgetOptions?: any;
37
37
  supportedAlignments?: ReadonlyArray<Alignment>;
38
38
  defaultAlignment?: Alignment;
39
- accessible?: boolean | ((options: PerseusWidgetOptions) => boolean);
39
+ accessible?: boolean | ((options: TWidgetOptions) => boolean);
40
40
  traverseChildWidgets?: (props: any, traverseRenderer: any) => any;
41
41
  /**
42
42
  * A function that provides a public version of the widget options that can
43
43
  * be shared with the client.
44
44
  */
45
- getPublicWidgetOptions?: PublicWidgetOptionsFunction;
45
+ getPublicWidgetOptions?: (options: TWidgetOptions) => TPublicWidgetOptions;
46
46
  };
@@ -1,5 +1,6 @@
1
+ import type { MatcherPublicWidgetOptions } from "./matcher-util";
1
2
  import type { PerseusMatcherWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type MatcherDefaultWidgetOptions = Pick<PerseusMatcherWidgetOptions, "left" | "right" | "labels" | "orderMatters" | "padding">;
4
- declare const matcherWidgetLogic: WidgetLogic;
5
+ declare const matcherWidgetLogic: WidgetLogic<PerseusMatcherWidgetOptions, MatcherPublicWidgetOptions>;
5
6
  export default matcherWidgetLogic;
@@ -1,5 +1,6 @@
1
+ import type { MatrixPublicWidgetOptions } from "./matrix-util";
1
2
  import type { PerseusMatrixWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type MatrixDefaultWidgetOptions = Pick<PerseusMatrixWidgetOptions, "matrixBoardSize" | "answers" | "prefix" | "suffix" | "cursorPosition">;
4
- declare const matrixWidgetLogic: WidgetLogic;
5
+ declare const matrixWidgetLogic: WidgetLogic<PerseusMatrixWidgetOptions, MatrixPublicWidgetOptions>;
5
6
  export default matrixWidgetLogic;
@@ -1,5 +1,6 @@
1
+ import type { NumberLinePublicWidgetOptions } from "./number-line-util";
1
2
  import type { PerseusNumberLineWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type NumberLineDefaultWidgetOptions = Pick<PerseusNumberLineWidgetOptions, "range" | "labelRange" | "labelStyle" | "labelTicks" | "divisionRange" | "numDivisions" | "snapDivisions" | "tickStep" | "correctRel" | "correctX" | "initialX" | "showTooltips">;
4
- declare const numberLineWidgetLogic: WidgetLogic;
5
+ declare const numberLineWidgetLogic: WidgetLogic<PerseusNumberLineWidgetOptions, NumberLinePublicWidgetOptions>;
5
6
  export default numberLineWidgetLogic;
@@ -1,5 +1,6 @@
1
+ import type { NumericInputPublicWidgetOptions } from "./numeric-input-util";
1
2
  import type { PerseusNumericInputWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type NumericInputDefaultWidgetOptions = Pick<PerseusNumericInputWidgetOptions, "answers" | "size" | "coefficient" | "labelText" | "rightAlign">;
4
- declare const numericInputWidgetLogic: WidgetLogic;
5
+ declare const numericInputWidgetLogic: WidgetLogic<PerseusNumericInputWidgetOptions, NumericInputPublicWidgetOptions>;
5
6
  export default numericInputWidgetLogic;
@@ -4,12 +4,11 @@ type NumericInputAnswerPublicData = Pick<PerseusNumericInputAnswer, "answerForms
4
4
  * For details on the individual options, see the
5
5
  * PerseusNumericInputWidgetOptions type
6
6
  */
7
- type NumericInputPublicWidgetOptions = {
7
+ export type NumericInputPublicWidgetOptions = {
8
8
  labelText?: PerseusNumericInputWidgetOptions["labelText"];
9
9
  size: PerseusNumericInputWidgetOptions["size"];
10
10
  coefficient: PerseusNumericInputWidgetOptions["coefficient"];
11
11
  rightAlign?: PerseusNumericInputWidgetOptions["rightAlign"];
12
- static: PerseusNumericInputWidgetOptions["static"];
13
12
  answers: ReadonlyArray<NumericInputAnswerPublicData>;
14
13
  };
15
14
  /**
@@ -1,5 +1,6 @@
1
+ import type { OrdererPublicWidgetOptions } from "./orderer-util";
1
2
  import type { PerseusOrdererWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type OrdererDefaultWidgetOptions = Pick<PerseusOrdererWidgetOptions, "correctOptions" | "otherOptions" | "height" | "layout">;
4
- declare const ordererWidgetLogic: WidgetLogic;
5
+ declare const ordererWidgetLogic: WidgetLogic<PerseusOrdererWidgetOptions, OrdererPublicWidgetOptions>;
5
6
  export default ordererWidgetLogic;
@@ -1,5 +1,6 @@
1
+ import type { PlotterPublicWidgetOptions } from "./plotter-util";
1
2
  import type { PerseusPlotterWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type PlotterDefaultWidgetOptions = Pick<PerseusPlotterWidgetOptions, "scaleY" | "maxY" | "snapsPerLine" | "correct" | "starting" | "type" | "labels" | "categories" | "picSize" | "picBoxHeight" | "plotDimensions" | "labelInterval" | "picUrl">;
4
- declare const plotterWidgetLogic: WidgetLogic;
5
+ declare const plotterWidgetLogic: WidgetLogic<PerseusPlotterWidgetOptions, PlotterPublicWidgetOptions>;
5
6
  export default plotterWidgetLogic;
@@ -1,5 +1,6 @@
1
+ import type { RadioPublicWidgetOptions } from "./radio-util";
1
2
  import type { PerseusRadioWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type RadioDefaultWidgetOptions = Pick<PerseusRadioWidgetOptions, "choices" | "randomize" | "hasNoneOfTheAbove" | "multipleSelect" | "countChoices" | "deselectEnabled">;
4
- declare const radioWidgetLogic: WidgetLogic;
5
+ declare const radioWidgetLogic: WidgetLogic<PerseusRadioWidgetOptions, RadioPublicWidgetOptions>;
5
6
  export default radioWidgetLogic;
@@ -1,5 +1,6 @@
1
+ import type { SorterPublicWidgetOptions } from "./sorter-util";
1
2
  import type { PerseusSorterWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type SorterDefaultWidgetOptions = Pick<PerseusSorterWidgetOptions, "correct" | "layout" | "padding">;
4
- declare const sorterWidgetLogic: WidgetLogic;
5
+ declare const sorterWidgetLogic: WidgetLogic<PerseusSorterWidgetOptions, SorterPublicWidgetOptions>;
5
6
  export default sorterWidgetLogic;
@@ -1,5 +1,6 @@
1
+ import type { TablePublicWidgetOptions } from "./table-util";
1
2
  import type { PerseusTableWidgetOptions } from "../../data-schema";
2
3
  import type { WidgetLogic } from "../logic-export.types";
3
4
  export type TableDefaultWidgetOptions = Pick<PerseusTableWidgetOptions, "headers" | "rows" | "columns" | "answers">;
4
- declare const tableWidgetLogic: WidgetLogic;
5
+ declare const tableWidgetLogic: WidgetLogic<PerseusTableWidgetOptions, TablePublicWidgetOptions>;
5
6
  export default tableWidgetLogic;
@@ -1,4 +1,3 @@
1
1
  import type { PerseusTableWidgetOptions } from "../../data-schema";
2
- type TablePublicWidgetOptions = Pick<PerseusTableWidgetOptions, "headers" | "rows" | "columns">;
2
+ export type TablePublicWidgetOptions = Pick<PerseusTableWidgetOptions, "headers" | "rows" | "columns">;
3
3
  export declare function getTablePublicWidgetOptions(options: PerseusTableWidgetOptions): TablePublicWidgetOptions;
4
- export {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Shared Perseus infrastructure",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "26.3.1",
6
+ "version": "27.0.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },