jupiter-dynamic-forms 1.7.3 → 1.8.1

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
@@ -2701,16 +2701,34 @@ let JupiterFormSection = class extends LitElement {
2701
2701
  this.disabled = false;
2702
2702
  this.collapsible = true;
2703
2703
  this.locale = "en-US";
2704
+ this.isFirstSection = false;
2704
2705
  this.availableDimensions = [];
2705
2706
  this._expanded = true;
2706
2707
  this._showAddColumnDialog = false;
2707
2708
  this._sectionPeriodType = "duration";
2708
2709
  this._expandedConcepts = /* @__PURE__ */ new Set();
2710
+ this._allTreeExpanded = false;
2709
2711
  }
2710
2712
  connectedCallback() {
2711
2713
  super.connectedCallback();
2712
2714
  this._expanded = this.section.expanded !== false;
2713
2715
  this._determinePeriodType();
2716
+ this._checkAndExpandFirstSection();
2717
+ }
2718
+ updated(changedProperties) {
2719
+ super.updated(changedProperties);
2720
+ if (changedProperties.has("isFirstSection") || changedProperties.has("section")) {
2721
+ this._checkAndExpandFirstSection();
2722
+ }
2723
+ }
2724
+ _checkAndExpandFirstSection() {
2725
+ if (this.isFirstSection && this.section && this.section.concepts) {
2726
+ this._expanded = true;
2727
+ setTimeout(() => {
2728
+ this._expandAllTrees();
2729
+ console.log("🎯 First section detected - expanded section and tree by default");
2730
+ }, 0);
2731
+ }
2714
2732
  }
2715
2733
  _determinePeriodType() {
2716
2734
  const nonAbstractConcepts = this._getAllNonAbstractConcepts(this.section.concepts);
@@ -2843,6 +2861,50 @@ let JupiterFormSection = class extends LitElement {
2843
2861
  }
2844
2862
  return result;
2845
2863
  }
2864
+ _getAllConceptIds(concepts) {
2865
+ const result = [];
2866
+ for (const concept of concepts) {
2867
+ if (concept.children && concept.children.length > 0) {
2868
+ result.push(concept.id);
2869
+ result.push(...this._getAllConceptIds(concept.children));
2870
+ }
2871
+ }
2872
+ return result;
2873
+ }
2874
+ _expandAllTrees() {
2875
+ const allConceptIds = this._getAllConceptIds(this.section.concepts || []);
2876
+ allConceptIds.forEach((id) => this._expandedConcepts.add(id));
2877
+ this._allTreeExpanded = true;
2878
+ this.requestUpdate();
2879
+ }
2880
+ _collapseAllTrees() {
2881
+ this._expandedConcepts.clear();
2882
+ this._allTreeExpanded = false;
2883
+ this.requestUpdate();
2884
+ }
2885
+ _toggleAllTrees(event) {
2886
+ event.stopPropagation();
2887
+ if (!this._expanded) {
2888
+ this._expanded = true;
2889
+ }
2890
+ if (this._allTreeExpanded) {
2891
+ this._collapseAllTrees();
2892
+ } else {
2893
+ this._expandAllTrees();
2894
+ }
2895
+ }
2896
+ _handleTreeCheckboxChange(event) {
2897
+ event.stopPropagation();
2898
+ const checkbox = event.target;
2899
+ if (!this._expanded) {
2900
+ this._expanded = true;
2901
+ }
2902
+ if (checkbox.checked) {
2903
+ this._expandAllTrees();
2904
+ } else {
2905
+ this._collapseAllTrees();
2906
+ }
2907
+ }
2846
2908
  _handleConceptExpand(event) {
2847
2909
  event.stopPropagation();
2848
2910
  const { conceptId, expanded } = event.detail;
@@ -2851,6 +2913,8 @@ let JupiterFormSection = class extends LitElement {
2851
2913
  } else {
2852
2914
  this._expandedConcepts.delete(conceptId);
2853
2915
  }
2916
+ const allConceptIds = this._getAllConceptIds(this.section.concepts || []);
2917
+ this._allTreeExpanded = allConceptIds.length > 0 && allConceptIds.every((id) => this._expandedConcepts.has(id));
2854
2918
  this.requestUpdate();
2855
2919
  this.dispatchEvent(new CustomEvent("concept-expand", {
2856
2920
  detail: event.detail,
@@ -2885,8 +2949,10 @@ let JupiterFormSection = class extends LitElement {
2885
2949
  <p class="section-description">${this.section.description}</p>
2886
2950
  ` : ""}
2887
2951
  </div>
2888
- <div class="section-toggle ${this.collapsible ? this._expanded ? "expanded" : "" : "hidden"}">
2889
- ${this.collapsible ? "" : ""}
2952
+ <div class="section-header-controls">
2953
+ <div class="section-toggle ${this.collapsible ? this._expanded ? "expanded" : "" : "hidden"}">
2954
+ ${this.collapsible ? "▶" : ""}
2955
+ </div>
2890
2956
  </div>
2891
2957
  </div>
2892
2958
 
@@ -2906,8 +2972,19 @@ let JupiterFormSection = class extends LitElement {
2906
2972
  <p class="section-description">${this.section.description}</p>
2907
2973
  ` : ""}
2908
2974
  </div>
2909
- <div class="section-toggle ${this.collapsible ? this._expanded ? "expanded" : "" : "hidden"}">
2910
- ${this.collapsible ? "" : ""}
2975
+ <div class="section-header-controls">
2976
+ <div class="tree-control">
2977
+ <input
2978
+ type="checkbox"
2979
+ class="tree-control-checkbox"
2980
+ .checked="${this._allTreeExpanded}"
2981
+ @change="${this._handleTreeCheckboxChange}"
2982
+ />
2983
+ <span class="tree-control-label" @click="${this._toggleAllTrees}">${this._allTreeExpanded ? "Collapse Tree" : "Expand Tree"}</span>
2984
+ </div>
2985
+ <div class="section-toggle ${this.collapsible ? this._expanded ? "expanded" : "" : "hidden"}">
2986
+ ${this.collapsible ? "▶" : ""}
2987
+ </div>
2911
2988
  </div>
2912
2989
  </div>
2913
2990
 
@@ -3063,6 +3140,43 @@ JupiterFormSection.styles = css`
3063
3140
  visibility: hidden;
3064
3141
  }
3065
3142
 
3143
+ .section-header-controls {
3144
+ display: flex;
3145
+ align-items: center;
3146
+ gap: 12px;
3147
+ }
3148
+
3149
+ .tree-control {
3150
+ display: flex;
3151
+ align-items: center;
3152
+ gap: 6px;
3153
+ font-size: 12px;
3154
+ color: var(--jupiter-text-secondary, #666);
3155
+ background: var(--jupiter-button-background, #fff);
3156
+ border: 1px solid var(--jupiter-border-color, #ddd);
3157
+ border-radius: 4px;
3158
+ padding: 4px 8px;
3159
+ cursor: pointer;
3160
+ transition: all 0.2s ease;
3161
+ }
3162
+
3163
+ .tree-control:hover {
3164
+ background: var(--jupiter-button-hover-background, #f5f5f5);
3165
+ border-color: var(--jupiter-primary-color, #007bff);
3166
+ }
3167
+
3168
+ .tree-control-checkbox {
3169
+ width: 14px;
3170
+ height: 14px;
3171
+ cursor: pointer;
3172
+ }
3173
+
3174
+ .tree-control-label {
3175
+ cursor: pointer;
3176
+ font-weight: 500;
3177
+ white-space: nowrap;
3178
+ }
3179
+
3066
3180
  .section-content {
3067
3181
  display: block;
3068
3182
  transition: max-height 0.3s ease;
@@ -3242,6 +3356,9 @@ __decorateClass$2([
3242
3356
  __decorateClass$2([
3243
3357
  n2({ type: String })
3244
3358
  ], JupiterFormSection.prototype, "locale", 2);
3359
+ __decorateClass$2([
3360
+ n2({ type: Boolean })
3361
+ ], JupiterFormSection.prototype, "isFirstSection", 2);
3245
3362
  __decorateClass$2([
3246
3363
  n2({ type: Array })
3247
3364
  ], JupiterFormSection.prototype, "availableDimensions", 2);
@@ -3257,6 +3374,9 @@ __decorateClass$2([
3257
3374
  __decorateClass$2([
3258
3375
  r()
3259
3376
  ], JupiterFormSection.prototype, "_expandedConcepts", 2);
3377
+ __decorateClass$2([
3378
+ r()
3379
+ ], JupiterFormSection.prototype, "_allTreeExpanded", 2);
3260
3380
  JupiterFormSection = __decorateClass$2([
3261
3381
  t$1("jupiter-form-section")
3262
3382
  ], JupiterFormSection);
@@ -3511,12 +3631,6 @@ let JupiterFilterRolesDialog = class extends LitElement {
3511
3631
  />
3512
3632
  <div class="role-info">
3513
3633
  <h4 class="role-title">${role.title}</h4>
3514
- ${role.description ? html`
3515
- <p class="role-description">${role.description}</p>
3516
- ` : ""}
3517
- ${role.id !== role.title ? html`
3518
- <p class="role-description">ID: ${role.id}</p>
3519
- ` : ""}
3520
3634
  ${((_a = role.metadata) == null ? void 0 : _a.roleURI) ? html`
3521
3635
  <p class="role-description">URI: ${role.metadata.roleURI}</p>
3522
3636
  ` : ""}
@@ -3917,10 +4031,17 @@ let JupiterDynamicForm = class extends LitElement {
3917
4031
  );
3918
4032
  console.log("✅ Generated schema with sections:", this._currentSchema.sections.length);
3919
4033
  this._allSections = [...this._currentSchema.sections];
3920
- if (this._allSections.length > 10 && this._selectedRoleIds.length === 0) {
3921
- this._selectedRoleIds = this._allSections.slice(0, 10).map((section) => section.id);
3922
- } else if (this._selectedRoleIds.length === 0) {
3923
- this._selectedRoleIds = this._allSections.map((section) => section.id);
4034
+ if (this._selectedRoleIds.length === 0) {
4035
+ if (this._allSections.length > 10) {
4036
+ this._selectedRoleIds = [];
4037
+ this._showFilterDialog = true;
4038
+ this._currentSchema = {
4039
+ ...this._currentSchema,
4040
+ sections: []
4041
+ };
4042
+ } else {
4043
+ this._selectedRoleIds = this._allSections.map((section) => section.id);
4044
+ }
3924
4045
  }
3925
4046
  this._applyRoleFilter();
3926
4047
  this._columns = [
@@ -3981,6 +4102,15 @@ let JupiterDynamicForm = class extends LitElement {
3981
4102
  _applyRoleFilter() {
3982
4103
  if (!this._currentSchema || !this._allSections.length)
3983
4104
  return;
4105
+ console.log(`🔍 Applying role filter: ${this._selectedRoleIds.length} selected out of ${this._allSections.length} total`);
4106
+ if (this._selectedRoleIds.length === 0) {
4107
+ console.log(`📝 No roles selected - showing empty form`);
4108
+ this._currentSchema = {
4109
+ ...this._currentSchema,
4110
+ sections: []
4111
+ };
4112
+ return;
4113
+ }
3984
4114
  this._preserveDataForHiddenSections();
3985
4115
  const filteredSections = this._allSections.filter(
3986
4116
  (section) => this._selectedRoleIds.includes(section.id)
@@ -4063,12 +4193,14 @@ let JupiterDynamicForm = class extends LitElement {
4063
4193
  }
4064
4194
  _handleFilterDialogCancel() {
4065
4195
  this._showFilterDialog = false;
4196
+ console.log(`🚫 Filter dialog cancelled. Current selection: ${this._selectedRoleIds.length}/${this._allSections.length}`);
4066
4197
  }
4067
4198
  _handleRoleFilterApply(event) {
4068
4199
  const { selectedRoleIds } = event.detail;
4069
4200
  this._selectedRoleIds = selectedRoleIds;
4070
4201
  this._applyRoleFilter();
4071
4202
  this._showFilterDialog = false;
4203
+ console.log(`🎯 Applied role filter: ${selectedRoleIds.length}/${this._allSections.length} roles selected`);
4072
4204
  this.dispatchEvent(new CustomEvent("roles-filter-changed", {
4073
4205
  detail: {
4074
4206
  selectedRoleIds,
@@ -4907,8 +5039,14 @@ let JupiterDynamicForm = class extends LitElement {
4907
5039
  </div>
4908
5040
  ` : ""}
4909
5041
 
4910
- <!-- Form Sections -->
4911
- ${schema.sections.map((section) => html`
5042
+ <!-- Form Sections or No Selection Message -->
5043
+ ${schema.sections.length === 0 && this._allSections.length > 10 ? html`
5044
+ <div class="no-roles-message">
5045
+ <h3>No Roles Selected</h3>
5046
+ <p>Please use the "Filter Roles" button below to select which sections you want to work with.</p>
5047
+ <p>Available roles: ${this._allSections.length}</p>
5048
+ </div>
5049
+ ` : schema.sections.map((section, index) => html`
4912
5050
  <jupiter-form-section
4913
5051
  .section="${section}"
4914
5052
  .columns="${section.columns || this._columns}"
@@ -4917,6 +5055,7 @@ let JupiterDynamicForm = class extends LitElement {
4917
5055
  .disabled="${this.disabled || this.readonly}"
4918
5056
  .collapsible="${config.collapsibleSections !== false}"
4919
5057
  .locale="${config.locale || "en-US"}"
5058
+ .isFirstSection="${index === 0}"
4920
5059
  .availableDimensions="${this._getAvailableDimensionsForSection(section.id)}"
4921
5060
  @field-change="${this._handleFieldChange}"
4922
5061
  @typed-member-change="${this._handleTypedMemberChange}"
@@ -4940,7 +5079,7 @@ let JupiterDynamicForm = class extends LitElement {
4940
5079
  <svg class="filter-icon" viewBox="0 0 24 24">
4941
5080
  <path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z"/>
4942
5081
  </svg>
4943
- Filter Roles
5082
+ ${this._selectedRoleIds.length === 0 ? "Select Roles" : "Filter Roles"}
4944
5083
  <span class="roles-count">${this._selectedRoleIds.length}/${this._allSections.length}</span>
4945
5084
  </button>
4946
5085
  ` : ""}
@@ -5154,6 +5293,25 @@ JupiterDynamicForm.styles = css`
5154
5293
  min-width: 18px;
5155
5294
  justify-content: center;
5156
5295
  }
5296
+
5297
+ .no-roles-message {
5298
+ padding: 40px;
5299
+ text-align: center;
5300
+ color: var(--jupiter-text-secondary, #666);
5301
+ background: var(--jupiter-background-light, #f8f9fa);
5302
+ border-radius: 8px;
5303
+ margin: 20px 0;
5304
+ }
5305
+
5306
+ .no-roles-message h3 {
5307
+ margin: 0 0 16px 0;
5308
+ color: var(--jupiter-text-primary, #333);
5309
+ }
5310
+
5311
+ .no-roles-message p {
5312
+ margin: 8px 0;
5313
+ line-height: 1.5;
5314
+ }
5157
5315
  `;
5158
5316
  __decorateClass([
5159
5317
  n2({ type: Object })