jupiter-dynamic-forms 1.18.8 → 1.18.9

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
@@ -3242,7 +3242,7 @@ let JupiterFormField = class extends LitElement {
3242
3242
  }
3243
3243
  if (this._isPercentItemType() && this.value !== null && this.value !== void 0) {
3244
3244
  const numVal = Number(this.value);
3245
- if (!isNaN(numVal) && Math.abs(numVal) >= 1) {
3245
+ if (!isNaN(numVal) && Math.abs(numVal) > 1) {
3246
3246
  this.value = numVal / 100;
3247
3247
  const oldValue = numVal;
3248
3248
  this.dispatchEvent(new CustomEvent("field-change", {
@@ -3892,6 +3892,7 @@ let JupiterFormField = class extends LitElement {
3892
3892
  <path fill="currentColor" d="M19 4h-1V2h-2v2H8V2H6v2H5
3893
3893
  a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14
3894
3894
  a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
3895
+ </svg>
3895
3896
  </div>
3896
3897
  </div>
3897
3898
  `;
@@ -3899,17 +3900,18 @@ let JupiterFormField = class extends LitElement {
3899
3900
  return html`
3900
3901
  <div class="period-controls">
3901
3902
  <label>From:</label>
3902
- <div class="date-wrapper">
3903
- <input
3904
- type="date"
3905
- .value="${this.periodStartDate || this.field.periodStartDate || ""}"
3906
- @change="${(e2) => this._handlePeriodChange(e2, "start")}"
3907
- ?disabled="${this.disabled}"
3908
- />
3909
- <svg class="calendar-icon-svg" viewBox="0 0 24 24">
3903
+ <div class="date-wrapper">
3904
+ <input
3905
+ type="date"
3906
+ .value="${this.periodStartDate || this.field.periodStartDate || ""}"
3907
+ @change="${(e2) => this._handlePeriodChange(e2, "start")}"
3908
+ ?disabled="${this.disabled}"
3909
+ />
3910
+ <svg class="calendar-icon-svg" viewBox="0 0 24 24">
3910
3911
  <path fill="currentColor" d="M19 4h-1V2h-2v2H8V2H6v2H5
3911
3912
  a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14
3912
3913
  a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
3914
+ </svg>
3913
3915
  </div>
3914
3916
  <label>To:</label>
3915
3917
  <div class="date-wrapper">
@@ -3923,6 +3925,7 @@ let JupiterFormField = class extends LitElement {
3923
3925
  <path fill="currentColor" d="M19 4h-1V2h-2v2H8V2H6v2H5
3924
3926
  a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14
3925
3927
  a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
3928
+ </svg>
3926
3929
  </div>
3927
3930
  </div>
3928
3931
  `;
@@ -3955,6 +3958,7 @@ let JupiterFormField = class extends LitElement {
3955
3958
  <path fill="currentColor" d="M19 4h-1V2h-2v2H8V2H6v2H5
3956
3959
  a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14
3957
3960
  a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
3961
+ </svg>
3958
3962
  </div>
3959
3963
  </div>
3960
3964
  ` : html`
@@ -3967,12 +3971,13 @@ let JupiterFormField = class extends LitElement {
3967
3971
  @change="${(e2) => this._handlePeriodChange(e2, "start")}"
3968
3972
  ?disabled="${this.disabled}"
3969
3973
  />
3970
- <svg class="calendar-icon-svg" viewBox="0 0 24 24">
3974
+ <svg class="calendar-icon-svg" viewBox="0 0 24 24">
3971
3975
  <path
3972
3976
  fill="currentColor"
3973
3977
  d="M19 4h-1V2h-2v2H8V2H6v2H5
3974
3978
  a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14
3975
3979
  a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
3980
+ </svg>
3976
3981
  </div>
3977
3982
  </div>
3978
3983
  <div class="period-controls">
@@ -3988,6 +3993,7 @@ let JupiterFormField = class extends LitElement {
3988
3993
  <path fill="currentColor" d="M19 4h-1V2h-2v2H8V2H6v2H5
3989
3994
  a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14
3990
3995
  a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
3996
+ </svg>
3991
3997
  </div>
3992
3998
  </div>
3993
3999
  `}
@@ -4011,7 +4017,7 @@ let JupiterFormField = class extends LitElement {
4011
4017
  </div>
4012
4018
  ` : ""}
4013
4019
 
4014
- ${this._isMonetaryType() || this._isPercentItemType() ? html`
4020
+ ${this._isMonetaryType() ? html`
4015
4021
  <div class="period-controls">
4016
4022
  <label>${I18n.t("field.scale")}:</label>
4017
4023
  <input
@@ -4019,7 +4025,7 @@ let JupiterFormField = class extends LitElement {
4019
4025
  min="0"
4020
4026
  class="typed-member-input"
4021
4027
  placeholder="Leave blank for INF"
4022
- .value="${this.decimals !== void 0 && this.decimals !== null && this.decimals !== "" ? this.decimals : this._isPercentItemType() ? "4" : this.globalDecimals !== "INF" ? this.globalDecimals : ""}"
4028
+ .value="${this.decimals !== void 0 && this.decimals !== null && this.decimals !== "" ? this.decimals : this.globalDecimals !== "INF" ? this.globalDecimals : ""}"
4023
4029
  @input="${this._handleDecimalsChange}"
4024
4030
  ?disabled="${this.disabled}"
4025
4031
  />
@@ -4298,20 +4304,26 @@ JupiterFormField.styles = css`
4298
4304
  width: min-content;
4299
4305
  }
4300
4306
 
4301
- /* hide native icon */
4307
+ .date-wrapper input[type="date"] {
4308
+ appearance: none;
4309
+ -webkit-appearance: none;
4310
+ padding-right: 34px;
4311
+ }
4312
+
4313
+ /* Chrome/Edge/Safari: hide the native calendar picker indicator and use custom SVG */
4302
4314
  input[type="date"]::-webkit-calendar-picker-indicator {
4303
4315
  opacity: 0;
4304
4316
  position: absolute;
4305
- right: 10px;
4306
- width: 20px;
4307
- height: 20px;
4317
+ right: 0;
4318
+ width: 34px;
4319
+ height: 100%;
4308
4320
  cursor: pointer;
4309
4321
  }
4310
4322
 
4311
- .calendar-icon-svg {
4323
+ .calendar-icon-svg {
4312
4324
  position: absolute;
4313
- right: 3px;
4314
- top: 18px;
4325
+ right: 8px;
4326
+ top: 50%;
4315
4327
  transform: translateY(-50%);
4316
4328
  width: 20px;
4317
4329
  height: 20px;
@@ -4319,6 +4331,17 @@ JupiterFormField.styles = css`
4319
4331
  pointer-events: none;
4320
4332
  }
4321
4333
 
4334
+ /* Firefox: cannot hide native calendar icon via pseudo-element;
4335
+ hide our custom SVG so only the native icon shows (no duplication) */
4336
+ @supports (-moz-appearance: none) {
4337
+ .calendar-icon-svg {
4338
+ display: none;
4339
+ }
4340
+ .date-wrapper input[type="date"] {
4341
+ padding-right: 10px;
4342
+ }
4343
+ }
4344
+
4322
4345
  .period-popup-content .period-controls input[type="date"] {
4323
4346
  padding: 8px 10px;
4324
4347
  font-size: 14px;
@@ -5434,6 +5457,7 @@ let JupiterAddColumnDialog = class extends LitElement {
5434
5457
  <path fill="currentColor" d="M19 4h-1V2h-2v2H8V2H6v2H5
5435
5458
  a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14
5436
5459
  a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
5460
+ </svg>
5437
5461
  </div>
5438
5462
  </div>
5439
5463
  ` : html`
@@ -5452,6 +5476,7 @@ let JupiterAddColumnDialog = class extends LitElement {
5452
5476
  <path fill="currentColor" d="M19 4h-1V2h-2v2H8V2H6v2H5
5453
5477
  a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14
5454
5478
  a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
5479
+ </svg>
5455
5480
  </div>
5456
5481
  </div>
5457
5482
  <div class="date-field">
@@ -5468,6 +5493,7 @@ let JupiterAddColumnDialog = class extends LitElement {
5468
5493
  <path fill="currentColor" d="M19 4h-1V2h-2v2H8V2H6v2H5
5469
5494
  a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14
5470
5495
  a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 16H5V9h14z"/>
5496
+ </svg>
5471
5497
  </div>
5472
5498
  </div>
5473
5499
  </div>
@@ -5633,20 +5659,26 @@ JupiterAddColumnDialog.styles = css`
5633
5659
  width: min-content;
5634
5660
  }
5635
5661
 
5636
- /* hide native icon */
5662
+ .date-wrapper input[type="date"] {
5663
+ appearance: none;
5664
+ -webkit-appearance: none;
5665
+ padding-right: 34px;
5666
+ }
5667
+
5668
+ /* Chrome/Edge/Safari: hide the native calendar picker indicator and use custom SVG */
5637
5669
  input[type="date"]::-webkit-calendar-picker-indicator {
5638
5670
  opacity: 0;
5639
5671
  position: absolute;
5640
- right: 10px;
5641
- width: 20px;
5642
- height: 20px;
5672
+ right: 0;
5673
+ width: 34px;
5674
+ height: 100%;
5643
5675
  cursor: pointer;
5644
5676
  }
5645
-
5646
- .calendar-icon-svg {
5677
+
5678
+ .calendar-icon-svg {
5647
5679
  position: absolute;
5648
- right: 3px;
5649
- top: 18px;
5680
+ right: 8px;
5681
+ top: 50%;
5650
5682
  transform: translateY(-50%);
5651
5683
  width: 20px;
5652
5684
  height: 20px;
@@ -5654,6 +5686,17 @@ JupiterAddColumnDialog.styles = css`
5654
5686
  pointer-events: none;
5655
5687
  }
5656
5688
 
5689
+ /* Firefox: cannot hide native calendar icon via pseudo-element;
5690
+ hide our custom SVG so only the native icon shows (no duplication) */
5691
+ @supports (-moz-appearance: none) {
5692
+ .calendar-icon-svg {
5693
+ display: none;
5694
+ }
5695
+ .date-wrapper input[type="date"] {
5696
+ padding-right: 10px;
5697
+ }
5698
+ }
5699
+
5657
5700
  .form-group {
5658
5701
  margin-bottom: 16px;
5659
5702
  }
@@ -11306,7 +11349,7 @@ let JupiterDynamicForm = class extends LitElement {
11306
11349
  return null;
11307
11350
  }
11308
11351
  _addConceptDataToSubmission(concept, columnId, value, submissionData, section2) {
11309
- var _a, _b, _c, _d, _e, _f, _g;
11352
+ var _a, _b, _c, _d, _e, _f;
11310
11353
  const field2 = concept.fields.find((f2) => f2.columnId === columnId);
11311
11354
  if (!field2)
11312
11355
  return;
@@ -11341,15 +11384,13 @@ let JupiterDynamicForm = class extends LitElement {
11341
11384
  console.log(`✅ [Submission] Adding unit to entry: ${fieldUnit} for ${concept.id}/${columnId}`);
11342
11385
  }
11343
11386
  const isMonetary = (_d = concept.type) == null ? void 0 : _d.toLowerCase().includes("monetary");
11344
- const isPercent = (_e = concept.type) == null ? void 0 : _e.toLowerCase().includes("percentitemtype");
11345
- const fieldDecimals = (_f = this._decimalsData[concept.id]) == null ? void 0 : _f[columnId];
11346
- const globalFallback = isPercent ? "4" : this.decimals !== "INF" ? this.decimals : void 0;
11347
- const decimalsValue = fieldDecimals || globalFallback;
11348
- if ((isMonetary || isPercent) && decimalsValue) {
11387
+ const fieldDecimals = (_e = this._decimalsData[concept.id]) == null ? void 0 : _e[columnId];
11388
+ const decimalsValue = fieldDecimals || (this.decimals !== "INF" ? this.decimals : void 0);
11389
+ if (isMonetary && decimalsValue) {
11349
11390
  const parsed = parseFloat(decimalsValue);
11350
11391
  entry.decimals = isNaN(parsed) ? decimalsValue : String(-Math.abs(parsed));
11351
11392
  }
11352
- if ((_g = column2 == null ? void 0 : column2.dimensionData) == null ? void 0 : _g.memberLabel) {
11393
+ if ((_f = column2 == null ? void 0 : column2.dimensionData) == null ? void 0 : _f.memberLabel) {
11353
11394
  entry.dimension = column2.dimensionData.memberLabel;
11354
11395
  }
11355
11396
  console.log(`📤 [Submission Entry] Created entry:`, JSON.stringify(entry, null, 2));
@@ -11487,7 +11528,7 @@ let JupiterDynamicForm = class extends LitElement {
11487
11528
  }
11488
11529
  if (concept.fields && concept.fields.length > 0) {
11489
11530
  concept.fields.forEach((field2) => {
11490
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11531
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
11491
11532
  const conceptData = this._formData[concept.id];
11492
11533
  let fieldValue = conceptData == null ? void 0 : conceptData[field2.columnId];
11493
11534
  const baseConceptId = field2.conceptId || concept.id.split("__").slice(0, -1).join("__") || concept.id;
@@ -11542,15 +11583,13 @@ let JupiterDynamicForm = class extends LitElement {
11542
11583
  console.log(`⚠️ [Submission] No unit found in _unitData for ${concept.id}/${field2.columnId}. _unitData state:`, JSON.stringify(this._unitData, null, 2));
11543
11584
  }
11544
11585
  const isMonetary = (_e = concept.type) == null ? void 0 : _e.toLowerCase().includes("monetary");
11545
- const isPercent = (_f = concept.type) == null ? void 0 : _f.toLowerCase().includes("percentitemtype");
11546
- const fieldDecimals = (_g = this._decimalsData[concept.id]) == null ? void 0 : _g[field2.columnId];
11547
- const globalFallback = isPercent ? "4" : this.decimals !== "INF" ? this.decimals : void 0;
11548
- const decimalsValue = fieldDecimals || globalFallback;
11549
- if ((isMonetary || isPercent) && decimalsValue) {
11586
+ const fieldDecimals = (_f = this._decimalsData[concept.id]) == null ? void 0 : _f[field2.columnId];
11587
+ const decimalsValue = fieldDecimals || (this.decimals !== "INF" ? this.decimals : void 0);
11588
+ if (isMonetary && decimalsValue) {
11550
11589
  const parsed = parseFloat(decimalsValue);
11551
11590
  submissionEntry.decimals = isNaN(parsed) ? decimalsValue : String(-Math.abs(parsed));
11552
11591
  }
11553
- if ((column2 == null ? void 0 : column2.type) === "dimension" && ((_h = column2.dimensionData) == null ? void 0 : _h.dimensionIdKey)) {
11592
+ if ((column2 == null ? void 0 : column2.type) === "dimension" && ((_g = column2.dimensionData) == null ? void 0 : _g.dimensionIdKey)) {
11554
11593
  submissionEntry.dimension = column2.dimensionData.dimensionIdKey;
11555
11594
  console.log(`🔍 [DynamicForm] Using dimension key from field's column (${field2.columnId}):`, column2.dimensionData.dimensionIdKey);
11556
11595
  } else {
@@ -11586,12 +11625,12 @@ let JupiterDynamicForm = class extends LitElement {
11586
11625
  console.log(`🔍 [DynamicForm] Column details:`, {
11587
11626
  id: column2.id,
11588
11627
  type: column2.type,
11589
- hasTypedMembers: (_i = column2.dimensionData) == null ? void 0 : _i.hasTypedMembers,
11628
+ hasTypedMembers: (_h = column2.dimensionData) == null ? void 0 : _h.hasTypedMembers,
11590
11629
  dimensionData: column2.dimensionData
11591
11630
  });
11592
11631
  }
11593
11632
  }
11594
- if (!submissionEntry.typedMembers && ((_j = field2.crossRoleTypedMembers) == null ? void 0 : _j.length)) {
11633
+ if (!submissionEntry.typedMembers && ((_i = field2.crossRoleTypedMembers) == null ? void 0 : _i.length)) {
11595
11634
  const crossRoleKey = `${concept.id}__${field2.columnId}`;
11596
11635
  const crossRoleValues = this._typedMemberData[crossRoleKey];
11597
11636
  if (crossRoleValues) {
@@ -12758,6 +12797,29 @@ let JupiterDynamicForm = class extends LitElement {
12758
12797
  const conceptIdBase = conceptId.includes("__") ? conceptId.split("__")[0] : conceptId;
12759
12798
  console.log(`[scrollToConcept] conceptId="${conceptId}" conceptIdBase="${conceptIdBase}"`);
12760
12799
  const sameBaseConcept = (fieldConceptId) => fieldConceptId === conceptId || fieldConceptId.includes("__") && fieldConceptId.split("__")[0] === conceptIdBase;
12800
+ const getFieldScaleFactor = (fieldEl) => {
12801
+ const effectiveDecimals = fieldEl.decimals || (fieldEl.globalDecimals !== void 0 && fieldEl.globalDecimals !== "INF" ? fieldEl.globalDecimals : null);
12802
+ if (!effectiveDecimals)
12803
+ return 1;
12804
+ const scale = parseFloat(String(effectiveDecimals));
12805
+ if (isNaN(scale) || scale <= 0)
12806
+ return 1;
12807
+ return Math.pow(10, scale);
12808
+ };
12809
+ const valueMatchesTarget = (fieldEl, targetVal) => {
12810
+ if (String(fieldEl.value ?? "") === targetVal)
12811
+ return true;
12812
+ const targetNum = Number(targetVal);
12813
+ const fieldNum = Number(fieldEl.value);
12814
+ if (!isNaN(targetNum) && !isNaN(fieldNum) && fieldNum !== 0) {
12815
+ const scaleFactor = getFieldScaleFactor(fieldEl);
12816
+ if (scaleFactor !== 1) {
12817
+ if (Math.abs(fieldNum * scaleFactor - targetNum) < 1e-4)
12818
+ return true;
12819
+ }
12820
+ }
12821
+ return false;
12822
+ };
12761
12823
  let phase1FieldCount = 0;
12762
12824
  conceptTrees == null ? void 0 : conceptTrees.forEach((ct) => {
12763
12825
  var _a2;
@@ -12768,10 +12830,10 @@ let JupiterDynamicForm = class extends LitElement {
12768
12830
  if (targetFieldEl)
12769
12831
  return;
12770
12832
  const columnMatch = targetColumnId ? fieldEl.conceptId === conceptId && fieldEl.columnId === targetColumnId : fieldEl.conceptId === conceptId;
12771
- const valueMatch = !hasValueMatch || String(fieldEl.value ?? "") === targetValue;
12833
+ const valueMatch = !hasValueMatch || valueMatchesTarget(fieldEl, targetValue);
12772
12834
  if (columnMatch) {
12773
12835
  phase1FieldCount++;
12774
- console.log(`[scrollToConcept] Phase1 candidate: conceptId=${fieldEl.conceptId} columnId=${fieldEl.columnId} value=${fieldEl.value} valueMatch=${valueMatch}`);
12836
+ console.log(`[scrollToConcept] Phase1 candidate: conceptId=${fieldEl.conceptId} columnId=${fieldEl.columnId} value=${fieldEl.value} scale=${getFieldScaleFactor(fieldEl)} valueMatch=${valueMatch}`);
12775
12837
  }
12776
12838
  if (columnMatch && valueMatch)
12777
12839
  targetFieldEl = fieldEl;
@@ -12793,9 +12855,9 @@ let JupiterDynamicForm = class extends LitElement {
12793
12855
  if (targetFieldEl)
12794
12856
  return;
12795
12857
  const baseMatch = sameBaseConcept(fieldEl.conceptId);
12796
- const valMatch = String(fieldEl.value ?? "") === targetValue;
12858
+ const valMatch = valueMatchesTarget(fieldEl, targetValue);
12797
12859
  if (baseMatch) {
12798
- console.log(`[scrollToConcept] Phase2 candidate: conceptId=${fieldEl.conceptId} value=${fieldEl.value} valMatch=${valMatch}`);
12860
+ console.log(`[scrollToConcept] Phase2 candidate: conceptId=${fieldEl.conceptId} value=${fieldEl.value} scale=${getFieldScaleFactor(fieldEl)} valMatch=${valMatch}`);
12799
12861
  }
12800
12862
  if (baseMatch && valMatch) {
12801
12863
  console.log(`[scrollToConcept] Phase2 ✅ MATCH: conceptId=${fieldEl.conceptId} columnId=${fieldEl.columnId} value=${fieldEl.value}`);