jupiter-dynamic-forms 1.14.7 → 1.14.8

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
@@ -1082,7 +1082,7 @@ class XBRLFormBuilder {
1082
1082
  } else if (periodTypes.size === 1 && periodTypes.has("instant")) {
1083
1083
  columns2.push({
1084
1084
  id: "typed-instant",
1085
- title: `${axisLabel2} [Typed Input Available]`,
1085
+ title: `${axisLabel2} `,
1086
1086
  description: periodEndDate,
1087
1087
  type: "dimension",
1088
1088
  dimensionData: {
@@ -1112,7 +1112,7 @@ class XBRLFormBuilder {
1112
1112
  } else if (periodTypes.size === 1 && periodTypes.has("duration")) {
1113
1113
  columns2.push({
1114
1114
  id: "typed-duration",
1115
- title: `${axisLabel2} [Typed Input Available]`,
1115
+ title: `${axisLabel2} `,
1116
1116
  description: this.formatPeriodDisplay(periodStartDate, periodEndDate),
1117
1117
  type: "dimension",
1118
1118
  dimensionData: {
@@ -1142,7 +1142,7 @@ class XBRLFormBuilder {
1142
1142
  } else {
1143
1143
  columns2.push({
1144
1144
  id: "typed-duration",
1145
- title: `${axisLabel2} [Typed Input Available]`,
1145
+ title: `${axisLabel2} `,
1146
1146
  description: this.formatPeriodDisplay(periodStartDate, periodEndDate),
1147
1147
  type: "dimension",
1148
1148
  dimensionData: {
@@ -1309,7 +1309,7 @@ class XBRLFormBuilder {
1309
1309
  typedMemberId: dimension.typedMember.id,
1310
1310
  members: [{
1311
1311
  id: "[typed]",
1312
- label: `${axisLabel} [Typed Input Available]`
1312
+ label: `${axisLabel}`
1313
1313
  }]
1314
1314
  };
1315
1315
  }
@@ -2010,6 +2010,241 @@ class DraftStorageService {
2010
2010
  return { compatible, warnings };
2011
2011
  }
2012
2012
  }
2013
+ class FactMatcher {
2014
+ /**
2015
+ * Find a matching fact for a given cell context
2016
+ */
2017
+ static findMatchingFact(facts, context) {
2018
+ if (!facts || facts.length === 0) {
2019
+ return null;
2020
+ }
2021
+ const periodMatchedFacts = facts.filter(
2022
+ (fact) => this.matchesPeriod(fact, context)
2023
+ );
2024
+ if (periodMatchedFacts.length === 0) {
2025
+ return null;
2026
+ }
2027
+ const dimensionMatchedFacts = periodMatchedFacts.filter(
2028
+ (fact) => this.matchesDimensions(fact, context)
2029
+ );
2030
+ if (dimensionMatchedFacts.length === 0) {
2031
+ return null;
2032
+ }
2033
+ if (dimensionMatchedFacts.length > 1 && context.unit) {
2034
+ const unitMatchedFact = dimensionMatchedFacts.find(
2035
+ (fact) => this.matchesUnit(fact, context)
2036
+ );
2037
+ if (unitMatchedFact) {
2038
+ return unitMatchedFact;
2039
+ }
2040
+ }
2041
+ return dimensionMatchedFacts[0];
2042
+ }
2043
+ /**
2044
+ * Check if fact period matches cell period
2045
+ */
2046
+ static matchesPeriod(fact, context) {
2047
+ const factPeriod = this.parsePeriod(fact.period);
2048
+ if (context.periodType === "instant" && context.periodInstantDate) {
2049
+ return factPeriod.isInstant && factPeriod.instantDate === context.periodInstantDate;
2050
+ }
2051
+ if (context.periodType === "duration" && context.periodStartDate && context.periodEndDate) {
2052
+ return !factPeriod.isInstant && factPeriod.startDate === context.periodStartDate && factPeriod.endDate === context.periodEndDate;
2053
+ }
2054
+ if (context.periodInstantDate) {
2055
+ return factPeriod.isInstant && factPeriod.instantDate === context.periodInstantDate;
2056
+ }
2057
+ if (context.periodStartDate && context.periodEndDate) {
2058
+ return !factPeriod.isInstant && factPeriod.startDate === context.periodStartDate && factPeriod.endDate === context.periodEndDate;
2059
+ }
2060
+ return true;
2061
+ }
2062
+ /**
2063
+ * Check if fact dimensions match cell dimensions
2064
+ */
2065
+ static matchesDimensions(fact, context) {
2066
+ const factDimensions = fact.dimensions || [];
2067
+ const cellDimensions = this.extractDimensionsFromContext(context);
2068
+ if (cellDimensions.length === 0) {
2069
+ return factDimensions.length === 0;
2070
+ }
2071
+ if (factDimensions.length === 0 && cellDimensions.length > 0) {
2072
+ return false;
2073
+ }
2074
+ if (factDimensions.length !== cellDimensions.length) {
2075
+ return false;
2076
+ }
2077
+ const allMatch = cellDimensions.every((cellDim) => {
2078
+ return factDimensions.some((factDim) => {
2079
+ const axisMatch = this.normalizeAxisId(factDim.dimension) === this.normalizeAxisId(cellDim.axisId);
2080
+ if (!axisMatch) {
2081
+ return false;
2082
+ }
2083
+ if (factDim.dimensionType === "explicit" && cellDim.memberId) {
2084
+ const memberMatch = this.normalizeMemberId(factDim.member || "") === this.normalizeMemberId(cellDim.memberId);
2085
+ return memberMatch;
2086
+ }
2087
+ if (factDim.dimensionType === "typed" && cellDim.isTyped) {
2088
+ return true;
2089
+ }
2090
+ return false;
2091
+ });
2092
+ });
2093
+ return allMatch;
2094
+ }
2095
+ /**
2096
+ * Check if fact unit matches cell unit
2097
+ */
2098
+ static matchesUnit(fact, context) {
2099
+ if (!context.unit || !fact.unitMeasure) {
2100
+ return true;
2101
+ }
2102
+ const factUnit = this.normalizeUnit(fact.unitMeasure);
2103
+ const cellUnit = this.normalizeUnit(context.unit);
2104
+ return factUnit === cellUnit;
2105
+ }
2106
+ /**
2107
+ * Parse period string into structured format
2108
+ */
2109
+ static parsePeriod(period) {
2110
+ if (period.includes(" / ")) {
2111
+ const [startDate, endDate] = period.split(" / ").map((d2) => d2.trim());
2112
+ return {
2113
+ isInstant: false,
2114
+ startDate,
2115
+ endDate
2116
+ };
2117
+ }
2118
+ return {
2119
+ isInstant: true,
2120
+ instantDate: period.trim()
2121
+ };
2122
+ }
2123
+ /**
2124
+ * Extract dimensions from cell context
2125
+ */
2126
+ static extractDimensionsFromContext(context) {
2127
+ if (!context.dimensionData) {
2128
+ return [];
2129
+ }
2130
+ const dimensions = [];
2131
+ if (context.dimensionData.combinations && context.dimensionData.combinations.length > 0) {
2132
+ context.dimensionData.combinations.forEach((combo) => {
2133
+ dimensions.push({
2134
+ axisId: combo.axisId,
2135
+ memberId: combo.memberId
2136
+ });
2137
+ });
2138
+ }
2139
+ if (context.dimensionData.typedMembers && context.dimensionData.typedMembers.length > 0) {
2140
+ context.dimensionData.typedMembers.forEach((typed) => {
2141
+ dimensions.push({
2142
+ axisId: typed.axisId,
2143
+ memberId: "[typed]",
2144
+ isTyped: true
2145
+ });
2146
+ });
2147
+ }
2148
+ return dimensions;
2149
+ }
2150
+ /**
2151
+ * Normalize axis ID for comparison
2152
+ * Handles both formats: "jenv-bw2-dim:BasisOfPreparationAxis" and "jenv-bw2-dim_BasisOfPreparationAxis"
2153
+ * Returns: "BasisOfPreparationAxis"
2154
+ */
2155
+ static normalizeAxisId(axisId) {
2156
+ if (!axisId)
2157
+ return "";
2158
+ if (axisId.includes(":")) {
2159
+ const parts = axisId.split(":");
2160
+ return parts[1] || parts[0];
2161
+ }
2162
+ if (axisId.includes("_")) {
2163
+ axisId.split("_");
2164
+ const lastUnderscoreIndex = axisId.lastIndexOf("_");
2165
+ if (lastUnderscoreIndex > 0) {
2166
+ return axisId.substring(lastUnderscoreIndex + 1);
2167
+ }
2168
+ }
2169
+ return axisId;
2170
+ }
2171
+ /**
2172
+ * Normalize member ID for comparison
2173
+ * Handles both formats: "jenv-bw2-dm:CommercialMember" and "jenv-bw2-dm_CommercialMember"
2174
+ * Returns: "CommercialMember"
2175
+ */
2176
+ static normalizeMemberId(memberId) {
2177
+ if (!memberId)
2178
+ return "";
2179
+ if (memberId.includes(":")) {
2180
+ const parts = memberId.split(":");
2181
+ return parts[1] || parts[0];
2182
+ }
2183
+ if (memberId.includes("_")) {
2184
+ const lastUnderscoreIndex = memberId.lastIndexOf("_");
2185
+ if (lastUnderscoreIndex > 0) {
2186
+ return memberId.substring(lastUnderscoreIndex + 1);
2187
+ }
2188
+ }
2189
+ return memberId;
2190
+ }
2191
+ /**
2192
+ * Normalize unit for comparison
2193
+ * Converts "iso4217:EUR" to "EUR"
2194
+ */
2195
+ static normalizeUnit(unit) {
2196
+ if (!unit)
2197
+ return "";
2198
+ const parts = unit.split(":");
2199
+ return parts.length > 1 ? parts[1] : parts[0];
2200
+ }
2201
+ /**
2202
+ * Extract typed dimension values from facts
2203
+ * Returns a map of axis IDs to typed values
2204
+ */
2205
+ static extractTypedValues(facts, context) {
2206
+ const typedValues = {};
2207
+ if (!facts || facts.length === 0) {
2208
+ return typedValues;
2209
+ }
2210
+ const matchedFacts = facts.filter(
2211
+ (fact) => this.matchesPeriod(fact, context) && this.matchesDimensions(fact, context)
2212
+ );
2213
+ matchedFacts.forEach((fact) => {
2214
+ if (fact.dimensions) {
2215
+ fact.dimensions.forEach((dim) => {
2216
+ if (dim.dimensionType === "typed" && dim.typedMemberValue) {
2217
+ const axisId = this.normalizeAxisId(dim.dimension);
2218
+ typedValues[axisId] = dim.typedMemberValue;
2219
+ }
2220
+ });
2221
+ }
2222
+ });
2223
+ return typedValues;
2224
+ }
2225
+ /**
2226
+ * Debug helper: Log matching process
2227
+ */
2228
+ static debugMatch(facts, context) {
2229
+ console.log("🔍 [FactMatcher] Debug Match");
2230
+ console.log(" Context:", {
2231
+ conceptId: context.conceptId,
2232
+ columnId: context.columnId,
2233
+ period: context.periodType === "instant" ? context.periodInstantDate : `${context.periodStartDate} / ${context.periodEndDate}`,
2234
+ dimensions: this.extractDimensionsFromContext(context)
2235
+ });
2236
+ console.log(" Facts:", facts.map((f2) => {
2237
+ var _a;
2238
+ return {
2239
+ value: f2.value,
2240
+ period: f2.period,
2241
+ dimensions: (_a = f2.dimensions) == null ? void 0 : _a.map((d2) => `${d2.dimension}:${d2.member}`)
2242
+ };
2243
+ }));
2244
+ const match = this.findMatchingFact(facts, context);
2245
+ console.log(" Match Result:", match ? match.value : "No match");
2246
+ }
2247
+ }
2013
2248
  class XBRLValidator {
2014
2249
  /**
2015
2250
  * Validates a value against XBRL datatype validation rules
@@ -2599,241 +2834,6 @@ function determineInputTypeFromBaseChain(baseTypeChain, datatypes) {
2599
2834
  placeholder: I18n.t("field.enterValue")
2600
2835
  };
2601
2836
  }
2602
- class FactMatcher {
2603
- /**
2604
- * Find a matching fact for a given cell context
2605
- */
2606
- static findMatchingFact(facts, context) {
2607
- if (!facts || facts.length === 0) {
2608
- return null;
2609
- }
2610
- const periodMatchedFacts = facts.filter(
2611
- (fact) => this.matchesPeriod(fact, context)
2612
- );
2613
- if (periodMatchedFacts.length === 0) {
2614
- return null;
2615
- }
2616
- const dimensionMatchedFacts = periodMatchedFacts.filter(
2617
- (fact) => this.matchesDimensions(fact, context)
2618
- );
2619
- if (dimensionMatchedFacts.length === 0) {
2620
- return null;
2621
- }
2622
- if (dimensionMatchedFacts.length > 1 && context.unit) {
2623
- const unitMatchedFact = dimensionMatchedFacts.find(
2624
- (fact) => this.matchesUnit(fact, context)
2625
- );
2626
- if (unitMatchedFact) {
2627
- return unitMatchedFact;
2628
- }
2629
- }
2630
- return dimensionMatchedFacts[0];
2631
- }
2632
- /**
2633
- * Check if fact period matches cell period
2634
- */
2635
- static matchesPeriod(fact, context) {
2636
- const factPeriod = this.parsePeriod(fact.period);
2637
- if (context.periodType === "instant" && context.periodInstantDate) {
2638
- return factPeriod.isInstant && factPeriod.instantDate === context.periodInstantDate;
2639
- }
2640
- if (context.periodType === "duration" && context.periodStartDate && context.periodEndDate) {
2641
- return !factPeriod.isInstant && factPeriod.startDate === context.periodStartDate && factPeriod.endDate === context.periodEndDate;
2642
- }
2643
- if (context.periodInstantDate) {
2644
- return factPeriod.isInstant && factPeriod.instantDate === context.periodInstantDate;
2645
- }
2646
- if (context.periodStartDate && context.periodEndDate) {
2647
- return !factPeriod.isInstant && factPeriod.startDate === context.periodStartDate && factPeriod.endDate === context.periodEndDate;
2648
- }
2649
- return true;
2650
- }
2651
- /**
2652
- * Check if fact dimensions match cell dimensions
2653
- */
2654
- static matchesDimensions(fact, context) {
2655
- const factDimensions = fact.dimensions || [];
2656
- const cellDimensions = this.extractDimensionsFromContext(context);
2657
- if (cellDimensions.length === 0) {
2658
- return factDimensions.length === 0;
2659
- }
2660
- if (factDimensions.length === 0 && cellDimensions.length > 0) {
2661
- return false;
2662
- }
2663
- if (factDimensions.length !== cellDimensions.length) {
2664
- return false;
2665
- }
2666
- const allMatch = cellDimensions.every((cellDim) => {
2667
- return factDimensions.some((factDim) => {
2668
- const axisMatch = this.normalizeAxisId(factDim.dimension) === this.normalizeAxisId(cellDim.axisId);
2669
- if (!axisMatch) {
2670
- return false;
2671
- }
2672
- if (factDim.dimensionType === "explicit" && cellDim.memberId) {
2673
- const memberMatch = this.normalizeMemberId(factDim.member || "") === this.normalizeMemberId(cellDim.memberId);
2674
- return memberMatch;
2675
- }
2676
- if (factDim.dimensionType === "typed" && cellDim.isTyped) {
2677
- return true;
2678
- }
2679
- return false;
2680
- });
2681
- });
2682
- return allMatch;
2683
- }
2684
- /**
2685
- * Check if fact unit matches cell unit
2686
- */
2687
- static matchesUnit(fact, context) {
2688
- if (!context.unit || !fact.unitMeasure) {
2689
- return true;
2690
- }
2691
- const factUnit = this.normalizeUnit(fact.unitMeasure);
2692
- const cellUnit = this.normalizeUnit(context.unit);
2693
- return factUnit === cellUnit;
2694
- }
2695
- /**
2696
- * Parse period string into structured format
2697
- */
2698
- static parsePeriod(period) {
2699
- if (period.includes(" / ")) {
2700
- const [startDate, endDate] = period.split(" / ").map((d2) => d2.trim());
2701
- return {
2702
- isInstant: false,
2703
- startDate,
2704
- endDate
2705
- };
2706
- }
2707
- return {
2708
- isInstant: true,
2709
- instantDate: period.trim()
2710
- };
2711
- }
2712
- /**
2713
- * Extract dimensions from cell context
2714
- */
2715
- static extractDimensionsFromContext(context) {
2716
- if (!context.dimensionData) {
2717
- return [];
2718
- }
2719
- const dimensions = [];
2720
- if (context.dimensionData.combinations && context.dimensionData.combinations.length > 0) {
2721
- context.dimensionData.combinations.forEach((combo) => {
2722
- dimensions.push({
2723
- axisId: combo.axisId,
2724
- memberId: combo.memberId
2725
- });
2726
- });
2727
- }
2728
- if (context.dimensionData.typedMembers && context.dimensionData.typedMembers.length > 0) {
2729
- context.dimensionData.typedMembers.forEach((typed) => {
2730
- dimensions.push({
2731
- axisId: typed.axisId,
2732
- memberId: "[typed]",
2733
- isTyped: true
2734
- });
2735
- });
2736
- }
2737
- return dimensions;
2738
- }
2739
- /**
2740
- * Normalize axis ID for comparison
2741
- * Handles both formats: "jenv-bw2-dim:BasisOfPreparationAxis" and "jenv-bw2-dim_BasisOfPreparationAxis"
2742
- * Returns: "BasisOfPreparationAxis"
2743
- */
2744
- static normalizeAxisId(axisId) {
2745
- if (!axisId)
2746
- return "";
2747
- if (axisId.includes(":")) {
2748
- const parts = axisId.split(":");
2749
- return parts[1] || parts[0];
2750
- }
2751
- if (axisId.includes("_")) {
2752
- axisId.split("_");
2753
- const lastUnderscoreIndex = axisId.lastIndexOf("_");
2754
- if (lastUnderscoreIndex > 0) {
2755
- return axisId.substring(lastUnderscoreIndex + 1);
2756
- }
2757
- }
2758
- return axisId;
2759
- }
2760
- /**
2761
- * Normalize member ID for comparison
2762
- * Handles both formats: "jenv-bw2-dm:CommercialMember" and "jenv-bw2-dm_CommercialMember"
2763
- * Returns: "CommercialMember"
2764
- */
2765
- static normalizeMemberId(memberId) {
2766
- if (!memberId)
2767
- return "";
2768
- if (memberId.includes(":")) {
2769
- const parts = memberId.split(":");
2770
- return parts[1] || parts[0];
2771
- }
2772
- if (memberId.includes("_")) {
2773
- const lastUnderscoreIndex = memberId.lastIndexOf("_");
2774
- if (lastUnderscoreIndex > 0) {
2775
- return memberId.substring(lastUnderscoreIndex + 1);
2776
- }
2777
- }
2778
- return memberId;
2779
- }
2780
- /**
2781
- * Normalize unit for comparison
2782
- * Converts "iso4217:EUR" to "EUR"
2783
- */
2784
- static normalizeUnit(unit) {
2785
- if (!unit)
2786
- return "";
2787
- const parts = unit.split(":");
2788
- return parts.length > 1 ? parts[1] : parts[0];
2789
- }
2790
- /**
2791
- * Extract typed dimension values from facts
2792
- * Returns a map of axis IDs to typed values
2793
- */
2794
- static extractTypedValues(facts, context) {
2795
- const typedValues = {};
2796
- if (!facts || facts.length === 0) {
2797
- return typedValues;
2798
- }
2799
- const matchedFacts = facts.filter(
2800
- (fact) => this.matchesPeriod(fact, context) && this.matchesDimensions(fact, context)
2801
- );
2802
- matchedFacts.forEach((fact) => {
2803
- if (fact.dimensions) {
2804
- fact.dimensions.forEach((dim) => {
2805
- if (dim.dimensionType === "typed" && dim.typedMemberValue) {
2806
- const axisId = this.normalizeAxisId(dim.dimension);
2807
- typedValues[axisId] = dim.typedMemberValue;
2808
- }
2809
- });
2810
- }
2811
- });
2812
- return typedValues;
2813
- }
2814
- /**
2815
- * Debug helper: Log matching process
2816
- */
2817
- static debugMatch(facts, context) {
2818
- console.log("🔍 [FactMatcher] Debug Match");
2819
- console.log(" Context:", {
2820
- conceptId: context.conceptId,
2821
- columnId: context.columnId,
2822
- period: context.periodType === "instant" ? context.periodInstantDate : `${context.periodStartDate} / ${context.periodEndDate}`,
2823
- dimensions: this.extractDimensionsFromContext(context)
2824
- });
2825
- console.log(" Facts:", facts.map((f2) => {
2826
- var _a;
2827
- return {
2828
- value: f2.value,
2829
- period: f2.period,
2830
- dimensions: (_a = f2.dimensions) == null ? void 0 : _a.map((d2) => `${d2.dimension}:${d2.member}`)
2831
- };
2832
- }));
2833
- const match = this.findMatchingFact(facts, context);
2834
- console.log(" Match Result:", match ? match.value : "No match");
2835
- }
2836
- }
2837
2837
  var __defProp$5 = Object.defineProperty;
2838
2838
  var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
2839
2839
  var __decorateClass$5 = (decorators, target, key, kind) => {
@@ -3453,7 +3453,8 @@ let JupiterFormField = class extends LitElement {
3453
3453
  });
3454
3454
  }
3455
3455
  }
3456
- const effectiveValue = isPredefinedValue ? this.masterData[baseConceptId] : factValue !== null ? factValue : this.value;
3456
+ const hasUserValue = this.value !== null && this.value !== void 0;
3457
+ const effectiveValue = isPredefinedValue ? this.masterData[baseConceptId] : hasUserValue ? this.value : factValue;
3457
3458
  const effectiveDisabled = isPredefinedValue || this.disabled;
3458
3459
  return html`
3459
3460
  <div class="field-container">
@@ -4143,6 +4144,8 @@ let JupiterAddColumnDialog = class extends LitElement {
4143
4144
  this.periodType = "duration";
4144
4145
  this.open = false;
4145
4146
  this.availableDimensions = [];
4147
+ this.periodStartDate = "";
4148
+ this.periodEndDate = "";
4146
4149
  this._startDate = "";
4147
4150
  this._endDate = "";
4148
4151
  this._instantDate = "";
@@ -4245,10 +4248,9 @@ let JupiterAddColumnDialog = class extends LitElement {
4245
4248
  }
4246
4249
  }
4247
4250
  _resetForm() {
4248
- const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
4249
- this._startDate = today;
4250
- this._endDate = today;
4251
- this._instantDate = today;
4251
+ this._startDate = this.periodStartDate || "";
4252
+ this._endDate = this.periodEndDate || "";
4253
+ this._instantDate = this.periodEndDate || this.periodStartDate || "";
4252
4254
  this._selectedType = this.periodType === "instant" ? "instant" : "duration";
4253
4255
  this._selectedDimensions.clear();
4254
4256
  this._autoSelectSingleMemberDimensions();
@@ -4684,6 +4686,12 @@ __decorateClass$3([
4684
4686
  __decorateClass$3([
4685
4687
  n2({ type: Array })
4686
4688
  ], JupiterAddColumnDialog.prototype, "availableDimensions", 2);
4689
+ __decorateClass$3([
4690
+ n2({ type: String })
4691
+ ], JupiterAddColumnDialog.prototype, "periodStartDate", 2);
4692
+ __decorateClass$3([
4693
+ n2({ type: String })
4694
+ ], JupiterAddColumnDialog.prototype, "periodEndDate", 2);
4687
4695
  __decorateClass$3([
4688
4696
  r()
4689
4697
  ], JupiterAddColumnDialog.prototype, "_startDate", 2);
@@ -4729,6 +4737,8 @@ let JupiterFormSection = class extends LitElement {
4729
4737
  this.availableDimensions = [];
4730
4738
  this.hideHeader = false;
4731
4739
  this.mode = "inputForm";
4740
+ this.periodStartDate = "";
4741
+ this.periodEndDate = "";
4732
4742
  this._expanded = true;
4733
4743
  this._showAddColumnDialog = false;
4734
4744
  this._sectionPeriodType = "duration";
@@ -5109,6 +5119,8 @@ let JupiterFormSection = class extends LitElement {
5109
5119
  .periodType="${this._sectionPeriodType}"
5110
5120
  ?open="${this._showAddColumnDialog}"
5111
5121
  .availableDimensions="${this.availableDimensions}"
5122
+ .periodStartDate="${this.periodStartDate}"
5123
+ .periodEndDate="${this.periodEndDate}"
5112
5124
  @dialog-cancel="${this._handleDialogCancel}"
5113
5125
  @column-add="${this._handleColumnAdd}"
5114
5126
  ></jupiter-add-column-dialog>
@@ -5422,6 +5434,12 @@ __decorateClass$2([
5422
5434
  __decorateClass$2([
5423
5435
  n2({ type: Object })
5424
5436
  ], JupiterFormSection.prototype, "masterData", 2);
5437
+ __decorateClass$2([
5438
+ n2({ type: String })
5439
+ ], JupiterFormSection.prototype, "periodStartDate", 2);
5440
+ __decorateClass$2([
5441
+ n2({ type: String })
5442
+ ], JupiterFormSection.prototype, "periodEndDate", 2);
5425
5443
  __decorateClass$2([
5426
5444
  r()
5427
5445
  ], JupiterFormSection.prototype, "_expanded", 2);
@@ -9452,7 +9470,7 @@ let JupiterDynamicForm = class extends LitElement {
9452
9470
  console.warn(`📦 masterData: NOT PROVIDED`);
9453
9471
  }
9454
9472
  const allFields = [];
9455
- this._collectAllFields(section2.concepts || [], new Set((section2.columns || []).map((col) => col.id)), allFields);
9473
+ this._collectAllFields(section2.concepts || [], new Set((section2.columns || []).map((col) => col.id)), section2.columns || [], allFields);
9456
9474
  console.warn(`📊 Total fields found: ${allFields.length}`);
9457
9475
  console.warn(`
9458
9476
  📋 FIELD DETAILS:`);
@@ -9495,30 +9513,52 @@ let JupiterDynamicForm = class extends LitElement {
9495
9513
  this._roleBorderStatuses = new Map(this._roleBorderStatuses);
9496
9514
  }
9497
9515
  }
9498
- _collectAllFields(concepts, sectionColumnIds, allFields) {
9499
- var _a;
9516
+ _collectAllFields(concepts, sectionColumnIds, sectionColumns, allFields) {
9517
+ var _a, _b;
9500
9518
  for (const concept of concepts) {
9501
9519
  if (concept.abstract) {
9502
9520
  if (concept.children && concept.children.length > 0) {
9503
- this._collectAllFields(concept.children, sectionColumnIds, allFields);
9521
+ this._collectAllFields(concept.children, sectionColumnIds, sectionColumns, allFields);
9504
9522
  }
9505
9523
  continue;
9506
9524
  }
9507
9525
  if (concept.fields && concept.fields.length > 0) {
9508
9526
  const relevantFields = concept.fields.filter((field2) => sectionColumnIds.has(field2.columnId));
9509
9527
  for (const field2 of relevantFields) {
9510
- const conceptIdForCheck = concept.id;
9511
- const originalConceptId = concept.id.split("__")[0];
9512
- const isMasterDataField = this.masterData && (this.masterData[conceptIdForCheck] !== void 0 || this.masterData[originalConceptId] !== void 0);
9528
+ const conceptIdWithSuffix = concept.id;
9529
+ const fieldConceptId = field2.conceptId;
9530
+ const isMasterDataField = this.masterData && this.masterData[fieldConceptId] !== void 0;
9513
9531
  if (isMasterDataField && this.masterData) {
9514
- const masterValue = this.masterData[conceptIdForCheck] || this.masterData[originalConceptId];
9515
- console.warn(` ⏭️ SKIPPING masterData field: ${concept.id} [${field2.columnId}] = ${JSON.stringify(masterValue)}`);
9532
+ const masterValue = this.masterData[fieldConceptId];
9533
+ console.warn(` ⏭️ SKIPPING masterData field: ${fieldConceptId} [${field2.columnId}] = ${JSON.stringify(masterValue)}`);
9516
9534
  continue;
9517
9535
  }
9518
- const value = (_a = this._formData[concept.id]) == null ? void 0 : _a[field2.columnId];
9519
- const isEmpty = value === null || value === void 0 || typeof value === "string" && value.trim() === "";
9536
+ let value = (_a = this._formData[conceptIdWithSuffix]) == null ? void 0 : _a[field2.columnId];
9537
+ if (value === void 0 && conceptIdWithSuffix !== fieldConceptId) {
9538
+ value = (_b = this._formData[fieldConceptId]) == null ? void 0 : _b[field2.columnId];
9539
+ }
9540
+ let isEmpty = value === null || value === void 0 || typeof value === "string" && value.trim() === "";
9541
+ if (isEmpty && concept.facts && concept.facts.length > 0) {
9542
+ const column2 = sectionColumns.find((col) => col.id === field2.columnId);
9543
+ const cellContext = {
9544
+ conceptId: fieldConceptId,
9545
+ columnId: field2.columnId,
9546
+ periodStartDate: field2.periodStartDate || (column2 == null ? void 0 : column2.periodStartDate),
9547
+ periodEndDate: field2.periodEndDate || (column2 == null ? void 0 : column2.periodEndDate),
9548
+ periodInstantDate: field2.periodInstantDate || (field2.periodType === "instant" ? field2.periodEndDate || field2.periodStartDate : void 0),
9549
+ periodType: field2.periodType,
9550
+ dimensionData: column2 == null ? void 0 : column2.dimensionData
9551
+ };
9552
+ const matchedFact = FactMatcher.findMatchingFact(concept.facts, cellContext);
9553
+ if (matchedFact && matchedFact.value !== null && matchedFact.value !== void 0 && matchedFact.value !== "") {
9554
+ value = matchedFact.value;
9555
+ isEmpty = false;
9556
+ console.warn(` ✨ FACT PRE-POPULATED: ${fieldConceptId} [${field2.columnId}] = ${JSON.stringify(value)}`);
9557
+ }
9558
+ }
9559
+ console.warn(` 🔍 Field lookup: concept.id="${conceptIdWithSuffix}", field.conceptId="${fieldConceptId}", value=${JSON.stringify(value)}, isEmpty=${isEmpty}`);
9520
9560
  allFields.push({
9521
- conceptId: concept.id,
9561
+ conceptId: fieldConceptId,
9522
9562
  columnId: field2.columnId,
9523
9563
  value,
9524
9564
  isEmpty
@@ -9526,7 +9566,7 @@ let JupiterDynamicForm = class extends LitElement {
9526
9566
  }
9527
9567
  }
9528
9568
  if (concept.children && concept.children.length > 0) {
9529
- this._collectAllFields(concept.children, sectionColumnIds, allFields);
9569
+ this._collectAllFields(concept.children, sectionColumnIds, sectionColumns, allFields);
9530
9570
  }
9531
9571
  }
9532
9572
  }
@@ -9958,6 +9998,8 @@ let JupiterDynamicForm = class extends LitElement {
9958
9998
  .availableDimensions="${this._getAvailableDimensionsForSection(section2.id)}"
9959
9999
  .mode="${this.mode}"
9960
10000
  .masterData="${this.masterData}"
10001
+ .periodStartDate="${this.periodStartDate}"
10002
+ .periodEndDate="${this.periodEndDate}"
9961
10003
  @field-change="${this._handleFieldChange}"
9962
10004
  @period-change="${this._handlePeriodChange}"
9963
10005
  @typed-member-change="${this._handleTypedMemberChange}"
@@ -10086,6 +10128,8 @@ let JupiterDynamicForm = class extends LitElement {
10086
10128
  .availableDimensions="${this._getAvailableDimensionsForSection(activeSection.id)}"
10087
10129
  .mode="${this.mode}"
10088
10130
  .masterData="${this.masterData}"
10131
+ .periodStartDate="${this.periodStartDate}"
10132
+ .periodEndDate="${this.periodEndDate}"
10089
10133
  @field-change="${this._handleFieldChange}"
10090
10134
  @typed-member-change="${this._handleTypedMemberChange}"
10091
10135
  @section-expand="${this._handleSectionExpand}"