jupiter-dynamic-forms 1.17.4 → 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
@@ -1702,7 +1702,8 @@ const field$1 = {
1702
1702
  urlPlaceholder: "https://example.com",
1703
1703
  phonePlaceholder: "+1 (555) 000-0000",
1704
1704
  enterValue: "Enter value",
1705
- enterDetailedInformation: "Enter detailed information..."
1705
+ enterDetailedInformation: "Enter detailed information...",
1706
+ scale: "Scale"
1706
1707
  };
1707
1708
  const admin$1 = {
1708
1709
  title: "Configure Roles",
@@ -1855,7 +1856,8 @@ const field = {
1855
1856
  urlPlaceholder: "https://voorbeeld.nl",
1856
1857
  phonePlaceholder: "+31 (0)20 123 4567",
1857
1858
  enterValue: "Voer waarde in",
1858
- enterDetailedInformation: "Voer gedetailleerde informatie in..."
1859
+ enterDetailedInformation: "Voer gedetailleerde informatie in...",
1860
+ scale: "Schaal"
1859
1861
  };
1860
1862
  const admin = {
1861
1863
  title: "Rollen configureren",
@@ -3062,6 +3064,9 @@ let JupiterFormField = class extends LitElement {
3062
3064
  );
3063
3065
  }
3064
3066
  }
3067
+ _isRoundingLevelConcept() {
3068
+ return !!this.conceptId && this.conceptId.includes("DocumentIntendedRoundingLevel");
3069
+ }
3065
3070
  _handleInput(event) {
3066
3071
  const target = event.target;
3067
3072
  let value = target.value;
@@ -3233,6 +3238,9 @@ let JupiterFormField = class extends LitElement {
3233
3238
  console.log(`❌ [FormField] Unit validation failed for ${this.conceptId}: unit is required but not selected`);
3234
3239
  }
3235
3240
  _handlePeriodIconClick() {
3241
+ if (this._isRoundingLevelConcept()) {
3242
+ return;
3243
+ }
3236
3244
  this._availableUnits = this._collectUnitsForConceptType();
3237
3245
  console.log(`📊 [FormField] Collected ${this._availableUnits.length} units for concept ${this.conceptId}:`, this._availableUnits);
3238
3246
  console.log(`📊 [FormField] Current unit value: ${this.unit}`);
@@ -3320,7 +3328,9 @@ let JupiterFormField = class extends LitElement {
3320
3328
  console.log(`🏷️ [FormField] unit-change event dispatched`);
3321
3329
  }
3322
3330
  _handleDecimalsChange(event) {
3323
- const value = event.target.value.trim();
3331
+ const raw = event.target.value.trim();
3332
+ const num = parseFloat(raw);
3333
+ const value = raw && !isNaN(num) ? String(Math.abs(num)) : raw === "" ? "" : raw;
3324
3334
  this.decimals = value || void 0;
3325
3335
  this.dispatchEvent(new CustomEvent("decimals-change", {
3326
3336
  detail: { conceptId: this.conceptId, columnId: this.columnId, decimals: this.decimals },
@@ -3678,12 +3688,13 @@ let JupiterFormField = class extends LitElement {
3678
3688
 
3679
3689
  ${this._isMonetaryType() ? html`
3680
3690
  <div class="period-controls">
3681
- <label>Decimals:</label>
3691
+ <label>${I18n.t("field.scale")}:</label>
3682
3692
  <input
3683
3693
  type="number"
3694
+ min="0"
3684
3695
  class="typed-member-input"
3685
3696
  placeholder="Leave blank for INF"
3686
- .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 : ""}"
3687
3698
  @input="${this._handleDecimalsChange}"
3688
3699
  ?disabled="${this.disabled}"
3689
3700
  />
@@ -3719,6 +3730,7 @@ let JupiterFormField = class extends LitElement {
3719
3730
  const hasPeriodControl = this.field.periodType && (this.field.periodType === "instant" || this.field.periodType === "duration");
3720
3731
  const baseConceptId = this._extractBaseConceptId(this.conceptId);
3721
3732
  const isPredefinedValue = this.mode !== "admin" && this.masterData && baseConceptId in this.masterData;
3733
+ const isRoundingLevelLocked = this._isRoundingLevelConcept();
3722
3734
  let factValue = null;
3723
3735
  if (this.facts && this.facts.length > 0 && !isPredefinedValue) {
3724
3736
  const cellContext = {
@@ -3773,7 +3785,7 @@ let JupiterFormField = class extends LitElement {
3773
3785
  }
3774
3786
  const hasUserValue = this.value !== null && this.value !== void 0;
3775
3787
  const effectiveValue = isPredefinedValue ? this.masterData[baseConceptId] : hasUserValue ? this.value : factValue;
3776
- const effectiveDisabled = isPredefinedValue || this.disabled || this.mode === "readonly";
3788
+ const effectiveDisabled = isPredefinedValue || isRoundingLevelLocked || this.disabled || this.mode === "readonly";
3777
3789
  return html`
3778
3790
  <div class="field-container">
3779
3791
  ${showLabel ? html`
@@ -3785,7 +3797,7 @@ let JupiterFormField = class extends LitElement {
3785
3797
  <div class="field-wrapper">
3786
3798
  ${this._renderInput(effectiveValue, effectiveDisabled)}
3787
3799
 
3788
- ${hasPeriodControl && this.mode !== "readonly" ? html`
3800
+ ${hasPeriodControl && this.mode !== "readonly" && !isRoundingLevelLocked ? html`
3789
3801
  <button
3790
3802
  class="period-icon-btn"
3791
3803
  type="button"
@@ -8167,6 +8179,7 @@ let JupiterDynamicForm = class extends LitElement {
8167
8179
  this._unitData = {};
8168
8180
  this._preservedUnitData = {};
8169
8181
  this._decimalsData = {};
8182
+ this._effectiveMasterData = void 0;
8170
8183
  this._typedMemberData = {};
8171
8184
  this._preservedTypedMemberData = {};
8172
8185
  this._repeatCounts = {};
@@ -8253,6 +8266,9 @@ let JupiterDynamicForm = class extends LitElement {
8253
8266
  }
8254
8267
  }
8255
8268
  updated(changedProperties) {
8269
+ if (changedProperties.has("decimals") || changedProperties.has("masterData")) {
8270
+ this._computeEffectiveMasterData();
8271
+ }
8256
8272
  if (changedProperties.has("language")) {
8257
8273
  I18n.setLanguage(this.language);
8258
8274
  }
@@ -8371,6 +8387,7 @@ let JupiterDynamicForm = class extends LitElement {
8371
8387
  if ((_a = this.xbrlInput) == null ? void 0 : _a.initialData) {
8372
8388
  this._formData = { ...this._formData, ...this.xbrlInput.initialData };
8373
8389
  }
8390
+ this._initializeGlobalDecimalsFromRoundingData();
8374
8391
  this._extractTypedMembersFromFacts();
8375
8392
  if (!this._skipDraftLoading) {
8376
8393
  this._loadDraftIfExists().then(() => {
@@ -9077,6 +9094,121 @@ let JupiterDynamicForm = class extends LitElement {
9077
9094
  this._dirty = true;
9078
9095
  this.requestUpdate();
9079
9096
  }
9097
+ _computeEffectiveMasterData() {
9098
+ const ROUNDING_CONCEPT = "rj-i_DocumentIntendedRoundingLevel";
9099
+ if (this.decimals !== "INF") {
9100
+ const parsed = parseFloat(this.decimals);
9101
+ if (!isNaN(parsed)) {
9102
+ this._effectiveMasterData = {
9103
+ ...this.masterData || {},
9104
+ [ROUNDING_CONCEPT]: String(-parsed)
9105
+ };
9106
+ return;
9107
+ }
9108
+ }
9109
+ this._effectiveMasterData = this.masterData ? { ...this.masterData } : void 0;
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
+ }
9080
9212
  _storeDecimals(conceptId, columnId, decimals) {
9081
9213
  const updated = { ...this._decimalsData };
9082
9214
  if (!updated[conceptId])
@@ -10011,6 +10143,7 @@ let JupiterDynamicForm = class extends LitElement {
10011
10143
  });
10012
10144
  this._formData = { ...this._formData, ...restoredFormData };
10013
10145
  console.log(`🔄 Restored ${Object.keys(restoredFormData).length} concepts with data`);
10146
+ this._initializeGlobalDecimalsFromRoundingData();
10014
10147
  this._periodData = {
10015
10148
  ...this._periodData,
10016
10149
  ...metadata.periodData || {},
@@ -10505,7 +10638,8 @@ let JupiterDynamicForm = class extends LitElement {
10505
10638
  const fieldDecimals = (_d = this._decimalsData[concept.id]) == null ? void 0 : _d[columnId];
10506
10639
  const decimalsValue = fieldDecimals || (this.decimals !== "INF" ? this.decimals : void 0);
10507
10640
  if (isMonetary && decimalsValue) {
10508
- entry.decimals = decimalsValue;
10641
+ const parsed = parseFloat(decimalsValue);
10642
+ entry.decimals = isNaN(parsed) ? decimalsValue : String(-Math.abs(parsed));
10509
10643
  }
10510
10644
  if ((_e = column2 == null ? void 0 : column2.dimensionData) == null ? void 0 : _e.memberLabel) {
10511
10645
  entry.dimension = column2.dimensionData.memberLabel;
@@ -10645,12 +10779,18 @@ let JupiterDynamicForm = class extends LitElement {
10645
10779
  }
10646
10780
  if (concept.fields && concept.fields.length > 0) {
10647
10781
  concept.fields.forEach((field2) => {
10648
- var _a, _b, _c, _d, _e, _f, _g;
10782
+ var _a, _b, _c, _d, _e, _f, _g, _h;
10649
10783
  const conceptData = this._formData[concept.id];
10650
10784
  let fieldValue = conceptData == null ? void 0 : conceptData[field2.columnId];
10651
- if ((fieldValue === void 0 || fieldValue === null || fieldValue === "") && this.masterData) {
10652
- const baseConceptId = field2.conceptId || concept.id.split("__").slice(0, -1).join("__") || concept.id;
10653
- const masterValue = this.masterData[baseConceptId];
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
+ }
10792
+ if ((fieldValue === void 0 || fieldValue === null || fieldValue === "") && this._effectiveMasterData) {
10793
+ const masterValue = (_a = this._effectiveMasterData) == null ? void 0 : _a[baseConceptId];
10654
10794
  if (masterValue !== void 0 && masterValue !== null && masterValue !== "") {
10655
10795
  fieldValue = masterValue;
10656
10796
  console.warn(` 📦 [Submission] Using masterData for: ${baseConceptId} [${field2.columnId}] = ${JSON.stringify(fieldValue)}`);
@@ -10658,7 +10798,7 @@ let JupiterDynamicForm = class extends LitElement {
10658
10798
  }
10659
10799
  if (fieldValue !== void 0 && fieldValue !== null && fieldValue !== "") {
10660
10800
  const column2 = this._findColumnByIdInSection(field2.columnId, section2);
10661
- const fieldPeriodData = (_a = this._periodData[concept.id]) == null ? void 0 : _a[field2.columnId];
10801
+ const fieldPeriodData = (_b = this._periodData[concept.id]) == null ? void 0 : _b[field2.columnId];
10662
10802
  const submissionEntry = {
10663
10803
  conceptId: concept.id,
10664
10804
  draftInstanceId: concept.id,
@@ -10680,20 +10820,21 @@ let JupiterDynamicForm = class extends LitElement {
10680
10820
  submissionEntry.period.endDate = endDate;
10681
10821
  }
10682
10822
  console.log(`🔍 [Submission] Concept: ${concept.id}, Column: ${field2.columnId}, Field Period: ${fieldPeriodData ? JSON.stringify(fieldPeriodData) : "none"}, Column Period: ${(column2 == null ? void 0 : column2.periodStartDate) || "none"} - ${(column2 == null ? void 0 : column2.periodEndDate) || "none"}, Used Period: ${submissionEntry.period.type === "instant" ? submissionEntry.period.date : `${submissionEntry.period.startDate} - ${submissionEntry.period.endDate}`}`);
10683
- const fieldUnit = (_b = this._unitData[concept.id]) == null ? void 0 : _b[field2.columnId];
10823
+ const fieldUnit = (_c = this._unitData[concept.id]) == null ? void 0 : _c[field2.columnId];
10684
10824
  if (fieldUnit) {
10685
10825
  submissionEntry.unit = fieldUnit;
10686
10826
  console.log(`✅ [Submission] Adding unit to entry: ${fieldUnit} for ${concept.id}/${field2.columnId}`);
10687
10827
  } else {
10688
10828
  console.log(`⚠️ [Submission] No unit found in _unitData for ${concept.id}/${field2.columnId}. _unitData state:`, JSON.stringify(this._unitData, null, 2));
10689
10829
  }
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];
10830
+ const isMonetary = (_d = concept.type) == null ? void 0 : _d.toLowerCase().includes("monetary");
10831
+ const fieldDecimals = (_e = this._decimalsData[concept.id]) == null ? void 0 : _e[field2.columnId];
10692
10832
  const decimalsValue = fieldDecimals || (this.decimals !== "INF" ? this.decimals : void 0);
10693
10833
  if (isMonetary && decimalsValue) {
10694
- submissionEntry.decimals = decimalsValue;
10834
+ const parsed = parseFloat(decimalsValue);
10835
+ submissionEntry.decimals = isNaN(parsed) ? decimalsValue : String(-Math.abs(parsed));
10695
10836
  }
10696
- if ((column2 == null ? void 0 : column2.type) === "dimension" && ((_e = column2.dimensionData) == null ? void 0 : _e.dimensionIdKey)) {
10837
+ if ((column2 == null ? void 0 : column2.type) === "dimension" && ((_f = column2.dimensionData) == null ? void 0 : _f.dimensionIdKey)) {
10697
10838
  submissionEntry.dimension = column2.dimensionData.dimensionIdKey;
10698
10839
  console.log(`🔍 [DynamicForm] Using dimension key from field's column (${field2.columnId}):`, column2.dimensionData.dimensionIdKey);
10699
10840
  } else {
@@ -10729,12 +10870,12 @@ let JupiterDynamicForm = class extends LitElement {
10729
10870
  console.log(`🔍 [DynamicForm] Column details:`, {
10730
10871
  id: column2.id,
10731
10872
  type: column2.type,
10732
- hasTypedMembers: (_f = column2.dimensionData) == null ? void 0 : _f.hasTypedMembers,
10873
+ hasTypedMembers: (_g = column2.dimensionData) == null ? void 0 : _g.hasTypedMembers,
10733
10874
  dimensionData: column2.dimensionData
10734
10875
  });
10735
10876
  }
10736
10877
  }
10737
- if (!submissionEntry.typedMembers && ((_g = field2.crossRoleTypedMembers) == null ? void 0 : _g.length)) {
10878
+ if (!submissionEntry.typedMembers && ((_h = field2.crossRoleTypedMembers) == null ? void 0 : _h.length)) {
10738
10879
  const crossRoleKey = `${concept.id}__${field2.columnId}`;
10739
10880
  const crossRoleValues = this._typedMemberData[crossRoleKey];
10740
10881
  if (crossRoleValues) {
@@ -11000,7 +11141,7 @@ let JupiterDynamicForm = class extends LitElement {
11000
11141
  if (value === void 0 && conceptIdWithSuffix !== fieldConceptId) {
11001
11142
  value = (_b = this._formData[fieldConceptId]) == null ? void 0 : _b[field2.columnId];
11002
11143
  }
11003
- const masterValue = (_c = this.masterData) == null ? void 0 : _c[fieldConceptId];
11144
+ const masterValue = (_c = this._effectiveMasterData) == null ? void 0 : _c[fieldConceptId];
11004
11145
  if ((value === null || value === void 0 || typeof value === "string" && value.trim() === "") && masterValue !== void 0) {
11005
11146
  value = masterValue;
11006
11147
  console.warn(` 📦 Using masterData value for: ${fieldConceptId} [${field2.columnId}] = ${JSON.stringify(value)}`);
@@ -11551,7 +11692,7 @@ let JupiterDynamicForm = class extends LitElement {
11551
11692
  .mode="${this.mode}"
11552
11693
  .showFactsOnly="${this._showFactsOnly}"
11553
11694
  .conceptMatchIds="${hasConceptSearch ? conceptMatchIds : void 0}"
11554
- .masterData="${this.masterData}"
11695
+ .masterData="${this._effectiveMasterData}"
11555
11696
  .periodStartDate="${this.periodStartDate}"
11556
11697
  .periodEndDate="${this.periodEndDate}"
11557
11698
  @field-change="${this._handleFieldChange}"
@@ -11694,7 +11835,7 @@ let JupiterDynamicForm = class extends LitElement {
11694
11835
  .mode="${this.mode}"
11695
11836
  .showFactsOnly="${this._showFactsOnly}"
11696
11837
  .conceptMatchIds="${hasConceptSearch ? conceptMatchIds : void 0}"
11697
- .masterData="${this.masterData}"
11838
+ .masterData="${this._effectiveMasterData}"
11698
11839
  .periodStartDate="${this.periodStartDate}"
11699
11840
  .periodEndDate="${this.periodEndDate}"
11700
11841
  @field-change="${this._handleFieldChange}"
@@ -12767,6 +12908,9 @@ __decorateClass([
12767
12908
  __decorateClass([
12768
12909
  r()
12769
12910
  ], JupiterDynamicForm.prototype, "_decimalsData", 2);
12911
+ __decorateClass([
12912
+ r()
12913
+ ], JupiterDynamicForm.prototype, "_effectiveMasterData", 2);
12770
12914
  __decorateClass([
12771
12915
  r()
12772
12916
  ], JupiterDynamicForm.prototype, "_typedMemberData", 2);