@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.cjs CHANGED
@@ -964,10 +964,10 @@ function shown(value) {
964
964
  if (typeof value === "number" || typeof value === "boolean") return String(value);
965
965
  return null;
966
966
  }
967
- function tellApart(rows, nameOf) {
967
+ function tellApart(rows, nameOf2) {
968
968
  const byName = /* @__PURE__ */ new Map();
969
969
  for (const row of rows) {
970
- const name = nameOf(row.id).trim().toLowerCase();
970
+ const name = nameOf2(row.id).trim().toLowerCase();
971
971
  byName.set(name, [...byName.get(name) ?? [], row]);
972
972
  }
973
973
  const out = /* @__PURE__ */ new Map();
@@ -1636,6 +1636,7 @@ function RecordLabelProvider({ children }) {
1636
1636
  const client = (0, import_react10.useRecordsClient)();
1637
1637
  const [names, setNames] = (0, import_react9.useState)({});
1638
1638
  const [archivedRefs, setArchivedRefs] = (0, import_react9.useState)({});
1639
+ const [iconsOf, setIconsOf] = (0, import_react9.useState)({});
1639
1640
  const [settled, setSettled] = (0, import_react9.useState)({});
1640
1641
  const [waitingLines, setWaitingLines] = (0, import_react9.useState)({});
1641
1642
  const asked3 = (0, import_react9.useRef)(/* @__PURE__ */ new Set());
@@ -1718,6 +1719,7 @@ function RecordLabelProvider({ children }) {
1718
1719
  void (async () => {
1719
1720
  const learned = {};
1720
1721
  const archivedNow = {};
1722
+ const iconsNow = {};
1721
1723
  await Promise.all(
1722
1724
  batch.map(async ({ field, ids }) => {
1723
1725
  const wanted = [...ids];
@@ -1730,10 +1732,12 @@ function RecordLabelProvider({ children }) {
1730
1732
  learned[id] = !result.ok ? UNREAD_RECORD_LABEL : typeof words === "string" && words !== "" ? words : WITHHELD_RECORD_LABEL;
1731
1733
  }
1732
1734
  if (result.ok) for (const id of result.archived ?? []) archivedNow[`${field.id}:${id}`] = true;
1735
+ if (result.ok) for (const [id, pair] of Object.entries(result.icons ?? {})) iconsNow[id] = pair;
1733
1736
  })
1734
1737
  );
1735
1738
  setNames((current) => ({ ...current, ...learned }));
1736
1739
  if (Object.keys(archivedNow).length > 0) setArchivedRefs((current) => ({ ...current, ...archivedNow }));
1740
+ if (Object.keys(iconsNow).length > 0) setIconsOf((current) => ({ ...current, ...iconsNow }));
1737
1741
  for (const { field } of batch) stopWaitClock(field.id);
1738
1742
  })();
1739
1743
  }, [client, stopWaitClock]);
@@ -1781,9 +1785,10 @@ function RecordLabelProvider({ children }) {
1781
1785
  () => {
1782
1786
  const answer = ((field, id) => lookupWords(field, id));
1783
1787
  answer.archived = (field, id) => archivedRefs[`${field.id}:${id}`] === true;
1788
+ answer.icons = (_field, id) => iconsOf[id];
1784
1789
  return answer;
1785
1790
  },
1786
- [lookupWords, archivedRefs]
1791
+ [lookupWords, archivedRefs, iconsOf]
1787
1792
  );
1788
1793
  const waiting = (0, import_react9.useCallback)((field) => waitingLines[field.id] ?? null, [waitingLines]);
1789
1794
  const value = (0, import_react9.useMemo)(() => ({ lookup, want, waiting }), [lookup, want, waiting]);
@@ -4535,6 +4540,20 @@ function kindLabel(kind) {
4535
4540
 
4536
4541
  // src/ReferenceChips.tsx
4537
4542
  var import_jsx_runtime22 = require("react/jsx-runtime");
4543
+ function glyphOf(icon) {
4544
+ const text = (icon ?? "").trim();
4545
+ return text !== "" && text.length <= 8 && /[^\u0000-\u007f]/.test(text) ? text : null;
4546
+ }
4547
+ function nameOf(icon) {
4548
+ const text = (icon ?? "").trim();
4549
+ return /^[A-Za-z][A-Za-z0-9_-]{1,40}$/.test(text) ? text : null;
4550
+ }
4551
+ function iconOf(pair) {
4552
+ const own3 = glyphOf(pair?.icon) ?? nameOf(pair?.icon);
4553
+ const table = glyphOf(pair?.tableIcon) ?? nameOf(pair?.tableIcon);
4554
+ const chosen = own3 ?? table;
4555
+ return chosen ? { icon: chosen } : {};
4556
+ }
4538
4557
  function referencesOf(field, value, kind, labels) {
4539
4558
  if (kind === "entity_reference") {
4540
4559
  return (0, import_records13.entityRefsOf)(value).map((r) => ({ token: r.token, id: r.id, label: r.label }));
@@ -4546,6 +4565,7 @@ function referencesOf(field, value, kind, labels) {
4546
4565
  id,
4547
4566
  label: labels?.(field, id) ?? null,
4548
4567
  tableId,
4568
+ ...iconOf(labels?.icons?.(field, id)),
4549
4569
  ...labels?.archived?.(field, id) ? { archived: true } : {}
4550
4570
  }));
4551
4571
  }
@@ -4577,7 +4597,7 @@ function ReferenceChip({ reference, waiting }) {
4577
4597
  "data-records-reference-archived": reference.archived ? "" : void 0,
4578
4598
  title: reference.archived ? ARCHIVED_REFERENCE_TIP : words,
4579
4599
  children: [
4580
- /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("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__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-sm leading-none", children: reference.icon }) : /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PageGlyph, {}) }),
4600
+ /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("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__ */ (0, import_jsx_runtime22.jsx)("span", { className: "text-sm leading-none", children: reference.icon }) : reference.icon && host.renderIcon?.(reference.icon) || /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(PageGlyph, {}) }),
4581
4601
  drawn ?? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "truncate", children: words }),
4582
4602
  reference.archived ? /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "shrink-0 text-muted-foreground", children: ARCHIVED_REFERENCE_WORD }) : null
4583
4603
  ]