@lingxiteam/ebe-utils 0.2.22 → 0.2.23

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 (144) hide show
  1. package/lib/h5public/yarn.lock +7 -8
  2. package/lib/pcpublic/src/components/pcfactory/src/Button/index.tsx +11 -10
  3. package/lib/pcpublic/src/components/pcfactory/src/Card/CardTitle/index.tsx +31 -24
  4. package/lib/pcpublic/src/components/pcfactory/src/Card/index.tsx +32 -14
  5. package/lib/pcpublic/src/components/pcfactory/src/Card/useExtendBtn.tsx +85 -48
  6. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/ChartLine.tsx +24 -6
  7. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/PropsType.ts +31 -5
  8. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/index.tsx +3 -2
  9. package/lib/pcpublic/src/components/pcfactory/src/ChartLine/loader.tsx +1 -1
  10. package/lib/pcpublic/src/components/pcfactory/src/Form/Form.tsx +153 -129
  11. package/lib/pcpublic/src/components/pcfactory/src/Form/index.tsx +2 -5
  12. package/lib/pcpublic/src/components/pcfactory/src/Form/useFormStatus.ts +8 -4
  13. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/LXPieChart.tsx +15 -3
  14. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/PropsType.ts +4 -3
  15. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/index.tsx +1 -1
  16. package/lib/pcpublic/src/components/pcfactory/src/LXPieChart/loader.tsx +1 -1
  17. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/LXRadarChat.tsx +18 -4
  18. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/PropsType.ts +2 -1
  19. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/index.tsx +1 -1
  20. package/lib/pcpublic/src/components/pcfactory/src/LXRadarChart/loader.tsx +1 -1
  21. package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/BaseModalSelect.tsx +7 -2
  22. package/lib/pcpublic/src/components/pcfactory/src/ModalSelect/index.tsx +60 -26
  23. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/LcdpUeditorMain.tsx +62 -55
  24. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditor.tsx +2 -6
  25. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/RichTextEditorMain.tsx +5 -5
  26. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/index.tsx +9 -2
  27. package/lib/pcpublic/src/components/pcfactory/src/RichTextEditor/loader.ts +1 -1
  28. package/lib/pcpublic/src/components/pcfactory/src/Select/index.tsx +145 -66
  29. package/lib/pcpublic/src/components/pcfactory/src/Select/selectUtils.ts +13 -9
  30. package/lib/pcpublic/src/components/pcfactory/src/Table/BodyCell/index.tsx +36 -26
  31. package/lib/pcpublic/src/components/pcfactory/src/Table/EditComponent/index.tsx +69 -94
  32. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/GhostTag/index.tsx +12 -5
  33. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Hyperlink/index.tsx +9 -5
  34. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PointTag/index.tsx +11 -5
  35. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureColourFill/index.tsx +11 -5
  36. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/PureFadeColourTag/index.tsx +14 -7
  37. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/Thumbnail/index.tsx +30 -31
  38. package/lib/pcpublic/src/components/pcfactory/src/Table/FormatCell/index.tsx +89 -41
  39. package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/HeaderCellTitle/index.tsx +25 -12
  40. package/lib/pcpublic/src/components/pcfactory/src/Table/HeaderCell/index.tsx +12 -5
  41. package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/PopoverWrapper.tsx +220 -0
  42. package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/SingleBtn.tsx +39 -32
  43. package/lib/pcpublic/src/components/pcfactory/src/Table/OperationCell/index.tsx +178 -148
  44. package/lib/pcpublic/src/components/pcfactory/src/Table/Table.tsx +439 -0
  45. package/lib/pcpublic/src/components/pcfactory/src/Table/TableHead/index.tsx +159 -72
  46. package/lib/pcpublic/src/components/pcfactory/src/Table/TableSummaryRow/index.tsx +12 -20
  47. package/lib/pcpublic/src/components/pcfactory/src/Table/constant.ts +3 -0
  48. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/index.ts +4 -4
  49. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCMDActions.ts +32 -28
  50. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCheckStrict.ts +44 -57
  51. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useColumns.tsx +306 -276
  52. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useCommon.ts +9 -6
  53. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useDataSource.ts +30 -21
  54. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useExpandable.tsx +33 -27
  55. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFilter.tsx +84 -77
  56. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useFormatCell.tsx +33 -16
  57. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/usePagination.ts +15 -5
  58. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowEdit.ts +33 -33
  59. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useRowMerge.ts +13 -5
  60. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useScroll.ts +94 -28
  61. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSelection.ts +108 -99
  62. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSort.ts +8 -5
  63. package/lib/pcpublic/src/components/pcfactory/src/Table/hooks/useSummaryCol.ts +27 -43
  64. package/lib/pcpublic/src/components/pcfactory/src/Table/index.tsx +73 -394
  65. package/lib/pcpublic/src/components/pcfactory/src/Table/loader.tsx +15 -0
  66. package/lib/pcpublic/src/components/pcfactory/src/Table/types/OperationCell.d.ts +2 -2
  67. package/lib/pcpublic/src/components/pcfactory/src/Table/types/event.d.ts +12 -8
  68. package/lib/pcpublic/src/components/pcfactory/src/Table/types/headerCell.d.ts +2 -1
  69. package/lib/pcpublic/src/components/pcfactory/src/Table/types/prop.d.ts +24 -11
  70. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/SequenceId.ts +2 -1
  71. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/index.ts +90 -82
  72. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/indexedDBHelper.ts +9 -22
  73. package/lib/pcpublic/src/components/pcfactory/src/Table/utils/translate.ts +59 -0
  74. package/lib/pcpublic/src/components/pcfactory/src/Transfer/Transfer.tsx +644 -0
  75. package/lib/pcpublic/src/components/pcfactory/src/Transfer/index.tsx +49 -637
  76. package/lib/pcpublic/src/components/pcfactory/src/Transfer/loader.tsx +11 -0
  77. package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeEllipsisIcon.tsx +38 -0
  78. package/lib/pcpublic/src/components/pcfactory/src/Tree/TreeNodeMenu/index.tsx +34 -35
  79. package/lib/pcpublic/src/components/pcfactory/src/Tree/index.tsx +213 -149
  80. package/lib/pcpublic/src/components/pcfactory/src/TreeSelect/index.tsx +47 -43
  81. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/TreeTable.tsx +264 -0
  82. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/index.ts +4 -1
  83. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useCMDAction.ts +9 -3
  84. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/hooks/useExpandable.tsx +9 -3
  85. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/index.tsx +52 -191
  86. package/lib/pcpublic/src/components/pcfactory/src/TreeTable/loader.tsx +16 -0
  87. package/lib/pcpublic/src/components/pcfactory/src/assets/index.tsx +34 -0
  88. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/quadrate.tsx +20 -0
  89. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/roundness.tsx +14 -0
  90. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/semicircle.tsx +15 -0
  91. package/lib/pcpublic/src/components/pcfactory/src/assets/svg/verticalLine.tsx +12 -0
  92. package/lib/pcpublic/src/components/pcfactory/src/styles/common.less +17 -0
  93. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Card.less +57 -11
  94. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Form.less +101 -12
  95. package/lib/pcpublic/src/components/pcfactory/src/styles/components/ModalSelect.less +6 -0
  96. package/lib/pcpublic/src/components/pcfactory/src/styles/components/Select.less +70 -6
  97. package/lib/pcpublic/src/components/pcfactory/src/utils/ChannelContainer.tsx +20 -14
  98. package/lib/pcpublic/src/components/pcfactory/src/utils/ChildRender.ts +6 -8
  99. package/lib/pcpublic/src/components/pcfactory/src/utils/CustomModule.tsx +4 -6
  100. package/lib/pcpublic/src/components/pcfactory/src/utils/DummyFormContext.ts +9 -13
  101. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/empty.tsx +5 -17
  102. package/lib/pcpublic/src/components/pcfactory/src/utils/Empty/index.tsx +3 -3
  103. package/lib/pcpublic/src/components/pcfactory/src/utils/Holidays.ts +11 -39
  104. package/lib/pcpublic/src/components/pcfactory/src/utils/HolidaysFormat.ts +83 -0
  105. package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/index.tsx +47 -0
  106. package/lib/pcpublic/src/components/pcfactory/src/utils/IdleContainer/scheduler.ts +74 -0
  107. package/lib/pcpublic/src/components/pcfactory/src/utils/LoaderHelper.tsx +4 -1
  108. package/lib/pcpublic/src/components/pcfactory/src/utils/Spin/index.tsx +8 -7
  109. package/lib/pcpublic/src/components/pcfactory/src/utils/WithSyncValue.ts +25 -23
  110. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/index.ts +10 -7
  111. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMap.ts +9 -6
  112. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useMemoizedFn.ts +4 -1
  113. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/usePersistFn.ts +17 -0
  114. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSafeState.ts +2 -2
  115. package/lib/pcpublic/src/components/pcfactory/src/utils/ahooks/useSetState.ts +7 -5
  116. package/lib/pcpublic/src/components/pcfactory/src/utils/common.ts +23 -50
  117. package/lib/pcpublic/src/components/pcfactory/src/utils/constant.ts +53 -57
  118. package/lib/pcpublic/src/components/pcfactory/src/utils/dynamicUtils/DynamicContext.tsx +12 -17
  119. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormContext.tsx +22 -12
  120. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/FormFields.tsx +50 -19
  121. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/WrapperContainer.tsx +58 -37
  122. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/cmdHelper.ts +33 -30
  123. package/lib/pcpublic/src/components/pcfactory/src/utils/formUtils/common.ts +2 -0
  124. package/lib/pcpublic/src/components/pcfactory/src/utils/generatorDisabledCallback.ts +121 -113
  125. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCommonImperativeHandle.ts +16 -14
  126. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useCompState.tsx +1 -1
  127. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDataMask.ts +7 -2
  128. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useDoubleClick.ts +3 -1
  129. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useFuncExpExecute.ts +16 -14
  130. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useGetStaticAttrData.ts +9 -3
  131. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useHiddenStyle.ts +4 -5
  132. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInit.ts +11 -0
  133. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useInitReactQuill.ts +3 -1
  134. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useListenState.ts +1 -0
  135. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useLocale.ts +5 -3
  136. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/usePrintMode.tsx +2 -2
  137. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useRules.ts +1 -1
  138. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useTestHelper.ts +2 -0
  139. package/lib/pcpublic/src/components/pcfactory/src/utils/hooks/useToggleBoolean.ts +8 -4
  140. package/lib/pcpublic/src/components/pcfactory/src/utils/index.ts +10 -10
  141. package/lib/pcpublic/src/components/pcfactory/src/utils/polyfill.js +29 -31
  142. package/lib/pcpublic/src/components/pcfactory/src/utils/renderReadOnly.tsx +29 -26
  143. package/lib/public/public/iconfont.js +1 -0
  144. package/package.json +2 -2
@@ -1,18 +1,20 @@
1
1
  /* eslint-disable no-underscore-dangle */
2
2
  /* eslint-disable eqeqeq */
3
3
  /* eslint-disable no-param-reassign */
4
- import { EllipsisOutlined } from '@ant-design/icons';
5
- import { LingxiForwardRef } from '@lingxiteam/types';
6
- import { Dropdown, Input, Menu, Popconfirm, Tooltip, Tree } from 'antd';
4
+ import { Input, Menu, Popconfirm, Tooltip, Tree } from 'antd';
7
5
  import classnames from 'classnames';
8
- import { uniq } from 'lodash';
9
6
  import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
7
+ import { uniq } from 'lodash';
10
8
  import Icon from '../Icon';
11
- import { useListenProps } from '../utils';
12
- import CustomModule from '../utils/CustomModule';
9
+ import TreeNodeMenu from './TreeNodeMenu';
13
10
  import { useFuncExpExecute } from '../utils/hooks/useFuncExpExecute';
11
+ import { LingxiForwardRef } from '@lingxiteam/types';
12
+ import { useListenProps } from '../utils';
14
13
  import { useLocale } from '../utils/hooks/useLocale';
15
- import TreeNodeMenu from './TreeNodeMenu';
14
+ import useBackgroundStyle from '../View/useBackgroundStyle';
15
+ import CustomModule from '../utils/CustomModule';
16
+ import EmptyComp from '../utils/Empty';
17
+ import TreeEllipsisIcon from './TreeEllipsisIcon';
16
18
 
17
19
  const SERVICE_SOURCE = {
18
20
  // 服务来源
@@ -74,15 +76,16 @@ export interface MyTreeProps {
74
76
  isSelectAll?: boolean;
75
77
  checkable?: boolean;
76
78
  rightMenuInfo?: any;
77
- onRightClickNode?: (key: any, data: any, isLoaded: boolean, parentNodeKey: any, parentNodeData: any) => void;
79
+ onRightClickNode?: (key: any, data: any, isLoaded: boolean, parentNodeKey: any, parentNodeData: any,) => void;
78
80
  onClickMenuItem?: (key: string, menuData: any, path: any[]) => void;
79
81
  customRenderCode?: any;
80
82
  expandedKey?: any;
81
83
  closeExpandedKey?: any;
82
84
  showLine?: any;
83
85
  getEngineApis: any;
84
- nodeIconsType?: 'default' | 'forceDropdown';
85
- style?: React.CSSProperties;
86
+ nodeIconsType?: 'default' | 'forceDropdown',
87
+ style?: React.CSSProperties,
88
+ backgroundType?: any;
86
89
  }
87
90
 
88
91
  // const prefixCls = 'tree';
@@ -113,9 +116,12 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
113
116
  getEngineApis,
114
117
  nodeIconsType = 'default',
115
118
  style,
119
+ backgroundType,
120
+ $$componentItem,
116
121
  ...resetProps
117
122
  } = props;
118
123
 
124
+ const { backgroundStyle } = useBackgroundStyle({ backgroundType, engineApis: getEngineApis?.(), appId: $$componentItem?.appId, mode: 'engine' });
119
125
  const [closeExpandedKey, setCloseExpandedKey] = useListenProps(props.closeExpandedKey);
120
126
  const [expandedKey, setExpandedKey] = useListenProps(props.expandedKey);
121
127
 
@@ -126,7 +132,11 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
126
132
 
127
133
  const engineApis = getEngineApis?.() || {};
128
134
 
129
- const { sandBoxSafeRun, sandBoxLoadModule } = engineApis;
135
+ const {
136
+ sandBoxSafeRun,
137
+ sandBoxLoadModule,
138
+ dataState,
139
+ } = engineApis;
130
140
 
131
141
  const { getLocale } = useLocale(engineApis);
132
142
 
@@ -249,9 +259,14 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
249
259
 
250
260
  // isGetAll 是否获取所有节点keys,否则只获取父级的,展开时使用
251
261
  const recursiveFind = (arr: any[], oldKey: any[], keys: any[], isGetAll = false) => {
252
- arr?.forEach?.(k => {
253
- if ((Array.isArray(k.children) && k.children.length > 0 && (!oldKey.length || oldKey.find(c => c == k.key))) || isGetAll) {
254
- keys.push(oldKey.find(c => c == k.key) || String(k.key)); // id为数字的时候, 树控件识别string来判断展开节点
262
+ arr?.forEach?.((k) => {
263
+ if (
264
+ (Array.isArray(k.children) &&
265
+ k.children.length > 0 &&
266
+ (!oldKey.length || oldKey.find((c) => c == k.key))) ||
267
+ isGetAll
268
+ ) {
269
+ keys.push(oldKey.find((c) => c == k.key) || String(k.key)); // id为数字的时候, 树控件识别string来判断展开节点
255
270
  if (Array.isArray(k.children) && k?.children?.length) {
256
271
  recursiveFind(k.children, oldKey, keys, isGetAll);
257
272
  }
@@ -276,8 +291,19 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
276
291
  }, [isSelectAll, data]);
277
292
 
278
293
  const getParams = (service: any, key: any) => {
279
- const { providerId, appId, serviceCode, _source, loadKey, _serviceId, serviceVersion, sceneCode, linkCode, busiObjectId, versionCode } =
280
- service || {};
294
+ const {
295
+ providerId,
296
+ appId,
297
+ serviceCode,
298
+ _source,
299
+ loadKey,
300
+ _serviceId,
301
+ serviceVersion,
302
+ sceneCode,
303
+ linkCode,
304
+ busiObjectId,
305
+ versionCode,
306
+ } = service || {};
281
307
  let params: Record<string, any> = { [loadKey]: key };
282
308
  // 特殊服务参数处理
283
309
  if (_source === SERVICE_SOURCE.ATOM) {
@@ -344,10 +370,11 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
344
370
  const { key, title, children, selectable = 'selectable' } = service || {};
345
371
  const getTreeData = (arr: any[]) => {
346
372
  if (Array.isArray(arr)) {
347
- return arr.map(c => {
373
+ return arr.map((c) => {
348
374
  // _isReload 标识节点数据是通过加载子节点动作设置的,此时取该动作配置好的key/title/selectable,原数据放在了data字段
349
375
  const originData = c._isReload ? c.data : c;
350
- const isSelectable = transformBoolean(originData[selectable] ?? originData.selectable) ?? true;
376
+ const isSelectable =
377
+ transformBoolean(originData[selectable] ?? originData.selectable) ?? true;
351
378
  // 如果加载子节点配置了映射,优先取加载子节点的,否则取当时加载数据的映射,若都没有则取数据上的默认字段
352
379
  const nodeSelectable = c._isReload ? c.selectable ?? isSelectable : isSelectable;
353
380
  const _key = c._isReload ? c.key ?? originData[key] : originData[key] ?? originData.key;
@@ -368,8 +395,14 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
368
395
  selectable: nodeSelectable,
369
396
  isLeaf: c.isLeaf ?? originData.isLeaf ?? false,
370
397
  data: c.data || c,
371
- disableCheckbox: c.disabled ?? c.disableCheckbox ?? (nodeSelectable !== undefined ? !nodeSelectable : undefined),
372
- disabled: c.disabled ?? c.disableCheckbox ?? (nodeSelectable !== undefined ? !nodeSelectable : undefined),
398
+ disableCheckbox:
399
+ c.disabled ??
400
+ c.disableCheckbox ??
401
+ (nodeSelectable !== undefined ? !nodeSelectable : undefined),
402
+ disabled:
403
+ c.disabled ??
404
+ c.disableCheckbox ??
405
+ (nodeSelectable !== undefined ? !nodeSelectable : undefined),
373
406
  };
374
407
  // 优先取配置的children字段,若配置错误则子节点为空,若无配置默认访问数据自身chidren
375
408
  const childrenKey = children || 'children';
@@ -443,7 +476,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
443
476
  const findTreeDataByKey = (treeD: any, keys: string[]) => {
444
477
  const selectedData: any[] = [];
445
478
  const findSelectedData = (arr: any[]) => {
446
- arr.forEach(c => {
479
+ arr.forEach((c) => {
447
480
  if (keys?.includes(String(c.key))) {
448
481
  selectedData.push(c.data || c);
449
482
  }
@@ -485,7 +518,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
485
518
 
486
519
  const loadNodeData = (node: any) => {
487
520
  const { children, eventKey } = node.props;
488
- return new Promise<void>(resolve => {
521
+ return new Promise<void>((resolve) => {
489
522
  if (children && children.length) {
490
523
  resolve();
491
524
  return;
@@ -507,16 +540,13 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
507
540
  }
508
541
  engineApis?.service?.commonFetch(serviceMethod, asyncService.api, params).then(
509
542
  (res: string | any[]) => {
510
- setLoadedKeys(pre => {
543
+ setLoadedKeys((pre) => {
511
544
  const newKeys = new Set([...pre, eventKey]);
512
545
  return [...newKeys];
513
546
  });
514
547
  if (Array.isArray(res) && res.length) {
515
548
  const source = loadTreeData(res, asyncService);
516
- node.props.dataRef.children = source.map(c => ({
517
- ...c,
518
- isLeaf: false,
519
- }));
549
+ node.props.dataRef.children = source.map((c) => ({ ...c, isLeaf: false }));
520
550
  node.props.dataRef.isLeaf = false;
521
551
  } else {
522
552
  node.props.dataRef.children = undefined;
@@ -530,12 +560,16 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
530
560
  node.props.dataRef.isLeaf = true;
531
561
  setData([...data]);
532
562
  resolve(err);
533
- }
563
+ },
534
564
  );
535
565
  });
536
566
  };
537
567
 
538
- const onClickIcon = (e: React.MouseEvent<HTMLSpanElement, MouseEvent>, c: Record<string, any>, icon: any) => {
568
+ const onClickIcon = (
569
+ e: React.MouseEvent<HTMLSpanElement, MouseEvent>,
570
+ c: Record<string, any>,
571
+ icon: any,
572
+ ) => {
539
573
  // e.stopPropagation();
540
574
 
541
575
  // 设置当前操作key
@@ -558,12 +592,20 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
558
592
  }
559
593
  };
560
594
 
561
- const renderIconFont = (c: Record<string, any>, icon: any, dropdown?: boolean) => {
595
+ const renderIconFont = (c: Record<string, any>, icon: any, dropdown?: boolean, onCloseDropdown?: Function) => {
562
596
  return dropdown ? (
563
- <span className="ued-tree-icon-dropdown" onClick={e => onClickIcon(e, c, icon)}>
597
+ <span
598
+ className="ued-tree-icon-dropdown"
599
+ onClick={(e) => {
600
+ if (typeof onCloseDropdown === 'function') {
601
+ onCloseDropdown();
602
+ }
603
+ onClickIcon(e, c, icon);
604
+ }}
605
+ >
564
606
  {/* ! 旧数据下,菜单不显示图标 */}
565
607
  {/* { 当nodeIconsType为dropdown时,显示图标 } */}
566
- {forceDrowdown && (
608
+ {forceDrowdown && icon?.icon && (
567
609
  <span className="ued-treedropdown-icon">
568
610
  <Icon
569
611
  key={icon}
@@ -582,7 +624,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
582
624
  {icon?.title || iconMap[icon]?.name}
583
625
  </span>
584
626
  ) : (
585
- <span className="ued-tree-icon" onClick={e => onClickIcon(e, c, icon)}>
627
+ <span className="ued-tree-icon" onClick={(e) => onClickIcon(e, c, icon)}>
586
628
  <Icon
587
629
  key={icon}
588
630
  appId={appId}
@@ -601,21 +643,24 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
601
643
 
602
644
  const getRuleFunc = (rule: string) => {
603
645
  if (!rule) {
604
- return () => {};
646
+ return () => { };
605
647
  }
606
648
  if (typeof rule === 'function') {
607
649
  return rule;
608
650
  }
609
651
  if (typeof rule === 'string') {
610
652
  // eslint-disable-next-line no-new-func
611
- return new Function('node', `try { return ${rule};} catch(e) { console.warn("${rule}${getLocale?.('nodeRule')}");}`);
653
+ return new Function(
654
+ 'node',
655
+ `try { return ${rule};} catch(e) { console.warn("${rule}${getLocale?.('nodeRule')}");}`,
656
+ );
612
657
  }
613
- return () => {};
658
+ return () => { };
614
659
  };
615
660
 
616
661
  const nodeIconsInfo = useMemo(() => {
617
662
  if (nodeIcons?.length) {
618
- return nodeIcons.map(node => {
663
+ return nodeIcons.map((node) => {
619
664
  if (typeof node === 'string') {
620
665
  return {
621
666
  icon: {
@@ -641,7 +686,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
641
686
  return [];
642
687
  }, [JSON.stringify(nodeIcons || {})]);
643
688
 
644
- const renderDelete = (c: Record<string, any>, icon: any, dropdown?: boolean) => (
689
+ const renderDelete = (c: Record<string, any>, icon: any, dropdown?: boolean, onCloseDropdown?: Function) => (
645
690
  <Popconfirm
646
691
  onVisibleChange={v => v && setPopVisible({ ...popVisible, [c.key]: false })}
647
692
  key={`${icon?.type || icon}_1`}
@@ -655,6 +700,9 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
655
700
  // 父节点数据保持一致,为平台包装后的数据,访问原数据需要从.data节点获取
656
701
  onNodeDelete(c.key, c.data, c?.data?.parentNode?.key, c?.data?.parentNode);
657
702
  }
703
+ if (typeof onCloseDropdown === 'function') {
704
+ onCloseDropdown();
705
+ }
658
706
  }}
659
707
  onCancel={(e: any) => e.stopPropagation()}
660
708
  >
@@ -662,17 +710,19 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
662
710
  </Popconfirm>
663
711
  );
664
712
 
665
- const renderIcons = (c: Record<string, any>, icons: any[], dropdown?: boolean) =>
713
+ const renderIcons = (c: Record<string, any>, icons: any[], dropdown?: boolean, onCloseDropdown?: Function) =>
666
714
  dropdown ? (
667
- <Menu onClick={e => e.domEvent.stopPropagation()}>
668
- {icons.map(icon => (
715
+ <Menu onClick={(e) => e.domEvent.stopPropagation()}>
716
+ {icons.map((icon) => (
669
717
  <Menu.Item key={icon?.type || icon}>
670
- {(icon?.type || icon) === 'delete' ? renderDelete(c, icon, dropdown) : renderIconFont(c, icon, dropdown)}
718
+ {(icon?.type || icon) === 'delete'
719
+ ? renderDelete(c, icon, dropdown, onCloseDropdown)
720
+ : renderIconFont(c, icon, dropdown, onCloseDropdown)}
671
721
  </Menu.Item>
672
722
  ))}
673
723
  </Menu>
674
724
  ) : (
675
- icons.map(icon =>
725
+ icons.map((icon) =>
676
726
  (icon?.type || icon) === 'delete' ? (
677
727
  <Tooltip
678
728
  title={icon?.title || iconMap[icon]?.name}
@@ -682,8 +732,10 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
682
732
  {renderDelete(c, icon)}
683
733
  </Tooltip>
684
734
  ) : (
685
- <Tooltip title={icon?.title || iconMap[icon]?.name}>{renderIconFont(c, icon)}</Tooltip>
686
- )
735
+ <Tooltip title={icon?.title || iconMap[icon]?.name}>
736
+ {renderIconFont(c, icon)}
737
+ </Tooltip>
738
+ ),
687
739
  )
688
740
  );
689
741
 
@@ -719,9 +771,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
719
771
  </div>
720
772
  );
721
773
  } else if (codeStr && funcExpExecute) {
722
- if (codeStr.toString().indexOf('节点名称hover展示全称') > -1) {
723
- isTooltip = true;
724
- }
774
+ if (codeStr.toString().indexOf('节点名称hover展示全称') > -1) isTooltip = true;
725
775
  context = (
726
776
  <div
727
777
  style={{ position: 'relative' }}
@@ -756,7 +806,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
756
806
  const renderTitle = (c: Record<string, any>, i: number) => {
757
807
  let iconsDom: any = null;
758
808
  if (!resetProps.disabled && Array.isArray(nodeIconsInfo) && nodeIconsInfo.length) {
759
- const finalNodeIcons = nodeIconsInfo.filter(node => {
809
+ const finalNodeIcons = nodeIconsInfo.filter((node) => {
760
810
  if (node.rule && typeof node.rule === 'function') {
761
811
  try {
762
812
  return !node.rule(c);
@@ -774,21 +824,19 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
774
824
  );
775
825
  } else {
776
826
  iconsDom = (
777
- <div className="ued-tree-icons">
778
- <Dropdown trigger={['click']} overlay={renderIcons(c, finalNodeIcons, true) as any} getPopupContainer={(node: any) => node}>
779
- <EllipsisOutlined
780
- rev=""
781
- className="ued-tree-icon"
782
- onClick={(e: { stopPropagation: () => void }) => {
783
- e.stopPropagation();
784
- }}
785
- />
786
- </Dropdown>
787
- </div>
827
+ <TreeEllipsisIcon
828
+ trigger={['click']}
829
+ overlayFn={(onClose) => renderIcons(c, finalNodeIcons, true, onClose) as any}
830
+ // 不挂在当前层级,避免被overflow hidden截取
831
+ // getPopupContainer={(node: any) => node}
832
+ overlayClassName="ued-tree-ellipsis-menu"
833
+ />
788
834
  );
789
835
  }
790
836
  }
791
837
 
838
+ const treeTitle = renderContent(c, i);
839
+
792
840
  return (
793
841
  <div
794
842
  onContextMenu={() => {
@@ -816,7 +864,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
816
864
  overlayClassName="ued-tree-menu"
817
865
  menuData={rightMenuData[c.key]}
818
866
  >
819
- <div className="tree-tit-item">{renderContent(c, i)}</div>
867
+ <div className="tree-tit-item" title={treeTitle}>{treeTitle}</div>
820
868
  </TreeNodeMenu>
821
869
  {iconsDom}
822
870
  </div>
@@ -829,6 +877,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
829
877
  return (
830
878
  <Icon
831
879
  {...info}
880
+ icon={info}
832
881
  appId={appId}
833
882
  isUsePrimary={treeNodeIcon?.isUsePrimary}
834
883
  style={{
@@ -875,10 +924,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
875
924
  extRules.forEach((iconRule: any) => {
876
925
  const { rule } = iconRule;
877
926
  if (typeof rule === 'function') {
878
- const ruleResult = rule({
879
- ...node,
880
- ...(data?.dataRef || data || {}),
881
- });
927
+ const ruleResult = rule({ ...node, ...(data?.dataRef || data || {}) });
882
928
  if (ruleResult) {
883
929
  // 为真时表示配置该图标
884
930
  info = iconRule;
@@ -902,10 +948,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
902
948
  const createNodes = (nodes: any[], parentNode?: any) =>
903
949
  Array.isArray(nodes) && nodes.length > 0
904
950
  ? nodes.map((c, i) => {
905
- const nodeWithParent = {
906
- ...c,
907
- data: { ...(c.data || {}), parentNode },
908
- };
951
+ const nodeWithParent = { ...c, data: { ...(c.data || {}), parentNode } };
909
952
  const nodeProps: any = { dataRef: c };
910
953
  return (
911
954
  <TreeNode
@@ -914,10 +957,21 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
914
957
  data={nodeWithParent.data}
915
958
  isLeaf={c.isLeaf}
916
959
  selectable={c.selectable}
917
- disableCheckbox={c.disabled ?? c.disableCheckbox ?? (c.selectable !== undefined ? !c.selectable : undefined)}
918
- disabled={c.disabled ?? c.disableCheckbox ?? (c.selectable !== undefined ? !c.selectable : undefined)}
919
- className={classnames(!c.children || !c.children.length ? 'ued-tree-node-leaf' : '', 'ued-tree-tree-node')}
920
- domRef={ref => {
960
+ disableCheckbox={
961
+ c.disabled ??
962
+ c.disableCheckbox ??
963
+ (c.selectable !== undefined ? !c.selectable : undefined)
964
+ }
965
+ disabled={
966
+ c.disabled ??
967
+ c.disableCheckbox ??
968
+ (c.selectable !== undefined ? !c.selectable : undefined)
969
+ }
970
+ className={classnames(
971
+ !c.children || !c.children.length ? 'ued-tree-node-leaf' : '',
972
+ 'ued-tree-tree-node',
973
+ )}
974
+ domRef={(ref) => {
921
975
  if (c.matchFlag && !scrollIntoViewComp?.current && ref && treeWrapRef?.current) {
922
976
  let currentComp: HTMLElement | null = ref.parentElement;
923
977
  while (currentComp !== treeWrapRef?.current && currentComp) {
@@ -952,7 +1006,7 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
952
1006
  const nodeMap = new WeakMap();
953
1007
  const recursiveGetChildren = (d: any) => {
954
1008
  if (Array.isArray(d) && d.length) {
955
- d.forEach(c => {
1009
+ d.forEach((c) => {
956
1010
  if (c.children) {
957
1011
  nodeMap.set(c, c.children);
958
1012
  recursiveGetChildren(c.children);
@@ -978,20 +1032,6 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
978
1032
  const newD = c;
979
1033
  newD.title = tit;
980
1034
  const originChildrenData = childrenData.get(newD);
981
- if (originChildrenData) {
982
- newD.children = originChildrenData;
983
- }
984
- if (newD.children) {
985
- // 增加父级key路径
986
- let pathKeys = newD.pathKeys || [];
987
- if (newD.key) {
988
- pathKeys = [...pathKeys, newD.key];
989
- }
990
- newD.children.forEach((d: any) => {
991
- d.pathKeys = pathKeys;
992
- });
993
- newD.children = recursiveFilter(newD.children);
994
- }
995
1035
 
996
1036
  // 自定义渲染函数-新数据格式
997
1037
  // 自定义渲染函数-旧数据格式兼容 {code: string, originCode: string}
@@ -1018,12 +1058,30 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
1018
1058
  titText = funCodeRes.replace(/<\/?[^>]*>/g, '').replace(/[|]*\n|\s*/g, '');
1019
1059
  }
1020
1060
 
1021
- if (titText?.includes(searchVal || '') || newD.children?.length > 0) {
1022
- if (titText.includes(searchVal || '') && !firstMatchFlag) {
1023
- firstMatchFlag = true;
1024
- // 匹配中的第一个节点出现在可视区域内
1025
- newD.matchFlag = true;
1061
+ if (titText?.includes(searchVal || '') && !firstMatchFlag) {
1062
+ firstMatchFlag = true;
1063
+ // 匹配中的第一个节点出现在可视区域内
1064
+ newD.matchFlag = true;
1065
+ } else {
1066
+ newD.matchFlag = false;
1067
+ }
1068
+
1069
+ if (originChildrenData) {
1070
+ newD.children = originChildrenData;
1071
+ }
1072
+ if (newD.children) {
1073
+ // 增加父级key路径
1074
+ let pathKeys = newD.pathKeys || [];
1075
+ if (newD.key) {
1076
+ pathKeys = [...pathKeys, newD.key];
1026
1077
  }
1078
+ newD.children.forEach((d: any) => {
1079
+ d.pathKeys = pathKeys;
1080
+ });
1081
+ newD.children = recursiveFilter(newD.children);
1082
+ }
1083
+
1084
+ if (titText?.includes(searchVal || '') || newD.children?.length > 0) {
1027
1085
  // 匹配中或存在子节点的,保留
1028
1086
  newArr.push(newD);
1029
1087
  }
@@ -1059,77 +1117,83 @@ const MyTree = LingxiForwardRef<any, MyTreeProps>((props, ref) => {
1059
1117
  // 展开指定节点
1060
1118
  useEffect(() => {
1061
1119
  if (Array.isArray(closeExpandedKey) && closeExpandedKey?.length && filterData?.length) {
1062
- const _expandedKeys = expandedKeys.filter(key => !closeExpandedKey.includes(key));
1120
+ const _expandedKeys = expandedKeys.filter((key) => !closeExpandedKey.includes(key));
1063
1121
  setExpandedKeys(_expandedKeys);
1064
1122
  }
1065
1123
  }, [closeExpandedKey]);
1066
1124
 
1125
+ const renderEmpty = (
1126
+ <EmptyComp getLocale={getLocale} dataState={dataState} />
1127
+ );
1128
+
1067
1129
  return visible ? (
1068
- <div className={classnames('ued-tree-wrap', className)} ref={treeWrapRef} style={style}>
1130
+ <div className={classnames('ued-tree-wrap', className)} ref={treeWrapRef} style={{ ...backgroundStyle, ...style }}>
1069
1131
  {showSearch && (
1070
1132
  <Input.Search
1071
1133
  className="ued-tree-search"
1072
1134
  value={searchVal}
1073
- onChange={e => {
1135
+ onChange={(e) => {
1074
1136
  setSearchVal(e.target.value);
1075
1137
  }}
1076
1138
  />
1077
1139
  )}
1078
- <Tree
1079
- {...resetProps}
1080
- className={classnames('ued-tree', !showLineIcon ? 'ued-tree-no-line-icon' : '')}
1081
- selectedKeys={selectedKeys}
1082
- checkedKeys={checkedKeys}
1083
- showLine={
1084
- resetProps?.showLine
1085
- ? {
1086
- showLeafIcon: false,
1140
+ {!filterData || !filterData?.length ? renderEmpty : (
1141
+ <Tree
1142
+ {...resetProps}
1143
+ className={classnames('ued-tree', !showLineIcon ? 'ued-tree-no-line-icon' : '')}
1144
+ selectedKeys={selectedKeys}
1145
+ checkedKeys={checkedKeys}
1146
+ showLine={
1147
+ resetProps?.showLine
1148
+ ? {
1149
+ showLeafIcon: false,
1150
+ }
1151
+ : false
1152
+ }
1153
+ defaultExpandAll={isAsync && asyncService ? false : defaultExpandAll}
1154
+ loadedKeys={loadedKeys}
1155
+ onExpand={(keys: any[], eventData) => {
1156
+ const { node, expanded } = eventData;
1157
+ const parentNode: any = (eventData?.node as any)?.data?.parentNode;
1158
+ setExpandedKeys(keys);
1159
+ // 展开的时候触发
1160
+ if (expanded) {
1161
+ if (typeof onExpand === 'function') {
1162
+ onExpand(
1163
+ node.key,
1164
+ (node.children || []).map((c: any) => c.key),
1165
+ parentNode?.key,
1166
+ parentNode,
1167
+ );
1168
+ } else {
1169
+ node.isLeaf = !(node?.children && node?.children.length > 0);
1170
+ }
1087
1171
  }
1088
- : false
1089
- }
1090
- defaultExpandAll={isAsync && asyncService ? false : defaultExpandAll}
1091
- loadedKeys={loadedKeys}
1092
- onExpand={(keys: any[], eventData) => {
1093
- const { node, expanded } = eventData;
1094
- const parentNode: any = (eventData?.node as any)?.data?.parentNode;
1095
- setExpandedKeys(keys);
1096
- // 展开的时候触发
1097
- if (expanded) {
1098
- if (typeof onExpand === 'function') {
1099
- onExpand(
1100
- node.key,
1101
- (node.children || []).map((c: any) => c.key),
1102
- parentNode?.key,
1103
- parentNode
1104
- );
1105
- } else {
1106
- node.isLeaf = !(node?.children && node?.children.length > 0);
1172
+ }}
1173
+ expandedKeys={expandedKeys}
1174
+ onCheck={(checked: any) => {
1175
+ // 重新设置选项时,重置全选状态
1176
+ setCheckedKeys(checked);
1177
+ setIsSelectAll(false);
1178
+ if (onCheck) {
1179
+ onCheck(checked);
1107
1180
  }
1108
- }
1109
- }}
1110
- expandedKeys={expandedKeys}
1111
- onCheck={(checked: any) => {
1112
- // 重新设置选项时,重置全选状态
1113
- setCheckedKeys(checked);
1114
- setIsSelectAll(false);
1115
- if (onCheck) {
1116
- onCheck(checked);
1117
- }
1118
- }}
1119
- onSelect={(keys: any[], e: any) => {
1120
- setSelectedKeys(keys);
1121
- const selectedData = findTreeDataByKey(data, keys);
1122
- setSelectDataList(selectedData);
1123
- if (onSelect) {
1124
- onSelect(keys, e, e?.node?.data?.parentNode?.key, e?.node?.data?.parentNode);
1125
- }
1126
- }}
1127
- showIcon={showLineIcon}
1128
- icon={showLineIcon ? renderNodeIcon : undefined}
1129
- loadData={isAsync && asyncService ? loadNodeData : undefined}
1130
- >
1131
- {createNodes(filterData)}
1132
- </Tree>
1181
+ }}
1182
+ onSelect={(keys: any[], e: any) => {
1183
+ setSelectedKeys(keys);
1184
+ const selectedData = findTreeDataByKey(data, keys);
1185
+ setSelectDataList(selectedData);
1186
+ if (onSelect) {
1187
+ onSelect(keys, e, e?.node?.data?.parentNode?.key, e?.node?.data?.parentNode);
1188
+ }
1189
+ }}
1190
+ showIcon={showLineIcon}
1191
+ icon={showLineIcon ? renderNodeIcon : undefined}
1192
+ loadData={isAsync && asyncService ? loadNodeData : undefined}
1193
+ >
1194
+ {createNodes(filterData)}
1195
+ </Tree>
1196
+ )}
1133
1197
  </div>
1134
1198
  ) : null;
1135
1199
  });