@ccs-ui/rc-pro 1.1.1-rc9 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/auth/auth-button.js +2 -3
- package/es/auth/auth-dropdown.js +16 -12
- package/es/auth/index.d.ts +2 -12
- package/es/auth/index.js +3 -5
- package/es/cascader/index.d.ts +3 -3
- package/es/cascader/index.js +3 -3
- package/es/ccs.d.ts +207 -25
- package/es/ccs.js +1 -79
- package/es/color-picker/index.js +30 -26
- package/es/context/index.d.ts +5 -5
- package/es/date-picker/index.js +9 -3
- package/es/dialog/HookDrawer.js +24 -8
- package/es/dialog/HookModal.d.ts +4 -0
- package/es/dialog/HookModal.js +93 -29
- package/es/dialog/button.d.ts +6 -2
- package/es/dialog/button.js +45 -13
- package/es/dialog/context.d.ts +8 -2
- package/es/dialog/drawer-footer.d.ts +12 -0
- package/es/dialog/drawer-footer.js +62 -0
- package/es/dialog/form.d.ts +7 -4
- package/es/dialog/form.js +9 -2
- package/es/dialog/hook.d.ts +9 -2
- package/es/dialog/hook.js +16 -4
- package/es/dialog/index.d.ts +9 -2
- package/es/dialog/index.js +4 -1
- package/es/dialog/index.less +12 -15
- package/es/hooks/use-global.d.ts +1 -1
- package/es/index.d.ts +3 -137
- package/es/index.js +4 -4
- package/es/interval-button/index.js +12 -6
- package/es/keep-alive-tabs/index.d.ts +4 -3
- package/es/keep-alive-tabs/index.js +5 -10
- package/es/keep-alive-tabs/page.d.ts +2 -2
- package/es/keep-alive-tabs/page.js +20 -16
- package/es/pro-grid/index.d.ts +0 -1
- package/es/pro-grid/index.js +51 -39
- package/es/pro-table/index.d.ts +11 -57
- package/es/pro-table/index.js +13 -13
- package/es/pro-table/index.less +17 -9
- package/es/pro-table/search.d.ts +5 -2
- package/es/pro-table/search.js +32 -9
- package/es/pro-table/tree.d.ts +5 -5
- package/es/pro-table/tree.js +1 -2
- package/es/pro-tabs/index.d.ts +0 -1
- package/es/pro-tabs/index.js +25 -8
- package/es/select/index.d.ts +3 -3
- package/es/select/index.js +3 -3
- package/es/theme-dialog.d.ts +24 -0
- package/es/theme-dialog.js +70 -0
- package/es/theme.d.ts +17 -0
- package/es/theme.js +66 -0
- package/es/time-picker/index.js +10 -4
- package/es/trigger/index.d.ts +0 -12
- package/es/trigger/index.js +78 -68
- package/es/upload/index.js +16 -7
- package/es/utils/index.d.ts +0 -15
- package/es/utils/index.js +3 -47
- package/es/virtual-list/index.js +34 -29
- package/es/water-mark/index.js +20 -17
- package/package.json +3 -1
- package/es/drawer.zip +0 -0
- package/es/modal.zip +0 -0
- package/es/pro-tabs/index.less +0 -5
package/es/dialog/HookDrawer.js
CHANGED
|
@@ -12,7 +12,9 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
import { Drawer } from 'antd';
|
|
14
14
|
import classNames from 'classnames';
|
|
15
|
-
import { forwardRef, useImperativeHandle, useState } from 'react';
|
|
15
|
+
import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
16
|
+
import { DialogSelfButton } from "./HookModal";
|
|
17
|
+
import { DialogButtonHolder } from "./button";
|
|
16
18
|
import { DialogContentContext } from "./context";
|
|
17
19
|
import DialogForm from "./form";
|
|
18
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -31,6 +33,9 @@ var HookDrawer = function HookDrawer(_ref, ref) {
|
|
|
31
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
32
34
|
innerConfig = _useState2[0],
|
|
33
35
|
setInnerConfig = _useState2[1];
|
|
36
|
+
var buttonRef = useRef(null);
|
|
37
|
+
var footerRef = useRef(null);
|
|
38
|
+
var formRef = useRef(null);
|
|
34
39
|
var afterClose = function afterClose() {
|
|
35
40
|
hookAfterClose();
|
|
36
41
|
};
|
|
@@ -81,6 +86,9 @@ var HookDrawer = function HookDrawer(_ref, ref) {
|
|
|
81
86
|
padding: 0
|
|
82
87
|
};
|
|
83
88
|
}
|
|
89
|
+
styles.mask = _objectSpread({
|
|
90
|
+
background: 'rgba(0, 0, 0, 0.1)'
|
|
91
|
+
}, styles.mask);
|
|
84
92
|
return /*#__PURE__*/_jsx(Drawer, _objectSpread(_objectSpread({
|
|
85
93
|
afterOpenChange: function afterOpenChange(open) {
|
|
86
94
|
if (!open) afterClose();
|
|
@@ -88,24 +96,32 @@ var HookDrawer = function HookDrawer(_ref, ref) {
|
|
|
88
96
|
}, innerConfig), {}, {
|
|
89
97
|
onClose: close,
|
|
90
98
|
className: classNames('ccs-dialog-drawer', innerConfig.className),
|
|
91
|
-
maskStyle: _objectSpread({
|
|
92
|
-
background: 'rgba(0, 0, 0, 0.1)'
|
|
93
|
-
}, innerConfig.maskStyle),
|
|
94
99
|
styles: styles,
|
|
95
100
|
rootStyle: _objectSpread(_objectSpread({}, !isCrInProp ? {
|
|
96
101
|
position: 'absolute'
|
|
97
102
|
} : {}), innerConfig.rootStyle),
|
|
98
|
-
contentWrapperStyle: _objectSpread(_objectSpread({}, !isCrInProp ? {
|
|
99
|
-
boxShadow: 'none'
|
|
100
|
-
} : {}), innerConfig.contentWrapperStyle),
|
|
101
103
|
getContainer: isCrInProp ? innerConfig.getContainer : onGetContainer,
|
|
102
|
-
extra:
|
|
104
|
+
extra: innerConfig.request ? /*#__PURE__*/_jsx(DialogSelfButton, {
|
|
105
|
+
request: innerConfig.request,
|
|
106
|
+
onCancel: close,
|
|
107
|
+
formRef: formRef,
|
|
108
|
+
onRequestBefore: innerConfig.onRequestBefore
|
|
109
|
+
}) : /*#__PURE__*/_jsx(DialogButtonHolder, {
|
|
110
|
+
ref: buttonRef
|
|
111
|
+
}),
|
|
112
|
+
footer: /*#__PURE__*/_jsx(DialogButtonHolder, {
|
|
113
|
+
ref: footerRef
|
|
114
|
+
}),
|
|
103
115
|
children: /*#__PURE__*/_jsx(DialogContentContext.Provider, {
|
|
104
116
|
value: {
|
|
117
|
+
buttonRef: buttonRef,
|
|
118
|
+
buttonType: 'drawer',
|
|
105
119
|
closeDialog: close,
|
|
120
|
+
drawerFooterRef: footerRef,
|
|
106
121
|
formInitialValues: ((_config$form = config.form) === null || _config$form === void 0 ? void 0 : _config$form.initialValues) || {}
|
|
107
122
|
},
|
|
108
123
|
children: config.form ? /*#__PURE__*/_jsx(DialogForm, {
|
|
124
|
+
ref: formRef,
|
|
109
125
|
formProps: config.form,
|
|
110
126
|
styles: _objectSpread({
|
|
111
127
|
padding: 24
|
package/es/dialog/HookModal.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { DialogFormRef } from './form';
|
|
2
3
|
import { CcsDialogModal, CcsDialogModalProps } from './hook';
|
|
4
|
+
export declare const DialogSelfButton: ({ formRef, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "request" | "onCancel" | "onRequestBefore"> & {
|
|
5
|
+
formRef: React.RefObject<DialogFormRef>;
|
|
6
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
3
7
|
export interface HookModalProps {
|
|
4
8
|
afterClose: () => void;
|
|
5
9
|
config: CcsDialogModalProps;
|
package/es/dialog/HookModal.js
CHANGED
|
@@ -10,13 +10,17 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
10
10
|
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; }
|
|
11
11
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
12
|
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); }
|
|
13
|
-
import { Modal } from 'antd';
|
|
13
|
+
import { Button, Modal } from 'antd';
|
|
14
14
|
import classNames from 'classnames';
|
|
15
15
|
import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
16
16
|
import Draggable from 'react-draggable';
|
|
17
|
+
import { CcsDialog, CcsUtils } from '..';
|
|
18
|
+
import { DialogButtonHolder } from "./button";
|
|
17
19
|
import { DialogContentContext } from "./context";
|
|
18
20
|
import DialogForm from "./form";
|
|
19
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
23
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
24
|
var DragModal = function DragModal(_ref) {
|
|
21
25
|
var modal = _ref.modal,
|
|
22
26
|
dragState = _ref.dragState,
|
|
@@ -54,11 +58,56 @@ var DragModal = function DragModal(_ref) {
|
|
|
54
58
|
})
|
|
55
59
|
});
|
|
56
60
|
};
|
|
57
|
-
var
|
|
61
|
+
export var DialogSelfButton = function DialogSelfButton(_ref2) {
|
|
62
|
+
var formRef = _ref2.formRef,
|
|
63
|
+
request = _ref2.request,
|
|
64
|
+
onCancel = _ref2.onCancel,
|
|
65
|
+
onRequestBefore = _ref2.onRequestBefore;
|
|
66
|
+
var _useState = useState(false),
|
|
67
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
68
|
+
loading = _useState2[0],
|
|
69
|
+
setLoading = _useState2[1];
|
|
70
|
+
var onOk = function onOk() {
|
|
71
|
+
var _formRef$current;
|
|
72
|
+
if (!((_formRef$current = formRef.current) !== null && _formRef$current !== void 0 && _formRef$current.formInstance)) {
|
|
73
|
+
CcsUtils.showWarning(false, "\u672A\u5B9A\u4E49form");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
formRef.current.formInstance.validateFields().then(function (values) {
|
|
77
|
+
setLoading(true);
|
|
78
|
+
var params = onRequestBefore ? onRequestBefore(values) : values;
|
|
79
|
+
request(params).then(function (d) {
|
|
80
|
+
setLoading(false);
|
|
81
|
+
if (d !== null && d !== void 0 && d.success && onCancel) {
|
|
82
|
+
onCancel(params);
|
|
83
|
+
}
|
|
84
|
+
CcsDialog.easyMessage(d);
|
|
85
|
+
}).catch(function (err) {
|
|
86
|
+
setLoading(false);
|
|
87
|
+
console.log('e', err);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// request
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
95
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
96
|
+
onClick: onCancel,
|
|
97
|
+
children: "\u53D6\u6D88"
|
|
98
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
99
|
+
type: "primary",
|
|
100
|
+
onClick: onOk,
|
|
101
|
+
loading: loading,
|
|
102
|
+
children: "\u786E\u5B9A"
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
var HookModal = function HookModal(_ref3, ref) {
|
|
58
107
|
var _config$form;
|
|
59
|
-
var hookAfterClose =
|
|
60
|
-
config =
|
|
61
|
-
var
|
|
108
|
+
var hookAfterClose = _ref3.afterClose,
|
|
109
|
+
config = _ref3.config;
|
|
110
|
+
var _useState3 = useState(function () {
|
|
62
111
|
if (config.open === undefined) {
|
|
63
112
|
return _objectSpread(_objectSpread({}, config), {}, {
|
|
64
113
|
open: true
|
|
@@ -66,10 +115,10 @@ var HookModal = function HookModal(_ref2, ref) {
|
|
|
66
115
|
}
|
|
67
116
|
return config;
|
|
68
117
|
}),
|
|
69
|
-
|
|
70
|
-
innerConfig =
|
|
71
|
-
setInnerConfig =
|
|
72
|
-
var
|
|
118
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
119
|
+
innerConfig = _useState4[0],
|
|
120
|
+
setInnerConfig = _useState4[1];
|
|
121
|
+
var _useState5 = useState({
|
|
73
122
|
disabled: true,
|
|
74
123
|
bounds: {
|
|
75
124
|
left: 0,
|
|
@@ -78,13 +127,11 @@ var HookModal = function HookModal(_ref2, ref) {
|
|
|
78
127
|
right: 0
|
|
79
128
|
}
|
|
80
129
|
}),
|
|
81
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
82
|
-
dragState = _useState4[0],
|
|
83
|
-
setDragState = _useState4[1];
|
|
84
|
-
var _useState5 = useState(false),
|
|
85
130
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
86
|
-
|
|
87
|
-
|
|
131
|
+
dragState = _useState6[0],
|
|
132
|
+
setDragState = _useState6[1];
|
|
133
|
+
var buttonRef = useRef(null);
|
|
134
|
+
var formRef = useRef(null);
|
|
88
135
|
var afterClose = function afterClose() {
|
|
89
136
|
var _innerConfig$afterClo;
|
|
90
137
|
if (config.destroyOnClose !== false) hookAfterClose();
|
|
@@ -124,19 +171,36 @@ var HookModal = function HookModal(_ref2, ref) {
|
|
|
124
171
|
};
|
|
125
172
|
});
|
|
126
173
|
var styles = innerConfig.styles || {};
|
|
127
|
-
styles.body = _objectSpread(_objectSpread({
|
|
128
|
-
position: 'relative'
|
|
129
|
-
}, styles.body), hasButtons ? {
|
|
130
|
-
paddingBottom: 44
|
|
131
|
-
} : {});
|
|
132
174
|
return /*#__PURE__*/_jsx(Modal, _objectSpread(_objectSpread({
|
|
133
175
|
onCancel: close,
|
|
134
176
|
afterClose: afterClose
|
|
135
177
|
}, innerConfig), {}, {
|
|
136
|
-
styles:
|
|
178
|
+
styles: _objectSpread({
|
|
179
|
+
footer: !innerConfig.request ? {
|
|
180
|
+
padding: 0
|
|
181
|
+
} : undefined
|
|
182
|
+
}, styles),
|
|
137
183
|
className: classNames('ccs-dialog-modal', innerConfig.className),
|
|
138
|
-
footer:
|
|
139
|
-
|
|
184
|
+
footer: innerConfig.request ? /*#__PURE__*/_jsx("div", {
|
|
185
|
+
style: {
|
|
186
|
+
padding: '8px 16px'
|
|
187
|
+
},
|
|
188
|
+
children: /*#__PURE__*/_jsx(DialogSelfButton, {
|
|
189
|
+
request: innerConfig.request,
|
|
190
|
+
onCancel: close,
|
|
191
|
+
formRef: formRef,
|
|
192
|
+
onRequestBefore: innerConfig.onRequestBefore
|
|
193
|
+
})
|
|
194
|
+
}) : /*#__PURE__*/_jsx(DialogButtonHolder, {
|
|
195
|
+
ref: buttonRef
|
|
196
|
+
}),
|
|
197
|
+
onOk: function onOk() {
|
|
198
|
+
// 传入request,onOk触发请求
|
|
199
|
+
if (innerConfig.request) {
|
|
200
|
+
console.log(111);
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
title: /*#__PURE__*/_jsx("div", {
|
|
140
204
|
style: {
|
|
141
205
|
width: '100%',
|
|
142
206
|
cursor: 'move'
|
|
@@ -158,23 +222,23 @@ var HookModal = function HookModal(_ref2, ref) {
|
|
|
158
222
|
});
|
|
159
223
|
},
|
|
160
224
|
children: config.title
|
|
161
|
-
})
|
|
162
|
-
modalRender:
|
|
225
|
+
}),
|
|
226
|
+
modalRender: function modalRender(modal) {
|
|
163
227
|
return /*#__PURE__*/_jsx(DragModal, {
|
|
164
228
|
modal: modal,
|
|
165
229
|
dragState: dragState,
|
|
166
230
|
onDragState: setDragState
|
|
167
231
|
});
|
|
168
|
-
}
|
|
232
|
+
},
|
|
169
233
|
children: /*#__PURE__*/_jsx(DialogContentContext.Provider, {
|
|
170
234
|
value: {
|
|
235
|
+
buttonRef: buttonRef,
|
|
236
|
+
buttonType: 'modal',
|
|
171
237
|
closeDialog: close,
|
|
172
|
-
onHasModalButtons: function onHasModalButtons() {
|
|
173
|
-
return setHasButtons(true);
|
|
174
|
-
},
|
|
175
238
|
formInitialValues: ((_config$form = config.form) === null || _config$form === void 0 ? void 0 : _config$form.initialValues) || {}
|
|
176
239
|
},
|
|
177
240
|
children: config.form ? /*#__PURE__*/_jsx(DialogForm, {
|
|
241
|
+
ref: formRef,
|
|
178
242
|
formProps: config.form,
|
|
179
243
|
children: config.content
|
|
180
244
|
}) : config.content
|
package/es/dialog/button.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
interface DialogButtonsProps {
|
|
3
3
|
okText?: string;
|
|
4
4
|
cancelText?: string;
|
|
@@ -8,5 +8,9 @@ interface DialogButtonsProps {
|
|
|
8
8
|
hideCancel?: boolean;
|
|
9
9
|
onOk?: (values?: any) => void;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type DialogButtonRef = {
|
|
12
|
+
onSetButtons: (e: React.ReactElement) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const DialogButtonHolder: React.MemoExoticComponent<React.ForwardRefExoticComponent<React.RefAttributes<DialogButtonRef>>>;
|
|
15
|
+
export default function CcsDialogButtons({ okText, okAuth, loading, children, hideCancel, cancelText, onOk, }: DialogButtonsProps): null;
|
|
12
16
|
export {};
|
package/es/dialog/button.js
CHANGED
|
@@ -4,13 +4,35 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
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; }
|
|
5
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
6
|
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); }
|
|
7
|
-
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { CcsAuth, CcsUtils } from "./..";
|
|
8
14
|
import { Button, Form } from 'antd';
|
|
9
|
-
import { useEffect } from 'react';
|
|
15
|
+
import React, { useEffect, useImperativeHandle, useState } from 'react';
|
|
10
16
|
import CcsDialog from '.';
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
17
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
+
export var DialogButtonHolder = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (_props, ref) {
|
|
21
|
+
var _useState = useState(),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
buttons = _useState2[0],
|
|
24
|
+
setButtons = _useState2[1];
|
|
25
|
+
useImperativeHandle(ref, function () {
|
|
26
|
+
return {
|
|
27
|
+
onSetButtons: function onSetButtons(e) {
|
|
28
|
+
return setButtons(e);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
|
33
|
+
children: buttons
|
|
34
|
+
});
|
|
35
|
+
}));
|
|
14
36
|
export default function CcsDialogButtons(_ref) {
|
|
15
37
|
var okText = _ref.okText,
|
|
16
38
|
okAuth = _ref.okAuth,
|
|
@@ -21,12 +43,10 @@ export default function CcsDialogButtons(_ref) {
|
|
|
21
43
|
onOk = _ref.onOk;
|
|
22
44
|
var _CcsDialog$useInstanc = CcsDialog.useInstance(),
|
|
23
45
|
closeDialog = _CcsDialog$useInstanc.closeDialog,
|
|
24
|
-
|
|
25
|
-
formInitialValues = _CcsDialog$useInstanc.formInitialValues
|
|
46
|
+
buttonRef = _CcsDialog$useInstanc.buttonRef,
|
|
47
|
+
formInitialValues = _CcsDialog$useInstanc.formInitialValues,
|
|
48
|
+
buttonType = _CcsDialog$useInstanc.buttonType;
|
|
26
49
|
var form = Form.useFormInstance();
|
|
27
|
-
useEffect(function () {
|
|
28
|
-
if (onHasModalButtons) onHasModalButtons();
|
|
29
|
-
}, []);
|
|
30
50
|
var onOkClick = function onOkClick() {
|
|
31
51
|
if (!onOk) return;
|
|
32
52
|
|
|
@@ -39,9 +59,10 @@ export default function CcsDialogButtons(_ref) {
|
|
|
39
59
|
}
|
|
40
60
|
onOk();
|
|
41
61
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
useEffect(function () {
|
|
63
|
+
var _buttonRef$current;
|
|
64
|
+
if (!onOk && !children) return;
|
|
65
|
+
var btns = /*#__PURE__*/_jsxs(_Fragment, {
|
|
45
66
|
children: [children, onOk && /*#__PURE__*/_jsxs(_Fragment, {
|
|
46
67
|
children: [!hideCancel && /*#__PURE__*/_jsx(Button, {
|
|
47
68
|
onClick: closeDialog,
|
|
@@ -54,6 +75,17 @@ export default function CcsDialogButtons(_ref) {
|
|
|
54
75
|
children: okText || '确定'
|
|
55
76
|
})]
|
|
56
77
|
})]
|
|
57
|
-
})
|
|
58
|
-
|
|
78
|
+
});
|
|
79
|
+
if (buttonType === 'modal') {
|
|
80
|
+
btns = /*#__PURE__*/_jsx("div", {
|
|
81
|
+
style: {
|
|
82
|
+
padding: '8px 16px'
|
|
83
|
+
},
|
|
84
|
+
children: btns
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
CcsUtils.showWarning(!!buttonRef.current, "\u68C0\u6D4B\u5230".concat(buttonType === 'modal' ? 'openModal' : 'openDrawer', "\u4F20\u5165request\u53C2\u6570\uFF0CCcsDialog.Buttons\u5C06\u4E0D\u80FD\u751F\u6548\u3002"));
|
|
88
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 ? void 0 : _buttonRef$current.onSetButtons(btns);
|
|
89
|
+
});
|
|
90
|
+
return null;
|
|
59
91
|
}
|
package/es/dialog/context.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Store } from 'antd/es/form/interface';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { RefObject } from 'react';
|
|
3
|
+
import { DialogButtonRef } from './button';
|
|
3
4
|
export interface DialogContextType<T = Store> {
|
|
5
|
+
/** 按钮类型 */
|
|
6
|
+
buttonType: 'modal' | 'drawer';
|
|
4
7
|
/** 表单初始值 */
|
|
5
8
|
formInitialValues: T;
|
|
9
|
+
/** 按钮 ref */
|
|
10
|
+
buttonRef: RefObject<DialogButtonRef>;
|
|
11
|
+
/** drawer footer ref */
|
|
12
|
+
drawerFooterRef?: RefObject<DialogButtonRef>;
|
|
6
13
|
/** 关闭弹框,可以设置返回值 */
|
|
7
14
|
closeDialog: (e?: any) => void;
|
|
8
|
-
onHasModalButtons?: () => void;
|
|
9
15
|
}
|
|
10
16
|
declare const DialogContentContext: React.Context<DialogContextType<any>>;
|
|
11
17
|
declare const useDialogContext: <T = Store>() => DialogContextType<T>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface DialogButtonsProps {
|
|
3
|
+
okText?: string;
|
|
4
|
+
cancelText?: string;
|
|
5
|
+
okAuth?: string;
|
|
6
|
+
loading?: boolean;
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
hideCancel?: boolean;
|
|
9
|
+
onOk?: (values?: any) => void;
|
|
10
|
+
}
|
|
11
|
+
export default function CcsDrawerFooter({ okText, okAuth, loading, children, hideCancel, cancelText, onOk, }: DialogButtonsProps): null;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
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 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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
|
+
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); }
|
|
7
|
+
import { CcsAuth } from "./..";
|
|
8
|
+
import { Button, Form } from 'antd';
|
|
9
|
+
import { useEffect } from 'react';
|
|
10
|
+
import CcsDialog from '.';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
export default function CcsDrawerFooter(_ref) {
|
|
15
|
+
var okText = _ref.okText,
|
|
16
|
+
okAuth = _ref.okAuth,
|
|
17
|
+
loading = _ref.loading,
|
|
18
|
+
children = _ref.children,
|
|
19
|
+
hideCancel = _ref.hideCancel,
|
|
20
|
+
cancelText = _ref.cancelText,
|
|
21
|
+
onOk = _ref.onOk;
|
|
22
|
+
var _CcsDialog$useInstanc = CcsDialog.useInstance(),
|
|
23
|
+
closeDialog = _CcsDialog$useInstanc.closeDialog,
|
|
24
|
+
drawerFooterRef = _CcsDialog$useInstanc.drawerFooterRef,
|
|
25
|
+
formInitialValues = _CcsDialog$useInstanc.formInitialValues;
|
|
26
|
+
var form = Form.useFormInstance();
|
|
27
|
+
var onOkClick = function onOkClick() {
|
|
28
|
+
if (!onOk) return;
|
|
29
|
+
|
|
30
|
+
// form返回表单值和所有初始值
|
|
31
|
+
if (form) {
|
|
32
|
+
form.validateFields().then(function (values) {
|
|
33
|
+
onOk(_objectSpread(_objectSpread({}, formInitialValues), values));
|
|
34
|
+
});
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
onOk();
|
|
38
|
+
};
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
var _drawerFooterRef$curr;
|
|
41
|
+
if (!onOk && !children) return;
|
|
42
|
+
var btns = /*#__PURE__*/_jsxs("div", {
|
|
43
|
+
style: {
|
|
44
|
+
padding: '8px 16px'
|
|
45
|
+
},
|
|
46
|
+
children: [children, onOk && /*#__PURE__*/_jsxs(_Fragment, {
|
|
47
|
+
children: [!hideCancel && /*#__PURE__*/_jsx(Button, {
|
|
48
|
+
onClick: closeDialog,
|
|
49
|
+
children: cancelText || '取消'
|
|
50
|
+
}), /*#__PURE__*/_jsx(CcsAuth.Button, {
|
|
51
|
+
auth: okAuth || '',
|
|
52
|
+
type: "primary",
|
|
53
|
+
loading: loading,
|
|
54
|
+
onClick: onOkClick,
|
|
55
|
+
children: okText || '确定'
|
|
56
|
+
})]
|
|
57
|
+
})]
|
|
58
|
+
});
|
|
59
|
+
drawerFooterRef === null || drawerFooterRef === void 0 ? void 0 : (_drawerFooterRef$curr = drawerFooterRef.current) === null || _drawerFooterRef$curr === void 0 ? void 0 : _drawerFooterRef$curr.onSetButtons(btns);
|
|
60
|
+
});
|
|
61
|
+
return null;
|
|
62
|
+
}
|
package/es/dialog/form.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { FormProps } from 'antd';
|
|
2
|
-
import { CSSProperties, ReactNode } from 'react';
|
|
1
|
+
import { FormInstance, FormProps } from 'antd';
|
|
2
|
+
import React, { CSSProperties, ReactNode } from 'react';
|
|
3
3
|
interface PropsType {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
formProps: FormProps;
|
|
6
6
|
styles?: CSSProperties;
|
|
7
7
|
}
|
|
8
|
+
export interface DialogFormRef {
|
|
9
|
+
formInstance: FormInstance;
|
|
10
|
+
}
|
|
8
11
|
/**
|
|
9
12
|
* 添加form实例
|
|
10
13
|
* @returns
|
|
11
14
|
*/
|
|
12
|
-
|
|
13
|
-
export
|
|
15
|
+
declare const DialogForm: React.ForwardRefExoticComponent<PropsType & React.RefAttributes<DialogFormRef>>;
|
|
16
|
+
export default DialogForm;
|
package/es/dialog/form.js
CHANGED
|
@@ -14,12 +14,13 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
14
14
|
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; }
|
|
15
15
|
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; }
|
|
16
16
|
import { Form } from 'antd';
|
|
17
|
+
import React, { useImperativeHandle } from 'react';
|
|
17
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
19
|
/**
|
|
19
20
|
* 添加form实例
|
|
20
21
|
* @returns
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
var DialogForm = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
23
24
|
var children = _ref.children,
|
|
24
25
|
styles = _ref.styles,
|
|
25
26
|
_ref$formProps = _ref.formProps,
|
|
@@ -29,6 +30,11 @@ export default function DialogForm(_ref) {
|
|
|
29
30
|
var _Form$useForm = Form.useForm(),
|
|
30
31
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
31
32
|
form = _Form$useForm2[0];
|
|
33
|
+
useImperativeHandle(ref, function () {
|
|
34
|
+
return {
|
|
35
|
+
formInstance: form
|
|
36
|
+
};
|
|
37
|
+
});
|
|
32
38
|
return /*#__PURE__*/_jsx(Form, _objectSpread(_objectSpread({
|
|
33
39
|
form: form,
|
|
34
40
|
labelCol: labelCol || {
|
|
@@ -45,4 +51,5 @@ export default function DialogForm(_ref) {
|
|
|
45
51
|
}, styles), restProps.style),
|
|
46
52
|
children: children
|
|
47
53
|
}));
|
|
48
|
-
}
|
|
54
|
+
});
|
|
55
|
+
export default DialogForm;
|
package/es/dialog/hook.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DrawerProps, FormProps, ModalFuncProps } from 'antd';
|
|
2
2
|
import React, { ReactNode } from 'react';
|
|
3
|
+
import CCS from '..';
|
|
3
4
|
export interface CcsDialogModal {
|
|
4
5
|
destroy: () => void;
|
|
5
6
|
update: (config: ModalFuncProps) => void;
|
|
@@ -17,10 +18,12 @@ type DrawerFunc = (props: DrawerProps) => {
|
|
|
17
18
|
update: (configUpdate: DrawerProps) => void;
|
|
18
19
|
};
|
|
19
20
|
export type CcsDialogModalProps = ModalFuncProps & {
|
|
20
|
-
/** 可拖拽 */
|
|
21
|
-
isDrag?: boolean;
|
|
22
21
|
/** antd form */
|
|
23
22
|
form?: FormProps;
|
|
23
|
+
/** 表单接口请求 */
|
|
24
|
+
request?: (values: any) => Promise<CCS.HttpResult>;
|
|
25
|
+
/** request执行前参数处理 */
|
|
26
|
+
onRequestBefore?: (values: any) => any;
|
|
24
27
|
/** 关闭后销毁组件,默认true */
|
|
25
28
|
destroyOnClose?: boolean;
|
|
26
29
|
/** 通过closeDialog方法关闭dialog */
|
|
@@ -33,6 +36,10 @@ export type CcsDialogDrawerProps = Omit<DrawerProps, 'extra'> & {
|
|
|
33
36
|
form?: FormProps;
|
|
34
37
|
/** 抽屉内容 */
|
|
35
38
|
content?: ReactNode;
|
|
39
|
+
/** 表单接口请求 */
|
|
40
|
+
request?: (values: any) => Promise<CCS.HttpResult>;
|
|
41
|
+
/** request执行前参数处理 */
|
|
42
|
+
onRequestBefore?: (values: any) => any;
|
|
36
43
|
/** 通过closeDialog方法关闭dialog */
|
|
37
44
|
afterCloseByOk?: (e: any) => void;
|
|
38
45
|
/** 通过点击关闭按钮或取消按钮关闭 */
|
package/es/dialog/hook.js
CHANGED
|
@@ -10,6 +10,7 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
11
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
12
12
|
|
|
13
|
+
import _debounce from 'lodash/debounce';
|
|
13
14
|
import React from 'react';
|
|
14
15
|
import HookDrawer from "./HookDrawer";
|
|
15
16
|
import HookModal from "./HookModal";
|
|
@@ -145,14 +146,25 @@ export default function useCcsDialog() {
|
|
|
145
146
|
};
|
|
146
147
|
return instance;
|
|
147
148
|
}, []);
|
|
149
|
+
|
|
150
|
+
// const resizeFn = _debounce((width: number) => {
|
|
151
|
+
// if (tabRef.current) tabRef.current.style.maxWidth = `${width}px`;
|
|
152
|
+
// }, 200);
|
|
153
|
+
|
|
148
154
|
var fns = React.useMemo(function () {
|
|
149
155
|
return {
|
|
150
|
-
openModal: function
|
|
156
|
+
openModal: _debounce(function (props) {
|
|
151
157
|
return getModalFunc(props);
|
|
152
|
-
},
|
|
153
|
-
|
|
158
|
+
}, 500, {
|
|
159
|
+
leading: true,
|
|
160
|
+
trailing: false
|
|
161
|
+
}),
|
|
162
|
+
openDrawer: _debounce(function (props) {
|
|
154
163
|
return getDrawerFunc(props);
|
|
155
|
-
}
|
|
164
|
+
}, 500, {
|
|
165
|
+
leading: true,
|
|
166
|
+
trailing: false
|
|
167
|
+
})
|
|
156
168
|
};
|
|
157
169
|
}, []);
|
|
158
170
|
// return [fns, <ElementsHolder key="modal-holder" ref={holderRef} />] as const;
|
package/es/dialog/index.d.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
import ThemeDialog from '../theme-dialog';
|
|
1
2
|
import CcsDialogButtons from './button';
|
|
2
3
|
import { useDialogContext } from './context';
|
|
4
|
+
import CcsDrawerFooter from './drawer-footer';
|
|
3
5
|
import useCcsDialog from './hook';
|
|
4
6
|
import './index.less';
|
|
5
7
|
interface DialogInterface {
|
|
6
|
-
|
|
8
|
+
/** 获取openModal,openDrawer方法 */
|
|
7
9
|
useDialog: typeof useCcsDialog;
|
|
10
|
+
/** dialog 实例 */
|
|
8
11
|
useInstance: typeof useDialogContext;
|
|
12
|
+
/** dialog 按钮 */
|
|
13
|
+
Buttons: typeof CcsDialogButtons;
|
|
14
|
+
/** drawer footer */
|
|
15
|
+
DrawerFooter: typeof CcsDrawerFooter;
|
|
9
16
|
}
|
|
10
|
-
declare const CcsDialog: DialogInterface;
|
|
17
|
+
declare const CcsDialog: typeof ThemeDialog & DialogInterface;
|
|
11
18
|
export default CcsDialog;
|
package/es/dialog/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import ThemeDialog from "../theme-dialog";
|
|
1
2
|
import CcsDialogButtons from "./button";
|
|
2
3
|
import { useDialogContext } from "./context";
|
|
4
|
+
import CcsDrawerFooter from "./drawer-footer";
|
|
3
5
|
import useCcsDialog from "./hook";
|
|
4
6
|
import "./index.less";
|
|
5
|
-
var CcsDialog =
|
|
7
|
+
var CcsDialog = ThemeDialog;
|
|
6
8
|
CcsDialog.Buttons = CcsDialogButtons;
|
|
7
9
|
CcsDialog.useDialog = useCcsDialog;
|
|
8
10
|
CcsDialog.useInstance = useDialogContext;
|
|
11
|
+
CcsDialog.DrawerFooter = CcsDrawerFooter;
|
|
9
12
|
export default CcsDialog;
|