@tunghtml/strapi-plugin-composite-field 1.1.3 → 1.1.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.
@@ -464,24 +464,23 @@ const CompositeInput = (props) => {
464
464
  }
465
465
  }
466
466
  if (!fieldValue) {
467
- const labels = document.querySelectorAll("label");
468
- for (const labelEl of labels) {
469
- const labelText = labelEl.textContent?.trim().toLowerCase();
470
- const fieldName = fieldPath.toLowerCase();
471
- if (labelText === fieldName || labelText.includes(fieldName)) {
472
- const container = labelEl.closest('[role="group"]') || labelEl.parentElement;
473
- if (container) {
474
- const combobox = container.querySelector(
475
- 'button[role="combobox"]'
476
- );
477
- if (combobox) {
478
- const selectedText = combobox.textContent?.trim();
479
- if (selectedText && selectedText !== "Select..." && selectedText !== "") {
480
- fieldValue = selectedText;
481
- break;
482
- }
483
- }
484
- }
467
+ const combobox = document.querySelector(
468
+ `div[role="combobox"][name="${fieldPath}"]`
469
+ );
470
+ if (combobox) {
471
+ const selectedText = combobox.textContent?.trim();
472
+ if (selectedText && selectedText !== "Select..." && selectedText !== "") {
473
+ fieldValue = selectedText;
474
+ }
475
+ }
476
+ }
477
+ if (!fieldValue) {
478
+ const fieldById = document.getElementById(fieldPath);
479
+ if (fieldById) {
480
+ if (fieldById.tagName === "SELECT") {
481
+ fieldValue = fieldById.value;
482
+ } else if (fieldById.value) {
483
+ fieldValue = fieldById.value;
485
484
  }
486
485
  }
487
486
  }
@@ -506,7 +505,7 @@ const CompositeInput = (props) => {
506
505
  const listeners = [];
507
506
  fields.forEach((fieldPath) => {
508
507
  const elements = document.querySelectorAll(
509
- `input[name="${fieldPath}"], textarea[name="${fieldPath}"], select[name="${fieldPath}"], button[role="combobox"]`
508
+ `input[name="${fieldPath}"], textarea[name="${fieldPath}"], select[name="${fieldPath}"], div[role="combobox"][name="${fieldPath}"]`
510
509
  );
511
510
  elements.forEach((element) => {
512
511
  element.addEventListener("change", handleFieldChange);
@@ -483,24 +483,23 @@ const CompositeInput = (props) => {
483
483
  }
484
484
  }
485
485
  if (!fieldValue) {
486
- const labels = document.querySelectorAll("label");
487
- for (const labelEl of labels) {
488
- const labelText = labelEl.textContent?.trim().toLowerCase();
489
- const fieldName = fieldPath.toLowerCase();
490
- if (labelText === fieldName || labelText.includes(fieldName)) {
491
- const container = labelEl.closest('[role="group"]') || labelEl.parentElement;
492
- if (container) {
493
- const combobox = container.querySelector(
494
- 'button[role="combobox"]'
495
- );
496
- if (combobox) {
497
- const selectedText = combobox.textContent?.trim();
498
- if (selectedText && selectedText !== "Select..." && selectedText !== "") {
499
- fieldValue = selectedText;
500
- break;
501
- }
502
- }
503
- }
486
+ const combobox = document.querySelector(
487
+ `div[role="combobox"][name="${fieldPath}"]`
488
+ );
489
+ if (combobox) {
490
+ const selectedText = combobox.textContent?.trim();
491
+ if (selectedText && selectedText !== "Select..." && selectedText !== "") {
492
+ fieldValue = selectedText;
493
+ }
494
+ }
495
+ }
496
+ if (!fieldValue) {
497
+ const fieldById = document.getElementById(fieldPath);
498
+ if (fieldById) {
499
+ if (fieldById.tagName === "SELECT") {
500
+ fieldValue = fieldById.value;
501
+ } else if (fieldById.value) {
502
+ fieldValue = fieldById.value;
504
503
  }
505
504
  }
506
505
  }
@@ -525,7 +524,7 @@ const CompositeInput = (props) => {
525
524
  const listeners = [];
526
525
  fields.forEach((fieldPath) => {
527
526
  const elements = document.querySelectorAll(
528
- `input[name="${fieldPath}"], textarea[name="${fieldPath}"], select[name="${fieldPath}"], button[role="combobox"]`
527
+ `input[name="${fieldPath}"], textarea[name="${fieldPath}"], select[name="${fieldPath}"], div[role="combobox"][name="${fieldPath}"]`
529
528
  );
530
529
  elements.forEach((element) => {
531
530
  element.addEventListener("change", handleFieldChange);
@@ -37,7 +37,7 @@ const index = {
37
37
  defaultMessage: "Combine multiple fields into one display value"
38
38
  },
39
39
  components: {
40
- Input: async () => Promise.resolve().then(() => require("../_chunks/CompositeInput-8DFCNiOg.js"))
40
+ Input: async () => Promise.resolve().then(() => require("../_chunks/CompositeInput-C_wtVXHq.js"))
41
41
  },
42
42
  options: {
43
43
  base: [
@@ -34,7 +34,7 @@ const index = {
34
34
  defaultMessage: "Combine multiple fields into one display value"
35
35
  },
36
36
  components: {
37
- Input: async () => import("../_chunks/CompositeInput-CZQYMB_n.mjs")
37
+ Input: async () => import("../_chunks/CompositeInput-CF-LA05U.mjs")
38
38
  },
39
39
  options: {
40
40
  base: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tunghtml/strapi-plugin-composite-field",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "A Strapi v5 plugin to create composite display fields by combining multiple text, string, and enum fields with auto-generate support",
5
5
  "keywords": [
6
6
  "strapi",