@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/CHANGELOG.md CHANGED
@@ -1,10 +1,31 @@
1
1
  # Changelog — @ai-matrx/records-ui
2
2
 
3
- ## 0.115.100
3
+ ## 0.115.102
4
4
 
5
5
  UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
6
6
  Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/records-ui/src`.
7
7
 
8
+ ## 0.115.101
9
+
10
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
11
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
12
+ Diff: `git diff 6902500e6b 0840b10e27 -- apps/shared/records-ui/src`
13
+
14
+ Changed shipped source files (1):
15
+ - `apps/shared/records-ui/src/values.tsx`
16
+
17
+ ## 0.115.100
18
+
19
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
20
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
21
+ Diff: `git diff a97ec09caf 6902500e6b -- apps/shared/records-ui/src`
22
+
23
+ Changed shipped source files (4):
24
+ - `apps/shared/records-ui/src/Grid.tsx`
25
+ - `apps/shared/records-ui/src/gridEditing.tsx`
26
+ - `apps/shared/records-ui/src/gridOpen.tsx`
27
+ - `apps/shared/records-ui/src/values.tsx`
28
+
8
29
  ## 0.115.99
9
30
 
10
31
  SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
package/dist/index.cjs CHANGED
@@ -14478,9 +14478,8 @@ function renderValue(field2, value, document2, labels, stillWaitingFor, look, ro
14478
14478
  if (Array.isArray(value)) {
14479
14479
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "flex flex-wrap gap-1", children: value.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_design_system40.Badge, { variant: "secondary", className: "text-[11px]", children: scalarText(field2, item, labels) }, `${String(item)}-${i}`)) });
14480
14480
  }
14481
- if ((kind2 === "text" || kind2 === "url") && typeof value === "string" && isImageUrl2(value)) {
14482
- return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ImageUrlValue, { url: value.trim(), alt: field2.label || field2.key, room });
14483
- }
14481
+ const pictureAt = imageAddressOf(field2, value);
14482
+ if (pictureAt) return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ImageUrlValue, { url: pictureAt, alt: field2.label || field2.key, room });
14484
14483
  if (kind2 === "url" && typeof value === "string") {
14485
14484
  const href = value.includes("://") ? value : `https://${value}`;
14486
14485
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(LinkPreviewCard, { url: href, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
@@ -14530,6 +14529,15 @@ function isImageUrl2(value) {
14530
14529
  }
14531
14530
  return /\.(png|jpe?g|gif|webp|avif|svg|bmp|ico)$/i.test(url.pathname) || /\/(images?|img)\//i.test(url.pathname);
14532
14531
  }
14532
+ function imageAddressOf(field2, value) {
14533
+ if (typeof value !== "string") return null;
14534
+ const kind2 = editorKindFor(field2);
14535
+ if (kind2 !== "text" && kind2 !== "url") return null;
14536
+ const text = value.trim();
14537
+ if (isImageUrl2(text)) return text;
14538
+ const named = /(^|[^a-z])(logo|image|img|photo|picture|avatar|thumbnail|headshot)s?([^a-z]|$)/i.test(`${field2.label ?? ""} ${field2.key}`);
14539
+ return named && /^https?:\/\/[^\s]+$/i.test(text) ? text : null;
14540
+ }
14533
14541
  function ImageUrlValue({ url, alt, room }) {
14534
14542
  const host = useRecordsUi();
14535
14543
  const box = room === "full" ? "size-24" : "size-6";
@@ -14669,6 +14677,8 @@ function RecordValue({
14669
14677
  }
14670
14678
  }
14671
14679
  }
14680
+ const pictureAt = value !== null && value !== void 0 && !(0, import_core10.wholeValueOf)(document2, field2.key) && !envelopeFor(document2, field2.key)?.absent ? imageAddressOf(field2, value) : null;
14681
+ if (pictureAt) return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(ImageUrlValue, { url: pictureAt, alt: field2.label || field2.key, room });
14672
14682
  const shown5 = format ?? formatForField(field2);
14673
14683
  const shape = shown5 && (shown5.id === "date" || shown5.id === "datetime") && isDateField(field2) ? dateFormatFor(field2, value) : void 0;
14674
14684
  const dated = shape ? { ...shape, ...shown5?.options ? { options: shown5.options } : {} } : void 0;
@@ -30498,6 +30508,9 @@ function GridBody({
30498
30508
  }, [countedButNotReturned]);
30499
30509
  const askPerRow = Boolean(editable) && !host.rights && rights.known && !rights.write && rows.length > 0;
30500
30510
  const rowRights = useRowRights(rowIds, askPerRow);
30511
+ const rowRightsAnswered = (0, import_react168.useRef)(false);
30512
+ const rowRightsWaiting = askPerRow && !rowRightsAnswered.current && rowIds.length > 0 && rowRights(rowIds[0])?.known === false;
30513
+ if (askPerRow && !rowRightsWaiting) rowRightsAnswered.current = true;
30501
30514
  const mayWriteRow = (0, import_react168.useCallback)(
30502
30515
  (rowId) => askPerRow ? rowRights(rowId)?.write ?? false : rights.write,
30503
30516
  [askPerRow, rowRights, rights.write]
@@ -32054,7 +32067,7 @@ function GridBody({
32054
32067
  if (table.error) return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(RefusalNotice, { error: table.error, className });
32055
32068
  if (fields.error) return /* @__PURE__ */ (0, import_jsx_runtime99.jsx)(RefusalNotice, { error: fields.error, className });
32056
32069
  const nothingToShowYet = table.loading && !table.data || // No columns on a table whose level may hide them: not yet known which (one read, Confidential only).
32057
- !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.
32070
+ !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.
32058
32071
  !records.data && !records.error || countedButNotReturned || manual && hand.loading && rows.length === 0;
32059
32072
  const refreshing = !nothingToShowYet && (records.loading || manual && hand.loading);
32060
32073
  const structureLocked = !nothingToShowYet && (fields.data ?? []).length === 0 && structure.hidden;
@@ -53277,7 +53290,7 @@ function ReviewBlockView({ block, viewerUserId, extra }) {
53277
53290
  const name = block.title ?? table.data?.name ?? "Records";
53278
53291
  const neighbors = current ? neighborsOf(rows.map((r) => r.id), current.id) : null;
53279
53292
  if (read.error) return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(RefusalLine, { error: read.error });
53280
- if (read.waiting || read.loading && rows.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(import_design_system146.Skeleton, { className: "h-48 w-full" });
53293
+ if (read.waiting || read.loading && rows.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(import_design_system146.Skeleton, { className: "h-72 w-full" });
53281
53294
  if (rows.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime165.jsx)(BlockNote, { children: read.mine ? "Nothing assigned to you here." : "No records match." });
53282
53295
  return /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("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: [
53283
53296
  /* @__PURE__ */ (0, import_jsx_runtime165.jsxs)("div", { className: "flex min-w-0 flex-col rounded-md border bg-card", children: [
@@ -55985,6 +55998,8 @@ var import_jsx_runtime176 = require("react/jsx-runtime");
55985
55998
  function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = false, neighbors, onStep, expanded, onToggleExpand }) {
55986
55999
  const host = useRecordsUi();
55987
56000
  const [asking, setAsking] = (0, import_react317.useState)(null);
56001
+ const record = (0, import_react318.useRecord)(recordId, true, { tableId });
56002
+ const answered = Boolean(record.data) && !record.error;
55988
56003
  return /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(
55989
56004
  "div",
55990
56005
  {
@@ -56011,28 +56026,30 @@ function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = fal
56011
56026
  children: [
56012
56027
  neighbors && onStep ? /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(RecordStepper, { neighbors, onStep: (to) => onStep(to), expanded, onToggleExpand }) : null,
56013
56028
  /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(Peek, { tableId, recordId, onPage, ...onClose ? { onClose } : {} }),
56014
- onPage ? /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(import_jsx_runtime176.Fragment, { children: [
56015
- /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(RecordBody, { tableId, recordId }),
56016
- /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(LinkedLists, { tableId, recordId }),
56017
- /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(ReverseLinksSections, { tableId, recordId })
56018
- ] }) : null,
56019
- host.recordSections ? /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(import_react317.Fragment, { children: [
56029
+ answered ? /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(import_jsx_runtime176.Fragment, { children: [
56030
+ onPage ? /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(import_jsx_runtime176.Fragment, { children: [
56031
+ /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(RecordBody, { tableId, recordId }),
56032
+ /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(LinkedLists, { tableId, recordId }),
56033
+ /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(ReverseLinksSections, { tableId, recordId })
56034
+ ] }) : null,
56035
+ host.recordSections ? /* @__PURE__ */ (0, import_jsx_runtime176.jsxs)(import_react317.Fragment, { children: [
56036
+ /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(import_design_system157.Separator, {}),
56037
+ host.recordSections({ tableId, recordId })
56038
+ ] }) : null,
56039
+ /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(ChecklistRunner, { tableId, recordId, quietWhenEmpty: true, className: "border-t pt-3" }),
56020
56040
  /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(import_design_system157.Separator, {}),
56021
- host.recordSections({ tableId, recordId })
56022
- ] }) : null,
56023
- /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(ChecklistRunner, { tableId, recordId, quietWhenEmpty: true, className: "border-t pt-3" }),
56024
- /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(import_design_system157.Separator, {}),
56025
- /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(CommentThread, { tableId, recordId }),
56026
- /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(import_design_system157.Separator, {}),
56027
- /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
56028
- HistoryPanel,
56029
- {
56030
- tableId,
56031
- recordId,
56032
- onAskAboutField: (fieldKey) => onAskAboutField ? onAskAboutField(fieldKey) : setAsking(fieldKey)
56033
- }
56034
- ),
56035
- !onAskAboutField && asking ? /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(FieldHistoryPanel, { tableId, fieldKey: asking, recordId, onClose: () => setAsking(null) }) : null
56041
+ /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(CommentThread, { tableId, recordId }),
56042
+ /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(import_design_system157.Separator, {}),
56043
+ /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(
56044
+ HistoryPanel,
56045
+ {
56046
+ tableId,
56047
+ recordId,
56048
+ onAskAboutField: (fieldKey) => onAskAboutField ? onAskAboutField(fieldKey) : setAsking(fieldKey)
56049
+ }
56050
+ ),
56051
+ !onAskAboutField && asking ? /* @__PURE__ */ (0, import_jsx_runtime176.jsx)(FieldHistoryPanel, { tableId, fieldKey: asking, recordId, onClose: () => setAsking(null) }) : null
56052
+ ] }) : null
56036
56053
  ]
56037
56054
  }
56038
56055
  );
@@ -56545,6 +56562,7 @@ init_host();
56545
56562
 
56546
56563
  // src/toolbarFit.ts
56547
56564
  var import_react325 = require("react");
56565
+ var import_react_dom3 = require("react-dom");
56548
56566
  function widthAtFold(piece, fold) {
56549
56567
  for (let f = Math.min(fold, (piece.byFold?.length ?? 0) - 1); f >= 0; f -= 1) {
56550
56568
  const w = piece.byFold?.[f];
@@ -56644,7 +56662,7 @@ function useToolbarFit(row) {
56644
56662
  let current = 0;
56645
56663
  let pending = 0;
56646
56664
  let stopped = false;
56647
- const measure = () => {
56665
+ const measure = (sync = false) => {
56648
56666
  pending = 0;
56649
56667
  if (stopped) return;
56650
56668
  const available = row.clientWidth;
@@ -56664,12 +56682,13 @@ function useToolbarFit(row) {
56664
56682
  const next = toolbarFold({ available, needsNow: needs, gap, folded: current, look, chooser, tools, share });
56665
56683
  if (next !== current) {
56666
56684
  current = next;
56667
- setFold(next);
56685
+ if (sync) (0, import_react_dom3.flushSync)(() => setFold(next));
56686
+ else setFold(next);
56668
56687
  }
56669
56688
  };
56670
56689
  const schedule = () => {
56671
56690
  if (pending) return;
56672
- pending = typeof requestAnimationFrame === "function" ? requestAnimationFrame(measure) : setTimeout(measure, 0);
56691
+ pending = typeof requestAnimationFrame === "function" ? requestAnimationFrame(() => measure()) : setTimeout(() => measure(), 0);
56673
56692
  };
56674
56693
  const sizes = typeof ResizeObserver === "function" ? new ResizeObserver(schedule) : null;
56675
56694
  const watchSizes = () => {
@@ -56683,6 +56702,7 @@ function useToolbarFit(row) {
56683
56702
  };
56684
56703
  const content = new MutationObserver(() => {
56685
56704
  watchSizes();
56705
+ measure(true);
56686
56706
  schedule();
56687
56707
  });
56688
56708
  content.observe(row, { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ["class", "style"] });