@fle-ui/plus-im-record 0.0.1-beta.3 → 0.0.2-beta.0

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/README.md CHANGED
@@ -17,3 +17,9 @@ or using yarn:
17
17
 
18
18
  $ yarn add @fle-ui/plus-im-record
19
19
  ```
20
+
21
+ ## 使用
22
+
23
+ ```tsx
24
+ import ImRecord from '@fle-ui/plus-im-record';
25
+ ```
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IMMessage } from '../@types';
3
+ import { RecordSession } from '../ChatMessageList';
3
4
  import './index.less';
4
5
  declare const ChatMessageItem: React.FC<{
5
6
  h5?: boolean;
@@ -9,9 +10,6 @@ declare const ChatMessageItem: React.FC<{
9
10
  myAccount?: string;
10
11
  accountInfo: any;
11
12
  isSessionEnd: boolean;
12
- recordSession?: {
13
- relationId: string | number;
14
- accid: string;
15
- };
13
+ recordSession?: RecordSession;
16
14
  }>;
17
15
  export default ChatMessageItem;
@@ -3,12 +3,18 @@ import { IMMessage } from '../@types';
3
3
  import './index.less';
4
4
  declare const LOADING_STATUS: any;
5
5
  export type LoadingStatus = keyof typeof LOADING_STATUS | undefined;
6
+ export interface RecordSession {
7
+ relationId?: string | number;
8
+ accid?: string;
9
+ relationType?: number;
10
+ }
6
11
  export interface ChatMessageListProps {
7
12
  h5?: boolean;
8
13
  msgs: IMMessage[];
9
14
  myAccount?: string;
10
15
  loadingStarus?: LoadingStatus;
11
16
  onScrollTop?: UIEventHandler<HTMLDivElement>;
17
+ onScrollBottom?: UIEventHandler<HTMLDivElement>;
12
18
  accountsMap?: Record<string, {
13
19
  accid: string;
14
20
  nickname: string;
@@ -16,11 +22,7 @@ export interface ChatMessageListProps {
16
22
  }>;
17
23
  style?: React.CSSProperties;
18
24
  isSessionEnd?: boolean;
19
- recordSession?: {
20
- relationId: string | number;
21
- accid: string;
22
- relationType?: number;
23
- };
25
+ recordSession?: RecordSession;
24
26
  }
25
27
  declare const ChatMessageList: React.ForwardRefExoticComponent<ChatMessageListProps & React.RefAttributes<HTMLDivElement>>;
26
28
  export default ChatMessageList;
@@ -10,8 +10,8 @@ var LOAD_LIMIT = 15;
10
10
  var ChatMessageList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
11
11
  var h5 = _ref.h5,
12
12
  msgs = _ref.msgs,
13
- _ref$onScrollTop = _ref.onScrollTop,
14
- onScrollTop = _ref$onScrollTop === void 0 ? function () {} : _ref$onScrollTop,
13
+ onScrollTop = _ref.onScrollTop,
14
+ onScrollBottom = _ref.onScrollBottom,
15
15
  _ref$loadingStarus = _ref.loadingStarus,
16
16
  loadingStarus = _ref$loadingStarus === void 0 ? '' : _ref$loadingStarus,
17
17
  myAccount = _ref.myAccount,
@@ -25,8 +25,10 @@ var ChatMessageList = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
25
25
  var onScrollHandler = debounce(function (e) {
26
26
  var scrollElRef = ref;
27
27
  if (!(scrollElRef === null || scrollElRef === void 0 ? void 0 : scrollElRef.current)) return;
28
+ var isBottom = scrollElRef.current.scrollTop >= scrollElRef.current.scrollHeight - scrollElRef.current.clientHeight - 20;
28
29
  var isTop = scrollElRef.current.scrollTop < 20;
29
30
  isTop && (onScrollTop === null || onScrollTop === void 0 ? void 0 : onScrollTop(e));
31
+ isBottom && (onScrollBottom === null || onScrollBottom === void 0 ? void 0 : onScrollBottom(e));
30
32
  }, 200);
31
33
  return /*#__PURE__*/React.createElement("div", {
32
34
  className: prefixCls,
@@ -1,7 +1,8 @@
1
1
  @prefix: chart;
2
2
 
3
3
  .@{prefix}-messages {
4
- flex: 1;
4
+ width: 100%;
5
+ height: 100%;
5
6
  position: relative;
6
7
  overflow: hidden;
7
8
  display: flex;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { RecordSession } from '../ChatMessageList';
2
3
  import './index.less';
3
4
  export declare function fitUrl(url: string): string;
4
5
  declare const GoodsOrderCard: React.FC<{
@@ -8,10 +9,6 @@ declare const GoodsOrderCard: React.FC<{
8
9
  onClose?: Function;
9
10
  orderSn?: any;
10
11
  orderId?: any;
11
- recordSession?: {
12
- relationId: string | number;
13
- accid: string;
14
- relationType?: number;
15
- };
12
+ recordSession?: RecordSession;
16
13
  }>;
17
14
  export default GoodsOrderCard;
@@ -62,7 +62,7 @@ var GoodsOrderCard = function GoodsOrderCard(props) {
62
62
  data = _useState2[0],
63
63
  setData = _useState2[1];
64
64
  useEffect(function () {
65
- if ((orderId || orderSn) && relationId && accid) {
65
+ if (orderId || orderSn) {
66
66
  api.getCSOrder({
67
67
  orderSn: orderSn,
68
68
  orderId: Number(orderId) || orderId,
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IMMessage } from '../@types';
3
+ import { RecordSession } from '../ChatMessageList';
3
4
  import './index.less';
4
5
  export interface IParseSessionProps {
5
6
  prefix?: string;
@@ -8,11 +9,7 @@ export interface IParseSessionProps {
8
9
  msg: IMMessage;
9
10
  isSessionEnd?: boolean;
10
11
  onChartHistoryClick?: Function;
11
- recordSession?: {
12
- relationId: string | number;
13
- accid: string;
14
- relationType?: number;
15
- };
12
+ recordSession?: RecordSession;
16
13
  }
17
14
  export declare const pauseAllAudio: () => HTMLAudioElement;
18
15
  export declare const pauseOtherVideo: (idClient: string) => void;
package/es/api/index.d.ts CHANGED
@@ -17,7 +17,7 @@ interface ApiMethods {
17
17
  getCSOrder: (data: {
18
18
  orderSn: number | string;
19
19
  orderId: any;
20
- accid: string;
20
+ accid?: string;
21
21
  relationId?: string | number;
22
22
  relationType?: number;
23
23
  }) => Promise<any>;
package/es/index.d.ts CHANGED
@@ -1,21 +1,24 @@
1
- import React from 'react';
1
+ import React, { UIEventHandler } from 'react';
2
+ import { RecordSession } from './ChatMessageList';
2
3
  import { apiCreate, Env } from './api';
3
4
  import { IMMessage } from './@types';
4
5
  import './styles/index.less';
5
6
  /**
6
7
  * @name 客服记录组件
7
- * @description 代码由小鲤客服平台搬运简化而来
8
+ * @description 代码由小鲤客服平台搬运简
8
9
  */
9
10
  export interface IMRecordProps {
10
11
  env?: Env;
11
12
  token?: string;
12
- msgRecords: IMMessage[];
13
- onScrollTop?: () => void;
14
- recordSession?: {
15
- relationId: string | number;
16
- accid: string;
17
- relationType?: number;
18
- };
13
+ h5?: boolean;
14
+ msgs: IMMessage[];
15
+ myAccount?: string;
16
+ loadingStarus?: 'loading' | 'nomore';
17
+ onScrollTop?: UIEventHandler<HTMLDivElement>;
18
+ onScrollBottom?: UIEventHandler<HTMLDivElement>;
19
+ style?: React.CSSProperties;
20
+ isSessionEnd?: boolean;
21
+ recordSession?: RecordSession;
19
22
  }
20
23
  export interface ImContextProps {
21
24
  api: ReturnType<typeof apiCreate>;
package/es/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["env", "token", "msgs", "recordSession"];
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
6
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -14,30 +16,33 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
14
16
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
15
17
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
16
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
17
- import React, { createContext, useEffect, useState } from 'react';
19
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
20
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
21
+ import React, { createContext, useEffect, useRef, useState } from 'react';
18
22
  import ChatMessageList from './ChatMessageList';
19
23
  import { apiCreate } from './api';
20
24
  import './styles/index.less';
21
25
  export var ImContext = /*#__PURE__*/createContext({});
22
26
  var IMRecord = function IMRecord(_ref) {
23
27
  var env = _ref.env,
24
- msgRecords = _ref.msgRecords,
25
28
  token = _ref.token,
29
+ msgs = _ref.msgs,
26
30
  recordSession = _ref.recordSession,
27
- onScrollTop = _ref.onScrollTop;
31
+ restProps = _objectWithoutProperties(_ref, _excluded);
28
32
  var api = apiCreate(env, token);
29
33
  var _useState = useState({}),
30
34
  _useState2 = _slicedToArray(_useState, 2),
31
35
  accountsMap = _useState2[0],
32
36
  setAccountsMap = _useState2[1];
37
+ var messageListDomRef = useRef(null);
33
38
  useEffect(function () {
34
- var accids = _toConsumableArray(new Set(msgRecords.map(function (x) {
39
+ var accids = _toConsumableArray(new Set(msgs.map(function (x) {
35
40
  return x.from;
36
41
  })));
37
42
  if (accids.length) {
38
43
  getAccountByAccids(accids);
39
44
  }
40
- }, [msgRecords]);
45
+ }, [msgs]);
41
46
  function getAccountByAccids(accids) {
42
47
  api.getAccountInfoByAccid({
43
48
  accids: accids
@@ -60,17 +65,13 @@ var IMRecord = function IMRecord(_ref) {
60
65
  value: {
61
66
  api: api
62
67
  }
63
- }, /*#__PURE__*/React.createElement(ChatMessageList, {
64
- msgs: msgRecords,
68
+ }, /*#__PURE__*/React.createElement(ChatMessageList, _extends({
69
+ ref: messageListDomRef,
70
+ msgs: msgs,
65
71
  h5: true,
66
- style: {
67
- height: '100%',
68
- background: '#f7f7f7'
69
- },
70
72
  accountsMap: accountsMap,
71
73
  isSessionEnd: true,
72
- recordSession: recordSession,
73
- onScrollTop: onScrollTop
74
- }));
74
+ recordSession: recordSession
75
+ }, restProps)));
75
76
  };
76
77
  export default IMRecord;
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IMMessage } from '../@types';
3
+ import { RecordSession } from '../ChatMessageList';
3
4
  import './index.less';
4
5
  declare const ChatMessageItem: React.FC<{
5
6
  h5?: boolean;
@@ -9,9 +10,6 @@ declare const ChatMessageItem: React.FC<{
9
10
  myAccount?: string;
10
11
  accountInfo: any;
11
12
  isSessionEnd: boolean;
12
- recordSession?: {
13
- relationId: string | number;
14
- accid: string;
15
- };
13
+ recordSession?: RecordSession;
16
14
  }>;
17
15
  export default ChatMessageItem;
@@ -3,12 +3,18 @@ import { IMMessage } from '../@types';
3
3
  import './index.less';
4
4
  declare const LOADING_STATUS: any;
5
5
  export type LoadingStatus = keyof typeof LOADING_STATUS | undefined;
6
+ export interface RecordSession {
7
+ relationId?: string | number;
8
+ accid?: string;
9
+ relationType?: number;
10
+ }
6
11
  export interface ChatMessageListProps {
7
12
  h5?: boolean;
8
13
  msgs: IMMessage[];
9
14
  myAccount?: string;
10
15
  loadingStarus?: LoadingStatus;
11
16
  onScrollTop?: UIEventHandler<HTMLDivElement>;
17
+ onScrollBottom?: UIEventHandler<HTMLDivElement>;
12
18
  accountsMap?: Record<string, {
13
19
  accid: string;
14
20
  nickname: string;
@@ -16,11 +22,7 @@ export interface ChatMessageListProps {
16
22
  }>;
17
23
  style?: React.CSSProperties;
18
24
  isSessionEnd?: boolean;
19
- recordSession?: {
20
- relationId: string | number;
21
- accid: string;
22
- relationType?: number;
23
- };
25
+ recordSession?: RecordSession;
24
26
  }
25
27
  declare const ChatMessageList: React.ForwardRefExoticComponent<ChatMessageListProps & React.RefAttributes<HTMLDivElement>>;
26
28
  export default ChatMessageList;
@@ -17,8 +17,8 @@ var LOAD_LIMIT = 15;
17
17
  var ChatMessageList = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
18
18
  var h5 = _ref.h5,
19
19
  msgs = _ref.msgs,
20
- _ref$onScrollTop = _ref.onScrollTop,
21
- onScrollTop = _ref$onScrollTop === void 0 ? function () {} : _ref$onScrollTop,
20
+ onScrollTop = _ref.onScrollTop,
21
+ onScrollBottom = _ref.onScrollBottom,
22
22
  _ref$loadingStarus = _ref.loadingStarus,
23
23
  loadingStarus = _ref$loadingStarus === void 0 ? '' : _ref$loadingStarus,
24
24
  myAccount = _ref.myAccount,
@@ -32,8 +32,10 @@ var ChatMessageList = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
32
32
  var onScrollHandler = (0, _utils.debounce)(function (e) {
33
33
  var scrollElRef = ref;
34
34
  if (!(scrollElRef === null || scrollElRef === void 0 ? void 0 : scrollElRef.current)) return;
35
+ var isBottom = scrollElRef.current.scrollTop >= scrollElRef.current.scrollHeight - scrollElRef.current.clientHeight - 20;
35
36
  var isTop = scrollElRef.current.scrollTop < 20;
36
37
  isTop && (onScrollTop === null || onScrollTop === void 0 ? void 0 : onScrollTop(e));
38
+ isBottom && (onScrollBottom === null || onScrollBottom === void 0 ? void 0 : onScrollBottom(e));
37
39
  }, 200);
38
40
  return /*#__PURE__*/_react.default.createElement("div", {
39
41
  className: prefixCls,
@@ -1,7 +1,8 @@
1
1
  @prefix: chart;
2
2
 
3
3
  .@{prefix}-messages {
4
- flex: 1;
4
+ width: 100%;
5
+ height: 100%;
5
6
  position: relative;
6
7
  overflow: hidden;
7
8
  display: flex;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { RecordSession } from '../ChatMessageList';
2
3
  import './index.less';
3
4
  export declare function fitUrl(url: string): string;
4
5
  declare const GoodsOrderCard: React.FC<{
@@ -8,10 +9,6 @@ declare const GoodsOrderCard: React.FC<{
8
9
  onClose?: Function;
9
10
  orderSn?: any;
10
11
  orderId?: any;
11
- recordSession?: {
12
- relationId: string | number;
13
- accid: string;
14
- relationType?: number;
15
- };
12
+ recordSession?: RecordSession;
16
13
  }>;
17
14
  export default GoodsOrderCard;
@@ -70,7 +70,7 @@ var GoodsOrderCard = function GoodsOrderCard(props) {
70
70
  data = _useState2[0],
71
71
  setData = _useState2[1];
72
72
  (0, _react.useEffect)(function () {
73
- if ((orderId || orderSn) && relationId && accid) {
73
+ if (orderId || orderSn) {
74
74
  api.getCSOrder({
75
75
  orderSn: orderSn,
76
76
  orderId: Number(orderId) || orderId,
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IMMessage } from '../@types';
3
+ import { RecordSession } from '../ChatMessageList';
3
4
  import './index.less';
4
5
  export interface IParseSessionProps {
5
6
  prefix?: string;
@@ -8,11 +9,7 @@ export interface IParseSessionProps {
8
9
  msg: IMMessage;
9
10
  isSessionEnd?: boolean;
10
11
  onChartHistoryClick?: Function;
11
- recordSession?: {
12
- relationId: string | number;
13
- accid: string;
14
- relationType?: number;
15
- };
12
+ recordSession?: RecordSession;
16
13
  }
17
14
  export declare const pauseAllAudio: () => HTMLAudioElement;
18
15
  export declare const pauseOtherVideo: (idClient: string) => void;
@@ -17,7 +17,7 @@ interface ApiMethods {
17
17
  getCSOrder: (data: {
18
18
  orderSn: number | string;
19
19
  orderId: any;
20
- accid: string;
20
+ accid?: string;
21
21
  relationId?: string | number;
22
22
  relationType?: number;
23
23
  }) => Promise<any>;
package/lib/index.d.ts CHANGED
@@ -1,21 +1,24 @@
1
- import React from 'react';
1
+ import React, { UIEventHandler } from 'react';
2
+ import { RecordSession } from './ChatMessageList';
2
3
  import { apiCreate, Env } from './api';
3
4
  import { IMMessage } from './@types';
4
5
  import './styles/index.less';
5
6
  /**
6
7
  * @name 客服记录组件
7
- * @description 代码由小鲤客服平台搬运简化而来
8
+ * @description 代码由小鲤客服平台搬运简
8
9
  */
9
10
  export interface IMRecordProps {
10
11
  env?: Env;
11
12
  token?: string;
12
- msgRecords: IMMessage[];
13
- onScrollTop?: () => void;
14
- recordSession?: {
15
- relationId: string | number;
16
- accid: string;
17
- relationType?: number;
18
- };
13
+ h5?: boolean;
14
+ msgs: IMMessage[];
15
+ myAccount?: string;
16
+ loadingStarus?: 'loading' | 'nomore';
17
+ onScrollTop?: UIEventHandler<HTMLDivElement>;
18
+ onScrollBottom?: UIEventHandler<HTMLDivElement>;
19
+ style?: React.CSSProperties;
20
+ isSessionEnd?: boolean;
21
+ recordSession?: RecordSession;
19
22
  }
20
23
  export interface ImContextProps {
21
24
  api: ReturnType<typeof apiCreate>;
package/lib/index.js CHANGED
@@ -9,9 +9,11 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _ChatMessageList = _interopRequireDefault(require("./ChatMessageList"));
10
10
  var _api = require("./api");
11
11
  require("./styles/index.less");
12
+ var _excluded = ["env", "token", "msgs", "recordSession"];
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
15
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
19
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -27,26 +29,29 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
27
29
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
28
30
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
29
31
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
32
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
33
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
30
34
  var ImContext = exports.ImContext = /*#__PURE__*/(0, _react.createContext)({});
31
35
  var IMRecord = function IMRecord(_ref) {
32
36
  var env = _ref.env,
33
- msgRecords = _ref.msgRecords,
34
37
  token = _ref.token,
38
+ msgs = _ref.msgs,
35
39
  recordSession = _ref.recordSession,
36
- onScrollTop = _ref.onScrollTop;
40
+ restProps = _objectWithoutProperties(_ref, _excluded);
37
41
  var api = (0, _api.apiCreate)(env, token);
38
42
  var _useState = (0, _react.useState)({}),
39
43
  _useState2 = _slicedToArray(_useState, 2),
40
44
  accountsMap = _useState2[0],
41
45
  setAccountsMap = _useState2[1];
46
+ var messageListDomRef = (0, _react.useRef)(null);
42
47
  (0, _react.useEffect)(function () {
43
- var accids = _toConsumableArray(new Set(msgRecords.map(function (x) {
48
+ var accids = _toConsumableArray(new Set(msgs.map(function (x) {
44
49
  return x.from;
45
50
  })));
46
51
  if (accids.length) {
47
52
  getAccountByAccids(accids);
48
53
  }
49
- }, [msgRecords]);
54
+ }, [msgs]);
50
55
  function getAccountByAccids(accids) {
51
56
  api.getAccountInfoByAccid({
52
57
  accids: accids
@@ -69,17 +74,13 @@ var IMRecord = function IMRecord(_ref) {
69
74
  value: {
70
75
  api: api
71
76
  }
72
- }, /*#__PURE__*/_react.default.createElement(_ChatMessageList.default, {
73
- msgs: msgRecords,
77
+ }, /*#__PURE__*/_react.default.createElement(_ChatMessageList.default, _extends({
78
+ ref: messageListDomRef,
79
+ msgs: msgs,
74
80
  h5: true,
75
- style: {
76
- height: '100%',
77
- background: '#f7f7f7'
78
- },
79
81
  accountsMap: accountsMap,
80
82
  isSessionEnd: true,
81
- recordSession: recordSession,
82
- onScrollTop: onScrollTop
83
- }));
83
+ recordSession: recordSession
84
+ }, restProps)));
84
85
  };
85
86
  var _default = exports.default = IMRecord;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fle-ui/plus-im-record",
3
- "version": "0.0.1-beta.3",
3
+ "version": "0.0.2-beta.0",
4
4
  "description": "@fle-ui/plus-im-record",
5
5
  "keywords": [
6
6
  "fle-ui",
@@ -44,5 +44,5 @@
44
44
  "peerDependencies": {
45
45
  "react": ">=17.0.0"
46
46
  },
47
- "gitHead": "b081f938415363a825529d29bfdd172845fa5e2f"
47
+ "gitHead": "fae9fe0beb35a02fe37964a6593da6155547d978"
48
48
  }