@chlp-tech/rpa-ui 0.0.10 → 0.0.11-beta.10

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.
@@ -0,0 +1,144 @@
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
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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); }
5
+ 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; }
6
+ 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; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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 : String(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
+ import React, { useState, useEffect } from "react";
12
+ import { Avatar, Row, Col, Popover } from 'antd';
13
+ import classNames from 'classnames';
14
+ import TextEllipsis from "../text-ellipsis";
15
+ import MediaAccountPreview from "../MediaAccountPreview";
16
+ import Fb from "./imgs/fb.svg";
17
+ import Ins from "./imgs/ins.svg";
18
+ import Tk from "./imgs/tk.svg";
19
+ import Yt from "./imgs/yt.svg";
20
+ import Tt from "./imgs/tt.svg";
21
+ import CloseIcon from "./imgs/close.svg";
22
+ import styles from "./index.module.less";
23
+ var AccountBlock = function AccountBlock(_ref) {
24
+ var _account$remark;
25
+ var active = _ref.active,
26
+ onClick = _ref.onClick,
27
+ account = _ref.account,
28
+ onErrorClose = _ref.onErrorClose,
29
+ width = _ref.width;
30
+ var isError = account.error;
31
+ return /*#__PURE__*/React.createElement(Popover, {
32
+ rootClassName: styles.previewPopBox,
33
+ content: /*#__PURE__*/React.createElement(MediaAccountPreview, {
34
+ nickname: account.label,
35
+ remark: account.remark,
36
+ language: account.language,
37
+ country: account.country,
38
+ width: 450,
39
+ ownerUsername: account.ownerUserName
40
+ })
41
+ }, /*#__PURE__*/React.createElement("div", {
42
+ className: classNames(styles['account-wrap'], _defineProperty(_defineProperty({}, styles['error'], isError), styles['active'], active)),
43
+ onClick: onClick,
44
+ style: {
45
+ width: width,
46
+ background: active && isError ? '#FEECEC' : active && !isError ? '#E9F1FF' : '#F5F7FA'
47
+ }
48
+ }, /*#__PURE__*/React.createElement("div", {
49
+ className: styles['flex']
50
+ }, /*#__PURE__*/React.createElement(Avatar, {
51
+ size: 24,
52
+ src: account.icon
53
+ }), /*#__PURE__*/React.createElement("div", {
54
+ className: "".concat(styles['account-wrap_text'], " ").concat(isError ? styles['error-text'] : active ? styles['active'] : ''),
55
+ style: {
56
+ color: active && isError ? '#FA4441' : active && !isError ? '#004FD3' : '#142A51'
57
+ }
58
+ }, account.label), account.remark && ((_account$remark = account.remark) === null || _account$remark === void 0 ? void 0 : _account$remark.length) > 0 && /*#__PURE__*/React.createElement("div", {
59
+ className: styles.remarkText
60
+ }, /*#__PURE__*/React.createElement(TextEllipsis, {
61
+ lines: 1,
62
+ showTooltip: false
63
+ }, account.remark)), isError && /*#__PURE__*/React.createElement("img", {
64
+ src: CloseIcon,
65
+ alt: "",
66
+ className: "".concat(styles['close-icon']),
67
+ onClick: function onClick(e) {
68
+ e.stopPropagation();
69
+ if (onErrorClose) {
70
+ onErrorClose(account);
71
+ }
72
+ }
73
+ }))));
74
+ };
75
+ var PublishAccount = function PublishAccount(_ref2) {
76
+ var accounts = _ref2.accounts,
77
+ onAccountSelect = _ref2.onAccountSelect,
78
+ onErrorClose = _ref2.onErrorClose,
79
+ boxWidth = _ref2.boxWidth;
80
+ var _useState = useState(null),
81
+ _useState2 = _slicedToArray(_useState, 2),
82
+ selectedAccount = _useState2[0],
83
+ setSelectedAccount = _useState2[1];
84
+ var getFirstAvailableAccount = function getFirstAvailableAccount() {
85
+ for (var _i = 0, _arr = ['fb', 'ins', 'tk', 'yt']; _i < _arr.length; _i++) {
86
+ var platform = _arr[_i];
87
+ if (accounts[platform] && accounts[platform].length > 0) {
88
+ return accounts[platform][0];
89
+ }
90
+ }
91
+ return null;
92
+ };
93
+ useEffect(function () {
94
+ var firstAccount = getFirstAvailableAccount();
95
+ if (firstAccount) {
96
+ setSelectedAccount(firstAccount);
97
+ onAccountSelect(firstAccount);
98
+ }
99
+ }, [accounts]);
100
+ var renderAccounts = function renderAccounts(platform, icon) {
101
+ var _accounts$platform;
102
+ if (!accounts[platform] || accounts[platform].length === 0) {
103
+ return null;
104
+ }
105
+ return /*#__PURE__*/React.createElement(Row, {
106
+ gutter: 12,
107
+ style: {
108
+ marginBottom: 12
109
+ }
110
+ }, /*#__PURE__*/React.createElement(Col, {
111
+ span: 2
112
+ }, /*#__PURE__*/React.createElement("img", {
113
+ src: icon,
114
+ alt: platform
115
+ })), /*#__PURE__*/React.createElement(Col, {
116
+ span: 22
117
+ }, /*#__PURE__*/React.createElement("div", {
118
+ style: {
119
+ display: 'flex',
120
+ alignItems: 'center',
121
+ flexWrap: 'wrap',
122
+ gap: 12
123
+ }
124
+ }, (_accounts$platform = accounts[platform]) === null || _accounts$platform === void 0 ? void 0 : _accounts$platform.map(function (account) {
125
+ return /*#__PURE__*/React.createElement(AccountBlock, {
126
+ key: account.value,
127
+ width: boxWidth,
128
+ active: (selectedAccount === null || selectedAccount === void 0 ? void 0 : selectedAccount.value) === account.value,
129
+ onClick: function onClick() {
130
+ setSelectedAccount(account);
131
+ onAccountSelect(account);
132
+ },
133
+ onErrorClose: onErrorClose,
134
+ account: account
135
+ });
136
+ }))));
137
+ };
138
+ return /*#__PURE__*/React.createElement(React.Fragment, null, renderAccounts('fb', Fb), renderAccounts('ins', Ins), renderAccounts('tk', Tk), renderAccounts('yt', Yt), renderAccounts('tt', Tt));
139
+ };
140
+ var AccountComponent = {
141
+ PublishAccount: PublishAccount,
142
+ AccountBlock: AccountBlock
143
+ };
144
+ export default AccountComponent;
@@ -0,0 +1,83 @@
1
+ .account-wrap {
2
+ padding: 6px 8px 6px 8px;
3
+ background: #F5F7FA;
4
+ border-radius: 8px;
5
+ border: 1px solid #F5F7FA;
6
+ cursor: pointer;
7
+ display: inline-block;
8
+
9
+ &.error {
10
+ border-color: #FA4441;
11
+
12
+ &.error-active {
13
+ background: #FEECEC;
14
+
15
+ &_text {
16
+ color: #FA4441;
17
+ }
18
+ }
19
+ }
20
+
21
+ &:hover {
22
+ &.error .close-icon {
23
+ opacity: 1;
24
+ visibility: visible;
25
+ }
26
+ }
27
+
28
+ .close-icon {
29
+ opacity: 0;
30
+ visibility: hidden;
31
+ transition: opacity 0.3s;
32
+ }
33
+
34
+ &.active {
35
+ border-color: #004FD3;
36
+ background: #E9F1FF;
37
+ }
38
+
39
+ &_icon {
40
+ width: 24px;
41
+ height: 24px;
42
+ border-radius: 60%;
43
+ }
44
+
45
+ &_text {
46
+ flex: 1;
47
+ font-weight: 500;
48
+ font-size: 14px;
49
+ color: #142A51;
50
+ line-height: 20px;
51
+ text-align: left;
52
+ font-style: normal;
53
+ overflow: hidden;
54
+ transition: all 0.3s;
55
+ // 单行省略
56
+ text-overflow: ellipsis;
57
+ white-space: nowrap;
58
+ &.active {
59
+ color: #004FD3;
60
+ }
61
+ }
62
+ }
63
+
64
+ .flex {
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: space-between;
68
+ gap: 4px;
69
+ }
70
+
71
+ .remarkText {
72
+ width: 80px;
73
+ font-size: 12px;
74
+ color: #9EA7B5;
75
+ }
76
+
77
+ .previewPopBox {
78
+ :global {
79
+ .ant-popover-inner {
80
+ padding: 0px !important;
81
+ }
82
+ }
83
+ }
@@ -19,6 +19,7 @@ interface Props {
19
19
  isAd?: boolean;
20
20
  id: string | number;
21
21
  onDelete?: (id: string | number) => void;
22
+ onPauseOrStart?: (id: string | number) => void;
22
23
  mediaInfo: {
23
24
  url: string[];
24
25
  type: string;
@@ -110,6 +110,25 @@ var MediaCardList = function MediaCardList(props) {
110
110
  };
111
111
  var ReleaseVideoCard = function ReleaseVideoCard(props) {
112
112
  var _props$mediaInfo, _props$countData$view, _props$countData, _props$countData$like, _props$countData2, _props$countData$comm, _props$countData3, _ref2, _props$editComponent, _props$detailComponen;
113
+ var dropMenus = function dropMenus() {
114
+ var list = [];
115
+ // if ([1, 6].includes(props.status)) {
116
+ // list.push({
117
+ // label: <div>{props.status === 1 ? '暂停' : '启用'}</div>,
118
+ // key: 'pause',
119
+ // onClick: () => props?.onPauseOrStart?.(props.id),
120
+ // })
121
+ // }
122
+ list.push({
123
+ label: '删除',
124
+ key: 'delete',
125
+ onClick: function onClick() {
126
+ var _props$onDelete;
127
+ return props === null || props === void 0 || (_props$onDelete = props.onDelete) === null || _props$onDelete === void 0 ? void 0 : _props$onDelete.call(props, props.id);
128
+ }
129
+ });
130
+ return list;
131
+ };
113
132
  return /*#__PURE__*/React.createElement("div", {
114
133
  className: styles['card']
115
134
  }, /*#__PURE__*/React.createElement("div", {
@@ -194,16 +213,10 @@ var ReleaseVideoCard = function ReleaseVideoCard(props) {
194
213
  marginRight: 12,
195
214
  cursor: 'pointer'
196
215
  }
197
- }, [0, 1].includes(props.status) ? /*#__PURE__*/React.createElement(React.Fragment, null, (_props$editComponent = props.editComponent) !== null && _props$editComponent !== void 0 ? _props$editComponent : /*#__PURE__*/React.createElement("span", null, "\u7F16\u8F91")) : [2, 3].includes(props.status) ? /*#__PURE__*/React.createElement(React.Fragment, null, (_props$detailComponen = props.detailComponent) !== null && _props$detailComponen !== void 0 ? _props$detailComponen : /*#__PURE__*/React.createElement("span", null, "\u8BE6\u60C5")) : null), /*#__PURE__*/React.createElement(Dropdown, {
216
+ }, [0, 1].includes(props.status) ? /*#__PURE__*/React.createElement(React.Fragment, null, (_props$editComponent = props.editComponent) !== null && _props$editComponent !== void 0 ? _props$editComponent : /*#__PURE__*/React.createElement("span", null, "\u7F16\u8F91")) : [2, 3].includes(props.status) ? /*#__PURE__*/React.createElement(React.Fragment, null, (_props$detailComponen = props.detailComponent) !== null && _props$detailComponen !== void 0 ? _props$detailComponen : /*#__PURE__*/React.createElement("span", null, "\u8BE6\u60C5")) : null), [0, 1, 6].includes(props.status) ? /*#__PURE__*/React.createElement(Dropdown, {
198
217
  trigger: ['click'],
199
218
  menu: {
200
- items: [{
201
- label: '删除',
202
- key: 'delete',
203
- onClick: function onClick() {
204
- return (props === null || props === void 0 ? void 0 : props.onDelete) && props.onDelete(props.id);
205
- }
206
- }]
219
+ items: dropMenus()
207
220
  }
208
221
  }, /*#__PURE__*/React.createElement("div", {
209
222
  style: {
@@ -212,7 +225,7 @@ var ReleaseVideoCard = function ReleaseVideoCard(props) {
212
225
  }, /*#__PURE__*/React.createElement(Image, {
213
226
  src: More,
214
227
  preview: false
215
- }))))), props.isNew && /*#__PURE__*/React.createElement("div", {
228
+ }))) : null)), props.isNew && /*#__PURE__*/React.createElement("div", {
216
229
  className: styles['new-position']
217
230
  }, /*#__PURE__*/React.createElement(Image, {
218
231
  src: New,
@@ -24,6 +24,7 @@
24
24
  text-align: left;
25
25
  font-style: normal;
26
26
  flex: 1;
27
+ min-width: 0;
27
28
  display: flex;
28
29
  flex-direction: column;
29
30
  justify-content: space-around;
@@ -27,7 +27,7 @@ var TextEllipsis = function TextEllipsis(_ref) {
27
27
  var parentElement = parentRef.current;
28
28
  var parentWidth = parentElement.clientWidth;
29
29
  var textWidth = textElement.scrollWidth;
30
- setIsTruncated(textWidth > parentWidth);
30
+ setIsTruncated(textWidth >= parentWidth);
31
31
  }
32
32
  };
33
33
  checkTruncation();
@@ -41,17 +41,21 @@ var TextEllipsis = function TextEllipsis(_ref) {
41
41
  }, /*#__PURE__*/React.createElement("div", {
42
42
  className: styles['text-ellipsis'],
43
43
  ref: parentRef,
44
+ style: {
45
+ width: '100%'
46
+ }
47
+ }, /*#__PURE__*/React.createElement("div", {
48
+ ref: textRef,
44
49
  style: {
45
50
  display: '-webkit-box',
51
+ width: 'max-content',
52
+ maxWidth: '100%',
46
53
  WebkitBoxOrient: 'vertical',
47
54
  WebkitLineClamp: lines,
48
55
  overflow: 'hidden',
49
56
  textOverflow: 'ellipsis',
50
- width: '100%',
51
57
  wordBreak: 'break-all'
52
58
  }
53
- }, /*#__PURE__*/React.createElement("div", {
54
- ref: textRef
55
59
  }, children)));
56
60
  };
57
61
  export default TextEllipsis;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chlp-tech/rpa-ui",
3
- "version": "0.0.10",
3
+ "version": "0.0.11-beta.10",
4
4
  "description": "rpa-ui",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@ant-design/icons": ">=4.18.0",
39
- "antd": ">=4.18.0",
39
+ "antd": ">=5.25.0",
40
40
  "react": ">=16.9.0",
41
41
  "react-dom": ">=16.9.0"
42
42
  },
@@ -62,6 +62,7 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "@webav/av-cliper": "^1.0.11",
65
+ "classnames": "^2.5.1",
65
66
  "dayjs": "^1.11.13",
66
67
  "js-md5": "^0.8.3",
67
68
  "styled-components": "^6.1.12"