@lemon-fe/kits 1.0.0-89 → 1.0.0-90
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.
|
@@ -16,6 +16,9 @@ export interface BasePopupProps {
|
|
|
16
16
|
* 当作为modal使用,请不要传入onOk方法,通过open以及onCancel来控制Modal是否显示
|
|
17
17
|
*/
|
|
18
18
|
modal?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* @description 受控open
|
|
21
|
+
*/
|
|
19
22
|
open?: boolean;
|
|
20
23
|
readOnly?: boolean;
|
|
21
24
|
/**
|
|
@@ -24,6 +27,9 @@ export interface BasePopupProps {
|
|
|
24
27
|
*/
|
|
25
28
|
beforeOpen?: () => boolean;
|
|
26
29
|
autoFocus?: boolean;
|
|
30
|
+
onCancel?: () => void;
|
|
31
|
+
onOpenChange?: (visible: boolean) => void;
|
|
32
|
+
onClick?: () => void;
|
|
27
33
|
}
|
|
28
34
|
export interface PopupProps<ValueType> extends BasePopupProps, Omit<ModalProps, 'children' | 'onCancel'> {
|
|
29
35
|
value?: ValueType;
|
|
@@ -50,12 +56,10 @@ export interface PopupProps<ValueType> extends BasePopupProps, Omit<ModalProps,
|
|
|
50
56
|
disabled?: boolean;
|
|
51
57
|
readOnly?: boolean;
|
|
52
58
|
}) => ReactElement | null);
|
|
53
|
-
onClick?: () => void;
|
|
54
59
|
/**
|
|
55
60
|
* @description 清空后的值
|
|
56
61
|
*/
|
|
57
62
|
emptyValue?: ValueType;
|
|
58
|
-
onCancel?: () => void;
|
|
59
63
|
renderFooter?: (params: {
|
|
60
64
|
onOk: () => void;
|
|
61
65
|
onCancel: () => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
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
2
|
|
|
3
|
-
var _excluded = ["value", "onChange", "component", "children", "formatLabel", "disabled", "allowClear", "autoFocus", "showLabel", "beforeOk", "beforeOkCheck", "placeholder", "onClick", "disabledTip", "bordered", "emptyValue", "onCancel", "modal", "open", "readOnly", "beforeOpen", "renderFooter"];
|
|
3
|
+
var _excluded = ["value", "onChange", "component", "children", "formatLabel", "disabled", "allowClear", "autoFocus", "showLabel", "beforeOk", "beforeOkCheck", "placeholder", "onClick", "disabledTip", "bordered", "emptyValue", "onCancel", "modal", "open", "readOnly", "beforeOpen", "renderFooter", "onOpenChange"];
|
|
4
4
|
|
|
5
5
|
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); }
|
|
6
6
|
|
|
@@ -60,6 +60,7 @@ function Popup(props) {
|
|
|
60
60
|
readOnly = props.readOnly,
|
|
61
61
|
beforeOpen = props.beforeOpen,
|
|
62
62
|
renderFooter = props.renderFooter,
|
|
63
|
+
onOpenChange = props.onOpenChange,
|
|
63
64
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
64
65
|
|
|
65
66
|
var _useState = useState(valueProp),
|
|
@@ -88,16 +89,12 @@ function Popup(props) {
|
|
|
88
89
|
|
|
89
90
|
var handleCancel = function handleCancel() {
|
|
90
91
|
setOpen(false);
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
onCancel();
|
|
94
|
-
}
|
|
92
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(false);
|
|
93
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
95
94
|
};
|
|
96
95
|
|
|
97
96
|
var handleOpen = function handleOpen() {
|
|
98
|
-
|
|
99
|
-
onClick();
|
|
100
|
-
}
|
|
97
|
+
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
101
98
|
|
|
102
99
|
if (disabled) {
|
|
103
100
|
if (disabledTip) {
|
|
@@ -113,6 +110,7 @@ function Popup(props) {
|
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
112
|
|
|
113
|
+
onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange(true);
|
|
116
114
|
setOpen(true);
|
|
117
115
|
};
|
|
118
116
|
|
|
@@ -144,40 +142,36 @@ function Popup(props) {
|
|
|
144
142
|
return _context.abrupt("return");
|
|
145
143
|
|
|
146
144
|
case 7:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (onCancel !== undefined) {
|
|
150
|
-
onCancel();
|
|
151
|
-
}
|
|
145
|
+
handleCancel();
|
|
152
146
|
|
|
153
147
|
if (!(onChange !== undefined)) {
|
|
154
|
-
_context.next =
|
|
148
|
+
_context.next = 17;
|
|
155
149
|
break;
|
|
156
150
|
}
|
|
157
151
|
|
|
158
152
|
if (!(beforeOk && result)) {
|
|
159
|
-
_context.next =
|
|
153
|
+
_context.next = 16;
|
|
160
154
|
break;
|
|
161
155
|
}
|
|
162
156
|
|
|
163
|
-
_context.next =
|
|
157
|
+
_context.next = 12;
|
|
164
158
|
return beforeOk(result);
|
|
165
159
|
|
|
166
|
-
case
|
|
160
|
+
case 12:
|
|
167
161
|
res = _context.sent;
|
|
168
162
|
onChange(res);
|
|
169
|
-
_context.next =
|
|
163
|
+
_context.next = 17;
|
|
170
164
|
break;
|
|
171
165
|
|
|
172
|
-
case
|
|
166
|
+
case 16:
|
|
173
167
|
onChange(result);
|
|
174
168
|
|
|
175
|
-
case
|
|
169
|
+
case 17:
|
|
176
170
|
if (inputRef.current !== null) {
|
|
177
171
|
inputRef.current.focus();
|
|
178
172
|
}
|
|
179
173
|
|
|
180
|
-
case
|
|
174
|
+
case 18:
|
|
181
175
|
case "end":
|
|
182
176
|
return _context.stop();
|
|
183
177
|
}
|