@natoe/colab 0.1.5 → 0.1.6

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.d.mts CHANGED
@@ -141,9 +141,9 @@ interface Message {
141
141
  interface SendMessagePayload {
142
142
  body: string;
143
143
  type: MessageType;
144
- mediaUrl?: string;
145
- mediaDuration?: number;
146
- fileName?: string;
144
+ media_url?: string;
145
+ media_duration?: number;
146
+ file_name?: string;
147
147
  metadata?: Record<string, unknown>;
148
148
  /** ID of message being replied to (snapshot is built server-side) */
149
149
  replyToId?: string;
@@ -200,6 +200,8 @@ interface CollabPopupProps {
200
200
  isOpen: boolean;
201
201
  /** Close the popup */
202
202
  onClose: () => void;
203
+ /** Optional back navigation — renders a ← button in the title bar when provided */
204
+ onBack?: () => void;
203
205
  /** Initial position (defaults to bottom-right) */
204
206
  initialPosition?: {
205
207
  x: number;
@@ -215,7 +217,7 @@ interface CollabPopupProps {
215
217
  * Draggable floating chat popup — drop-in replacement for DraggableChatPopup.
216
218
  * Renders a CollabPanel inside a movable, resizable container.
217
219
  */
218
- declare function CollabPopup({ orderId, patientData, participantIds, isOpen, onClose, initialPosition, width, height, className, }: CollabPopupProps): react_jsx_runtime.JSX.Element | null;
220
+ declare function CollabPopup({ orderId, patientData, participantIds, isOpen, onClose, onBack, initialPosition, width, height, className, }: CollabPopupProps): react_jsx_runtime.JSX.Element | null;
219
221
 
220
222
  interface CollabInlineProps {
221
223
  orderId: string;
package/dist/index.d.ts CHANGED
@@ -141,9 +141,9 @@ interface Message {
141
141
  interface SendMessagePayload {
142
142
  body: string;
143
143
  type: MessageType;
144
- mediaUrl?: string;
145
- mediaDuration?: number;
146
- fileName?: string;
144
+ media_url?: string;
145
+ media_duration?: number;
146
+ file_name?: string;
147
147
  metadata?: Record<string, unknown>;
148
148
  /** ID of message being replied to (snapshot is built server-side) */
149
149
  replyToId?: string;
@@ -200,6 +200,8 @@ interface CollabPopupProps {
200
200
  isOpen: boolean;
201
201
  /** Close the popup */
202
202
  onClose: () => void;
203
+ /** Optional back navigation — renders a ← button in the title bar when provided */
204
+ onBack?: () => void;
203
205
  /** Initial position (defaults to bottom-right) */
204
206
  initialPosition?: {
205
207
  x: number;
@@ -215,7 +217,7 @@ interface CollabPopupProps {
215
217
  * Draggable floating chat popup — drop-in replacement for DraggableChatPopup.
216
218
  * Renders a CollabPanel inside a movable, resizable container.
217
219
  */
218
- declare function CollabPopup({ orderId, patientData, participantIds, isOpen, onClose, initialPosition, width, height, className, }: CollabPopupProps): react_jsx_runtime.JSX.Element | null;
220
+ declare function CollabPopup({ orderId, patientData, participantIds, isOpen, onClose, onBack, initialPosition, width, height, className, }: CollabPopupProps): react_jsx_runtime.JSX.Element | null;
219
221
 
220
222
  interface CollabInlineProps {
221
223
  orderId: string;
package/dist/index.js CHANGED
@@ -376,7 +376,9 @@ function CollabProvider({ config, apiBaseUrl, children }) {
376
376
  const data = snakeToCamel(await response.json());
377
377
  orderIds.forEach((orderId) => {
378
378
  const preview = data.previews[orderId] ?? null;
379
- previewCache.current.set(orderId, preview);
379
+ if (preview !== null) {
380
+ previewCache.current.set(orderId, preview);
381
+ }
380
382
  resolvers.get(orderId)?.forEach((resolve) => resolve(preview));
381
383
  });
382
384
  } catch (error) {
@@ -423,7 +425,8 @@ function CollabProvider({ config, apiBaseUrl, children }) {
423
425
  if (!response.ok) {
424
426
  throw { code: "FETCH_ERROR", message: "Failed to fetch messages", status: response.status };
425
427
  }
426
- return snakeToCamel(await response.json());
428
+ const msgs = snakeToCamel(await response.json());
429
+ return msgs.sort((a, b) => a.insertedAt.localeCompare(b.insertedAt));
427
430
  },
428
431
  [apiBaseUrl, authHeaders]
429
432
  );
@@ -897,8 +900,8 @@ function useConversation({
897
900
  const payload = {
898
901
  body: "Voice message",
899
902
  type: "audio",
900
- mediaUrl: url,
901
- mediaDuration: duration
903
+ media_url: url,
904
+ media_duration: duration
902
905
  };
903
906
  const { conv, persistedByCreate } = await ensureConversation(payload);
904
907
  if (persistedByCreate) return;
@@ -914,8 +917,8 @@ function useConversation({
914
917
  const payload = {
915
918
  body: file.name,
916
919
  type: isImage ? "image" : "file",
917
- mediaUrl: url,
918
- fileName: file.name
920
+ media_url: url,
921
+ file_name: file.name
919
922
  };
920
923
  const { conv, persistedByCreate } = await ensureConversation(payload);
921
924
  if (persistedByCreate) return;
@@ -3655,6 +3658,7 @@ function CollabPopup({
3655
3658
  participantIds,
3656
3659
  isOpen,
3657
3660
  onClose,
3661
+ onBack,
3658
3662
  initialPosition,
3659
3663
  width = 380,
3660
3664
  height = 520,
@@ -3764,7 +3768,18 @@ function CollabPopup({
3764
3768
  onMouseDown: handleMouseDown,
3765
3769
  children: [
3766
3770
  /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-drag-handle": true, style: styles13.titleBar, children: [
3767
- /* @__PURE__ */ jsxRuntime.jsx("span", { id: titleId, style: styles13.titleText, children: buildChannelName(patientData) }),
3771
+ onBack && /* @__PURE__ */ jsxRuntime.jsx(
3772
+ "button",
3773
+ {
3774
+ onClick: onBack,
3775
+ style: styles13.titleButton,
3776
+ "aria-label": "Go back",
3777
+ title: "Back",
3778
+ type: "button",
3779
+ children: "\u2190"
3780
+ }
3781
+ ),
3782
+ /* @__PURE__ */ jsxRuntime.jsx("span", { id: titleId, style: { ...styles13.titleText, flex: 1 }, children: buildChannelName(patientData) }),
3768
3783
  /* @__PURE__ */ jsxRuntime.jsxs("div", { style: styles13.titleActions, children: [
3769
3784
  /* @__PURE__ */ jsxRuntime.jsx(
3770
3785
  "button",
@@ -4051,8 +4066,8 @@ function useInlineCollab({
4051
4066
  await dispatchSend({
4052
4067
  body: "Voice message",
4053
4068
  type: "audio",
4054
- mediaUrl: url,
4055
- mediaDuration: duration
4069
+ media_url: url,
4070
+ media_duration: duration
4056
4071
  });
4057
4072
  } catch (err) {
4058
4073
  setError(err instanceof Error ? err.message : "Failed to send voice message");