jupiter-dynamic-forms 1.17.2 → 1.17.4

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
@@ -2137,7 +2137,7 @@ class DraftStorageService {
2137
2137
  /**
2138
2138
  * Create metadata snapshot from current form state
2139
2139
  */
2140
- createMetadataSnapshot(periodStartDate, periodEndDate, language, selectedRoleIds, allSections, typedMemberData, periodPreferences, periodData, unitData, reportingLanguage = "en", repeatCounts) {
2140
+ createMetadataSnapshot(periodStartDate, periodEndDate, language, selectedRoleIds, allSections, typedMemberData, periodPreferences, periodData, unitData, reportingLanguage = "en", repeatCounts, decimalsData) {
2141
2141
  return {
2142
2142
  periodStartDate,
2143
2143
  periodEndDate,
@@ -2150,6 +2150,7 @@ class DraftStorageService {
2150
2150
  periodPreferences,
2151
2151
  periodData,
2152
2152
  unitData,
2153
+ decimalsData,
2153
2154
  repeatCounts,
2154
2155
  schemaVersion: this.STORAGE_VERSION
2155
2156
  };
@@ -3016,6 +3017,7 @@ let JupiterFormField = class extends LitElement {
3016
3017
  this.locale = "en-US";
3017
3018
  this.hideLabel = false;
3018
3019
  this.mode = "inputForm";
3020
+ this.globalDecimals = "INF";
3019
3021
  this.typedMemberValues = {};
3020
3022
  this._errors = [];
3021
3023
  this._xbrlErrors = [];
@@ -3317,6 +3319,15 @@ let JupiterFormField = class extends LitElement {
3317
3319
  }));
3318
3320
  console.log(`🏷️ [FormField] unit-change event dispatched`);
3319
3321
  }
3322
+ _handleDecimalsChange(event) {
3323
+ const value = event.target.value.trim();
3324
+ this.decimals = value || void 0;
3325
+ this.dispatchEvent(new CustomEvent("decimals-change", {
3326
+ detail: { conceptId: this.conceptId, columnId: this.columnId, decimals: this.decimals },
3327
+ bubbles: true,
3328
+ composed: true
3329
+ }));
3330
+ }
3320
3331
  _handlePopupOverlayClick(e2) {
3321
3332
  if (e2.target === e2.currentTarget) {
3322
3333
  this._closePeriodPopup();
@@ -3665,6 +3676,20 @@ let JupiterFormField = class extends LitElement {
3665
3676
  </div>
3666
3677
  ` : ""}
3667
3678
 
3679
+ ${this._isMonetaryType() ? html`
3680
+ <div class="period-controls">
3681
+ <label>Decimals:</label>
3682
+ <input
3683
+ type="number"
3684
+ class="typed-member-input"
3685
+ placeholder="Leave blank for INF"
3686
+ .value="${this.decimals ?? (this.globalDecimals !== "INF" ? this.globalDecimals : "")}"
3687
+ @input="${this._handleDecimalsChange}"
3688
+ ?disabled="${this.disabled}"
3689
+ />
3690
+ </div>
3691
+ ` : ""}
3692
+
3668
3693
  ${this.field.crossRoleTypedMembers && this.field.crossRoleTypedMembers.length > 0 ? html`
3669
3694
  ${this.field.crossRoleTypedMembers.map((tm) => html`
3670
3695
  <div class="period-controls">
@@ -4201,6 +4226,12 @@ __decorateClass$6([
4201
4226
  __decorateClass$6([
4202
4227
  n2({ type: String })
4203
4228
  ], JupiterFormField.prototype, "unit", 2);
4229
+ __decorateClass$6([
4230
+ n2({ type: String })
4231
+ ], JupiterFormField.prototype, "decimals", 2);
4232
+ __decorateClass$6([
4233
+ n2({ type: String })
4234
+ ], JupiterFormField.prototype, "globalDecimals", 2);
4204
4235
  __decorateClass$6([
4205
4236
  n2({ type: Object })
4206
4237
  ], JupiterFormField.prototype, "typedMemberValues", 2);
@@ -4240,6 +4271,8 @@ let JupiterConceptTree = class extends LitElement {
4240
4271
  this.formData = {};
4241
4272
  this.periodData = {};
4242
4273
  this.unitData = {};
4274
+ this.decimalsData = {};
4275
+ this.globalDecimals = "INF";
4243
4276
  this.defaultUnits = [];
4244
4277
  this.disabled = false;
4245
4278
  this.locale = "en-US";
@@ -4351,12 +4384,13 @@ let JupiterConceptTree = class extends LitElement {
4351
4384
 
4352
4385
  <!-- Input Field Cells (Period Columns) - Only for non-abstract concepts -->
4353
4386
  ${this.columns.map((column2) => {
4354
- var _a, _b, _c;
4387
+ var _a, _b, _c, _d, _e;
4355
4388
  const field2 = this._getFieldForColumn(column2.id);
4356
4389
  const shouldShowField = !isAbstract && field2;
4357
4390
  const storedUnit = (_b = (_a = this.unitData) == null ? void 0 : _a[this.concept.id]) == null ? void 0 : _b[column2.id];
4391
+ const storedDecimals = (_d = (_c = this.decimalsData) == null ? void 0 : _c[this.concept.id]) == null ? void 0 : _d[column2.id];
4358
4392
  return html`
4359
- <td class="field-cell ${!shouldShowField ? "empty" : ""} ${isAbstract ? "abstract-row" : ""} ${this.highlightType && column2.id === this.highlightColumnId ? "highlight-" + this.highlightType : ""} ${((_c = this.calculationErrorKeys) == null ? void 0 : _c.has(`${this.concept.id}__${column2.id}`)) ? "calc-error" : ""}">
4393
+ <td class="field-cell ${!shouldShowField ? "empty" : ""} ${isAbstract ? "abstract-row" : ""} ${this.highlightType && column2.id === this.highlightColumnId ? "highlight-" + this.highlightType : ""} ${((_e = this.calculationErrorKeys) == null ? void 0 : _e.has(`${this.concept.id}__${column2.id}`)) ? "calc-error" : ""}">
4360
4394
  ${shouldShowField ? html`
4361
4395
  <jupiter-form-field
4362
4396
  .field="${field2}"
@@ -4367,6 +4401,8 @@ let JupiterConceptTree = class extends LitElement {
4367
4401
  .columnId="${column2.id}"
4368
4402
  .value="${this._getFieldValue(field2)}"
4369
4403
  .unit="${storedUnit || ""}"
4404
+ .decimals="${storedDecimals}"
4405
+ .globalDecimals="${this.globalDecimals}"
4370
4406
  .periodStartDate="${field2.periodStartDate || column2.periodStartDate}"
4371
4407
  .periodEndDate="${field2.periodEndDate || column2.periodEndDate}"
4372
4408
  .periodInstantDate="${field2.periodInstantDate || (field2.periodType === "instant" ? field2.periodEndDate || field2.periodStartDate : void 0)}"
@@ -4575,6 +4611,12 @@ __decorateClass$5([
4575
4611
  __decorateClass$5([
4576
4612
  n2({ type: Object })
4577
4613
  ], JupiterConceptTree.prototype, "unitData", 2);
4614
+ __decorateClass$5([
4615
+ n2({ type: Object })
4616
+ ], JupiterConceptTree.prototype, "decimalsData", 2);
4617
+ __decorateClass$5([
4618
+ n2({ type: String })
4619
+ ], JupiterConceptTree.prototype, "globalDecimals", 2);
4578
4620
  __decorateClass$5([
4579
4621
  n2({ type: Array })
4580
4622
  ], JupiterConceptTree.prototype, "defaultUnits", 2);
@@ -5271,6 +5313,8 @@ let JupiterFormSection = class extends LitElement {
5271
5313
  this.formData = {};
5272
5314
  this.periodData = {};
5273
5315
  this.unitData = {};
5316
+ this.decimalsData = {};
5317
+ this.globalDecimals = "INF";
5274
5318
  this.typedMemberData = {};
5275
5319
  this.repeatCounts = {};
5276
5320
  this.defaultUnits = [];
@@ -5291,9 +5335,6 @@ let JupiterFormSection = class extends LitElement {
5291
5335
  this._insertAfterColumnId = null;
5292
5336
  this._boundFieldBlur = (e2) => {
5293
5337
  this._clearHighlights();
5294
- const { conceptId, columnId } = e2.detail || {};
5295
- if (conceptId && columnId)
5296
- this._runCalculationCheck(conceptId, columnId);
5297
5338
  };
5298
5339
  this._expandedConcepts = /* @__PURE__ */ new Set();
5299
5340
  this._allTreeExpanded = false;
@@ -5542,7 +5583,7 @@ let JupiterFormSection = class extends LitElement {
5542
5583
  this._traverseTotalGroups(concepts);
5543
5584
  }
5544
5585
  _traverseTotalGroups(concepts) {
5545
- var _a, _b, _c;
5586
+ var _a, _b, _c, _d;
5546
5587
  for (let i2 = 0; i2 < concepts.length; i2++) {
5547
5588
  const concept = concepts[i2];
5548
5589
  if ((_a = concept.preferredLabel) == null ? void 0 : _a.includes("totalLabel")) {
@@ -5555,7 +5596,14 @@ let JupiterFormSection = class extends LitElement {
5555
5596
  this._memberParentMap.set(childId, concept.id);
5556
5597
  }
5557
5598
  } else {
5558
- const siblings = concepts.slice(0, i2);
5599
+ let lastTotalIdx = -1;
5600
+ for (let j = i2 - 1; j >= 0; j--) {
5601
+ if ((_c = concepts[j].preferredLabel) == null ? void 0 : _c.includes("totalLabel")) {
5602
+ lastTotalIdx = j;
5603
+ break;
5604
+ }
5605
+ }
5606
+ const siblings = concepts.slice(lastTotalIdx + 1, i2);
5559
5607
  if (siblings.length > 0) {
5560
5608
  const siblingIds = siblings.map((s2) => s2.id);
5561
5609
  this._totalChildrenMap.set(concept.id, siblingIds);
@@ -5567,7 +5615,7 @@ let JupiterFormSection = class extends LitElement {
5567
5615
  }
5568
5616
  }
5569
5617
  }
5570
- if ((_c = concept.children) == null ? void 0 : _c.length) {
5618
+ if ((_d = concept.children) == null ? void 0 : _d.length) {
5571
5619
  this._traverseTotalGroups(concept.children);
5572
5620
  }
5573
5621
  }
@@ -5702,6 +5750,8 @@ let JupiterFormSection = class extends LitElement {
5702
5750
  .formData="${this.formData}"
5703
5751
  .periodData="${this.periodData}"
5704
5752
  .unitData="${this.unitData}"
5753
+ .decimalsData="${this.decimalsData}"
5754
+ .globalDecimals="${this.globalDecimals}"
5705
5755
  .defaultUnits="${this.defaultUnits}"
5706
5756
  .disabled="${this.disabled}"
5707
5757
  .locale="${this.locale}"
@@ -6171,6 +6221,12 @@ __decorateClass$3([
6171
6221
  __decorateClass$3([
6172
6222
  n2({ type: Object })
6173
6223
  ], JupiterFormSection.prototype, "unitData", 2);
6224
+ __decorateClass$3([
6225
+ n2({ type: Object })
6226
+ ], JupiterFormSection.prototype, "decimalsData", 2);
6227
+ __decorateClass$3([
6228
+ n2({ type: String })
6229
+ ], JupiterFormSection.prototype, "globalDecimals", 2);
6174
6230
  __decorateClass$3([
6175
6231
  n2({ type: Object })
6176
6232
  ], JupiterFormSection.prototype, "typedMemberData", 2);
@@ -8102,6 +8158,7 @@ let JupiterDynamicForm = class extends LitElement {
8102
8158
  this.showLastValidationResultBtn = false;
8103
8159
  this.isDraftSaving = false;
8104
8160
  this.defaultUnits = [];
8161
+ this.decimals = "INF";
8105
8162
  this._formData = {};
8106
8163
  this._draftLoaded = false;
8107
8164
  this._preservedFormData = {};
@@ -8109,6 +8166,7 @@ let JupiterDynamicForm = class extends LitElement {
8109
8166
  this._preservedPeriodData = {};
8110
8167
  this._unitData = {};
8111
8168
  this._preservedUnitData = {};
8169
+ this._decimalsData = {};
8112
8170
  this._typedMemberData = {};
8113
8171
  this._preservedTypedMemberData = {};
8114
8172
  this._repeatCounts = {};
@@ -8157,6 +8215,9 @@ let JupiterDynamicForm = class extends LitElement {
8157
8215
  console.log(`🏷️ [GLOBAL DynamicForm] Event detail:`, customEvent.detail);
8158
8216
  this._handleUnitChange(customEvent);
8159
8217
  });
8218
+ this.addEventListener("decimals-change", (e2) => {
8219
+ this._handleDecimalsChange(e2);
8220
+ });
8160
8221
  this.addEventListener("field-blur", (e2) => {
8161
8222
  console.log("🚨 [DynamicForm] field-blur event listener triggered!", e2);
8162
8223
  const customEvent = e2;
@@ -8849,7 +8910,8 @@ let JupiterDynamicForm = class extends LitElement {
8849
8910
  this._periodData,
8850
8911
  this._unitData,
8851
8912
  this.reportingLanguage,
8852
- this._repeatCounts
8913
+ this._repeatCounts,
8914
+ this._decimalsData
8853
8915
  );
8854
8916
  this._draftStorageService.saveDraft(currentFormData, currentMetadata);
8855
8917
  console.log("✅ Current form data saved to draft storage with NEW preferences");
@@ -9007,6 +9069,21 @@ let JupiterDynamicForm = class extends LitElement {
9007
9069
  console.log(`💾 [_storeUnit] Unit data stored for [${conceptId}][${columnId}]:`, this._unitData[conceptId][columnId]);
9008
9070
  console.log(`📦 [_storeUnit] Full unit data state after update:`, JSON.stringify(this._unitData, null, 2));
9009
9071
  }
9072
+ _handleDecimalsChange(event) {
9073
+ const { conceptId, columnId, decimals } = event.detail;
9074
+ if (!conceptId || !columnId)
9075
+ return;
9076
+ this._storeDecimals(conceptId, columnId, decimals);
9077
+ this._dirty = true;
9078
+ this.requestUpdate();
9079
+ }
9080
+ _storeDecimals(conceptId, columnId, decimals) {
9081
+ const updated = { ...this._decimalsData };
9082
+ if (!updated[conceptId])
9083
+ updated[conceptId] = {};
9084
+ updated[conceptId] = { ...updated[conceptId], [columnId]: decimals ?? "" };
9085
+ this._decimalsData = updated;
9086
+ }
9010
9087
  /**
9011
9088
  * Generate a unique concept key that includes section context
9012
9089
  */
@@ -9724,7 +9801,8 @@ let JupiterDynamicForm = class extends LitElement {
9724
9801
  this._periodData,
9725
9802
  this._unitData,
9726
9803
  this.reportingLanguage,
9727
- this._repeatCounts
9804
+ this._repeatCounts,
9805
+ this._decimalsData
9728
9806
  );
9729
9807
  const draftPayloadSnapshot = JSON.stringify({
9730
9808
  draftData,
@@ -9850,6 +9928,10 @@ let JupiterDynamicForm = class extends LitElement {
9850
9928
  this._unitData = metadata.unitData;
9851
9929
  console.log("🔄 Restored custom field-level unit data:", Object.keys(this._unitData).length, "concepts");
9852
9930
  }
9931
+ if (metadata.decimalsData) {
9932
+ this._decimalsData = metadata.decimalsData;
9933
+ console.log("🔄 Restored per-fact decimals data:", Object.keys(this._decimalsData).length, "concepts");
9934
+ }
9853
9935
  if (metadata.periodPreferences) {
9854
9936
  if (this._skipPeriodPreferencesRestore) {
9855
9937
  console.log("⏭️ Skipping period preferences restoration - using new filter selections");
@@ -10391,7 +10473,7 @@ let JupiterDynamicForm = class extends LitElement {
10391
10473
  return null;
10392
10474
  }
10393
10475
  _addConceptDataToSubmission(concept, columnId, value, submissionData, section2) {
10394
- var _a, _b, _c;
10476
+ var _a, _b, _c, _d, _e;
10395
10477
  const field2 = concept.fields.find((f2) => f2.columnId === columnId);
10396
10478
  if (!field2)
10397
10479
  return;
@@ -10419,7 +10501,13 @@ let JupiterDynamicForm = class extends LitElement {
10419
10501
  entry.unit = fieldUnit;
10420
10502
  console.log(`✅ [Submission] Adding unit to entry: ${fieldUnit} for ${concept.id}/${columnId}`);
10421
10503
  }
10422
- if ((_c = column2 == null ? void 0 : column2.dimensionData) == null ? void 0 : _c.memberLabel) {
10504
+ const isMonetary = (_c = concept.type) == null ? void 0 : _c.toLowerCase().includes("monetary");
10505
+ const fieldDecimals = (_d = this._decimalsData[concept.id]) == null ? void 0 : _d[columnId];
10506
+ const decimalsValue = fieldDecimals || (this.decimals !== "INF" ? this.decimals : void 0);
10507
+ if (isMonetary && decimalsValue) {
10508
+ entry.decimals = decimalsValue;
10509
+ }
10510
+ if ((_e = column2 == null ? void 0 : column2.dimensionData) == null ? void 0 : _e.memberLabel) {
10423
10511
  entry.dimension = column2.dimensionData.memberLabel;
10424
10512
  }
10425
10513
  console.log(`📤 [Submission Entry] Created entry:`, JSON.stringify(entry, null, 2));
@@ -10557,7 +10645,7 @@ let JupiterDynamicForm = class extends LitElement {
10557
10645
  }
10558
10646
  if (concept.fields && concept.fields.length > 0) {
10559
10647
  concept.fields.forEach((field2) => {
10560
- var _a, _b, _c, _d, _e;
10648
+ var _a, _b, _c, _d, _e, _f, _g;
10561
10649
  const conceptData = this._formData[concept.id];
10562
10650
  let fieldValue = conceptData == null ? void 0 : conceptData[field2.columnId];
10563
10651
  if ((fieldValue === void 0 || fieldValue === null || fieldValue === "") && this.masterData) {
@@ -10599,7 +10687,13 @@ let JupiterDynamicForm = class extends LitElement {
10599
10687
  } else {
10600
10688
  console.log(`⚠️ [Submission] No unit found in _unitData for ${concept.id}/${field2.columnId}. _unitData state:`, JSON.stringify(this._unitData, null, 2));
10601
10689
  }
10602
- if ((column2 == null ? void 0 : column2.type) === "dimension" && ((_c = column2.dimensionData) == null ? void 0 : _c.dimensionIdKey)) {
10690
+ const isMonetary = (_c = concept.type) == null ? void 0 : _c.toLowerCase().includes("monetary");
10691
+ const fieldDecimals = (_d = this._decimalsData[concept.id]) == null ? void 0 : _d[field2.columnId];
10692
+ const decimalsValue = fieldDecimals || (this.decimals !== "INF" ? this.decimals : void 0);
10693
+ if (isMonetary && decimalsValue) {
10694
+ submissionEntry.decimals = decimalsValue;
10695
+ }
10696
+ if ((column2 == null ? void 0 : column2.type) === "dimension" && ((_e = column2.dimensionData) == null ? void 0 : _e.dimensionIdKey)) {
10603
10697
  submissionEntry.dimension = column2.dimensionData.dimensionIdKey;
10604
10698
  console.log(`🔍 [DynamicForm] Using dimension key from field's column (${field2.columnId}):`, column2.dimensionData.dimensionIdKey);
10605
10699
  } else {
@@ -10635,12 +10729,12 @@ let JupiterDynamicForm = class extends LitElement {
10635
10729
  console.log(`🔍 [DynamicForm] Column details:`, {
10636
10730
  id: column2.id,
10637
10731
  type: column2.type,
10638
- hasTypedMembers: (_d = column2.dimensionData) == null ? void 0 : _d.hasTypedMembers,
10732
+ hasTypedMembers: (_f = column2.dimensionData) == null ? void 0 : _f.hasTypedMembers,
10639
10733
  dimensionData: column2.dimensionData
10640
10734
  });
10641
10735
  }
10642
10736
  }
10643
- if (!submissionEntry.typedMembers && ((_e = field2.crossRoleTypedMembers) == null ? void 0 : _e.length)) {
10737
+ if (!submissionEntry.typedMembers && ((_g = field2.crossRoleTypedMembers) == null ? void 0 : _g.length)) {
10644
10738
  const crossRoleKey = `${concept.id}__${field2.columnId}`;
10645
10739
  const crossRoleValues = this._typedMemberData[crossRoleKey];
10646
10740
  if (crossRoleValues) {
@@ -11444,6 +11538,8 @@ let JupiterDynamicForm = class extends LitElement {
11444
11538
  .formData="${this._formData}"
11445
11539
  .periodData="${this._periodData}"
11446
11540
  .unitData="${this._unitData}"
11541
+ .decimalsData="${this._decimalsData}"
11542
+ .globalDecimals="${this.decimals}"
11447
11543
  .typedMemberData="${this._typedMemberData}"
11448
11544
  .repeatCounts="${this._repeatCounts}"
11449
11545
  .defaultUnits="${this.defaultUnits}"
@@ -11584,6 +11680,8 @@ let JupiterDynamicForm = class extends LitElement {
11584
11680
  .formData="${this._formData}"
11585
11681
  .periodData="${this._periodData}"
11586
11682
  .unitData="${this._unitData}"
11683
+ .decimalsData="${this._decimalsData}"
11684
+ .globalDecimals="${this.decimals}"
11587
11685
  .typedMemberData="${this._typedMemberData}"
11588
11686
  .repeatCounts="${this._repeatCounts}"
11589
11687
  .defaultUnits="${this.defaultUnits}"
@@ -12630,6 +12728,9 @@ __decorateClass([
12630
12728
  __decorateClass([
12631
12729
  n2({ type: Array })
12632
12730
  ], JupiterDynamicForm.prototype, "defaultUnits", 2);
12731
+ __decorateClass([
12732
+ n2({ type: String })
12733
+ ], JupiterDynamicForm.prototype, "decimals", 2);
12633
12734
  __decorateClass([
12634
12735
  n2({ type: Object, attribute: "master-data" })
12635
12736
  ], JupiterDynamicForm.prototype, "masterData", 2);
@@ -12663,6 +12764,9 @@ __decorateClass([
12663
12764
  __decorateClass([
12664
12765
  r()
12665
12766
  ], JupiterDynamicForm.prototype, "_preservedUnitData", 2);
12767
+ __decorateClass([
12768
+ r()
12769
+ ], JupiterDynamicForm.prototype, "_decimalsData", 2);
12666
12770
  __decorateClass([
12667
12771
  r()
12668
12772
  ], JupiterDynamicForm.prototype, "_typedMemberData", 2);