@ai-matrx/records-ui 0.101.31 → 0.101.34

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
@@ -962,10 +962,10 @@ function shown(value) {
962
962
  if (typeof value === "number" || typeof value === "boolean") return String(value);
963
963
  return null;
964
964
  }
965
- function tellApart(rows, nameOf) {
965
+ function tellApart(rows, nameOf2) {
966
966
  const byName = /* @__PURE__ */ new Map();
967
967
  for (const row of rows) {
968
- const name = nameOf(row.id).trim().toLowerCase();
968
+ const name = nameOf2(row.id).trim().toLowerCase();
969
969
  byName.set(name, [...byName.get(name) ?? [], row]);
970
970
  }
971
971
  const out = /* @__PURE__ */ new Map();
@@ -1634,6 +1634,7 @@ function RecordLabelProvider({ children }) {
1634
1634
  const client = useRecordsClient();
1635
1635
  const [names, setNames] = useState5({});
1636
1636
  const [archivedRefs, setArchivedRefs] = useState5({});
1637
+ const [iconsOf, setIconsOf] = useState5({});
1637
1638
  const [settled, setSettled] = useState5({});
1638
1639
  const [waitingLines, setWaitingLines] = useState5({});
1639
1640
  const asked3 = useRef3(/* @__PURE__ */ new Set());
@@ -1716,6 +1717,7 @@ function RecordLabelProvider({ children }) {
1716
1717
  void (async () => {
1717
1718
  const learned = {};
1718
1719
  const archivedNow = {};
1720
+ const iconsNow = {};
1719
1721
  await Promise.all(
1720
1722
  batch.map(async ({ field, ids }) => {
1721
1723
  const wanted = [...ids];
@@ -1728,10 +1730,12 @@ function RecordLabelProvider({ children }) {
1728
1730
  learned[id] = !result.ok ? UNREAD_RECORD_LABEL : typeof words === "string" && words !== "" ? words : WITHHELD_RECORD_LABEL;
1729
1731
  }
1730
1732
  if (result.ok) for (const id of result.archived ?? []) archivedNow[`${field.id}:${id}`] = true;
1733
+ if (result.ok) for (const [id, pair] of Object.entries(result.icons ?? {})) iconsNow[id] = pair;
1731
1734
  })
1732
1735
  );
1733
1736
  setNames((current) => ({ ...current, ...learned }));
1734
1737
  if (Object.keys(archivedNow).length > 0) setArchivedRefs((current) => ({ ...current, ...archivedNow }));
1738
+ if (Object.keys(iconsNow).length > 0) setIconsOf((current) => ({ ...current, ...iconsNow }));
1735
1739
  for (const { field } of batch) stopWaitClock(field.id);
1736
1740
  })();
1737
1741
  }, [client, stopWaitClock]);
@@ -1779,9 +1783,10 @@ function RecordLabelProvider({ children }) {
1779
1783
  () => {
1780
1784
  const answer = ((field, id) => lookupWords(field, id));
1781
1785
  answer.archived = (field, id) => archivedRefs[`${field.id}:${id}`] === true;
1786
+ answer.icons = (_field, id) => iconsOf[id];
1782
1787
  return answer;
1783
1788
  },
1784
- [lookupWords, archivedRefs]
1789
+ [lookupWords, archivedRefs, iconsOf]
1785
1790
  );
1786
1791
  const waiting = useCallback((field) => waitingLines[field.id] ?? null, [waitingLines]);
1787
1792
  const value = useMemo3(() => ({ lookup, want, waiting }), [lookup, want, waiting]);
@@ -4545,6 +4550,20 @@ function kindLabel(kind) {
4545
4550
 
4546
4551
  // src/ReferenceChips.tsx
4547
4552
  import { jsx as jsx22, jsxs as jsxs19 } from "react/jsx-runtime";
4553
+ function glyphOf(icon) {
4554
+ const text = (icon ?? "").trim();
4555
+ return text !== "" && text.length <= 8 && /[^\u0000-\u007f]/.test(text) ? text : null;
4556
+ }
4557
+ function nameOf(icon) {
4558
+ const text = (icon ?? "").trim();
4559
+ return /^[A-Za-z][A-Za-z0-9_-]{1,40}$/.test(text) ? text : null;
4560
+ }
4561
+ function iconOf(pair) {
4562
+ const own3 = glyphOf(pair?.icon) ?? nameOf(pair?.icon);
4563
+ const table = glyphOf(pair?.tableIcon) ?? nameOf(pair?.tableIcon);
4564
+ const chosen = own3 ?? table;
4565
+ return chosen ? { icon: chosen } : {};
4566
+ }
4548
4567
  function referencesOf(field, value, kind, labels) {
4549
4568
  if (kind === "entity_reference") {
4550
4569
  return entityRefsOf2(value).map((r) => ({ token: r.token, id: r.id, label: r.label }));
@@ -4556,6 +4575,7 @@ function referencesOf(field, value, kind, labels) {
4556
4575
  id,
4557
4576
  label: labels?.(field, id) ?? null,
4558
4577
  tableId,
4578
+ ...iconOf(labels?.icons?.(field, id)),
4559
4579
  ...labels?.archived?.(field, id) ? { archived: true } : {}
4560
4580
  }));
4561
4581
  }
@@ -4587,7 +4607,7 @@ function ReferenceChip({ reference, waiting }) {
4587
4607
  "data-records-reference-archived": reference.archived ? "" : void 0,
4588
4608
  title: reference.archived ? ARCHIVED_REFERENCE_TIP : words,
4589
4609
  children: [
4590
- /* @__PURE__ */ jsx22("span", { "aria-hidden": "true", "data-records-reference-icon": "", className: "inline-flex size-4 shrink-0 items-center justify-center text-muted-foreground", children: reference.icon ? /* @__PURE__ */ jsx22("span", { className: "text-sm leading-none", children: reference.icon }) : /* @__PURE__ */ jsx22(PageGlyph, {}) }),
4610
+ /* @__PURE__ */ jsx22("span", { "aria-hidden": "true", "data-records-reference-icon": "", className: "inline-flex size-4 shrink-0 items-center justify-center text-muted-foreground", children: glyphOf(reference.icon) ? /* @__PURE__ */ jsx22("span", { className: "text-sm leading-none", children: reference.icon }) : reference.icon && host.renderIcon?.(reference.icon) || /* @__PURE__ */ jsx22(PageGlyph, {}) }),
4591
4611
  drawn ?? /* @__PURE__ */ jsx22("span", { className: "truncate", children: words }),
4592
4612
  reference.archived ? /* @__PURE__ */ jsx22("span", { className: "shrink-0 text-muted-foreground", children: ARCHIVED_REFERENCE_WORD }) : null
4593
4613
  ]