@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.js CHANGED
@@ -188,7 +188,7 @@ import {
188
188
  withoutLeadingBlank,
189
189
  workedOutErrorFor,
190
190
  workedOutHoldsNumbers
191
- } from "./chunk-D2FZEAYO.js";
191
+ } from "./chunk-P7GVWT6U.js";
192
192
  import {
193
193
  CHART_PLOT_PX,
194
194
  EMBEDDED_ROW_PX,
package/dist/pickers.cjs CHANGED
@@ -8173,12 +8173,36 @@ var import_design_system22 = require("@ai-matrx/design-system");
8173
8173
  init_host();
8174
8174
  var import_jsx_runtime26 = require("react/jsx-runtime");
8175
8175
  var answers = /* @__PURE__ */ new Map();
8176
+ function hostOf(url) {
8177
+ try {
8178
+ return new URL(url).hostname.replace(/^www\./, "");
8179
+ } catch {
8180
+ return url;
8181
+ }
8182
+ }
8183
+ function linkPreviewRecord(url, shown2) {
8184
+ const site = shown2.siteName?.trim() || hostOf(url);
8185
+ const title = shown2.title?.trim() || site;
8186
+ return {
8187
+ kind: "Link",
8188
+ id: url,
8189
+ showId: false,
8190
+ title,
8191
+ ...shown2.siteName || shown2.title ? { subtitle: site } : {},
8192
+ avatar: { initials: site.slice(0, 1).toUpperCase(), ...shown2.faviconUrl ? { src: shown2.faviconUrl } : {} },
8193
+ ...shown2.imageUrl ? { media: { alt: title, src: shown2.imageUrl, aspect: "16:9" } } : {},
8194
+ ...shown2.description ? { body: [{ section: "Description", text: shown2.description, clamp: 3 }] } : {},
8195
+ href: url,
8196
+ copyData: { url, title: shown2.title, description: shown2.description, site: shown2.siteName }
8197
+ };
8198
+ }
8176
8199
  function LinkPreviewCard({ url, children }) {
8177
8200
  const port = useRecordsUi().linkPreview;
8178
8201
  const [preview, setPreview] = (0, import_react34.useState)(void 0);
8179
8202
  const [open, setOpen] = (0, import_react34.useState)(false);
8180
- const timer = (0, import_react34.useRef)(null);
8181
- (0, import_react34.useEffect)(() => () => void (timer.current && clearTimeout(timer.current)), []);
8203
+ const shown2 = preview && (preview.title || preview.description || preview.imageUrl) ? preview : null;
8204
+ const record = (0, import_react34.useMemo)(() => shown2 ? linkPreviewRecord(url, shown2) : null, [url, shown2]);
8205
+ (0, import_react34.useEffect)(() => setPreview(void 0), [url]);
8182
8206
  if (!port) return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, { children });
8183
8207
  const ask = () => {
8184
8208
  if (preview !== void 0) return;
@@ -8189,31 +8213,23 @@ function LinkPreviewCard({ url, children }) {
8189
8213
  }
8190
8214
  void pending.then((found) => setPreview(found));
8191
8215
  };
8192
- const enter = () => {
8193
- ask();
8194
- if (timer.current) clearTimeout(timer.current);
8195
- timer.current = setTimeout(() => setOpen(true), 350);
8196
- };
8197
- const leave = () => {
8198
- if (timer.current) clearTimeout(timer.current);
8199
- setOpen(false);
8200
- };
8201
- const shown2 = preview && (preview.title || preview.description || preview.imageUrl) ? preview : null;
8202
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_design_system22.HoverCard, { open: open && shown2 !== null, onOpenChange: (next) => next ? void 0 : setOpen(false), children: [
8203
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_design_system22.HoverCardTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "inline-flex min-w-0 max-w-full", onMouseEnter: enter, onMouseLeave: leave, onFocus: enter, onBlur: leave, children }) }),
8204
- shown2 ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_design_system22.HoverCardContent, { align: "start", className: "w-72 space-y-1.5 p-2 text-xs", "data-records-link-preview": "", children: [
8205
- shown2.imageUrl ? (
8206
- // eslint-disable-next-line @next/next/no-img-element
8207
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("img", { src: shown2.imageUrl, alt: "", className: "h-28 w-full rounded object-cover", referrerPolicy: "no-referrer" })
8208
- ) : null,
8209
- /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex items-center gap-1.5", children: [
8210
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_design_system22.SiteIcon, { site: url, iconUrl: shown2.faviconUrl, className: "h-3.5 w-3.5" }),
8211
- /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "truncate text-muted-foreground", children: shown2.siteName ?? "" })
8212
- ] }),
8213
- shown2.title ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "line-clamp-2 font-medium", children: shown2.title }) : null,
8214
- shown2.description ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "line-clamp-3 text-muted-foreground", children: shown2.description }) : null
8215
- ] }) : null
8216
- ] });
8216
+ const chip = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "inline-flex min-w-0 max-w-full", onMouseEnter: ask, onFocus: ask, children });
8217
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
8218
+ import_design_system22.PeekHoverCard,
8219
+ {
8220
+ trigger: chip,
8221
+ label: record?.title ?? "Link",
8222
+ side: "bottom",
8223
+ align: "start",
8224
+ presentation: "float",
8225
+ open: open && record !== null,
8226
+ onOpenChange: (next) => {
8227
+ if (next) ask();
8228
+ setOpen(next);
8229
+ },
8230
+ children: record ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_design_system22.Peek, { record, size: "sm" }) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_jsx_runtime26.Fragment, {})
8231
+ }
8232
+ );
8217
8233
  }
8218
8234
 
8219
8235
  // src/formattedValue.tsx