@ai-matrx/records-ui 0.102.6 → 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/index.js CHANGED
@@ -4995,12 +4995,19 @@ function PersonPicker({ field: field2, value, onChange, disabled, id, className,
4995
4995
  " 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."
4996
4996
  ] });
4997
4997
  }
4998
+ const displayNameOf = (userId, recordName2) => {
4999
+ const member = userId ? (members ?? []).find((m) => m.userId === userId) : void 0;
5000
+ const own3 = (member?.name ?? "").trim();
5001
+ if (own3 !== "") return own3;
5002
+ const kept = (recordName2 ?? people.find((p) => p.userId === userId)?.name ?? "").trim();
5003
+ const email = (member?.email ?? "").trim();
5004
+ return kept !== "" && kept !== email ? kept : null;
5005
+ };
4998
5006
  const nameOfRecord = (recordId) => {
4999
5007
  const person = people.find((p) => p.id === recordId);
5000
5008
  if (!person) return "Loading\u2026";
5001
- if (person.name !== "") return person.name;
5002
5009
  const member = (members ?? []).find((m) => m.userId === person.userId);
5003
- return member ? memberName(member) : "A member with no name set";
5010
+ return displayNameOf(person.userId, person.name) ?? (member ? memberName(member) : person.name || "A member with no name set");
5004
5011
  };
5005
5012
  const pick = async (member) => {
5006
5013
  setBusy(true);
@@ -5062,10 +5069,10 @@ function PersonPicker({ field: field2, value, onChange, disabled, id, className,
5062
5069
  chips: picked.map((recordId) => ({ id: recordId, label: nameOfRecord(recordId), onRemove: () => drop(recordId) })),
5063
5070
  items: visible.map((member) => ({
5064
5071
  id: member.userId,
5065
- label: memberName(member),
5072
+ label: displayNameOf(member.userId) ?? memberName(member),
5066
5073
  // A name and an email with nothing between them read as one run-on string (verdict,
5067
5074
  // 19 September). They are two facts, so they are drawn as two.
5068
- detail: member.email && member.email !== memberName(member) ? member.email : null,
5075
+ detail: displayNameOf(member.userId) !== null && member.email ? member.email : null,
5069
5076
  picked: pickedUserIds.has(member.userId),
5070
5077
  disabled: busy
5071
5078
  })),