@khanacademy/perseus-core 3.5.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/analytics.d.ts +30 -1
- package/dist/data-schema.d.ts +1 -1
- package/dist/es/index.js +285 -242
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +299 -255
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/general-purpose-parsers/index.d.ts +0 -1
- package/dist/parse-perseus-json/general-purpose-parsers/test-helpers.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/legacy-button-sets.d.ts +2 -0
- package/dist/parse-perseus-json/perseus-parsers/legacy-button-sets.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/result.d.ts +7 -0
- package/dist/utils/split-perseus-item.d.ts +2 -0
- package/dist/widgets/core-widget-registry.d.ts +2 -0
- package/dist/widgets/logic-export.types.d.ts +28 -0
- package/package.json +1 -1
- package/dist/parse-perseus-json/general-purpose-parsers/unknown.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -3155,6 +3155,13 @@ function convert(f) {
|
|
|
3155
3155
|
return (rawValue, ctx) => ctx.success(f(rawValue));
|
|
3156
3156
|
}
|
|
3157
3157
|
|
|
3158
|
+
const parseLegacyButtonSet = enumeration("basic", "basic+div", "trig", "prealgebra", "logarithms", "basic relations", "advanced relations", "scientific");
|
|
3159
|
+
const parseLegacyButtonSets = defaulted(array(parseLegacyButtonSet),
|
|
3160
|
+
// NOTE(benchristel): I copied the default buttonSets from
|
|
3161
|
+
// expression.tsx. See the parse-perseus-json/README.md for
|
|
3162
|
+
// an explanation of why we want to duplicate the default here.
|
|
3163
|
+
() => ["basic", "trig", "prealgebra", "logarithms"]);
|
|
3164
|
+
|
|
3158
3165
|
/**
|
|
3159
3166
|
* Creates a parser for a widget options type with multiple major versions. Old
|
|
3160
3167
|
* 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:
|
|
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:
|
|
3279
|
+
buttonSets: parseLegacyButtonSets,
|
|
3278
3280
|
buttonsVisible: optional(enumeration("always", "never", "focused"))
|
|
3279
3281
|
}));
|
|
3280
3282
|
function migrateV0ToV1(widget) {
|
|
@@ -4606,7 +4608,7 @@ function throwErrorIfCheatingDetected() {
|
|
|
4606
4608
|
|
|
4607
4609
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
4608
4610
|
const libName = "@khanacademy/perseus-core";
|
|
4609
|
-
const libVersion = "3.
|
|
4611
|
+
const libVersion = "3.6.0";
|
|
4610
4612
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
4611
4613
|
|
|
4612
4614
|
/**
|
|
@@ -4705,6 +4707,24 @@ const mapObject = function (obj, lambda) {
|
|
|
4705
4707
|
return result;
|
|
4706
4708
|
};
|
|
4707
4709
|
|
|
4710
|
+
/**
|
|
4711
|
+
* For details on the individual options, see the
|
|
4712
|
+
* PerseusCategorizerWidgetOptions type
|
|
4713
|
+
*/
|
|
4714
|
+
|
|
4715
|
+
/**
|
|
4716
|
+
* Given a PerseusCategorizerWidgetOptions object, return a new object with only
|
|
4717
|
+
* the public options that should be exposed to the client.
|
|
4718
|
+
*/
|
|
4719
|
+
function getCategorizerPublicWidgetOptions(options) {
|
|
4720
|
+
return {
|
|
4721
|
+
items: options.items,
|
|
4722
|
+
categories: options.categories,
|
|
4723
|
+
randomizeItems: options.randomizeItems,
|
|
4724
|
+
static: options.static
|
|
4725
|
+
};
|
|
4726
|
+
}
|
|
4727
|
+
|
|
4708
4728
|
const defaultWidgetOptions$v = {
|
|
4709
4729
|
items: [],
|
|
4710
4730
|
categories: [],
|
|
@@ -4713,9 +4733,14 @@ const defaultWidgetOptions$v = {
|
|
|
4713
4733
|
};
|
|
4714
4734
|
const categorizerWidgetLogic = {
|
|
4715
4735
|
name: "categorizer",
|
|
4716
|
-
defaultWidgetOptions: defaultWidgetOptions$v
|
|
4736
|
+
defaultWidgetOptions: defaultWidgetOptions$v,
|
|
4737
|
+
getPublicWidgetOptions: getCategorizerPublicWidgetOptions
|
|
4717
4738
|
};
|
|
4718
4739
|
|
|
4740
|
+
function getCSProgramPublicWidgetOptions(options) {
|
|
4741
|
+
return options;
|
|
4742
|
+
}
|
|
4743
|
+
|
|
4719
4744
|
const DEFAULT_HEIGHT = 400;
|
|
4720
4745
|
const defaultWidgetOptions$u = {
|
|
4721
4746
|
programID: "",
|
|
@@ -4731,7 +4756,8 @@ const defaultWidgetOptions$u = {
|
|
|
4731
4756
|
const csProgramWidgetLogic = {
|
|
4732
4757
|
name: "cs-program",
|
|
4733
4758
|
defaultWidgetOptions: defaultWidgetOptions$u,
|
|
4734
|
-
supportedAlignments: ["block", "full-width"]
|
|
4759
|
+
supportedAlignments: ["block", "full-width"],
|
|
4760
|
+
getPublicWidgetOptions: getCSProgramPublicWidgetOptions
|
|
4735
4761
|
};
|
|
4736
4762
|
|
|
4737
4763
|
const defaultWidgetOptions$t = {
|
|
@@ -4744,6 +4770,27 @@ const definitionWidgetLogic = {
|
|
|
4744
4770
|
defaultAlignment: "inline"
|
|
4745
4771
|
};
|
|
4746
4772
|
|
|
4773
|
+
/**
|
|
4774
|
+
* For details on the individual options, see the
|
|
4775
|
+
* PerseusDropdownWidgetOptions type
|
|
4776
|
+
*/
|
|
4777
|
+
|
|
4778
|
+
/**
|
|
4779
|
+
* Given a PerseusDropdownWidgetOptions object, return a new object with only
|
|
4780
|
+
* the public options that should be exposed to the client.
|
|
4781
|
+
*/
|
|
4782
|
+
function getDropdownPublicWidgetOptions(options) {
|
|
4783
|
+
return {
|
|
4784
|
+
choices: options.choices.map(choice => ({
|
|
4785
|
+
content: choice.content
|
|
4786
|
+
})),
|
|
4787
|
+
placeholder: options.placeholder,
|
|
4788
|
+
static: options.static,
|
|
4789
|
+
visibleLabel: options.visibleLabel,
|
|
4790
|
+
ariaLabel: options.ariaLabel
|
|
4791
|
+
};
|
|
4792
|
+
}
|
|
4793
|
+
|
|
4747
4794
|
const defaultWidgetOptions$s = {
|
|
4748
4795
|
placeholder: "",
|
|
4749
4796
|
choices: [{
|
|
@@ -4754,7 +4801,8 @@ const defaultWidgetOptions$s = {
|
|
|
4754
4801
|
const dropdownWidgetLogic = {
|
|
4755
4802
|
name: "definition",
|
|
4756
4803
|
defaultWidgetOptions: defaultWidgetOptions$s,
|
|
4757
|
-
defaultAlignment: "inline-block"
|
|
4804
|
+
defaultAlignment: "inline-block",
|
|
4805
|
+
getPublicWidgetOptions: getDropdownPublicWidgetOptions
|
|
4758
4806
|
};
|
|
4759
4807
|
|
|
4760
4808
|
const defaultWidgetOptions$r = {
|
|
@@ -4796,12 +4844,33 @@ const defaultWidgetOptions$q = {
|
|
|
4796
4844
|
functions: ["f", "g", "h"]
|
|
4797
4845
|
};
|
|
4798
4846
|
|
|
4847
|
+
/**
|
|
4848
|
+
* For details on the individual options, see the
|
|
4849
|
+
* PerseusExpressionWidgetOptions type
|
|
4850
|
+
*/
|
|
4851
|
+
|
|
4852
|
+
/**
|
|
4853
|
+
* Given a PerseusExpressionWidgetOptions object, return a new object with only
|
|
4854
|
+
* the public options that should be exposed to the client.
|
|
4855
|
+
*/
|
|
4856
|
+
function getExpressionPublicWidgetOptions(options) {
|
|
4857
|
+
return {
|
|
4858
|
+
buttonSets: options.buttonSets,
|
|
4859
|
+
functions: options.functions,
|
|
4860
|
+
times: options.times,
|
|
4861
|
+
visibleLabel: options.visibleLabel,
|
|
4862
|
+
ariaLabel: options.ariaLabel,
|
|
4863
|
+
buttonsVisible: options.buttonsVisible
|
|
4864
|
+
};
|
|
4865
|
+
}
|
|
4866
|
+
|
|
4799
4867
|
const expressionWidgetLogic = {
|
|
4800
4868
|
name: "expression",
|
|
4801
4869
|
version: currentVersion$3,
|
|
4802
4870
|
widgetOptionsUpgrades: widgetOptionsUpgrades$2,
|
|
4803
4871
|
defaultWidgetOptions: defaultWidgetOptions$q,
|
|
4804
|
-
defaultAlignment: "inline-block"
|
|
4872
|
+
defaultAlignment: "inline-block",
|
|
4873
|
+
getPublicWidgetOptions: getExpressionPublicWidgetOptions
|
|
4805
4874
|
};
|
|
4806
4875
|
|
|
4807
4876
|
const defaultWidgetOptions$p = {
|
|
@@ -4824,6 +4893,14 @@ const gradedGroupSetWidgetLogic = {
|
|
|
4824
4893
|
defaultWidgetOptions: defaultWidgetOptions$o
|
|
4825
4894
|
};
|
|
4826
4895
|
|
|
4896
|
+
function getGrapherPublicWidgetOptions(options) {
|
|
4897
|
+
const {
|
|
4898
|
+
correct: _,
|
|
4899
|
+
...publicOptions
|
|
4900
|
+
} = options;
|
|
4901
|
+
return publicOptions;
|
|
4902
|
+
}
|
|
4903
|
+
|
|
4827
4904
|
const defaultWidgetOptions$n = {
|
|
4828
4905
|
graph: {
|
|
4829
4906
|
labels: ["x", "y"],
|
|
@@ -4846,7 +4923,8 @@ const defaultWidgetOptions$n = {
|
|
|
4846
4923
|
};
|
|
4847
4924
|
const grapherWidgetLogic = {
|
|
4848
4925
|
name: "grapher",
|
|
4849
|
-
defaultWidgetOptions: defaultWidgetOptions$n
|
|
4926
|
+
defaultWidgetOptions: defaultWidgetOptions$n,
|
|
4927
|
+
getPublicWidgetOptions: getGrapherPublicWidgetOptions
|
|
4850
4928
|
};
|
|
4851
4929
|
|
|
4852
4930
|
const defaultWidgetOptions$m = {
|
|
@@ -4862,6 +4940,10 @@ const groupWidgetLogic = {
|
|
|
4862
4940
|
defaultWidgetOptions: defaultWidgetOptions$m
|
|
4863
4941
|
};
|
|
4864
4942
|
|
|
4943
|
+
function getIFramePublicWidgetOptions(options) {
|
|
4944
|
+
return options;
|
|
4945
|
+
}
|
|
4946
|
+
|
|
4865
4947
|
const defaultWidgetOptions$l = {
|
|
4866
4948
|
url: "",
|
|
4867
4949
|
settings: [{
|
|
@@ -4875,7 +4957,8 @@ const defaultWidgetOptions$l = {
|
|
|
4875
4957
|
};
|
|
4876
4958
|
const iframeWidgetLogic = {
|
|
4877
4959
|
name: "iframe",
|
|
4878
|
-
defaultWidgetOptions: defaultWidgetOptions$l
|
|
4960
|
+
defaultWidgetOptions: defaultWidgetOptions$l,
|
|
4961
|
+
getPublicWidgetOptions: getIFramePublicWidgetOptions
|
|
4879
4962
|
};
|
|
4880
4963
|
|
|
4881
4964
|
const defaultWidgetOptions$k = {
|
|
@@ -4929,6 +5012,14 @@ const interactionWidgetLogic = {
|
|
|
4929
5012
|
defaultWidgetOptions: defaultWidgetOptions$i
|
|
4930
5013
|
};
|
|
4931
5014
|
|
|
5015
|
+
function getInteractiveGraphPublicWidgetOptions(options) {
|
|
5016
|
+
const {
|
|
5017
|
+
correct: _,
|
|
5018
|
+
...publicOptions
|
|
5019
|
+
} = options;
|
|
5020
|
+
return publicOptions;
|
|
5021
|
+
}
|
|
5022
|
+
|
|
4932
5023
|
const defaultWidgetOptions$h = {
|
|
4933
5024
|
labels: ["x", "y"],
|
|
4934
5025
|
range: [[-10, 10], [-10, 10]],
|
|
@@ -4949,9 +5040,29 @@ const defaultWidgetOptions$h = {
|
|
|
4949
5040
|
};
|
|
4950
5041
|
const interactiveGraphWidgetLogic = {
|
|
4951
5042
|
name: "interactive-graph",
|
|
4952
|
-
defaultWidgetOptions: defaultWidgetOptions$h
|
|
5043
|
+
defaultWidgetOptions: defaultWidgetOptions$h,
|
|
5044
|
+
getPublicWidgetOptions: getInteractiveGraphPublicWidgetOptions
|
|
4953
5045
|
};
|
|
4954
5046
|
|
|
5047
|
+
/**
|
|
5048
|
+
* For details on the individual options, see the
|
|
5049
|
+
* PerseusLabelImageWidgetOptions type
|
|
5050
|
+
*/
|
|
5051
|
+
|
|
5052
|
+
function getLabelImagePublicWidgetOptions(options) {
|
|
5053
|
+
return {
|
|
5054
|
+
...options,
|
|
5055
|
+
markers: options.markers.map(getLabelImageMarkerPublicData)
|
|
5056
|
+
};
|
|
5057
|
+
}
|
|
5058
|
+
function getLabelImageMarkerPublicData(marker) {
|
|
5059
|
+
const {
|
|
5060
|
+
answers: _,
|
|
5061
|
+
...publicData
|
|
5062
|
+
} = marker;
|
|
5063
|
+
return publicData;
|
|
5064
|
+
}
|
|
5065
|
+
|
|
4955
5066
|
const defaultWidgetOptions$g = {
|
|
4956
5067
|
choices: [],
|
|
4957
5068
|
imageAlt: "",
|
|
@@ -4964,7 +5075,8 @@ const defaultWidgetOptions$g = {
|
|
|
4964
5075
|
};
|
|
4965
5076
|
const labelImageWidgetLogic = {
|
|
4966
5077
|
name: "label-image",
|
|
4967
|
-
defaultWidgetOptions: defaultWidgetOptions$g
|
|
5078
|
+
defaultWidgetOptions: defaultWidgetOptions$g,
|
|
5079
|
+
getPublicWidgetOptions: getLabelImagePublicWidgetOptions
|
|
4968
5080
|
};
|
|
4969
5081
|
|
|
4970
5082
|
const defaultWidgetOptions$f = {
|
|
@@ -4979,6 +5091,14 @@ const matcherWidgetLogic = {
|
|
|
4979
5091
|
defaultWidgetOptions: defaultWidgetOptions$f
|
|
4980
5092
|
};
|
|
4981
5093
|
|
|
5094
|
+
function getMatrixPublicWidgetOptions(options) {
|
|
5095
|
+
const {
|
|
5096
|
+
answers: _,
|
|
5097
|
+
...publicOptions
|
|
5098
|
+
} = options;
|
|
5099
|
+
return publicOptions;
|
|
5100
|
+
}
|
|
5101
|
+
|
|
4982
5102
|
const defaultWidgetOptions$e = {
|
|
4983
5103
|
matrixBoardSize: [3, 3],
|
|
4984
5104
|
answers: [[]],
|
|
@@ -4988,7 +5108,8 @@ const defaultWidgetOptions$e = {
|
|
|
4988
5108
|
};
|
|
4989
5109
|
const matrixWidgetLogic = {
|
|
4990
5110
|
name: "matrix",
|
|
4991
|
-
defaultWidgetOptions: defaultWidgetOptions$e
|
|
5111
|
+
defaultWidgetOptions: defaultWidgetOptions$e,
|
|
5112
|
+
getPublicWidgetOptions: getMatrixPublicWidgetOptions
|
|
4992
5113
|
};
|
|
4993
5114
|
|
|
4994
5115
|
const currentVersion$2 = {
|
|
@@ -5031,6 +5152,15 @@ const measurerWidgetLogic = {
|
|
|
5031
5152
|
defaultWidgetOptions: defaultWidgetOptions$d
|
|
5032
5153
|
};
|
|
5033
5154
|
|
|
5155
|
+
function getNumberLinePublicWidgetOptions(options) {
|
|
5156
|
+
const {
|
|
5157
|
+
correctX: _,
|
|
5158
|
+
correctRel: __,
|
|
5159
|
+
...publicOptions
|
|
5160
|
+
} = options;
|
|
5161
|
+
return publicOptions;
|
|
5162
|
+
}
|
|
5163
|
+
|
|
5034
5164
|
const defaultWidgetOptions$c = {
|
|
5035
5165
|
range: [0, 10],
|
|
5036
5166
|
labelRange: [null, null],
|
|
@@ -5047,9 +5177,27 @@ const defaultWidgetOptions$c = {
|
|
|
5047
5177
|
};
|
|
5048
5178
|
const numberLineWidgetLogic = {
|
|
5049
5179
|
name: "number-line",
|
|
5050
|
-
defaultWidgetOptions: defaultWidgetOptions$c
|
|
5180
|
+
defaultWidgetOptions: defaultWidgetOptions$c,
|
|
5181
|
+
getPublicWidgetOptions: getNumberLinePublicWidgetOptions
|
|
5051
5182
|
};
|
|
5052
5183
|
|
|
5184
|
+
/**
|
|
5185
|
+
* For details on the individual options, see the
|
|
5186
|
+
* PerseusNumericInputWidgetOptions type
|
|
5187
|
+
*/
|
|
5188
|
+
|
|
5189
|
+
/**
|
|
5190
|
+
* Given a PerseusNumericInputWidgetOptions object, return a new object with only
|
|
5191
|
+
* the public options that should be exposed to the client.
|
|
5192
|
+
*/
|
|
5193
|
+
function getNumericInputPublicWidgetOptions(options) {
|
|
5194
|
+
const {
|
|
5195
|
+
answers: _,
|
|
5196
|
+
...publicWidgetOptions
|
|
5197
|
+
} = options;
|
|
5198
|
+
return publicWidgetOptions;
|
|
5199
|
+
}
|
|
5200
|
+
|
|
5053
5201
|
const defaultWidgetOptions$b = {
|
|
5054
5202
|
answers: [{
|
|
5055
5203
|
value: null,
|
|
@@ -5068,9 +5216,27 @@ const defaultWidgetOptions$b = {
|
|
|
5068
5216
|
const numericInputWidgetLogic = {
|
|
5069
5217
|
name: "numeric-input",
|
|
5070
5218
|
defaultWidgetOptions: defaultWidgetOptions$b,
|
|
5071
|
-
defaultAlignment: "inline-block"
|
|
5219
|
+
defaultAlignment: "inline-block",
|
|
5220
|
+
getPublicWidgetOptions: getNumericInputPublicWidgetOptions
|
|
5072
5221
|
};
|
|
5073
5222
|
|
|
5223
|
+
/**
|
|
5224
|
+
* For details on the individual options, see the
|
|
5225
|
+
* PerseusOrdererWidgetOptions type
|
|
5226
|
+
*/
|
|
5227
|
+
|
|
5228
|
+
/**
|
|
5229
|
+
* Given a PerseusOrdererWidgetOptions object, return a new object with only
|
|
5230
|
+
* the public options that should be exposed to the client.
|
|
5231
|
+
*/
|
|
5232
|
+
function getOrdererPublicWidgetOptions(options) {
|
|
5233
|
+
return {
|
|
5234
|
+
options: options.options,
|
|
5235
|
+
height: options.height,
|
|
5236
|
+
layout: options.layout
|
|
5237
|
+
};
|
|
5238
|
+
}
|
|
5239
|
+
|
|
5074
5240
|
const defaultWidgetOptions$a = {
|
|
5075
5241
|
correctOptions: [{
|
|
5076
5242
|
content: "$x$"
|
|
@@ -5083,7 +5249,8 @@ const defaultWidgetOptions$a = {
|
|
|
5083
5249
|
};
|
|
5084
5250
|
const ordererWidgetLogic = {
|
|
5085
5251
|
name: "orderer",
|
|
5086
|
-
defaultWidgetOptions: defaultWidgetOptions$a
|
|
5252
|
+
defaultWidgetOptions: defaultWidgetOptions$a,
|
|
5253
|
+
getPublicWidgetOptions: getOrdererPublicWidgetOptions
|
|
5087
5254
|
};
|
|
5088
5255
|
|
|
5089
5256
|
const defaultWidgetOptions$9 = {
|
|
@@ -5132,6 +5299,23 @@ const phetSimulationWidgetLogic = {
|
|
|
5132
5299
|
defaultWidgetOptions: defaultWidgetOptions$6
|
|
5133
5300
|
};
|
|
5134
5301
|
|
|
5302
|
+
/**
|
|
5303
|
+
* For details on the individual options, see the
|
|
5304
|
+
* PerseusPlotterWidgetOptions type
|
|
5305
|
+
*/
|
|
5306
|
+
|
|
5307
|
+
/**
|
|
5308
|
+
* Given a PerseusPlotterWidgetOptions object, return a new object with only
|
|
5309
|
+
* the public options that should be exposed to the client.
|
|
5310
|
+
*/
|
|
5311
|
+
function getPlotterPublicWidgetOptions(options) {
|
|
5312
|
+
const {
|
|
5313
|
+
correct: _,
|
|
5314
|
+
...publicOptions
|
|
5315
|
+
} = options;
|
|
5316
|
+
return publicOptions;
|
|
5317
|
+
}
|
|
5318
|
+
|
|
5135
5319
|
const defaultWidgetOptions$5 = {
|
|
5136
5320
|
scaleY: 1,
|
|
5137
5321
|
maxY: 10,
|
|
@@ -5149,7 +5333,8 @@ const defaultWidgetOptions$5 = {
|
|
|
5149
5333
|
};
|
|
5150
5334
|
const plotterWidgetLogic = {
|
|
5151
5335
|
name: "plotter",
|
|
5152
|
-
defaultWidgetOptions: defaultWidgetOptions$5
|
|
5336
|
+
defaultWidgetOptions: defaultWidgetOptions$5,
|
|
5337
|
+
getPublicWidgetOptions: getPlotterPublicWidgetOptions
|
|
5153
5338
|
};
|
|
5154
5339
|
|
|
5155
5340
|
const defaultWidgetOptions$4 = {
|
|
@@ -5190,13 +5375,71 @@ const defaultWidgetOptions$3 = {
|
|
|
5190
5375
|
deselectEnabled: false
|
|
5191
5376
|
};
|
|
5192
5377
|
|
|
5378
|
+
/**
|
|
5379
|
+
* For details on the individual options, see the
|
|
5380
|
+
* PerseusRadioWidgetOptions type
|
|
5381
|
+
*/
|
|
5382
|
+
|
|
5383
|
+
/**
|
|
5384
|
+
* Only the options from each Radio choice that should be exposed to the client.
|
|
5385
|
+
*/
|
|
5386
|
+
|
|
5387
|
+
/**
|
|
5388
|
+
* Given a PerseusRadioChoice object, return a new object with only the public
|
|
5389
|
+
* data that should be included in the Radio public widget options.
|
|
5390
|
+
*/
|
|
5391
|
+
function getRadioChoicePublicData(choice) {
|
|
5392
|
+
const {
|
|
5393
|
+
content,
|
|
5394
|
+
isNoneOfTheAbove,
|
|
5395
|
+
widgets
|
|
5396
|
+
} = choice;
|
|
5397
|
+
return {
|
|
5398
|
+
content,
|
|
5399
|
+
isNoneOfTheAbove,
|
|
5400
|
+
widgets
|
|
5401
|
+
};
|
|
5402
|
+
}
|
|
5403
|
+
|
|
5404
|
+
/**
|
|
5405
|
+
* Given a PerseusRadioWidgetOptions object, return a new object with only
|
|
5406
|
+
* the public options that should be exposed to the client.
|
|
5407
|
+
*/
|
|
5408
|
+
function getRadioPublicWidgetOptions(options) {
|
|
5409
|
+
return {
|
|
5410
|
+
...options,
|
|
5411
|
+
choices: options.choices.map(getRadioChoicePublicData)
|
|
5412
|
+
};
|
|
5413
|
+
}
|
|
5414
|
+
|
|
5193
5415
|
const radioWidgetLogic = {
|
|
5194
5416
|
name: "radio",
|
|
5195
5417
|
version: currentVersion,
|
|
5196
5418
|
widgetOptionsUpgrades: widgetOptionsUpgrades,
|
|
5197
|
-
defaultWidgetOptions: defaultWidgetOptions$3
|
|
5419
|
+
defaultWidgetOptions: defaultWidgetOptions$3,
|
|
5420
|
+
getPublicWidgetOptions: getRadioPublicWidgetOptions
|
|
5198
5421
|
};
|
|
5199
5422
|
|
|
5423
|
+
/**
|
|
5424
|
+
* For details on the individual options, see the
|
|
5425
|
+
* PerseusSorterWidgetOptions type
|
|
5426
|
+
*/
|
|
5427
|
+
|
|
5428
|
+
/**
|
|
5429
|
+
* Given a PerseusSorterWidgetOptions object, return a new object with only
|
|
5430
|
+
* the public options that should be exposed to the client.
|
|
5431
|
+
*/
|
|
5432
|
+
function getSorterPublicWidgetOptions(options) {
|
|
5433
|
+
return {
|
|
5434
|
+
// Note(Tamara): This does not provide correct answer information any longer.
|
|
5435
|
+
// To maintain compatibility with the original widget options, we are
|
|
5436
|
+
// keeping the key the same. Represents initial state of the cards here.
|
|
5437
|
+
correct: options.correct.slice().sort(),
|
|
5438
|
+
padding: options.padding,
|
|
5439
|
+
layout: options.layout
|
|
5440
|
+
};
|
|
5441
|
+
}
|
|
5442
|
+
|
|
5200
5443
|
const defaultWidgetOptions$2 = {
|
|
5201
5444
|
correct: ["$x$", "$y$", "$z$"],
|
|
5202
5445
|
layout: "horizontal",
|
|
@@ -5204,9 +5447,18 @@ const defaultWidgetOptions$2 = {
|
|
|
5204
5447
|
};
|
|
5205
5448
|
const sorterWidgetLogic = {
|
|
5206
5449
|
name: "sorter",
|
|
5207
|
-
defaultWidgetOptions: defaultWidgetOptions$2
|
|
5450
|
+
defaultWidgetOptions: defaultWidgetOptions$2,
|
|
5451
|
+
getPublicWidgetOptions: getSorterPublicWidgetOptions
|
|
5208
5452
|
};
|
|
5209
5453
|
|
|
5454
|
+
function getTablePublicWidgetOptions(options) {
|
|
5455
|
+
const {
|
|
5456
|
+
answers: _,
|
|
5457
|
+
...publicOptions
|
|
5458
|
+
} = options;
|
|
5459
|
+
return publicOptions;
|
|
5460
|
+
}
|
|
5461
|
+
|
|
5210
5462
|
const defaultRows = 4;
|
|
5211
5463
|
const defaultColumns = 1;
|
|
5212
5464
|
|
|
@@ -5221,7 +5473,8 @@ const defaultWidgetOptions$1 = {
|
|
|
5221
5473
|
};
|
|
5222
5474
|
const tableWidgetLogic = {
|
|
5223
5475
|
name: "table",
|
|
5224
|
-
defaultWidgetOptions: defaultWidgetOptions$1
|
|
5476
|
+
defaultWidgetOptions: defaultWidgetOptions$1,
|
|
5477
|
+
getPublicWidgetOptions: getTablePublicWidgetOptions
|
|
5225
5478
|
};
|
|
5226
5479
|
|
|
5227
5480
|
const defaultWidgetOptions = {
|
|
@@ -5249,6 +5502,12 @@ function getCurrentVersion(type) {
|
|
|
5249
5502
|
minor: 0
|
|
5250
5503
|
};
|
|
5251
5504
|
}
|
|
5505
|
+
|
|
5506
|
+
// TODO(LEMS-2870): getPublicWidgetOptionsFunction/PublicWidgetOptionsFunction
|
|
5507
|
+
// need better types
|
|
5508
|
+
const getPublicWidgetOptionsFunction = name => {
|
|
5509
|
+
return widgets[name]?.getPublicWidgetOptions ?? (i => i);
|
|
5510
|
+
};
|
|
5252
5511
|
function getWidgetOptionsUpgrades(type) {
|
|
5253
5512
|
const widgetLogic = widgets[type];
|
|
5254
5513
|
return widgetLogic?.widgetOptionsUpgrades || {};
|
|
@@ -5333,6 +5592,7 @@ var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
|
|
|
5333
5592
|
__proto__: null,
|
|
5334
5593
|
isWidgetRegistered: isWidgetRegistered,
|
|
5335
5594
|
getCurrentVersion: getCurrentVersion,
|
|
5595
|
+
getPublicWidgetOptionsFunction: getPublicWidgetOptionsFunction,
|
|
5336
5596
|
getWidgetOptionsUpgrades: getWidgetOptionsUpgrades,
|
|
5337
5597
|
getDefaultWidgetOptions: getDefaultWidgetOptions,
|
|
5338
5598
|
getSupportedAlignments: getSupportedAlignments,
|
|
@@ -5465,241 +5725,24 @@ function getUpgradedWidgetOptions(oldWidgetOptions) {
|
|
|
5465
5725
|
});
|
|
5466
5726
|
}
|
|
5467
5727
|
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
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
|
-
function getGrapherPublicWidgetOptions(options) {
|
|
5528
|
-
const {
|
|
5529
|
-
correct: _,
|
|
5530
|
-
...publicOptions
|
|
5531
|
-
} = options;
|
|
5532
|
-
return publicOptions;
|
|
5533
|
-
}
|
|
5534
|
-
|
|
5535
|
-
function getInteractiveGraphPublicWidgetOptions(options) {
|
|
5536
|
-
const {
|
|
5537
|
-
correct: _,
|
|
5538
|
-
...publicOptions
|
|
5539
|
-
} = options;
|
|
5540
|
-
return publicOptions;
|
|
5541
|
-
}
|
|
5542
|
-
|
|
5543
|
-
/**
|
|
5544
|
-
* For details on the individual options, see the
|
|
5545
|
-
* PerseusLabelImageWidgetOptions type
|
|
5546
|
-
*/
|
|
5547
|
-
|
|
5548
|
-
function getLabelImagePublicWidgetOptions(options) {
|
|
5549
|
-
return {
|
|
5550
|
-
...options,
|
|
5551
|
-
markers: options.markers.map(getLabelImageMarkerPublicData)
|
|
5552
|
-
};
|
|
5553
|
-
}
|
|
5554
|
-
function getLabelImageMarkerPublicData(marker) {
|
|
5555
|
-
const {
|
|
5556
|
-
answers: _,
|
|
5557
|
-
...publicData
|
|
5558
|
-
} = marker;
|
|
5559
|
-
return publicData;
|
|
5560
|
-
}
|
|
5561
|
-
|
|
5562
|
-
/**
|
|
5563
|
-
* For details on the individual options, see the
|
|
5564
|
-
* PerseusSorterWidgetOptions type
|
|
5565
|
-
*/
|
|
5566
|
-
|
|
5567
|
-
/**
|
|
5568
|
-
* Given a PerseusSorterWidgetOptions object, return a new object with only
|
|
5569
|
-
* the public options that should be exposed to the client.
|
|
5570
|
-
*/
|
|
5571
|
-
function getSorterPublicWidgetOptions(options) {
|
|
5572
|
-
return {
|
|
5573
|
-
// Note(Tamara): This does not provide correct answer information any longer.
|
|
5574
|
-
// To maintain compatibility with the original widget options, we are
|
|
5575
|
-
// keeping the key the same. Represents initial state of the cards here.
|
|
5576
|
-
correct: options.correct.slice().sort(),
|
|
5577
|
-
padding: options.padding,
|
|
5578
|
-
layout: options.layout
|
|
5579
|
-
};
|
|
5580
|
-
}
|
|
5581
|
-
|
|
5582
|
-
/**
|
|
5583
|
-
* For details on the individual options, see the
|
|
5584
|
-
* PerseusDropdownWidgetOptions type
|
|
5585
|
-
*/
|
|
5586
|
-
|
|
5587
|
-
/**
|
|
5588
|
-
* Given a PerseusDropdownWidgetOptions object, return a new object with only
|
|
5589
|
-
* the public options that should be exposed to the client.
|
|
5590
|
-
*/
|
|
5591
|
-
function getDropdownPublicWidgetOptions(options) {
|
|
5592
|
-
return {
|
|
5593
|
-
choices: options.choices.map(choice => ({
|
|
5594
|
-
content: choice.content
|
|
5595
|
-
})),
|
|
5596
|
-
placeholder: options.placeholder,
|
|
5597
|
-
static: options.static,
|
|
5598
|
-
visibleLabel: options.visibleLabel,
|
|
5599
|
-
ariaLabel: options.ariaLabel
|
|
5600
|
-
};
|
|
5601
|
-
}
|
|
5602
|
-
|
|
5603
|
-
/**
|
|
5604
|
-
* For details on the individual options, see the
|
|
5605
|
-
* PerseusNumericInputWidgetOptions type
|
|
5606
|
-
*/
|
|
5607
|
-
|
|
5608
|
-
/**
|
|
5609
|
-
* Given a PerseusNumericInputWidgetOptions object, return a new object with only
|
|
5610
|
-
* the public options that should be exposed to the client.
|
|
5611
|
-
*/
|
|
5612
|
-
function getNumericInputPublicWidgetOptions(options) {
|
|
5613
|
-
const {
|
|
5614
|
-
answers: _,
|
|
5615
|
-
...publicWidgetOptions
|
|
5616
|
-
} = options;
|
|
5617
|
-
return publicWidgetOptions;
|
|
5618
|
-
}
|
|
5619
|
-
|
|
5620
|
-
function getNumberLinePublicWidgetOptions(options) {
|
|
5621
|
-
const {
|
|
5622
|
-
correctX: _,
|
|
5623
|
-
correctRel: __,
|
|
5624
|
-
...publicOptions
|
|
5625
|
-
} = options;
|
|
5626
|
-
return publicOptions;
|
|
5627
|
-
}
|
|
5628
|
-
|
|
5629
|
-
/**
|
|
5630
|
-
* For details on the individual options, see the
|
|
5631
|
-
* PerseusRadioWidgetOptions type
|
|
5632
|
-
*/
|
|
5633
|
-
|
|
5634
|
-
/**
|
|
5635
|
-
* Only the options from each Radio choice that should be exposed to the client.
|
|
5636
|
-
*/
|
|
5637
|
-
|
|
5638
|
-
/**
|
|
5639
|
-
* Given a PerseusRadioChoice object, return a new object with only the public
|
|
5640
|
-
* data that should be included in the Radio public widget options.
|
|
5641
|
-
*/
|
|
5642
|
-
function getRadioChoicePublicData(choice) {
|
|
5643
|
-
const {
|
|
5644
|
-
content,
|
|
5645
|
-
isNoneOfTheAbove,
|
|
5646
|
-
widgets
|
|
5647
|
-
} = choice;
|
|
5648
|
-
return {
|
|
5649
|
-
content,
|
|
5650
|
-
isNoneOfTheAbove,
|
|
5651
|
-
widgets
|
|
5652
|
-
};
|
|
5653
|
-
}
|
|
5654
|
-
|
|
5655
|
-
/**
|
|
5656
|
-
* Given a PerseusRadioWidgetOptions object, return a new object with only
|
|
5657
|
-
* the public options that should be exposed to the client.
|
|
5658
|
-
*/
|
|
5659
|
-
function getRadioPublicWidgetOptions(options) {
|
|
5728
|
+
function splitPerseusItem(originalItem) {
|
|
5729
|
+
const item = _.clone(originalItem);
|
|
5730
|
+
const originalWidgets = item.widgets ?? {};
|
|
5731
|
+
const upgradedWidgets = getUpgradedWidgetOptions(originalWidgets);
|
|
5732
|
+
const splitWidgets = {};
|
|
5733
|
+
for (const [id, widget] of Object.entries(upgradedWidgets)) {
|
|
5734
|
+
const publicWidgetOptionsFun = getPublicWidgetOptionsFunction(widget.type);
|
|
5735
|
+
splitWidgets[id] = {
|
|
5736
|
+
...widget,
|
|
5737
|
+
options: publicWidgetOptionsFun(widget.options)
|
|
5738
|
+
};
|
|
5739
|
+
}
|
|
5660
5740
|
return {
|
|
5661
|
-
...
|
|
5662
|
-
|
|
5741
|
+
...item,
|
|
5742
|
+
widgets: splitWidgets
|
|
5663
5743
|
};
|
|
5664
5744
|
}
|
|
5665
5745
|
|
|
5666
|
-
function getTablePublicWidgetOptions(options) {
|
|
5667
|
-
const {
|
|
5668
|
-
answers: _,
|
|
5669
|
-
...publicOptions
|
|
5670
|
-
} = options;
|
|
5671
|
-
return publicOptions;
|
|
5672
|
-
}
|
|
5673
|
-
|
|
5674
|
-
function getIFramePublicWidgetOptions(options) {
|
|
5675
|
-
return options;
|
|
5676
|
-
}
|
|
5677
|
-
|
|
5678
|
-
function getMatrixPublicWidgetOptions(options) {
|
|
5679
|
-
const {
|
|
5680
|
-
answers: _,
|
|
5681
|
-
...publicOptions
|
|
5682
|
-
} = options;
|
|
5683
|
-
return publicOptions;
|
|
5684
|
-
}
|
|
5685
|
-
|
|
5686
|
-
/**
|
|
5687
|
-
* For details on the individual options, see the
|
|
5688
|
-
* PerseusPlotterWidgetOptions type
|
|
5689
|
-
*/
|
|
5690
|
-
|
|
5691
|
-
/**
|
|
5692
|
-
* Given a PerseusPlotterWidgetOptions object, return a new object with only
|
|
5693
|
-
* the public options that should be exposed to the client.
|
|
5694
|
-
*/
|
|
5695
|
-
function getPlotterPublicWidgetOptions(options) {
|
|
5696
|
-
const {
|
|
5697
|
-
correct: _,
|
|
5698
|
-
...publicOptions
|
|
5699
|
-
} = options;
|
|
5700
|
-
return publicOptions;
|
|
5701
|
-
}
|
|
5702
|
-
|
|
5703
5746
|
exports.CoreWidgetRegistry = coreWidgetRegistry;
|
|
5704
5747
|
exports.Errors = Errors;
|
|
5705
5748
|
exports.GrapherUtil = grapherUtil;
|
|
@@ -5774,6 +5817,7 @@ exports.pluck = pluck;
|
|
|
5774
5817
|
exports.pythonProgramLogic = pythonProgramWidgetLogic;
|
|
5775
5818
|
exports.radioLogic = radioWidgetLogic;
|
|
5776
5819
|
exports.sorterLogic = sorterWidgetLogic;
|
|
5820
|
+
exports.splitPerseusItem = splitPerseusItem;
|
|
5777
5821
|
exports.tableLogic = tableWidgetLogic;
|
|
5778
5822
|
exports.upgradeWidgetInfoToLatestVersion = upgradeWidgetInfoToLatestVersion;
|
|
5779
5823
|
exports.videoLogic = videoWidgetLogic;
|