@medipha/chat 1.0.66 → 1.0.67

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
@@ -80218,10 +80218,14 @@ function Gle({ conversationId: e, index: t, isWindowVisible: n, isExpanded: r, i
80218
80218
  }
80219
80219
  //#endregion
80220
80220
  //#region src/module/widget/widget-chat-shell.tsx
80221
- function Kle({ isWindowVisible: e, isExpanded: t, openConversationIds: n, windowCapacity: r, focusedConversationId: i, composerFocusRequest: a, onToggleExpand: o, onOpenConversation: s, onCloseConversation: c, onFocusConversation: l, onOpenFullPage: u, onRequestClose: f }) {
80222
- let { currentUserId: p, userProfile: m, startDirectChat: h } = s2(), [g, _] = b(null), v = nh((e) => g ? e.conversations.find((e) => H(Lc(e), g)) ?? null : null), y = n.slice(Math.max(0, n.length - r)), x = d((e, t) => {
80223
- _(t), m.openProfile(e);
80224
- }, [m]), S = f ? /* @__PURE__ */ A("button", {
80221
+ function Kle({ isWindowVisible: e, isExpanded: t, openConversationIds: n, windowCapacity: r, focusedConversationId: i, composerFocusRequest: a, onToggleExpand: o, onOpenConversation: s, onCloseConversation: c, onFocusConversation: l, onOpenFullPage: u, onRequestClose: f, openProfileRequest: p }) {
80222
+ let { currentUserId: h, userProfile: g, startDirectChat: _ } = s2(), [v, y] = b(null), { openProfile: x } = g;
80223
+ m(() => {
80224
+ p && (y(null), x(p.userId));
80225
+ }, [p, x]);
80226
+ let S = nh((e) => v ? e.conversations.find((e) => H(Lc(e), v)) ?? null : null), C = n.slice(Math.max(0, n.length - r)), w = d((e, t) => {
80227
+ y(t), g.openProfile(e);
80228
+ }, [g]), T = f ? /* @__PURE__ */ A("button", {
80225
80229
  type: "button",
80226
80230
  className: "conversation-widget-close",
80227
80231
  "aria-label": "Đóng khung chat",
@@ -80241,19 +80245,19 @@ function Kle({ isWindowVisible: e, isExpanded: t, openConversationIds: n, window
80241
80245
  "aria-pressed": t,
80242
80246
  onClick: o,
80243
80247
  children: A(t ? Ut : Bt, {})
80244
- }), t ? S : null] }),
80248
+ }), t ? T : null] }),
80245
80249
  footerAction: t ? u ? /* @__PURE__ */ j("button", {
80246
80250
  type: "button",
80247
80251
  className: "conversation-widget-view-all",
80248
80252
  onClick: () => u(void 0),
80249
80253
  children: ["Xem Tất Cả", /* @__PURE__ */ A(Cr, {})]
80250
- }) : null : S
80254
+ }) : null : T
80251
80255
  }),
80252
- y.map((n, r) => {
80256
+ C.map((n, r) => {
80253
80257
  let o = H(i ?? "", n), d = H(a?.conversationId ?? "", n);
80254
80258
  return /* @__PURE__ */ A(Wle, {
80255
80259
  conversationId: n,
80256
- index: y.length - 1 - r,
80260
+ index: C.length - 1 - r,
80257
80261
  isWindowVisible: e,
80258
80262
  isExpanded: t,
80259
80263
  isFocused: o,
@@ -80261,16 +80265,16 @@ function Kle({ isWindowVisible: e, isExpanded: t, openConversationIds: n, window
80261
80265
  onOpenConversation: s,
80262
80266
  onCloseConversation: c,
80263
80267
  onFocusConversation: l,
80264
- onOpenUserProfile: x,
80268
+ onOpenUserProfile: w,
80265
80269
  onOpenFullPage: u
80266
80270
  }, n);
80267
80271
  }),
80268
80272
  /* @__PURE__ */ A(c2, {
80269
- profileUserId: m.profileUserId,
80270
- conversation: v,
80271
- currentUserId: p,
80272
- onClose: () => m.closeProfile(),
80273
- onStartChat: h
80273
+ profileUserId: g.profileUserId,
80274
+ conversation: S,
80275
+ currentUserId: h,
80276
+ onClose: () => g.closeProfile(),
80277
+ onStartChat: _
80274
80278
  })
80275
80279
  ] });
80276
80280
  }
@@ -80297,58 +80301,59 @@ function Qle(e) {
80297
80301
  }
80298
80302
  var $le = 200, A2 = 3;
80299
80303
  function eue(e) {
80300
- let { isOpen: t = !0, onActiveConversationChange: n, onExpandChange: r, onOpenFullPage: i, onRequestClose: a, onUnreadTotalChange: o } = e, [s, c] = b([]), [l, u] = b(void 0), [f, p] = b(null), [h, g] = b(!1), [_, v] = b(!1), x = y(null), S = nh((e) => Qle(e.conversations)), C = h || _, w = Zle(C, A2), T = s[s.length - 1], E = d((e) => {
80301
- c((t) => {
80304
+ let { isOpen: t = !0, openProfileRequest: n, onActiveConversationChange: r, onExpandChange: i, onOpenFullPage: a, onRequestClose: o, onUnreadTotalChange: s } = e, [c, l] = b([]), [u, f] = b(void 0), [p, h] = b(null), [g, _] = b(!1), [v, x] = b(!1), S = y(null), C = nh((e) => Qle(e.conversations)), w = g || v, T = Zle(w, A2), E = c[c.length - 1], D = d((e) => {
80305
+ l((t) => {
80302
80306
  if (t.some((t) => H(t, e))) return t;
80303
80307
  let n = [...t, e];
80304
80308
  return n.slice(Math.max(0, n.length - A2));
80305
- }), u(e), p((t) => ({
80309
+ }), f(e), h((t) => ({
80306
80310
  conversationId: e,
80307
80311
  nonce: (t?.nonce ?? 0) + 1
80308
80312
  }));
80309
- }, []), D = d((e) => {
80310
- c((t) => t.filter((t) => !H(t, e))), u((t) => H(t ?? "", e) ? void 0 : t);
80311
80313
  }, []), O = d((e) => {
80312
- u((t) => H(t ?? "", e) ? t : e);
80314
+ l((t) => t.filter((t) => !H(t, e))), f((t) => H(t ?? "", e) ? void 0 : t);
80313
80315
  }, []), k = d((e) => {
80314
- c([]), u(void 0), p(null), i?.(e);
80315
- }, [i]);
80316
+ f((t) => H(t ?? "", e) ? t : e);
80317
+ }, []), j = d((e) => {
80318
+ l([]), f(void 0), h(null), a?.(e);
80319
+ }, [a]);
80316
80320
  return m(() => {
80317
- n?.(T);
80318
- }, [T, n]), m(() => {
80319
- o?.(S);
80320
- }, [S, o]), m(() => {
80321
- r?.(h);
80322
- }, [h, r]), m(() => () => {
80323
- x.current && clearTimeout(x.current);
80321
+ r?.(E);
80322
+ }, [E, r]), m(() => {
80323
+ s?.(C);
80324
+ }, [C, s]), m(() => {
80325
+ i?.(g);
80326
+ }, [g, i]), m(() => () => {
80327
+ S.current && clearTimeout(S.current);
80324
80328
  }, []), /* @__PURE__ */ A(k2, {
80325
80329
  runtimeProps: e,
80326
- rootClassName: `med-chat-widget${C ? " is-rail-expanded" : ""}${_ ? " is-rail-closing" : ""}`,
80330
+ rootClassName: `med-chat-widget${w ? " is-rail-expanded" : ""}${v ? " is-rail-closing" : ""}`,
80327
80331
  children: /* @__PURE__ */ A(Vle, {
80328
- openConversationIds: s,
80329
- onOpenConversation: E,
80330
- onCloseConversation: D,
80332
+ openConversationIds: c,
80333
+ onOpenConversation: D,
80334
+ onCloseConversation: O,
80331
80335
  children: /* @__PURE__ */ A(Kle, {
80332
80336
  isWindowVisible: t,
80333
- isExpanded: C,
80334
- openConversationIds: s,
80335
- windowCapacity: w,
80336
- focusedConversationId: l,
80337
- composerFocusRequest: f,
80337
+ isExpanded: w,
80338
+ openConversationIds: c,
80339
+ windowCapacity: T,
80340
+ focusedConversationId: u,
80341
+ composerFocusRequest: p,
80338
80342
  onToggleExpand: () => {
80339
- if (x.current &&= (clearTimeout(x.current), null), !h) {
80340
- v(!1), g(!0);
80343
+ if (S.current &&= (clearTimeout(S.current), null), !g) {
80344
+ x(!1), _(!0);
80341
80345
  return;
80342
80346
  }
80343
- v(!0), x.current = setTimeout(() => {
80344
- g(!1), v(!1), x.current = null;
80347
+ x(!0), S.current = setTimeout(() => {
80348
+ _(!1), x(!1), S.current = null;
80345
80349
  }, $le);
80346
80350
  },
80347
- onOpenConversation: E,
80348
- onCloseConversation: D,
80349
- onFocusConversation: O,
80350
- onOpenFullPage: i ? k : void 0,
80351
- onRequestClose: a
80351
+ onOpenConversation: D,
80352
+ onCloseConversation: O,
80353
+ onFocusConversation: k,
80354
+ onOpenFullPage: a ? j : void 0,
80355
+ onRequestClose: o,
80356
+ openProfileRequest: n
80352
80357
  })
80353
80358
  })
80354
80359
  });
@@ -3,12 +3,20 @@ export interface WidgetFocusRequest {
3
3
  conversationId: string;
4
4
  nonce: number;
5
5
  }
6
+ /** Asks the widget to show a colleague's "Thông tin tài khoản" dialog (with its "Nhắn tin" button). */
7
+ export interface WidgetProfileRequest {
8
+ userId: string;
9
+ /** Change it on every request so asking for the same person again opens the dialog again. */
10
+ nonce: number;
11
+ }
6
12
  export interface ChatWidgetProps extends ChatModuleProps {
7
13
  /** Whether the host is currently showing the widget. Keep the widget mounted while this
8
14
  * is false — the conversation list stays warm and onUnreadTotalChange keeps reporting —
9
15
  * but the floating chat window is withheld, since it is portalled out of whatever box
10
16
  * the host hides. Defaults to true. */
11
17
  isOpen?: boolean;
18
+ /** Lets the host (e.g. the newsfeed) open a user's profile dialog inside this widget. */
19
+ openProfileRequest?: WidgetProfileRequest;
12
20
  onActiveConversationChange?: (conversationId: string | undefined) => void;
13
21
  onExpandChange?: (isExpanded: boolean) => void;
14
22
  onOpenFullPage?: (conversationId: string | undefined) => void;
@@ -1,4 +1,4 @@
1
- import { WidgetFocusRequest } from './chat-widget.types';
1
+ import { WidgetFocusRequest, WidgetProfileRequest } from './chat-widget.types';
2
2
  interface WidgetChatShellProps {
3
3
  isWindowVisible: boolean;
4
4
  isExpanded: boolean;
@@ -12,6 +12,7 @@ interface WidgetChatShellProps {
12
12
  onFocusConversation: (conversationId: string) => void;
13
13
  onOpenFullPage?: (conversationId: string | undefined) => void;
14
14
  onRequestClose?: () => void;
15
+ openProfileRequest?: WidgetProfileRequest;
15
16
  }
16
- export declare function WidgetChatShell({ isWindowVisible, isExpanded, openConversationIds, windowCapacity, focusedConversationId, composerFocusRequest, onToggleExpand, onOpenConversation, onCloseConversation, onFocusConversation, onOpenFullPage, onRequestClose, }: WidgetChatShellProps): import('react/jsx-runtime').JSX.Element;
17
+ export declare function WidgetChatShell({ isWindowVisible, isExpanded, openConversationIds, windowCapacity, focusedConversationId, composerFocusRequest, onToggleExpand, onOpenConversation, onCloseConversation, onFocusConversation, onOpenFullPage, onRequestClose, openProfileRequest, }: WidgetChatShellProps): import('react/jsx-runtime').JSX.Element;
17
18
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medipha/chat",
3
- "version": "1.0.66",
3
+ "version": "1.0.67",
4
4
  "description": "Embeddable Medic-ERP chat module for React applications.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",