@alifd/chat 0.3.29 → 0.3.30-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.
package/es/index.js CHANGED
@@ -31,4 +31,4 @@ export { default as RadioGroup } from './radio-group';
31
31
  export { default as CheckboxGroup } from './checkbox-group';
32
32
  export { default as Select } from './select';
33
33
  export { default as Flip } from './flip';
34
- export const version = '0.3.29';
34
+ export const version = '0.3.30-beta.1';
@@ -18,7 +18,7 @@ import { __awaiter, __rest } from "tslib";
18
18
  * | Enter | Trigger the onClick event |
19
19
  * | SPACE | Trigger the onClick event |
20
20
  */
21
- import React, { useState, forwardRef, useEffect } from 'react';
21
+ import React, { useState, forwardRef, useRef, useEffect } from 'react';
22
22
  import { Select as NextSelect, ConfigProvider } from '@alifd/next';
23
23
  import cs from 'classnames';
24
24
  import axios from 'axios';
@@ -26,6 +26,7 @@ import { PREFIX_DEFAULT, assignSubComponent } from '../utils';
26
26
  const PersonPicker = forwardRef((_a, ref) => {
27
27
  var { className, size = 'medium', defaultValue, readOnly } = _a, props = __rest(_a, ["className", "size", "defaultValue", "readOnly"]);
28
28
  const [dataSource, setDataSource] = useState([]);
29
+ const debounceTimerRef = useRef(null);
29
30
  // 默认出现最近联系人
30
31
  useEffect(() => {
31
32
  handleUserSearch('');
@@ -42,7 +43,7 @@ const PersonPicker = forwardRef((_a, ref) => {
42
43
  React.createElement("img", { style: { width: '20px', height: '20px', borderRadius: '4px' }, src: `https://work.alibaba-inc.com/photo/${selectItem.value}.20x20.jpg` }),
43
44
  React.createElement("span", { className: "label-text" }, selectItem.label));
44
45
  };
45
- const handleUserSearch = (keyword) => __awaiter(void 0, void 0, void 0, function* () {
46
+ const fetchUserData = (keyword) => __awaiter(void 0, void 0, void 0, function* () {
46
47
  var _a, _b;
47
48
  if (readOnly) {
48
49
  return;
@@ -54,6 +55,9 @@ const PersonPicker = forwardRef((_a, ref) => {
54
55
  try {
55
56
  const response = yield axios.get('/_gw/employee360Service/searchEmpInfo.json', {
56
57
  params: queryParams,
58
+ headers: {
59
+ 'X-Epaas-Api-Type': 'u'
60
+ }
57
61
  });
58
62
  const newDataSource = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.map((item) => {
59
63
  return Object.assign(Object.assign({}, item), { label: item.nickName, value: item.workNo });
@@ -64,6 +68,17 @@ const PersonPicker = forwardRef((_a, ref) => {
64
68
  setDataSource([]);
65
69
  }
66
70
  });
71
+ // 带防抖功能的搜索处理函数
72
+ const handleUserSearch = (keyword) => {
73
+ // 清除之前的定时器
74
+ if (debounceTimerRef.current) {
75
+ clearTimeout(debounceTimerRef.current);
76
+ }
77
+ // 设置新的定时器,300ms后执行实际的搜索请求
78
+ debounceTimerRef.current = setTimeout(() => {
79
+ fetchUserData(keyword);
80
+ }, 300);
81
+ };
67
82
  return (React.createElement(NextSelect, Object.assign({}, props, { popupClassName: cs(`${PREFIX_DEFAULT}person-picker`, className), itemRender: tagRender, valueRender: labelRender, mode: "multiple", showSearch: true, filterLocal: false, hiddenSelected: true, dataSource: dataSource, onSearch: handleUserSearch, size: size, ref: ref, readOnly: readOnly })));
68
83
  });
69
84
  const PersonPickerWithSub = assignSubComponent(PersonPicker, {
package/lib/index.js CHANGED
@@ -68,4 +68,4 @@ var select_1 = require("./select");
68
68
  Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return tslib_1.__importDefault(select_1).default; } });
69
69
  var flip_1 = require("./flip");
70
70
  Object.defineProperty(exports, "Flip", { enumerable: true, get: function () { return tslib_1.__importDefault(flip_1).default; } });
71
- exports.version = '0.3.29';
71
+ exports.version = '0.3.30-beta.1';
@@ -28,6 +28,7 @@ const utils_1 = require("../utils");
28
28
  const PersonPicker = (0, react_1.forwardRef)((_a, ref) => {
29
29
  var { className, size = 'medium', defaultValue, readOnly } = _a, props = tslib_1.__rest(_a, ["className", "size", "defaultValue", "readOnly"]);
30
30
  const [dataSource, setDataSource] = (0, react_1.useState)([]);
31
+ const debounceTimerRef = (0, react_1.useRef)(null);
31
32
  // 默认出现最近联系人
32
33
  (0, react_1.useEffect)(() => {
33
34
  handleUserSearch('');
@@ -44,7 +45,7 @@ const PersonPicker = (0, react_1.forwardRef)((_a, ref) => {
44
45
  react_1.default.createElement("img", { style: { width: '20px', height: '20px', borderRadius: '4px' }, src: `https://work.alibaba-inc.com/photo/${selectItem.value}.20x20.jpg` }),
45
46
  react_1.default.createElement("span", { className: "label-text" }, selectItem.label));
46
47
  };
47
- const handleUserSearch = (keyword) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
48
+ const fetchUserData = (keyword) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
48
49
  var _a, _b;
49
50
  if (readOnly) {
50
51
  return;
@@ -56,6 +57,9 @@ const PersonPicker = (0, react_1.forwardRef)((_a, ref) => {
56
57
  try {
57
58
  const response = yield axios_1.default.get('/_gw/employee360Service/searchEmpInfo.json', {
58
59
  params: queryParams,
60
+ headers: {
61
+ 'X-Epaas-Api-Type': 'u'
62
+ }
59
63
  });
60
64
  const newDataSource = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.map((item) => {
61
65
  return Object.assign(Object.assign({}, item), { label: item.nickName, value: item.workNo });
@@ -66,6 +70,17 @@ const PersonPicker = (0, react_1.forwardRef)((_a, ref) => {
66
70
  setDataSource([]);
67
71
  }
68
72
  });
73
+ // 带防抖功能的搜索处理函数
74
+ const handleUserSearch = (keyword) => {
75
+ // 清除之前的定时器
76
+ if (debounceTimerRef.current) {
77
+ clearTimeout(debounceTimerRef.current);
78
+ }
79
+ // 设置新的定时器,300ms后执行实际的搜索请求
80
+ debounceTimerRef.current = setTimeout(() => {
81
+ fetchUserData(keyword);
82
+ }, 300);
83
+ };
69
84
  return (react_1.default.createElement(next_1.Select, Object.assign({}, props, { popupClassName: (0, classnames_1.default)(`${utils_1.PREFIX_DEFAULT}person-picker`, className), itemRender: tagRender, valueRender: labelRender, mode: "multiple", showSearch: true, filterLocal: false, hiddenSelected: true, dataSource: dataSource, onSearch: handleUserSearch, size: size, ref: ref, readOnly: readOnly })));
70
85
  });
71
86
  const PersonPickerWithSub = (0, utils_1.assignSubComponent)(PersonPicker, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alifd/chat",
3
- "version": "0.3.29",
3
+ "version": "0.3.30-beta.1",
4
4
  "description": "A configurable component library for chat built on React.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,23 +0,0 @@
1
- /**
2
- * @component 输入框
3
- * @en Input
4
- * @type 通用 - General
5
- * @remarks 同 Next Input,按钮用于开始一个即时操作。- Same as Next.Input, Input used to trigger an action.
6
- * @when 标记一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。- Inputs are used for emphasizing important functions on your page.
7
- * @others
8
- * ## 无障碍键盘操作指南
9
- * | 按键 | 说明 |
10
- * | :---- | :---------- |
11
- * | Enter | 触发 onClick 事件 |
12
- * | SPACE | 触发 onClick 事件 |
13
- * @othersEn
14
- * ## ARIA and KeyBoard
15
- * | KeyBoard | Description |
16
- * | :---------- | :------------------------------ |
17
- * | Enter | Trigger the onClick event |
18
- * | SPACE | Trigger the onClick event |
19
- */
20
- import React from 'react';
21
- export * from './types';
22
- declare const _default: import("@alifd/next/types/config-provider/types").ConfiguredComponentClass<Pick<Pick<any, string | number | symbol> & React.RefAttributes<import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/input").InputProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/input/input").default<import("@alifd/next/types/input").InputProps>> & Pick<import("@alifd/next/types/input/input").default<import("@alifd/next/types/input").InputProps>, "focus" | "getInputNode">>, string | number | symbol> & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/config-provider/types").ConfiguredComponent<import("@alifd/next/types/input").InputProps & import("@alifd/next/types/config-provider/types").ComponentCommonProps, import("@alifd/next/types/input/input").default<import("@alifd/next/types/input").InputProps>> & Pick<import("@alifd/next/types/input/input").default<import("@alifd/next/types/input").InputProps>, "focus" | "getInputNode">, {}>;
23
- export default _default;
package/es/form/index.js DELETED
@@ -1,33 +0,0 @@
1
- /**
2
- * @component 输入框
3
- * @en Input
4
- * @type 通用 - General
5
- * @remarks 同 Next Input,按钮用于开始一个即时操作。- Same as Next.Input, Input used to trigger an action.
6
- * @when 标记一个(或封装一组)操作命令,响应用户点击行为,触发相应的业务逻辑。- Inputs are used for emphasizing important functions on your page.
7
- * @others
8
- * ## 无障碍键盘操作指南
9
- * | 按键 | 说明 |
10
- * | :---- | :---------- |
11
- * | Enter | 触发 onClick 事件 |
12
- * | SPACE | 触发 onClick 事件 |
13
- * @othersEn
14
- * ## ARIA and KeyBoard
15
- * | KeyBoard | Description |
16
- * | :---------- | :------------------------------ |
17
- * | Enter | Trigger the onClick event |
18
- * | SPACE | Trigger the onClick event |
19
- */
20
- import { __rest } from "tslib";
21
- import React, { forwardRef } from 'react';
22
- import { Input as NextInput, ConfigProvider } from '@alifd/next';
23
- import cs from 'classnames';
24
- import { PREFIX_DEFAULT, assignSubComponent } from '../utils';
25
- const Input = forwardRef((_a, ref) => {
26
- var { className, size = 'medium' } = _a, props = __rest(_a, ["className", "size"]);
27
- return (React.createElement(NextInput, Object.assign({}, props, { className: cs(`${PREFIX_DEFAULT}input`, className), size: size, ref: ref })));
28
- });
29
- const InputWithSub = assignSubComponent(Input, {
30
- displayName: 'Input',
31
- });
32
- export * from './types';
33
- export default ConfigProvider.config(InputWithSub);
package/es/form/main.scss DELETED
@@ -1,5 +0,0 @@
1
- @import "../core/variables.scss";
2
-
3
- .#{$prefix}input {
4
-
5
- }
@@ -1 +0,0 @@
1
- import '@alifd/next/lib/input/style2';
package/es/form/style.js DELETED
@@ -1 +0,0 @@
1
- import '@alifd/next/lib/input/style2';