@cloudbase/weda-ui 3.2.1 → 3.3.0

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 (78) hide show
  1. package/dist/src/configs/components/chart/bar.json +9 -1
  2. package/dist/src/configs/components/chart/line.json +8 -0
  3. package/dist/src/configs/components/chart/pie.json +8 -0
  4. package/dist/src/web/actions/showModal/index.js +0 -1
  5. package/dist/src/web/components/calendar/index.js +39 -37
  6. package/dist/src/web/components/carousel/index.js +62 -62
  7. package/dist/src/web/components/chart/bar/index.js +6 -2
  8. package/dist/src/web/components/chart/common/Chart.d.ts +1 -0
  9. package/dist/src/web/components/chart/common/Chart.js +9 -1
  10. package/dist/src/web/components/chart/common/chart-custom-connector.js +1 -1
  11. package/dist/src/web/components/chart/common/core/eChartBase.js +1 -1
  12. package/dist/src/web/components/chart/common/data-transform.js +3 -1
  13. package/dist/src/web/components/chart/common/useChart.js +13 -2
  14. package/dist/src/web/components/chart/line/index.js +2 -2
  15. package/dist/src/web/components/chart/pie/index.js +2 -2
  16. package/dist/src/web/components/common/error-boundary.d.ts +5 -0
  17. package/dist/src/web/components/common/error-boundary.js +33 -0
  18. package/dist/src/web/components/common/use-loop-render-detect.d.ts +11 -0
  19. package/dist/src/web/components/common/use-loop-render-detect.js +124 -0
  20. package/dist/src/web/components/form/checkbox/index.js +29 -29
  21. package/dist/src/web/components/form/form/index.js +24 -15
  22. package/dist/src/web/components/form/input/index.js +11 -3
  23. package/dist/src/web/components/form/location/common/mapChoose.js +6 -5
  24. package/dist/src/web/components/form/location/common/mapView.js +9 -6
  25. package/dist/src/web/components/form/location/common/tmap.d.ts +3 -0
  26. package/dist/src/web/components/form/location/common/tmap.js +21 -0
  27. package/dist/src/web/components/form/location/common/useLocationInfo.js +3 -2
  28. package/dist/src/web/components/form/location/components/LocationH5/location.h5.js +6 -3
  29. package/dist/src/web/components/form/location/components/LocationPC/location.PC.js +5 -1
  30. package/dist/src/web/components/form/location/index.js +7 -0
  31. package/dist/src/web/components/form/radio/index.js +3 -3
  32. package/dist/src/web/components/form/select/allTimePicker/index.js +1 -0
  33. package/dist/src/web/components/form/select/h5.js +18 -4
  34. package/dist/src/web/components/form/select/index.js +15 -1
  35. package/dist/src/web/components/form/select/use-options.js +1 -1
  36. package/dist/src/web/components/form/uploader/uploader.h5.js +2 -2
  37. package/dist/src/web/components/form/uploader/uploader.pc.js +1 -1
  38. package/dist/src/web/components/form/uploaderFile/uploadFile.h5.js +9 -7
  39. package/dist/src/web/components/form/uploaderFile/uploadFile.pc.js +9 -6
  40. package/dist/src/web/components/form/userOrgSelect/comTool.js +3 -9
  41. package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.h5.js +39 -34
  42. package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.d.ts +1 -1
  43. package/dist/src/web/components/form/userOrgSelect/departTreeSelect/departTreeSelect.pc.js +35 -36
  44. package/dist/src/web/components/form/userOrgSelect/getUserService.d.ts +11 -0
  45. package/dist/src/web/components/form/userOrgSelect/getUserService.js +159 -0
  46. package/dist/src/web/components/form/userOrgSelect/userTreeSelect.h5.d.ts +3 -2
  47. package/dist/src/web/components/form/userOrgSelect/userTreeSelect.h5.js +37 -19
  48. package/dist/src/web/components/form/userOrgSelect/userTreeSelect.pc.d.ts +1 -1
  49. package/dist/src/web/components/form/userOrgSelect/userTreeSelect.pc.js +111 -129
  50. package/dist/src/web/components/form/userOrgSelect/utils.d.ts +3 -2
  51. package/dist/src/web/components/form/userOrgSelect/utils.js +24 -16
  52. package/dist/src/web/components/formdetail/index.js +14 -11
  53. package/dist/src/web/components/graphicCard/index.js +5 -6
  54. package/dist/src/web/components/image/index.js +1 -1
  55. package/dist/src/web/components/listView/index.js +1 -0
  56. package/dist/src/web/components/lottery/index.js +10 -16
  57. package/dist/src/web/components/navLayout/index.js +1 -1
  58. package/dist/src/web/components/navigationBar/horizontalMenu.js +1 -1
  59. package/dist/src/web/components/navigationBar/index.js +6 -6
  60. package/dist/src/web/components/richText/index.js +1 -2
  61. package/dist/src/web/components/richTextView/index.js +20 -18
  62. package/dist/src/web/components/scrollView/index.d.ts +1 -2
  63. package/dist/src/web/components/scrollView/index.js +7 -5
  64. package/dist/src/web/components/swiper/index.js +62 -62
  65. package/dist/src/web/components/tabs/index.js +6 -1
  66. package/dist/src/web/components/tabs/tabs.h5.js +2 -0
  67. package/dist/src/web/components/text/index.js +10 -8
  68. package/dist/src/web/components/uploaderFileView/index.js +1 -1
  69. package/dist/src/web/components/uploaderView/index.js +1 -1
  70. package/dist/src/web/components/wedaVideo/index.js +15 -3
  71. package/dist/src/web/utils/console.d.ts +3 -0
  72. package/dist/src/web/utils/console.js +26 -0
  73. package/dist/src/web/utils/platform.js +1 -1
  74. package/dist/src/web/utils/tcb.js +1 -1
  75. package/dist/src/web/utils/useSyncValue.js +1 -0
  76. package/dist/web/components/form/input/index.css +16 -0
  77. package/dist/web/components/form/userOrgSelect/userOrgSelect.css +4 -0
  78. package/package.json +20 -20
@@ -1,10 +1,10 @@
1
- import React, { useState, useEffect } from 'react';
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
2
  import { renderDecorator } from '../renderDecorator';
3
3
  import { isInIde, filterStrList } from '../../../utils/platform';
4
4
  import classNames from 'classnames';
5
5
  import { Dropdown, ConfigProvider, Text, Modal } from 'tea-component';
6
- import { getNode, getRelationData, dealOrgData } from './utils';
7
- import { getUserInfo, defaultRequest } from '../../../utils/getUserService';
6
+ import { getNode, getRelationData, dealOrgData, dealUserData, removeMarkString, } from './utils';
7
+ import { getUserInfo, defaultRequest } from './getUserService';
8
8
  import './userOrgSelect.css';
9
9
  import { DimTreeContent } from './comTool';
10
10
  import isObjectEqual from '../../../utils/isObjectEqual';
@@ -14,11 +14,10 @@ export function UserTreeSelectPC({ id, className, modelClassName, modelStyle, //
14
14
  style, events = emptyObject,
15
15
  // 组件属性
16
16
  label = '人员选择', labelVisible = true, //标题显隐
17
- // name = 'formUserTreeSelect',
18
17
  defaultValue = emptyArray, //默认值,支持数组
19
18
  confirmValue = '', placeholder = '请选择人员', defaultValueType = 'noneUser', disabled = false, layout = 'horizontal', modelType = 'dropdown', requiredFlag = false, size = 'l', multiple = false, //多选
20
19
  onChange = null, request = defaultRequest, //接口请求
21
- decorator, matchButtonWidth = false, dropDownStyle = defaultDropDownStyle, }) {
20
+ decorator, matchButtonWidth = false, modelOpen = false, dropDownStyle = defaultDropDownStyle, }) {
22
21
  // 两次默认值不同, 需要刷新
23
22
  const prevDefaultRef = React.useRef(null);
24
23
  const prevConfirmRef = React.useRef(null);
@@ -33,50 +32,11 @@ decorator, matchButtonWidth = false, dropDownStyle = defaultDropDownStyle, }) {
33
32
  //鼠标移入移除输入框
34
33
  const [moveIn, setMoveIn] = useState(false);
35
34
  const [originalOrgData, setOriginalOrgData] = useState([]);
36
- const [, setErrorInfo] = useState({
35
+ const [errorInfo, setErrorInfo] = useState({
37
36
  errorStatus: false,
38
37
  errorMessage: null,
39
38
  });
40
- useEffect(() => {
41
- initOrgsData();
42
- }, [defaultValueType]);
43
- useEffect(() => {
44
- if ((defaultValue &&
45
- !isObjectEqual(prevDefaultRef.current !== defaultValue)) ||
46
- (confirmValue &&
47
- !isObjectEqual(prevConfirmRef.current !== confirmValue)) ||
48
- defaultValueType === 'loginUser') {
49
- getdefaultUser();
50
- prevDefaultRef.current = defaultValue;
51
- prevConfirmRef.current = confirmValue;
52
- }
53
- }, [defaultValueType, confirmValue, defaultValue]);
54
- useEffect(() => {
55
- var _a;
56
- if (open) {
57
- setErrorInfo({ errorStatus: false, errorMessage: null });
58
- const userId = (_a = curSelectData[0]) === null || _a === void 0 ? void 0 : _a.userId;
59
- const isOrgs = getNode(orgsTreeData, userId, 'userId');
60
- if (isOrgs) {
61
- setActiveIds([isOrgs.id]);
62
- setSelectIds([isOrgs.id]);
63
- }
64
- }
65
- }, [open]);
66
- // 初始化数据
67
- const initOrgsData = async () => {
68
- try {
69
- setErrorInfo({ errorStatus: false, errorMessage: null });
70
- const resData = (await request('InitRootOrgs', {})) || [];
71
- const data = dealOrgData(resData);
72
- setOrgsTreeData(data);
73
- setOriginalOrgData([...data]);
74
- }
75
- catch (e) {
76
- setErrorInfo({ errorStatus: true, errorMessage: e });
77
- }
78
- };
79
- const getdefaultUser = async () => {
39
+ const getDefaultUser = useCallback(async (defaultValue) => {
80
40
  var _a;
81
41
  try {
82
42
  setErrorInfo({ errorStatus: false, errorMessage: null });
@@ -104,16 +64,76 @@ decorator, matchButtonWidth = false, dropDownStyle = defaultDropDownStyle, }) {
104
64
  else if ((defaultValueType === 'confirmUser' && confirmValue.length !== 0) ||
105
65
  defaultValue.length !== 0) {
106
66
  const userIdList = filterStrList(confirmValue.length !== 0 ? confirmValue : defaultValue);
107
- const userSelectList = await request('getUserById', {
67
+ const userList = await request('getUserById', {
108
68
  idList: userIdList || [],
109
69
  }, 'callDataSource');
70
+ const userSelectList = [];
71
+ userList.forEach((list) => {
72
+ var _a;
73
+ if (Array.isArray(list === null || list === void 0 ? void 0 : list.orgs)) {
74
+ userSelectList.push({
75
+ value: `${(_a = list === null || list === void 0 ? void 0 : list.orgs[0]) === null || _a === void 0 ? void 0 : _a.OrgId}-${list.value}`,
76
+ data: list === null || list === void 0 ? void 0 : list.data,
77
+ });
78
+ }
79
+ else {
80
+ userSelectList.push(list);
81
+ }
82
+ });
110
83
  setCurSelectData([...userSelectList]);
111
84
  }
112
85
  }
113
86
  catch (e) {
114
87
  setErrorInfo({ errorStatus: true, errorMessage: e });
115
88
  }
116
- };
89
+ }, [confirmValue, defaultValueType, events, request]);
90
+ useEffect(() => {
91
+ // 初始化数据
92
+ const initOrgsData = async () => {
93
+ try {
94
+ setErrorInfo({ errorStatus: false, errorMessage: null });
95
+ const resData = (await request('InitRootOrgs', {})) || [];
96
+ const pageNo = 1;
97
+ const noOrgUserData = await request('DescribeWedaUsersRuntime', {
98
+ pageNo: pageNo,
99
+ pageSize: 200,
100
+ IsNoRelatedOrgFlag: true,
101
+ UserType: 'internalUser',
102
+ });
103
+ const data = dealOrgData(resData).concat(dealUserData(noOrgUserData === null || noOrgUserData === void 0 ? void 0 : noOrgUserData.UserList));
104
+ setOrgsTreeData(data);
105
+ setOriginalOrgData([...data]);
106
+ }
107
+ catch (e) {
108
+ setErrorInfo({ errorStatus: true, errorMessage: e });
109
+ }
110
+ };
111
+ initOrgsData();
112
+ }, [defaultValueType, request]);
113
+ useEffect(() => {
114
+ setOpen(modelOpen);
115
+ }, [modelOpen]);
116
+ useEffect(() => {
117
+ if ((defaultValue &&
118
+ !isObjectEqual(prevDefaultRef.current !== defaultValue)) ||
119
+ (confirmValue &&
120
+ !isObjectEqual(prevConfirmRef.current !== confirmValue)) ||
121
+ defaultValueType === 'loginUser') {
122
+ getDefaultUser(defaultValue);
123
+ prevDefaultRef.current = defaultValue;
124
+ prevConfirmRef.current = confirmValue;
125
+ }
126
+ }, [defaultValueType, confirmValue, defaultValue, getDefaultUser]);
127
+ useEffect(() => {
128
+ if (open) {
129
+ setErrorInfo({ errorStatus: false, errorMessage: null });
130
+ const userIdList = curSelectData.map((d) => d === null || d === void 0 ? void 0 : d.value);
131
+ if (userIdList && userIdList.length > 0) {
132
+ setActiveIds(userIdList);
133
+ setSelectIds(userIdList);
134
+ }
135
+ }
136
+ }, [open, orgsTreeData, curSelectData]);
117
137
  const reset = (close, value = '') => {
118
138
  var _a;
119
139
  setSelectIds([]);
@@ -136,6 +156,43 @@ decorator, matchButtonWidth = false, dropDownStyle = defaultDropDownStyle, }) {
136
156
  'dim-tree-select--user': true,
137
157
  [className]: modelClassName,
138
158
  });
159
+ const onActiveChange = (ids) => {
160
+ const selectedId = ids[0];
161
+ const node = getNode(orgsTreeData, selectedId, 'id');
162
+ if (node === null || node === void 0 ? void 0 : node.isUser) {
163
+ //多选情况,取消选中某元素时
164
+ if (multiple && activeIds.indexOf(selectedId) !== -1) {
165
+ activeIds.splice(activeIds.indexOf(selectedId), 1);
166
+ setActiveIds([...activeIds]);
167
+ setSelectIds([...activeIds]);
168
+ }
169
+ else {
170
+ setActiveIds(multiple ? [...activeIds, ...ids] : [...ids]);
171
+ setSelectIds(multiple ? [...activeIds, ...ids] : [...ids]);
172
+ }
173
+ }
174
+ };
175
+ const onConfirm = () => {
176
+ var _a, _b;
177
+ const nodeList = [];
178
+ const idList = [];
179
+ const selectItem = [];
180
+ removeMarkString(selectIds).forEach((selectId) => {
181
+ if (selectId) {
182
+ const node = getNode(orgsTreeData, selectId, 'userId');
183
+ nodeList.push(node);
184
+ idList.push((node === null || node === void 0 ? void 0 : node.userId) || selectId);
185
+ selectItem.push({
186
+ value: node === null || node === void 0 ? void 0 : node.userId,
187
+ data: node,
188
+ });
189
+ }
190
+ });
191
+ getDefaultUser([...idList]);
192
+ onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? idList : (_a = selectItem[0]) === null || _a === void 0 ? void 0 : _a.value);
193
+ (_b = events === null || events === void 0 ? void 0 : events.change) === null || _b === void 0 ? void 0 : _b.call(events, multiple ? { value: idList, data: nodeList } : selectItem[0]);
194
+ setOpen(false);
195
+ };
139
196
  return renderDecorator(React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
140
197
  React.createElement("div", { onMouseEnter: () => {
141
198
  setMoveIn(true);
@@ -145,97 +202,22 @@ decorator, matchButtonWidth = false, dropDownStyle = defaultDropDownStyle, }) {
145
202
  React.createElement(Dropdown, { "data-testid": "userSelectDropdown", className: classNames('role-tree-select', `role-tree-select--depart`, `size-${size}`), overlayStyle: modelType === 'model' ? { display: 'none' } : {}, destroyOnClose: false, open: open, onOpenChange: (open) => {
146
203
  setOpen(open);
147
204
  setErrorInfo({ errorStatus: false, errorMessage: null });
148
- }, button: curSelectData.length === 0 ? (React.createElement(Text, { className: "placeholder" }, placeholder)) : (React.createElement(SelectViewContainer, { curSelectData: curSelectData, multiple: multiple, placeholder: placeholder, onChange: () => reset(true), moveIn: moveIn })), style: dropDownStyle, appearance: 'button', clickClose: false, disabled: disabled, matchButtonWidth: matchButtonWidth }, (close) => (React.createElement(React.Fragment, null, modelType === 'model' ? (React.createElement(Modal, { visible: open, onClose: close, className: "user_modal" },
205
+ }, button: curSelectData.length === 0 ? (React.createElement(Text, { className: "placeholder" }, placeholder)) : (React.createElement(SelectViewContainer, { curSelectData: curSelectData, placeholder: placeholder, onChange: () => reset(true), moveIn: moveIn })), style: dropDownStyle, appearance: 'button', clickClose: false, disabled: disabled, matchButtonWidth: matchButtonWidth }, (close) => (React.createElement(React.Fragment, null, modelType === 'model' ? (React.createElement(Modal, { visible: open, onClose: close, className: "user_modal" },
149
206
  React.createElement("div", { className: modelCls, style: modelStyle },
150
- React.createElement(DimTreeContent, { data: orgsTreeData, setTreeData: setOrgsTreeData, selectedIds: selectIds, activeIds: activeIds, needUser: true, request: request, onActive: (ids) => {
151
- const selectedId = ids[0];
152
- const node = getNode(orgsTreeData, selectedId, 'id');
153
- if (node === null || node === void 0 ? void 0 : node.isUser) {
154
- //多选情况,取消选中某元素时
155
- if (multiple &&
156
- activeIds.indexOf(selectedId) !== -1) {
157
- activeIds.splice(activeIds.indexOf(selectedId), 1);
158
- setActiveIds([...activeIds]);
159
- setSelectIds([...activeIds]);
160
- }
161
- else {
162
- setActiveIds(multiple ? [...activeIds, ...ids] : [...ids]);
163
- setSelectIds(multiple ? [...activeIds, ...ids] : [...ids]);
164
- }
165
- }
166
- }, onReset: () => setOrgsTreeData(originalOrgData), onCancel: () => {
207
+ React.createElement(DimTreeContent, { data: orgsTreeData, setTreeData: setOrgsTreeData, selectedIds: selectIds, activeIds: activeIds, needUser: true, request: request, errorInfo: errorInfo, onActive: (ids) => onActiveChange(ids), onReset: () => setOrgsTreeData(originalOrgData), onCancel: () => {
167
208
  setOpen(false);
168
209
  setErrorInfo({
169
210
  errorStatus: false,
170
211
  errorMessage: null,
171
212
  });
172
- }, onClear: () => reset(false), onConfirm: () => {
173
- var _a, _b;
174
- const nodeList = [];
175
- const idList = [];
176
- const selectItem = [];
177
- selectIds.forEach((selectId) => {
178
- if (selectId) {
179
- const node = getNode(orgsTreeData, selectId, 'id');
180
- nodeList.push(node);
181
- idList.push(node.userId);
182
- selectItem.push({
183
- value: node === null || node === void 0 ? void 0 : node.userId,
184
- data: node,
185
- });
186
- }
187
- });
188
- setCurSelectData(selectItem);
189
- onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? idList : (_a = selectItem[0]) === null || _a === void 0 ? void 0 : _a.value);
190
- setOpen(false);
191
- (_b = events === null || events === void 0 ? void 0 : events.change) === null || _b === void 0 ? void 0 : _b.call(events, multiple
192
- ? { value: idList, data: nodeList }
193
- : selectItem[0]);
194
- } })))) : (React.createElement("div", { className: modelCls, style: modelStyle },
195
- React.createElement(DimTreeContent, { data: orgsTreeData, setTreeData: setOrgsTreeData, selectedIds: selectIds, activeIds: activeIds, needUser: true, request: request, onActive: (ids) => {
196
- const selectedId = ids[0];
197
- const node = getNode(orgsTreeData, selectedId, 'id');
198
- if (node === null || node === void 0 ? void 0 : node.isUser) {
199
- //多选情况,取消选中某元素时
200
- if (multiple && activeIds.indexOf(selectedId) !== -1) {
201
- activeIds.splice(activeIds.indexOf(selectedId), 1);
202
- setActiveIds([...activeIds]);
203
- setSelectIds([...activeIds]);
204
- }
205
- else {
206
- setActiveIds(multiple ? [...activeIds, ...ids] : [...ids]);
207
- setSelectIds(multiple ? [...activeIds, ...ids] : [...ids]);
208
- }
209
- }
210
- }, onReset: () => setOrgsTreeData(originalOrgData), onCancel: () => {
213
+ }, onClear: () => reset(false), onConfirm: onConfirm })))) : (React.createElement("div", { className: modelCls, style: modelStyle },
214
+ React.createElement(DimTreeContent, { data: orgsTreeData, setTreeData: setOrgsTreeData, selectedIds: selectIds, activeIds: activeIds, needUser: true, request: request, errorInfo: errorInfo, onActive: (ids) => onActiveChange(ids), onReset: () => setOrgsTreeData(originalOrgData), onCancel: () => {
211
215
  setOpen(false);
212
216
  setErrorInfo({
213
217
  errorStatus: false,
214
218
  errorMessage: null,
215
219
  });
216
- }, onClear: () => reset(false), onConfirm: () => {
217
- var _a, _b;
218
- const nodeList = [];
219
- const idList = [];
220
- const selectItem = [];
221
- selectIds.forEach((selectId) => {
222
- if (selectId) {
223
- const node = getNode(orgsTreeData, selectId, 'id');
224
- nodeList.push(node);
225
- idList.push(node.userId);
226
- selectItem.push({
227
- value: node === null || node === void 0 ? void 0 : node.userId,
228
- data: node,
229
- });
230
- }
231
- });
232
- setCurSelectData(selectItem);
233
- onChange === null || onChange === void 0 ? void 0 : onChange(multiple ? idList : (_a = selectItem[0]) === null || _a === void 0 ? void 0 : _a.value);
234
- setOpen(false);
235
- (_b = events === null || events === void 0 ? void 0 : events.change) === null || _b === void 0 ? void 0 : _b.call(events, multiple
236
- ? { value: idList, data: nodeList }
237
- : selectItem[0]);
238
- } })))))))))({
220
+ }, onClear: () => reset(false), onConfirm: onConfirm })))))))))({
239
221
  id,
240
222
  className: cls,
241
223
  style,
@@ -264,7 +246,7 @@ const SelectViewContainer = (props) => {
264
246
  };
265
247
  const ViewCell = ({ data, showType, relation }) => {
266
248
  if (showType === 'tree') {
267
- return (React.createElement(Text, { verticalAlign: "middle", "data-testid": "defaultValueText" }, data.join(',') || '-'));
249
+ return (React.createElement(Text, { verticalAlign: "middle", "data-testid": "defaultValueText", className: "dropdown-cell" }, data.join(',') || '-'));
268
250
  }
269
251
  const defaultValue = getRelationData(relation);
270
252
  return (defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.value) ? (React.createElement(Text, { verticalAlign: "middle" }, defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.content)) : (React.createElement(Text, null, "-"));
@@ -17,8 +17,8 @@ export function dealOrgData(data?: any[]): {
17
17
  orgId: any;
18
18
  userId: any;
19
19
  }[];
20
- export function dealUserData(data: any[], isRole: any): {
21
- id: string;
20
+ export function dealUserData(data: any[], isRole: any, orgId?: string): {
21
+ id: any;
22
22
  expandable: boolean;
23
23
  selectable: boolean;
24
24
  content: any;
@@ -28,6 +28,7 @@ export function dealUserData(data: any[], isRole: any): {
28
28
  children: any;
29
29
  icon: () => JSX.Element;
30
30
  }[];
31
+ export function removeMarkString(arr?: any[]): any[];
31
32
  export function getNode(nodes: any, id: any, key: any): any;
32
33
  export function getRelationData(relation: any): {
33
34
  content: any;
@@ -17,23 +17,31 @@ export const dealOrgData = (data = []) => data.map((i) => ({
17
17
  userId: (i === null || i === void 0 ? void 0 : i.UserId) || null,
18
18
  }));
19
19
  // 处理用户数据格式
20
- export const dealUserData = (data = [], isRole) => data.map((user) => {
21
- var _a;
22
- return ({
23
- id: `${guidMod(7)}-${user.UserId}`,
24
- expandable: false,
25
- selectable: true,
26
- content: (user === null || user === void 0 ? void 0 : user[user === null || user === void 0 ? void 0 : user.PrimaryColumn]) ||
27
- ((user === null || user === void 0 ? void 0 : user.UserExtend)
28
- ? ((_a = destr(user.UserExtend)) === null || _a === void 0 ? void 0 : _a[user === null || user === void 0 ? void 0 : user.PrimaryColumn]) || user.UserId
29
- : user.UserId),
30
- userId: user.UserId,
31
- isUser: true,
32
- orgId: (user === null || user === void 0 ? void 0 : user.OrgId) || null,
33
- children: undefined,
34
- icon: isRole ? roleIcon : departIcon,
20
+ export const dealUserData = (data = [], isRole, orgId = '') => {
21
+ return data.map((user) => {
22
+ var _a, _b, _c, _d;
23
+ return ({
24
+ id: orgId ? `${orgId}-${user === null || user === void 0 ? void 0 : user.UserId}` : user === null || user === void 0 ? void 0 : user.UserId,
25
+ expandable: false,
26
+ selectable: true,
27
+ content: (user === null || user === void 0 ? void 0 : user[nameParse(user === null || user === void 0 ? void 0 : user.PrimaryColumn)]) ||
28
+ ((user === null || user === void 0 ? void 0 : user.UserExtend)
29
+ ? ((_a = destr(user.UserExtend)) === null || _a === void 0 ? void 0 : _a[nameParse(user === null || user === void 0 ? void 0 : user.PrimaryColumn)]) ||
30
+ ((_b = destr(user.UserExtend)) === null || _b === void 0 ? void 0 : _b[nameParse((_c = destr(user === null || user === void 0 ? void 0 : user.UserSchema)) === null || _c === void 0 ? void 0 : _c['x-primary-column'])]) ||
31
+ (user === null || user === void 0 ? void 0 : user[nameParse((_d = destr(user === null || user === void 0 ? void 0 : user.UserSchema)) === null || _d === void 0 ? void 0 : _d['x-primary-column'])]) ||
32
+ user.UserId
33
+ : user.UserId),
34
+ userId: user === null || user === void 0 ? void 0 : user.UserId,
35
+ isUser: true,
36
+ orgId: (user === null || user === void 0 ? void 0 : user.OrgId) || null,
37
+ children: undefined,
38
+ icon: isRole ? roleIcon : departIcon,
39
+ });
35
40
  });
36
- });
41
+ };
42
+ //用户主列字段为name时,特殊处理
43
+ const nameParse = (primaryColumn) => primaryColumn === 'name' ? 'Name' : primaryColumn;
44
+ export const removeMarkString = (arr = []) => (arr || []).map((item) => item.indexOf('-') === -1 ? item : item.split('-')[1]);
37
45
  export function guidMod(bit) {
38
46
  const str = 'qwertyuiopasdfghjklmnbvcxz1234567890';
39
47
  let cont = '';
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useRef, forwardRef, useImperativeHandle, useState, } from 'react';
1
+ import React, { useEffect, forwardRef, useImperativeHandle, useState, useCallback, } from 'react';
2
2
  import destr from 'destr';
3
3
  import classNames from '../../utils/classnames';
4
4
  import { usePlatform, randomStr } from '../../utils/platform';
@@ -60,12 +60,11 @@ export const changeHandle = ({ type, name, data, childFormItem, isPureArray, par
60
60
  };
61
61
  export default forwardRef(function FormDetail(props, ref) {
62
62
  const { className, id, style, children, events, name, value: initDetailValue, isPureArray, parent, } = props;
63
- const observeRef = useRef(null); // 当前监听对象
64
63
  const [defaultValue, setDetailValue] = useState([]);
65
64
  const [contextData, setContextData] = useState([]);
66
65
  const [childFormItem, setCildFormItem] = useState([]);
67
66
  const platform = usePlatform();
68
- const init = (defaultValue) => {
67
+ const init = useCallback((defaultValue) => {
69
68
  var _a;
70
69
  const formDetailItemValue = {};
71
70
  let childFormItem = defaultValue[0] ? Object.keys(defaultValue[0]) : [];
@@ -99,7 +98,7 @@ export default forwardRef(function FormDetail(props, ref) {
99
98
  });
100
99
  }
101
100
  catch (error) {
102
- console.log(error);
101
+ console.error(error);
103
102
  }
104
103
  const mock = newContextItem(childFormItem, name, isPureArray);
105
104
  const data = (initialValues === null || initialValues === void 0 ? void 0 : initialValues.length) ? initialValues : [mock];
@@ -111,28 +110,32 @@ export default forwardRef(function FormDetail(props, ref) {
111
110
  // eslint-disable-next-line rulesdir/no-timer
112
111
  setTimeout(() => {
113
112
  if (!isObjectEqual(formDetailItemValue, {})) {
114
- parent.setValue(formDetailItemValue);
113
+ if ((parent === null || parent === void 0 ? void 0 : parent.setValue) && typeof (parent === null || parent === void 0 ? void 0 : parent.setValue) === 'function') {
114
+ parent === null || parent === void 0 ? void 0 : parent.setValue(formDetailItemValue);
115
+ }
115
116
  }
116
117
  }, 0);
117
- };
118
+ }, [events, isPureArray, name, parent]);
118
119
  // 初始化context的值
119
120
  useEffect(() => {
120
121
  if (!isObjectEqual(initDetailValue, defaultValue)) {
121
122
  setDetailValue(initDetailValue);
122
123
  init(initDetailValue);
123
124
  }
125
+ // eslint-disable-next-line react-hooks/exhaustive-deps
124
126
  }, [initDetailValue]);
125
127
  useEffect(() => {
126
128
  init(initDetailValue);
127
129
  setDetailValue(initDetailValue);
128
130
  // 组件卸载时触发
129
131
  return () => {
130
- var _a, _b;
131
- (_a = observeRef.current) === null || _a === void 0 ? void 0 : _a.disconnect();
132
- (_b = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _b === void 0 ? void 0 : _b.call(events, { data: [] });
132
+ var _a;
133
+ (_a = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _a === void 0 ? void 0 : _a.call(events, { data: [] });
133
134
  };
135
+ // 只执行一次;
136
+ // eslint-disable-next-line react-hooks/exhaustive-deps
134
137
  }, []);
135
- const onChange = (type, params) => {
138
+ const onChange = useCallback((type, params) => {
136
139
  var _a;
137
140
  let data = destr(contextData);
138
141
  data = changeHandle({
@@ -145,7 +148,7 @@ export default forwardRef(function FormDetail(props, ref) {
145
148
  });
146
149
  setContextData(data);
147
150
  (_a = events === null || events === void 0 ? void 0 : events.onDataChange) === null || _a === void 0 ? void 0 : _a.call(events, { data });
148
- };
151
+ }, [childFormItem, contextData, events, isPureArray, name]);
149
152
  useImperativeHandle(ref, () => {
150
153
  return {
151
154
  methods: {
@@ -1,4 +1,4 @@
1
- import React, { useEffect, useMemo } from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import './index.css';
3
3
  import classNames from '../../utils/classnames';
4
4
  import { Row, Col, ConfigProvider, Button, Text } from 'tea-component';
@@ -12,7 +12,6 @@ const CLASS_PREFIX = 'weda-graphic-card';
12
12
  export default function GraphicCard({ navOption = emptyArray, ColMobile, ColPC, iconWidthSize, iconHeightSize, titleVisible, desVisible, buttonVisible, textAlign, className, titleColor, titleFontWeight, titleFontSize, titleLineHeight, titleMaxLines, desColor, desFontWeight, desFontSize, desLineHeight, desMaxLines, buttonText, style, }) {
13
13
  const platform = usePlatform();
14
14
  const isH5 = platform === 'h5';
15
- const [colCount, setColCount] = React.useState(2);
16
15
  // 一个栅格的宽度
17
16
  const { width } = useWindowSize();
18
17
  const singleGrid = useMemo(() => (width - 24 * 2) / 12, [width]);
@@ -24,10 +23,10 @@ export default function GraphicCard({ navOption = emptyArray, ColMobile, ColPC,
24
23
  [className]: className,
25
24
  [`${CLASS_PREFIX}-mobile`]: isH5,
26
25
  });
27
- useEffect(() => {
26
+ const colCount = useMemo(() => {
28
27
  const col = isH5 ? ColMobile : ColPC;
29
- setColCount(col);
30
- }, [isH5]);
28
+ return col !== null && col !== void 0 ? col : 2;
29
+ }, [ColMobile, ColPC, isH5]);
31
30
  const cardList = useMemo(() => {
32
31
  const list = [];
33
32
  if (prevColRef.current !== colCount ||
@@ -122,7 +121,7 @@ export default function GraphicCard({ navOption = emptyArray, ColMobile, ColPC,
122
121
  ? iconHeightSize
123
122
  : (Number(height) * parseInt(iconHeightSize)) / 100 + 'px';
124
123
  return { width, height };
125
- }, [iconWidthSize, iconHeightSize, ColMobile, ColPC, isH5]);
124
+ }, [platform, ColMobile, ColPC, iconWidthSize, iconHeightSize]);
126
125
  const tapTo = (colInfo = navOption[0]) => {
127
126
  switch (colInfo === null || colInfo === void 0 ? void 0 : colInfo.tapStatus) {
128
127
  case 'tap':
@@ -46,7 +46,7 @@ src, alt, mode, lazyLoad, imgPreview, maskClosable, fit, }) {
46
46
  else {
47
47
  return style;
48
48
  }
49
- }, [style, fit]);
49
+ }, [objectFit, style]);
50
50
  return src === realSrc || (realSrc !== undefined && src !== realSrc) ? (React.createElement(ImageInner, { objectFit: realFit, style: realStyle, className: cls, alt: alt, src: realSrc, isError: isError, setIsError: setIsError, events: events, lazyLoad: lazyLoad, imgPreview: imgPreview, maskClosable: maskClosable })) : null;
51
51
  }
52
52
  function getObjectFitByWxImageMode(mode) {
@@ -1,3 +1,4 @@
1
+ /* eslint-disable react-hooks/exhaustive-deps */
1
2
  import React, { useState, useEffect, useRef, useCallback } from 'react';
2
3
  import { callDataSource } from '../../utils/tcb';
3
4
  import { isInIde, getWhereList } from '../../utils/platform';
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable react/jsx-key */
2
- import React, { useState, useEffect, useCallback, useImperativeHandle, } from 'react';
2
+ import React, { useState, useEffect, useCallback, useImperativeHandle, useMemo, } from 'react';
3
3
  import { usePlatform } from '../../utils/platform';
4
4
  import classNames from '../../utils/classnames';
5
5
  import './index.css';
@@ -14,7 +14,7 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
14
14
  const [lotteryList, setLotteryList] = useState([]);
15
15
  const [btnActived, setBtnActived] = useState(false);
16
16
  //获取初始化默认数据,数据不足8条设置默认,超过8条获取前8条
17
- const lotteryListDefault = () => {
17
+ const lotteryListDefault = useMemo(() => {
18
18
  const list = [];
19
19
  if (prizeList == null) {
20
20
  return list;
@@ -39,21 +39,15 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
39
39
  }
40
40
  }
41
41
  return list;
42
- };
42
+ }, [prizeList]);
43
43
  const startLottery = useCallback(() => {
44
- setLotteryList(lotteryListDefault());
44
+ setLotteryList(lotteryListDefault);
45
45
  setBtnActived(true);
46
46
  if (lotteryAction.isStart)
47
47
  return;
48
48
  events === null || events === void 0 ? void 0 : events.clickLotteryButton();
49
49
  setIsStartLottery(true);
50
- }, [
51
- lotteryAction.isStart,
52
- setIsStartLottery,
53
- setBtnActived,
54
- lotteryListDefault,
55
- setLotteryList,
56
- ]);
50
+ }, [lotteryListDefault, events]);
57
51
  useImperativeHandle(ref, () => {
58
52
  return {
59
53
  methods: {
@@ -62,8 +56,8 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
62
56
  };
63
57
  }, [startLottery]);
64
58
  useEffect(() => {
65
- setLotteryList(lotteryListDefault());
66
- }, [prizeList]);
59
+ setLotteryList(lotteryListDefault);
60
+ }, [lotteryListDefault]);
67
61
  useEffect(() => {
68
62
  lotteryAction.animationCallback = ({ idx, isEnd }) => {
69
63
  setActivedId(idx == -1 ? 0 : idx);
@@ -90,7 +84,7 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
90
84
  }, 700);
91
85
  }
92
86
  };
93
- }, [lotteryList]);
87
+ }, [events, lotteryList]);
94
88
  useEffect(() => {
95
89
  // 当满足开启抽奖条件并且点击了开奖开关时,启用抽奖
96
90
  if (enablePrize && isStartLottery) {
@@ -108,7 +102,7 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
108
102
  //立马停止抽奖
109
103
  lotteryAction.stop();
110
104
  }
111
- }, [isStartLottery, enablePrize]);
105
+ }, [isStartLottery, enablePrize, prizeResult]);
112
106
  useEffect(() => {
113
107
  // 设置抽奖结果
114
108
  lotteryAction.end(prizeResult);
@@ -188,7 +182,7 @@ export default React.forwardRef(function Lottery({ className, id, style, prizeLi
188
182
  setDotHeight(dotHeight);
189
183
  }
190
184
  }
191
- }, [style]);
185
+ }, [platform, style]);
192
186
  const renderDot = (direction, list) => {
193
187
  return (React.createElement(React.Fragment, null,
194
188
  React.createElement("div", { className: classNames(`${CLASS_PREFIX}__dot`, `${CLASS_PREFIX}__dot-${direction}`) }, list.map((item, index) => {
@@ -54,7 +54,7 @@ export default function NavLayout({ navOption = emptyArray, mobileCol, pcCol, ic
54
54
  }, [colCount, navOption]);
55
55
  React.useEffect(() => {
56
56
  setColCount(platform === 'h5' ? mobileCol : pcCol);
57
- }, [mobileCol, pcCol]);
57
+ }, [mobileCol, pcCol, platform]);
58
58
  // 每个col的宽度百分比
59
59
  const colStyle = {
60
60
  width: `${(1 / colCount) * 100}%`,
@@ -48,7 +48,7 @@ const HorizontalMenu = ({ menuData, navigationStyle, selected, setSelected }) =>
48
48
  if (platform !== 'h5' && isHorizontal && ((_a = navWrapRef === null || navWrapRef === void 0 ? void 0 : navWrapRef.current) === null || _a === void 0 ? void 0 : _a.children)) {
49
49
  getMenuOffset();
50
50
  }
51
- }, [platform, isHorizontal, navWrapRef]);
51
+ }, [platform, isHorizontal, navWrapRef, getMenuOffset]);
52
52
  // 渲染下拉菜单
53
53
  const renderMenuList = (item, navigationStyle) => {
54
54
  return (React.createElement(List, { type: "option", className: `${CLASS_PREFIX}__dropdown-menu-list`, style: { background: navigationStyle.menuBackgroundColor } }, item === null || item === void 0 ? void 0 : item.map((menu) => {
@@ -1,4 +1,4 @@
1
- import React, { useState, useEffect } from 'react';
1
+ import React, { useState, useEffect, useCallback } from 'react';
2
2
  import classNames from '../../utils/classnames';
3
3
  import { ConfigProvider } from 'tea-component';
4
4
  import { usePlatform, isInIde } from '../../utils/platform';
@@ -79,7 +79,7 @@ export default function NavigationBar({ navigationbar, contentSlot, className, s
79
79
  ...style,
80
80
  };
81
81
  // 更新导航菜单
82
- const updateNavigationData = () => {
82
+ const updateNavigationData = useCallback(() => {
83
83
  callApi
84
84
  .getAppCustomNav()
85
85
  .then((res) => {
@@ -111,22 +111,22 @@ export default function NavigationBar({ navigationbar, contentSlot, className, s
111
111
  }
112
112
  })
113
113
  .catch((error) => {
114
- console.log(error);
114
+ console.error(error);
115
115
  });
116
- };
116
+ }, [callApi]);
117
117
  /**
118
118
  * 每次渲染组件通过接口拉取数据
119
119
  */
120
120
  useEffect(() => {
121
121
  updateNavigationData();
122
- }, []);
122
+ }, [updateNavigationData]);
123
123
  useEffect(() => {
124
124
  if (isInIde()) {
125
125
  // setMenuData(navigationbar?.menuData);
126
126
  // setNavigationStyle(navigationbar?.navigationStyle);
127
127
  updateNavigationData();
128
128
  }
129
- }, [navigationbar]);
129
+ }, [navigationbar, updateNavigationData]);
130
130
  // 初始化css变量
131
131
  useEffect(() => {
132
132
  if (navigationStyle.menuHoverColor) {