jupiter-dynamic-forms 1.14.4 → 1.14.5

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
@@ -6774,6 +6774,20 @@ let JupiterDynamicForm = class extends LitElement {
6774
6774
  );
6775
6775
  console.log("✅ Generated schema with sections:", this._currentSchema.sections.length);
6776
6776
  this._allSections = [...this._currentSchema.sections];
6777
+ if (Array.isArray(this._selectedRoleIds) && this._selectedRoleIds.length > 0 && typeof this._selectedRoleIds[0] === "object") {
6778
+ console.log("🔄 Applying custom role order to _allSections from _selectedRoleIds");
6779
+ const enhancedRoles = this._selectedRoleIds;
6780
+ const orderMap = /* @__PURE__ */ new Map();
6781
+ enhancedRoles.forEach((role) => {
6782
+ orderMap.set(role.roleId, role.order);
6783
+ });
6784
+ this._allSections = [...this._allSections].sort((a2, b2) => {
6785
+ const orderA = orderMap.get(a2.id) ?? 999;
6786
+ const orderB = orderMap.get(b2.id) ?? 999;
6787
+ return orderA - orderB;
6788
+ });
6789
+ console.log("✅ Custom order applied to _allSections:", this._allSections.map((s2) => s2.title));
6790
+ }
6777
6791
  if (this.financialStatementsTypeAxis && this.financialStatementsTypeAxis.length > 0) {
6778
6792
  console.log("🔍 Applying financialStatementsTypeAxis filter:", this.financialStatementsTypeAxis);
6779
6793
  console.log("📊 Sections before filter:", this._allSections.length);
@@ -8827,7 +8841,7 @@ let JupiterDynamicForm = class extends LitElement {
8827
8841
  });
8828
8842
  }
8829
8843
  _renderAdminModeContent(section2) {
8830
- var _a;
8844
+ var _a, _b;
8831
8845
  if (!section2) {
8832
8846
  return html`
8833
8847
  <div class="admin-mode-container">
@@ -8836,6 +8850,34 @@ let JupiterDynamicForm = class extends LitElement {
8836
8850
  `;
8837
8851
  }
8838
8852
  const showPreviousYearChecked = ((_a = this._periodPreferences[section2.id]) == null ? void 0 : _a.showPreviousYear) ?? section2.showPreviousYear ?? false;
8853
+ const dimensions = this._getDimensionsForRole(section2.id);
8854
+ const hasDimensions = dimensions.length > 0;
8855
+ if (hasDimensions && !((_b = this._periodPreferences[section2.id]) == null ? void 0 : _b.dimensionSelections)) {
8856
+ const currentPref = this._periodPreferences[section2.id] || {
8857
+ showDuration: true,
8858
+ showInstant: true,
8859
+ showPreviousYear: false
8860
+ };
8861
+ currentPref.dimensionSelections = [];
8862
+ dimensions.forEach((dimension) => {
8863
+ var _a2, _b2;
8864
+ const allMembers = this._getAllDimensionMembers(dimension.members);
8865
+ const allMemberIds = allMembers.map((m) => m.id);
8866
+ 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;
8867
+ if (currentPref.dimensionSelections) {
8868
+ currentPref.dimensionSelections.push({
8869
+ dimensionId: dimension.id,
8870
+ dimensionLabel,
8871
+ selectedMemberIds: allMemberIds
8872
+ });
8873
+ }
8874
+ });
8875
+ this._periodPreferences = {
8876
+ ...this._periodPreferences,
8877
+ [section2.id]: currentPref
8878
+ };
8879
+ console.log("✅ [Admin Mode] Initialized all dimension members as selected by default for role:", section2.id);
8880
+ }
8839
8881
  return html`
8840
8882
  <div class="admin-mode-container">
8841
8883
  <h2 class="admin-mode-title">Role Configuration: ${section2.title}</h2>
@@ -8851,6 +8893,58 @@ let JupiterDynamicForm = class extends LitElement {
8851
8893
  <label for="admin-prev-year-${section2.id}">Show Previous Year Column</label>
8852
8894
  </div>
8853
8895
  </div>
8896
+
8897
+ ${hasDimensions ? html`
8898
+ <div class="admin-dimension-section">
8899
+ <div class="admin-dimension-header">📊 ${I18n.t("filter.dimensionMemberSelection")}</div>
8900
+ ${dimensions.map((dimension) => {
8901
+ var _a2, _b2;
8902
+ const allMembers = this._getAllDimensionMembers(dimension.members);
8903
+ 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;
8904
+ const isSingleMember = this._isSingleMemberDimension(dimension);
8905
+ return html`
8906
+ <div class="admin-dimension-group">
8907
+ <div class="admin-dimension-label">${dimensionLabel}${isSingleMember ? " (Mandatory)" : ""}</div>
8908
+ <div class="admin-dimension-members">
8909
+ ${allMembers.map((member) => {
8910
+ var _a3, _b3;
8911
+ 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;
8912
+ const isChecked = this._isAdminDimensionMemberSelected(section2.id, dimension.id, member.id);
8913
+ return html`
8914
+ <label class="admin-member-checkbox-item">
8915
+ <input
8916
+ type="checkbox"
8917
+ class="admin-member-checkbox"
8918
+ .checked="${isChecked}"
8919
+ ?disabled="${isSingleMember}"
8920
+ @change="${(e2) => this._handleAdminDimensionMemberChange(e2, section2.id, dimension.id, member.id)}"
8921
+ />
8922
+ <span class="admin-member-checkbox-label">${memberLabel}</span>
8923
+ </label>
8924
+ `;
8925
+ })}
8926
+ </div>
8927
+ ${!isSingleMember ? html`
8928
+ <div class="admin-member-select-controls">
8929
+ <button
8930
+ class="admin-member-select-btn"
8931
+ @click="${() => this._selectAllAdminDimensionMembers(section2.id, dimension.id)}"
8932
+ >
8933
+ ${I18n.t("filter.selectAllMembers")}
8934
+ </button>
8935
+ <button
8936
+ class="admin-member-select-btn"
8937
+ @click="${() => this._deselectAllAdminDimensionMembers(section2.id, dimension.id)}"
8938
+ >
8939
+ ${I18n.t("filter.clearMembers")}
8940
+ </button>
8941
+ </div>
8942
+ ` : ""}
8943
+ </div>
8944
+ `;
8945
+ })}
8946
+ </div>
8947
+ ` : ""}
8854
8948
  </div>
8855
8949
  </div>
8856
8950
  `;
@@ -8879,6 +8973,178 @@ let JupiterDynamicForm = class extends LitElement {
8879
8973
  console.log(`✅ [Admin Mode] Updated ${field2} = ${checked} for role ${roleId}`);
8880
8974
  console.log(`📋 [Admin Mode] _periodPreferences now includes:`, this._periodPreferences[roleId]);
8881
8975
  }
8976
+ /**
8977
+ * Get dimensions for a specific role from hypercube data
8978
+ */
8979
+ _getDimensionsForRole(roleId) {
8980
+ var _a, _b, _c, _d;
8981
+ if (!((_b = (_a = this.xbrlInput) == null ? void 0 : _a.hypercubes) == null ? void 0 : _b[0])) {
8982
+ return [];
8983
+ }
8984
+ const hypercubeRole = (_c = this.xbrlInput.hypercubes[0].roles) == null ? void 0 : _c.find((r2) => r2.roleId === roleId);
8985
+ if (!((_d = hypercubeRole == null ? void 0 : hypercubeRole.items) == null ? void 0 : _d.length)) {
8986
+ return [];
8987
+ }
8988
+ const dimensionsMap = /* @__PURE__ */ new Map();
8989
+ hypercubeRole.items.forEach((item) => {
8990
+ if (item.dimensions) {
8991
+ item.dimensions.forEach((dimension) => {
8992
+ if (!dimensionsMap.has(dimension.id)) {
8993
+ dimensionsMap.set(dimension.id, dimension);
8994
+ }
8995
+ });
8996
+ }
8997
+ });
8998
+ return Array.from(dimensionsMap.values());
8999
+ }
9000
+ /**
9001
+ * Get all dimension members recursively
9002
+ */
9003
+ _getAllDimensionMembers(members) {
9004
+ if (!members || members.length === 0) {
9005
+ return [];
9006
+ }
9007
+ let allMembers = [];
9008
+ members.forEach((member) => {
9009
+ allMembers.push(member);
9010
+ if (member.children && member.children.length > 0) {
9011
+ allMembers = allMembers.concat(this._getAllDimensionMembers(member.children));
9012
+ }
9013
+ });
9014
+ return allMembers;
9015
+ }
9016
+ /**
9017
+ * Check if a dimension has only one member (single choice, mandatory)
9018
+ */
9019
+ _isSingleMemberDimension(dimension) {
9020
+ if (!dimension || !dimension.members) {
9021
+ return false;
9022
+ }
9023
+ const allMembers = this._getAllDimensionMembers(dimension.members);
9024
+ return allMembers.length === 1;
9025
+ }
9026
+ /**
9027
+ * Handle dimension member selection in admin mode
9028
+ */
9029
+ _handleAdminDimensionMemberChange(event, roleId, dimensionId, memberId) {
9030
+ var _a, _b;
9031
+ event.stopPropagation();
9032
+ const checkbox = event.target;
9033
+ const currentPref = this._periodPreferences[roleId] || {
9034
+ showDuration: true,
9035
+ showInstant: true,
9036
+ showPreviousYear: false,
9037
+ dimensionSelections: []
9038
+ };
9039
+ if (!currentPref.dimensionSelections) {
9040
+ currentPref.dimensionSelections = [];
9041
+ }
9042
+ let dimensionSelection = currentPref.dimensionSelections.find(
9043
+ (ds) => ds.dimensionId === dimensionId
9044
+ );
9045
+ if (!dimensionSelection) {
9046
+ const dimensions = this._getDimensionsForRole(roleId);
9047
+ const dimension = dimensions.find((d2) => d2.id === dimensionId);
9048
+ 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;
9049
+ dimensionSelection = {
9050
+ dimensionId,
9051
+ dimensionLabel,
9052
+ selectedMemberIds: []
9053
+ };
9054
+ currentPref.dimensionSelections.push(dimensionSelection);
9055
+ }
9056
+ if (checkbox.checked) {
9057
+ if (!dimensionSelection.selectedMemberIds.includes(memberId)) {
9058
+ dimensionSelection.selectedMemberIds.push(memberId);
9059
+ }
9060
+ } else {
9061
+ dimensionSelection.selectedMemberIds = dimensionSelection.selectedMemberIds.filter(
9062
+ (id) => id !== memberId
9063
+ );
9064
+ }
9065
+ this._periodPreferences = {
9066
+ ...this._periodPreferences,
9067
+ [roleId]: currentPref
9068
+ };
9069
+ console.log("📊 [Admin Mode] Updated dimension selections:", this._periodPreferences[roleId].dimensionSelections);
9070
+ this.requestUpdate();
9071
+ }
9072
+ /**
9073
+ * Check if a dimension member is selected in admin mode
9074
+ * Returns true by default if no explicit preference exists (all members checked by default)
9075
+ */
9076
+ _isAdminDimensionMemberSelected(roleId, dimensionId, memberId) {
9077
+ const preferences = this._periodPreferences[roleId];
9078
+ if (!(preferences == null ? void 0 : preferences.dimensionSelections)) {
9079
+ return true;
9080
+ }
9081
+ const dimensionSelection = preferences.dimensionSelections.find(
9082
+ (ds) => ds.dimensionId === dimensionId
9083
+ );
9084
+ if (!dimensionSelection) {
9085
+ return true;
9086
+ }
9087
+ return dimensionSelection.selectedMemberIds.includes(memberId);
9088
+ }
9089
+ /**
9090
+ * Select all members for a dimension in admin mode
9091
+ */
9092
+ _selectAllAdminDimensionMembers(roleId, dimensionId) {
9093
+ var _a, _b;
9094
+ const dimensions = this._getDimensionsForRole(roleId);
9095
+ const dimension = dimensions.find((d2) => d2.id === dimensionId);
9096
+ if (!dimension)
9097
+ return;
9098
+ const allMembers = this._getAllDimensionMembers(dimension.members);
9099
+ const allMemberIds = allMembers.map((m) => m.id);
9100
+ const currentPref = this._periodPreferences[roleId] || {
9101
+ showDuration: true,
9102
+ showInstant: true,
9103
+ showPreviousYear: false,
9104
+ dimensionSelections: []
9105
+ };
9106
+ if (!currentPref.dimensionSelections) {
9107
+ currentPref.dimensionSelections = [];
9108
+ }
9109
+ let dimensionSelection = currentPref.dimensionSelections.find(
9110
+ (ds) => ds.dimensionId === dimensionId
9111
+ );
9112
+ if (!dimensionSelection) {
9113
+ 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;
9114
+ dimensionSelection = {
9115
+ dimensionId,
9116
+ dimensionLabel,
9117
+ selectedMemberIds: []
9118
+ };
9119
+ currentPref.dimensionSelections.push(dimensionSelection);
9120
+ }
9121
+ dimensionSelection.selectedMemberIds = allMemberIds;
9122
+ this._periodPreferences = {
9123
+ ...this._periodPreferences,
9124
+ [roleId]: currentPref
9125
+ };
9126
+ this.requestUpdate();
9127
+ }
9128
+ /**
9129
+ * Deselect all members for a dimension in admin mode
9130
+ */
9131
+ _deselectAllAdminDimensionMembers(roleId, dimensionId) {
9132
+ const currentPref = this._periodPreferences[roleId];
9133
+ if (!(currentPref == null ? void 0 : currentPref.dimensionSelections)) {
9134
+ return;
9135
+ }
9136
+ const dimensionSelection = currentPref.dimensionSelections.find(
9137
+ (ds) => ds.dimensionId === dimensionId
9138
+ );
9139
+ if (dimensionSelection) {
9140
+ dimensionSelection.selectedMemberIds = [];
9141
+ }
9142
+ this._periodPreferences = {
9143
+ ...this._periodPreferences,
9144
+ [roleId]: currentPref
9145
+ };
9146
+ this.requestUpdate();
9147
+ }
8882
9148
  _handleAdminModeSubmit() {
8883
9149
  var _a, _b, _c, _d;
8884
9150
  if (!((_c = (_b = (_a = this.xbrlInput) == null ? void 0 : _a.presentation) == null ? void 0 : _b[0]) == null ? void 0 : _c.roles)) {
@@ -9184,7 +9450,7 @@ let JupiterDynamicForm = class extends LitElement {
9184
9450
  @click="${this._handleSubmit}"
9185
9451
  ?disabled="${this.disabled || this.readonly}"
9186
9452
  >
9187
- ${I18n.t("form.submit")}
9453
+ ${this.submitButtonLabel || I18n.t("form.submit")}
9188
9454
  </button>
9189
9455
 
9190
9456
 
@@ -9685,6 +9951,100 @@ JupiterDynamicForm.styles = css`
9685
9951
  user-select: none;
9686
9952
  }
9687
9953
 
9954
+ .admin-dimension-section {
9955
+ margin-top: 16px;
9956
+ padding: 16px;
9957
+ background: var(--jupiter-background, #fff);
9958
+ border: 1px solid var(--jupiter-border-color, #ddd);
9959
+ border-radius: 6px;
9960
+ }
9961
+
9962
+ .admin-dimension-header {
9963
+ font-size: 14px;
9964
+ font-weight: 600;
9965
+ color: var(--jupiter-text-primary, #333);
9966
+ margin-bottom: 16px;
9967
+ padding-bottom: 8px;
9968
+ border-bottom: 1px solid var(--jupiter-border-color, #ddd);
9969
+ }
9970
+
9971
+ .admin-dimension-group {
9972
+ margin-bottom: 16px;
9973
+ }
9974
+
9975
+ .admin-dimension-group:last-child {
9976
+ margin-bottom: 0;
9977
+ }
9978
+
9979
+ .admin-dimension-label {
9980
+ font-size: 13px;
9981
+ font-weight: 500;
9982
+ color: var(--jupiter-text-primary, #333);
9983
+ margin-bottom: 8px;
9984
+ }
9985
+
9986
+ .admin-dimension-members {
9987
+ display: flex;
9988
+ flex-direction: column;
9989
+ gap: 6px;
9990
+ margin-bottom: 8px;
9991
+ }
9992
+
9993
+ .admin-member-checkbox-item {
9994
+ display: flex;
9995
+ align-items: center;
9996
+ gap: 8px;
9997
+ padding: 6px 8px;
9998
+ border-radius: 4px;
9999
+ cursor: pointer;
10000
+ transition: background-color 0.2s ease;
10001
+ }
10002
+
10003
+ .admin-member-checkbox-item:hover {
10004
+ background: var(--jupiter-hover-background, #f5f5f5);
10005
+ }
10006
+
10007
+ .admin-member-checkbox {
10008
+ width: 16px;
10009
+ height: 16px;
10010
+ cursor: pointer;
10011
+ flex-shrink: 0;
10012
+ }
10013
+
10014
+ .admin-member-checkbox-label {
10015
+ font-size: 13px;
10016
+ color: var(--jupiter-text-secondary, #666);
10017
+ user-select: none;
10018
+ flex: 1;
10019
+ }
10020
+
10021
+ .admin-member-select-controls {
10022
+ display: flex;
10023
+ gap: 8px;
10024
+ margin-top: 8px;
10025
+ }
10026
+
10027
+ .admin-member-select-btn {
10028
+ padding: 6px 12px;
10029
+ font-size: 12px;
10030
+ background: var(--jupiter-background-light, #f8f9fa);
10031
+ border: 1px solid var(--jupiter-border-color, #ddd);
10032
+ border-radius: 4px;
10033
+ cursor: pointer;
10034
+ transition: all 0.2s ease;
10035
+ color: var(--jupiter-text-secondary, #666);
10036
+ }
10037
+
10038
+ .admin-member-select-btn:hover {
10039
+ background: var(--jupiter-hover-background, #e8e8e8);
10040
+ border-color: var(--jupiter-primary-color, #1976d2);
10041
+ color: var(--jupiter-primary-color, #1976d2);
10042
+ }
10043
+
10044
+ .admin-member-select-btn:active {
10045
+ transform: translateY(1px);
10046
+ }
10047
+
9688
10048
  /* Error Popup Styles */
9689
10049
  .error-popup-overlay {
9690
10050
  position: fixed;
@@ -9840,6 +10200,9 @@ __decorateClass([
9840
10200
  __decorateClass([
9841
10201
  n2({ type: String })
9842
10202
  ], JupiterDynamicForm.prototype, "mode", 2);
10203
+ __decorateClass([
10204
+ n2({ type: String, attribute: "submit-button-label" })
10205
+ ], JupiterDynamicForm.prototype, "submitButtonLabel", 2);
9843
10206
  __decorateClass([
9844
10207
  n2({ type: Array })
9845
10208
  ], JupiterDynamicForm.prototype, "financialStatementsTypeAxis", 2);