jupiter-dynamic-forms 1.14.6 → 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
@@ -699,6 +699,8 @@ class XBRLFormBuilder {
699
699
  level,
700
700
  children,
701
701
  fields,
702
+ facts: concept.facts || [],
703
+ // Pass facts array from presentation concept for pre-population
702
704
  collapsed: level > 0,
703
705
  // Collapse nested levels by default
704
706
  abstract: concept.elementAbstract,
@@ -1080,7 +1082,7 @@ class XBRLFormBuilder {
1080
1082
  } else if (periodTypes.size === 1 && periodTypes.has("instant")) {
1081
1083
  columns2.push({
1082
1084
  id: "typed-instant",
1083
- title: `${axisLabel2} [Typed Input Available]`,
1085
+ title: `${axisLabel2} `,
1084
1086
  description: periodEndDate,
1085
1087
  type: "dimension",
1086
1088
  dimensionData: {
@@ -1110,7 +1112,7 @@ class XBRLFormBuilder {
1110
1112
  } else if (periodTypes.size === 1 && periodTypes.has("duration")) {
1111
1113
  columns2.push({
1112
1114
  id: "typed-duration",
1113
- title: `${axisLabel2} [Typed Input Available]`,
1115
+ title: `${axisLabel2} `,
1114
1116
  description: this.formatPeriodDisplay(periodStartDate, periodEndDate),
1115
1117
  type: "dimension",
1116
1118
  dimensionData: {
@@ -1140,7 +1142,7 @@ class XBRLFormBuilder {
1140
1142
  } else {
1141
1143
  columns2.push({
1142
1144
  id: "typed-duration",
1143
- title: `${axisLabel2} [Typed Input Available]`,
1145
+ title: `${axisLabel2} `,
1144
1146
  description: this.formatPeriodDisplay(periodStartDate, periodEndDate),
1145
1147
  type: "dimension",
1146
1148
  dimensionData: {
@@ -1307,7 +1309,7 @@ class XBRLFormBuilder {
1307
1309
  typedMemberId: dimension.typedMember.id,
1308
1310
  members: [{
1309
1311
  id: "[typed]",
1310
- label: `${axisLabel} [Typed Input Available]`
1312
+ label: `${axisLabel}`
1311
1313
  }]
1312
1314
  };
1313
1315
  }
@@ -2008,6 +2010,241 @@ class DraftStorageService {
2008
2010
  return { compatible, warnings };
2009
2011
  }
2010
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
+ }
2011
2248
  class XBRLValidator {
2012
2249
  /**
2013
2250
  * Validates a value against XBRL datatype validation rules
@@ -2616,6 +2853,7 @@ let JupiterFormField = class extends LitElement {
2616
2853
  this.disabled = false;
2617
2854
  this.locale = "en-US";
2618
2855
  this.hideLabel = false;
2856
+ this.mode = "inputForm";
2619
2857
  this._errors = [];
2620
2858
  this._xbrlErrors = [];
2621
2859
  this._touched = false;
@@ -2916,7 +3154,7 @@ let JupiterFormField = class extends LitElement {
2916
3154
  periodType: this.field.periodType
2917
3155
  });
2918
3156
  }
2919
- _renderInput() {
3157
+ _renderInput(effectiveValue = this.value, effectiveDisabled = this.disabled) {
2920
3158
  const hasErrors = this._errors.some((e2) => e2.severity === "error");
2921
3159
  const hasWarnings = this._errors.some((e2) => e2.severity === "warning");
2922
3160
  const isMonetary = this._isMonetaryType();
@@ -2933,8 +3171,8 @@ let JupiterFormField = class extends LitElement {
2933
3171
  id="${fieldId}"
2934
3172
  name="${fieldName}"
2935
3173
  class="${cssClass}"
2936
- .value="${this.value || ""}"
2937
- ?disabled="${this.disabled || this.field.disabled}"
3174
+ .value="${effectiveValue || ""}"
3175
+ ?disabled="${effectiveDisabled || this.field.disabled}"
2938
3176
  placeholder="${typeConfig.placeholder || this.field.placeholder || ""}"
2939
3177
  @input="${this._handleInput}"
2940
3178
  @focus="${this._handleFocus}"
@@ -2949,8 +3187,8 @@ let JupiterFormField = class extends LitElement {
2949
3187
  id="${fieldId}"
2950
3188
  name="${fieldName}"
2951
3189
  class="${cssClass}"
2952
- .value="${this.value || ""}"
2953
- ?disabled="${this.disabled || this.field.disabled}"
3190
+ .value="${effectiveValue || ""}"
3191
+ ?disabled="${effectiveDisabled || this.field.disabled}"
2954
3192
  @change="${this._handleInput}"
2955
3193
  @focus="${this._handleFocus}"
2956
3194
  @blur="${this._handleBlur}"
@@ -2964,7 +3202,7 @@ let JupiterFormField = class extends LitElement {
2964
3202
  <option
2965
3203
  value="${optionValue}"
2966
3204
  ?disabled="${isDisabled}"
2967
- ?selected="${this.value === optionValue}"
3205
+ ?selected="${effectiveValue === optionValue}"
2968
3206
  >
2969
3207
  ${optionLabel}
2970
3208
  </option>
@@ -2981,8 +3219,8 @@ let JupiterFormField = class extends LitElement {
2981
3219
  name="${fieldName}"
2982
3220
  type="checkbox"
2983
3221
  class="field-input"
2984
- .checked="${Boolean(this.value)}"
2985
- ?disabled="${this.disabled || this.field.disabled}"
3222
+ .checked="${Boolean(effectiveValue)}"
3223
+ ?disabled="${effectiveDisabled || this.field.disabled}"
2986
3224
  @change="${this._handleInput}"
2987
3225
  @focus="${this._handleFocus}"
2988
3226
  @blur="${this._handleBlur}"
@@ -3001,8 +3239,8 @@ let JupiterFormField = class extends LitElement {
3001
3239
  name="${fieldName}"
3002
3240
  type="${inputType}"
3003
3241
  class="${cssClass}"
3004
- .value="${this.value || ""}"
3005
- ?disabled="${this.disabled || this.field.disabled}"
3242
+ .value="${effectiveValue || ""}"
3243
+ ?disabled="${effectiveDisabled || this.field.disabled}"
3006
3244
  placeholder="${typeConfig.placeholder || this.field.placeholder || ""}"
3007
3245
  step="${step !== void 0 ? step : ""}"
3008
3246
  min="${min !== void 0 ? min : ""}"
@@ -3035,6 +3273,17 @@ let JupiterFormField = class extends LitElement {
3035
3273
  return "text";
3036
3274
  }
3037
3275
  }
3276
+ /**
3277
+ * Extract base concept ID by removing column suffix
3278
+ * Example: "nl-cd_LegalEntityName__4qukyf" -> "nl-cd_LegalEntityName"
3279
+ */
3280
+ _extractBaseConceptId(conceptId) {
3281
+ const parts = conceptId.split("__");
3282
+ if (parts.length > 1) {
3283
+ return parts.slice(0, -1).join("__");
3284
+ }
3285
+ return conceptId;
3286
+ }
3038
3287
  _renderPeriodControls() {
3039
3288
  if (this.conceptId === "nl-cd_DescriptionLocationNL__a64trl") {
3040
3289
  console.log(`🔍 [FormField Render] Concept: ${this.conceptId}, ColumnId: ${this.columnId}, Field periodType: ${this.field.periodType}, Field periodStartDate: ${this.field.periodStartDate}, Field periodEndDate: ${this.field.periodEndDate}`);
@@ -3143,8 +3392,70 @@ let JupiterFormField = class extends LitElement {
3143
3392
  `;
3144
3393
  }
3145
3394
  render() {
3395
+ var _a, _b;
3396
+ if (!this.field) {
3397
+ console.error("[FormField] No field provided!", { conceptId: this.conceptId, columnId: this.columnId });
3398
+ return html`<div>Error: No field data</div>`;
3399
+ }
3146
3400
  const showLabel = !this.hideLabel && this.field.type !== "boolean";
3147
3401
  const hasPeriodControl = this.field.periodType && (this.field.periodType === "instant" || this.field.periodType === "duration");
3402
+ const baseConceptId = this._extractBaseConceptId(this.conceptId);
3403
+ const isPredefinedValue = this.mode !== "admin" && this.masterData && baseConceptId in this.masterData;
3404
+ let factValue = null;
3405
+ if (this.facts && this.facts.length > 0 && !isPredefinedValue) {
3406
+ const cellContext = {
3407
+ conceptId: baseConceptId,
3408
+ columnId: this.columnId,
3409
+ periodStartDate: this.periodStartDate || this.field.periodStartDate,
3410
+ periodEndDate: this.periodEndDate || this.field.periodEndDate,
3411
+ periodInstantDate: this.periodInstantDate || this.field.periodInstantDate,
3412
+ periodType: this.field.periodType,
3413
+ unit: this.unit,
3414
+ dimensionData: (_a = this.column) == null ? void 0 : _a.dimensionData
3415
+ };
3416
+ const shouldDebugDimensions = baseConceptId.includes("BalanceSheet") || baseConceptId.includes("CostsIncorporation") || baseConceptId.includes("Assets");
3417
+ if (shouldDebugDimensions && this.facts.length > 0) {
3418
+ console.log("🔍 [FormField] Attempting fact match for concept with dimensions:", {
3419
+ conceptId: baseConceptId,
3420
+ columnId: this.columnId,
3421
+ factsCount: this.facts.length,
3422
+ cellContext: {
3423
+ period: cellContext.periodType === "instant" ? cellContext.periodInstantDate : `${cellContext.periodStartDate} / ${cellContext.periodEndDate}`,
3424
+ dimensionData: cellContext.dimensionData
3425
+ },
3426
+ facts: this.facts.map((f2) => {
3427
+ var _a2;
3428
+ return {
3429
+ value: f2.value,
3430
+ period: f2.period,
3431
+ dimensions: (_a2 = f2.dimensions) == null ? void 0 : _a2.map((d2) => `${d2.dimension}:${d2.member}`)
3432
+ };
3433
+ })
3434
+ });
3435
+ }
3436
+ const matchedFact = FactMatcher.findMatchingFact(this.facts, cellContext);
3437
+ if (matchedFact) {
3438
+ factValue = matchedFact.value;
3439
+ if (shouldDebugDimensions || baseConceptId.includes("StreetName")) {
3440
+ console.log("✅ [FormField] Fact matched:", {
3441
+ conceptId: baseConceptId,
3442
+ columnId: this.columnId,
3443
+ factValue: matchedFact.value,
3444
+ period: matchedFact.period,
3445
+ dimensions: (_b = matchedFact.dimensions) == null ? void 0 : _b.map((d2) => `${d2.dimension}:${d2.member}`)
3446
+ });
3447
+ }
3448
+ } else if (shouldDebugDimensions && this.facts.length > 0) {
3449
+ console.log("❌ [FormField] No fact match found for:", {
3450
+ conceptId: baseConceptId,
3451
+ columnId: this.columnId,
3452
+ factsAvailable: this.facts.length
3453
+ });
3454
+ }
3455
+ }
3456
+ const hasUserValue = this.value !== null && this.value !== void 0;
3457
+ const effectiveValue = isPredefinedValue ? this.masterData[baseConceptId] : hasUserValue ? this.value : factValue;
3458
+ const effectiveDisabled = isPredefinedValue || this.disabled;
3148
3459
  return html`
3149
3460
  <div class="field-container">
3150
3461
  ${showLabel ? html`
@@ -3154,7 +3465,7 @@ let JupiterFormField = class extends LitElement {
3154
3465
  ` : ""}
3155
3466
 
3156
3467
  <div class="field-wrapper">
3157
- ${this._renderInput()}
3468
+ ${this._renderInput(effectiveValue, effectiveDisabled)}
3158
3469
 
3159
3470
  ${hasPeriodControl ? html`
3160
3471
  <button
@@ -3496,6 +3807,18 @@ __decorateClass$5([
3496
3807
  __decorateClass$5([
3497
3808
  n2({ type: Boolean })
3498
3809
  ], JupiterFormField.prototype, "hideLabel", 2);
3810
+ __decorateClass$5([
3811
+ n2({ type: String })
3812
+ ], JupiterFormField.prototype, "mode", 2);
3813
+ __decorateClass$5([
3814
+ n2({ type: Object })
3815
+ ], JupiterFormField.prototype, "masterData", 2);
3816
+ __decorateClass$5([
3817
+ n2({ type: Array })
3818
+ ], JupiterFormField.prototype, "facts", 2);
3819
+ __decorateClass$5([
3820
+ n2({ type: Object })
3821
+ ], JupiterFormField.prototype, "column", 2);
3499
3822
  __decorateClass$5([
3500
3823
  n2({ type: String })
3501
3824
  ], JupiterFormField.prototype, "periodStartDate", 2);
@@ -3548,6 +3871,7 @@ let JupiterConceptTree = class extends LitElement {
3548
3871
  this.disabled = false;
3549
3872
  this.locale = "en-US";
3550
3873
  this.expandedConcepts = /* @__PURE__ */ new Set();
3874
+ this.mode = "inputForm";
3551
3875
  this._expanded = true;
3552
3876
  }
3553
3877
  connectedCallback() {
@@ -3641,6 +3965,10 @@ let JupiterConceptTree = class extends LitElement {
3641
3965
  .disabled="${this.disabled}"
3642
3966
  .locale="${this.locale}"
3643
3967
  .hideLabel="${true}"
3968
+ .mode="${this.mode}"
3969
+ .masterData="${this.masterData}"
3970
+ .facts="${this.facts}"
3971
+ .column="${column2}"
3644
3972
  @field-change="${this._handleFieldChange}"
3645
3973
  @period-change="${this._handlePeriodChange}"
3646
3974
  ></jupiter-form-field>
@@ -3784,6 +4112,15 @@ __decorateClass$4([
3784
4112
  __decorateClass$4([
3785
4113
  n2({ type: Array })
3786
4114
  ], JupiterConceptTree.prototype, "datatypes", 2);
4115
+ __decorateClass$4([
4116
+ n2({ type: String })
4117
+ ], JupiterConceptTree.prototype, "mode", 2);
4118
+ __decorateClass$4([
4119
+ n2({ type: Object })
4120
+ ], JupiterConceptTree.prototype, "masterData", 2);
4121
+ __decorateClass$4([
4122
+ n2({ type: Array })
4123
+ ], JupiterConceptTree.prototype, "facts", 2);
3787
4124
  __decorateClass$4([
3788
4125
  r()
3789
4126
  ], JupiterConceptTree.prototype, "_expanded", 2);
@@ -3807,6 +4144,8 @@ let JupiterAddColumnDialog = class extends LitElement {
3807
4144
  this.periodType = "duration";
3808
4145
  this.open = false;
3809
4146
  this.availableDimensions = [];
4147
+ this.periodStartDate = "";
4148
+ this.periodEndDate = "";
3810
4149
  this._startDate = "";
3811
4150
  this._endDate = "";
3812
4151
  this._instantDate = "";
@@ -3909,10 +4248,9 @@ let JupiterAddColumnDialog = class extends LitElement {
3909
4248
  }
3910
4249
  }
3911
4250
  _resetForm() {
3912
- const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
3913
- this._startDate = today;
3914
- this._endDate = today;
3915
- this._instantDate = today;
4251
+ this._startDate = this.periodStartDate || "";
4252
+ this._endDate = this.periodEndDate || "";
4253
+ this._instantDate = this.periodEndDate || this.periodStartDate || "";
3916
4254
  this._selectedType = this.periodType === "instant" ? "instant" : "duration";
3917
4255
  this._selectedDimensions.clear();
3918
4256
  this._autoSelectSingleMemberDimensions();
@@ -4348,6 +4686,12 @@ __decorateClass$3([
4348
4686
  __decorateClass$3([
4349
4687
  n2({ type: Array })
4350
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);
4351
4695
  __decorateClass$3([
4352
4696
  r()
4353
4697
  ], JupiterAddColumnDialog.prototype, "_startDate", 2);
@@ -4392,6 +4736,9 @@ let JupiterFormSection = class extends LitElement {
4392
4736
  this.isFirstSection = false;
4393
4737
  this.availableDimensions = [];
4394
4738
  this.hideHeader = false;
4739
+ this.mode = "inputForm";
4740
+ this.periodStartDate = "";
4741
+ this.periodEndDate = "";
4395
4742
  this._expanded = true;
4396
4743
  this._showAddColumnDialog = false;
4397
4744
  this._sectionPeriodType = "duration";
@@ -4753,6 +5100,9 @@ let JupiterFormSection = class extends LitElement {
4753
5100
  .disabled="${this.disabled}"
4754
5101
  .locale="${this.locale}"
4755
5102
  .expandedConcepts="${this._expandedConcepts}"
5103
+ .mode="${this.mode}"
5104
+ .masterData="${this.masterData}"
5105
+ .facts="${concept.facts}"
4756
5106
  @field-change="${this._handleFieldChange}"
4757
5107
  @period-change="${this._handlePeriodChange}"
4758
5108
  @concept-expand="${this._handleConceptExpand}"
@@ -4769,6 +5119,8 @@ let JupiterFormSection = class extends LitElement {
4769
5119
  .periodType="${this._sectionPeriodType}"
4770
5120
  ?open="${this._showAddColumnDialog}"
4771
5121
  .availableDimensions="${this.availableDimensions}"
5122
+ .periodStartDate="${this.periodStartDate}"
5123
+ .periodEndDate="${this.periodEndDate}"
4772
5124
  @dialog-cancel="${this._handleDialogCancel}"
4773
5125
  @column-add="${this._handleColumnAdd}"
4774
5126
  ></jupiter-add-column-dialog>
@@ -5076,6 +5428,18 @@ __decorateClass$2([
5076
5428
  __decorateClass$2([
5077
5429
  n2({ type: Boolean })
5078
5430
  ], JupiterFormSection.prototype, "hideHeader", 2);
5431
+ __decorateClass$2([
5432
+ n2({ type: String })
5433
+ ], JupiterFormSection.prototype, "mode", 2);
5434
+ __decorateClass$2([
5435
+ n2({ type: Object })
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);
5079
5443
  __decorateClass$2([
5080
5444
  r()
5081
5445
  ], JupiterFormSection.prototype, "_expanded", 2);
@@ -5344,6 +5708,13 @@ let JupiterFilterRolesDialog = class extends LitElement {
5344
5708
  }));
5345
5709
  }
5346
5710
  _handleApply() {
5711
+ const currentlySelected = Array.from(this._tempSelectedRoles);
5712
+ const orderedByOriginal = currentlySelected.sort((a2, b2) => {
5713
+ const indexA = this.availableRoles.findIndex((r2) => r2.id === a2);
5714
+ const indexB = this.availableRoles.findIndex((r2) => r2.id === b2);
5715
+ return indexA - indexB;
5716
+ });
5717
+ this._chosenRoleOrder = orderedByOriginal;
5347
5718
  const orderedRolesWithMetadata = this._chosenRoleOrder.map((roleId, index) => {
5348
5719
  var _a;
5349
5720
  const role = this.availableRoles.find((r2) => r2.id === roleId);
@@ -6675,6 +7046,11 @@ let JupiterDynamicForm = class extends LitElement {
6675
7046
  this._sidePanelSearchQuery = "";
6676
7047
  this._sidePanelCollapsed = false;
6677
7048
  this._adminRoleConfigs = {};
7049
+ this._roleBorderStatuses = /* @__PURE__ */ new Map();
7050
+ this._showRoleContextMenu = false;
7051
+ this._contextMenuX = 0;
7052
+ this._contextMenuY = 0;
7053
+ this._contextMenuRoleId = null;
6678
7054
  this._skipDraftLoading = false;
6679
7055
  this._skipPeriodPreferencesRestore = false;
6680
7056
  }
@@ -6697,6 +7073,12 @@ let JupiterDynamicForm = class extends LitElement {
6697
7073
  const customEvent = e2;
6698
7074
  this._handleFieldBlur(customEvent);
6699
7075
  });
7076
+ document.addEventListener("click", () => {
7077
+ if (this._showRoleContextMenu) {
7078
+ this._showRoleContextMenu = false;
7079
+ this.requestUpdate();
7080
+ }
7081
+ });
6700
7082
  this._initializeForm();
6701
7083
  }
6702
7084
  updated(changedProperties) {
@@ -6824,13 +7206,185 @@ let JupiterDynamicForm = class extends LitElement {
6824
7206
  if ((_a = this.xbrlInput) == null ? void 0 : _a.initialData) {
6825
7207
  this._formData = { ...this._formData, ...this.xbrlInput.initialData };
6826
7208
  }
7209
+ this._extractTypedMembersFromFacts();
6827
7210
  if (!this._skipDraftLoading) {
6828
- this._loadDraftIfExists();
7211
+ this._loadDraftIfExists().then(() => {
7212
+ this._analyzeAllVisibleRoles();
7213
+ }).catch(() => {
7214
+ this._analyzeAllVisibleRoles();
7215
+ });
6829
7216
  } else {
6830
7217
  console.log("⏭️ Skipping draft loading during preference update");
7218
+ this._analyzeAllVisibleRoles();
6831
7219
  }
6832
7220
  this._validateForm();
6833
7221
  }
7222
+ /**
7223
+ * Extract typed dimension values from facts and pre-populate typedMemberData
7224
+ * This scans all facts for typed dimensions and sets their values in column headers
7225
+ */
7226
+ _extractTypedMembersFromFacts() {
7227
+ var _a;
7228
+ if (!((_a = this._currentSchema) == null ? void 0 : _a.sections)) {
7229
+ return;
7230
+ }
7231
+ console.log("🔍 [DynamicForm] Extracting typed member values from facts");
7232
+ this._currentSchema.sections.forEach((section2) => {
7233
+ this._extractTypedMembersFromConcepts(section2.concepts || [], section2);
7234
+ });
7235
+ console.log("✅ [DynamicForm] Typed member data populated:", this._typedMemberData);
7236
+ }
7237
+ /**
7238
+ * Recursively extract typed member values from concept tree
7239
+ */
7240
+ _extractTypedMembersFromConcepts(concepts, section2) {
7241
+ concepts.forEach((concept) => {
7242
+ if (concept.facts && concept.facts.length > 0) {
7243
+ console.log(`🔍 [DynamicForm] Checking concept ${concept.id} with ${concept.facts.length} facts`);
7244
+ concept.facts.forEach((fact) => {
7245
+ if (fact.dimensions && Array.isArray(fact.dimensions)) {
7246
+ const typedDimensions = fact.dimensions.filter((d2) => d2.dimensionType === "typed" && d2.typedMemberValue);
7247
+ if (typedDimensions.length > 0) {
7248
+ console.log(`📝 [DynamicForm] Found ${typedDimensions.length} typed dimensions in fact:`, {
7249
+ factName: fact.name,
7250
+ typedDimensions: typedDimensions.map((d2) => ({
7251
+ dimension: d2.dimension,
7252
+ typedMemberValue: d2.typedMemberValue
7253
+ }))
7254
+ });
7255
+ const matchingColumn = this._findColumnWithTypedMembers(fact, concept, section2);
7256
+ if (matchingColumn) {
7257
+ console.log(`✅ [DynamicForm] Found matching column: ${matchingColumn.id}`);
7258
+ typedDimensions.forEach((dim) => {
7259
+ var _a, _b;
7260
+ const normalizedAxisId = this._normalizeAxisId(dim.dimension);
7261
+ const typedMember = (_b = (_a = matchingColumn.dimensionData) == null ? void 0 : _a.typedMembers) == null ? void 0 : _b.find(
7262
+ (tm) => tm.axisId === normalizedAxisId || this._normalizeAxisId(tm.axisId) === normalizedAxisId
7263
+ );
7264
+ if (typedMember) {
7265
+ if (!this._typedMemberData[matchingColumn.id]) {
7266
+ this._typedMemberData[matchingColumn.id] = {};
7267
+ }
7268
+ const axisKey = typedMember.axisId;
7269
+ this._typedMemberData[matchingColumn.id][axisKey] = dim.typedMemberValue;
7270
+ console.log(`✅ [DynamicForm] Set typed member value:`, {
7271
+ sectionId: section2.id,
7272
+ conceptId: concept.id,
7273
+ columnId: matchingColumn.id,
7274
+ axisKey,
7275
+ typedMemberValue: dim.typedMemberValue
7276
+ });
7277
+ } else {
7278
+ console.warn(`⚠️ [DynamicForm] Typed member not found for axis: ${normalizedAxisId}`);
7279
+ }
7280
+ });
7281
+ } else {
7282
+ console.warn(`⚠️ [DynamicForm] No matching column found for fact with typed dimensions`);
7283
+ }
7284
+ }
7285
+ }
7286
+ });
7287
+ }
7288
+ if (concept.children && concept.children.length > 0) {
7289
+ this._extractTypedMembersFromConcepts(concept.children, section2);
7290
+ }
7291
+ });
7292
+ }
7293
+ /**
7294
+ * Find a column that has typed members and matches the fact's explicit dimensions
7295
+ */
7296
+ _findColumnWithTypedMembers(fact, concept, section2) {
7297
+ var _a;
7298
+ if (!concept.fields || concept.fields.length === 0) {
7299
+ return null;
7300
+ }
7301
+ const sectionColumns = section2.columns || [];
7302
+ if (sectionColumns.length === 0) {
7303
+ return null;
7304
+ }
7305
+ for (const field2 of concept.fields) {
7306
+ const column2 = sectionColumns.find((col) => col.id === field2.columnId);
7307
+ if (column2 && ((_a = column2.dimensionData) == null ? void 0 : _a.hasTypedMembers)) {
7308
+ const factExplicitDims = (fact.dimensions || []).filter((d2) => d2.dimensionType === "explicit");
7309
+ const columnExplicitDims = column2.dimensionData.combinations || [];
7310
+ if (factExplicitDims.length === 0 || factExplicitDims.length === columnExplicitDims.length && factExplicitDims.every(
7311
+ (factDim) => columnExplicitDims.some(
7312
+ (colDim) => this._normalizeAxisId(factDim.dimension) === this._normalizeAxisId(colDim.axisId) && this._normalizeMemberId(factDim.member) === this._normalizeMemberId(colDim.memberId)
7313
+ )
7314
+ )) {
7315
+ return column2;
7316
+ }
7317
+ }
7318
+ }
7319
+ return null;
7320
+ }
7321
+ /**
7322
+ * Find the column that matches the fact's dimensions
7323
+ */
7324
+ _findColumnForFactDimensions(fact, concept, section2) {
7325
+ if (!concept.fields || concept.fields.length === 0) {
7326
+ console.log(`⚠️ [DynamicForm] No fields for concept: ${concept.id}`);
7327
+ return null;
7328
+ }
7329
+ const sectionColumns = section2.columns || [];
7330
+ if (sectionColumns.length === 0) {
7331
+ console.log(`⚠️ [DynamicForm] No columns in section: ${section2.id}`);
7332
+ return null;
7333
+ }
7334
+ for (const field2 of concept.fields) {
7335
+ const column2 = sectionColumns.find((col) => col.id === field2.columnId);
7336
+ if (column2 && column2.dimensionData) {
7337
+ const factDimensions = fact.dimensions || [];
7338
+ const columnDimensions = column2.dimensionData.combinations || [];
7339
+ console.log(`🔍 [DynamicForm] Checking column ${column2.id}:`, {
7340
+ factDimensions: factDimensions.map((d2) => ({ axis: d2.dimension, member: d2.member, type: d2.dimensionType })),
7341
+ columnDimensions: columnDimensions.map((d2) => ({ axis: d2.axisId, member: d2.memberId }))
7342
+ });
7343
+ const allMatch = columnDimensions.every((colDim) => {
7344
+ return factDimensions.some((factDim) => {
7345
+ const axisMatch = this._normalizeAxisId(factDim.dimension) === this._normalizeAxisId(colDim.axisId);
7346
+ if (factDim.dimensionType === "explicit") {
7347
+ const memberMatch = this._normalizeMemberId(factDim.member) === this._normalizeMemberId(colDim.memberId);
7348
+ return axisMatch && memberMatch;
7349
+ } else if (factDim.dimensionType === "typed") {
7350
+ return axisMatch;
7351
+ }
7352
+ return false;
7353
+ });
7354
+ });
7355
+ if (allMatch) {
7356
+ return column2;
7357
+ }
7358
+ }
7359
+ }
7360
+ return null;
7361
+ }
7362
+ /**
7363
+ * Normalize axis ID by extracting the local name
7364
+ */
7365
+ _normalizeAxisId(axisId) {
7366
+ if (!axisId)
7367
+ return "";
7368
+ if (axisId.includes(":")) {
7369
+ return axisId.split(":").pop() || axisId;
7370
+ } else if (axisId.includes("_")) {
7371
+ return axisId.split("_").pop() || axisId;
7372
+ }
7373
+ return axisId;
7374
+ }
7375
+ /**
7376
+ * Normalize member ID by extracting the local name
7377
+ */
7378
+ _normalizeMemberId(memberId) {
7379
+ if (!memberId)
7380
+ return "";
7381
+ if (memberId.includes(":")) {
7382
+ return memberId.split(":").pop() || memberId;
7383
+ } else if (memberId.includes("_")) {
7384
+ return memberId.split("_").pop() || memberId;
7385
+ }
7386
+ return memberId;
7387
+ }
6834
7388
  _getDefaultSchema() {
6835
7389
  return {
6836
7390
  version: "1.0",
@@ -7078,10 +7632,14 @@ let JupiterDynamicForm = class extends LitElement {
7078
7632
  console.log(`🚫 Filter dialog cancelled. Current selection: ${roleCount}/${this._allSections.length}`);
7079
7633
  }
7080
7634
  _handleRoleFilterApply(event) {
7635
+ var _a, _b;
7081
7636
  const { selectedRoleIds, periodPreferences } = event.detail;
7637
+ console.log("🎯 Filter apply triggered");
7638
+ console.log("📊 Old _selectedRoleIds:", this._selectedRoleIds);
7639
+ console.log("📊 New selectedRoleIds from dialog:", selectedRoleIds);
7082
7640
  this._selectedRoleIds = selectedRoleIds;
7083
7641
  this._periodPreferences = periodPreferences;
7084
- console.log("🎯 Filter apply triggered - always reinitializing form");
7642
+ console.log("📊 Updated _selectedRoleIds:", this._selectedRoleIds);
7085
7643
  console.log("📊 New period preferences (including dimension selections):", this._periodPreferences);
7086
7644
  console.log("💾 Capturing current form data before reinitialization...");
7087
7645
  const currentFormData = this._generateSubmissionData();
@@ -7105,6 +7663,8 @@ let JupiterDynamicForm = class extends LitElement {
7105
7663
  this._initializeForm();
7106
7664
  this._skipDraftLoading = false;
7107
7665
  this._skipPeriodPreferencesRestore = false;
7666
+ console.log("📊 After _initializeForm, _currentSchema.sections.length:", (_a = this._currentSchema) == null ? void 0 : _a.sections.length);
7667
+ console.log("📊 Section IDs:", (_b = this._currentSchema) == null ? void 0 : _b.sections.map((s2) => s2.id));
7108
7668
  console.log("📥 Restoring form data from draft after reinitialization...");
7109
7669
  this._loadDraftIfExists().then(() => {
7110
7670
  console.log("✅ Form data restored successfully after reinitialization");
@@ -7345,6 +7905,9 @@ let JupiterDynamicForm = class extends LitElement {
7345
7905
  console.log(`🔍 [_getSectionTitle] Result: "${result}"`);
7346
7906
  return result;
7347
7907
  }
7908
+ _roleHasErrors(roleId) {
7909
+ return this._xbrlFormErrors.some((error2) => error2.sectionId === roleId);
7910
+ }
7348
7911
  async _handleErrorFieldClick(conceptId, columnId, sectionId) {
7349
7912
  var _a, _b, _c, _d;
7350
7913
  console.log(`🎯 [Error Click] Attempting to focus field: ${conceptId}__${columnId} in section: ${sectionId}`);
@@ -7823,6 +8386,16 @@ let JupiterDynamicForm = class extends LitElement {
7823
8386
  this._handleAdminModeSubmit();
7824
8387
  return;
7825
8388
  }
8389
+ console.log(`🔵 [Submit] Checking for errors...`);
8390
+ console.log(`🔵 [Submit] _xbrlFormErrors.length: ${this._xbrlFormErrors.length}`);
8391
+ console.log(`🔵 [Submit] _xbrlFormErrors:`, this._xbrlFormErrors);
8392
+ if (this._xbrlFormErrors.length > 0) {
8393
+ console.log("❌ [Submit] Cannot submit - validation errors present:", this._xbrlFormErrors);
8394
+ this._showErrorPopup = true;
8395
+ this.requestUpdate();
8396
+ return;
8397
+ }
8398
+ console.log(`✅ [Submit] No validation errors, proceeding with submission...`);
7826
8399
  this._validateForm();
7827
8400
  const submissionData = this._generateSubmissionData();
7828
8401
  console.log("📊 Form Submission Data:", JSON.stringify(submissionData, null, 2));
@@ -8800,9 +9373,203 @@ let JupiterDynamicForm = class extends LitElement {
8800
9373
  submitted: this._submitted
8801
9374
  };
8802
9375
  }
9376
+ /**
9377
+ * Analyze all visible roles on form load to set initial border statuses
9378
+ */
9379
+ _analyzeAllVisibleRoles() {
9380
+ if (!this._currentSchema || !this._currentSchema.sections || this._currentSchema.sections.length === 0) {
9381
+ console.log("⏭️ No sections to analyze for initial border status");
9382
+ return;
9383
+ }
9384
+ console.log(`🔍 Analyzing ${this._currentSchema.sections.length} visible roles for initial border status...`);
9385
+ for (const section2 of this._currentSchema.sections) {
9386
+ this._analyzeAndLogRole(section2.id);
9387
+ }
9388
+ console.log(`✅ Initial border status analysis complete for all visible roles`);
9389
+ }
9390
+ /**
9391
+ * Handle right-click on role item to show context menu
9392
+ */
9393
+ _handleRoleContextMenu(event, roleId, roleTitle) {
9394
+ event.preventDefault();
9395
+ event.stopPropagation();
9396
+ this._contextMenuX = event.clientX;
9397
+ this._contextMenuY = event.clientY;
9398
+ this._contextMenuRoleId = roleId;
9399
+ this._showRoleContextMenu = true;
9400
+ console.log(`🖱️ Context menu opened for role: ${roleTitle} (ID: ${roleId})`);
9401
+ this.requestUpdate();
9402
+ }
9403
+ /**
9404
+ * Close the context menu
9405
+ */
9406
+ _closeRoleContextMenu() {
9407
+ this._showRoleContextMenu = false;
9408
+ this._contextMenuRoleId = null;
9409
+ this.requestUpdate();
9410
+ }
9411
+ /**
9412
+ * Handle remove role action - removes role from side panel
9413
+ */
9414
+ _handleRemoveRole() {
9415
+ if (!this._contextMenuRoleId) {
9416
+ this._closeRoleContextMenu();
9417
+ return;
9418
+ }
9419
+ const role = this._allSections.find((s2) => s2.id === this._contextMenuRoleId);
9420
+ const roleTitle = (role == null ? void 0 : role.title) || "Unknown";
9421
+ console.log(`🗑️ Removing role from side panel:`);
9422
+ console.log(` - Role ID: ${this._contextMenuRoleId}`);
9423
+ console.log(` - Role Title: ${roleTitle}`);
9424
+ if (Array.isArray(this._selectedRoleIds)) {
9425
+ if (this._selectedRoleIds.length > 0 && typeof this._selectedRoleIds[0] === "object") {
9426
+ this._selectedRoleIds = this._selectedRoleIds.filter((r2) => r2.roleId !== this._contextMenuRoleId);
9427
+ } else {
9428
+ this._selectedRoleIds = this._selectedRoleIds.filter((id) => id !== this._contextMenuRoleId);
9429
+ }
9430
+ }
9431
+ console.log(`✅ Role removed from _selectedRoleIds. Remaining roles: ${this._selectedRoleIds.length}`);
9432
+ if (this._activeSidePanelRoleId === this._contextMenuRoleId) {
9433
+ const remainingRoleIds = this._getRoleIdsArray();
9434
+ this._activeSidePanelRoleId = remainingRoleIds.length > 0 ? remainingRoleIds[0] : null;
9435
+ console.log(`📌 Active role changed to: ${this._activeSidePanelRoleId || "None"}`);
9436
+ }
9437
+ this._applyRoleFilter();
9438
+ this.dispatchEvent(new CustomEvent("role-removed", {
9439
+ detail: {
9440
+ roleId: this._contextMenuRoleId,
9441
+ roleTitle,
9442
+ remainingRolesCount: this._selectedRoleIds.length
9443
+ },
9444
+ bubbles: true,
9445
+ composed: true
9446
+ }));
9447
+ console.log(`✅ Role "${roleTitle}" successfully removed from side panel`);
9448
+ console.log(`ℹ️ User can re-add this role using the Filter Roles dialog`);
9449
+ this._closeRoleContextMenu();
9450
+ }
8803
9451
  _handleSidePanelRoleClick(roleId) {
9452
+ if (this._activeSidePanelRoleId && this._activeSidePanelRoleId !== roleId) {
9453
+ this._analyzeAndLogRole(this._activeSidePanelRoleId);
9454
+ }
8804
9455
  this._activeSidePanelRoleId = roleId;
8805
9456
  }
9457
+ _analyzeAndLogRole(roleId) {
9458
+ const section2 = this._allSections.find((s2) => s2.id === roleId);
9459
+ if (!section2) {
9460
+ console.warn(`⚠️ Section not found for roleId: ${roleId}`);
9461
+ return;
9462
+ }
9463
+ console.warn(`
9464
+ ========================================`);
9465
+ console.warn(`🔍 ANALYZING ROLE: "${section2.title}"`);
9466
+ console.warn(`========================================`);
9467
+ if (this.masterData) {
9468
+ console.warn(`📦 masterData keys:`, Object.keys(this.masterData));
9469
+ } else {
9470
+ console.warn(`📦 masterData: NOT PROVIDED`);
9471
+ }
9472
+ const allFields = [];
9473
+ this._collectAllFields(section2.concepts || [], new Set((section2.columns || []).map((col) => col.id)), section2.columns || [], allFields);
9474
+ console.warn(`📊 Total fields found: ${allFields.length}`);
9475
+ console.warn(`
9476
+ 📋 FIELD DETAILS:`);
9477
+ allFields.forEach((field2, index) => {
9478
+ const status = field2.isEmpty ? "❌ EMPTY" : "✅ FILLED";
9479
+ console.warn(` ${index + 1}. ${field2.conceptId} [${field2.columnId}]: ${status} = ${JSON.stringify(field2.value)}`);
9480
+ });
9481
+ const hasErrors = this._roleHasErrors(roleId);
9482
+ const emptyCount = allFields.filter((f2) => f2.isEmpty).length;
9483
+ const filledCount = allFields.filter((f2) => !f2.isEmpty).length;
9484
+ console.warn(`
9485
+ 📈 SUMMARY:`);
9486
+ console.warn(` Total Fields: ${allFields.length}`);
9487
+ console.warn(` Filled: ${filledCount}`);
9488
+ console.warn(` Empty: ${emptyCount}`);
9489
+ console.warn(` Has Errors: ${hasErrors}`);
9490
+ let result;
9491
+ if (hasErrors) {
9492
+ result = "INVALID";
9493
+ console.warn(`
9494
+ 🔴 RESULT: INVALID (contains validation errors)`);
9495
+ } else if (emptyCount > 0) {
9496
+ result = "INCOMPLETE";
9497
+ console.warn(`
9498
+ 🟠 RESULT: INCOMPLETE (${emptyCount} field(s) blank)`);
9499
+ } else {
9500
+ result = "COMPLETE";
9501
+ console.warn(`
9502
+ 🟢 RESULT: COMPLETE (all fields filled)`);
9503
+ }
9504
+ console.warn(`========================================
9505
+ `);
9506
+ if (result === "INVALID")
9507
+ ;
9508
+ else if (result === "INCOMPLETE") {
9509
+ this._roleBorderStatuses.set(roleId, "incomplete");
9510
+ this._roleBorderStatuses = new Map(this._roleBorderStatuses);
9511
+ } else {
9512
+ this._roleBorderStatuses.set(roleId, "complete");
9513
+ this._roleBorderStatuses = new Map(this._roleBorderStatuses);
9514
+ }
9515
+ }
9516
+ _collectAllFields(concepts, sectionColumnIds, sectionColumns, allFields) {
9517
+ var _a, _b;
9518
+ for (const concept of concepts) {
9519
+ if (concept.abstract) {
9520
+ if (concept.children && concept.children.length > 0) {
9521
+ this._collectAllFields(concept.children, sectionColumnIds, sectionColumns, allFields);
9522
+ }
9523
+ continue;
9524
+ }
9525
+ if (concept.fields && concept.fields.length > 0) {
9526
+ const relevantFields = concept.fields.filter((field2) => sectionColumnIds.has(field2.columnId));
9527
+ for (const field2 of relevantFields) {
9528
+ const conceptIdWithSuffix = concept.id;
9529
+ const fieldConceptId = field2.conceptId;
9530
+ const isMasterDataField = this.masterData && this.masterData[fieldConceptId] !== void 0;
9531
+ if (isMasterDataField && this.masterData) {
9532
+ const masterValue = this.masterData[fieldConceptId];
9533
+ console.warn(` ⏭️ SKIPPING masterData field: ${fieldConceptId} [${field2.columnId}] = ${JSON.stringify(masterValue)}`);
9534
+ continue;
9535
+ }
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}`);
9560
+ allFields.push({
9561
+ conceptId: fieldConceptId,
9562
+ columnId: field2.columnId,
9563
+ value,
9564
+ isEmpty
9565
+ });
9566
+ }
9567
+ }
9568
+ if (concept.children && concept.children.length > 0) {
9569
+ this._collectAllFields(concept.children, sectionColumnIds, sectionColumns, allFields);
9570
+ }
9571
+ }
9572
+ }
8806
9573
  _handleSidePanelSearchInput(event) {
8807
9574
  const input = event.target;
8808
9575
  this._sidePanelSearchQuery = input.value;
@@ -9229,6 +9996,10 @@ let JupiterDynamicForm = class extends LitElement {
9229
9996
  .locale="${config.locale || "en-US"}"
9230
9997
  .isFirstSection="${index === 0}"
9231
9998
  .availableDimensions="${this._getAvailableDimensionsForSection(section2.id)}"
9999
+ .mode="${this.mode}"
10000
+ .masterData="${this.masterData}"
10001
+ .periodStartDate="${this.periodStartDate}"
10002
+ .periodEndDate="${this.periodEndDate}"
9232
10003
  @field-change="${this._handleFieldChange}"
9233
10004
  @period-change="${this._handlePeriodChange}"
9234
10005
  @typed-member-change="${this._handleTypedMemberChange}"
@@ -9300,14 +10071,20 @@ let JupiterDynamicForm = class extends LitElement {
9300
10071
  ${I18n.t("filter.tryDifferentSearch")}
9301
10072
  </div>
9302
10073
  ` : html`
9303
- ${filteredSections.map((section2) => html`
9304
- <div
9305
- class="side-panel-role-item ${section2.id === this._activeSidePanelRoleId ? "active" : ""}"
9306
- @click="${() => this._handleSidePanelRoleClick(section2.id)}"
9307
- >
9308
- ${section2.title}
9309
- </div>
9310
- `)}
10074
+ ${filteredSections.map((section2) => {
10075
+ const hasErrors = this._roleHasErrors(section2.id);
10076
+ const borderStatus = this._roleBorderStatuses.get(section2.id);
10077
+ const statusClass = hasErrors ? "has-errors" : borderStatus === "incomplete" ? "has-empty-fields" : borderStatus === "complete" ? "has-complete-data" : "";
10078
+ return html`
10079
+ <div
10080
+ class="side-panel-role-item ${section2.id === this._activeSidePanelRoleId ? "active" : ""} ${statusClass}"
10081
+ @click="${() => this._handleSidePanelRoleClick(section2.id)}"
10082
+ @contextmenu="${(e2) => this._handleRoleContextMenu(e2, section2.id, section2.title)}"
10083
+ >
10084
+ ${section2.title}
10085
+ </div>
10086
+ `;
10087
+ })}
9311
10088
  `}
9312
10089
  ` : ""}
9313
10090
  </div>
@@ -9349,6 +10126,10 @@ let JupiterDynamicForm = class extends LitElement {
9349
10126
  .locale="${config.locale || "en-US"}"
9350
10127
  .isFirstSection="${true}"
9351
10128
  .availableDimensions="${this._getAvailableDimensionsForSection(activeSection.id)}"
10129
+ .mode="${this.mode}"
10130
+ .masterData="${this.masterData}"
10131
+ .periodStartDate="${this.periodStartDate}"
10132
+ .periodEndDate="${this.periodEndDate}"
9352
10133
  @field-change="${this._handleFieldChange}"
9353
10134
  @typed-member-change="${this._handleTypedMemberChange}"
9354
10135
  @section-expand="${this._handleSectionExpand}"
@@ -9510,6 +10291,27 @@ let JupiterDynamicForm = class extends LitElement {
9510
10291
  </div>
9511
10292
  </div>
9512
10293
  ` : ""}
10294
+
10295
+ <!-- Role Context Menu -->
10296
+ ${this._showRoleContextMenu ? html`
10297
+ <div
10298
+ class="role-context-menu"
10299
+ style="left: ${this._contextMenuX}px; top: ${this._contextMenuY}px;"
10300
+ @click="${(e2) => {
10301
+ e2.stopPropagation();
10302
+ }}"
10303
+ >
10304
+ <div
10305
+ class="context-menu-item danger"
10306
+ @click="${() => this._handleRemoveRole()}"
10307
+ >
10308
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="currentColor">
10309
+ <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/>
10310
+ </svg>
10311
+ Remove
10312
+ </div>
10313
+ </div>
10314
+ ` : ""}
9513
10315
  </div>
9514
10316
  `;
9515
10317
  }
@@ -9866,6 +10668,30 @@ JupiterDynamicForm.styles = css`
9866
10668
  font-weight: 500;
9867
10669
  }
9868
10670
 
10671
+ .side-panel-role-item.has-errors {
10672
+ border-left: 2px solid var(--jupiter-error-color, #d32f2f);
10673
+ }
10674
+
10675
+ .side-panel-role-item.has-errors.active {
10676
+ border-left: 2px solid var(--jupiter-error-color, #d32f2f);
10677
+ }
10678
+
10679
+ .side-panel-role-item.has-empty-fields {
10680
+ border-left: 2px solid var(--jupiter-warning-color, #ff9800);
10681
+ }
10682
+
10683
+ .side-panel-role-item.has-empty-fields.active {
10684
+ border-left: 2px solid var(--jupiter-warning-color, #ff9800);
10685
+ }
10686
+
10687
+ .side-panel-role-item.has-complete-data {
10688
+ border-left: 2px solid var(--jupiter-success-color, #4caf50);
10689
+ }
10690
+
10691
+ .side-panel-role-item.has-complete-data.active {
10692
+ border-left: 2px solid var(--jupiter-success-color, #4caf50);
10693
+ }
10694
+
9869
10695
  .side-panel-content {
9870
10696
  flex: 1;
9871
10697
  overflow-y: auto;
@@ -10159,6 +10985,41 @@ JupiterDynamicForm.styles = css`
10159
10985
  color: #0052a3;
10160
10986
  text-decoration: none;
10161
10987
  }
10988
+
10989
+ /* Context Menu Styles */
10990
+ .role-context-menu {
10991
+ position: fixed;
10992
+ background: white;
10993
+ border: 1px solid var(--jupiter-border-color, #ddd);
10994
+ border-radius: 4px;
10995
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
10996
+ z-index: 10001;
10997
+ min-width: 150px;
10998
+ padding: 4px 0;
10999
+ }
11000
+
11001
+ .context-menu-item {
11002
+ padding: 8px 16px;
11003
+ cursor: pointer;
11004
+ font-size: 14px;
11005
+ color: var(--jupiter-text-primary, #333);
11006
+ transition: background-color 0.2s ease;
11007
+ display: flex;
11008
+ align-items: center;
11009
+ gap: 8px;
11010
+ }
11011
+
11012
+ .context-menu-item:hover {
11013
+ background: var(--jupiter-hover-background, #f5f5f5);
11014
+ }
11015
+
11016
+ .context-menu-item.danger {
11017
+ color: var(--jupiter-error-color, #d32f2f);
11018
+ }
11019
+
11020
+ .context-menu-item.danger:hover {
11021
+ background: #ffebee;
11022
+ }
10162
11023
  `;
10163
11024
  __decorateClass([
10164
11025
  n2({ type: Object })
@@ -10202,6 +11063,9 @@ __decorateClass([
10202
11063
  __decorateClass([
10203
11064
  n2({ type: Array })
10204
11065
  ], JupiterDynamicForm.prototype, "defaultUnits", 2);
11066
+ __decorateClass([
11067
+ n2({ type: Object, attribute: "master-data" })
11068
+ ], JupiterDynamicForm.prototype, "masterData", 2);
10205
11069
  __decorateClass([
10206
11070
  n2({ type: Object, attribute: "dynaforms-metadata" })
10207
11071
  ], JupiterDynamicForm.prototype, "dynaformsMetadata", 2);
@@ -10289,11 +11153,27 @@ __decorateClass([
10289
11153
  __decorateClass([
10290
11154
  r()
10291
11155
  ], JupiterDynamicForm.prototype, "_adminRoleConfigs", 2);
11156
+ __decorateClass([
11157
+ r()
11158
+ ], JupiterDynamicForm.prototype, "_roleBorderStatuses", 2);
11159
+ __decorateClass([
11160
+ r()
11161
+ ], JupiterDynamicForm.prototype, "_showRoleContextMenu", 2);
11162
+ __decorateClass([
11163
+ r()
11164
+ ], JupiterDynamicForm.prototype, "_contextMenuX", 2);
11165
+ __decorateClass([
11166
+ r()
11167
+ ], JupiterDynamicForm.prototype, "_contextMenuY", 2);
11168
+ __decorateClass([
11169
+ r()
11170
+ ], JupiterDynamicForm.prototype, "_contextMenuRoleId", 2);
10292
11171
  JupiterDynamicForm = __decorateClass([
10293
11172
  t$1("jupiter-dynamic-form")
10294
11173
  ], JupiterDynamicForm);
10295
11174
  const version = "1.5.0";
10296
11175
  export {
11176
+ FactMatcher,
10297
11177
  FormValidator,
10298
11178
  JupiterAddColumnDialog,
10299
11179
  JupiterConceptTree,