@ai-matrx/records-ui 0.115.100 → 0.115.102

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
@@ -13993,9 +13993,8 @@ function renderValue(field2, value, document2, labels, stillWaitingFor, look, ro
13993
13993
  if (Array.isArray(value)) {
13994
13994
  return /* @__PURE__ */ jsx44("span", { className: "flex flex-wrap gap-1", children: value.map((item, i) => /* @__PURE__ */ jsx44(Badge8, { variant: "secondary", className: "text-[11px]", children: scalarText(field2, item, labels) }, `${String(item)}-${i}`)) });
13995
13995
  }
13996
- if ((kind2 === "text" || kind2 === "url") && typeof value === "string" && isImageUrl2(value)) {
13997
- return /* @__PURE__ */ jsx44(ImageUrlValue, { url: value.trim(), alt: field2.label || field2.key, room });
13998
- }
13996
+ const pictureAt = imageAddressOf(field2, value);
13997
+ if (pictureAt) return /* @__PURE__ */ jsx44(ImageUrlValue, { url: pictureAt, alt: field2.label || field2.key, room });
13999
13998
  if (kind2 === "url" && typeof value === "string") {
14000
13999
  const href = value.includes("://") ? value : `https://${value}`;
14001
14000
  return /* @__PURE__ */ jsx44(LinkPreviewCard, { url: href, children: /* @__PURE__ */ jsxs39(
@@ -14045,6 +14044,15 @@ function isImageUrl2(value) {
14045
14044
  }
14046
14045
  return /\.(png|jpe?g|gif|webp|avif|svg|bmp|ico)$/i.test(url.pathname) || /\/(images?|img)\//i.test(url.pathname);
14047
14046
  }
14047
+ function imageAddressOf(field2, value) {
14048
+ if (typeof value !== "string") return null;
14049
+ const kind2 = editorKindFor(field2);
14050
+ if (kind2 !== "text" && kind2 !== "url") return null;
14051
+ const text = value.trim();
14052
+ if (isImageUrl2(text)) return text;
14053
+ const named = /(^|[^a-z])(logo|image|img|photo|picture|avatar|thumbnail|headshot)s?([^a-z]|$)/i.test(`${field2.label ?? ""} ${field2.key}`);
14054
+ return named && /^https?:\/\/[^\s]+$/i.test(text) ? text : null;
14055
+ }
14048
14056
  function ImageUrlValue({ url, alt, room }) {
14049
14057
  const host = useRecordsUi();
14050
14058
  const box = room === "full" ? "size-24" : "size-6";
@@ -14184,6 +14192,8 @@ function RecordValue({
14184
14192
  }
14185
14193
  }
14186
14194
  }
14195
+ const pictureAt = value !== null && value !== void 0 && !wholeValueOf(document2, field2.key) && !envelopeFor(document2, field2.key)?.absent ? imageAddressOf(field2, value) : null;
14196
+ if (pictureAt) return /* @__PURE__ */ jsx44(ImageUrlValue, { url: pictureAt, alt: field2.label || field2.key, room });
14187
14197
  const shown5 = format ?? formatForField(field2);
14188
14198
  const shape = shown5 && (shown5.id === "date" || shown5.id === "datetime") && isDateField(field2) ? dateFormatFor(field2, value) : void 0;
14189
14199
  const dated = shape ? { ...shape, ...shown5?.options ? { options: shown5.options } : {} } : void 0;
@@ -30259,6 +30269,9 @@ function GridBody({
30259
30269
  }, [countedButNotReturned]);
30260
30270
  const askPerRow = Boolean(editable) && !host.rights && rights.known && !rights.write && rows.length > 0;
30261
30271
  const rowRights = useRowRights(rowIds, askPerRow);
30272
+ const rowRightsAnswered = useRef42(false);
30273
+ const rowRightsWaiting = askPerRow && !rowRightsAnswered.current && rowIds.length > 0 && rowRights(rowIds[0])?.known === false;
30274
+ if (askPerRow && !rowRightsWaiting) rowRightsAnswered.current = true;
30262
30275
  const mayWriteRow = useCallback32(
30263
30276
  (rowId) => askPerRow ? rowRights(rowId)?.write ?? false : rights.write,
30264
30277
  [askPerRow, rowRights, rights.write]
@@ -31815,7 +31828,7 @@ function GridBody({
31815
31828
  if (table.error) return /* @__PURE__ */ jsx99(RefusalNotice, { error: table.error, className });
31816
31829
  if (fields.error) return /* @__PURE__ */ jsx99(RefusalNotice, { error: fields.error, className });
31817
31830
  const nothingToShowYet = table.loading && !table.data || // No columns on a table whose level may hide them: not yet known which (one read, Confidential only).
31818
- !structure.settled && (fields.data ?? []).length === 0 || fields.loading && !fields.data || !rights.known || records.loading && rows.length === 0 || // The page read has neither answered nor refused: nothing has been said yet, so nothing is empty.
31831
+ !structure.settled && (fields.data ?? []).length === 0 || fields.loading && !fields.data || !rights.known || rowRightsWaiting || records.loading && rows.length === 0 || // The page read has neither answered nor refused: nothing has been said yet, so nothing is empty.
31819
31832
  !records.data && !records.error || countedButNotReturned || manual && hand.loading && rows.length === 0;
31820
31833
  const refreshing = !nothingToShowYet && (records.loading || manual && hand.loading);
31821
31834
  const structureLocked = !nothingToShowYet && (fields.data ?? []).length === 0 && structure.hidden;
@@ -53211,7 +53224,7 @@ function ReviewBlockView({ block, viewerUserId, extra }) {
53211
53224
  const name = block.title ?? table.data?.name ?? "Records";
53212
53225
  const neighbors = current ? neighborsOf(rows.map((r) => r.id), current.id) : null;
53213
53226
  if (read.error) return /* @__PURE__ */ jsx165(RefusalLine, { error: read.error });
53214
- if (read.waiting || read.loading && rows.length === 0) return /* @__PURE__ */ jsx165(Skeleton40, { className: "h-48 w-full" });
53227
+ if (read.waiting || read.loading && rows.length === 0) return /* @__PURE__ */ jsx165(Skeleton40, { className: "h-72 w-full" });
53215
53228
  if (rows.length === 0) return /* @__PURE__ */ jsx165(BlockNote, { children: read.mine ? "Nothing assigned to you here." : "No records match." });
53216
53229
  return /* @__PURE__ */ jsxs153("div", { className: "grid min-w-0 grid-cols-1 gap-2 md:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]", "data-records-page-review": block.id, children: [
53217
53230
  /* @__PURE__ */ jsxs153("div", { className: "flex min-w-0 flex-col rounded-md border bg-card", children: [
@@ -55939,6 +55952,8 @@ import { Fragment as Fragment73, jsx as jsx176, jsxs as jsxs164 } from "react/js
55939
55952
  function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = false, neighbors, onStep, expanded, onToggleExpand }) {
55940
55953
  const host = useRecordsUi();
55941
55954
  const [asking, setAsking] = useState150(null);
55955
+ const record = useRecord5(recordId, true, { tableId });
55956
+ const answered = Boolean(record.data) && !record.error;
55942
55957
  return /* @__PURE__ */ jsxs164(
55943
55958
  "div",
55944
55959
  {
@@ -55965,28 +55980,30 @@ function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = fal
55965
55980
  children: [
55966
55981
  neighbors && onStep ? /* @__PURE__ */ jsx176(RecordStepper, { neighbors, onStep: (to) => onStep(to), expanded, onToggleExpand }) : null,
55967
55982
  /* @__PURE__ */ jsx176(Peek, { tableId, recordId, onPage, ...onClose ? { onClose } : {} }),
55968
- onPage ? /* @__PURE__ */ jsxs164(Fragment73, { children: [
55969
- /* @__PURE__ */ jsx176(RecordBody, { tableId, recordId }),
55970
- /* @__PURE__ */ jsx176(LinkedLists, { tableId, recordId }),
55971
- /* @__PURE__ */ jsx176(ReverseLinksSections, { tableId, recordId })
55972
- ] }) : null,
55973
- host.recordSections ? /* @__PURE__ */ jsxs164(Fragment72, { children: [
55983
+ answered ? /* @__PURE__ */ jsxs164(Fragment73, { children: [
55984
+ onPage ? /* @__PURE__ */ jsxs164(Fragment73, { children: [
55985
+ /* @__PURE__ */ jsx176(RecordBody, { tableId, recordId }),
55986
+ /* @__PURE__ */ jsx176(LinkedLists, { tableId, recordId }),
55987
+ /* @__PURE__ */ jsx176(ReverseLinksSections, { tableId, recordId })
55988
+ ] }) : null,
55989
+ host.recordSections ? /* @__PURE__ */ jsxs164(Fragment72, { children: [
55990
+ /* @__PURE__ */ jsx176(Separator13, {}),
55991
+ host.recordSections({ tableId, recordId })
55992
+ ] }) : null,
55993
+ /* @__PURE__ */ jsx176(ChecklistRunner, { tableId, recordId, quietWhenEmpty: true, className: "border-t pt-3" }),
55974
55994
  /* @__PURE__ */ jsx176(Separator13, {}),
55975
- host.recordSections({ tableId, recordId })
55976
- ] }) : null,
55977
- /* @__PURE__ */ jsx176(ChecklistRunner, { tableId, recordId, quietWhenEmpty: true, className: "border-t pt-3" }),
55978
- /* @__PURE__ */ jsx176(Separator13, {}),
55979
- /* @__PURE__ */ jsx176(CommentThread, { tableId, recordId }),
55980
- /* @__PURE__ */ jsx176(Separator13, {}),
55981
- /* @__PURE__ */ jsx176(
55982
- HistoryPanel,
55983
- {
55984
- tableId,
55985
- recordId,
55986
- onAskAboutField: (fieldKey) => onAskAboutField ? onAskAboutField(fieldKey) : setAsking(fieldKey)
55987
- }
55988
- ),
55989
- !onAskAboutField && asking ? /* @__PURE__ */ jsx176(FieldHistoryPanel, { tableId, fieldKey: asking, recordId, onClose: () => setAsking(null) }) : null
55995
+ /* @__PURE__ */ jsx176(CommentThread, { tableId, recordId }),
55996
+ /* @__PURE__ */ jsx176(Separator13, {}),
55997
+ /* @__PURE__ */ jsx176(
55998
+ HistoryPanel,
55999
+ {
56000
+ tableId,
56001
+ recordId,
56002
+ onAskAboutField: (fieldKey) => onAskAboutField ? onAskAboutField(fieldKey) : setAsking(fieldKey)
56003
+ }
56004
+ ),
56005
+ !onAskAboutField && asking ? /* @__PURE__ */ jsx176(FieldHistoryPanel, { tableId, fieldKey: asking, recordId, onClose: () => setAsking(null) }) : null
56006
+ ] }) : null
55990
56007
  ]
55991
56008
  }
55992
56009
  );
@@ -56510,6 +56527,7 @@ init_host();
56510
56527
 
56511
56528
  // src/toolbarFit.ts
56512
56529
  import { useEffect as useEffect130, useLayoutEffect as useLayoutEffect6, useState as useState155 } from "react";
56530
+ import { flushSync } from "react-dom";
56513
56531
  function widthAtFold(piece, fold) {
56514
56532
  for (let f = Math.min(fold, (piece.byFold?.length ?? 0) - 1); f >= 0; f -= 1) {
56515
56533
  const w = piece.byFold?.[f];
@@ -56609,7 +56627,7 @@ function useToolbarFit(row) {
56609
56627
  let current = 0;
56610
56628
  let pending = 0;
56611
56629
  let stopped = false;
56612
- const measure = () => {
56630
+ const measure = (sync = false) => {
56613
56631
  pending = 0;
56614
56632
  if (stopped) return;
56615
56633
  const available = row.clientWidth;
@@ -56629,12 +56647,13 @@ function useToolbarFit(row) {
56629
56647
  const next = toolbarFold({ available, needsNow: needs, gap, folded: current, look, chooser, tools, share });
56630
56648
  if (next !== current) {
56631
56649
  current = next;
56632
- setFold(next);
56650
+ if (sync) flushSync(() => setFold(next));
56651
+ else setFold(next);
56633
56652
  }
56634
56653
  };
56635
56654
  const schedule = () => {
56636
56655
  if (pending) return;
56637
- pending = typeof requestAnimationFrame === "function" ? requestAnimationFrame(measure) : setTimeout(measure, 0);
56656
+ pending = typeof requestAnimationFrame === "function" ? requestAnimationFrame(() => measure()) : setTimeout(() => measure(), 0);
56638
56657
  };
56639
56658
  const sizes = typeof ResizeObserver === "function" ? new ResizeObserver(schedule) : null;
56640
56659
  const watchSizes = () => {
@@ -56648,6 +56667,7 @@ function useToolbarFit(row) {
56648
56667
  };
56649
56668
  const content = new MutationObserver(() => {
56650
56669
  watchSizes();
56670
+ measure(true);
56651
56671
  schedule();
56652
56672
  });
56653
56673
  content.observe(row, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ["class", "style"] });