jupiter-dynamic-forms 1.14.4 → 1.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -587,10 +587,7 @@ class XBRLFormBuilder {
587
587
  const hypercubeData = (_a = xbrlInput.hypercubes) == null ? void 0 : _a[0];
588
588
  const datatypes = Array.isArray(xbrlInput.datatypes) ? xbrlInput.datatypes : ((_b = xbrlInput.datatypes) == null ? void 0 : _b.concepts) || [];
589
589
  const sections = [];
590
- const sortedRoles = [...presentationData.roles].sort((a2, b2) => {
591
- return a2.role.localeCompare(b2.role);
592
- });
593
- sortedRoles.forEach((role) => {
590
+ presentationData.roles.forEach((role) => {
594
591
  const section2 = this.buildSectionFromRole(role, periodStartDate, periodEndDate, hypercubeData, language, periodPreferences);
595
592
  if (datatypes && datatypes.length > 0) {
596
593
  section2.datatypes = datatypes;
@@ -5152,9 +5149,7 @@ let JupiterFilterRolesDialog = class extends LitElement {
5152
5149
  }
5153
5150
  _updateFilteredRoles() {
5154
5151
  if (!this._searchQuery.trim()) {
5155
- this._filteredRoles = [...this.availableRoles].sort((a2, b2) => {
5156
- return a2.title.localeCompare(b2.title);
5157
- });
5152
+ this._filteredRoles = [...this.availableRoles];
5158
5153
  return;
5159
5154
  }
5160
5155
  const query = this._searchQuery.toLowerCase().trim();
@@ -5166,9 +5161,7 @@ let JupiterFilterRolesDialog = class extends LitElement {
5166
5161
  const uriMatch = this._searchInRoleURI(role, query);
5167
5162
  return titleMatch || idMatch || descriptionMatch || uriMatch;
5168
5163
  });
5169
- this._filteredRoles = filtered.sort((a2, b2) => {
5170
- return a2.title.localeCompare(b2.title);
5171
- });
5164
+ this._filteredRoles = filtered;
5172
5165
  }
5173
5166
  _searchInRoleURI(role, query) {
5174
5167
  var _a;
@@ -6774,6 +6767,20 @@ let JupiterDynamicForm = class extends LitElement {
6774
6767
  );
6775
6768
  console.log("✅ Generated schema with sections:", this._currentSchema.sections.length);
6776
6769
  this._allSections = [...this._currentSchema.sections];
6770
+ if (Array.isArray(this._selectedRoleIds) && this._selectedRoleIds.length > 0 && typeof this._selectedRoleIds[0] === "object") {
6771
+ console.log("🔄 Applying custom role order to _allSections from _selectedRoleIds");
6772
+ const enhancedRoles = this._selectedRoleIds;
6773
+ const orderMap = /* @__PURE__ */ new Map();
6774
+ enhancedRoles.forEach((role) => {
6775
+ orderMap.set(role.roleId, role.order);
6776
+ });
6777
+ this._allSections = [...this._allSections].sort((a2, b2) => {
6778
+ const orderA = orderMap.get(a2.id) ?? 999;
6779
+ const orderB = orderMap.get(b2.id) ?? 999;
6780
+ return orderA - orderB;
6781
+ });
6782
+ console.log("✅ Custom order applied to _allSections:", this._allSections.map((s2) => s2.title));
6783
+ }
6777
6784
  if (this.financialStatementsTypeAxis && this.financialStatementsTypeAxis.length > 0) {
6778
6785
  console.log("🔍 Applying financialStatementsTypeAxis filter:", this.financialStatementsTypeAxis);
6779
6786
  console.log("📊 Sections before filter:", this._allSections.length);
@@ -8827,7 +8834,7 @@ let JupiterDynamicForm = class extends LitElement {
8827
8834
  });
8828
8835
  }
8829
8836
  _renderAdminModeContent(section2) {
8830
- var _a;
8837
+ var _a, _b;
8831
8838
  if (!section2) {
8832
8839
  return html`
8833
8840
  <div class="admin-mode-container">
@@ -8836,6 +8843,34 @@ let JupiterDynamicForm = class extends LitElement {
8836
8843
  `;
8837
8844
  }
8838
8845
  const showPreviousYearChecked = ((_a = this._periodPreferences[section2.id]) == null ? void 0 : _a.showPreviousYear) ?? section2.showPreviousYear ?? false;
8846
+ const dimensions = this._getDimensionsForRole(section2.id);
8847
+ const hasDimensions = dimensions.length > 0;
8848
+ if (hasDimensions && !((_b = this._periodPreferences[section2.id]) == null ? void 0 : _b.dimensionSelections)) {
8849
+ const currentPref = this._periodPreferences[section2.id] || {
8850
+ showDuration: true,
8851
+ showInstant: true,
8852
+ showPreviousYear: false
8853
+ };
8854
+ currentPref.dimensionSelections = [];
8855
+ dimensions.forEach((dimension) => {
8856
+ var _a2, _b2;
8857
+ const allMembers = this._getAllDimensionMembers(dimension.members);
8858
+ const allMemberIds = allMembers.map((m) => m.id);
8859
+ const dimensionLabel = ((_b2 = (_a2 = dimension.labels) == null ? void 0 : _a2.find((l2) => l2.role === "http://www.xbrl.org/2003/role/label")) == null ? void 0 : _b2.label) || dimension.conceptName;
8860
+ if (currentPref.dimensionSelections) {
8861
+ currentPref.dimensionSelections.push({
8862
+ dimensionId: dimension.id,
8863
+ dimensionLabel,
8864
+ selectedMemberIds: allMemberIds
8865
+ });
8866
+ }
8867
+ });
8868
+ this._periodPreferences = {
8869
+ ...this._periodPreferences,
8870
+ [section2.id]: currentPref
8871
+ };
8872
+ console.log("✅ [Admin Mode] Initialized all dimension members as selected by default for role:", section2.id);
8873
+ }
8839
8874
  return html`
8840
8875
  <div class="admin-mode-container">
8841
8876
  <h2 class="admin-mode-title">Role Configuration: ${section2.title}</h2>
@@ -8851,6 +8886,58 @@ let JupiterDynamicForm = class extends LitElement {
8851
8886
  <label for="admin-prev-year-${section2.id}">Show Previous Year Column</label>
8852
8887
  </div>
8853
8888
  </div>
8889
+
8890
+ ${hasDimensions ? html`
8891
+ <div class="admin-dimension-section">
8892
+ <div class="admin-dimension-header">📊 ${I18n.t("filter.dimensionMemberSelection")}</div>
8893
+ ${dimensions.map((dimension) => {
8894
+ var _a2, _b2;
8895
+ const allMembers = this._getAllDimensionMembers(dimension.members);
8896
+ const dimensionLabel = ((_b2 = (_a2 = dimension.labels) == null ? void 0 : _a2.find((l2) => l2.role === "http://www.xbrl.org/2003/role/label")) == null ? void 0 : _b2.label) || dimension.conceptName;
8897
+ const isSingleMember = this._isSingleMemberDimension(dimension);
8898
+ return html`
8899
+ <div class="admin-dimension-group">
8900
+ <div class="admin-dimension-label">${dimensionLabel}${isSingleMember ? " (Mandatory)" : ""}</div>
8901
+ <div class="admin-dimension-members">
8902
+ ${allMembers.map((member) => {
8903
+ var _a3, _b3;
8904
+ const memberLabel = ((_b3 = (_a3 = member.labels) == null ? void 0 : _a3.find((l2) => l2.role === "http://www.xbrl.org/2003/role/label")) == null ? void 0 : _b3.label) || member.conceptName;
8905
+ const isChecked = this._isAdminDimensionMemberSelected(section2.id, dimension.id, member.id);
8906
+ return html`
8907
+ <label class="admin-member-checkbox-item">
8908
+ <input
8909
+ type="checkbox"
8910
+ class="admin-member-checkbox"
8911
+ .checked="${isChecked}"
8912
+ ?disabled="${isSingleMember}"
8913
+ @change="${(e2) => this._handleAdminDimensionMemberChange(e2, section2.id, dimension.id, member.id)}"
8914
+ />
8915
+ <span class="admin-member-checkbox-label">${memberLabel}</span>
8916
+ </label>
8917
+ `;
8918
+ })}
8919
+ </div>
8920
+ ${!isSingleMember ? html`
8921
+ <div class="admin-member-select-controls">
8922
+ <button
8923
+ class="admin-member-select-btn"
8924
+ @click="${() => this._selectAllAdminDimensionMembers(section2.id, dimension.id)}"
8925
+ >
8926
+ ${I18n.t("filter.selectAllMembers")}
8927
+ </button>
8928
+ <button
8929
+ class="admin-member-select-btn"
8930
+ @click="${() => this._deselectAllAdminDimensionMembers(section2.id, dimension.id)}"
8931
+ >
8932
+ ${I18n.t("filter.clearMembers")}
8933
+ </button>
8934
+ </div>
8935
+ ` : ""}
8936
+ </div>
8937
+ `;
8938
+ })}
8939
+ </div>
8940
+ ` : ""}
8854
8941
  </div>
8855
8942
  </div>
8856
8943
  `;
@@ -8879,6 +8966,178 @@ let JupiterDynamicForm = class extends LitElement {
8879
8966
  console.log(`✅ [Admin Mode] Updated ${field2} = ${checked} for role ${roleId}`);
8880
8967
  console.log(`📋 [Admin Mode] _periodPreferences now includes:`, this._periodPreferences[roleId]);
8881
8968
  }
8969
+ /**
8970
+ * Get dimensions for a specific role from hypercube data
8971
+ */
8972
+ _getDimensionsForRole(roleId) {
8973
+ var _a, _b, _c, _d;
8974
+ if (!((_b = (_a = this.xbrlInput) == null ? void 0 : _a.hypercubes) == null ? void 0 : _b[0])) {
8975
+ return [];
8976
+ }
8977
+ const hypercubeRole = (_c = this.xbrlInput.hypercubes[0].roles) == null ? void 0 : _c.find((r2) => r2.roleId === roleId);
8978
+ if (!((_d = hypercubeRole == null ? void 0 : hypercubeRole.items) == null ? void 0 : _d.length)) {
8979
+ return [];
8980
+ }
8981
+ const dimensionsMap = /* @__PURE__ */ new Map();
8982
+ hypercubeRole.items.forEach((item) => {
8983
+ if (item.dimensions) {
8984
+ item.dimensions.forEach((dimension) => {
8985
+ if (!dimensionsMap.has(dimension.id)) {
8986
+ dimensionsMap.set(dimension.id, dimension);
8987
+ }
8988
+ });
8989
+ }
8990
+ });
8991
+ return Array.from(dimensionsMap.values());
8992
+ }
8993
+ /**
8994
+ * Get all dimension members recursively
8995
+ */
8996
+ _getAllDimensionMembers(members) {
8997
+ if (!members || members.length === 0) {
8998
+ return [];
8999
+ }
9000
+ let allMembers = [];
9001
+ members.forEach((member) => {
9002
+ allMembers.push(member);
9003
+ if (member.children && member.children.length > 0) {
9004
+ allMembers = allMembers.concat(this._getAllDimensionMembers(member.children));
9005
+ }
9006
+ });
9007
+ return allMembers;
9008
+ }
9009
+ /**
9010
+ * Check if a dimension has only one member (single choice, mandatory)
9011
+ */
9012
+ _isSingleMemberDimension(dimension) {
9013
+ if (!dimension || !dimension.members) {
9014
+ return false;
9015
+ }
9016
+ const allMembers = this._getAllDimensionMembers(dimension.members);
9017
+ return allMembers.length === 1;
9018
+ }
9019
+ /**
9020
+ * Handle dimension member selection in admin mode
9021
+ */
9022
+ _handleAdminDimensionMemberChange(event, roleId, dimensionId, memberId) {
9023
+ var _a, _b;
9024
+ event.stopPropagation();
9025
+ const checkbox = event.target;
9026
+ const currentPref = this._periodPreferences[roleId] || {
9027
+ showDuration: true,
9028
+ showInstant: true,
9029
+ showPreviousYear: false,
9030
+ dimensionSelections: []
9031
+ };
9032
+ if (!currentPref.dimensionSelections) {
9033
+ currentPref.dimensionSelections = [];
9034
+ }
9035
+ let dimensionSelection = currentPref.dimensionSelections.find(
9036
+ (ds) => ds.dimensionId === dimensionId
9037
+ );
9038
+ if (!dimensionSelection) {
9039
+ const dimensions = this._getDimensionsForRole(roleId);
9040
+ const dimension = dimensions.find((d2) => d2.id === dimensionId);
9041
+ const dimensionLabel = ((_b = (_a = dimension == null ? void 0 : dimension.labels) == null ? void 0 : _a.find((l2) => l2.role === "http://www.xbrl.org/2003/role/label")) == null ? void 0 : _b.label) || dimensionId;
9042
+ dimensionSelection = {
9043
+ dimensionId,
9044
+ dimensionLabel,
9045
+ selectedMemberIds: []
9046
+ };
9047
+ currentPref.dimensionSelections.push(dimensionSelection);
9048
+ }
9049
+ if (checkbox.checked) {
9050
+ if (!dimensionSelection.selectedMemberIds.includes(memberId)) {
9051
+ dimensionSelection.selectedMemberIds.push(memberId);
9052
+ }
9053
+ } else {
9054
+ dimensionSelection.selectedMemberIds = dimensionSelection.selectedMemberIds.filter(
9055
+ (id) => id !== memberId
9056
+ );
9057
+ }
9058
+ this._periodPreferences = {
9059
+ ...this._periodPreferences,
9060
+ [roleId]: currentPref
9061
+ };
9062
+ console.log("📊 [Admin Mode] Updated dimension selections:", this._periodPreferences[roleId].dimensionSelections);
9063
+ this.requestUpdate();
9064
+ }
9065
+ /**
9066
+ * Check if a dimension member is selected in admin mode
9067
+ * Returns true by default if no explicit preference exists (all members checked by default)
9068
+ */
9069
+ _isAdminDimensionMemberSelected(roleId, dimensionId, memberId) {
9070
+ const preferences = this._periodPreferences[roleId];
9071
+ if (!(preferences == null ? void 0 : preferences.dimensionSelections)) {
9072
+ return true;
9073
+ }
9074
+ const dimensionSelection = preferences.dimensionSelections.find(
9075
+ (ds) => ds.dimensionId === dimensionId
9076
+ );
9077
+ if (!dimensionSelection) {
9078
+ return true;
9079
+ }
9080
+ return dimensionSelection.selectedMemberIds.includes(memberId);
9081
+ }
9082
+ /**
9083
+ * Select all members for a dimension in admin mode
9084
+ */
9085
+ _selectAllAdminDimensionMembers(roleId, dimensionId) {
9086
+ var _a, _b;
9087
+ const dimensions = this._getDimensionsForRole(roleId);
9088
+ const dimension = dimensions.find((d2) => d2.id === dimensionId);
9089
+ if (!dimension)
9090
+ return;
9091
+ const allMembers = this._getAllDimensionMembers(dimension.members);
9092
+ const allMemberIds = allMembers.map((m) => m.id);
9093
+ const currentPref = this._periodPreferences[roleId] || {
9094
+ showDuration: true,
9095
+ showInstant: true,
9096
+ showPreviousYear: false,
9097
+ dimensionSelections: []
9098
+ };
9099
+ if (!currentPref.dimensionSelections) {
9100
+ currentPref.dimensionSelections = [];
9101
+ }
9102
+ let dimensionSelection = currentPref.dimensionSelections.find(
9103
+ (ds) => ds.dimensionId === dimensionId
9104
+ );
9105
+ if (!dimensionSelection) {
9106
+ const dimensionLabel = ((_b = (_a = dimension.labels) == null ? void 0 : _a.find((l2) => l2.role === "http://www.xbrl.org/2003/role/label")) == null ? void 0 : _b.label) || dimensionId;
9107
+ dimensionSelection = {
9108
+ dimensionId,
9109
+ dimensionLabel,
9110
+ selectedMemberIds: []
9111
+ };
9112
+ currentPref.dimensionSelections.push(dimensionSelection);
9113
+ }
9114
+ dimensionSelection.selectedMemberIds = allMemberIds;
9115
+ this._periodPreferences = {
9116
+ ...this._periodPreferences,
9117
+ [roleId]: currentPref
9118
+ };
9119
+ this.requestUpdate();
9120
+ }
9121
+ /**
9122
+ * Deselect all members for a dimension in admin mode
9123
+ */
9124
+ _deselectAllAdminDimensionMembers(roleId, dimensionId) {
9125
+ const currentPref = this._periodPreferences[roleId];
9126
+ if (!(currentPref == null ? void 0 : currentPref.dimensionSelections)) {
9127
+ return;
9128
+ }
9129
+ const dimensionSelection = currentPref.dimensionSelections.find(
9130
+ (ds) => ds.dimensionId === dimensionId
9131
+ );
9132
+ if (dimensionSelection) {
9133
+ dimensionSelection.selectedMemberIds = [];
9134
+ }
9135
+ this._periodPreferences = {
9136
+ ...this._periodPreferences,
9137
+ [roleId]: currentPref
9138
+ };
9139
+ this.requestUpdate();
9140
+ }
8882
9141
  _handleAdminModeSubmit() {
8883
9142
  var _a, _b, _c, _d;
8884
9143
  if (!((_c = (_b = (_a = this.xbrlInput) == null ? void 0 : _a.presentation) == null ? void 0 : _b[0]) == null ? void 0 : _c.roles)) {
@@ -9184,7 +9443,7 @@ let JupiterDynamicForm = class extends LitElement {
9184
9443
  @click="${this._handleSubmit}"
9185
9444
  ?disabled="${this.disabled || this.readonly}"
9186
9445
  >
9187
- ${I18n.t("form.submit")}
9446
+ ${this.submitButtonLabel || I18n.t("form.submit")}
9188
9447
  </button>
9189
9448
 
9190
9449
 
@@ -9685,6 +9944,100 @@ JupiterDynamicForm.styles = css`
9685
9944
  user-select: none;
9686
9945
  }
9687
9946
 
9947
+ .admin-dimension-section {
9948
+ margin-top: 16px;
9949
+ padding: 16px;
9950
+ background: var(--jupiter-background, #fff);
9951
+ border: 1px solid var(--jupiter-border-color, #ddd);
9952
+ border-radius: 6px;
9953
+ }
9954
+
9955
+ .admin-dimension-header {
9956
+ font-size: 14px;
9957
+ font-weight: 600;
9958
+ color: var(--jupiter-text-primary, #333);
9959
+ margin-bottom: 16px;
9960
+ padding-bottom: 8px;
9961
+ border-bottom: 1px solid var(--jupiter-border-color, #ddd);
9962
+ }
9963
+
9964
+ .admin-dimension-group {
9965
+ margin-bottom: 16px;
9966
+ }
9967
+
9968
+ .admin-dimension-group:last-child {
9969
+ margin-bottom: 0;
9970
+ }
9971
+
9972
+ .admin-dimension-label {
9973
+ font-size: 13px;
9974
+ font-weight: 500;
9975
+ color: var(--jupiter-text-primary, #333);
9976
+ margin-bottom: 8px;
9977
+ }
9978
+
9979
+ .admin-dimension-members {
9980
+ display: flex;
9981
+ flex-direction: column;
9982
+ gap: 6px;
9983
+ margin-bottom: 8px;
9984
+ }
9985
+
9986
+ .admin-member-checkbox-item {
9987
+ display: flex;
9988
+ align-items: center;
9989
+ gap: 8px;
9990
+ padding: 6px 8px;
9991
+ border-radius: 4px;
9992
+ cursor: pointer;
9993
+ transition: background-color 0.2s ease;
9994
+ }
9995
+
9996
+ .admin-member-checkbox-item:hover {
9997
+ background: var(--jupiter-hover-background, #f5f5f5);
9998
+ }
9999
+
10000
+ .admin-member-checkbox {
10001
+ width: 16px;
10002
+ height: 16px;
10003
+ cursor: pointer;
10004
+ flex-shrink: 0;
10005
+ }
10006
+
10007
+ .admin-member-checkbox-label {
10008
+ font-size: 13px;
10009
+ color: var(--jupiter-text-secondary, #666);
10010
+ user-select: none;
10011
+ flex: 1;
10012
+ }
10013
+
10014
+ .admin-member-select-controls {
10015
+ display: flex;
10016
+ gap: 8px;
10017
+ margin-top: 8px;
10018
+ }
10019
+
10020
+ .admin-member-select-btn {
10021
+ padding: 6px 12px;
10022
+ font-size: 12px;
10023
+ background: var(--jupiter-background-light, #f8f9fa);
10024
+ border: 1px solid var(--jupiter-border-color, #ddd);
10025
+ border-radius: 4px;
10026
+ cursor: pointer;
10027
+ transition: all 0.2s ease;
10028
+ color: var(--jupiter-text-secondary, #666);
10029
+ }
10030
+
10031
+ .admin-member-select-btn:hover {
10032
+ background: var(--jupiter-hover-background, #e8e8e8);
10033
+ border-color: var(--jupiter-primary-color, #1976d2);
10034
+ color: var(--jupiter-primary-color, #1976d2);
10035
+ }
10036
+
10037
+ .admin-member-select-btn:active {
10038
+ transform: translateY(1px);
10039
+ }
10040
+
9688
10041
  /* Error Popup Styles */
9689
10042
  .error-popup-overlay {
9690
10043
  position: fixed;
@@ -9840,6 +10193,9 @@ __decorateClass([
9840
10193
  __decorateClass([
9841
10194
  n2({ type: String })
9842
10195
  ], JupiterDynamicForm.prototype, "mode", 2);
10196
+ __decorateClass([
10197
+ n2({ type: String, attribute: "submit-button-label" })
10198
+ ], JupiterDynamicForm.prototype, "submitButtonLabel", 2);
9843
10199
  __decorateClass([
9844
10200
  n2({ type: Array })
9845
10201
  ], JupiterDynamicForm.prototype, "financialStatementsTypeAxis", 2);