@ai-matrx/records-ui 0.116.76 → 0.116.77

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.cjs CHANGED
@@ -8261,7 +8261,7 @@ __export(src_exports, {
8261
8261
  PROPOSED_CHANGE_ACT_VALUES: () => PROPOSED_CHANGE_ACT_VALUES,
8262
8262
  PageCanvas: () => PageCanvas,
8263
8263
  PageScreen: () => PageScreen,
8264
- Peek: () => Peek2,
8264
+ Peek: () => Peek3,
8265
8265
  PersonPicker: () => PersonPicker,
8266
8266
  PickOrAdd: () => PickOrAdd,
8267
8267
  PipelineBoard: () => PipelineBoard,
@@ -15135,12 +15135,36 @@ var import_design_system26 = require("@ai-matrx/design-system");
15135
15135
  init_host();
15136
15136
  var import_jsx_runtime32 = require("react/jsx-runtime");
15137
15137
  var answers = /* @__PURE__ */ new Map();
15138
+ function hostOf(url) {
15139
+ try {
15140
+ return new URL(url).hostname.replace(/^www\./, "");
15141
+ } catch {
15142
+ return url;
15143
+ }
15144
+ }
15145
+ function linkPreviewRecord(url, shown5) {
15146
+ const site = shown5.siteName?.trim() || hostOf(url);
15147
+ const title = shown5.title?.trim() || site;
15148
+ return {
15149
+ kind: "Link",
15150
+ id: url,
15151
+ showId: false,
15152
+ title,
15153
+ ...shown5.siteName || shown5.title ? { subtitle: site } : {},
15154
+ avatar: { initials: site.slice(0, 1).toUpperCase(), ...shown5.faviconUrl ? { src: shown5.faviconUrl } : {} },
15155
+ ...shown5.imageUrl ? { media: { alt: title, src: shown5.imageUrl, aspect: "16:9" } } : {},
15156
+ ...shown5.description ? { body: [{ section: "Description", text: shown5.description, clamp: 3 }] } : {},
15157
+ href: url,
15158
+ copyData: { url, title: shown5.title, description: shown5.description, site: shown5.siteName }
15159
+ };
15160
+ }
15138
15161
  function LinkPreviewCard({ url, children }) {
15139
15162
  const port = useRecordsUi().linkPreview;
15140
15163
  const [preview, setPreview] = (0, import_react48.useState)(void 0);
15141
15164
  const [open, setOpen] = (0, import_react48.useState)(false);
15142
- const timer = (0, import_react48.useRef)(null);
15143
- (0, import_react48.useEffect)(() => () => void (timer.current && clearTimeout(timer.current)), []);
15165
+ const shown5 = preview && (preview.title || preview.description || preview.imageUrl) ? preview : null;
15166
+ const record = (0, import_react48.useMemo)(() => shown5 ? linkPreviewRecord(url, shown5) : null, [url, shown5]);
15167
+ (0, import_react48.useEffect)(() => setPreview(void 0), [url]);
15144
15168
  if (!port) return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, { children });
15145
15169
  const ask2 = () => {
15146
15170
  if (preview !== void 0) return;
@@ -15151,31 +15175,23 @@ function LinkPreviewCard({ url, children }) {
15151
15175
  }
15152
15176
  void pending.then((found) => setPreview(found));
15153
15177
  };
15154
- const enter = () => {
15155
- ask2();
15156
- if (timer.current) clearTimeout(timer.current);
15157
- timer.current = setTimeout(() => setOpen(true), 350);
15158
- };
15159
- const leave = () => {
15160
- if (timer.current) clearTimeout(timer.current);
15161
- setOpen(false);
15162
- };
15163
- const shown5 = preview && (preview.title || preview.description || preview.imageUrl) ? preview : null;
15164
- return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_design_system26.HoverCard, { open: open && shown5 !== null, onOpenChange: (next) => next ? void 0 : setOpen(false), children: [
15165
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system26.HoverCardTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "inline-flex min-w-0 max-w-full", onMouseEnter: enter, onMouseLeave: leave, onFocus: enter, onBlur: leave, children }) }),
15166
- shown5 ? /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_design_system26.HoverCardContent, { align: "start", className: "w-72 space-y-1.5 p-2 text-xs", "data-records-link-preview": "", children: [
15167
- shown5.imageUrl ? (
15168
- // eslint-disable-next-line @next/next/no-img-element
15169
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("img", { src: shown5.imageUrl, alt: "", className: "h-28 w-full rounded object-cover", referrerPolicy: "no-referrer" })
15170
- ) : null,
15171
- /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center gap-1.5", children: [
15172
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system26.SiteIcon, { site: url, iconUrl: shown5.faviconUrl, className: "h-3.5 w-3.5" }),
15173
- /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "truncate text-muted-foreground", children: shown5.siteName ?? "" })
15174
- ] }),
15175
- shown5.title ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "line-clamp-2 font-medium", children: shown5.title }) : null,
15176
- shown5.description ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "line-clamp-3 text-muted-foreground", children: shown5.description }) : null
15177
- ] }) : null
15178
- ] });
15178
+ const chip = /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("span", { className: "inline-flex min-w-0 max-w-full", onMouseEnter: ask2, onFocus: ask2, children });
15179
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
15180
+ import_design_system26.PeekHoverCard,
15181
+ {
15182
+ trigger: chip,
15183
+ label: record?.title ?? "Link",
15184
+ side: "bottom",
15185
+ align: "start",
15186
+ presentation: "float",
15187
+ open: open && record !== null,
15188
+ onOpenChange: (next) => {
15189
+ if (next) ask2();
15190
+ setOpen(next);
15191
+ },
15192
+ children: record ? /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_design_system26.Peek, { record, size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_jsx_runtime32.Fragment, {})
15193
+ }
15194
+ );
15179
15195
  }
15180
15196
 
15181
15197
  // src/formattedValue.tsx
@@ -37594,7 +37610,7 @@ var import_jsx_runtime126 = require("react/jsx-runtime");
37594
37610
  function drawnBelowOnPage(field2, bodyKey) {
37595
37611
  return field2.key === bodyKey || editorKindFor(field2) === "relation";
37596
37612
  }
37597
- function Peek2({ tableId, recordId, onClose, className, onPage = false }) {
37613
+ function Peek3({ tableId, recordId, onClose, className, onPage = false }) {
37598
37614
  usePeopleTick();
37599
37615
  const table = (0, import_react209.useTable)(tableId);
37600
37616
  const fields = (0, import_react209.useFields)(tableId);
@@ -39883,7 +39899,7 @@ function RecordPanel({ tableId, recordId, onClose, onAskAboutField, onPage = fal
39883
39899
  },
39884
39900
  children: [
39885
39901
  neighbors && onStep ? /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(RecordStepper, { neighbors, onStep: (to) => onStep(to), expanded, onToggleExpand, full, onToggleFull }) : null,
39886
- /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Peek2, { tableId, recordId, onPage, ...onClose ? { onClose } : {} }),
39902
+ /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(Peek3, { tableId, recordId, onPage, ...onClose ? { onClose } : {} }),
39887
39903
  answered ? /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { children: [
39888
39904
  onPage ? /* @__PURE__ */ (0, import_jsx_runtime135.jsxs)(import_jsx_runtime135.Fragment, { children: [
39889
39905
  /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(RecordBody, { tableId, recordId }),
@@ -59374,7 +59390,7 @@ function BlockBody(inner2) {
59374
59390
  function RecordPanelView({ tableId, recordId, row, listId }) {
59375
59391
  const door = useInterfaceDoor();
59376
59392
  const through = useDoorRows(door, listId);
59377
- if (!door) return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(Peek2, { tableId, recordId }, recordId);
59393
+ if (!door) return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(Peek3, { tableId, recordId }, recordId);
59378
59394
  if (!row) return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(BlockNote, { children: "Pick a record in the list." });
59379
59395
  return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(RecordDetail, { row, all: through.fields, groups: void 0 });
59380
59396
  }
@@ -59602,7 +59618,7 @@ function ReviewBlockView({ block, viewerUserId, extra }) {
59602
59618
  /* @__PURE__ */ (0, import_jsx_runtime194.jsx)("span", { className: "min-w-0 flex-1 truncate text-sm font-medium", children: rowNameIn(table.data ?? null, current) }),
59603
59619
  neighbors ? /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(RecordStepper, { neighbors, onStep: (to) => setChosen(to) }) : null
59604
59620
  ] }),
59605
- block.field_groups && block.field_groups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(RecordDetail, { row: current, all, groups: block.field_groups }) : door ? /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(RecordDetail, { row: current, all, groups: void 0 }) : /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(Peek2, { tableId: block.table_id, recordId: current.id }, current.id)
59621
+ block.field_groups && block.field_groups.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(RecordDetail, { row: current, all, groups: block.field_groups }) : door ? /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(RecordDetail, { row: current, all, groups: void 0 }) : /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(Peek3, { tableId: block.table_id, recordId: current.id }, current.id)
59606
59622
  ] }) : null
59607
59623
  ] });
59608
59624
  }
@@ -59695,7 +59711,7 @@ function MemberLayoutView({ block, viewerUserId, extra }) {
59695
59711
  onOpenRecord: (id) => setOpen(id)
59696
59712
  }
59697
59713
  ),
59698
- open ? /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(Peek2, { tableId: block.table_id, recordId: open, onClose: () => setOpen(null) }, open) : null
59714
+ open ? /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(Peek3, { tableId: block.table_id, recordId: open, onClose: () => setOpen(null) }, open) : null
59699
59715
  ] });
59700
59716
  }
59701
59717
  function DoorLayoutView({ block, door }) {
@@ -61710,7 +61726,7 @@ function PortalShell({ tableId, form, resourceType = "record", className }) {
61710
61726
  ] });
61711
61727
  }
61712
61728
  if (open) {
61713
- return /* @__PURE__ */ (0, import_jsx_runtime200.jsx)("section", { className: (0, import_design_system176.cn)("flex min-h-0 flex-col gap-2", className), children: /* @__PURE__ */ (0, import_jsx_runtime200.jsx)(Peek2, { tableId, recordId: open, onClose: () => setOpen(null) }) });
61729
+ return /* @__PURE__ */ (0, import_jsx_runtime200.jsx)("section", { className: (0, import_design_system176.cn)("flex min-h-0 flex-col gap-2", className), children: /* @__PURE__ */ (0, import_jsx_runtime200.jsx)(Peek3, { tableId, recordId: open, onClose: () => setOpen(null) }) });
61714
61730
  }
61715
61731
  return /* @__PURE__ */ (0, import_jsx_runtime200.jsxs)("section", { className: (0, import_design_system176.cn)("flex min-h-0 flex-col gap-2", className), children: [
61716
61732
  /* @__PURE__ */ (0, import_jsx_runtime200.jsxs)("header", { className: "flex items-center gap-2 text-xs text-muted-foreground", children: [