@alifd/chat 0.1.15-beta.2 → 0.1.15-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.
- package/es/person-picker/index.js +35 -9
- package/lib/person-picker/index.js +32 -6
- package/package.json +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
1
|
+
import { __awaiter, __rest } from "tslib";
|
|
2
2
|
/**
|
|
3
3
|
* @component 人员选择
|
|
4
4
|
* @en PersonSelect
|
|
@@ -18,20 +18,46 @@ import { __rest } from "tslib";
|
|
|
18
18
|
* | Enter | Trigger the onClick event |
|
|
19
19
|
* | SPACE | Trigger the onClick event |
|
|
20
20
|
*/
|
|
21
|
-
import React, { forwardRef } from 'react';
|
|
22
|
-
import { Select as NextSelect, Tag as NextTag, Avatar as NextAvatar,
|
|
21
|
+
import React, { useState, forwardRef } from 'react';
|
|
22
|
+
import { Select as NextSelect, Tag as NextTag, Avatar as NextAvatar, ConfigProvider } from '@alifd/next';
|
|
23
23
|
import cs from 'classnames';
|
|
24
|
+
import axios from 'axios';
|
|
24
25
|
import { PREFIX_DEFAULT, assignSubComponent } from '../utils';
|
|
25
26
|
const PersonPicker = forwardRef((_a, ref) => {
|
|
26
|
-
var { className, size = 'small', value,
|
|
27
|
+
var { className, size = 'small', defaultValue, value, onChange, readOnly } = _a, props = __rest(_a, ["className", "size", "defaultValue", "value", "onChange", "readOnly"]);
|
|
28
|
+
const [dataSource, setDataSource] = useState([]);
|
|
27
29
|
const tagRender = (selectItem) => {
|
|
28
|
-
|
|
29
|
-
return React.createElement(NextTag.Closeable, { onClose: onClose, className: "h-6 px-1 mt-1 mr-1" },
|
|
30
|
+
return React.createElement(NextTag, { className: "h-6 px-1 mt-1 mr-1" },
|
|
30
31
|
React.createElement("div", { className: "flex items-center" },
|
|
31
|
-
React.createElement(NextAvatar, { className: "mr-0.5 scale-75", shape: "square", size: "small", src: `//work.alibaba-inc.com/photo/${value}.80x80.jpg` }),
|
|
32
|
-
React.createElement("span", { className: "text-xs" }, label)));
|
|
32
|
+
React.createElement(NextAvatar, { className: "mr-0.5 scale-75", shape: "square", size: "small", src: `//work.alibaba-inc.com/photo/${selectItem.value}.80x80.jpg` }),
|
|
33
|
+
React.createElement("span", { className: "text-xs" }, selectItem.label)));
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
+
const handleUserSearch = (keyword) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
var _b, _c;
|
|
37
|
+
if (readOnly) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const queryParams = {
|
|
41
|
+
key: keyword,
|
|
42
|
+
pageSize: (props === null || props === void 0 ? void 0 : props.pageSize) || 5
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
const response = yield axios.get('/_gw/employee360Service/searchEmpInfo.json', {
|
|
46
|
+
params: queryParams,
|
|
47
|
+
});
|
|
48
|
+
const newDataSource = (_c = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
49
|
+
return {
|
|
50
|
+
label: item.nickName,
|
|
51
|
+
value: item.workNo
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
setDataSource(newDataSource);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
setDataSource([]);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
return (React.createElement(NextSelect, Object.assign({}, props, { className: cs(`${PREFIX_DEFAULT}person-picker`, className), itemRender: tagRender, mode: "multiple", showSearch: true, filterLocal: false, dataSource: dataSource, onSearch: handleUserSearch, size: size, ref: ref })));
|
|
35
61
|
});
|
|
36
62
|
const PersonPickerWithSub = assignSubComponent(PersonPicker, {
|
|
37
63
|
displayName: 'PersonPicker',
|
|
@@ -23,17 +23,43 @@ const tslib_1 = require("tslib");
|
|
|
23
23
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
24
24
|
const next_1 = require("@alifd/next");
|
|
25
25
|
const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
26
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
26
27
|
const utils_1 = require("../utils");
|
|
27
28
|
const PersonPicker = (0, react_1.forwardRef)((_a, ref) => {
|
|
28
|
-
var { className, size = 'small', value,
|
|
29
|
+
var { className, size = 'small', defaultValue, value, onChange, readOnly } = _a, props = tslib_1.__rest(_a, ["className", "size", "defaultValue", "value", "onChange", "readOnly"]);
|
|
30
|
+
const [dataSource, setDataSource] = (0, react_1.useState)([]);
|
|
29
31
|
const tagRender = (selectItem) => {
|
|
30
|
-
|
|
31
|
-
return react_1.default.createElement(next_1.Tag.Closeable, { onClose: onClose, className: "h-6 px-1 mt-1 mr-1" },
|
|
32
|
+
return react_1.default.createElement(next_1.Tag, { className: "h-6 px-1 mt-1 mr-1" },
|
|
32
33
|
react_1.default.createElement("div", { className: "flex items-center" },
|
|
33
|
-
react_1.default.createElement(next_1.Avatar, { className: "mr-0.5 scale-75", shape: "square", size: "small", src: `//work.alibaba-inc.com/photo/${value}.80x80.jpg` }),
|
|
34
|
-
react_1.default.createElement("span", { className: "text-xs" }, label)));
|
|
34
|
+
react_1.default.createElement(next_1.Avatar, { className: "mr-0.5 scale-75", shape: "square", size: "small", src: `//work.alibaba-inc.com/photo/${selectItem.value}.80x80.jpg` }),
|
|
35
|
+
react_1.default.createElement("span", { className: "text-xs" }, selectItem.label)));
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
+
const handleUserSearch = (keyword) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
var _b, _c;
|
|
39
|
+
if (readOnly) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const queryParams = {
|
|
43
|
+
key: keyword,
|
|
44
|
+
pageSize: (props === null || props === void 0 ? void 0 : props.pageSize) || 5
|
|
45
|
+
};
|
|
46
|
+
try {
|
|
47
|
+
const response = yield axios_1.default.get('/_gw/employee360Service/searchEmpInfo.json', {
|
|
48
|
+
params: queryParams,
|
|
49
|
+
});
|
|
50
|
+
const newDataSource = (_c = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.map((item) => {
|
|
51
|
+
return {
|
|
52
|
+
label: item.nickName,
|
|
53
|
+
value: item.workNo
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
setDataSource(newDataSource);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
setDataSource([]);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return (react_1.default.createElement(next_1.Select, Object.assign({}, props, { className: (0, classnames_1.default)(`${utils_1.PREFIX_DEFAULT}person-picker`, className), itemRender: tagRender, mode: "multiple", showSearch: true, filterLocal: false, dataSource: dataSource, onSearch: handleUserSearch, size: size, ref: ref })));
|
|
37
63
|
});
|
|
38
64
|
const PersonPickerWithSub = (0, utils_1.assignSubComponent)(PersonPicker, {
|
|
39
65
|
displayName: 'PersonPicker',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alifd/chat",
|
|
3
|
-
"version": "0.1.15-beta.
|
|
3
|
+
"version": "0.1.15-beta.3",
|
|
4
4
|
"description": "A configurable component library for chat built on React.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -238,6 +238,7 @@
|
|
|
238
238
|
},
|
|
239
239
|
"dependencies": {
|
|
240
240
|
"@ali/dingtalk-jsapi": "^3.0.33",
|
|
241
|
+
"axios": "^1.7.0",
|
|
241
242
|
"dd-icons": "^1.6.20",
|
|
242
243
|
"dingtalk-jsapi": "^3.0.33",
|
|
243
244
|
"hoist-non-react-statics": "^3.3.2",
|