pcm-shared-components 2.1.411 → 2.1.412

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.
@@ -92,6 +92,7 @@ export const AnimalVehicleDetailsEditor = props => {
92
92
  canAddMore,
93
93
  maxItems,
94
94
  showHistoricalAnswers,
95
+ extraLiveKeys,
95
96
  bare,
96
97
  className,
97
98
  theme,
@@ -455,7 +456,12 @@ export const AnimalVehicleDetailsEditor = props => {
455
456
  }, requiredErrorText(field.type)));
456
457
  }));
457
458
  })())), showHistoricalAnswers && selectedItem && (() => {
458
- const liveKeys = new Set(fieldConfig.map(f => f.key));
459
+ // extraLiveKeys covers keys this component's own fieldConfig doesn't include but which
460
+ // are still genuinely live -- e.g. a once-per-reservation field, rendered by a sibling
461
+ // component (AnimalFieldsOnceBlock) but written into this same item's `values` object.
462
+ // Without this, a currently-checked notice/once field reads as a retired one the moment
463
+ // its value is set, since this component never saw it in its own fieldConfig.
464
+ const liveKeys = new Set([...fieldConfig.map(f => f.key), ...extraLiveKeys]);
459
465
  const historicalEntries = Object.keys(selectedItem.values || {}).filter(k => !liveKeys.has(k)).map(k => ({
460
466
  key: k,
461
467
  value: selectedItem.values[k]
@@ -615,6 +621,7 @@ AnimalVehicleDetailsEditor.defaultProps = {
615
621
  canAddMore: true,
616
622
  maxItems: 0,
617
623
  showHistoricalAnswers: true,
624
+ extraLiveKeys: [],
618
625
  bare: false,
619
626
  className: 'w-full',
620
627
  theme: undefined,
@@ -665,6 +672,13 @@ AnimalVehicleDetailsEditor.propTypes = {
665
672
  * since-retired answer on an EXISTING reservation is legitimate. A guest-facing booking widget
666
673
  * creating a brand-new reservation has no history to show and should pass false. */
667
674
  showHistoricalAnswers: PropTypes.bool,
675
+ /** Keys that should count as "live" for the Historical Answers check above even though they
676
+ * aren't in this instance's own `fieldConfig` -- for a caller that splits one lot's field list
677
+ * across two sibling components sharing the same item's `values` object (e.g. once-per-
678
+ * reservation fields rendered by AnimalFieldsOnceBlock instead of this component's own grid).
679
+ * Without this, a currently-answered field owned by that sibling component reads as retired the
680
+ * moment its value is set, since this component never sees it in its own fieldConfig. */
681
+ extraLiveKeys: PropTypes.arrayOf(PropTypes.string),
668
682
  /** Skip this component's own outer card (background/border/rounding) and render a plain
669
683
  * fragment instead -- for a caller placing this editor and AnimalFieldsOnceBlock's fields inside
670
684
  * one shared outer card. Defaults to false so every existing usage keeps its current look. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pcm-shared-components",
3
- "version": "2.1.411",
3
+ "version": "2.1.412",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "babel": {