@khanacademy/perseus-core 3.4.0 → 3.6.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/es/index.js CHANGED
@@ -3156,6 +3156,13 @@ function convert(f) {
3156
3156
  return (rawValue, ctx) => ctx.success(f(rawValue));
3157
3157
  }
3158
3158
 
3159
+ const parseLegacyButtonSet = enumeration("basic", "basic+div", "trig", "prealgebra", "logarithms", "basic relations", "advanced relations", "scientific");
3160
+ const parseLegacyButtonSets = defaulted(array(parseLegacyButtonSet),
3161
+ // NOTE(benchristel): I copied the default buttonSets from
3162
+ // expression.tsx. See the parse-perseus-json/README.md for
3163
+ // an explanation of why we want to duplicate the default here.
3164
+ () => ["basic", "trig", "prealgebra", "logarithms"]);
3165
+
3159
3166
  /**
3160
3167
  * Creates a parser for a widget options type with multiple major versions. Old
3161
3168
  * versions are migrated to the latest version. The parse fails if the input
@@ -3244,11 +3251,6 @@ function removeInvalidAnswerForms(possiblyInvalid) {
3244
3251
  }
3245
3252
  return valid;
3246
3253
  }
3247
-
3248
- // NOTE(benchristel): I copied the default buttonSets from
3249
- // expression.tsx. See the parse-perseus-json/README.md for
3250
- // an explanation of why we want to duplicate the default here.
3251
- const parseButtonSets = defaulted(array(enumeration("basic", "basic+div", "trig", "prealgebra", "logarithms", "basic relations", "advanced relations")), () => ["basic", "trig", "prealgebra", "logarithms"]);
3252
3254
  const version1 = object({
3253
3255
  major: constant(1),
3254
3256
  minor: number
@@ -3259,7 +3261,7 @@ const parseExpressionWidgetV1 = parseWidgetWithVersion(version1, constant("expre
3259
3261
  times: boolean,
3260
3262
  visibleLabel: optional(string),
3261
3263
  ariaLabel: optional(string),
3262
- buttonSets: parseButtonSets,
3264
+ buttonSets: parseLegacyButtonSets,
3263
3265
  buttonsVisible: optional(enumeration("always", "never", "focused"))
3264
3266
  }));
3265
3267
  const version0 = optional(object({
@@ -3274,7 +3276,7 @@ const parseExpressionWidgetV0 = parseWidgetWithVersion(version0, constant("expre
3274
3276
  form: boolean,
3275
3277
  simplify: boolean,
3276
3278
  value: string,
3277
- buttonSets: parseButtonSets,
3279
+ buttonSets: parseLegacyButtonSets,
3278
3280
  buttonsVisible: optional(enumeration("always", "never", "focused"))
3279
3281
  }));
3280
3282
  function migrateV0ToV1(widget) {
@@ -4492,7 +4494,7 @@ function _objectWithoutPropertiesLoose(r, e) {
4492
4494
  if (null == r) return {};
4493
4495
  var t = {};
4494
4496
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
4495
- if (e.includes(n)) continue;
4497
+ if (-1 !== e.indexOf(n)) continue;
4496
4498
  t[n] = r[n];
4497
4499
  }
4498
4500
  return t;
@@ -4506,7 +4508,7 @@ const parseHint = object({
4506
4508
  images: parseImages
4507
4509
  });
4508
4510
 
4509
- const _excluded$5 = ["type", "options"];
4511
+ const _excluded$a = ["type", "options"];
4510
4512
  const parsePerseusItem$1 = object({
4511
4513
  question: parsePerseusRenderer,
4512
4514
  hints: defaulted(array(parseHint), () => []),
@@ -4533,7 +4535,7 @@ const parsePerseusItem$1 = object({
4533
4535
  // The "type" and "options" fields don't seem to be used anywhere. This
4534
4536
  // migration function removes them.
4535
4537
  function migrateAnswerArea(rawValue, ctx) {
4536
- const rest = _objectWithoutPropertiesLoose(rawValue, _excluded$5);
4538
+ const rest = _objectWithoutPropertiesLoose(rawValue, _excluded$a);
4537
4539
  return ctx.success(rest);
4538
4540
  }
4539
4541
 
@@ -4611,7 +4613,7 @@ function throwErrorIfCheatingDetected() {
4611
4613
 
4612
4614
  // This file is processed by a Rollup plugin (replace) to inject the production
4613
4615
  const libName = "@khanacademy/perseus-core";
4614
- const libVersion = "3.4.0";
4616
+ const libVersion = "3.6.0";
4615
4617
  addLibraryVersionToPerseusDebug(libName, libVersion);
4616
4618
 
4617
4619
  /**
@@ -4710,6 +4712,24 @@ const mapObject = function mapObject(obj, lambda) {
4710
4712
  return result;
4711
4713
  };
4712
4714
 
4715
+ /**
4716
+ * For details on the individual options, see the
4717
+ * PerseusCategorizerWidgetOptions type
4718
+ */
4719
+
4720
+ /**
4721
+ * Given a PerseusCategorizerWidgetOptions object, return a new object with only
4722
+ * the public options that should be exposed to the client.
4723
+ */
4724
+ function getCategorizerPublicWidgetOptions(options) {
4725
+ return {
4726
+ items: options.items,
4727
+ categories: options.categories,
4728
+ randomizeItems: options.randomizeItems,
4729
+ static: options.static
4730
+ };
4731
+ }
4732
+
4713
4733
  const defaultWidgetOptions$v = {
4714
4734
  items: [],
4715
4735
  categories: [],
@@ -4718,9 +4738,14 @@ const defaultWidgetOptions$v = {
4718
4738
  };
4719
4739
  const categorizerWidgetLogic = {
4720
4740
  name: "categorizer",
4721
- defaultWidgetOptions: defaultWidgetOptions$v
4741
+ defaultWidgetOptions: defaultWidgetOptions$v,
4742
+ getPublicWidgetOptions: getCategorizerPublicWidgetOptions
4722
4743
  };
4723
4744
 
4745
+ function getCSProgramPublicWidgetOptions(options) {
4746
+ return options;
4747
+ }
4748
+
4724
4749
  const DEFAULT_HEIGHT = 400;
4725
4750
  const defaultWidgetOptions$u = {
4726
4751
  programID: "",
@@ -4736,7 +4761,8 @@ const defaultWidgetOptions$u = {
4736
4761
  const csProgramWidgetLogic = {
4737
4762
  name: "cs-program",
4738
4763
  defaultWidgetOptions: defaultWidgetOptions$u,
4739
- supportedAlignments: ["block", "full-width"]
4764
+ supportedAlignments: ["block", "full-width"],
4765
+ getPublicWidgetOptions: getCSProgramPublicWidgetOptions
4740
4766
  };
4741
4767
 
4742
4768
  const defaultWidgetOptions$t = {
@@ -4749,6 +4775,27 @@ const definitionWidgetLogic = {
4749
4775
  defaultAlignment: "inline"
4750
4776
  };
4751
4777
 
4778
+ /**
4779
+ * For details on the individual options, see the
4780
+ * PerseusDropdownWidgetOptions type
4781
+ */
4782
+
4783
+ /**
4784
+ * Given a PerseusDropdownWidgetOptions object, return a new object with only
4785
+ * the public options that should be exposed to the client.
4786
+ */
4787
+ function getDropdownPublicWidgetOptions(options) {
4788
+ return {
4789
+ choices: options.choices.map(choice => ({
4790
+ content: choice.content
4791
+ })),
4792
+ placeholder: options.placeholder,
4793
+ static: options.static,
4794
+ visibleLabel: options.visibleLabel,
4795
+ ariaLabel: options.ariaLabel
4796
+ };
4797
+ }
4798
+
4752
4799
  const defaultWidgetOptions$s = {
4753
4800
  placeholder: "",
4754
4801
  choices: [{
@@ -4759,7 +4806,8 @@ const defaultWidgetOptions$s = {
4759
4806
  const dropdownWidgetLogic = {
4760
4807
  name: "definition",
4761
4808
  defaultWidgetOptions: defaultWidgetOptions$s,
4762
- defaultAlignment: "inline-block"
4809
+ defaultAlignment: "inline-block",
4810
+ getPublicWidgetOptions: getDropdownPublicWidgetOptions
4763
4811
  };
4764
4812
 
4765
4813
  const defaultWidgetOptions$r = {
@@ -4801,12 +4849,33 @@ const defaultWidgetOptions$q = {
4801
4849
  functions: ["f", "g", "h"]
4802
4850
  };
4803
4851
 
4852
+ /**
4853
+ * For details on the individual options, see the
4854
+ * PerseusExpressionWidgetOptions type
4855
+ */
4856
+
4857
+ /**
4858
+ * Given a PerseusExpressionWidgetOptions object, return a new object with only
4859
+ * the public options that should be exposed to the client.
4860
+ */
4861
+ function getExpressionPublicWidgetOptions(options) {
4862
+ return {
4863
+ buttonSets: options.buttonSets,
4864
+ functions: options.functions,
4865
+ times: options.times,
4866
+ visibleLabel: options.visibleLabel,
4867
+ ariaLabel: options.ariaLabel,
4868
+ buttonsVisible: options.buttonsVisible
4869
+ };
4870
+ }
4871
+
4804
4872
  const expressionWidgetLogic = {
4805
4873
  name: "expression",
4806
4874
  version: currentVersion$3,
4807
4875
  widgetOptionsUpgrades: widgetOptionsUpgrades$2,
4808
4876
  defaultWidgetOptions: defaultWidgetOptions$q,
4809
- defaultAlignment: "inline-block"
4877
+ defaultAlignment: "inline-block",
4878
+ getPublicWidgetOptions: getExpressionPublicWidgetOptions
4810
4879
  };
4811
4880
 
4812
4881
  const defaultWidgetOptions$p = {
@@ -4829,6 +4898,12 @@ const gradedGroupSetWidgetLogic = {
4829
4898
  defaultWidgetOptions: defaultWidgetOptions$o
4830
4899
  };
4831
4900
 
4901
+ const _excluded$9 = ["correct"];
4902
+ function getGrapherPublicWidgetOptions(options) {
4903
+ const publicOptions = _objectWithoutPropertiesLoose(options, _excluded$9);
4904
+ return publicOptions;
4905
+ }
4906
+
4832
4907
  const defaultWidgetOptions$n = {
4833
4908
  graph: {
4834
4909
  labels: ["x", "y"],
@@ -4851,7 +4926,8 @@ const defaultWidgetOptions$n = {
4851
4926
  };
4852
4927
  const grapherWidgetLogic = {
4853
4928
  name: "grapher",
4854
- defaultWidgetOptions: defaultWidgetOptions$n
4929
+ defaultWidgetOptions: defaultWidgetOptions$n,
4930
+ getPublicWidgetOptions: getGrapherPublicWidgetOptions
4855
4931
  };
4856
4932
 
4857
4933
  const defaultWidgetOptions$m = {
@@ -4867,6 +4943,10 @@ const groupWidgetLogic = {
4867
4943
  defaultWidgetOptions: defaultWidgetOptions$m
4868
4944
  };
4869
4945
 
4946
+ function getIFramePublicWidgetOptions(options) {
4947
+ return options;
4948
+ }
4949
+
4870
4950
  const defaultWidgetOptions$l = {
4871
4951
  url: "",
4872
4952
  settings: [{
@@ -4880,7 +4960,8 @@ const defaultWidgetOptions$l = {
4880
4960
  };
4881
4961
  const iframeWidgetLogic = {
4882
4962
  name: "iframe",
4883
- defaultWidgetOptions: defaultWidgetOptions$l
4963
+ defaultWidgetOptions: defaultWidgetOptions$l,
4964
+ getPublicWidgetOptions: getIFramePublicWidgetOptions
4884
4965
  };
4885
4966
 
4886
4967
  const defaultWidgetOptions$k = {
@@ -4934,6 +5015,12 @@ const interactionWidgetLogic = {
4934
5015
  defaultWidgetOptions: defaultWidgetOptions$i
4935
5016
  };
4936
5017
 
5018
+ const _excluded$8 = ["correct"];
5019
+ function getInteractiveGraphPublicWidgetOptions(options) {
5020
+ const publicOptions = _objectWithoutPropertiesLoose(options, _excluded$8);
5021
+ return publicOptions;
5022
+ }
5023
+
4937
5024
  const defaultWidgetOptions$h = {
4938
5025
  labels: ["x", "y"],
4939
5026
  range: [[-10, 10], [-10, 10]],
@@ -4954,9 +5041,26 @@ const defaultWidgetOptions$h = {
4954
5041
  };
4955
5042
  const interactiveGraphWidgetLogic = {
4956
5043
  name: "interactive-graph",
4957
- defaultWidgetOptions: defaultWidgetOptions$h
5044
+ defaultWidgetOptions: defaultWidgetOptions$h,
5045
+ getPublicWidgetOptions: getInteractiveGraphPublicWidgetOptions
4958
5046
  };
4959
5047
 
5048
+ const _excluded$7 = ["answers"];
5049
+ /**
5050
+ * For details on the individual options, see the
5051
+ * PerseusLabelImageWidgetOptions type
5052
+ */
5053
+
5054
+ function getLabelImagePublicWidgetOptions(options) {
5055
+ return _extends({}, options, {
5056
+ markers: options.markers.map(getLabelImageMarkerPublicData)
5057
+ });
5058
+ }
5059
+ function getLabelImageMarkerPublicData(marker) {
5060
+ const publicData = _objectWithoutPropertiesLoose(marker, _excluded$7);
5061
+ return publicData;
5062
+ }
5063
+
4960
5064
  const defaultWidgetOptions$g = {
4961
5065
  choices: [],
4962
5066
  imageAlt: "",
@@ -4969,7 +5073,8 @@ const defaultWidgetOptions$g = {
4969
5073
  };
4970
5074
  const labelImageWidgetLogic = {
4971
5075
  name: "label-image",
4972
- defaultWidgetOptions: defaultWidgetOptions$g
5076
+ defaultWidgetOptions: defaultWidgetOptions$g,
5077
+ getPublicWidgetOptions: getLabelImagePublicWidgetOptions
4973
5078
  };
4974
5079
 
4975
5080
  const defaultWidgetOptions$f = {
@@ -4984,6 +5089,12 @@ const matcherWidgetLogic = {
4984
5089
  defaultWidgetOptions: defaultWidgetOptions$f
4985
5090
  };
4986
5091
 
5092
+ const _excluded$6 = ["answers"];
5093
+ function getMatrixPublicWidgetOptions(options) {
5094
+ const publicOptions = _objectWithoutPropertiesLoose(options, _excluded$6);
5095
+ return publicOptions;
5096
+ }
5097
+
4987
5098
  const defaultWidgetOptions$e = {
4988
5099
  matrixBoardSize: [3, 3],
4989
5100
  answers: [[]],
@@ -4993,10 +5104,11 @@ const defaultWidgetOptions$e = {
4993
5104
  };
4994
5105
  const matrixWidgetLogic = {
4995
5106
  name: "matrix",
4996
- defaultWidgetOptions: defaultWidgetOptions$e
5107
+ defaultWidgetOptions: defaultWidgetOptions$e,
5108
+ getPublicWidgetOptions: getMatrixPublicWidgetOptions
4997
5109
  };
4998
5110
 
4999
- const _excluded$4 = ["imageUrl", "imageTop", "imageLeft"];
5111
+ const _excluded$5 = ["imageUrl", "imageTop", "imageLeft"];
5000
5112
  const currentVersion$2 = {
5001
5113
  major: 1,
5002
5114
  minor: 0
@@ -5008,7 +5120,7 @@ const widgetOptionsUpgrades$1 = {
5008
5120
  imageTop,
5009
5121
  imageLeft
5010
5122
  } = v0options,
5011
- rest = _objectWithoutPropertiesLoose(v0options, _excluded$4);
5123
+ rest = _objectWithoutPropertiesLoose(v0options, _excluded$5);
5012
5124
  return _extends({}, rest, {
5013
5125
  image: {
5014
5126
  url: imageUrl,
@@ -5036,6 +5148,12 @@ const measurerWidgetLogic = {
5036
5148
  defaultWidgetOptions: defaultWidgetOptions$d
5037
5149
  };
5038
5150
 
5151
+ const _excluded$4 = ["correctX", "correctRel"];
5152
+ function getNumberLinePublicWidgetOptions(options) {
5153
+ const publicOptions = _objectWithoutPropertiesLoose(options, _excluded$4);
5154
+ return publicOptions;
5155
+ }
5156
+
5039
5157
  const defaultWidgetOptions$c = {
5040
5158
  range: [0, 10],
5041
5159
  labelRange: [null, null],
@@ -5052,9 +5170,25 @@ const defaultWidgetOptions$c = {
5052
5170
  };
5053
5171
  const numberLineWidgetLogic = {
5054
5172
  name: "number-line",
5055
- defaultWidgetOptions: defaultWidgetOptions$c
5173
+ defaultWidgetOptions: defaultWidgetOptions$c,
5174
+ getPublicWidgetOptions: getNumberLinePublicWidgetOptions
5056
5175
  };
5057
5176
 
5177
+ const _excluded$3 = ["answers"];
5178
+ /**
5179
+ * For details on the individual options, see the
5180
+ * PerseusNumericInputWidgetOptions type
5181
+ */
5182
+
5183
+ /**
5184
+ * Given a PerseusNumericInputWidgetOptions object, return a new object with only
5185
+ * the public options that should be exposed to the client.
5186
+ */
5187
+ function getNumericInputPublicWidgetOptions(options) {
5188
+ const publicWidgetOptions = _objectWithoutPropertiesLoose(options, _excluded$3);
5189
+ return publicWidgetOptions;
5190
+ }
5191
+
5058
5192
  const defaultWidgetOptions$b = {
5059
5193
  answers: [{
5060
5194
  value: null,
@@ -5073,9 +5207,27 @@ const defaultWidgetOptions$b = {
5073
5207
  const numericInputWidgetLogic = {
5074
5208
  name: "numeric-input",
5075
5209
  defaultWidgetOptions: defaultWidgetOptions$b,
5076
- defaultAlignment: "inline-block"
5210
+ defaultAlignment: "inline-block",
5211
+ getPublicWidgetOptions: getNumericInputPublicWidgetOptions
5077
5212
  };
5078
5213
 
5214
+ /**
5215
+ * For details on the individual options, see the
5216
+ * PerseusOrdererWidgetOptions type
5217
+ */
5218
+
5219
+ /**
5220
+ * Given a PerseusOrdererWidgetOptions object, return a new object with only
5221
+ * the public options that should be exposed to the client.
5222
+ */
5223
+ function getOrdererPublicWidgetOptions(options) {
5224
+ return {
5225
+ options: options.options,
5226
+ height: options.height,
5227
+ layout: options.layout
5228
+ };
5229
+ }
5230
+
5079
5231
  const defaultWidgetOptions$a = {
5080
5232
  correctOptions: [{
5081
5233
  content: "$x$"
@@ -5088,7 +5240,8 @@ const defaultWidgetOptions$a = {
5088
5240
  };
5089
5241
  const ordererWidgetLogic = {
5090
5242
  name: "orderer",
5091
- defaultWidgetOptions: defaultWidgetOptions$a
5243
+ defaultWidgetOptions: defaultWidgetOptions$a,
5244
+ getPublicWidgetOptions: getOrdererPublicWidgetOptions
5092
5245
  };
5093
5246
 
5094
5247
  const defaultWidgetOptions$9 = {
@@ -5137,6 +5290,21 @@ const phetSimulationWidgetLogic = {
5137
5290
  defaultWidgetOptions: defaultWidgetOptions$6
5138
5291
  };
5139
5292
 
5293
+ const _excluded$2 = ["correct"];
5294
+ /**
5295
+ * For details on the individual options, see the
5296
+ * PerseusPlotterWidgetOptions type
5297
+ */
5298
+
5299
+ /**
5300
+ * Given a PerseusPlotterWidgetOptions object, return a new object with only
5301
+ * the public options that should be exposed to the client.
5302
+ */
5303
+ function getPlotterPublicWidgetOptions(options) {
5304
+ const publicOptions = _objectWithoutPropertiesLoose(options, _excluded$2);
5305
+ return publicOptions;
5306
+ }
5307
+
5140
5308
  const defaultWidgetOptions$5 = {
5141
5309
  scaleY: 1,
5142
5310
  maxY: 10,
@@ -5154,7 +5322,8 @@ const defaultWidgetOptions$5 = {
5154
5322
  };
5155
5323
  const plotterWidgetLogic = {
5156
5324
  name: "plotter",
5157
- defaultWidgetOptions: defaultWidgetOptions$5
5325
+ defaultWidgetOptions: defaultWidgetOptions$5,
5326
+ getPublicWidgetOptions: getPlotterPublicWidgetOptions
5158
5327
  };
5159
5328
 
5160
5329
  const defaultWidgetOptions$4 = {
@@ -5166,7 +5335,7 @@ const pythonProgramWidgetLogic = {
5166
5335
  defaultWidgetOptions: defaultWidgetOptions$4
5167
5336
  };
5168
5337
 
5169
- const _excluded$3 = ["noneOfTheAbove"];
5338
+ const _excluded$1 = ["noneOfTheAbove"];
5170
5339
  const currentVersion = {
5171
5340
  major: 1,
5172
5341
  minor: 0
@@ -5176,7 +5345,7 @@ const widgetOptionsUpgrades = {
5176
5345
  const {
5177
5346
  noneOfTheAbove
5178
5347
  } = v0props,
5179
- rest = _objectWithoutPropertiesLoose(v0props, _excluded$3);
5348
+ rest = _objectWithoutPropertiesLoose(v0props, _excluded$1);
5180
5349
  if (noneOfTheAbove) {
5181
5350
  throw new Error("radio widget v0 no longer supports auto noneOfTheAbove");
5182
5351
  }
@@ -5195,13 +5364,70 @@ const defaultWidgetOptions$3 = {
5195
5364
  deselectEnabled: false
5196
5365
  };
5197
5366
 
5367
+ /**
5368
+ * For details on the individual options, see the
5369
+ * PerseusRadioWidgetOptions type
5370
+ */
5371
+
5372
+ /**
5373
+ * Only the options from each Radio choice that should be exposed to the client.
5374
+ */
5375
+
5376
+ /**
5377
+ * Given a PerseusRadioChoice object, return a new object with only the public
5378
+ * data that should be included in the Radio public widget options.
5379
+ */
5380
+ function getRadioChoicePublicData(choice) {
5381
+ const {
5382
+ content,
5383
+ isNoneOfTheAbove,
5384
+ widgets
5385
+ } = choice;
5386
+ return {
5387
+ content,
5388
+ isNoneOfTheAbove,
5389
+ widgets
5390
+ };
5391
+ }
5392
+
5393
+ /**
5394
+ * Given a PerseusRadioWidgetOptions object, return a new object with only
5395
+ * the public options that should be exposed to the client.
5396
+ */
5397
+ function getRadioPublicWidgetOptions(options) {
5398
+ return _extends({}, options, {
5399
+ choices: options.choices.map(getRadioChoicePublicData)
5400
+ });
5401
+ }
5402
+
5198
5403
  const radioWidgetLogic = {
5199
5404
  name: "radio",
5200
5405
  version: currentVersion,
5201
5406
  widgetOptionsUpgrades: widgetOptionsUpgrades,
5202
- defaultWidgetOptions: defaultWidgetOptions$3
5407
+ defaultWidgetOptions: defaultWidgetOptions$3,
5408
+ getPublicWidgetOptions: getRadioPublicWidgetOptions
5203
5409
  };
5204
5410
 
5411
+ /**
5412
+ * For details on the individual options, see the
5413
+ * PerseusSorterWidgetOptions type
5414
+ */
5415
+
5416
+ /**
5417
+ * Given a PerseusSorterWidgetOptions object, return a new object with only
5418
+ * the public options that should be exposed to the client.
5419
+ */
5420
+ function getSorterPublicWidgetOptions(options) {
5421
+ return {
5422
+ // Note(Tamara): This does not provide correct answer information any longer.
5423
+ // To maintain compatibility with the original widget options, we are
5424
+ // keeping the key the same. Represents initial state of the cards here.
5425
+ correct: options.correct.slice().sort(),
5426
+ padding: options.padding,
5427
+ layout: options.layout
5428
+ };
5429
+ }
5430
+
5205
5431
  const defaultWidgetOptions$2 = {
5206
5432
  correct: ["$x$", "$y$", "$z$"],
5207
5433
  layout: "horizontal",
@@ -5209,9 +5435,16 @@ const defaultWidgetOptions$2 = {
5209
5435
  };
5210
5436
  const sorterWidgetLogic = {
5211
5437
  name: "sorter",
5212
- defaultWidgetOptions: defaultWidgetOptions$2
5438
+ defaultWidgetOptions: defaultWidgetOptions$2,
5439
+ getPublicWidgetOptions: getSorterPublicWidgetOptions
5213
5440
  };
5214
5441
 
5442
+ const _excluded = ["answers"];
5443
+ function getTablePublicWidgetOptions(options) {
5444
+ const publicOptions = _objectWithoutPropertiesLoose(options, _excluded);
5445
+ return publicOptions;
5446
+ }
5447
+
5215
5448
  const defaultRows = 4;
5216
5449
  const defaultColumns = 1;
5217
5450
 
@@ -5226,7 +5459,8 @@ const defaultWidgetOptions$1 = {
5226
5459
  };
5227
5460
  const tableWidgetLogic = {
5228
5461
  name: "table",
5229
- defaultWidgetOptions: defaultWidgetOptions$1
5462
+ defaultWidgetOptions: defaultWidgetOptions$1,
5463
+ getPublicWidgetOptions: getTablePublicWidgetOptions
5230
5464
  };
5231
5465
 
5232
5466
  const defaultWidgetOptions = {
@@ -5254,6 +5488,13 @@ function getCurrentVersion(type) {
5254
5488
  minor: 0
5255
5489
  };
5256
5490
  }
5491
+
5492
+ // TODO(LEMS-2870): getPublicWidgetOptionsFunction/PublicWidgetOptionsFunction
5493
+ // need better types
5494
+ const getPublicWidgetOptionsFunction = name => {
5495
+ var _widgets$name$getPubl, _widgets$name;
5496
+ return (_widgets$name$getPubl = (_widgets$name = widgets[name]) == null ? void 0 : _widgets$name.getPublicWidgetOptions) != null ? _widgets$name$getPubl : i => i;
5497
+ };
5257
5498
  function getWidgetOptionsUpgrades(type) {
5258
5499
  const widgetLogic = widgets[type];
5259
5500
  return (widgetLogic == null ? void 0 : widgetLogic.widgetOptionsUpgrades) || {};
@@ -5339,6 +5580,7 @@ var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
5339
5580
  __proto__: null,
5340
5581
  isWidgetRegistered: isWidgetRegistered,
5341
5582
  getCurrentVersion: getCurrentVersion,
5583
+ getPublicWidgetOptionsFunction: getPublicWidgetOptionsFunction,
5342
5584
  getWidgetOptionsUpgrades: getWidgetOptionsUpgrades,
5343
5585
  getDefaultWidgetOptions: getDefaultWidgetOptions,
5344
5586
  getSupportedAlignments: getSupportedAlignments,
@@ -5465,142 +5707,22 @@ function getUpgradedWidgetOptions(oldWidgetOptions) {
5465
5707
  });
5466
5708
  }
5467
5709
 
5468
- /**
5469
- * For details on the individual options, see the
5470
- * PerseusOrdererWidgetOptions type
5471
- */
5472
-
5473
- /**
5474
- * Given a PerseusOrdererWidgetOptions object, return a new object with only
5475
- * the public options that should be exposed to the client.
5476
- */
5477
- function getOrdererPublicWidgetOptions(options) {
5478
- return {
5479
- options: options.options,
5480
- height: options.height,
5481
- layout: options.layout
5482
- };
5483
- }
5484
-
5485
- /**
5486
- * For details on the individual options, see the
5487
- * PerseusCategorizerWidgetOptions type
5488
- */
5489
-
5490
- /**
5491
- * Given a PerseusCategorizerWidgetOptions object, return a new object with only
5492
- * the public options that should be exposed to the client.
5493
- */
5494
- function getCategorizerPublicWidgetOptions(options) {
5495
- return {
5496
- items: options.items,
5497
- categories: options.categories,
5498
- randomizeItems: options.randomizeItems,
5499
- static: options.static
5500
- };
5501
- }
5502
-
5503
- function getCSProgramPublicWidgetOptions(options) {
5504
- return options;
5505
- }
5506
-
5507
- /**
5508
- * For details on the individual options, see the
5509
- * PerseusExpressionWidgetOptions type
5510
- */
5511
-
5512
- /**
5513
- * Given a PerseusExpressionWidgetOptions object, return a new object with only
5514
- * the public options that should be exposed to the client.
5515
- */
5516
- function getExpressionPublicWidgetOptions(options) {
5517
- return {
5518
- buttonSets: options.buttonSets,
5519
- functions: options.functions,
5520
- times: options.times,
5521
- visibleLabel: options.visibleLabel,
5522
- ariaLabel: options.ariaLabel,
5523
- buttonsVisible: options.buttonsVisible
5524
- };
5525
- }
5526
-
5527
- const _excluded$2 = ["answers"];
5528
- /**
5529
- * For details on the individual options, see the
5530
- * PerseusLabelImageWidgetOptions type
5531
- */
5532
-
5533
- function getLabelImagePublicWidgetOptions(options) {
5534
- return _extends({}, options, {
5535
- markers: options.markers.map(getLabelImageMarkerPublicData)
5710
+ function splitPerseusItem(originalItem) {
5711
+ var _item$widgets;
5712
+ const item = _.clone(originalItem);
5713
+ const originalWidgets = (_item$widgets = item.widgets) != null ? _item$widgets : {};
5714
+ const upgradedWidgets = getUpgradedWidgetOptions(originalWidgets);
5715
+ const splitWidgets = {};
5716
+ for (const [id, widget] of Object.entries(upgradedWidgets)) {
5717
+ const publicWidgetOptionsFun = getPublicWidgetOptionsFunction(widget.type);
5718
+ splitWidgets[id] = _extends({}, widget, {
5719
+ options: publicWidgetOptionsFun(widget.options)
5720
+ });
5721
+ }
5722
+ return _extends({}, item, {
5723
+ widgets: splitWidgets
5536
5724
  });
5537
5725
  }
5538
- function getLabelImageMarkerPublicData(marker) {
5539
- const publicData = _objectWithoutPropertiesLoose(marker, _excluded$2);
5540
- return publicData;
5541
- }
5542
-
5543
- /**
5544
- * For details on the individual options, see the
5545
- * PerseusSorterWidgetOptions type
5546
- */
5547
-
5548
- /**
5549
- * Given a PerseusSorterWidgetOptions object, return a new object with only
5550
- * the public options that should be exposed to the client.
5551
- */
5552
- function getSorterPublicWidgetOptions(options) {
5553
- return {
5554
- // Note(Tamara): This does not provide correct answer information any longer.
5555
- // To maintain compatibility with the original widget options, we are
5556
- // keeping the key the same. Represents initial state of the cards here.
5557
- correct: options.correct.slice().sort(),
5558
- padding: options.padding,
5559
- layout: options.layout
5560
- };
5561
- }
5562
-
5563
- /**
5564
- * For details on the individual options, see the
5565
- * PerseusDropdownWidgetOptions type
5566
- */
5567
-
5568
- /**
5569
- * Given a PerseusDropdownWidgetOptions object, return a new object with only
5570
- * the public options that should be exposed to the client.
5571
- */
5572
- function getDropdownPublicWidgetOptions(options) {
5573
- return {
5574
- choices: options.choices.map(choice => ({
5575
- content: choice.content
5576
- })),
5577
- placeholder: options.placeholder,
5578
- static: options.static,
5579
- visibleLabel: options.visibleLabel,
5580
- ariaLabel: options.ariaLabel
5581
- };
5582
- }
5583
-
5584
- const _excluded$1 = ["answers"];
5585
- /**
5586
- * For details on the individual options, see the
5587
- * PerseusNumericInputWidgetOptions type
5588
- */
5589
-
5590
- /**
5591
- * Given a PerseusNumericInputWidgetOptions object, return a new object with only
5592
- * the public options that should be exposed to the client.
5593
- */
5594
- function getNumericInputPublicWidgetOptions(options) {
5595
- const publicWidgetOptions = _objectWithoutPropertiesLoose(options, _excluded$1);
5596
- return publicWidgetOptions;
5597
- }
5598
-
5599
- const _excluded = ["correctX", "correctRel"];
5600
- function getNumberLinePublicWidgetOptions(options) {
5601
- const publicOptions = _objectWithoutPropertiesLoose(options, _excluded);
5602
- return publicOptions;
5603
- }
5604
5726
 
5605
- export { coreWidgetRegistry as CoreWidgetRegistry, Errors, grapherUtil as GrapherUtil, ItemExtras, PerseusError, PerseusExpressionAnswerFormConsidered, addLibraryVersionToPerseusDebug, addWidget, approximateDeepEqual, approximateEqual, categorizerWidgetLogic as categorizerLogic, csProgramWidgetLogic as csProgramLogic, deepClone, definitionWidgetLogic as definitionLogic, dropdownWidgetLogic as dropdownLogic, explanationWidgetLogic as explanationLogic, expressionWidgetLogic as expressionLogic, getCSProgramPublicWidgetOptions, getCategorizerPublicWidgetOptions, getDecimalSeparator, getDropdownPublicWidgetOptions, getExpressionPublicWidgetOptions, getLabelImagePublicWidgetOptions, getMatrixSize, getNumberLinePublicWidgetOptions, getNumericInputPublicWidgetOptions, getOrdererPublicWidgetOptions, getSorterPublicWidgetOptions, getUpgradedWidgetOptions, getWidgetIdsFromContent, getWidgetIdsFromContentByType, gradedGroupWidgetLogic as gradedGroupLogic, gradedGroupSetWidgetLogic as gradedGroupSetLogic, grapherWidgetLogic as grapherLogic, groupWidgetLogic as groupLogic, iframeWidgetLogic as iframeLogic, imageWidgetLogic as imageLogic, inputNumberWidgetLogic as inputNumberLogic, interactionWidgetLogic as interactionLogic, interactiveGraphWidgetLogic as interactiveGraphLogic, isFailure, isSuccess, labelImageWidgetLogic as labelImageLogic, libVersion, lockedFigureColorNames, lockedFigureColors, lockedFigureFillStyles, mapObject, matcherWidgetLogic as matcherLogic, matrixWidgetLogic as matrixLogic, measurerWidgetLogic as measurerLogic, numberLineWidgetLogic as numberLineLogic, numericInputWidgetLogic as numericInputLogic, ordererWidgetLogic as ordererLogic, parseAndMigratePerseusArticle, parseAndMigratePerseusItem, parsePerseusItem, passageWidgetLogic as passageLogic, passageRefWidgetLogic as passageRefLogic, passageRefTargetWidgetLogic as passageRefTargetLogic, phetSimulationWidgetLogic as phetSimulationLogic, plotterWidgetLogic as plotterLogic, plotterPlotTypes, pluck, pythonProgramWidgetLogic as pythonProgramLogic, radioWidgetLogic as radioLogic, sorterWidgetLogic as sorterLogic, tableWidgetLogic as tableLogic, upgradeWidgetInfoToLatestVersion, videoWidgetLogic as videoLogic };
5727
+ export { coreWidgetRegistry as CoreWidgetRegistry, Errors, grapherUtil as GrapherUtil, ItemExtras, PerseusError, PerseusExpressionAnswerFormConsidered, addLibraryVersionToPerseusDebug, addWidget, approximateDeepEqual, approximateEqual, categorizerWidgetLogic as categorizerLogic, csProgramWidgetLogic as csProgramLogic, deepClone, definitionWidgetLogic as definitionLogic, dropdownWidgetLogic as dropdownLogic, explanationWidgetLogic as explanationLogic, expressionWidgetLogic as expressionLogic, getCSProgramPublicWidgetOptions, getCategorizerPublicWidgetOptions, getDecimalSeparator, getDropdownPublicWidgetOptions, getExpressionPublicWidgetOptions, getGrapherPublicWidgetOptions, getIFramePublicWidgetOptions, getInteractiveGraphPublicWidgetOptions, getLabelImagePublicWidgetOptions, getMatrixPublicWidgetOptions, getMatrixSize, getNumberLinePublicWidgetOptions, getNumericInputPublicWidgetOptions, getOrdererPublicWidgetOptions, getPlotterPublicWidgetOptions, getRadioPublicWidgetOptions, getSorterPublicWidgetOptions, getTablePublicWidgetOptions, getUpgradedWidgetOptions, getWidgetIdsFromContent, getWidgetIdsFromContentByType, gradedGroupWidgetLogic as gradedGroupLogic, gradedGroupSetWidgetLogic as gradedGroupSetLogic, grapherWidgetLogic as grapherLogic, groupWidgetLogic as groupLogic, iframeWidgetLogic as iframeLogic, imageWidgetLogic as imageLogic, inputNumberWidgetLogic as inputNumberLogic, interactionWidgetLogic as interactionLogic, interactiveGraphWidgetLogic as interactiveGraphLogic, isFailure, isSuccess, labelImageWidgetLogic as labelImageLogic, libVersion, lockedFigureColorNames, lockedFigureColors, lockedFigureFillStyles, mapObject, matcherWidgetLogic as matcherLogic, matrixWidgetLogic as matrixLogic, measurerWidgetLogic as measurerLogic, numberLineWidgetLogic as numberLineLogic, numericInputWidgetLogic as numericInputLogic, ordererWidgetLogic as ordererLogic, parseAndMigratePerseusArticle, parseAndMigratePerseusItem, parsePerseusItem, passageWidgetLogic as passageLogic, passageRefWidgetLogic as passageRefLogic, passageRefTargetWidgetLogic as passageRefTargetLogic, phetSimulationWidgetLogic as phetSimulationLogic, plotterWidgetLogic as plotterLogic, plotterPlotTypes, pluck, pythonProgramWidgetLogic as pythonProgramLogic, radioWidgetLogic as radioLogic, sorterWidgetLogic as sorterLogic, splitPerseusItem, tableWidgetLogic as tableLogic, upgradeWidgetInfoToLatestVersion, videoWidgetLogic as videoLogic };
5606
5728
  //# sourceMappingURL=index.js.map