jupiter-dynamic-forms 1.20.0 → 1.20.1

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.mjs CHANGED
@@ -683,6 +683,7 @@ class XBRLFormBuilder {
683
683
  var _a, _b;
684
684
  const label = this.getPreferredLabel(concept.labels, language, concept.preferredLabel);
685
685
  const childPeriodHint = ((_a = concept.preferredLabel) == null ? void 0 : _a.includes("periodStartLabel")) ? "start" : ((_b = concept.preferredLabel) == null ? void 0 : _b.includes("periodEndLabel")) ? "end" : ancestorPeriodHint;
686
+ const effectivePeriodRole = childPeriodHint === "start" ? "periodStartLabel" : childPeriodHint === "end" ? "periodEndLabel" : void 0;
686
687
  const fields = [];
687
688
  if (!concept.elementAbstract) {
688
689
  let columnIds = [];
@@ -751,8 +752,10 @@ class XBRLFormBuilder {
751
752
  periodType: concept.periodType,
752
753
  balance: concept.balance,
753
754
  // Pass through balance attribute from XBRL data
754
- preferredLabel: concept.preferredLabel
755
+ preferredLabel: concept.preferredLabel,
755
756
  // Pass through for period date calculation in manual columns
757
+ effectivePeriodRole
758
+ // JDF-039: own-or-inherited periodStartLabel/periodEndLabel role
756
759
  };
757
760
  }
758
761
  /**
@@ -10781,6 +10784,38 @@ let JupiterDynamicForm = class extends LitElement {
10781
10784
  }
10782
10785
  return `${startDate} / ${endDate}`;
10783
10786
  }
10787
+ /**
10788
+ * JDF-040: Resolves the instant date for a submission entry (Save Draft/Submit).
10789
+ * periodStartLabel-effective concepts (own-labelled or inherited, JDF-039) always
10790
+ * resolve via _resolveInstantDate — the same call the self-heal itself makes — instead
10791
+ * of trusting whatever happens to be cached in _periodData/field.periodInstantDate.
10792
+ * This matters because self-heal only ever corrects an EXISTING _periodData override
10793
+ * (it never fabricates one), so a cell that was never manually period-edited would
10794
+ * otherwise fall through to column.periodEndDate here and silently re-emit the wrong
10795
+ * date on every Save Draft/Submit even though field.periodInstantDate was healed.
10796
+ * Everything else keeps the previous fallback chain, but with field.periodInstantDate
10797
+ * now outranking column.periodEndDate, matching the already-correct sibling
10798
+ * implementations in _findFactValueForField and _addConceptDataToSubmission.
10799
+ */
10800
+ _resolveSubmissionInstantDate(concept, field2, fieldPeriodData, column2) {
10801
+ const effectiveRole = this._getEffectivePeriodRole(concept);
10802
+ if (effectiveRole == null ? void 0 : effectiveRole.includes("periodStartLabel")) {
10803
+ const periodStartDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.startDate) || (column2 == null ? void 0 : column2.periodStartDate) || field2.periodStartDate || this.periodStartDate;
10804
+ const periodEndDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.endDate) || (column2 == null ? void 0 : column2.periodEndDate) || field2.periodEndDate || this.periodEndDate;
10805
+ return this._resolveInstantDate(effectiveRole, void 0, periodStartDate, periodEndDate);
10806
+ }
10807
+ return (fieldPeriodData == null ? void 0 : fieldPeriodData.instantDate) || (fieldPeriodData == null ? void 0 : fieldPeriodData.endDate) || field2.periodInstantDate || (column2 == null ? void 0 : column2.periodEndDate) || field2.periodEndDate || field2.periodStartDate || this.periodStartDate;
10808
+ }
10809
+ /**
10810
+ * JDF-039: The label value to use for periodStartLabel/periodEndLabel checks — the
10811
+ * concept's own preferredLabel if it carries one of those roles, otherwise the role
10812
+ * inherited from the nearest ancestor that does (stamped by XBRLFormBuilder as
10813
+ * effectivePeriodRole). Falls back to preferredLabel for any concept built before this
10814
+ * fix (or otherwise missing the field).
10815
+ */
10816
+ _getEffectivePeriodRole(concept) {
10817
+ return concept.effectivePeriodRole ?? concept.preferredLabel;
10818
+ }
10784
10819
  _resolveInstantDate(preferredLabel, instantDate, startDate, endDate) {
10785
10820
  if (preferredLabel == null ? void 0 : preferredLabel.includes("periodStartLabel")) {
10786
10821
  const base = startDate || "2025-01-01";
@@ -10810,7 +10845,7 @@ let JupiterDynamicForm = class extends LitElement {
10810
10845
  _correctPeriodStartInstantDatesInConcepts(concepts, section2) {
10811
10846
  concepts.forEach((concept) => {
10812
10847
  var _a, _b;
10813
- if (((_a = concept.preferredLabel) == null ? void 0 : _a.includes("periodStartLabel")) && concept.periodType === "instant" && ((_b = concept.fields) == null ? void 0 : _b.length)) {
10848
+ if (((_a = this._getEffectivePeriodRole(concept)) == null ? void 0 : _a.includes("periodStartLabel")) && concept.periodType === "instant" && ((_b = concept.fields) == null ? void 0 : _b.length)) {
10814
10849
  concept.fields.forEach((field2) => {
10815
10850
  this._correctFieldPeriodStartInstantDate(concept, field2, concept.id, section2);
10816
10851
  const repeatCount = this._repeatCounts[concept.id] || 0;
@@ -10830,7 +10865,7 @@ let JupiterDynamicForm = class extends LitElement {
10830
10865
  const fieldPeriodData = (_a = this._periodData[periodDataKey]) == null ? void 0 : _a[field2.columnId];
10831
10866
  const periodStartDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.startDate) || (column2 == null ? void 0 : column2.periodStartDate) || field2.periodStartDate || this.periodStartDate;
10832
10867
  const periodEndDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.endDate) || (column2 == null ? void 0 : column2.periodEndDate) || field2.periodEndDate || this.periodEndDate;
10833
- const correctedInstantDate = this._resolveInstantDate(concept.preferredLabel, void 0, periodStartDate, periodEndDate);
10868
+ const correctedInstantDate = this._resolveInstantDate(this._getEffectivePeriodRole(concept), void 0, periodStartDate, periodEndDate);
10834
10869
  if (fieldPeriodData && fieldPeriodData.instantDate !== correctedInstantDate) {
10835
10870
  console.log(`🩹 [Legacy Period Correction] ${periodDataKey}/${field2.columnId}: instantDate ${fieldPeriodData.instantDate} → ${correctedInstantDate}`);
10836
10871
  fieldPeriodData.instantDate = correctedInstantDate;
@@ -11040,7 +11075,7 @@ let JupiterDynamicForm = class extends LitElement {
11040
11075
  let field2;
11041
11076
  const colStartDate = request.periodType === "instant" ? request.instantDate : request.startDate;
11042
11077
  const colEndDate = request.periodType === "instant" ? request.instantDate : request.endDate;
11043
- const instantDate = this._resolveInstantDate(concept.preferredLabel, request.instantDate, colStartDate, colEndDate);
11078
+ const instantDate = this._resolveInstantDate(this._getEffectivePeriodRole(concept), request.instantDate, colStartDate, colEndDate);
11044
11079
  if (existingField) {
11045
11080
  field2 = {
11046
11081
  id: `${concept.id}_${columnId}`,
@@ -11756,7 +11791,7 @@ let JupiterDynamicForm = class extends LitElement {
11756
11791
  // CRITICAL: Include conceptType for XBRL validation
11757
11792
  periodStartDate: column2.periodStartDate,
11758
11793
  periodEndDate: column2.periodEndDate,
11759
- periodInstantDate: conceptPeriodType === "instant" ? column2.periodEndDate || column2.periodStartDate : void 0
11794
+ periodInstantDate: conceptPeriodType === "instant" ? this._resolveInstantDate(this._getEffectivePeriodRole(concept), void 0, column2.periodStartDate, column2.periodEndDate) : void 0
11760
11795
  };
11761
11796
  if ((_a = this._periodData[concept.id]) == null ? void 0 : _a[column2.id]) {
11762
11797
  const customPeriod = this._periodData[concept.id][column2.id];
@@ -12088,7 +12123,7 @@ let JupiterDynamicForm = class extends LitElement {
12088
12123
  }
12089
12124
  };
12090
12125
  if (concept.periodType === "instant") {
12091
- const instantDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.instantDate) || (fieldPeriodData == null ? void 0 : fieldPeriodData.endDate) || (column2 == null ? void 0 : column2.periodEndDate) || field2.periodInstantDate || field2.periodEndDate || field2.periodStartDate || this.periodStartDate;
12126
+ const instantDate = this._resolveSubmissionInstantDate(concept, field2, fieldPeriodData, column2);
12092
12127
  submissionEntry.period.date = instantDate;
12093
12128
  } else {
12094
12129
  const startDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.startDate) || (column2 == null ? void 0 : column2.periodStartDate) || field2.periodStartDate || this.periodStartDate;
@@ -12204,7 +12239,7 @@ let JupiterDynamicForm = class extends LitElement {
12204
12239
  }
12205
12240
  };
12206
12241
  if (concept.periodType === "instant") {
12207
- instanceEntry.period.date = (fieldPeriodData == null ? void 0 : fieldPeriodData.instantDate) || (fieldPeriodData == null ? void 0 : fieldPeriodData.endDate) || (column2 == null ? void 0 : column2.periodEndDate) || field2.periodInstantDate || field2.periodEndDate || field2.periodStartDate || this.periodStartDate;
12242
+ instanceEntry.period.date = this._resolveSubmissionInstantDate(concept, field2, fieldPeriodData, column2);
12208
12243
  } else {
12209
12244
  instanceEntry.period.startDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.startDate) || (column2 == null ? void 0 : column2.periodStartDate) || field2.periodStartDate || this.periodStartDate;
12210
12245
  instanceEntry.period.endDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.endDate) || (column2 == null ? void 0 : column2.periodEndDate) || field2.periodEndDate || this.periodEndDate;