@zat-design/sisyphus-react 3.13.18-beta.3 → 3.13.18-beta.4

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 (25) hide show
  1. package/es/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +1 -3
  2. package/es/ProForm/components/combination/ProModalSelect/index.js +24 -11
  3. package/es/ProForm/components/combination/ProModalSelect/propsType.d.ts +5 -1
  4. package/es/ProForm/components/combination/ProModalSelect/style/index.less +2 -2
  5. package/es/ProLayout/components/Layout/Menu/FoldMenu/index.js +57 -8
  6. package/es/ProLayout/components/Layout/Menu/OpenMenu/index.js +23 -3
  7. package/es/ProLayout/components/Layout/Menu/SideMenu/index.js +3 -1
  8. package/es/ProLayout/components/Layout/Menu/index.js +4 -1
  9. package/es/ProLayout/index.js +3 -1
  10. package/es/ProLayout/propTypes.d.ts +9 -0
  11. package/es/ProLayout/utils/index.d.ts +7 -0
  12. package/es/ProLayout/utils/index.js +31 -1
  13. package/lib/ProForm/components/combination/ProModalSelect/hooks/useRequestList.js +1 -3
  14. package/lib/ProForm/components/combination/ProModalSelect/index.js +25 -12
  15. package/lib/ProForm/components/combination/ProModalSelect/propsType.d.ts +5 -1
  16. package/lib/ProForm/components/combination/ProModalSelect/style/index.less +2 -2
  17. package/lib/ProLayout/components/Layout/Menu/FoldMenu/index.js +56 -7
  18. package/lib/ProLayout/components/Layout/Menu/OpenMenu/index.js +22 -2
  19. package/lib/ProLayout/components/Layout/Menu/SideMenu/index.js +3 -1
  20. package/lib/ProLayout/components/Layout/Menu/index.js +4 -1
  21. package/lib/ProLayout/index.js +3 -1
  22. package/lib/ProLayout/propTypes.d.ts +9 -0
  23. package/lib/ProLayout/utils/index.d.ts +7 -0
  24. package/lib/ProLayout/utils/index.js +30 -1
  25. package/package.json +1 -1
@@ -98,9 +98,7 @@ export function useRequestList(service, options, useRequestOptions) {
98
98
  }, [onChange, searchValues]);
99
99
  // 重置查询条件
100
100
  var onReset = useCallback(function () {
101
- onSearch({
102
- d: Date.now()
103
- });
101
+ onSearch({});
104
102
  }, [onSearch]);
105
103
  var dataSource = useMemo(function () {
106
104
  if (data) {
@@ -23,7 +23,7 @@ import _isFunction from "lodash/isFunction";
23
23
  import _isEqual from "lodash/isEqual";
24
24
  import _isArray from "lodash/isArray";
25
25
  import _debounce from "lodash/debounce";
26
- var _excluded = ["value", "onChange", "disabled", "labelInValue", "fieldNames", "readOnly", "addonAfter", "configOption", "title", "onFormat", "showCodeName", "optionRender", "customRender", "style", "className", "beforeOpen", "afterOpen", "isTooltip", "searchForm", "searchKey", "defaultOne", "otherProps"],
26
+ var _excluded = ["value", "onChange", "disabled", "labelInValue", "fieldNames", "readOnly", "mode", "addonAfter", "configOption", "title", "onFormat", "showCodeName", "optionRender", "customRender", "style", "className", "beforeOpen", "afterOpen", "isTooltip", "tooltip", "searchForm", "searchKey", "defaultOne", "otherProps"],
27
27
  _excluded2 = ["onOk"],
28
28
  _excluded3 = ["rowKey", "columns", "rowSelection"];
29
29
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
@@ -48,6 +48,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
48
48
  fieldNames = props.fieldNames,
49
49
  _props$readOnly = props.readOnly,
50
50
  readOnly = _props$readOnly === void 0 ? true : _props$readOnly,
51
+ _props$mode = props.mode,
52
+ mode = _props$mode === void 0 ? 'select' : _props$mode,
51
53
  addonAfter = props.addonAfter,
52
54
  configOption = props.configOption,
53
55
  title = props.title,
@@ -60,11 +62,22 @@ var ProModalSelect = function ProModalSelect(props, ref) {
60
62
  beforeOpen = props.beforeOpen,
61
63
  afterOpen = props.afterOpen,
62
64
  isTooltip = props.isTooltip,
65
+ tooltip = props.tooltip,
63
66
  searchForm = props.searchForm,
64
67
  searchKey = props.searchKey,
65
68
  defaultOne = props.defaultOne,
66
69
  otherProps = props.otherProps,
67
70
  restProps = _objectWithoutProperties(props, _excluded);
71
+ var _tooltip = tooltip !== null && tooltip !== void 0 ? tooltip : isTooltip;
72
+ var _readOnly = readOnly;
73
+ if (mode) {
74
+ if (String(mode) === 'input') {
75
+ _readOnly = false;
76
+ }
77
+ if (String(mode) === 'select') {
78
+ _readOnly = true;
79
+ }
80
+ }
68
81
  var contentForm = _Form.useFormInstance();
69
82
  if (!configOption || Object.prototype.toString.call(configOption) !== '[object Object]') {
70
83
  throw new Error('error: 请检查枚举选择弹框的配置项【configOption】');
@@ -172,7 +185,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
172
185
  transformResponse: transformResponse
173
186
  }, _objectSpread({
174
187
  manual: true,
175
- ready: (initParams || defaultOne) && !readOnly || visible
188
+ ready: (initParams || defaultOne) && !_readOnly || visible
176
189
  }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options)),
177
190
  data = _useRequestList2.data,
178
191
  loading = _useRequestList2.loading,
@@ -262,7 +275,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
262
275
  var handleChangeValue = function handleChangeValue(e) {
263
276
  onChange(e.target.value);
264
277
  preValue.current = e.target.value;
265
- if (!readOnly) {
278
+ if (!_readOnly) {
266
279
  setState({
267
280
  _value: e.target.value
268
281
  });
@@ -520,7 +533,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
520
533
  selectedRows: list,
521
534
  selectedRowKeys: nextSelectRowKeys
522
535
  });
523
- } else if (!readOnly) {
536
+ } else if (!_readOnly) {
524
537
  // 当传入initParams且文本框非只读时,不调用接口获取初始化数据
525
538
  setState({
526
539
  _value: value,
@@ -663,12 +676,12 @@ var ProModalSelect = function ProModalSelect(props, ref) {
663
676
  hideTooltipIfOpen(fieldRef.current, visible);
664
677
  }, [visible]);
665
678
  useEffect(function () {
666
- if (value && !visible && isInit && !readOnly) {
679
+ if (value && !visible && isInit && !_readOnly) {
667
680
  getInitValues();
668
681
  }
669
682
  }, [JSON.stringify(value), visible, isInit]);
670
683
  useDebounceEffect(function () {
671
- if (value && !visible && readOnly && (!_isEqual(value, preValue.current) || (options === null || options === void 0 ? void 0 : options.length) === 0)) {
684
+ if (value && !visible && _readOnly && (!_isEqual(value, preValue.current) || (options === null || options === void 0 ? void 0 : options.length) === 0)) {
672
685
  var _options$some;
673
686
  preValue.current = value;
674
687
  var _data3 = labelInValue ? value[valueKey] : value;
@@ -735,7 +748,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
735
748
  });
736
749
  }
737
750
  }
738
- if (!readOnly) {
751
+ if (!_readOnly) {
739
752
  if (labelInValue && _value && !_isEqual(value, _value)) {
740
753
  setState({
741
754
  _value: value,
@@ -758,7 +771,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
758
771
  width: '100%'
759
772
  },
760
773
  block: true,
761
- children: [readOnly ? _jsx(ProSelect, _objectSpread({
774
+ children: [_readOnly ? _jsx(ProSelect, _objectSpread({
762
775
  value: value,
763
776
  onChange: handleSelectValue,
764
777
  disabled: disabled,
@@ -799,7 +812,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
799
812
  });
800
813
  }
801
814
  useDeepCompareEffect(function () {
802
- if (isTooltip && value) {
815
+ if (_tooltip && value) {
803
816
  var dom = document.getElementById(uuid);
804
817
  dom.addEventListener('mouseover', function (e) {
805
818
  if (value && e.target.tagName === 'INPUT') {
@@ -832,7 +845,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
832
845
  });
833
846
  };
834
847
  }
835
- }, [value, isTooltip]);
848
+ }, [value, _tooltip]);
836
849
  useDeepCompareEffect(function () {
837
850
  setState({
838
851
  options: (tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource) || []
@@ -870,7 +883,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
870
883
  className: _className,
871
884
  style: style,
872
885
  ref: fieldRef,
873
- children: isTooltip && viewText ? _jsx(_Tooltip, {
886
+ children: _tooltip && viewText ? _jsx(_Tooltip, {
874
887
  placement: "topLeft",
875
888
  open: open,
876
889
  title: viewText,
@@ -80,14 +80,18 @@ interface ProModalPropsType {
80
80
  beforeOpen?: any;
81
81
  /** 打开弹框后的回调函数 */
82
82
  afterOpen?: any;
83
- /** 是否启用tooltip提示 */
83
+ /** 废弃 是否启用tooltip提示 */
84
84
  isTooltip?: boolean;
85
+ /** 是否启用tooltip提示 */
86
+ tooltip?: boolean;
85
87
  /** 是否以"值-名称"形式展示 */
86
88
  showCodeName?: boolean;
87
89
  /** 查询表单实例,用于获取查询表单数据 */
88
90
  searchForm?: FormInstance;
89
91
  /** 模糊查询的字段名 */
90
92
  searchKey?: string;
93
+ /** 展示形式 */
94
+ mode?: 'input' | 'select';
91
95
  }
92
96
  /** 模态框选择器属性类型(结合Select和Input属性) */
93
97
  export declare type ProModalSelectPropsType = SelectProps & InputProps & ProModalPropsType;
@@ -53,7 +53,7 @@
53
53
  }
54
54
  }
55
55
 
56
- // 新加适用于 readonly false
56
+ // 新加适用于 _readOnly false
57
57
  .@{ant-prefix}-input-affix-wrapper {
58
58
  border-top-right-radius: 0;
59
59
  border-bottom-right-radius: 0;
@@ -100,7 +100,7 @@
100
100
  }
101
101
 
102
102
  .@{ant-prefix}-input-affix-wrapper-status-error{
103
-
103
+
104
104
  }
105
105
 
106
106
 
@@ -10,10 +10,11 @@ import { Link } from 'react-router-dom';
10
10
  import { Icon } from '../../index';
11
11
  import SideMenu from '../SideMenu';
12
12
  import { LayoutContext } from '../../../../index';
13
- import { getUrlParams, getPathNameKey } from '../../../../utils';
13
+ import { getUrlParams, getPathNameKey, findMenuItemByKey } from '../../../../utils';
14
14
  var FoldMenu = function FoldMenu(props) {
15
15
  var style = props.style,
16
- dataSource = props.dataSource;
16
+ dataSource = props.dataSource,
17
+ onMenuClick = props.onMenuClick;
17
18
  var menus = dataSource.menus,
18
19
  iconfontUrl = dataSource.iconfontUrl,
19
20
  notice = dataSource.notice,
@@ -82,7 +83,8 @@ var FoldMenu = function FoldMenu(props) {
82
83
  content: _jsx(SideMenu, {
83
84
  dataSource: _objectSpread(_objectSpread({}, dataSource), {}, {
84
85
  menus: item
85
- })
86
+ }),
87
+ onMenuClick: onMenuClick
86
88
  }),
87
89
  color: "#fff",
88
90
  overlayClassName: noticeCls,
@@ -91,12 +93,42 @@ var FoldMenu = function FoldMenu(props) {
91
93
  height: "calc(100vh - ".concat(headerHeight + (notice ? 32 : 0), "px)")
92
94
  },
93
95
  placement: "rightTop",
94
- children: LiNode
96
+ children: _jsx("span", {
97
+ onClick: function onClick() {
98
+ // 查找完整的菜单项数据
99
+ var menuItem = findMenuItemByKey(menus, String(id));
100
+ var menuKeyPath = (menuItem === null || menuItem === void 0 ? void 0 : menuItem.keyIdPath) ? menuItem.keyIdPath.map(function (id) {
101
+ return String(id);
102
+ }) : [String(id)];
103
+ // 调用用户传入的onMenuClick回调
104
+ if (onMenuClick) {
105
+ onMenuClick({
106
+ item: menuItem,
107
+ key: String(id),
108
+ keyPath: menuKeyPath
109
+ });
110
+ }
111
+ },
112
+ children: LiNode
113
+ })
95
114
  }, "".concat(id, "-").concat(name)) : !collapsed ? _jsx(_Tooltip, {
96
115
  placement: "right",
97
116
  title: name,
98
117
  children: _jsx("span", {
99
118
  onClick: function onClick() {
119
+ // 查找完整的菜单项数据
120
+ var menuItem = findMenuItemByKey(menus, String(id));
121
+ var menuKeyPath = (menuItem === null || menuItem === void 0 ? void 0 : menuItem.keyIdPath) ? menuItem.keyIdPath.map(function (id) {
122
+ return String(id);
123
+ }) : [String(id)];
124
+ // 调用用户传入的onMenuClick回调
125
+ if (onMenuClick) {
126
+ onMenuClick({
127
+ item: menuItem,
128
+ key: String(id),
129
+ keyPath: menuKeyPath
130
+ });
131
+ }
100
132
  onSelected({
101
133
  selectedPath: toPath
102
134
  });
@@ -106,10 +138,27 @@ var FoldMenu = function FoldMenu(props) {
106
138
  children: LiNode
107
139
  }, toPath)
108
140
  })
109
- }, toPath) : _jsx(Link, {
110
- to: toPath,
111
- children: LiNode
112
- }, toPath);
141
+ }, toPath) : _jsx("span", {
142
+ onClick: function onClick() {
143
+ // 查找完整的菜单项数据
144
+ var menuItem = findMenuItemByKey(menus, String(id));
145
+ var menuKeyPath = (menuItem === null || menuItem === void 0 ? void 0 : menuItem.keyIdPath) ? menuItem.keyIdPath.map(function (id) {
146
+ return String(id);
147
+ }) : [String(id)];
148
+ // 调用用户传入的onMenuClick回调
149
+ if (onMenuClick) {
150
+ onMenuClick({
151
+ item: menuItem,
152
+ key: String(id),
153
+ keyPath: menuKeyPath
154
+ });
155
+ }
156
+ },
157
+ children: _jsx(Link, {
158
+ to: toPath,
159
+ children: LiNode
160
+ }, toPath)
161
+ });
113
162
  })
114
163
  })
115
164
  });
@@ -10,7 +10,7 @@ import { CaretDownOutlined } from '@ant-design/icons';
10
10
  import classnames from 'classnames';
11
11
  import { Link } from 'react-router-dom';
12
12
  import { LayoutContext } from '../../../../index';
13
- import { getIdsByPathName } from '../../../../utils';
13
+ import { getIdsByPathName, findMenuItemByKey } from '../../../../utils';
14
14
  import { Icon } from '../../index';
15
15
  var OpenMenu = function OpenMenu(props) {
16
16
  var _getIdsByPathName;
@@ -18,7 +18,8 @@ var OpenMenu = function OpenMenu(props) {
18
18
  dataSource = props.dataSource,
19
19
  style = props.style,
20
20
  _props$theme = props.theme,
21
- theme = _props$theme === void 0 ? 'dark' : _props$theme;
21
+ theme = _props$theme === void 0 ? 'dark' : _props$theme,
22
+ onMenuClick = props.onMenuClick;
22
23
  var _ref = dataSource || {},
23
24
  menus = _ref.menus,
24
25
  sideMenu = _ref.sideMenu;
@@ -142,7 +143,26 @@ var OpenMenu = function OpenMenu(props) {
142
143
  onClick: function onClick(_ref2) {
143
144
  var _item$props, _item$props2;
144
145
  var item = _ref2.item,
145
- keyPath = _ref2.keyPath;
146
+ keyPath = _ref2.keyPath,
147
+ key = _ref2.key,
148
+ domEvent = _ref2.domEvent;
149
+ // console.log('item', item);
150
+ // console.log('keyPath', keyPath);
151
+ // console.log('key', key);
152
+ // console.log('domEvent', domEvent);
153
+ // 查找完整的菜单项数据
154
+ var menuItem = findMenuItemByKey(menus, key);
155
+ var menuKeyPath = (menuItem === null || menuItem === void 0 ? void 0 : menuItem.keyIdPath) ? menuItem.keyIdPath.map(function (id) {
156
+ return String(id);
157
+ }) : keyPath;
158
+ // 调用用户传入的onMenuClick回调
159
+ if (onMenuClick) {
160
+ onMenuClick({
161
+ item: menuItem,
162
+ key: key,
163
+ keyPath: menuKeyPath
164
+ });
165
+ }
146
166
  setState({
147
167
  selectedKeys: keyPath,
148
168
  router: item === null || item === void 0 ? void 0 : (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.router
@@ -4,7 +4,8 @@ import classnames from 'classnames';
4
4
  import { useSize } from 'ahooks';
5
5
  import OpenMenu from '../OpenMenu';
6
6
  var SideMenu = function SideMenu(props) {
7
- var dataSource = props.dataSource;
7
+ var dataSource = props.dataSource,
8
+ onMenuClick = props.onMenuClick;
8
9
  var ref = useRef(null);
9
10
  var size = useSize(ref);
10
11
  var menus = dataSource.menus,
@@ -24,6 +25,7 @@ var SideMenu = function SideMenu(props) {
24
25
  children: _jsx(OpenMenu, {
25
26
  className: "pro-layout-sider-menu-list",
26
27
  theme: "light",
28
+ onMenuClick: onMenuClick,
27
29
  dataSource: {
28
30
  menus: (menus === null || menus === void 0 ? void 0 : menus.children) || [],
29
31
  iconfontUrl: iconfontUrl,
@@ -13,7 +13,8 @@ var Menu = function Menu(props) {
13
13
  pure = _ref.pure,
14
14
  theme = _ref.theme,
15
15
  sideMenuFooterRender = _ref.sideMenuFooterRender,
16
- sideMenuHeaderRender = _ref.sideMenuHeaderRender;
16
+ sideMenuHeaderRender = _ref.sideMenuHeaderRender,
17
+ onMenuClick = _ref.onMenuClick;
17
18
  var menus = [];
18
19
  var menuCls = classnames({
19
20
  'pro-layout-menu': true,
@@ -39,6 +40,7 @@ var Menu = function Menu(props) {
39
40
  height: headerHeight + (notice ? 32 : 0) + 48
40
41
  },
41
42
  theme: theme,
43
+ onMenuClick: onMenuClick,
42
44
  style: {
43
45
  display: collapsed ? 'block' : 'none'
44
46
  }
@@ -51,6 +53,7 @@ var Menu = function Menu(props) {
51
53
  collapsed: collapsed,
52
54
  headerHeight: headerHeight
53
55
  },
56
+ onMenuClick: onMenuClick,
54
57
  style: {
55
58
  display: collapsed ? 'none' : 'block',
56
59
  height: "calc(100vh - ".concat(headerHeight + (notice ? 32 : 0) + 48 || 0, "px)")
@@ -30,7 +30,8 @@ var ProLayout = function ProLayout(props) {
30
30
  pathPrefix = _props$pathPrefix === void 0 ? '' : _props$pathPrefix,
31
31
  theme = props.theme,
32
32
  target = props.target,
33
- onCollapsedChange = props.onCollapsedChange;
33
+ onCollapsedChange = props.onCollapsedChange,
34
+ onMenuClick = props.onMenuClick;
34
35
  var _useSetState = useSetState({
35
36
  notice: headerNotice || noticeIn,
36
37
  menus: [],
@@ -95,6 +96,7 @@ var ProLayout = function ProLayout(props) {
95
96
  } : menus,
96
97
  notice: notice,
97
98
  collapsed: collapsed,
99
+ onMenuClick: onMenuClick,
98
100
  onToggle: function onToggle() {
99
101
  toggle();
100
102
  onCollapsedChange && onCollapsedChange(!collapsed);
@@ -180,6 +180,15 @@ export interface ProLayoutType {
180
180
  * @default -
181
181
  */
182
182
  onCollapsedChange?: (collapsed: boolean) => void;
183
+ /**
184
+ * @description 菜单点击回调事件,返回命中的菜单项数据和完整路径
185
+ * @default -
186
+ */
187
+ onMenuClick?: (params: {
188
+ item: MenusType | null;
189
+ key: string;
190
+ keyPath: string[];
191
+ }) => void;
183
192
  /**
184
193
  * @description 规定在何处打开被链接文档
185
194
  * @default "_self"
@@ -34,3 +34,10 @@ export declare const getPathNameKey: ({ menus, pathName, }: {
34
34
  menus: any[];
35
35
  pathName: string;
36
36
  }) => any;
37
+ /**
38
+ * 根据key查找完整的菜单项数据
39
+ * @param menus 菜单数据数组
40
+ * @param key 要查找的菜单项key
41
+ * @returns 找到的菜单项数据或null
42
+ */
43
+ export declare const findMenuItemByKey: (menus: any[], key: string) => any;
@@ -1,3 +1,4 @@
1
+ import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
1
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
3
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
4
  import _isPlainObject from "lodash/isPlainObject";
@@ -159,4 +160,33 @@ export var getPathNameKey = function getPathNameKey(_ref) {
159
160
  };
160
161
  _menuDeep3(menus);
161
162
  return result;
162
- };
163
+ };
164
+ /**
165
+ * 根据key查找完整的菜单项数据
166
+ * @param menus 菜单数据数组
167
+ * @param key 要查找的菜单项key
168
+ * @returns 找到的菜单项数据或null
169
+ */
170
+ var _findMenuItemByKey = function findMenuItemByKey(menus, key) {
171
+ // eslint-disable-next-line no-restricted-syntax
172
+ var _iterator = _createForOfIteratorHelper(menus),
173
+ _step;
174
+ try {
175
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
176
+ var item = _step.value;
177
+ if (String(item.id) === key) {
178
+ return item;
179
+ }
180
+ if (Array.isArray(item.children) && item.children.length) {
181
+ var found = _findMenuItemByKey(item.children, key);
182
+ if (found) return found;
183
+ }
184
+ }
185
+ } catch (err) {
186
+ _iterator.e(err);
187
+ } finally {
188
+ _iterator.f();
189
+ }
190
+ return null;
191
+ };
192
+ export { _findMenuItemByKey as findMenuItemByKey };
@@ -107,9 +107,7 @@ function useRequestList(service, options, useRequestOptions) {
107
107
  }, [onChange, searchValues]);
108
108
  // 重置查询条件
109
109
  var onReset = (0, _react.useCallback)(function () {
110
- onSearch({
111
- d: Date.now()
112
- });
110
+ onSearch({});
113
111
  }, [onSearch]);
114
112
  var dataSource = (0, _react.useMemo)(function () {
115
113
  if (data) {
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
  require("antd/es/tooltip/style");
10
- var _tooltip = _interopRequireDefault(require("antd/es/tooltip"));
10
+ var _tooltip2 = _interopRequireDefault(require("antd/es/tooltip"));
11
11
  require("antd/es/button/style");
12
12
  var _button = _interopRequireDefault(require("antd/es/button"));
13
13
  require("antd/es/input/style");
@@ -43,7 +43,7 @@ var _view = _interopRequireDefault(require("../../../../assets/view.svg"));
43
43
  var _useRequestList3 = _interopRequireDefault(require("./hooks/useRequestList"));
44
44
  var _locale = _interopRequireDefault(require("../../../../locale"));
45
45
  var _utils = require("./utils");
46
- var _excluded = ["value", "onChange", "disabled", "labelInValue", "fieldNames", "readOnly", "addonAfter", "configOption", "title", "onFormat", "showCodeName", "optionRender", "customRender", "style", "className", "beforeOpen", "afterOpen", "isTooltip", "searchForm", "searchKey", "defaultOne", "otherProps"],
46
+ var _excluded = ["value", "onChange", "disabled", "labelInValue", "fieldNames", "readOnly", "mode", "addonAfter", "configOption", "title", "onFormat", "showCodeName", "optionRender", "customRender", "style", "className", "beforeOpen", "afterOpen", "isTooltip", "tooltip", "searchForm", "searchKey", "defaultOne", "otherProps"],
47
47
  _excluded2 = ["onOk"],
48
48
  _excluded3 = ["rowKey", "columns", "rowSelection"];
49
49
  var ProModalSelect = function ProModalSelect(props, ref) {
@@ -56,6 +56,8 @@ var ProModalSelect = function ProModalSelect(props, ref) {
56
56
  fieldNames = props.fieldNames,
57
57
  _props$readOnly = props.readOnly,
58
58
  readOnly = _props$readOnly === void 0 ? true : _props$readOnly,
59
+ _props$mode = props.mode,
60
+ mode = _props$mode === void 0 ? 'select' : _props$mode,
59
61
  addonAfter = props.addonAfter,
60
62
  configOption = props.configOption,
61
63
  title = props.title,
@@ -68,11 +70,22 @@ var ProModalSelect = function ProModalSelect(props, ref) {
68
70
  beforeOpen = props.beforeOpen,
69
71
  afterOpen = props.afterOpen,
70
72
  isTooltip = props.isTooltip,
73
+ tooltip = props.tooltip,
71
74
  searchForm = props.searchForm,
72
75
  searchKey = props.searchKey,
73
76
  defaultOne = props.defaultOne,
74
77
  otherProps = props.otherProps,
75
78
  restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
79
+ var _tooltip = tooltip !== null && tooltip !== void 0 ? tooltip : isTooltip;
80
+ var _readOnly = readOnly;
81
+ if (mode) {
82
+ if (String(mode) === 'input') {
83
+ _readOnly = false;
84
+ }
85
+ if (String(mode) === 'select') {
86
+ _readOnly = true;
87
+ }
88
+ }
76
89
  var contentForm = _form.default.useFormInstance();
77
90
  if (!configOption || Object.prototype.toString.call(configOption) !== '[object Object]') {
78
91
  throw new Error('error: 请检查枚举选择弹框的配置项【configOption】');
@@ -180,7 +193,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
180
193
  transformResponse: transformResponse
181
194
  }, (0, _objectSpread5.default)({
182
195
  manual: true,
183
- ready: (initParams || defaultOne) && !readOnly || visible
196
+ ready: (initParams || defaultOne) && !_readOnly || visible
184
197
  }, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options)),
185
198
  data = _useRequestList2.data,
186
199
  loading = _useRequestList2.loading,
@@ -270,7 +283,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
270
283
  var handleChangeValue = function handleChangeValue(e) {
271
284
  onChange(e.target.value);
272
285
  preValue.current = e.target.value;
273
- if (!readOnly) {
286
+ if (!_readOnly) {
274
287
  setState({
275
288
  _value: e.target.value
276
289
  });
@@ -528,7 +541,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
528
541
  selectedRows: list,
529
542
  selectedRowKeys: nextSelectRowKeys
530
543
  });
531
- } else if (!readOnly) {
544
+ } else if (!_readOnly) {
532
545
  // 当传入initParams且文本框非只读时,不调用接口获取初始化数据
533
546
  setState({
534
547
  _value: value,
@@ -671,12 +684,12 @@ var ProModalSelect = function ProModalSelect(props, ref) {
671
684
  (0, _utils.hideTooltipIfOpen)(fieldRef.current, visible);
672
685
  }, [visible]);
673
686
  (0, _react.useEffect)(function () {
674
- if (value && !visible && isInit && !readOnly) {
687
+ if (value && !visible && isInit && !_readOnly) {
675
688
  getInitValues();
676
689
  }
677
690
  }, [JSON.stringify(value), visible, isInit]);
678
691
  (0, _ahooks.useDebounceEffect)(function () {
679
- if (value && !visible && readOnly && (!(0, _isEqual2.default)(value, preValue.current) || (options === null || options === void 0 ? void 0 : options.length) === 0)) {
692
+ if (value && !visible && _readOnly && (!(0, _isEqual2.default)(value, preValue.current) || (options === null || options === void 0 ? void 0 : options.length) === 0)) {
680
693
  var _options$some;
681
694
  preValue.current = value;
682
695
  var _data3 = labelInValue ? value[valueKey] : value;
@@ -743,7 +756,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
743
756
  });
744
757
  }
745
758
  }
746
- if (!readOnly) {
759
+ if (!_readOnly) {
747
760
  if (labelInValue && _value && !(0, _isEqual2.default)(value, _value)) {
748
761
  setState({
749
762
  _value: value,
@@ -766,7 +779,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
766
779
  width: '100%'
767
780
  },
768
781
  block: true,
769
- children: [readOnly ? (0, _jsxRuntime.jsx)(_index.ProSelect, (0, _objectSpread5.default)({
782
+ children: [_readOnly ? (0, _jsxRuntime.jsx)(_index.ProSelect, (0, _objectSpread5.default)({
770
783
  value: value,
771
784
  onChange: handleSelectValue,
772
785
  disabled: disabled,
@@ -807,7 +820,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
807
820
  });
808
821
  }
809
822
  (0, _ahooks.useDeepCompareEffect)(function () {
810
- if (isTooltip && value) {
823
+ if (_tooltip && value) {
811
824
  var dom = document.getElementById(uuid);
812
825
  dom.addEventListener('mouseover', function (e) {
813
826
  if (value && e.target.tagName === 'INPUT') {
@@ -840,7 +853,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
840
853
  });
841
854
  };
842
855
  }
843
- }, [value, isTooltip]);
856
+ }, [value, _tooltip]);
844
857
  (0, _ahooks.useDeepCompareEffect)(function () {
845
858
  setState({
846
859
  options: (tableProps === null || tableProps === void 0 ? void 0 : tableProps.dataSource) || []
@@ -878,7 +891,7 @@ var ProModalSelect = function ProModalSelect(props, ref) {
878
891
  className: _className,
879
892
  style: style,
880
893
  ref: fieldRef,
881
- children: isTooltip && viewText ? (0, _jsxRuntime.jsx)(_tooltip.default, {
894
+ children: _tooltip && viewText ? (0, _jsxRuntime.jsx)(_tooltip2.default, {
882
895
  placement: "topLeft",
883
896
  open: open,
884
897
  title: viewText,
@@ -80,14 +80,18 @@ interface ProModalPropsType {
80
80
  beforeOpen?: any;
81
81
  /** 打开弹框后的回调函数 */
82
82
  afterOpen?: any;
83
- /** 是否启用tooltip提示 */
83
+ /** 废弃 是否启用tooltip提示 */
84
84
  isTooltip?: boolean;
85
+ /** 是否启用tooltip提示 */
86
+ tooltip?: boolean;
85
87
  /** 是否以"值-名称"形式展示 */
86
88
  showCodeName?: boolean;
87
89
  /** 查询表单实例,用于获取查询表单数据 */
88
90
  searchForm?: FormInstance;
89
91
  /** 模糊查询的字段名 */
90
92
  searchKey?: string;
93
+ /** 展示形式 */
94
+ mode?: 'input' | 'select';
91
95
  }
92
96
  /** 模态框选择器属性类型(结合Select和Input属性) */
93
97
  export declare type ProModalSelectPropsType = SelectProps & InputProps & ProModalPropsType;
@@ -53,7 +53,7 @@
53
53
  }
54
54
  }
55
55
 
56
- // 新加适用于 readonly false
56
+ // 新加适用于 _readOnly false
57
57
  .@{ant-prefix}-input-affix-wrapper {
58
58
  border-top-right-radius: 0;
59
59
  border-bottom-right-radius: 0;
@@ -100,7 +100,7 @@
100
100
  }
101
101
 
102
102
  .@{ant-prefix}-input-affix-wrapper-status-error{
103
-
103
+
104
104
  }
105
105
 
106
106
 
@@ -20,7 +20,8 @@ var _index2 = require("../../../../index");
20
20
  var _utils = require("../../../../utils");
21
21
  var FoldMenu = function FoldMenu(props) {
22
22
  var style = props.style,
23
- dataSource = props.dataSource;
23
+ dataSource = props.dataSource,
24
+ onMenuClick = props.onMenuClick;
24
25
  var menus = dataSource.menus,
25
26
  iconfontUrl = dataSource.iconfontUrl,
26
27
  notice = dataSource.notice,
@@ -89,7 +90,8 @@ var FoldMenu = function FoldMenu(props) {
89
90
  content: (0, _jsxRuntime.jsx)(_SideMenu.default, {
90
91
  dataSource: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, dataSource), {}, {
91
92
  menus: item
92
- })
93
+ }),
94
+ onMenuClick: onMenuClick
93
95
  }),
94
96
  color: "#fff",
95
97
  overlayClassName: noticeCls,
@@ -98,12 +100,42 @@ var FoldMenu = function FoldMenu(props) {
98
100
  height: "calc(100vh - ".concat(headerHeight + (notice ? 32 : 0), "px)")
99
101
  },
100
102
  placement: "rightTop",
101
- children: LiNode
103
+ children: (0, _jsxRuntime.jsx)("span", {
104
+ onClick: function onClick() {
105
+ // 查找完整的菜单项数据
106
+ var menuItem = (0, _utils.findMenuItemByKey)(menus, String(id));
107
+ var menuKeyPath = (menuItem === null || menuItem === void 0 ? void 0 : menuItem.keyIdPath) ? menuItem.keyIdPath.map(function (id) {
108
+ return String(id);
109
+ }) : [String(id)];
110
+ // 调用用户传入的onMenuClick回调
111
+ if (onMenuClick) {
112
+ onMenuClick({
113
+ item: menuItem,
114
+ key: String(id),
115
+ keyPath: menuKeyPath
116
+ });
117
+ }
118
+ },
119
+ children: LiNode
120
+ })
102
121
  }, "".concat(id, "-").concat(name)) : !collapsed ? (0, _jsxRuntime.jsx)(_tooltip.default, {
103
122
  placement: "right",
104
123
  title: name,
105
124
  children: (0, _jsxRuntime.jsx)("span", {
106
125
  onClick: function onClick() {
126
+ // 查找完整的菜单项数据
127
+ var menuItem = (0, _utils.findMenuItemByKey)(menus, String(id));
128
+ var menuKeyPath = (menuItem === null || menuItem === void 0 ? void 0 : menuItem.keyIdPath) ? menuItem.keyIdPath.map(function (id) {
129
+ return String(id);
130
+ }) : [String(id)];
131
+ // 调用用户传入的onMenuClick回调
132
+ if (onMenuClick) {
133
+ onMenuClick({
134
+ item: menuItem,
135
+ key: String(id),
136
+ keyPath: menuKeyPath
137
+ });
138
+ }
107
139
  onSelected({
108
140
  selectedPath: toPath
109
141
  });
@@ -113,10 +145,27 @@ var FoldMenu = function FoldMenu(props) {
113
145
  children: LiNode
114
146
  }, toPath)
115
147
  })
116
- }, toPath) : (0, _jsxRuntime.jsx)(_reactRouterDom.Link, {
117
- to: toPath,
118
- children: LiNode
119
- }, toPath);
148
+ }, toPath) : (0, _jsxRuntime.jsx)("span", {
149
+ onClick: function onClick() {
150
+ // 查找完整的菜单项数据
151
+ var menuItem = (0, _utils.findMenuItemByKey)(menus, String(id));
152
+ var menuKeyPath = (menuItem === null || menuItem === void 0 ? void 0 : menuItem.keyIdPath) ? menuItem.keyIdPath.map(function (id) {
153
+ return String(id);
154
+ }) : [String(id)];
155
+ // 调用用户传入的onMenuClick回调
156
+ if (onMenuClick) {
157
+ onMenuClick({
158
+ item: menuItem,
159
+ key: String(id),
160
+ keyPath: menuKeyPath
161
+ });
162
+ }
163
+ },
164
+ children: (0, _jsxRuntime.jsx)(_reactRouterDom.Link, {
165
+ to: toPath,
166
+ children: LiNode
167
+ }, toPath)
168
+ });
120
169
  })
121
170
  })
122
171
  });
@@ -25,7 +25,8 @@ var OpenMenu = function OpenMenu(props) {
25
25
  dataSource = props.dataSource,
26
26
  style = props.style,
27
27
  _props$theme = props.theme,
28
- theme = _props$theme === void 0 ? 'dark' : _props$theme;
28
+ theme = _props$theme === void 0 ? 'dark' : _props$theme,
29
+ onMenuClick = props.onMenuClick;
29
30
  var _ref = dataSource || {},
30
31
  menus = _ref.menus,
31
32
  sideMenu = _ref.sideMenu;
@@ -149,7 +150,26 @@ var OpenMenu = function OpenMenu(props) {
149
150
  onClick: function onClick(_ref2) {
150
151
  var _item$props, _item$props2;
151
152
  var item = _ref2.item,
152
- keyPath = _ref2.keyPath;
153
+ keyPath = _ref2.keyPath,
154
+ key = _ref2.key,
155
+ domEvent = _ref2.domEvent;
156
+ // console.log('item', item);
157
+ // console.log('keyPath', keyPath);
158
+ // console.log('key', key);
159
+ // console.log('domEvent', domEvent);
160
+ // 查找完整的菜单项数据
161
+ var menuItem = (0, _utils.findMenuItemByKey)(menus, key);
162
+ var menuKeyPath = (menuItem === null || menuItem === void 0 ? void 0 : menuItem.keyIdPath) ? menuItem.keyIdPath.map(function (id) {
163
+ return String(id);
164
+ }) : keyPath;
165
+ // 调用用户传入的onMenuClick回调
166
+ if (onMenuClick) {
167
+ onMenuClick({
168
+ item: menuItem,
169
+ key: key,
170
+ keyPath: menuKeyPath
171
+ });
172
+ }
153
173
  setState({
154
174
  selectedKeys: keyPath,
155
175
  router: item === null || item === void 0 ? void 0 : (_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.router
@@ -11,7 +11,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
11
11
  var _ahooks = require("ahooks");
12
12
  var _OpenMenu = _interopRequireDefault(require("../OpenMenu"));
13
13
  var SideMenu = function SideMenu(props) {
14
- var dataSource = props.dataSource;
14
+ var dataSource = props.dataSource,
15
+ onMenuClick = props.onMenuClick;
15
16
  var ref = (0, _react.useRef)(null);
16
17
  var size = (0, _ahooks.useSize)(ref);
17
18
  var menus = dataSource.menus,
@@ -31,6 +32,7 @@ var SideMenu = function SideMenu(props) {
31
32
  children: (0, _jsxRuntime.jsx)(_OpenMenu.default, {
32
33
  className: "pro-layout-sider-menu-list",
33
34
  theme: "light",
35
+ onMenuClick: onMenuClick,
34
36
  dataSource: {
35
37
  menus: (menus === null || menus === void 0 ? void 0 : menus.children) || [],
36
38
  iconfontUrl: iconfontUrl,
@@ -21,7 +21,8 @@ var Menu = function Menu(props) {
21
21
  pure = _ref.pure,
22
22
  theme = _ref.theme,
23
23
  sideMenuFooterRender = _ref.sideMenuFooterRender,
24
- sideMenuHeaderRender = _ref.sideMenuHeaderRender;
24
+ sideMenuHeaderRender = _ref.sideMenuHeaderRender,
25
+ onMenuClick = _ref.onMenuClick;
25
26
  var menus = [];
26
27
  var menuCls = (0, _classnames.default)({
27
28
  'pro-layout-menu': true,
@@ -47,6 +48,7 @@ var Menu = function Menu(props) {
47
48
  height: headerHeight + (notice ? 32 : 0) + 48
48
49
  },
49
50
  theme: theme,
51
+ onMenuClick: onMenuClick,
50
52
  style: {
51
53
  display: collapsed ? 'block' : 'none'
52
54
  }
@@ -59,6 +61,7 @@ var Menu = function Menu(props) {
59
61
  collapsed: collapsed,
60
62
  headerHeight: headerHeight
61
63
  },
64
+ onMenuClick: onMenuClick,
62
65
  style: {
63
66
  display: collapsed ? 'none' : 'block',
64
67
  height: "calc(100vh - ".concat(headerHeight + (notice ? 32 : 0) + 48 || 0, "px)")
@@ -37,7 +37,8 @@ var ProLayout = function ProLayout(props) {
37
37
  pathPrefix = _props$pathPrefix === void 0 ? '' : _props$pathPrefix,
38
38
  theme = props.theme,
39
39
  target = props.target,
40
- onCollapsedChange = props.onCollapsedChange;
40
+ onCollapsedChange = props.onCollapsedChange,
41
+ onMenuClick = props.onMenuClick;
41
42
  var _useSetState = (0, _ahooks.useSetState)({
42
43
  notice: headerNotice || noticeIn,
43
44
  menus: [],
@@ -102,6 +103,7 @@ var ProLayout = function ProLayout(props) {
102
103
  } : menus,
103
104
  notice: notice,
104
105
  collapsed: collapsed,
106
+ onMenuClick: onMenuClick,
105
107
  onToggle: function onToggle() {
106
108
  toggle();
107
109
  onCollapsedChange && onCollapsedChange(!collapsed);
@@ -180,6 +180,15 @@ export interface ProLayoutType {
180
180
  * @default -
181
181
  */
182
182
  onCollapsedChange?: (collapsed: boolean) => void;
183
+ /**
184
+ * @description 菜单点击回调事件,返回命中的菜单项数据和完整路径
185
+ * @default -
186
+ */
187
+ onMenuClick?: (params: {
188
+ item: MenusType | null;
189
+ key: string;
190
+ keyPath: string[];
191
+ }) => void;
183
192
  /**
184
193
  * @description 规定在何处打开被链接文档
185
194
  * @default "_self"
@@ -34,3 +34,10 @@ export declare const getPathNameKey: ({ menus, pathName, }: {
34
34
  menus: any[];
35
35
  pathName: string;
36
36
  }) => any;
37
+ /**
38
+ * 根据key查找完整的菜单项数据
39
+ * @param menus 菜单数据数组
40
+ * @param key 要查找的菜单项key
41
+ * @returns 找到的菜单项数据或null
42
+ */
43
+ export declare const findMenuItemByKey: (menus: any[], key: string) => any;
@@ -4,9 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.getPathNameKey = exports.getIdsByPathName = void 0;
7
+ exports.getPathNameKey = exports.getIdsByPathName = exports.findMenuItemByKey = void 0;
8
8
  exports.getUrlParams = getUrlParams;
9
9
  exports.transformMenus = exports.transformMenu = void 0;
10
+ var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
10
11
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
12
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
13
  var _isPlainObject2 = _interopRequireDefault(require("lodash/isPlainObject"));
@@ -168,4 +169,32 @@ var getPathNameKey = exports.getPathNameKey = function getPathNameKey(_ref) {
168
169
  };
169
170
  _menuDeep3(menus);
170
171
  return result;
172
+ };
173
+ /**
174
+ * 根据key查找完整的菜单项数据
175
+ * @param menus 菜单数据数组
176
+ * @param key 要查找的菜单项key
177
+ * @returns 找到的菜单项数据或null
178
+ */
179
+ var _findMenuItemByKey = exports.findMenuItemByKey = function findMenuItemByKey(menus, key) {
180
+ // eslint-disable-next-line no-restricted-syntax
181
+ var _iterator = (0, _createForOfIteratorHelper2.default)(menus),
182
+ _step;
183
+ try {
184
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
185
+ var item = _step.value;
186
+ if (String(item.id) === key) {
187
+ return item;
188
+ }
189
+ if (Array.isArray(item.children) && item.children.length) {
190
+ var found = _findMenuItemByKey(item.children, key);
191
+ if (found) return found;
192
+ }
193
+ }
194
+ } catch (err) {
195
+ _iterator.e(err);
196
+ } finally {
197
+ _iterator.f();
198
+ }
199
+ return null;
171
200
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.13.18-beta.3",
3
+ "version": "3.13.18-beta.4",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",