@crombolo/core 0.54.1 → 0.56.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/forms.ts +9 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/core",
3
- "version": "0.54.1",
3
+ "version": "0.56.0",
4
4
  "description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Domain model, entity keys and shared contracts for crombolo. No I/O.",
5
5
  "license": "MIT",
6
6
  "author": "Crombolo",
@@ -28,6 +28,6 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@crombolo/common": "0.54.1"
31
+ "@crombolo/common": "0.56.0"
32
32
  }
33
33
  }
package/src/forms.ts CHANGED
@@ -360,6 +360,12 @@ export function withResolvedChoices(
360
360
  }
361
361
  }
362
362
 
363
+ /**
364
+ * The field types whose default value is words a visitor reads in the box, and so
365
+ * may name a dictionary item. Any other type's default is a value it compares.
366
+ */
367
+ export const WORDY_DEFAULT_TYPES: readonly string[] = ['shortAnswer', 'longAnswer']
368
+
363
369
  /** Each word a form shows a visitor, passed through `word`. */
364
370
  function mapFormWords(form: SchemaForm, word: (text: string) => string): SchemaForm {
365
371
  const text = (value: string | undefined) => (value === undefined ? undefined : word(value))
@@ -388,6 +394,9 @@ function mapFormWords(form: SchemaForm, word: (text: string) => string): SchemaF
388
394
  content: text(field.content),
389
395
  mandatoryMessage: text(field.mandatoryMessage),
390
396
  patternMessage: text(field.patternMessage),
397
+ defaultValue: WORDY_DEFAULT_TYPES.includes(field.type)
398
+ ? text(field.defaultValue)
399
+ : field.defaultValue,
391
400
  }),
392
401
  })),
393
402
  })),