@ai-matrx/records-ui 0.115.82 → 0.115.83

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
@@ -4002,23 +4002,24 @@ function useFileRead(id) {
4002
4002
  (0, import_react31.useEffect)(() => {
4003
4003
  let cancelled = false;
4004
4004
  if (handedHostFileIds.has(id)) {
4005
- setRead({ name: null, fileId: id, why: null });
4005
+ setRead({ name: null, fileId: id, why: null, mime: null });
4006
4006
  return;
4007
4007
  }
4008
4008
  if (!client) {
4009
- setRead({ name: null, fileId: null, why: null });
4009
+ setRead({ name: null, fileId: null, why: null, mime: null });
4010
4010
  return;
4011
4011
  }
4012
4012
  void client.recordRead({ record_id: id }).then((answered) => {
4013
4013
  if (cancelled) return;
4014
4014
  if (!answered.ok) {
4015
- setRead({ name: null, fileId: id, why: refusalSentence(answered.error) });
4015
+ setRead({ name: null, fileId: id, why: refusalSentence(answered.error), mime: null });
4016
4016
  return;
4017
4017
  }
4018
4018
  const doc = answered.data.document ?? {};
4019
4019
  const fileId = typeof doc["file_id"] === "string" ? doc["file_id"] : null;
4020
4020
  const name = typeof doc["name"] === "string" && doc["name"] !== "" ? doc["name"] : null;
4021
- setRead({ name, fileId, why: null });
4021
+ const mime = typeof doc["mime"] === "string" ? doc["mime"] : null;
4022
+ setRead({ name, fileId, why: null, mime });
4022
4023
  });
4023
4024
  return () => {
4024
4025
  cancelled = true;
@@ -4032,6 +4033,43 @@ function AttachmentChip({ id, onRemove, onPreview }) {
4032
4033
  const words = read?.name ?? (read ? FILE_CHIP_UNREAD : "\u2026");
4033
4034
  const href = read?.fileId ? host.hrefForFile?.({ fileId: read.fileId }) : void 0;
4034
4035
  const title = onPreview ? `Preview ${words}` : href ? `Open ${words}` : read?.why ?? FILE_CHIP_NO_PAGE;
4036
+ if (read?.fileId && read.mime?.startsWith("image/") && host.fileImage) {
4037
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { className: "relative inline-flex shrink-0", "data-records-file-thumb": id, children: [
4038
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4039
+ "button",
4040
+ {
4041
+ type: "button",
4042
+ title,
4043
+ "aria-label": onPreview ? `Preview ${words}` : words,
4044
+ className: (0, import_design_system19.cn)(
4045
+ "relative block size-20 overflow-hidden rounded-md border bg-muted",
4046
+ "[[data-matrx-cell-lines]_&]:size-6 [[data-matrx-cell-lines=two]_&]:size-10 [[data-matrx-cell-lines=four]_&]:size-[4.5rem] [[data-matrx-cell-lines=six]_&]:size-24"
4047
+ ),
4048
+ onClick: (event) => {
4049
+ event.stopPropagation();
4050
+ onPreview?.();
4051
+ },
4052
+ onMouseDown: (event) => event.stopPropagation(),
4053
+ onDoubleClick: (event) => event.stopPropagation(),
4054
+ ...onPreview ? { "data-records-file-preview": id } : {},
4055
+ children: host.fileImage({ fileId: read.fileId, alt: words })
4056
+ }
4057
+ ),
4058
+ onRemove ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
4059
+ "button",
4060
+ {
4061
+ type: "button",
4062
+ "aria-label": `Remove ${words}`,
4063
+ className: "absolute -right-1 -top-1 rounded-full border bg-background px-1 text-[10px] leading-4 text-muted-foreground hover:text-foreground",
4064
+ onClick: (event) => {
4065
+ event.stopPropagation();
4066
+ onRemove();
4067
+ },
4068
+ children: "\xD7"
4069
+ }
4070
+ ) : null
4071
+ ] });
4072
+ }
4035
4073
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)(
4036
4074
  import_design_system19.Badge,
4037
4075
  {