jupiter-dynamic-forms 1.8.2 → 1.9.0

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
@@ -555,8 +555,12 @@ class XBRLFormBuilder {
555
555
  /**
556
556
  * Build form schema from XBRL input data
557
557
  * Creates accordion sections for each presentation role
558
+ * @param xbrlInput - XBRL taxonomy data
559
+ * @param periodStartDate - Start date for the reporting period
560
+ * @param periodEndDate - End date for the reporting period
561
+ * @param language - ISO language code for labels (e.g., 'en', 'nl', 'de')
558
562
  */
559
- static buildFormSchema(xbrlInput, periodStartDate, periodEndDate) {
563
+ static buildFormSchema(xbrlInput, periodStartDate, periodEndDate, language = "en") {
560
564
  var _a;
561
565
  if (!xbrlInput.presentation || xbrlInput.presentation.length === 0) {
562
566
  throw new Error("XBRL presentation data is required");
@@ -568,7 +572,7 @@ class XBRLFormBuilder {
568
572
  return a2.role.localeCompare(b2.role);
569
573
  });
570
574
  sortedRoles.forEach((role) => {
571
- const section = this.buildSectionFromRole(role, periodStartDate, periodEndDate, hypercubeData);
575
+ const section = this.buildSectionFromRole(role, periodStartDate, periodEndDate, hypercubeData, language);
572
576
  this.assignFieldColumnIds(section);
573
577
  sections.push(section);
574
578
  });
@@ -583,7 +587,7 @@ class XBRLFormBuilder {
583
587
  /**
584
588
  * Build a form section from a presentation role
585
589
  */
586
- static buildSectionFromRole(role, periodStartDate, periodEndDate, hypercubeData) {
590
+ static buildSectionFromRole(role, periodStartDate, periodEndDate, hypercubeData, language = "en") {
587
591
  var _a;
588
592
  const title = this.extractRoleTitle(role.role);
589
593
  const nonAbstractConcepts = this.getAllNonAbstractConcepts(role);
@@ -597,7 +601,7 @@ class XBRLFormBuilder {
597
601
  const conceptTrees = [];
598
602
  if ((_a = role.presentationLinkbase) == null ? void 0 : _a.concepts) {
599
603
  role.presentationLinkbase.concepts.forEach((concept) => {
600
- const conceptTree = this.buildConceptTree(concept, 0, periodStartDate, periodEndDate, roleInfo, role.id);
604
+ const conceptTree = this.buildConceptTree(concept, 0, periodStartDate, periodEndDate, roleInfo, role.id, language);
601
605
  if (conceptTree) {
602
606
  conceptTrees.push(conceptTree);
603
607
  }
@@ -619,8 +623,8 @@ class XBRLFormBuilder {
619
623
  /**
620
624
  * Build concept tree from XBRL presentation concept
621
625
  */
622
- static buildConceptTree(concept, level, periodStartDate, periodEndDate, roleInfo, sectionId) {
623
- const label = this.getPreferredLabel(concept.labels);
626
+ static buildConceptTree(concept, level, periodStartDate, periodEndDate, roleInfo, sectionId, language = "en") {
627
+ const label = this.getPreferredLabel(concept.labels, language);
624
628
  const fields = [];
625
629
  if (!concept.elementAbstract) {
626
630
  let columnIds = [];
@@ -663,7 +667,7 @@ class XBRLFormBuilder {
663
667
  const children = [];
664
668
  if (concept.children && concept.children.length > 0) {
665
669
  concept.children.forEach((child) => {
666
- const childTree = this.buildConceptTree(child, level + 1, periodStartDate, periodEndDate, roleInfo, sectionId);
670
+ const childTree = this.buildConceptTree(child, level + 1, periodStartDate, periodEndDate, roleInfo, sectionId, language);
667
671
  if (childTree) {
668
672
  children.push(childTree);
669
673
  }
@@ -744,21 +748,25 @@ class XBRLFormBuilder {
744
748
  return typeMap[xbrlType] || "text";
745
749
  }
746
750
  /**
747
- * Get preferred label from labels array
751
+ * Get preferred label from labels array with language support
752
+ * @param labels - Array of XBRL labels
753
+ * @param language - ISO language code (e.g., 'en', 'nl', 'de')
748
754
  */
749
- static getPreferredLabel(labels) {
755
+ static getPreferredLabel(labels, language = "en") {
750
756
  if (!labels || labels.length === 0)
751
757
  return "Unnamed Concept";
752
- const preferred = labels.find((l2) => l2.preferredLabel);
758
+ const languageLabels = labels.filter((l2) => l2.lang === language);
759
+ const labelsToSearch = languageLabels.length > 0 ? languageLabels : labels;
760
+ const preferred = labelsToSearch.find((l2) => l2.preferredLabel);
753
761
  if (preferred)
754
762
  return preferred.label;
755
- const standard = labels.find((l2) => l2.role === "http://www.xbrl.org/2003/role/label");
763
+ const standard = labelsToSearch.find((l2) => l2.role === "http://www.xbrl.org/2003/role/label");
756
764
  if (standard)
757
765
  return standard.label;
758
- const terse = labels.find((l2) => l2.role === "http://www.xbrl.org/2003/role/terseLabel");
766
+ const terse = labelsToSearch.find((l2) => l2.role === "http://www.xbrl.org/2003/role/terseLabel");
759
767
  if (terse)
760
768
  return terse.label;
761
- return labels[0].label;
769
+ return labelsToSearch.length > 0 ? labelsToSearch[0].label : labels[0].label;
762
770
  }
763
771
  /**
764
772
  * Assign appropriate column IDs to fields based on section's generated columns
@@ -3909,6 +3917,7 @@ let JupiterDynamicForm = class extends LitElement {
3909
3917
  this.readonly = false;
3910
3918
  this.periodStartDate = "2025-01-01";
3911
3919
  this.periodEndDate = "2025-12-31";
3920
+ this.language = "en";
3912
3921
  this._formData = {};
3913
3922
  this._preservedFormData = {};
3914
3923
  this._typedMemberData = {};
@@ -3938,10 +3947,12 @@ let JupiterDynamicForm = class extends LitElement {
3938
3947
  try {
3939
3948
  console.log("🔄 Initializing form from XBRL input:", this.xbrlInput);
3940
3949
  console.log("📅 Using period dates:", this.periodStartDate, "to", this.periodEndDate);
3950
+ console.log("🌐 Using language:", this.language);
3941
3951
  this._currentSchema = XBRLFormBuilder.buildFormSchema(
3942
3952
  this.xbrlInput,
3943
3953
  this.periodStartDate,
3944
- this.periodEndDate
3954
+ this.periodEndDate,
3955
+ this.language
3945
3956
  );
3946
3957
  console.log("✅ Generated schema with sections:", this._currentSchema.sections.length);
3947
3958
  this._allSections = [...this._currentSchema.sections];
@@ -5230,6 +5241,9 @@ __decorateClass([
5230
5241
  __decorateClass([
5231
5242
  n2({ type: String })
5232
5243
  ], JupiterDynamicForm.prototype, "periodEndDate", 2);
5244
+ __decorateClass([
5245
+ n2({ type: String })
5246
+ ], JupiterDynamicForm.prototype, "language", 2);
5233
5247
  __decorateClass([
5234
5248
  r()
5235
5249
  ], JupiterDynamicForm.prototype, "_formData", 2);