@fle-ui/plus-im-record 0.0.8-beta.0 → 0.0.8-beta.1

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.
Files changed (79) hide show
  1. package/es/@types/index.d.ts +620 -0
  2. package/es/CardTag/index.d.ts +3 -0
  3. package/es/CardTag/index.js +18 -0
  4. package/es/ChatMessageItem/index.d.ts +15 -0
  5. package/es/ChatMessageItem/index.js +130 -0
  6. package/es/ChatMessageItem/index.less +108 -0
  7. package/es/ChatMessageList/index.d.ts +28 -0
  8. package/es/ChatMessageList/index.js +58 -0
  9. package/es/ChatMessageList/index.less +34 -0
  10. package/es/GoodsCard/index.d.ts +15 -0
  11. package/es/GoodsCard/index.js +95 -0
  12. package/es/GoodsCard/index.less +49 -0
  13. package/es/GoodsOrderCard/index.d.ts +14 -0
  14. package/es/GoodsOrderCard/index.js +161 -0
  15. package/es/GoodsOrderCard/index.less +81 -0
  16. package/es/Icon/index.d.ts +8 -0
  17. package/es/Icon/index.js +11 -0
  18. package/es/ParseSession/AudioPlayer.d.ts +14 -0
  19. package/es/ParseSession/AudioPlayer.js +89 -0
  20. package/es/ParseSession/audioAndVideoTool.d.ts +3 -0
  21. package/es/ParseSession/audioAndVideoTool.js +21 -0
  22. package/es/ParseSession/index.d.ts +15 -0
  23. package/es/ParseSession/index.js +492 -0
  24. package/es/ParseSession/index.less +226 -0
  25. package/es/api/index.d.ts +30 -0
  26. package/es/api/index.js +48 -0
  27. package/es/audioAndVideoTool.d.ts +3 -0
  28. package/es/audioAndVideoTool.js +21 -0
  29. package/es/common/const/index.d.ts +46 -0
  30. package/es/common/const/index.js +82 -0
  31. package/es/common/utils/index.d.ts +33 -0
  32. package/es/common/utils/index.js +169 -0
  33. package/es/index.d.ts +28 -0
  34. package/es/index.js +77 -0
  35. package/es/styles/extends.less +50 -0
  36. package/es/styles/index.less +35 -0
  37. package/es/styles/vars.less +8 -0
  38. package/es/utils/index.d.ts +14 -0
  39. package/es/utils/index.js +50 -0
  40. package/lib/@types/index.d.ts +620 -0
  41. package/lib/CardTag/index.d.ts +3 -0
  42. package/lib/CardTag/index.js +25 -0
  43. package/lib/ChatMessageItem/index.d.ts +15 -0
  44. package/lib/ChatMessageItem/index.js +136 -0
  45. package/lib/ChatMessageItem/index.less +108 -0
  46. package/lib/ChatMessageList/index.d.ts +28 -0
  47. package/lib/ChatMessageList/index.js +65 -0
  48. package/lib/ChatMessageList/index.less +34 -0
  49. package/lib/GoodsCard/index.d.ts +15 -0
  50. package/lib/GoodsCard/index.js +105 -0
  51. package/lib/GoodsCard/index.less +49 -0
  52. package/lib/GoodsOrderCard/index.d.ts +14 -0
  53. package/lib/GoodsOrderCard/index.js +169 -0
  54. package/lib/GoodsOrderCard/index.less +81 -0
  55. package/lib/Icon/index.d.ts +8 -0
  56. package/lib/Icon/index.js +18 -0
  57. package/lib/ParseSession/AudioPlayer.d.ts +14 -0
  58. package/lib/ParseSession/AudioPlayer.js +98 -0
  59. package/lib/ParseSession/audioAndVideoTool.d.ts +3 -0
  60. package/lib/ParseSession/audioAndVideoTool.js +27 -0
  61. package/lib/ParseSession/index.d.ts +15 -0
  62. package/lib/ParseSession/index.js +494 -0
  63. package/lib/ParseSession/index.less +226 -0
  64. package/lib/api/index.d.ts +30 -0
  65. package/lib/api/index.js +55 -0
  66. package/lib/audioAndVideoTool.d.ts +3 -0
  67. package/lib/audioAndVideoTool.js +27 -0
  68. package/lib/common/const/index.d.ts +46 -0
  69. package/lib/common/const/index.js +88 -0
  70. package/lib/common/utils/index.d.ts +33 -0
  71. package/lib/common/utils/index.js +183 -0
  72. package/lib/index.d.ts +28 -0
  73. package/lib/index.js +86 -0
  74. package/lib/styles/extends.less +50 -0
  75. package/lib/styles/index.less +35 -0
  76. package/lib/styles/vars.less +8 -0
  77. package/lib/utils/index.d.ts +14 -0
  78. package/lib/utils/index.js +56 -0
  79. package/package.json +2 -2
package/es/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import React, { UIEventHandler } from 'react';
2
+ import { RecordSession } from './ChatMessageList';
3
+ import { apiCreate, Env } from './api';
4
+ import { IMMessage } from './@types';
5
+ import './styles/index.less';
6
+ /**
7
+ * @name 客服记录组件
8
+ * @description 代码由小鲤客服平台搬运简来.
9
+ */
10
+ export interface IMRecordProps {
11
+ env?: Env;
12
+ token?: string;
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;
22
+ }
23
+ export interface ImContextProps {
24
+ api: ReturnType<typeof apiCreate>;
25
+ }
26
+ export declare const ImContext: React.Context<ImContextProps>;
27
+ declare const IMRecord: React.FC<IMRecordProps>;
28
+ export default IMRecord;
package/es/index.js ADDED
@@ -0,0 +1,77 @@
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); }
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; }
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; }
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; }
7
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
8
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
9
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
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; }
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; } }
18
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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';
22
+ import ChatMessageList from './ChatMessageList';
23
+ import { apiCreate } from './api';
24
+ import './styles/index.less';
25
+ export var ImContext = /*#__PURE__*/createContext({});
26
+ var IMRecord = function IMRecord(_ref) {
27
+ var env = _ref.env,
28
+ token = _ref.token,
29
+ msgs = _ref.msgs,
30
+ recordSession = _ref.recordSession,
31
+ restProps = _objectWithoutProperties(_ref, _excluded);
32
+ var api = apiCreate(env, token);
33
+ var _useState = useState({}),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ accountsMap = _useState2[0],
36
+ setAccountsMap = _useState2[1];
37
+ var messageListDomRef = useRef(null);
38
+ useEffect(function () {
39
+ var accids = _toConsumableArray(new Set(msgs.map(function (x) {
40
+ return x.from;
41
+ })));
42
+ if (accids.length) {
43
+ getAccountByAccids(accids);
44
+ }
45
+ }, [msgs]);
46
+ function getAccountByAccids(accids) {
47
+ api.getAccountInfoByAccid({
48
+ accids: accids
49
+ }).then(function (_ref2) {
50
+ var data = _ref2.data;
51
+ var temp = {};
52
+ if (Array.isArray(data)) {
53
+ data.forEach(function (item) {
54
+ if (!accountsMap[item.accid]) {
55
+ temp[item.accid] = item;
56
+ }
57
+ });
58
+ }
59
+ setAccountsMap(function (prev) {
60
+ return _objectSpread(_objectSpread({}, prev), temp);
61
+ });
62
+ });
63
+ }
64
+ return /*#__PURE__*/React.createElement(ImContext.Provider, {
65
+ value: {
66
+ api: api
67
+ }
68
+ }, /*#__PURE__*/React.createElement(ChatMessageList, _extends({
69
+ ref: messageListDomRef,
70
+ msgs: msgs,
71
+ h5: true,
72
+ accountsMap: accountsMap,
73
+ isSessionEnd: true,
74
+ recordSession: recordSession
75
+ }, restProps)));
76
+ };
77
+ export default IMRecord;
@@ -0,0 +1,50 @@
1
+ @import './vars.less';
2
+
3
+ /* flex 布局样式 */
4
+ .flex {
5
+ display: flex;
6
+ }
7
+
8
+ .flex-align-center {
9
+ align-items: center;
10
+ }
11
+
12
+ .flex-center {
13
+ &:extend(.flex);
14
+ &:extend(.flex-align-center);
15
+ justify-content: center;
16
+ }
17
+
18
+ /* 文字样式 */
19
+
20
+ .one-line-text {
21
+ overflow: hidden;
22
+ text-overflow: ellipsis;
23
+ white-space: nowrap;
24
+ }
25
+
26
+ .multi-line-text {
27
+ display: -webkit-box;
28
+ -webkit-box-orient: vertical;
29
+ overflow: hidden;
30
+ }
31
+
32
+ .two-line-text {
33
+ &:extend(.multi-line-text);
34
+ -webkit-line-clamp: 2;
35
+ }
36
+
37
+ /* 小滚动条样式 */
38
+ .scrollmini {
39
+ &::-webkit-scrollbar {
40
+ width: 4px;
41
+ }
42
+ &::-webkit-scrollbar-thumb {
43
+ background: #ddd;
44
+ border-radius: 4px;
45
+ border-radius: 2px;
46
+ }
47
+ &::-webkit-scrollbar-thumb:hover {
48
+ background-color: #ddd;
49
+ }
50
+ }
@@ -0,0 +1,35 @@
1
+ @import './vars.less';
2
+ @import './extends.less';
3
+
4
+ .mp0() {
5
+ margin: 0;
6
+ padding: 0;
7
+ }
8
+
9
+ input::-ms-clear,
10
+ input::-ms-reveal {
11
+ display: none;
12
+ }
13
+ *,
14
+ *::before,
15
+ *::after {
16
+ box-sizing: border-box;
17
+ }
18
+
19
+ ul,
20
+ li {
21
+ list-style: none;
22
+ .mp0();
23
+ }
24
+
25
+ ::-webkit-scrollbar {
26
+ width: 3px;
27
+ border-radius: 4px;
28
+ }
29
+ ::-webkit-scrollbar-thumb {
30
+ background: #ddd;
31
+ border-radius: 4px;
32
+ }
33
+ ::-webkit-scrollbar-thumb:hover {
34
+ background-color: #ddd;
35
+ }
@@ -0,0 +1,8 @@
1
+ :root {
2
+ --prc: #2c6bff; // 主题色
3
+ --txtc: #333; // 主文字颜色
4
+ --txtc2: #777; // 次级文字颜色
5
+
6
+ //
7
+ --rv-primary-color: var(--prc) !important;
8
+ }
@@ -0,0 +1,14 @@
1
+ export declare const debounce: <T extends (...args: any[]) => any>(fn: T, delay: number) => (...args: Parameters<T>) => void;
2
+ /**
3
+ * 格式化文件大小
4
+ * @param size 文件大小(字节)
5
+ * @returns 格式化后的文件大小字符串
6
+ */
7
+ export declare const parseFileSize: (size: number, level?: number) => string;
8
+ /**
9
+ * 给URL添加查询参数
10
+ * @param url 原始URL
11
+ * @param search 要添加的查询字符串
12
+ * @returns 添加参数后的URL
13
+ */
14
+ export declare const addUrlSearch: (url: string, search: string) => string;
@@ -0,0 +1,50 @@
1
+ export var debounce = function debounce(fn, delay) {
2
+ var timeoutId;
3
+ return function () {
4
+ var _this = this;
5
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
6
+ args[_key] = arguments[_key];
7
+ }
8
+ clearTimeout(timeoutId);
9
+ timeoutId = setTimeout(function () {
10
+ // @ts-ignore
11
+ fn.apply(_this, args);
12
+ }, delay);
13
+ };
14
+ };
15
+ /**
16
+ * 格式化文件大小
17
+ * @param size 文件大小(字节)
18
+ * @returns 格式化后的文件大小字符串
19
+ */
20
+ export var parseFileSize = function parseFileSize(size) {
21
+ var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
22
+ var fileSizeMap = {
23
+ 0: 'B',
24
+ 1: 'KB',
25
+ 2: 'MB',
26
+ 3: 'GB',
27
+ 4: 'TB'
28
+ };
29
+ var handler = function handler(size, level) {
30
+ if (level >= Object.keys(fileSizeMap).length) {
31
+ return 'the file is too big';
32
+ }
33
+ if (size < 1024) {
34
+ return "".concat(size).concat(fileSizeMap[level]);
35
+ }
36
+ return handler(Math.round(size / 1024), level + 1);
37
+ };
38
+ return handler(size, level);
39
+ };
40
+ /**
41
+ * 给URL添加查询参数
42
+ * @param url 原始URL
43
+ * @param search 要添加的查询字符串
44
+ * @returns 添加参数后的URL
45
+ */
46
+ export var addUrlSearch = function addUrlSearch(url, search) {
47
+ var urlObj = new URL(url);
48
+ urlObj.search += (urlObj.search.startsWith('?') ? '&' : '?') + search;
49
+ return urlObj.href;
50
+ };