jupiter-dynamic-forms 1.16.5 → 1.16.6

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
@@ -715,14 +715,17 @@ class XBRLFormBuilder {
715
715
  // Collapse nested levels by default
716
716
  abstract: concept.elementAbstract,
717
717
  periodType: concept.periodType,
718
- balance: concept.balance
718
+ balance: concept.balance,
719
719
  // Pass through balance attribute from XBRL data
720
+ preferredLabel: concept.preferredLabel
721
+ // Pass through for period date calculation in manual columns
720
722
  };
721
723
  }
722
724
  /**
723
725
  * Create form field from XBRL concept
724
726
  */
725
727
  static createFieldFromConcept(concept, periodStartDate, periodEndDate, forcedColumnId) {
728
+ var _a;
726
729
  const fieldType = this.mapXBRLTypeToFieldType(concept.type);
727
730
  const label = this.getPreferredLabel(concept.labels);
728
731
  let columnId;
@@ -747,7 +750,7 @@ class XBRLFormBuilder {
747
750
  // Validate and set the period type
748
751
  periodStartDate: periodStartDate || "2025-01-01",
749
752
  periodEndDate: periodEndDate || "2025-12-31",
750
- periodInstantDate: concept.periodType === "instant" ? periodEndDate || periodStartDate || "2025-01-01" : void 0
753
+ periodInstantDate: concept.periodType === "instant" ? ((_a = concept.preferredLabel) == null ? void 0 : _a.includes("periodStartLabel")) ? this.subtractOneDay(periodStartDate || "2025-01-01") : periodEndDate || periodStartDate || "2025-01-01" : void 0
751
754
  };
752
755
  if (concept.id === "nl-cd_DescriptionLocationNL__a64trl") {
753
756
  console.log(`🏗️ [Field Creation] Concept: ${concept.id}, periodType from concept: ${concept.periodType}, Field periodType: ${field2.periodType}, ColumnId: ${columnId}`);
@@ -1052,6 +1055,16 @@ class XBRLFormBuilder {
1052
1055
  return dateString;
1053
1056
  }
1054
1057
  }
1058
+ static subtractOneDay(dateString) {
1059
+ try {
1060
+ const date = new Date(dateString);
1061
+ date.setDate(date.getDate() - 1);
1062
+ return date.toISOString().split("T")[0];
1063
+ } catch (error2) {
1064
+ console.error(`Error subtracting one day from date ${dateString}:`, error2);
1065
+ return dateString;
1066
+ }
1067
+ }
1055
1068
  /**
1056
1069
  * Generate previous year columns based on current year columns
1057
1070
  */
@@ -8728,6 +8741,19 @@ let JupiterDynamicForm = class extends LitElement {
8728
8741
  }
8729
8742
  return `${startDate} / ${endDate}`;
8730
8743
  }
8744
+ _resolveInstantDate(preferredLabel, instantDate, startDate, endDate) {
8745
+ if (preferredLabel == null ? void 0 : preferredLabel.includes("periodStartLabel")) {
8746
+ const base = startDate || "2025-01-01";
8747
+ try {
8748
+ const d2 = new Date(base);
8749
+ d2.setDate(d2.getDate() - 1);
8750
+ return d2.toISOString().split("T")[0];
8751
+ } catch {
8752
+ return base;
8753
+ }
8754
+ }
8755
+ return instantDate || endDate || startDate || "2025-01-01";
8756
+ }
8731
8757
  _addColumnFromRequest(request, sectionId, insertAfterColumnId) {
8732
8758
  var _a, _b, _c, _d, _e;
8733
8759
  const timestamp = Date.now();
@@ -8926,6 +8952,9 @@ let JupiterDynamicForm = class extends LitElement {
8926
8952
  if (this._shouldCreateFieldForConcept(concept, request)) {
8927
8953
  const existingField = (_a = concept.fields) == null ? void 0 : _a[0];
8928
8954
  let field2;
8955
+ const colStartDate = request.periodType === "instant" ? request.instantDate : request.startDate;
8956
+ const colEndDate = request.periodType === "instant" ? request.instantDate : request.endDate;
8957
+ const instantDate = this._resolveInstantDate(concept.preferredLabel, request.instantDate, colStartDate, colEndDate);
8929
8958
  if (existingField) {
8930
8959
  field2 = {
8931
8960
  id: `${concept.id}_${columnId}`,
@@ -8939,13 +8968,10 @@ let JupiterDynamicForm = class extends LitElement {
8939
8968
  validation: existingField.validation,
8940
8969
  defaultValue: existingField.defaultValue,
8941
8970
  periodType: concept.periodType,
8942
- // Add periodType from concept
8943
8971
  conceptType: concept.type,
8944
- // CRITICAL: Include conceptType for XBRL validation
8945
- // Set period dates from the add column request
8946
- periodStartDate: request.periodType === "instant" ? request.instantDate : request.startDate,
8947
- periodEndDate: request.periodType === "instant" ? request.instantDate : request.endDate,
8948
- periodInstantDate: concept.periodType === "instant" ? request.instantDate || request.startDate : void 0
8972
+ periodStartDate: colStartDate,
8973
+ periodEndDate: colEndDate,
8974
+ periodInstantDate: concept.periodType === "instant" ? instantDate : void 0
8949
8975
  };
8950
8976
  } else {
8951
8977
  field2 = {
@@ -8960,13 +8986,10 @@ let JupiterDynamicForm = class extends LitElement {
8960
8986
  validation: [],
8961
8987
  defaultValue: "",
8962
8988
  periodType: concept.periodType,
8963
- // Add periodType from concept
8964
8989
  conceptType: concept.type,
8965
- // CRITICAL: Include conceptType for XBRL validation
8966
- // Set period dates from the add column request
8967
- periodStartDate: request.periodType === "instant" ? request.instantDate : request.startDate,
8968
- periodEndDate: request.periodType === "instant" ? request.instantDate : request.endDate,
8969
- periodInstantDate: concept.periodType === "instant" ? request.instantDate || request.startDate : void 0
8990
+ periodStartDate: colStartDate,
8991
+ periodEndDate: colEndDate,
8992
+ periodInstantDate: concept.periodType === "instant" ? instantDate : void 0
8970
8993
  };
8971
8994
  }
8972
8995
  if (!concept.fields) {