@ai-matrx/records-ui 0.102.5 → 0.102.7

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/pickers.js CHANGED
@@ -2528,12 +2528,19 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
2528
2528
  " is a person field, but it does not say which Table the people are records of yet, so there is nothing to pick from. A table admin sets its target in the field editor."
2529
2529
  ] });
2530
2530
  }
2531
+ const displayNameOf = (userId, recordName2) => {
2532
+ const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
2533
+ const own3 = (member?.name ?? "").trim();
2534
+ if (own3 !== "") return own3;
2535
+ const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
2536
+ const email = (member?.email ?? "").trim();
2537
+ return kept !== "" && kept !== email ? kept : null;
2538
+ };
2531
2539
  const nameOfRecord = (recordId) => {
2532
2540
  const person = people.find((p) => p.id === recordId);
2533
2541
  if (!person) return "Loading\u2026";
2534
- if (person.name !== "") return person.name;
2535
2542
  const member = (members ?? []).find((m) => m.userId === person.userId);
2536
- return member ? memberName(member) : "A member with no name set";
2543
+ return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
2537
2544
  };
2538
2545
  const pick = async (member) => {
2539
2546
  setBusy(true);
@@ -2595,10 +2602,10 @@ function PersonPicker({ field, value, onChange, disabled, id, className, autoOpe
2595
2602
  chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), onRemove: () => drop(recordId) })),
2596
2603
  items: visible.map((member) => ({
2597
2604
  id: member.userId,
2598
- label: memberName(member),
2605
+ label: displayNameOf(member.userId) ?? memberName(member),
2599
2606
  // A name and an email with nothing between them read as one run-on string (verdict,
2600
2607
  // 19 September). They are two facts, so they are drawn as two.
2601
- detail: member.email && member.email !== memberName(member) ? member.email : null,
2608
+ detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
2602
2609
  picked: pickedUserIds.has(member.userId),
2603
2610
  disabled: busy
2604
2611
  })),