@khanacademy/perseus-core 3.3.0 → 3.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { PerseusAnalyticsEvent, AnalyticsEventHandlerFn } from "./analytics";
2
- export type { KEScore, KeypadContextRendererInterface, RendererInterface, MarkerType, InteractiveMarkerType, Relationship, } from "./types";
2
+ export type { KEScore, KeypadContextRendererInterface, RendererInterface, MarkerType, InteractiveMarkerType, Relationship, Alignment, } from "./types";
3
3
  export type { ErrorKind } from "./error/errors";
4
4
  export type { FunctionTypeMappingKeys } from "./utils/grapher-util";
5
5
  export type { Coords } from "./utils/grapher-types";
@@ -33,6 +33,8 @@ export { default as gradedGroupLogic } from "./widgets/graded-group";
33
33
  export type { GradedGroupDefaultWidgetOptions } from "./widgets/graded-group";
34
34
  export { default as gradedGroupSetLogic } from "./widgets/graded-group-set";
35
35
  export type { GradedGroupSetDefaultWidgetOptions } from "./widgets/graded-group-set";
36
+ export { default as grapherLogic } from "./widgets/grapher";
37
+ export type { GrapherDefaultWidgetOptions } from "./widgets/grapher";
36
38
  export { default as groupLogic } from "./widgets/group";
37
39
  export type { GroupDefaultWidgetOptions } from "./widgets/group";
38
40
  export { default as iframeLogic } from "./widgets/iframe";
@@ -79,7 +81,15 @@ export { default as tableLogic } from "./widgets/table";
79
81
  export type { TableDefaultWidgetOptions } from "./widgets/table";
80
82
  export { default as videoLogic } from "./widgets/video";
81
83
  export type { VideoDefaultWidgetOptions } from "./widgets/video";
84
+ export { getUpgradedWidgetOptions, upgradeWidgetInfoToLatestVersion, } from "./widgets/upgrade";
82
85
  export type * from "./widgets/logic-export.types";
86
+ export * as CoreWidgetRegistry from "./widgets/core-widget-registry";
83
87
  export { default as getOrdererPublicWidgetOptions } from "./widgets/orderer/orderer-util";
84
88
  export { default as getCategorizerPublicWidgetOptions } from "./widgets/categorizer/categorizer-util";
89
+ export { default as getCSProgramPublicWidgetOptions } from "./widgets/cs-program/cs-program-util";
85
90
  export { default as getExpressionPublicWidgetOptions } from "./widgets/expression/expression-util";
91
+ export { default as getLabelImagePublicWidgetOptions } from "./widgets/label-image/label-image-util";
92
+ export { default as getSorterPublicWidgetOptions } from "./widgets/sorter/sorter-util";
93
+ export { default as getDropdownPublicWidgetOptions } from "./widgets/dropdown/dropdown-util";
94
+ export { default as getNumericInputPublicWidgetOptions } from "./widgets/numeric-input/numeric-input-util";
95
+ export { default as getNumberLinePublicWidgetOptions } from "./widgets/number-line/number-line-util";
package/dist/index.js CHANGED
@@ -4606,7 +4606,7 @@ function throwErrorIfCheatingDetected() {
4606
4606
 
4607
4607
  // This file is processed by a Rollup plugin (replace) to inject the production
4608
4608
  const libName = "@khanacademy/perseus-core";
4609
- const libVersion = "3.3.0";
4609
+ const libVersion = "3.4.0";
4610
4610
  addLibraryVersionToPerseusDebug(libName, libVersion);
4611
4611
 
4612
4612
  /**
@@ -4705,7 +4705,7 @@ const mapObject = function (obj, lambda) {
4705
4705
  return result;
4706
4706
  };
4707
4707
 
4708
- const defaultWidgetOptions$u = {
4708
+ const defaultWidgetOptions$v = {
4709
4709
  items: [],
4710
4710
  categories: [],
4711
4711
  values: [],
@@ -4713,11 +4713,11 @@ const defaultWidgetOptions$u = {
4713
4713
  };
4714
4714
  const categorizerWidgetLogic = {
4715
4715
  name: "categorizer",
4716
- defaultWidgetOptions: defaultWidgetOptions$u
4716
+ defaultWidgetOptions: defaultWidgetOptions$v
4717
4717
  };
4718
4718
 
4719
4719
  const DEFAULT_HEIGHT = 400;
4720
- const defaultWidgetOptions$t = {
4720
+ const defaultWidgetOptions$u = {
4721
4721
  programID: "",
4722
4722
  programType: null,
4723
4723
  settings: [{
@@ -4730,19 +4730,21 @@ const defaultWidgetOptions$t = {
4730
4730
  };
4731
4731
  const csProgramWidgetLogic = {
4732
4732
  name: "cs-program",
4733
- defaultWidgetOptions: defaultWidgetOptions$t
4733
+ defaultWidgetOptions: defaultWidgetOptions$u,
4734
+ supportedAlignments: ["block", "full-width"]
4734
4735
  };
4735
4736
 
4736
- const defaultWidgetOptions$s = {
4737
+ const defaultWidgetOptions$t = {
4737
4738
  togglePrompt: "",
4738
4739
  definition: ""
4739
4740
  };
4740
4741
  const definitionWidgetLogic = {
4741
4742
  name: "definition",
4742
- defaultWidgetOptions: defaultWidgetOptions$s
4743
+ defaultWidgetOptions: defaultWidgetOptions$t,
4744
+ defaultAlignment: "inline"
4743
4745
  };
4744
4746
 
4745
- const defaultWidgetOptions$r = {
4747
+ const defaultWidgetOptions$s = {
4746
4748
  placeholder: "",
4747
4749
  choices: [{
4748
4750
  content: "",
@@ -4751,10 +4753,11 @@ const defaultWidgetOptions$r = {
4751
4753
  };
4752
4754
  const dropdownWidgetLogic = {
4753
4755
  name: "definition",
4754
- defaultWidgetOptions: defaultWidgetOptions$r
4756
+ defaultWidgetOptions: defaultWidgetOptions$s,
4757
+ defaultAlignment: "inline-block"
4755
4758
  };
4756
4759
 
4757
- const defaultWidgetOptions$q = {
4760
+ const defaultWidgetOptions$r = {
4758
4761
  showPrompt: "Explain",
4759
4762
  hidePrompt: "Hide explanation",
4760
4763
  explanation: "explanation goes here\n\nmore explanation",
@@ -4762,7 +4765,8 @@ const defaultWidgetOptions$q = {
4762
4765
  };
4763
4766
  const explanationWidgetLogic = {
4764
4767
  name: "explanation",
4765
- defaultWidgetOptions: defaultWidgetOptions$q
4768
+ defaultWidgetOptions: defaultWidgetOptions$r,
4769
+ defaultAlignment: "inline"
4766
4770
  };
4767
4771
 
4768
4772
  const currentVersion$3 = {
@@ -4785,7 +4789,7 @@ const widgetOptionsUpgrades$2 = {
4785
4789
  }]
4786
4790
  })
4787
4791
  };
4788
- const defaultWidgetOptions$p = {
4792
+ const defaultWidgetOptions$q = {
4789
4793
  answerForms: [],
4790
4794
  times: false,
4791
4795
  buttonSets: ["basic"],
@@ -4796,26 +4800,52 @@ const expressionWidgetLogic = {
4796
4800
  name: "expression",
4797
4801
  version: currentVersion$3,
4798
4802
  widgetOptionsUpgrades: widgetOptionsUpgrades$2,
4799
- defaultWidgetOptions: defaultWidgetOptions$p
4803
+ defaultWidgetOptions: defaultWidgetOptions$q,
4804
+ defaultAlignment: "inline-block"
4800
4805
  };
4801
4806
 
4802
- const defaultWidgetOptions$o = {
4807
+ const defaultWidgetOptions$p = {
4803
4808
  title: "",
4804
4809
  content: "",
4805
4810
  widgets: {},
4806
4811
  images: {},
4807
4812
  hint: null
4808
4813
  };
4809
- const GradedGroupWidgetLogic = {
4814
+ const gradedGroupWidgetLogic = {
4810
4815
  name: "graded-group",
4811
- defaultWidgetOptions: defaultWidgetOptions$o
4816
+ defaultWidgetOptions: defaultWidgetOptions$p
4812
4817
  };
4813
4818
 
4814
- const defaultWidgetOptions$n = {
4819
+ const defaultWidgetOptions$o = {
4815
4820
  gradedGroups: []
4816
4821
  };
4817
- const GradedGroupSetWidgetLogic = {
4822
+ const gradedGroupSetWidgetLogic = {
4818
4823
  name: "graded-group-set",
4824
+ defaultWidgetOptions: defaultWidgetOptions$o
4825
+ };
4826
+
4827
+ const defaultWidgetOptions$n = {
4828
+ graph: {
4829
+ labels: ["x", "y"],
4830
+ range: [[-10, 10], [-10, 10]],
4831
+ step: [1, 1],
4832
+ backgroundImage: {
4833
+ url: null
4834
+ },
4835
+ markings: "graph",
4836
+ rulerLabel: "",
4837
+ rulerTicks: 10,
4838
+ valid: true,
4839
+ showTooltips: false
4840
+ },
4841
+ correct: {
4842
+ type: "linear",
4843
+ coords: null
4844
+ },
4845
+ availableTypes: ["linear"]
4846
+ };
4847
+ const grapherWidgetLogic = {
4848
+ name: "grapher",
4819
4849
  defaultWidgetOptions: defaultWidgetOptions$n
4820
4850
  };
4821
4851
 
@@ -4827,7 +4857,7 @@ const defaultWidgetOptions$m = {
4827
4857
  // `the GroupMetadataEditor`
4828
4858
  metadata: undefined
4829
4859
  };
4830
- const GroupWidgetLogic = {
4860
+ const groupWidgetLogic = {
4831
4861
  name: "group",
4832
4862
  defaultWidgetOptions: defaultWidgetOptions$m
4833
4863
  };
@@ -4863,7 +4893,9 @@ const defaultWidgetOptions$k = {
4863
4893
  };
4864
4894
  const imageWidgetLogic = {
4865
4895
  name: "image",
4866
- defaultWidgetOptions: defaultWidgetOptions$k
4896
+ defaultWidgetOptions: defaultWidgetOptions$k,
4897
+ supportedAlignments: ["block", "full-width"],
4898
+ defaultAlignment: "block"
4867
4899
  };
4868
4900
 
4869
4901
  const defaultWidgetOptions$j = {
@@ -4877,7 +4909,8 @@ const defaultWidgetOptions$j = {
4877
4909
  };
4878
4910
  const inputNumberWidgetLogic = {
4879
4911
  name: "input-number",
4880
- defaultWidgetOptions: defaultWidgetOptions$j
4912
+ defaultWidgetOptions: defaultWidgetOptions$j,
4913
+ defaultAlignment: "inline-block"
4881
4914
  };
4882
4915
 
4883
4916
  const defaultWidgetOptions$i = {
@@ -5034,7 +5067,8 @@ const defaultWidgetOptions$b = {
5034
5067
  };
5035
5068
  const numericInputWidgetLogic = {
5036
5069
  name: "numeric-input",
5037
- defaultWidgetOptions: defaultWidgetOptions$b
5070
+ defaultWidgetOptions: defaultWidgetOptions$b,
5071
+ defaultAlignment: "inline-block"
5038
5072
  };
5039
5073
 
5040
5074
  const defaultWidgetOptions$a = {
@@ -5076,7 +5110,8 @@ const defaultWidgetOptions$8 = {
5076
5110
  const passageRefWidgetLogic = {
5077
5111
  name: "passageRef",
5078
5112
  version: currentVersion$1,
5079
- defaultWidgetOptions: defaultWidgetOptions$8
5113
+ defaultWidgetOptions: defaultWidgetOptions$8,
5114
+ defaultAlignment: "inline"
5080
5115
  };
5081
5116
 
5082
5117
  const defaultWidgetOptions$7 = {
@@ -5084,14 +5119,15 @@ const defaultWidgetOptions$7 = {
5084
5119
  };
5085
5120
  const passageRefTargetWidgetLogic = {
5086
5121
  name: "passageRefTarget",
5087
- defaultWidgetOptions: defaultWidgetOptions$7
5122
+ defaultWidgetOptions: defaultWidgetOptions$7,
5123
+ defaultAlignment: "inline"
5088
5124
  };
5089
5125
 
5090
5126
  const defaultWidgetOptions$6 = {
5091
5127
  url: "",
5092
5128
  description: ""
5093
5129
  };
5094
- const PhetSimulationWidgetLogic = {
5130
+ const phetSimulationWidgetLogic = {
5095
5131
  name: "phet-simulation",
5096
5132
  defaultWidgetOptions: defaultWidgetOptions$6
5097
5133
  };
@@ -5193,9 +5229,242 @@ const defaultWidgetOptions = {
5193
5229
  };
5194
5230
  const videoWidgetLogic = {
5195
5231
  name: "video",
5196
- defaultWidgetOptions
5232
+ defaultWidgetOptions,
5233
+ supportedAlignments: ["block", "float-left", "float-right", "full-width"],
5234
+ defaultAlignment: "block"
5197
5235
  };
5198
5236
 
5237
+ const widgets = {};
5238
+ function registerWidget(type, logic) {
5239
+ widgets[type] = logic;
5240
+ }
5241
+ function isWidgetRegistered(type) {
5242
+ const widgetLogic = widgets[type];
5243
+ return !!widgetLogic;
5244
+ }
5245
+ function getCurrentVersion(type) {
5246
+ const widgetLogic = widgets[type];
5247
+ return widgetLogic?.version || {
5248
+ major: 0,
5249
+ minor: 0
5250
+ };
5251
+ }
5252
+ function getWidgetOptionsUpgrades(type) {
5253
+ const widgetLogic = widgets[type];
5254
+ return widgetLogic?.widgetOptionsUpgrades || {};
5255
+ }
5256
+ function getDefaultWidgetOptions(type) {
5257
+ const widgetLogic = widgets[type];
5258
+ return widgetLogic?.defaultWidgetOptions || {};
5259
+ }
5260
+
5261
+ /**
5262
+ * Handling for the optional alignments for widgets
5263
+ * See widget-container.jsx for details on how alignments are implemented.
5264
+ */
5265
+
5266
+ /**
5267
+ * Returns the list of supported alignments for the given (string) widget
5268
+ * type. This is used primarily at editing time to display the choices
5269
+ * for the user.
5270
+ *
5271
+ * Supported alignments are given as an array of strings in the exports of
5272
+ * a widget's module.
5273
+ */
5274
+ const getSupportedAlignments = type => {
5275
+ const widgetLogic = widgets[type];
5276
+ if (!widgetLogic?.supportedAlignments?.[0]) {
5277
+ // default alignments
5278
+ return ["default"];
5279
+ }
5280
+ return widgetLogic?.supportedAlignments;
5281
+ };
5282
+
5283
+ /**
5284
+ * For the given (string) widget type, determine the default alignment for
5285
+ * the widget. This is used at rendering time to go from "default" alignment
5286
+ * to the actual alignment displayed on the screen.
5287
+ *
5288
+ * The default alignment is given either as a string (called
5289
+ * `defaultAlignment`) or a function (called `getDefaultAlignment`) on
5290
+ * the exports of a widget's module.
5291
+ */
5292
+ const getDefaultAlignment = type => {
5293
+ const widgetLogic = widgets[type];
5294
+ if (!widgetLogic?.defaultAlignment) {
5295
+ return "block";
5296
+ }
5297
+ return widgetLogic.defaultAlignment;
5298
+ };
5299
+ registerWidget("categorizer", categorizerWidgetLogic);
5300
+ registerWidget("cs-program", csProgramWidgetLogic);
5301
+ registerWidget("definition", definitionWidgetLogic);
5302
+ registerWidget("dropdown", dropdownWidgetLogic);
5303
+ registerWidget("explanation", explanationWidgetLogic);
5304
+ registerWidget("expression", expressionWidgetLogic);
5305
+ registerWidget("graded-group", gradedGroupWidgetLogic);
5306
+ registerWidget("graded-group-set", gradedGroupSetWidgetLogic);
5307
+ registerWidget("grapher", grapherWidgetLogic);
5308
+ registerWidget("group", groupWidgetLogic);
5309
+ registerWidget("iframe", iframeWidgetLogic);
5310
+ registerWidget("image", imageWidgetLogic);
5311
+ registerWidget("input-number", inputNumberWidgetLogic);
5312
+ registerWidget("interaction", interactionWidgetLogic);
5313
+ registerWidget("interactive-graph", interactiveGraphWidgetLogic);
5314
+ registerWidget("label-image", labelImageWidgetLogic);
5315
+ registerWidget("matcher", matcherWidgetLogic);
5316
+ registerWidget("matrix", matrixWidgetLogic);
5317
+ registerWidget("measurer", measurerWidgetLogic);
5318
+ registerWidget("number-line", numberLineWidgetLogic);
5319
+ registerWidget("numeric-input", numericInputWidgetLogic);
5320
+ registerWidget("orderer", ordererWidgetLogic);
5321
+ registerWidget("passage", passageWidgetLogic);
5322
+ registerWidget("passage-ref", passageRefWidgetLogic);
5323
+ registerWidget("passage-ref-target", passageRefTargetWidgetLogic);
5324
+ registerWidget("phet-simulation", phetSimulationWidgetLogic);
5325
+ registerWidget("plotter", plotterWidgetLogic);
5326
+ registerWidget("python-program", pythonProgramWidgetLogic);
5327
+ registerWidget("radio", radioWidgetLogic);
5328
+ registerWidget("sorter", sorterWidgetLogic);
5329
+ registerWidget("table", tableWidgetLogic);
5330
+ registerWidget("video", videoWidgetLogic);
5331
+
5332
+ var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
5333
+ __proto__: null,
5334
+ isWidgetRegistered: isWidgetRegistered,
5335
+ getCurrentVersion: getCurrentVersion,
5336
+ getWidgetOptionsUpgrades: getWidgetOptionsUpgrades,
5337
+ getDefaultWidgetOptions: getDefaultWidgetOptions,
5338
+ getSupportedAlignments: getSupportedAlignments,
5339
+ getDefaultAlignment: getDefaultAlignment
5340
+ });
5341
+
5342
+ const DEFAULT_STATIC = false;
5343
+ const upgradeWidgetInfoToLatestVersion = oldWidgetInfo => {
5344
+ const type = oldWidgetInfo.type;
5345
+ // NOTE(jeremy): This looks like it could be replaced by fixing types so
5346
+ // that `type` is non-optional. But we're seeing this in Sentry today so I
5347
+ // suspect we have legacy data (potentially unpublished) and we should
5348
+ // figure that out before depending solely on types.
5349
+ if (!_.isString(type)) {
5350
+ throw new PerseusError("widget type must be a string, but was: " + type, Errors.Internal);
5351
+ }
5352
+ if (!isWidgetRegistered(type)) {
5353
+ // If we have a widget that isn't registered, we can't upgrade it
5354
+ // TODO(aria): Figure out what the best thing to do here would be
5355
+ return oldWidgetInfo;
5356
+ }
5357
+
5358
+ // Unversioned widgets (pre-July 2014) are all implicitly 0.0
5359
+ const initialVersion = oldWidgetInfo.version || {
5360
+ major: 0,
5361
+ minor: 0
5362
+ };
5363
+ const latestVersion = getCurrentVersion(type);
5364
+
5365
+ // If the widget version is later than what we understand (major
5366
+ // version is higher than latest, or major versions are equal and minor
5367
+ // version is higher than latest), don't perform any upgrades.
5368
+ if (initialVersion.major > latestVersion.major || initialVersion.major === latestVersion.major && initialVersion.minor > latestVersion.minor) {
5369
+ return oldWidgetInfo;
5370
+ }
5371
+
5372
+ // We do a clone here so that it's safe to mutate the input parameter
5373
+ // in propUpgrades functions (which I will probably accidentally do at
5374
+ // some point, and we would like to not break when that happens).
5375
+ let newEditorOptions = _.clone(oldWidgetInfo.options) || {};
5376
+ const upgradePropsMap = getWidgetOptionsUpgrades(type);
5377
+
5378
+ // Empty props usually mean a newly created widget by the editor,
5379
+ // and are always considerered up-to-date.
5380
+ // Mostly, we'd rather not run upgrade functions on props that are
5381
+ // not complete.
5382
+ if (_.keys(newEditorOptions).length !== 0) {
5383
+ // We loop through all the versions after the current version of
5384
+ // the loaded widget, up to and including the latest version of the
5385
+ // loaded widget, and run the upgrade function to bring our loaded
5386
+ // widget's props up to that version.
5387
+ // There is a little subtlety here in that we call
5388
+ // upgradePropsMap[1] to upgrade *to* version 1,
5389
+ // (not from version 1).
5390
+ for (let nextVersion = initialVersion.major + 1; nextVersion <= latestVersion.major; nextVersion++) {
5391
+ if (upgradePropsMap[String(nextVersion)]) {
5392
+ newEditorOptions = upgradePropsMap[String(nextVersion)](newEditorOptions);
5393
+ } else {
5394
+ throw new PerseusError("No upgrade found for widget. Cannot render.", Errors.Internal, {
5395
+ metadata: {
5396
+ type,
5397
+ fromMajorVersion: nextVersion - 1,
5398
+ toMajorVersion: nextVersion,
5399
+ oldWidgetInfo: JSON.stringify(oldWidgetInfo)
5400
+ }
5401
+ });
5402
+ }
5403
+ }
5404
+ }
5405
+
5406
+ // Minor version upgrades (eg. new optional props) don't have
5407
+ // transform functions. Instead, we fill in the new props with their
5408
+ // defaults.
5409
+ const defaultOptions = getDefaultWidgetOptions(type);
5410
+ newEditorOptions = {
5411
+ ...defaultOptions,
5412
+ ...newEditorOptions
5413
+ };
5414
+ let alignment = oldWidgetInfo.alignment;
5415
+
5416
+ // Widgets that support multiple alignments will "lock in" the
5417
+ // alignment to the alignment that would be listed first in the
5418
+ // select box. If the widget only supports one alignment, the
5419
+ // alignment value will likely just end up as "default".
5420
+ if (alignment == null || alignment === "default") {
5421
+ alignment = getSupportedAlignments(type)?.[0];
5422
+ if (!alignment) {
5423
+ throw new PerseusError("No default alignment found when upgrading widget", Errors.Internal, {
5424
+ metadata: {
5425
+ widgetType: type
5426
+ }
5427
+ });
5428
+ }
5429
+ }
5430
+ let widgetStatic = oldWidgetInfo.static;
5431
+ if (widgetStatic == null) {
5432
+ widgetStatic = DEFAULT_STATIC;
5433
+ }
5434
+ return {
5435
+ ...oldWidgetInfo,
5436
+ // maintain other info, like type
5437
+ // After upgrading we guarantee that the version is up-to-date
5438
+ version: latestVersion,
5439
+ // Default graded to true (so null/undefined becomes true):
5440
+ graded: oldWidgetInfo.graded != null ? oldWidgetInfo.graded : true,
5441
+ alignment: alignment,
5442
+ static: widgetStatic,
5443
+ options: newEditorOptions
5444
+ };
5445
+ };
5446
+ function getUpgradedWidgetOptions(oldWidgetOptions) {
5447
+ return mapObject(oldWidgetOptions, (widgetInfo, widgetId) => {
5448
+ if (!widgetInfo.type || !widgetInfo.alignment) {
5449
+ const newValues = {};
5450
+ if (!widgetInfo.type) {
5451
+ // TODO: why does widget have no type?
5452
+ // We don't want to derive type from widget ID
5453
+ // see: LEMS-1845
5454
+ newValues.type = widgetId.split(" ")[0];
5455
+ }
5456
+ if (!widgetInfo.alignment) {
5457
+ newValues.alignment = "default";
5458
+ }
5459
+ widgetInfo = {
5460
+ ...widgetInfo,
5461
+ ...newValues
5462
+ };
5463
+ }
5464
+ return upgradeWidgetInfoToLatestVersion(widgetInfo);
5465
+ });
5466
+ }
5467
+
5199
5468
  /**
5200
5469
  * For details on the individual options, see the
5201
5470
  * PerseusOrdererWidgetOptions type
@@ -5231,6 +5500,10 @@ function getCategorizerPublicWidgetOptions(options) {
5231
5500
  };
5232
5501
  }
5233
5502
 
5503
+ function getCSProgramPublicWidgetOptions(options) {
5504
+ return options;
5505
+ }
5506
+
5234
5507
  /**
5235
5508
  * For details on the individual options, see the
5236
5509
  * PerseusExpressionWidgetOptions type
@@ -5251,6 +5524,93 @@ function getExpressionPublicWidgetOptions(options) {
5251
5524
  };
5252
5525
  }
5253
5526
 
5527
+ /**
5528
+ * For details on the individual options, see the
5529
+ * PerseusLabelImageWidgetOptions type
5530
+ */
5531
+
5532
+ function getLabelImagePublicWidgetOptions(options) {
5533
+ return {
5534
+ ...options,
5535
+ markers: options.markers.map(getLabelImageMarkerPublicData)
5536
+ };
5537
+ }
5538
+ function getLabelImageMarkerPublicData(marker) {
5539
+ const {
5540
+ answers: _,
5541
+ ...publicData
5542
+ } = marker;
5543
+ return publicData;
5544
+ }
5545
+
5546
+ /**
5547
+ * For details on the individual options, see the
5548
+ * PerseusSorterWidgetOptions type
5549
+ */
5550
+
5551
+ /**
5552
+ * Given a PerseusSorterWidgetOptions object, return a new object with only
5553
+ * the public options that should be exposed to the client.
5554
+ */
5555
+ function getSorterPublicWidgetOptions(options) {
5556
+ return {
5557
+ // Note(Tamara): This does not provide correct answer information any longer.
5558
+ // To maintain compatibility with the original widget options, we are
5559
+ // keeping the key the same. Represents initial state of the cards here.
5560
+ correct: options.correct.slice().sort(),
5561
+ padding: options.padding,
5562
+ layout: options.layout
5563
+ };
5564
+ }
5565
+
5566
+ /**
5567
+ * For details on the individual options, see the
5568
+ * PerseusDropdownWidgetOptions type
5569
+ */
5570
+
5571
+ /**
5572
+ * Given a PerseusDropdownWidgetOptions object, return a new object with only
5573
+ * the public options that should be exposed to the client.
5574
+ */
5575
+ function getDropdownPublicWidgetOptions(options) {
5576
+ return {
5577
+ choices: options.choices.map(choice => ({
5578
+ content: choice.content
5579
+ })),
5580
+ placeholder: options.placeholder,
5581
+ static: options.static,
5582
+ visibleLabel: options.visibleLabel,
5583
+ ariaLabel: options.ariaLabel
5584
+ };
5585
+ }
5586
+
5587
+ /**
5588
+ * For details on the individual options, see the
5589
+ * PerseusNumericInputWidgetOptions type
5590
+ */
5591
+
5592
+ /**
5593
+ * Given a PerseusNumericInputWidgetOptions object, return a new object with only
5594
+ * the public options that should be exposed to the client.
5595
+ */
5596
+ function getNumericInputPublicWidgetOptions(options) {
5597
+ const {
5598
+ answers: _,
5599
+ ...publicWidgetOptions
5600
+ } = options;
5601
+ return publicWidgetOptions;
5602
+ }
5603
+
5604
+ function getNumberLinePublicWidgetOptions(options) {
5605
+ const {
5606
+ correctX: _,
5607
+ correctRel: __,
5608
+ ...publicOptions
5609
+ } = options;
5610
+ return publicOptions;
5611
+ }
5612
+
5613
+ exports.CoreWidgetRegistry = coreWidgetRegistry;
5254
5614
  exports.Errors = Errors;
5255
5615
  exports.GrapherUtil = grapherUtil;
5256
5616
  exports.ItemExtras = ItemExtras;
@@ -5267,16 +5627,24 @@ exports.definitionLogic = definitionWidgetLogic;
5267
5627
  exports.dropdownLogic = dropdownWidgetLogic;
5268
5628
  exports.explanationLogic = explanationWidgetLogic;
5269
5629
  exports.expressionLogic = expressionWidgetLogic;
5630
+ exports.getCSProgramPublicWidgetOptions = getCSProgramPublicWidgetOptions;
5270
5631
  exports.getCategorizerPublicWidgetOptions = getCategorizerPublicWidgetOptions;
5271
5632
  exports.getDecimalSeparator = getDecimalSeparator;
5633
+ exports.getDropdownPublicWidgetOptions = getDropdownPublicWidgetOptions;
5272
5634
  exports.getExpressionPublicWidgetOptions = getExpressionPublicWidgetOptions;
5635
+ exports.getLabelImagePublicWidgetOptions = getLabelImagePublicWidgetOptions;
5273
5636
  exports.getMatrixSize = getMatrixSize;
5637
+ exports.getNumberLinePublicWidgetOptions = getNumberLinePublicWidgetOptions;
5638
+ exports.getNumericInputPublicWidgetOptions = getNumericInputPublicWidgetOptions;
5274
5639
  exports.getOrdererPublicWidgetOptions = getOrdererPublicWidgetOptions;
5640
+ exports.getSorterPublicWidgetOptions = getSorterPublicWidgetOptions;
5641
+ exports.getUpgradedWidgetOptions = getUpgradedWidgetOptions;
5275
5642
  exports.getWidgetIdsFromContent = getWidgetIdsFromContent;
5276
5643
  exports.getWidgetIdsFromContentByType = getWidgetIdsFromContentByType;
5277
- exports.gradedGroupLogic = GradedGroupWidgetLogic;
5278
- exports.gradedGroupSetLogic = GradedGroupSetWidgetLogic;
5279
- exports.groupLogic = GroupWidgetLogic;
5644
+ exports.gradedGroupLogic = gradedGroupWidgetLogic;
5645
+ exports.gradedGroupSetLogic = gradedGroupSetWidgetLogic;
5646
+ exports.grapherLogic = grapherWidgetLogic;
5647
+ exports.groupLogic = groupWidgetLogic;
5280
5648
  exports.iframeLogic = iframeWidgetLogic;
5281
5649
  exports.imageLogic = imageWidgetLogic;
5282
5650
  exports.inputNumberLogic = inputNumberWidgetLogic;
@@ -5302,7 +5670,7 @@ exports.parsePerseusItem = parsePerseusItem;
5302
5670
  exports.passageLogic = passageWidgetLogic;
5303
5671
  exports.passageRefLogic = passageRefWidgetLogic;
5304
5672
  exports.passageRefTargetLogic = passageRefTargetWidgetLogic;
5305
- exports.phetSimulationLogic = PhetSimulationWidgetLogic;
5673
+ exports.phetSimulationLogic = phetSimulationWidgetLogic;
5306
5674
  exports.plotterLogic = plotterWidgetLogic;
5307
5675
  exports.plotterPlotTypes = plotterPlotTypes;
5308
5676
  exports.pluck = pluck;
@@ -5310,5 +5678,6 @@ exports.pythonProgramLogic = pythonProgramWidgetLogic;
5310
5678
  exports.radioLogic = radioWidgetLogic;
5311
5679
  exports.sorterLogic = sorterWidgetLogic;
5312
5680
  exports.tableLogic = tableWidgetLogic;
5681
+ exports.upgradeWidgetInfoToLatestVersion = upgradeWidgetInfoToLatestVersion;
5313
5682
  exports.videoLogic = videoWidgetLogic;
5314
5683
  //# sourceMappingURL=index.js.map