@ccs-ui/rc-pro 1.1.0 → 1.1.1-rc10

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 (60) hide show
  1. package/es/auth/auth-button.js +25 -12
  2. package/es/auth/index.d.ts +7 -13
  3. package/es/auth/index.js +96 -74
  4. package/es/dialog/HookDrawer.d.ts +1 -1
  5. package/es/dialog/HookDrawer.js +31 -19
  6. package/es/dialog/HookModal.d.ts +1 -1
  7. package/es/dialog/HookModal.js +25 -20
  8. package/es/dialog/button.d.ts +3 -1
  9. package/es/dialog/button.js +28 -16
  10. package/es/dialog/context.d.ts +8 -7
  11. package/es/dialog/context.js +4 -4
  12. package/es/dialog/form.d.ts +2 -2
  13. package/es/dialog/form.js +4 -3
  14. package/es/dialog/{dialog.d.ts → hook.d.ts} +9 -1
  15. package/es/dialog/{dialog.js → hook.js} +11 -11
  16. package/es/dialog/index.d.ts +4 -4
  17. package/es/dialog/index.js +2 -2
  18. package/es/dialog/index.less +14 -17
  19. package/es/drawer.zip +0 -0
  20. package/es/index.d.ts +11 -8
  21. package/es/index.js +0 -2
  22. package/es/keep-alive-tabs/index.d.ts +1 -1
  23. package/es/keep-alive-tabs/index.js +46 -41
  24. package/es/keep-alive-tabs/index.less +2 -2
  25. package/es/modal.zip +0 -0
  26. package/es/pro-table/index.d.ts +3 -3
  27. package/es/pro-table/index.js +69 -179
  28. package/es/pro-table/index.less +3 -13
  29. package/es/pro-table/search.js +7 -4
  30. package/es/pro-table/tree.d.ts +22 -0
  31. package/es/pro-table/tree.js +184 -0
  32. package/es/table/index.js +70 -59
  33. package/es/upload/upload-image.js +33 -15
  34. package/package.json +3 -2
  35. package/es/drawer/buttons.d.ts +0 -14
  36. package/es/drawer/buttons.js +0 -93
  37. package/es/drawer/index.d.ts +0 -13
  38. package/es/drawer/index.js +0 -11
  39. package/es/drawer/index.less +0 -5
  40. package/es/drawer/open/content.d.ts +0 -20
  41. package/es/drawer/open/content.js +0 -43
  42. package/es/drawer/open/destory-fns.d.ts +0 -2
  43. package/es/drawer/open/destory-fns.js +0 -3
  44. package/es/drawer/open/form.d.ts +0 -12
  45. package/es/drawer/open/form.js +0 -32
  46. package/es/drawer/open/index.d.ts +0 -18
  47. package/es/drawer/open/index.js +0 -166
  48. package/es/modal/buttons.d.ts +0 -14
  49. package/es/modal/buttons.js +0 -90
  50. package/es/modal/index.d.ts +0 -12
  51. package/es/modal/index.js +0 -11
  52. package/es/modal/index.less +0 -26
  53. package/es/modal/open/destory-fns.d.ts +0 -2
  54. package/es/modal/open/destory-fns.js +0 -3
  55. package/es/modal/open/drag.d.ts +0 -1
  56. package/es/modal/open/drag.js +0 -104
  57. package/es/modal/open/form.d.ts +0 -12
  58. package/es/modal/open/form.js +0 -35
  59. package/es/modal/open/index.d.ts +0 -19
  60. package/es/modal/open/index.js +0 -93
@@ -1,12 +1,20 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
2
  var _excluded = ["auth", "text", "confirm", "onClick"];
2
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
3
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
9
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
10
  import { ExclamationCircleOutlined } from '@ant-design/icons';
6
11
  import { Button } from 'antd';
7
- import React, { useRef } from 'react';
12
+ import { useRef } from 'react';
8
13
  import { ModalConfirm } from '.';
9
14
  import { CCS, useCcsPage } from "../";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ import { Fragment as _Fragment } from "react/jsx-runtime";
10
18
  /**
11
19
  * 带权限的按钮组件、继承Ant Button所有属性
12
20
  * @param CcsAuthButtonProps
@@ -22,14 +30,14 @@ export default (function (_ref) {
22
30
  onAuth = _ref2.onAuth;
23
31
  var IsAuthButton = CCS.GlobalConfig.IsAuthButton;
24
32
  var modalRef = useRef(null);
25
- var button = /*#__PURE__*/React.createElement(Button, _extends({}, restProps, {
33
+ var button = /*#__PURE__*/_jsxs(Button, _objectSpread(_objectSpread({}, restProps), {}, {
26
34
  onClick: function onClick(e) {
27
35
  if (!_onClick) return;
28
36
  if (confirm) {
29
37
  var _modalRef$current;
30
38
  (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : _modalRef$current.confirm({
31
39
  title: '操作确认',
32
- icon: /*#__PURE__*/React.createElement(ExclamationCircleOutlined, null),
40
+ icon: /*#__PURE__*/_jsx(ExclamationCircleOutlined, {}),
33
41
  centered: true,
34
42
  content: confirm,
35
43
  okText: '确认',
@@ -41,19 +49,24 @@ export default (function (_ref) {
41
49
  return;
42
50
  }
43
51
  _onClick(e);
44
- }
45
- }), text, restProps.children);
52
+ },
53
+ children: [text, restProps.children]
54
+ }));
46
55
 
47
56
  // 不控制权限或没有传auth
48
57
  if (!IsAuthButton || !auth) {
49
- return /*#__PURE__*/React.createElement(React.Fragment, null, button, !!confirm ? /*#__PURE__*/React.createElement(ModalConfirm, {
50
- modalRef: modalRef
51
- }) : null);
58
+ return /*#__PURE__*/_jsxs(_Fragment, {
59
+ children: [button, !!confirm ? /*#__PURE__*/_jsx(ModalConfirm, {
60
+ modalRef: modalRef
61
+ }) : null]
62
+ });
52
63
  }
53
64
 
54
65
  // 当前菜单下查找按钮权限
55
66
  var hasAuth = onAuth && onAuth(auth);
56
- return /*#__PURE__*/React.createElement(React.Fragment, null, hasAuth ? button : /*#__PURE__*/React.createElement(React.Fragment, null), !!confirm ? /*#__PURE__*/React.createElement(ModalConfirm, {
57
- modalRef: modalRef
58
- }) : null);
67
+ return /*#__PURE__*/_jsxs(_Fragment, {
68
+ children: [hasAuth ? button : /*#__PURE__*/_jsx(_Fragment, {}), !!confirm ? /*#__PURE__*/_jsx(ModalConfirm, {
69
+ modalRef: modalRef
70
+ }) : null]
71
+ });
59
72
  });
@@ -1,11 +1,12 @@
1
1
  import { ButtonProps } from 'antd';
2
- import React, { ReactElement, ReactNode } from 'react';
2
+ import { ReactElement, ReactNode } from 'react';
3
3
  export interface ButtonItem {
4
4
  key: string;
5
5
  label: string;
6
6
  auth?: string;
7
7
  type?: ButtonProps['type'];
8
8
  disabled?: boolean;
9
+ hidden?: boolean;
9
10
  danger?: boolean;
10
11
  icon?: ReactNode;
11
12
  confirm?: string;
@@ -13,7 +14,7 @@ export interface ButtonItem {
13
14
  export interface CcsAuthGroupProps {
14
15
  /** 按钮尺寸 */
15
16
  size?: ButtonProps['size'];
16
- /** 默认显示按钮数量 default:3 */
17
+ /** 默认显示按钮数量 */
17
18
  showCount?: number;
18
19
  /** 全部显示成link样式 */
19
20
  isLink?: boolean;
@@ -28,29 +29,22 @@ export interface CcsAuthGroupProps {
28
29
  }
29
30
  export interface CcsAuthProps {
30
31
  /** 权限标识 */
31
- auth: string;
32
+ auth?: string;
32
33
  /** component children */
33
34
  children: ReactElement;
34
35
  }
35
36
  export declare function ModalConfirm({ modalRef }: {
36
37
  modalRef: any;
37
38
  }): import("react/jsx-runtime").JSX.Element;
38
- declare function CcsAuth({ auth, children }: CcsAuthProps): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
39
+ declare function CcsAuth({ auth, children }: CcsAuthProps): ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
39
40
  declare namespace CcsAuth {
40
41
  var Group: typeof AuthGroup;
41
- var Button: ({ auth, text, confirm, onClick, ...restProps }: Partial<{
42
- href: string;
43
- target?: React.HTMLAttributeAnchorTarget | undefined;
44
- onClick?: React.MouseEventHandler<HTMLAnchorElement> | undefined;
45
- } & import("antd/es/button/button").BaseButtonProps & Omit<React.AnchorHTMLAttributes<HTMLButtonElement | HTMLAnchorElement>, "onClick" | "type"> & {
46
- htmlType?: "button" | "reset" | "submit" | undefined;
47
- onClick?: React.MouseEventHandler<HTMLButtonElement> | undefined;
48
- } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick" | "type">> & {
42
+ var Button: ({ auth, text, confirm, onClick, ...restProps }: ButtonProps & {
49
43
  auth: string;
50
44
  text?: string | undefined;
51
45
  confirm?: string | undefined;
52
46
  }) => import("react/jsx-runtime").JSX.Element;
53
- var Dropdown: ({ auth, menus, children, onClick, ...restProps }: import("./auth-dropdown").CcsAuthDropdownProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
47
+ var Dropdown: ({ auth, menus, children, onClick, ...restProps }: import("./auth-dropdown").CcsAuthDropdownProps) => ReactElement<any, string | import("react").JSXElementConstructor<any>>;
54
48
  }
55
49
  declare function AuthGroup({ size, isLink, showCount, moreIcon, moreText, items, onClick, }: CcsAuthGroupProps): import("react/jsx-runtime").JSX.Element | null;
56
50
  export default CcsAuth;
package/es/auth/index.js CHANGED
@@ -1,12 +1,13 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
2
  var _excluded = ["key", "label"],
2
3
  _excluded2 = ["key", "label"];
3
- function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
9
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
10
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
7
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
11
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
12
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
13
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -15,10 +16,13 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
15
16
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
17
  import { EllipsisOutlined, ExclamationCircleOutlined } from '@ant-design/icons';
17
18
  import { Button, Dropdown, Modal, Space } from 'antd';
18
- import React, { useEffect, useRef } from 'react';
19
+ import { useEffect, useRef } from 'react';
19
20
  import { CCS, useCcsPage } from '..';
20
21
  import AuthButton from "./auth-button";
21
22
  import AuthDropdown from "./auth-dropdown";
23
+ import { Fragment as _Fragment } from "react/jsx-runtime";
24
+ import { jsxs as _jsxs } from "react/jsx-runtime";
25
+ import { jsx as _jsx } from "react/jsx-runtime";
22
26
  export function ModalConfirm(_ref) {
23
27
  var modalRef = _ref.modalRef;
24
28
  var _Modal$useModal = Modal.useModal(),
@@ -28,7 +32,9 @@ export function ModalConfirm(_ref) {
28
32
  useEffect(function () {
29
33
  modalRef.current = modal;
30
34
  }, []);
31
- return /*#__PURE__*/React.createElement(React.Fragment, null, " ", contextHolder);
35
+ return /*#__PURE__*/_jsxs(_Fragment, {
36
+ children: [" ", contextHolder]
37
+ });
32
38
  }
33
39
  function CcsAuth(_ref2) {
34
40
  var auth = _ref2.auth,
@@ -47,23 +53,28 @@ function AuthGroup(_ref4) {
47
53
  showCount = _ref4.showCount,
48
54
  moreIcon = _ref4.moreIcon,
49
55
  moreText = _ref4.moreText,
50
- items = _ref4.items,
56
+ _ref4$items = _ref4.items,
57
+ items = _ref4$items === void 0 ? [] : _ref4$items,
51
58
  onClick = _ref4.onClick;
52
59
  var _ref5 = useCcsPage() || {},
53
60
  onAuth = _ref5.onAuth;
54
61
  var IsAuthButton = CCS.GlobalConfig.IsAuthButton;
55
62
  var modalRef = useRef(null);
56
- if (!items || items.length === 0) return null;
57
63
  var authButtons = [];
64
+
65
+ // 过滤隐藏按钮
66
+ authButtons = items.filter(function (items) {
67
+ return !items.hidden;
68
+ });
69
+
58
70
  // 需要判断权限
59
71
  if (IsAuthButton && onAuth) {
60
- authButtons = items.filter(function (b) {
72
+ authButtons = authButtons.filter(function (b) {
61
73
  if (b.auth) return onAuth(b.auth);
62
74
  return true;
63
75
  });
64
- } else {
65
- authButtons = _toConsumableArray(items);
66
76
  }
77
+ if (!items || items.length === 0) return null;
67
78
 
68
79
  // 当前菜单下查找按钮权限
69
80
  var showBtns = authButtons.splice(0, showCount || items.length);
@@ -76,7 +87,7 @@ function AuthGroup(_ref4) {
76
87
  var _modalRef$current;
77
88
  (_modalRef$current = modalRef.current) === null || _modalRef$current === void 0 ? void 0 : _modalRef$current.confirm({
78
89
  title: '操作确认',
79
- icon: /*#__PURE__*/React.createElement(ExclamationCircleOutlined, null),
90
+ icon: /*#__PURE__*/_jsx(ExclamationCircleOutlined, {}),
80
91
  centered: true,
81
92
  content: item.confirm,
82
93
  okText: '确认',
@@ -90,73 +101,84 @@ function AuthGroup(_ref4) {
90
101
  onClick(key);
91
102
  };
92
103
  if (isLink) {
93
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space, null, showBtns === null || showBtns === void 0 ? void 0 : showBtns.map(function (_ref6) {
94
- var key = _ref6.key,
95
- label = _ref6.label,
96
- restProps = _objectWithoutProperties(_ref6, _excluded);
97
- return /*#__PURE__*/React.createElement(Button, _extends({
98
- key: key
99
- }, restProps, {
100
- size: size,
101
- type: "link",
102
- onClick: function onClick() {
103
- return handleOnClick(key);
104
- }
105
- }), label);
106
- })), authButtons.length > 0 && /*#__PURE__*/React.createElement(Dropdown, {
107
- menu: {
108
- items: authButtons,
109
- onClick: function onClick(e) {
110
- return handleOnClick(e.key);
111
- }
112
- }
113
- }, /*#__PURE__*/React.createElement(Button, {
114
- type: "link",
115
- icon: moreText ? null : moreIcon || /*#__PURE__*/React.createElement(EllipsisOutlined, null),
116
- size: "small"
117
- }, moreText)), items.find(function (i) {
118
- return !!i.confirm;
119
- }) ? /*#__PURE__*/React.createElement(ModalConfirm, {
120
- modalRef: modalRef
121
- }) : null);
122
- }
123
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Space, null, showBtns === null || showBtns === void 0 ? void 0 : showBtns.map(function (_ref7, index) {
124
- var key = _ref7.key,
125
- label = _ref7.label,
126
- restProps = _objectWithoutProperties(_ref7, _excluded2);
127
- // 更多按钮
128
- if (index === showBtns.length - 1 && authButtons.length > 0) {
129
- return /*#__PURE__*/React.createElement(Space.Compact, {
130
- key: key
131
- }, /*#__PURE__*/React.createElement(Button, _extends({}, restProps, {
132
- size: size,
133
- onClick: function onClick() {
134
- return handleOnClick(key);
135
- }
136
- }), label), /*#__PURE__*/React.createElement(Dropdown, {
104
+ return /*#__PURE__*/_jsxs(_Fragment, {
105
+ children: [/*#__PURE__*/_jsx(Space, {
106
+ children: showBtns === null || showBtns === void 0 ? void 0 : showBtns.map(function (_ref6) {
107
+ var key = _ref6.key,
108
+ label = _ref6.label,
109
+ restProps = _objectWithoutProperties(_ref6, _excluded);
110
+ return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({}, restProps), {}, {
111
+ size: size,
112
+ type: "link",
113
+ onClick: function onClick() {
114
+ return handleOnClick(key);
115
+ },
116
+ children: label
117
+ }), key);
118
+ })
119
+ }), authButtons.length > 0 && /*#__PURE__*/_jsx(Dropdown, {
137
120
  menu: {
138
121
  items: authButtons,
139
122
  onClick: function onClick(e) {
140
123
  return handleOnClick(e.key);
141
124
  }
125
+ },
126
+ children: /*#__PURE__*/_jsx(Button, {
127
+ type: "link",
128
+ icon: moreText ? null : moreIcon || /*#__PURE__*/_jsx(EllipsisOutlined, {}),
129
+ size: "small",
130
+ children: moreText
131
+ })
132
+ }), items.find(function (i) {
133
+ return !!i.confirm;
134
+ }) ? /*#__PURE__*/_jsx(ModalConfirm, {
135
+ modalRef: modalRef
136
+ }) : null]
137
+ });
138
+ }
139
+ return /*#__PURE__*/_jsxs(_Fragment, {
140
+ children: [/*#__PURE__*/_jsx(Space, {
141
+ children: showBtns === null || showBtns === void 0 ? void 0 : showBtns.map(function (_ref7, index) {
142
+ var key = _ref7.key,
143
+ label = _ref7.label,
144
+ restProps = _objectWithoutProperties(_ref7, _excluded2);
145
+ // 更多按钮
146
+ if (index === showBtns.length - 1 && authButtons.length > 0) {
147
+ return /*#__PURE__*/_jsxs(Space.Compact, {
148
+ children: [/*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({}, restProps), {}, {
149
+ size: size,
150
+ onClick: function onClick() {
151
+ return handleOnClick(key);
152
+ },
153
+ children: label
154
+ })), /*#__PURE__*/_jsx(Dropdown, {
155
+ menu: {
156
+ items: authButtons,
157
+ onClick: function onClick(e) {
158
+ return handleOnClick(e.key);
159
+ }
160
+ },
161
+ children: /*#__PURE__*/_jsx(Button, {
162
+ icon: moreText ? null : moreIcon || /*#__PURE__*/_jsx(EllipsisOutlined, {}),
163
+ children: moreText
164
+ })
165
+ })]
166
+ }, key);
142
167
  }
143
- }, /*#__PURE__*/React.createElement(Button, {
144
- icon: moreText ? null : moreIcon || /*#__PURE__*/React.createElement(EllipsisOutlined, null)
145
- }, moreText)));
146
- }
147
- return /*#__PURE__*/React.createElement(Button, _extends({
148
- key: key
149
- }, restProps, {
150
- size: size,
151
- onClick: function onClick() {
152
- return handleOnClick(key);
153
- }
154
- }), label);
155
- })), items.find(function (i) {
156
- return !!i.confirm;
157
- }) ? /*#__PURE__*/React.createElement(ModalConfirm, {
158
- modalRef: modalRef
159
- }) : null);
168
+ return /*#__PURE__*/_jsx(Button, _objectSpread(_objectSpread({}, restProps), {}, {
169
+ size: size,
170
+ onClick: function onClick() {
171
+ return handleOnClick(key);
172
+ },
173
+ children: label
174
+ }), key);
175
+ })
176
+ }), items.find(function (i) {
177
+ return !!i.confirm;
178
+ }) ? /*#__PURE__*/_jsx(ModalConfirm, {
179
+ modalRef: modalRef
180
+ }) : null]
181
+ });
160
182
  }
161
183
  CcsAuth.Group = AuthGroup;
162
184
  CcsAuth.Button = AuthButton;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { CcsDialogDrawer, CcsDialogDrawerProps } from './dialog';
2
+ import { CcsDialogDrawer, CcsDialogDrawerProps } from './hook';
3
3
  export interface HookDrawerProps {
4
4
  afterClose: () => void;
5
5
  config: CcsDialogDrawerProps;
@@ -13,11 +13,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { Drawer } from 'antd';
14
14
  import classNames from 'classnames';
15
15
  import { forwardRef, useImperativeHandle, useState } from 'react';
16
- import { ModalContentContext } from "./context";
16
+ import { DialogContentContext } from "./context";
17
17
  import DialogForm from "./form";
18
18
  import { jsx as _jsx } from "react/jsx-runtime";
19
19
  var HookDrawer = function HookDrawer(_ref, ref) {
20
- var _config$form;
20
+ var _config$form, _innerConfig$styles;
21
21
  var hookAfterClose = _ref.afterClose,
22
22
  config = _ref.config;
23
23
  var _useState = useState(function () {
@@ -31,19 +31,31 @@ var HookDrawer = function HookDrawer(_ref, ref) {
31
31
  _useState2 = _slicedToArray(_useState, 2),
32
32
  innerConfig = _useState2[0],
33
33
  setInnerConfig = _useState2[1];
34
- var _useState3 = useState(false),
35
- _useState4 = _slicedToArray(_useState3, 2),
36
- hasButtons = _useState4[0],
37
- setHasButtons = _useState4[1];
38
34
  var afterClose = function afterClose() {
39
35
  hookAfterClose();
40
36
  };
41
- var close = function close() {
37
+ var close = function close(e) {
42
38
  setInnerConfig(function (c) {
43
39
  return _objectSpread(_objectSpread({}, c), {}, {
44
40
  open: false
45
41
  });
46
42
  });
43
+ if ((e === null || e === void 0 ? void 0 : e.type) === 'click') {
44
+ // 通过点击关闭按钮或取消按钮关闭
45
+ if (innerConfig.afterCloseByCancel) {
46
+ innerConfig.afterCloseByCancel(e);
47
+ }
48
+ } else {
49
+ // 通过调用closeDialog关闭
50
+ if (innerConfig.afterCloseByOk) {
51
+ innerConfig.afterCloseByOk(e);
52
+ }
53
+ }
54
+
55
+ // 入参有onClose
56
+ if (innerConfig.onClose) {
57
+ innerConfig.onClose(e);
58
+ }
47
59
  };
48
60
  useImperativeHandle(ref, function () {
49
61
  return {
@@ -63,21 +75,23 @@ var HookDrawer = function HookDrawer(_ref, ref) {
63
75
  return undefined;
64
76
  };
65
77
  var isCrInProp = ('getContainer' in innerConfig);
78
+ var styles = innerConfig.styles || {};
79
+ if (config.form) {
80
+ styles.body = {
81
+ padding: 0
82
+ };
83
+ }
66
84
  return /*#__PURE__*/_jsx(Drawer, _objectSpread(_objectSpread({
67
- onClose: close,
68
85
  afterOpenChange: function afterOpenChange(open) {
69
86
  if (!open) afterClose();
70
87
  }
71
88
  }, innerConfig), {}, {
89
+ onClose: close,
72
90
  className: classNames('ccs-dialog-drawer', innerConfig.className),
73
91
  maskStyle: _objectSpread({
74
92
  background: 'rgba(0, 0, 0, 0.1)'
75
93
  }, innerConfig.maskStyle),
76
- bodyStyle: _objectSpread(_objectSpread({}, hasButtons ? {
77
- marginBottom: 80
78
- } : {}), config.form ? {
79
- padding: 0
80
- } : innerConfig.bodyStyle),
94
+ styles: styles,
81
95
  rootStyle: _objectSpread(_objectSpread({}, !isCrInProp ? {
82
96
  position: 'absolute'
83
97
  } : {}), innerConfig.rootStyle),
@@ -85,19 +99,17 @@ var HookDrawer = function HookDrawer(_ref, ref) {
85
99
  boxShadow: 'none'
86
100
  } : {}), innerConfig.contentWrapperStyle),
87
101
  getContainer: isCrInProp ? innerConfig.getContainer : onGetContainer,
88
- children: /*#__PURE__*/_jsx(ModalContentContext.Provider, {
102
+ extra: null,
103
+ children: /*#__PURE__*/_jsx(DialogContentContext.Provider, {
89
104
  value: {
90
105
  closeDialog: close,
91
- onHasButtons: function onHasButtons() {
92
- return setHasButtons(true);
93
- },
94
106
  formInitialValues: ((_config$form = config.form) === null || _config$form === void 0 ? void 0 : _config$form.initialValues) || {}
95
107
  },
96
108
  children: config.form ? /*#__PURE__*/_jsx(DialogForm, {
97
109
  formProps: config.form,
98
- bodyStyle: _objectSpread({
110
+ styles: _objectSpread({
99
111
  padding: 24
100
- }, innerConfig.bodyStyle),
112
+ }, (_innerConfig$styles = innerConfig.styles) === null || _innerConfig$styles === void 0 ? void 0 : _innerConfig$styles.body),
101
113
  children: config.content
102
114
  }) : config.content
103
115
  })
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { CcsDialogModal, CcsDialogModalProps } from './dialog';
2
+ import { CcsDialogModal, CcsDialogModalProps } from './hook';
3
3
  export interface HookModalProps {
4
4
  afterClose: () => void;
5
5
  config: CcsDialogModalProps;
@@ -1,8 +1,4 @@
1
1
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
2
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
3
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
8
4
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -18,7 +14,7 @@ import { Modal } from 'antd';
18
14
  import classNames from 'classnames';
19
15
  import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
20
16
  import Draggable from 'react-draggable';
21
- import { ModalContentContext } from "./context";
17
+ import { DialogContentContext } from "./context";
22
18
  import DialogForm from "./form";
23
19
  import { jsx as _jsx } from "react/jsx-runtime";
24
20
  var DragModal = function DragModal(_ref) {
@@ -94,20 +90,27 @@ var HookModal = function HookModal(_ref2, ref) {
94
90
  if (config.destroyOnClose !== false) hookAfterClose();
95
91
  (_innerConfig$afterClo = innerConfig.afterClose) === null || _innerConfig$afterClo === void 0 ? void 0 : _innerConfig$afterClo.call(innerConfig);
96
92
  };
97
- var close = function close() {
93
+ var close = function close(e) {
98
94
  setInnerConfig(function (c) {
99
95
  return _objectSpread(_objectSpread({}, c), {}, {
100
96
  open: false
101
97
  });
102
98
  });
103
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
104
- args[_key] = arguments[_key];
99
+ if ((e === null || e === void 0 ? void 0 : e.type) === 'click') {
100
+ // 通过点击关闭按钮或取消按钮关闭
101
+ if (innerConfig.afterCloseByCancel) {
102
+ innerConfig.afterCloseByCancel(e);
103
+ }
104
+ } else {
105
+ // 通过调用closeDialog关闭
106
+ if (innerConfig.afterCloseByOk) {
107
+ innerConfig.afterCloseByOk(e);
108
+ }
105
109
  }
106
- var triggerCancel = args.some(function (param) {
107
- return param && param.triggerCancel;
108
- });
109
- if (innerConfig.onCancel && triggerCancel) {
110
- innerConfig.onCancel.apply(innerConfig, [function () {}].concat(_toConsumableArray(args.slice(1))));
110
+
111
+ // 入参有onClose
112
+ if (innerConfig.onCancel) {
113
+ innerConfig.onCancel(e);
111
114
  }
112
115
  };
113
116
  useImperativeHandle(ref, function () {
@@ -120,15 +123,17 @@ var HookModal = function HookModal(_ref2, ref) {
120
123
  }
121
124
  };
122
125
  });
126
+ var styles = innerConfig.styles || {};
127
+ styles.body = _objectSpread(_objectSpread({
128
+ position: 'relative'
129
+ }, styles.body), hasButtons ? {
130
+ paddingBottom: 44
131
+ } : {});
123
132
  return /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
124
133
  onCancel: close,
125
134
  afterClose: afterClose
126
135
  }, innerConfig), {}, {
127
- bodyStyle: _objectSpread(_objectSpread({
128
- position: 'relative'
129
- }, innerConfig.bodyStyle), hasButtons ? {
130
- paddingBottom: 44
131
- } : {}),
136
+ styles: styles,
132
137
  className: classNames('ccs-dialog-modal', innerConfig.className),
133
138
  footer: null,
134
139
  title: config.isDrag ? /*#__PURE__*/_jsx("div", {
@@ -161,10 +166,10 @@ var HookModal = function HookModal(_ref2, ref) {
161
166
  onDragState: setDragState
162
167
  });
163
168
  } : undefined,
164
- children: /*#__PURE__*/_jsx(ModalContentContext.Provider, {
169
+ children: /*#__PURE__*/_jsx(DialogContentContext.Provider, {
165
170
  value: {
166
171
  closeDialog: close,
167
- onHasButtons: function onHasButtons() {
172
+ onHasModalButtons: function onHasModalButtons() {
168
173
  return setHasButtons(true);
169
174
  },
170
175
  formInitialValues: ((_config$form = config.form) === null || _config$form === void 0 ? void 0 : _config$form.initialValues) || {}
@@ -1,10 +1,12 @@
1
1
  import { ReactNode } from 'react';
2
2
  interface DialogButtonsProps {
3
3
  okText?: string;
4
+ cancelText?: string;
4
5
  okAuth?: string;
5
6
  loading?: boolean;
6
7
  children?: ReactNode;
8
+ hideCancel?: boolean;
7
9
  onOk?: (values?: any) => void;
8
10
  }
9
- export default function CcsDialogButtons({ okText, okAuth, loading, children, onOk, }: DialogButtonsProps): import("react/jsx-runtime").JSX.Element | null;
11
+ export default function CcsDialogButtons({ okText, okAuth, loading, children, hideCancel, cancelText, onOk, }: DialogButtonsProps): import("react/jsx-runtime").JSX.Element | null;
10
12
  export {};