@khanacademy/perseus-core 36.1.0 → 38.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 (61) hide show
  1. package/dist/data-schema.d.ts +9 -29
  2. package/dist/es/index.item-splitting.js +14 -10
  3. package/dist/es/index.item-splitting.js.map +1 -1
  4. package/dist/es/index.js +26 -20
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/index.d.ts +9 -61
  7. package/dist/index.item-splitting.js +14 -10
  8. package/dist/index.item-splitting.js.map +1 -1
  9. package/dist/index.js +30 -19
  10. package/dist/index.js.map +1 -1
  11. package/dist/parse-perseus-json/perseus-parsers/categorizer-widget.d.ts +0 -1
  12. package/dist/parse-perseus-json/perseus-parsers/definition-widget.d.ts +0 -1
  13. package/dist/parse-perseus-json/perseus-parsers/dropdown-widget.d.ts +0 -1
  14. package/dist/parse-perseus-json/perseus-parsers/explanation-widget.d.ts +0 -1
  15. package/dist/parse-perseus-json/perseus-parsers/graded-group-set-widget.d.ts +0 -3
  16. package/dist/parse-perseus-json/perseus-parsers/graded-group-widget.d.ts +0 -6
  17. package/dist/parse-perseus-json/perseus-parsers/iframe-widget.d.ts +0 -1
  18. package/dist/parse-perseus-json/perseus-parsers/interaction-widget.d.ts +0 -1
  19. package/dist/parse-perseus-json/perseus-parsers/label-image-widget.d.ts +0 -1
  20. package/dist/parse-perseus-json/perseus-parsers/number-line-widget.d.ts +0 -1
  21. package/dist/parse-perseus-json/perseus-parsers/video-widget.d.ts +0 -1
  22. package/dist/utils/generators/table-widget-generator.d.ts +10 -0
  23. package/dist/utils/widget-prop-denylist.d.ts +5 -0
  24. package/dist/validation.types.d.ts +8 -228
  25. package/dist/widgets/categorizer/categorizer-util.d.ts +0 -1
  26. package/dist/widgets/categorizer/index.d.ts +0 -1
  27. package/dist/widgets/cs-program/index.d.ts +0 -1
  28. package/dist/widgets/definition/index.d.ts +0 -2
  29. package/dist/widgets/dropdown/dropdown-util.d.ts +0 -1
  30. package/dist/widgets/dropdown/index.d.ts +0 -1
  31. package/dist/widgets/explanation/index.d.ts +0 -2
  32. package/dist/widgets/expression/index.d.ts +0 -1
  33. package/dist/widgets/free-response/index.d.ts +0 -1
  34. package/dist/widgets/graded-group/index.d.ts +0 -2
  35. package/dist/widgets/graded-group-set/index.d.ts +0 -2
  36. package/dist/widgets/grapher/index.d.ts +0 -1
  37. package/dist/widgets/group/index.d.ts +0 -1
  38. package/dist/widgets/iframe/index.d.ts +0 -1
  39. package/dist/widgets/image/index.d.ts +0 -1
  40. package/dist/widgets/input-number/index.d.ts +0 -1
  41. package/dist/widgets/interaction/index.d.ts +0 -2
  42. package/dist/widgets/interactive-graph/index.d.ts +0 -1
  43. package/dist/widgets/label-image/index.d.ts +0 -1
  44. package/dist/widgets/label-image/label-image-util.d.ts +0 -1
  45. package/dist/widgets/matcher/index.d.ts +0 -1
  46. package/dist/widgets/matrix/index.d.ts +0 -1
  47. package/dist/widgets/measurer/index.d.ts +0 -2
  48. package/dist/widgets/number-line/index.d.ts +0 -1
  49. package/dist/widgets/number-line/number-line-util.d.ts +1 -1
  50. package/dist/widgets/numeric-input/index.d.ts +0 -1
  51. package/dist/widgets/orderer/index.d.ts +0 -1
  52. package/dist/widgets/orderer/orderer-util.d.ts +11 -1
  53. package/dist/widgets/phet-simulation/index.d.ts +0 -2
  54. package/dist/widgets/plotter/index.d.ts +0 -1
  55. package/dist/widgets/python-program/index.d.ts +0 -2
  56. package/dist/widgets/radio/index.d.ts +0 -1
  57. package/dist/widgets/sorter/index.d.ts +0 -1
  58. package/dist/widgets/sorter/sorter-util.d.ts +12 -1
  59. package/dist/widgets/table/index.d.ts +0 -1
  60. package/dist/widgets/video/index.d.ts +0 -2
  61. package/package.json +1 -1
@@ -1,6 +1,5 @@
1
1
  import type { LabelImagePublicWidgetOptions } from "./label-image-util";
2
2
  import type { PerseusLabelImageWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type LabelImageDefaultWidgetOptions = Pick<PerseusLabelImageWidgetOptions, "choices" | "imageAlt" | "imageUrl" | "imageWidth" | "imageHeight" | "markers" | "multipleAnswers" | "hideChoicesFromInstructions">;
5
4
  declare const labelImageWidgetLogic: WidgetLogic<PerseusLabelImageWidgetOptions, LabelImagePublicWidgetOptions>;
6
5
  export default labelImageWidgetLogic;
@@ -12,7 +12,6 @@ export type LabelImagePublicWidgetOptions = {
12
12
  markers: ReadonlyArray<LabelImageMarkerPublicData>;
13
13
  hideChoicesFromInstructions: PerseusLabelImageWidgetOptions["hideChoicesFromInstructions"];
14
14
  multipleAnswers: PerseusLabelImageWidgetOptions["multipleAnswers"];
15
- static: PerseusLabelImageWidgetOptions["static"];
16
15
  };
17
16
  export type LabelImageMarkerPublicData = Pick<PerseusLabelImageMarker, "x" | "y" | "label">;
18
17
  export declare function getLabelImagePublicWidgetOptions(options: PerseusLabelImageWidgetOptions): LabelImagePublicWidgetOptions;
@@ -1,6 +1,5 @@
1
1
  import type { MatcherPublicWidgetOptions } from "./matcher-util";
2
2
  import type { PerseusMatcherWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type MatcherDefaultWidgetOptions = Pick<PerseusMatcherWidgetOptions, "left" | "right" | "labels" | "orderMatters" | "padding">;
5
4
  declare const matcherWidgetLogic: WidgetLogic<PerseusMatcherWidgetOptions, MatcherPublicWidgetOptions>;
6
5
  export default matcherWidgetLogic;
@@ -1,6 +1,5 @@
1
1
  import type { MatrixPublicWidgetOptions } from "./matrix-util";
2
2
  import type { PerseusMatrixWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type MatrixDefaultWidgetOptions = Pick<PerseusMatrixWidgetOptions, "matrixBoardSize" | "answers" | "prefix" | "suffix">;
5
4
  declare const matrixWidgetLogic: WidgetLogic<PerseusMatrixWidgetOptions, MatrixPublicWidgetOptions>;
6
5
  export default matrixWidgetLogic;
@@ -1,5 +1,3 @@
1
- import type { PerseusMeasurerWidgetOptions } from "../../data-schema";
2
1
  import type { WidgetLogic } from "../logic-export.types";
3
- export type MeasurerDefaultWidgetOptions = Pick<PerseusMeasurerWidgetOptions, "box" | "image" | "showProtractor" | "showRuler" | "rulerLabel" | "rulerTicks" | "rulerPixels" | "rulerLength">;
4
2
  declare const measurerWidgetLogic: WidgetLogic;
5
3
  export default measurerWidgetLogic;
@@ -1,6 +1,5 @@
1
1
  import type { NumberLinePublicWidgetOptions } from "./number-line-util";
2
2
  import type { PerseusNumberLineWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type NumberLineDefaultWidgetOptions = Pick<PerseusNumberLineWidgetOptions, "range" | "labelRange" | "labelStyle" | "labelTicks" | "divisionRange" | "numDivisions" | "snapDivisions" | "tickStep" | "correctRel" | "correctX" | "initialX" | "showTooltips">;
5
4
  declare const numberLineWidgetLogic: WidgetLogic<PerseusNumberLineWidgetOptions, NumberLinePublicWidgetOptions>;
6
5
  export default numberLineWidgetLogic;
@@ -1,3 +1,3 @@
1
1
  import type { PerseusNumberLineWidgetOptions } from "../../data-schema";
2
- export type NumberLinePublicWidgetOptions = Pick<PerseusNumberLineWidgetOptions, "range" | "labelRange" | "labelStyle" | "labelTicks" | "isTickCtrl" | "isInequality" | "divisionRange" | "numDivisions" | "snapDivisions" | "tickStep" | "initialX" | "showTooltips" | "static">;
2
+ export type NumberLinePublicWidgetOptions = Pick<PerseusNumberLineWidgetOptions, "range" | "labelRange" | "labelStyle" | "labelTicks" | "isTickCtrl" | "isInequality" | "divisionRange" | "numDivisions" | "snapDivisions" | "tickStep" | "initialX" | "showTooltips">;
3
3
  export declare function getNumberLinePublicWidgetOptions(options: PerseusNumberLineWidgetOptions): NumberLinePublicWidgetOptions;
@@ -1,6 +1,5 @@
1
1
  import type { NumericInputPublicWidgetOptions } from "./numeric-input-util";
2
2
  import type { PerseusNumericInputWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type NumericInputDefaultWidgetOptions = Pick<PerseusNumericInputWidgetOptions, "answers" | "size" | "coefficient" | "labelText" | "textAlign">;
5
4
  declare const numericInputWidgetLogic: WidgetLogic<PerseusNumericInputWidgetOptions, NumericInputPublicWidgetOptions>;
6
5
  export default numericInputWidgetLogic;
@@ -1,6 +1,5 @@
1
1
  import type { OrdererPublicWidgetOptions } from "./orderer-util";
2
2
  import type { PerseusOrdererWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type OrdererDefaultWidgetOptions = Pick<PerseusOrdererWidgetOptions, "correctOptions" | "otherOptions" | "height" | "layout">;
5
4
  declare const ordererWidgetLogic: WidgetLogic<PerseusOrdererWidgetOptions, OrdererPublicWidgetOptions>;
6
5
  export default ordererWidgetLogic;
@@ -1,4 +1,4 @@
1
- import type { PerseusOrdererWidgetOptions } from "../../data-schema";
1
+ import type { PerseusOrdererWidgetOptions, PerseusRenderer } from "../../data-schema";
2
2
  /**
3
3
  * For details on the individual options, see the
4
4
  * PerseusOrdererWidgetOptions type
@@ -9,3 +9,13 @@ export type OrdererPublicWidgetOptions = Pick<PerseusOrdererWidgetOptions, "opti
9
9
  * the public options that should be exposed to the client.
10
10
  */
11
11
  export declare function getOrdererPublicWidgetOptions(fullOptions: PerseusOrdererWidgetOptions): OrdererPublicWidgetOptions;
12
+ export declare function toCard(content: string): PerseusRenderer;
13
+ /**
14
+ * The cards the student picks from: the correct answer and the distractors,
15
+ * with duplicates and empty cards removed.
16
+ *
17
+ * The sort is what keeps the answer ordering out of the card bank, so this is
18
+ * the only way `options` should ever be derived — it ships to the client
19
+ * verbatim via getOrdererPublicWidgetOptions.
20
+ */
21
+ export declare function mergeCards(correctOptions: PerseusRenderer[], otherOptions: PerseusRenderer[]): PerseusRenderer[];
@@ -1,5 +1,3 @@
1
- import type { PerseusPhetSimulationWidgetOptions } from "../../data-schema";
2
1
  import type { WidgetLogic } from "../logic-export.types";
3
- export type PhetSimulationDefaultWidgetOptions = Pick<PerseusPhetSimulationWidgetOptions, "url" | "description">;
4
2
  declare const phetSimulationWidgetLogic: WidgetLogic;
5
3
  export default phetSimulationWidgetLogic;
@@ -1,6 +1,5 @@
1
1
  import type { PlotterPublicWidgetOptions } from "./plotter-util";
2
2
  import type { PerseusPlotterWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type PlotterDefaultWidgetOptions = Pick<PerseusPlotterWidgetOptions, "scaleY" | "maxY" | "snapsPerLine" | "correct" | "starting" | "type" | "labels" | "categories" | "picSize" | "picBoxHeight" | "plotDimensions" | "labelInterval" | "picUrl">;
5
4
  declare const plotterWidgetLogic: WidgetLogic<PerseusPlotterWidgetOptions, PlotterPublicWidgetOptions>;
6
5
  export default plotterWidgetLogic;
@@ -1,5 +1,3 @@
1
- import type { PerseusPythonProgramWidgetOptions } from "../../data-schema";
2
1
  import type { WidgetLogic } from "../logic-export.types";
3
- export type PythonProgramDefaultWidgetOptions = Pick<PerseusPythonProgramWidgetOptions, "programID" | "height">;
4
2
  declare const pythonProgramWidgetLogic: WidgetLogic;
5
3
  export default pythonProgramWidgetLogic;
@@ -1,6 +1,5 @@
1
1
  import type { RadioPublicWidgetOptions } from "./radio-util";
2
2
  import type { PerseusRadioWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type RadioDefaultWidgetOptions = Pick<PerseusRadioWidgetOptions, "choices" | "randomize" | "hasNoneOfTheAbove" | "multipleSelect" | "countChoices" | "deselectEnabled">;
5
4
  declare const radioWidgetLogic: WidgetLogic<PerseusRadioWidgetOptions, RadioPublicWidgetOptions>;
6
5
  export default radioWidgetLogic;
@@ -1,6 +1,5 @@
1
1
  import type { SorterPublicWidgetOptions } from "./sorter-util";
2
2
  import type { PerseusSorterWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type SorterDefaultWidgetOptions = Pick<PerseusSorterWidgetOptions, "correct" | "layout" | "padding">;
5
4
  declare const sorterWidgetLogic: WidgetLogic<PerseusSorterWidgetOptions, SorterPublicWidgetOptions>;
6
5
  export default sorterWidgetLogic;
@@ -4,9 +4,20 @@ import type { PerseusSorterWidgetOptions } from "../../data-schema";
4
4
  * PerseusSorterWidgetOptions type
5
5
  */
6
6
  export type SorterPublicWidgetOptions = {
7
+ layout: PerseusSorterWidgetOptions["layout"];
8
+ /**
9
+ * `correct` is the wrong term, because it's not
10
+ * in the correct order when in SorterPublicWidgetOptions
11
+ *
12
+ * TODO(LEMS-4535): rename this
13
+ */
7
14
  correct: PerseusSorterWidgetOptions["correct"];
15
+ /**
16
+ * @deprecated
17
+ *
18
+ * TODO(LEMS-4538): remove padding from Sorter
19
+ */
8
20
  padding: PerseusSorterWidgetOptions["padding"];
9
- layout: PerseusSorterWidgetOptions["layout"];
10
21
  };
11
22
  /**
12
23
  * Given a PerseusSorterWidgetOptions object, return a new object with only
@@ -1,6 +1,5 @@
1
1
  import type { TablePublicWidgetOptions } from "./table-util";
2
2
  import type { PerseusTableWidgetOptions } from "../../data-schema";
3
3
  import type { WidgetLogic } from "../logic-export.types";
4
- export type TableDefaultWidgetOptions = Pick<PerseusTableWidgetOptions, "headers" | "rows" | "columns" | "answers">;
5
4
  declare const tableWidgetLogic: WidgetLogic<PerseusTableWidgetOptions, TablePublicWidgetOptions>;
6
5
  export default tableWidgetLogic;
@@ -1,5 +1,3 @@
1
- import type { PerseusVideoWidgetOptions } from "../../data-schema";
2
1
  import type { WidgetLogic } from "../logic-export.types";
3
- export type VideoDefaultWidgetOptions = Pick<PerseusVideoWidgetOptions, "location">;
4
2
  declare const videoWidgetLogic: WidgetLogic;
5
3
  export default videoWidgetLogic;
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": "36.1.0",
6
+ "version": "38.0.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },