jupiter-dynamic-forms 1.17.3 → 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 = [];
@@ -5706,6 +5750,8 @@ let JupiterFormSection = class extends LitElement {
5706
5750
  .formData="${this.formData}"
5707
5751
  .periodData="${this.periodData}"
5708
5752
  .unitData="${this.unitData}"
5753
+ .decimalsData="${this.decimalsData}"
5754
+ .globalDecimals="${this.globalDecimals}"
5709
5755
  .defaultUnits="${this.defaultUnits}"
5710
5756
  .disabled="${this.disabled}"
5711
5757
  .locale="${this.locale}"
@@ -6175,6 +6221,12 @@ __decorateClass$3([
6175
6221
  __decorateClass$3([
6176
6222
  n2({ type: Object })
6177
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);
6178
6230
  __decorateClass$3([
6179
6231
  n2({ type: Object })
6180
6232
  ], JupiterFormSection.prototype, "typedMemberData", 2);
@@ -8106,6 +8158,7 @@ let JupiterDynamicForm = class extends LitElement {
8106
8158
  this.showLastValidationResultBtn = false;
8107
8159
  this.isDraftSaving = false;
8108
8160
  this.defaultUnits = [];
8161
+ this.decimals = "INF";
8109
8162
  this._formData = {};
8110
8163
  this._draftLoaded = false;
8111
8164
  this._preservedFormData = {};
@@ -8113,6 +8166,7 @@ let JupiterDynamicForm = class extends LitElement {
8113
8166
  this._preservedPeriodData = {};
8114
8167
  this._unitData = {};
8115
8168
  this._preservedUnitData = {};
8169
+ this._decimalsData = {};
8116
8170
  this._typedMemberData = {};
8117
8171
  this._preservedTypedMemberData = {};
8118
8172
  this._repeatCounts = {};
@@ -8161,6 +8215,9 @@ let JupiterDynamicForm = class extends LitElement {
8161
8215
  console.log(`🏷️ [GLOBAL DynamicForm] Event detail:`, customEvent.detail);
8162
8216
  this._handleUnitChange(customEvent);
8163
8217
  });
8218
+ this.addEventListener("decimals-change", (e2) => {
8219
+ this._handleDecimalsChange(e2);
8220
+ });
8164
8221
  this.addEventListener("field-blur", (e2) => {
8165
8222
  console.log("🚨 [DynamicForm] field-blur event listener triggered!", e2);
8166
8223
  const customEvent = e2;
@@ -8853,7 +8910,8 @@ let JupiterDynamicForm = class extends LitElement {
8853
8910
  this._periodData,
8854
8911
  this._unitData,
8855
8912
  this.reportingLanguage,
8856
- this._repeatCounts
8913
+ this._repeatCounts,
8914
+ this._decimalsData
8857
8915
  );
8858
8916
  this._draftStorageService.saveDraft(currentFormData, currentMetadata);
8859
8917
  console.log("✅ Current form data saved to draft storage with NEW preferences");
@@ -9011,6 +9069,21 @@ let JupiterDynamicForm = class extends LitElement {
9011
9069
  console.log(`💾 [_storeUnit] Unit data stored for [${conceptId}][${columnId}]:`, this._unitData[conceptId][columnId]);
9012
9070
  console.log(`📦 [_storeUnit] Full unit data state after update:`, JSON.stringify(this._unitData, null, 2));
9013
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
+ }
9014
9087
  /**
9015
9088
  * Generate a unique concept key that includes section context
9016
9089
  */
@@ -9728,7 +9801,8 @@ let JupiterDynamicForm = class extends LitElement {
9728
9801
  this._periodData,
9729
9802
  this._unitData,
9730
9803
  this.reportingLanguage,
9731
- this._repeatCounts
9804
+ this._repeatCounts,
9805
+ this._decimalsData
9732
9806
  );
9733
9807
  const draftPayloadSnapshot = JSON.stringify({
9734
9808
  draftData,
@@ -9854,6 +9928,10 @@ let JupiterDynamicForm = class extends LitElement {
9854
9928
  this._unitData = metadata.unitData;
9855
9929
  console.log("🔄 Restored custom field-level unit data:", Object.keys(this._unitData).length, "concepts");
9856
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
+ }
9857
9935
  if (metadata.periodPreferences) {
9858
9936
  if (this._skipPeriodPreferencesRestore) {
9859
9937
  console.log("⏭️ Skipping period preferences restoration - using new filter selections");
@@ -10395,7 +10473,7 @@ let JupiterDynamicForm = class extends LitElement {
10395
10473
  return null;
10396
10474
  }
10397
10475
  _addConceptDataToSubmission(concept, columnId, value, submissionData, section2) {
10398
- var _a, _b, _c;
10476
+ var _a, _b, _c, _d, _e;
10399
10477
  const field2 = concept.fields.find((f2) => f2.columnId === columnId);
10400
10478
  if (!field2)
10401
10479
  return;
@@ -10423,7 +10501,13 @@ let JupiterDynamicForm = class extends LitElement {
10423
10501
  entry.unit = fieldUnit;
10424
10502
  console.log(`✅ [Submission] Adding unit to entry: ${fieldUnit} for ${concept.id}/${columnId}`);
10425
10503
  }
10426
- 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) {
10427
10511
  entry.dimension = column2.dimensionData.memberLabel;
10428
10512
  }
10429
10513
  console.log(`📤 [Submission Entry] Created entry:`, JSON.stringify(entry, null, 2));
@@ -10561,7 +10645,7 @@ let JupiterDynamicForm = class extends LitElement {
10561
10645
  }
10562
10646
  if (concept.fields && concept.fields.length > 0) {
10563
10647
  concept.fields.forEach((field2) => {
10564
- var _a, _b, _c, _d, _e;
10648
+ var _a, _b, _c, _d, _e, _f, _g;
10565
10649
  const conceptData = this._formData[concept.id];
10566
10650
  let fieldValue = conceptData == null ? void 0 : conceptData[field2.columnId];
10567
10651
  if ((fieldValue === void 0 || fieldValue === null || fieldValue === "") && this.masterData) {
@@ -10603,7 +10687,13 @@ let JupiterDynamicForm = class extends LitElement {
10603
10687
  } else {
10604
10688
  console.log(`⚠️ [Submission] No unit found in _unitData for ${concept.id}/${field2.columnId}. _unitData state:`, JSON.stringify(this._unitData, null, 2));
10605
10689
  }
10606
- 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)) {
10607
10697
  submissionEntry.dimension = column2.dimensionData.dimensionIdKey;
10608
10698
  console.log(`🔍 [DynamicForm] Using dimension key from field's column (${field2.columnId}):`, column2.dimensionData.dimensionIdKey);
10609
10699
  } else {
@@ -10639,12 +10729,12 @@ let JupiterDynamicForm = class extends LitElement {
10639
10729
  console.log(`🔍 [DynamicForm] Column details:`, {
10640
10730
  id: column2.id,
10641
10731
  type: column2.type,
10642
- hasTypedMembers: (_d = column2.dimensionData) == null ? void 0 : _d.hasTypedMembers,
10732
+ hasTypedMembers: (_f = column2.dimensionData) == null ? void 0 : _f.hasTypedMembers,
10643
10733
  dimensionData: column2.dimensionData
10644
10734
  });
10645
10735
  }
10646
10736
  }
10647
- if (!submissionEntry.typedMembers && ((_e = field2.crossRoleTypedMembers) == null ? void 0 : _e.length)) {
10737
+ if (!submissionEntry.typedMembers && ((_g = field2.crossRoleTypedMembers) == null ? void 0 : _g.length)) {
10648
10738
  const crossRoleKey = `${concept.id}__${field2.columnId}`;
10649
10739
  const crossRoleValues = this._typedMemberData[crossRoleKey];
10650
10740
  if (crossRoleValues) {
@@ -11448,6 +11538,8 @@ let JupiterDynamicForm = class extends LitElement {
11448
11538
  .formData="${this._formData}"
11449
11539
  .periodData="${this._periodData}"
11450
11540
  .unitData="${this._unitData}"
11541
+ .decimalsData="${this._decimalsData}"
11542
+ .globalDecimals="${this.decimals}"
11451
11543
  .typedMemberData="${this._typedMemberData}"
11452
11544
  .repeatCounts="${this._repeatCounts}"
11453
11545
  .defaultUnits="${this.defaultUnits}"
@@ -11588,6 +11680,8 @@ let JupiterDynamicForm = class extends LitElement {
11588
11680
  .formData="${this._formData}"
11589
11681
  .periodData="${this._periodData}"
11590
11682
  .unitData="${this._unitData}"
11683
+ .decimalsData="${this._decimalsData}"
11684
+ .globalDecimals="${this.decimals}"
11591
11685
  .typedMemberData="${this._typedMemberData}"
11592
11686
  .repeatCounts="${this._repeatCounts}"
11593
11687
  .defaultUnits="${this.defaultUnits}"
@@ -12634,6 +12728,9 @@ __decorateClass([
12634
12728
  __decorateClass([
12635
12729
  n2({ type: Array })
12636
12730
  ], JupiterDynamicForm.prototype, "defaultUnits", 2);
12731
+ __decorateClass([
12732
+ n2({ type: String })
12733
+ ], JupiterDynamicForm.prototype, "decimals", 2);
12637
12734
  __decorateClass([
12638
12735
  n2({ type: Object, attribute: "master-data" })
12639
12736
  ], JupiterDynamicForm.prototype, "masterData", 2);
@@ -12667,6 +12764,9 @@ __decorateClass([
12667
12764
  __decorateClass([
12668
12765
  r()
12669
12766
  ], JupiterDynamicForm.prototype, "_preservedUnitData", 2);
12767
+ __decorateClass([
12768
+ r()
12769
+ ], JupiterDynamicForm.prototype, "_decimalsData", 2);
12670
12770
  __decorateClass([
12671
12771
  r()
12672
12772
  ], JupiterDynamicForm.prototype, "_typedMemberData", 2);