@khanacademy/perseus-core 0.0.0-PR875-20250221232857 → 0.0.0-PR875-20250225011257

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.js CHANGED
@@ -53,7 +53,9 @@ const getDecimalSeparator = locale => {
53
53
  const match = new Intl.NumberFormat(locale).format(numberWithDecimalSeparator)
54
54
  // 0x661 is ARABIC-INDIC DIGIT ONE
55
55
  // 0x6F1 is EXTENDED ARABIC-INDIC DIGIT ONE
56
- .match(/[^\d\u0661\u06F1]/);
56
+ // 0x967 is DEVANAGARI DIGIT ONE
57
+ // 0x9e7 is BENGALI/BANGLA DIGIT ONE
58
+ .match(/[^\d\u0661\u06F1\u0967\u09e7]/);
57
59
  return match?.[0] ?? ".";
58
60
  }
59
61
  };
@@ -2146,6 +2148,7 @@ const parseNumberLineWidget = parseWidget(constant("number-line"), object({
2146
2148
  }));
2147
2149
 
2148
2150
  const parseMathFormat = enumeration("integer", "mixed", "improper", "proper", "decimal", "percent", "pi");
2151
+ const parseSimplify = enumeration("required", "correct", "enforced", "optional");
2149
2152
  const parseNumericInputWidget = parseWidget(constant("numeric-input"), object({
2150
2153
  answers: array(object({
2151
2154
  message: string,
@@ -2160,7 +2163,12 @@ const parseNumericInputWidget = parseWidget(constant("numeric-input"), object({
2160
2163
  // TODO(benchristel): simplify should never be a boolean, but we
2161
2164
  // have some content where it is anyway. If we ever backfill
2162
2165
  // the data, we should simplify `simplify`.
2163
- simplify: optional(nullable(union(string).or(pipeParsers(boolean).then(convert(String)).parser).parser))
2166
+ simplify: optional(nullable(union(parseSimplify).or(pipeParsers(boolean).then(convert(value => {
2167
+ if (typeof value === "boolean") {
2168
+ return value ? "required" : "optional";
2169
+ }
2170
+ return value;
2171
+ })).parser).parser))
2164
2172
  })),
2165
2173
  labelText: optional(string),
2166
2174
  size: string,
@@ -3239,16 +3247,36 @@ const numberLineWidgetLogic = {
3239
3247
  * PerseusNumericInputWidgetOptions type
3240
3248
  */
3241
3249
 
3250
+ /**
3251
+ * This data from `answers` is used pre-scoring to give hints
3252
+ * to the learner regarding the format of accepted answers
3253
+ */
3254
+ function getNumericInputAnswerPublicData(answer) {
3255
+ const {
3256
+ answerForms,
3257
+ simplify,
3258
+ status
3259
+ } = answer;
3260
+ return {
3261
+ answerForms,
3262
+ simplify,
3263
+ status
3264
+ };
3265
+ }
3266
+
3242
3267
  /**
3243
3268
  * Given a PerseusNumericInputWidgetOptions object, return a new object with only
3244
3269
  * the public options that should be exposed to the client.
3245
3270
  */
3246
3271
  function getNumericInputPublicWidgetOptions(options) {
3247
3272
  const {
3248
- answers: _,
3273
+ answers,
3249
3274
  ...publicWidgetOptions
3250
3275
  } = options;
3251
- return publicWidgetOptions;
3276
+ return {
3277
+ ...publicWidgetOptions,
3278
+ answers: answers.map(getNumericInputAnswerPublicData)
3279
+ };
3252
3280
  }
3253
3281
 
3254
3282
  const defaultWidgetOptions$b = {