jupiter-dynamic-forms 1.17.5 → 1.17.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
@@ -3064,6 +3064,9 @@ let JupiterFormField = class extends LitElement {
3064
3064
  );
3065
3065
  }
3066
3066
  }
3067
+ _isRoundingLevelConcept() {
3068
+ return !!this.conceptId && this.conceptId.includes("DocumentIntendedRoundingLevel");
3069
+ }
3067
3070
  _handleInput(event) {
3068
3071
  const target = event.target;
3069
3072
  let value = target.value;
@@ -3235,6 +3238,9 @@ let JupiterFormField = class extends LitElement {
3235
3238
  console.log(`❌ [FormField] Unit validation failed for ${this.conceptId}: unit is required but not selected`);
3236
3239
  }
3237
3240
  _handlePeriodIconClick() {
3241
+ if (this._isRoundingLevelConcept()) {
3242
+ return;
3243
+ }
3238
3244
  this._availableUnits = this._collectUnitsForConceptType();
3239
3245
  console.log(`📊 [FormField] Collected ${this._availableUnits.length} units for concept ${this.conceptId}:`, this._availableUnits);
3240
3246
  console.log(`📊 [FormField] Current unit value: ${this.unit}`);
@@ -3688,7 +3694,7 @@ let JupiterFormField = class extends LitElement {
3688
3694
  min="0"
3689
3695
  class="typed-member-input"
3690
3696
  placeholder="Leave blank for INF"
3691
- .value="${this.decimals ?? (this.globalDecimals !== "INF" ? this.globalDecimals : "")}"
3697
+ .value="${this.decimals !== void 0 && this.decimals !== null && this.decimals !== "" ? this.decimals : this.globalDecimals !== "INF" ? this.globalDecimals : ""}"
3692
3698
  @input="${this._handleDecimalsChange}"
3693
3699
  ?disabled="${this.disabled}"
3694
3700
  />
@@ -3724,6 +3730,7 @@ let JupiterFormField = class extends LitElement {
3724
3730
  const hasPeriodControl = this.field.periodType && (this.field.periodType === "instant" || this.field.periodType === "duration");
3725
3731
  const baseConceptId = this._extractBaseConceptId(this.conceptId);
3726
3732
  const isPredefinedValue = this.mode !== "admin" && this.masterData && baseConceptId in this.masterData;
3733
+ const isRoundingLevelLocked = this._isRoundingLevelConcept();
3727
3734
  let factValue = null;
3728
3735
  if (this.facts && this.facts.length > 0 && !isPredefinedValue) {
3729
3736
  const cellContext = {
@@ -3778,7 +3785,7 @@ let JupiterFormField = class extends LitElement {
3778
3785
  }
3779
3786
  const hasUserValue = this.value !== null && this.value !== void 0;
3780
3787
  const effectiveValue = isPredefinedValue ? this.masterData[baseConceptId] : hasUserValue ? this.value : factValue;
3781
- const effectiveDisabled = isPredefinedValue || this.disabled || this.mode === "readonly";
3788
+ const effectiveDisabled = isPredefinedValue || isRoundingLevelLocked || this.disabled || this.mode === "readonly";
3782
3789
  return html`
3783
3790
  <div class="field-container">
3784
3791
  ${showLabel ? html`
@@ -3790,7 +3797,7 @@ let JupiterFormField = class extends LitElement {
3790
3797
  <div class="field-wrapper">
3791
3798
  ${this._renderInput(effectiveValue, effectiveDisabled)}
3792
3799
 
3793
- ${hasPeriodControl && this.mode !== "readonly" ? html`
3800
+ ${hasPeriodControl && this.mode !== "readonly" && !isRoundingLevelLocked ? html`
3794
3801
  <button
3795
3802
  class="period-icon-btn"
3796
3803
  type="button"
@@ -8380,6 +8387,7 @@ let JupiterDynamicForm = class extends LitElement {
8380
8387
  if ((_a = this.xbrlInput) == null ? void 0 : _a.initialData) {
8381
8388
  this._formData = { ...this._formData, ...this.xbrlInput.initialData };
8382
8389
  }
8390
+ this._initializeGlobalDecimalsFromRoundingData();
8383
8391
  this._extractTypedMembersFromFacts();
8384
8392
  if (!this._skipDraftLoading) {
8385
8393
  this._loadDraftIfExists().then(() => {
@@ -9100,6 +9108,107 @@ let JupiterDynamicForm = class extends LitElement {
9100
9108
  }
9101
9109
  this._effectiveMasterData = this.masterData ? { ...this.masterData } : void 0;
9102
9110
  }
9111
+ _initializeGlobalDecimalsFromRoundingData() {
9112
+ if (this._hasValidGlobalDecimals()) {
9113
+ return;
9114
+ }
9115
+ const roundingLevel = this._findRoundingLevelFactValue(this._allSections) ?? this._findRoundingLevelValueInFormData(this._formData);
9116
+ if (roundingLevel === void 0 || roundingLevel === null || roundingLevel === "") {
9117
+ return;
9118
+ }
9119
+ const parsed = parseFloat(String(roundingLevel));
9120
+ if (isNaN(parsed)) {
9121
+ return;
9122
+ }
9123
+ this.decimals = String(Math.abs(parsed));
9124
+ }
9125
+ _findRoundingLevelValueInFormData(formData) {
9126
+ if (!formData) {
9127
+ return void 0;
9128
+ }
9129
+ for (const conceptKey of Object.keys(formData)) {
9130
+ if (!this._isRoundingLevelConcept(conceptKey)) {
9131
+ continue;
9132
+ }
9133
+ const columnValues = formData[conceptKey] || {};
9134
+ for (const columnId of Object.keys(columnValues)) {
9135
+ const value = columnValues[columnId];
9136
+ if (value !== void 0 && value !== null && value !== "") {
9137
+ return value;
9138
+ }
9139
+ }
9140
+ }
9141
+ return void 0;
9142
+ }
9143
+ _findRoundingLevelFactValue(sections) {
9144
+ for (const section2 of sections) {
9145
+ const value = this._findRoundingLevelFactValueInConcepts(section2.concepts || []);
9146
+ if (value !== void 0 && value !== null && value !== "") {
9147
+ return value;
9148
+ }
9149
+ }
9150
+ return void 0;
9151
+ }
9152
+ _findRoundingLevelFactValueInConcepts(concepts) {
9153
+ for (const concept of concepts) {
9154
+ const conceptIdToCheck = concept.originalConceptId || concept.id;
9155
+ if (this._isRoundingLevelConcept(conceptIdToCheck)) {
9156
+ const facts = concept.facts || [];
9157
+ for (const fact of facts) {
9158
+ if ((fact == null ? void 0 : fact.value) !== void 0 && (fact == null ? void 0 : fact.value) !== null && (fact == null ? void 0 : fact.value) !== "") {
9159
+ return fact.value;
9160
+ }
9161
+ }
9162
+ }
9163
+ if (concept.children && concept.children.length > 0) {
9164
+ const childValue = this._findRoundingLevelFactValueInConcepts(concept.children);
9165
+ if (childValue !== void 0 && childValue !== null && childValue !== "") {
9166
+ return childValue;
9167
+ }
9168
+ }
9169
+ }
9170
+ return void 0;
9171
+ }
9172
+ _hasValidGlobalDecimals() {
9173
+ if (this.decimals === void 0 || this.decimals === null) {
9174
+ return false;
9175
+ }
9176
+ if (this.decimals === "INF") {
9177
+ return false;
9178
+ }
9179
+ const parsed = parseFloat(this.decimals);
9180
+ return !isNaN(parsed);
9181
+ }
9182
+ _isRoundingLevelConcept(conceptId) {
9183
+ if (!conceptId) {
9184
+ return false;
9185
+ }
9186
+ return conceptId === "rj-i_DocumentIntendedRoundingLevel" || conceptId.includes("DocumentIntendedRoundingLevel");
9187
+ }
9188
+ _findFactValueForField(concept, field2, section2) {
9189
+ var _a, _b;
9190
+ if (!concept.facts || concept.facts.length === 0) {
9191
+ return void 0;
9192
+ }
9193
+ const column2 = this._findColumnByIdInSection(field2.columnId, section2);
9194
+ const fieldPeriodData = (_a = this._periodData[concept.id]) == null ? void 0 : _a[field2.columnId];
9195
+ const periodStartDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.startDate) || (column2 == null ? void 0 : column2.periodStartDate) || field2.periodStartDate || this.periodStartDate;
9196
+ const periodEndDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.endDate) || (column2 == null ? void 0 : column2.periodEndDate) || field2.periodEndDate || this.periodEndDate;
9197
+ const periodInstantDate = (fieldPeriodData == null ? void 0 : fieldPeriodData.instantDate) || field2.periodInstantDate || periodEndDate || periodStartDate;
9198
+ const unit = (_b = this._unitData[concept.id]) == null ? void 0 : _b[field2.columnId];
9199
+ const cellContext = {
9200
+ conceptId: concept.originalConceptId || field2.conceptId || concept.id,
9201
+ columnId: field2.columnId,
9202
+ periodStartDate,
9203
+ periodEndDate,
9204
+ periodInstantDate,
9205
+ periodType: field2.periodType,
9206
+ unit,
9207
+ dimensionData: column2 == null ? void 0 : column2.dimensionData
9208
+ };
9209
+ const matchedFact = FactMatcher.findMatchingFact(concept.facts, cellContext);
9210
+ return matchedFact == null ? void 0 : matchedFact.value;
9211
+ }
9103
9212
  _storeDecimals(conceptId, columnId, decimals) {
9104
9213
  const updated = { ...this._decimalsData };
9105
9214
  if (!updated[conceptId])
@@ -10034,6 +10143,7 @@ let JupiterDynamicForm = class extends LitElement {
10034
10143
  });
10035
10144
  this._formData = { ...this._formData, ...restoredFormData };
10036
10145
  console.log(`🔄 Restored ${Object.keys(restoredFormData).length} concepts with data`);
10146
+ this._initializeGlobalDecimalsFromRoundingData();
10037
10147
  this._periodData = {
10038
10148
  ...this._periodData,
10039
10149
  ...metadata.periodData || {},
@@ -10672,8 +10782,14 @@ let JupiterDynamicForm = class extends LitElement {
10672
10782
  var _a, _b, _c, _d, _e, _f, _g, _h;
10673
10783
  const conceptData = this._formData[concept.id];
10674
10784
  let fieldValue = conceptData == null ? void 0 : conceptData[field2.columnId];
10785
+ const baseConceptId = field2.conceptId || concept.id.split("__").slice(0, -1).join("__") || concept.id;
10786
+ if ((fieldValue === void 0 || fieldValue === null || fieldValue === "") && this._isRoundingLevelConcept(baseConceptId) && !this._hasValidGlobalDecimals()) {
10787
+ const factValue = this._findFactValueForField(concept, field2, section2);
10788
+ if (factValue !== void 0 && factValue !== null && factValue !== "") {
10789
+ fieldValue = factValue;
10790
+ }
10791
+ }
10675
10792
  if ((fieldValue === void 0 || fieldValue === null || fieldValue === "") && this._effectiveMasterData) {
10676
- const baseConceptId = field2.conceptId || concept.id.split("__").slice(0, -1).join("__") || concept.id;
10677
10793
  const masterValue = (_a = this._effectiveMasterData) == null ? void 0 : _a[baseConceptId];
10678
10794
  if (masterValue !== void 0 && masterValue !== null && masterValue !== "") {
10679
10795
  fieldValue = masterValue;