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

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 +29 -0
  8. package/es/ChatMessageList/index.js +66 -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 +38 -0
  34. package/es/index.js +111 -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 +29 -0
  47. package/lib/ChatMessageList/index.js +76 -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 +38 -0
  73. package/lib/index.js +119 -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,38 @@
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
+ /**是否显示搜索输入框 默认为false*/
23
+ showSearchInput?: boolean;
24
+ /**搜索事件,对外抛出搜索关键字*/
25
+ onSearch?: (keyword: string) => void;
26
+ /**搜索模式
27
+ * internal: 内部搜索 只对输入到组件内部的msgs进行搜索
28
+ * external: 外部搜索 只对外抛出搜索关键字,在外部搜索,从而改变输入到组件的msgs
29
+ * 默认为internal
30
+ */
31
+ searchMode?: 'internal' | 'external';
32
+ }
33
+ export interface ImContextProps {
34
+ api: ReturnType<typeof apiCreate>;
35
+ }
36
+ export declare const ImContext: React.Context<ImContextProps>;
37
+ declare const IMRecord: React.FC<IMRecordProps>;
38
+ export default IMRecord;
package/es/index.js ADDED
@@ -0,0 +1,111 @@
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
+ import "antd/es/input/style";
3
+ import _Input from "antd/es/input";
4
+ var _excluded = ["env", "token", "msgs", "recordSession", "showSearchInput", "searchMode", "onSearch"];
5
+ 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); }
6
+ 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; }
7
+ 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; }
8
+ 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; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
10
+ 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); }
11
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
12
+ 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."); }
13
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
16
+ 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."); }
17
+ 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); }
18
+ 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; }
19
+ 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; } }
20
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
+ 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; }
22
+ 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; }
23
+ import React, { createContext, useEffect, useRef, useState } from 'react';
24
+ import ChatMessageList from './ChatMessageList';
25
+ import { apiCreate } from './api';
26
+ import './styles/index.less';
27
+ export var ImContext = /*#__PURE__*/createContext({});
28
+ var IMRecord = function IMRecord(_ref) {
29
+ var env = _ref.env,
30
+ token = _ref.token,
31
+ msgs = _ref.msgs,
32
+ recordSession = _ref.recordSession,
33
+ _ref$showSearchInput = _ref.showSearchInput,
34
+ showSearchInput = _ref$showSearchInput === void 0 ? false : _ref$showSearchInput,
35
+ _ref$searchMode = _ref.searchMode,
36
+ searchMode = _ref$searchMode === void 0 ? 'internal' : _ref$searchMode,
37
+ onSearch = _ref.onSearch,
38
+ restProps = _objectWithoutProperties(_ref, _excluded);
39
+ var api = apiCreate(env, token);
40
+ var _useState = useState({}),
41
+ _useState2 = _slicedToArray(_useState, 2),
42
+ accountsMap = _useState2[0],
43
+ setAccountsMap = _useState2[1];
44
+ var _useState3 = useState(),
45
+ _useState4 = _slicedToArray(_useState3, 2),
46
+ searchValue = _useState4[0],
47
+ setSearchValue = _useState4[1];
48
+ var messageListDomRef = useRef(null);
49
+ useEffect(function () {
50
+ var accids = _toConsumableArray(new Set(msgs.map(function (x) {
51
+ return x.from;
52
+ })));
53
+ if (accids.length) {
54
+ getAccountByAccids(accids);
55
+ }
56
+ }, [msgs]);
57
+ useEffect(function () {
58
+ var handler = setTimeout(function () {
59
+ if (onSearch && searchValue !== undefined) {
60
+ onSearch(searchValue); // 仅在external模式下触发onSearch
61
+ }
62
+ }, 300); // 300ms的防抖时间,可以根据需要调整
63
+ return function () {
64
+ clearTimeout(handler); // 清除上一次的定时器
65
+ };
66
+ }, [searchValue, searchMode, onSearch]);
67
+ function getAccountByAccids(accids) {
68
+ api.getAccountInfoByAccid({
69
+ accids: accids
70
+ }).then(function (_ref2) {
71
+ var data = _ref2.data;
72
+ var temp = {};
73
+ if (Array.isArray(data)) {
74
+ data.forEach(function (item) {
75
+ if (!accountsMap[item.accid]) {
76
+ temp[item.accid] = item;
77
+ }
78
+ });
79
+ }
80
+ setAccountsMap(function (prev) {
81
+ return _objectSpread(_objectSpread({}, prev), temp);
82
+ });
83
+ });
84
+ }
85
+ return /*#__PURE__*/React.createElement(ImContext.Provider, {
86
+ value: {
87
+ api: api
88
+ }
89
+ }, showSearchInput && /*#__PURE__*/React.createElement("div", {
90
+ style: {
91
+ padding: 8,
92
+ backgroundColor: '#f7f7f7'
93
+ }
94
+ }, /*#__PURE__*/React.createElement(_Input, {
95
+ value: searchValue,
96
+ onChange: function onChange(e) {
97
+ return setSearchValue(e.target.value);
98
+ },
99
+ allowClear: true,
100
+ placeholder: "\u8F93\u5165\u5BF9\u8BDD\u5173\u952E\u8BCD\u641C\u7D22"
101
+ })), /*#__PURE__*/React.createElement(ChatMessageList, _extends({
102
+ searchValue: searchMode === 'internal' ? searchValue : undefined,
103
+ ref: messageListDomRef,
104
+ msgs: msgs,
105
+ h5: true,
106
+ accountsMap: accountsMap,
107
+ isSessionEnd: true,
108
+ recordSession: recordSession
109
+ }, restProps)));
110
+ };
111
+ 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
+ };