@ai-matrx/records-ui 0.115.81 → 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.js CHANGED
@@ -4066,23 +4066,24 @@ function useFileRead(id) {
4066
4066
  useEffect11(() => {
4067
4067
  let cancelled = false;
4068
4068
  if (handedHostFileIds.has(id)) {
4069
- setRead({ name: null, fileId: id, why: null });
4069
+ setRead({ name: null, fileId: id, why: null, mime: null });
4070
4070
  return;
4071
4071
  }
4072
4072
  if (!client) {
4073
- setRead({ name: null, fileId: null, why: null });
4073
+ setRead({ name: null, fileId: null, why: null, mime: null });
4074
4074
  return;
4075
4075
  }
4076
4076
  void client.recordRead({ record_id: id }).then((answered) => {
4077
4077
  if (cancelled) return;
4078
4078
  if (!answered.ok) {
4079
- setRead({ name: null, fileId: id, why: refusalSentence(answered.error) });
4079
+ setRead({ name: null, fileId: id, why: refusalSentence(answered.error), mime: null });
4080
4080
  return;
4081
4081
  }
4082
4082
  const doc = answered.data.document ?? {};
4083
4083
  const fileId = typeof doc["file_id"] === "string" ? doc["file_id"] : null;
4084
4084
  const name = typeof doc["name"] === "string" && doc["name"] !== "" ? doc["name"] : null;
4085
- setRead({ name, fileId, why: null });
4085
+ const mime = typeof doc["mime"] === "string" ? doc["mime"] : null;
4086
+ setRead({ name, fileId, why: null, mime });
4086
4087
  });
4087
4088
  return () => {
4088
4089
  cancelled = true;
@@ -4096,6 +4097,43 @@ function AttachmentChip({ id, onRemove, onPreview }) {
4096
4097
  const words = read?.name ?? (read ? FILE_CHIP_UNREAD : "\u2026");
4097
4098
  const href = read?.fileId ? host.hrefForFile?.({ fileId: read.fileId }) : void 0;
4098
4099
  const title = onPreview ? `Preview ${words}` : href ? `Open ${words}` : read?.why ?? FILE_CHIP_NO_PAGE;
4100
+ if (read?.fileId && read.mime?.startsWith("image/") && host.fileImage) {
4101
+ return /* @__PURE__ */ jsxs19("span", { className: "relative inline-flex shrink-0", "data-records-file-thumb": id, children: [
4102
+ /* @__PURE__ */ jsx21(
4103
+ "button",
4104
+ {
4105
+ type: "button",
4106
+ title,
4107
+ "aria-label": onPreview ? `Preview ${words}` : words,
4108
+ className: cn17(
4109
+ "relative block size-20 overflow-hidden rounded-md border bg-muted",
4110
+ "[[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"
4111
+ ),
4112
+ onClick: (event) => {
4113
+ event.stopPropagation();
4114
+ onPreview?.();
4115
+ },
4116
+ onMouseDown: (event) => event.stopPropagation(),
4117
+ onDoubleClick: (event) => event.stopPropagation(),
4118
+ ...onPreview ? { "data-records-file-preview": id } : {},
4119
+ children: host.fileImage({ fileId: read.fileId, alt: words })
4120
+ }
4121
+ ),
4122
+ onRemove ? /* @__PURE__ */ jsx21(
4123
+ "button",
4124
+ {
4125
+ type: "button",
4126
+ "aria-label": `Remove ${words}`,
4127
+ className: "absolute -right-1 -top-1 rounded-full border bg-background px-1 text-[10px] leading-4 text-muted-foreground hover:text-foreground",
4128
+ onClick: (event) => {
4129
+ event.stopPropagation();
4130
+ onRemove();
4131
+ },
4132
+ children: "\xD7"
4133
+ }
4134
+ ) : null
4135
+ ] });
4136
+ }
4099
4137
  return /* @__PURE__ */ jsxs19(
4100
4138
  Badge3,
4101
4139
  {