jupiter-dynamic-forms 1.16.4 → 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
@@ -714,13 +714,18 @@ class XBRLFormBuilder {
714
714
  collapsed: level > 0,
715
715
  // Collapse nested levels by default
716
716
  abstract: concept.elementAbstract,
717
- periodType: concept.periodType
717
+ periodType: concept.periodType,
718
+ balance: concept.balance,
719
+ // Pass through balance attribute from XBRL data
720
+ preferredLabel: concept.preferredLabel
721
+ // Pass through for period date calculation in manual columns
718
722
  };
719
723
  }
720
724
  /**
721
725
  * Create form field from XBRL concept
722
726
  */
723
727
  static createFieldFromConcept(concept, periodStartDate, periodEndDate, forcedColumnId) {
728
+ var _a;
724
729
  const fieldType = this.mapXBRLTypeToFieldType(concept.type);
725
730
  const label = this.getPreferredLabel(concept.labels);
726
731
  let columnId;
@@ -745,7 +750,7 @@ class XBRLFormBuilder {
745
750
  // Validate and set the period type
746
751
  periodStartDate: periodStartDate || "2025-01-01",
747
752
  periodEndDate: periodEndDate || "2025-12-31",
748
- 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
749
754
  };
750
755
  if (concept.id === "nl-cd_DescriptionLocationNL__a64trl") {
751
756
  console.log(`🏗️ [Field Creation] Concept: ${concept.id}, periodType from concept: ${concept.periodType}, Field periodType: ${field2.periodType}, ColumnId: ${columnId}`);
@@ -1050,6 +1055,16 @@ class XBRLFormBuilder {
1050
1055
  return dateString;
1051
1056
  }
1052
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
+ }
1053
1068
  /**
1054
1069
  * Generate previous year columns based on current year columns
1055
1070
  */
@@ -4229,6 +4244,9 @@ let JupiterConceptTree = class extends LitElement {
4229
4244
  title="${this.concept.id}${this.concept.description ? " - " + this.concept.description : ""}">
4230
4245
  ${this.concept.label}
4231
4246
  </div>
4247
+ ${this.concept.balance ? html`
4248
+ <div class="concept-balance ${this.concept.balance}">${this.concept.balance}</div>
4249
+ ` : ""}
4232
4250
  ${this.showAddButton ? html`
4233
4251
  <button class="repeat-btn" type="button" title="Add row"
4234
4252
  @click="${this._handleAddRepeat}">+</button>
@@ -4356,6 +4374,29 @@ JupiterConceptTree.styles = css`
4356
4374
  min-width: 0; /* Allows flex item to shrink below content size */
4357
4375
  }
4358
4376
 
4377
+ .concept-balance {
4378
+ margin-left: 8px;
4379
+ font-size: 11px;
4380
+ font-weight: 600;
4381
+ padding: 2px 6px;
4382
+ border-radius: 3px;
4383
+ text-transform: uppercase;
4384
+ letter-spacing: 0.5px;
4385
+ flex-shrink: 0;
4386
+ }
4387
+
4388
+ .concept-balance.debit {
4389
+ color: #d32f2f;
4390
+ background: rgba(211, 47, 47, 0.1);
4391
+ border: 1px solid rgba(211, 47, 47, 0.3);
4392
+ }
4393
+
4394
+ .concept-balance.credit {
4395
+ color: #388e3c;
4396
+ background: rgba(56, 142, 60, 0.1);
4397
+ border: 1px solid rgba(56, 142, 60, 0.3);
4398
+ }
4399
+
4359
4400
  .field-cell {
4360
4401
  vertical-align: middle;
4361
4402
  padding: 2px 6px;
@@ -8700,6 +8741,19 @@ let JupiterDynamicForm = class extends LitElement {
8700
8741
  }
8701
8742
  return `${startDate} / ${endDate}`;
8702
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
+ }
8703
8757
  _addColumnFromRequest(request, sectionId, insertAfterColumnId) {
8704
8758
  var _a, _b, _c, _d, _e;
8705
8759
  const timestamp = Date.now();
@@ -8898,6 +8952,9 @@ let JupiterDynamicForm = class extends LitElement {
8898
8952
  if (this._shouldCreateFieldForConcept(concept, request)) {
8899
8953
  const existingField = (_a = concept.fields) == null ? void 0 : _a[0];
8900
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);
8901
8958
  if (existingField) {
8902
8959
  field2 = {
8903
8960
  id: `${concept.id}_${columnId}`,
@@ -8911,13 +8968,10 @@ let JupiterDynamicForm = class extends LitElement {
8911
8968
  validation: existingField.validation,
8912
8969
  defaultValue: existingField.defaultValue,
8913
8970
  periodType: concept.periodType,
8914
- // Add periodType from concept
8915
8971
  conceptType: concept.type,
8916
- // CRITICAL: Include conceptType for XBRL validation
8917
- // Set period dates from the add column request
8918
- periodStartDate: request.periodType === "instant" ? request.instantDate : request.startDate,
8919
- periodEndDate: request.periodType === "instant" ? request.instantDate : request.endDate,
8920
- periodInstantDate: concept.periodType === "instant" ? request.instantDate || request.startDate : void 0
8972
+ periodStartDate: colStartDate,
8973
+ periodEndDate: colEndDate,
8974
+ periodInstantDate: concept.periodType === "instant" ? instantDate : void 0
8921
8975
  };
8922
8976
  } else {
8923
8977
  field2 = {
@@ -8932,13 +8986,10 @@ let JupiterDynamicForm = class extends LitElement {
8932
8986
  validation: [],
8933
8987
  defaultValue: "",
8934
8988
  periodType: concept.periodType,
8935
- // Add periodType from concept
8936
8989
  conceptType: concept.type,
8937
- // CRITICAL: Include conceptType for XBRL validation
8938
- // Set period dates from the add column request
8939
- periodStartDate: request.periodType === "instant" ? request.instantDate : request.startDate,
8940
- periodEndDate: request.periodType === "instant" ? request.instantDate : request.endDate,
8941
- periodInstantDate: concept.periodType === "instant" ? request.instantDate || request.startDate : void 0
8990
+ periodStartDate: colStartDate,
8991
+ periodEndDate: colEndDate,
8992
+ periodInstantDate: concept.periodType === "instant" ? instantDate : void 0
8942
8993
  };
8943
8994
  }
8944
8995
  if (!concept.fields) {