@tiny-codes/react-easy 1.0.3 → 1.0.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.
- package/CHANGELOG.md +13 -0
- package/es/components/BreakLines/index.js +43 -26
- package/es/components/BreakLines/index.js.map +1 -1
- package/es/components/ConfigProvider/context.js +3 -3
- package/es/components/ConfigProvider/context.js.map +1 -1
- package/es/components/ConfigProvider/index.js +37 -35
- package/es/components/ConfigProvider/index.js.map +1 -1
- package/es/components/ConfirmAction/index.d.ts +74 -6
- package/es/components/ConfirmAction/index.js +210 -104
- package/es/components/ConfirmAction/index.js.map +1 -1
- package/es/components/DeleteConfirmAction/index.js +22 -20
- package/es/components/DeleteConfirmAction/index.js.map +1 -1
- package/es/components/ModalAction/index.d.ts +45 -5
- package/es/components/ModalAction/index.js +393 -209
- package/es/components/ModalAction/index.js.map +1 -1
- package/es/components/index.js +10 -8
- package/es/components/index.js.map +1 -1
- package/es/hooks/index.js +4 -4
- package/es/hooks/index.js.map +1 -1
- package/es/hooks/useContextValidator.js +7 -12
- package/es/hooks/useContextValidator.js.map +1 -1
- package/es/hooks/useLocalizedText.js +6 -4
- package/es/hooks/useLocalizedText.js.map +1 -1
- package/es/hooks/useRefFunction.js +13 -6
- package/es/hooks/useRefFunction.js.map +1 -1
- package/es/hooks/useT.js +11 -8
- package/es/hooks/useT.js.map +1 -1
- package/es/hooks/useValidator.js +7 -4
- package/es/hooks/useValidator.js.map +1 -1
- package/es/hooks/useValidatorBuilder.js +146 -117
- package/es/hooks/useValidatorBuilder.js.map +1 -1
- package/es/hooks/useValidators.js +94 -58
- package/es/hooks/useValidators.js.map +1 -1
- package/es/index.js +2 -2
- package/es/index.js.map +1 -1
- package/es/locales/index.js +19 -13
- package/es/locales/index.js.map +1 -1
- package/es/locales/langs/en-US.js +20 -20
- package/es/locales/langs/en-US.js.map +1 -1
- package/es/locales/langs/en.js +1 -1
- package/es/locales/langs/en.js.map +1 -1
- package/es/locales/langs/zh-CN.js +20 -20
- package/es/locales/langs/zh-CN.js.map +1 -1
- package/es/utils/index.js +1 -1
- package/es/utils/index.js.map +1 -1
- package/lib/components/BreakLines/index.js +50 -37
- package/lib/components/BreakLines/index.js.map +7 -1
- package/lib/components/ConfigProvider/context.js +35 -6
- package/lib/components/ConfigProvider/context.js.map +7 -1
- package/lib/components/ConfigProvider/index.js +56 -42
- package/lib/components/ConfigProvider/index.js.map +7 -1
- package/lib/components/ConfirmAction/index.d.ts +74 -6
- package/lib/components/ConfirmAction/index.js +194 -138
- package/lib/components/ConfirmAction/index.js.map +7 -1
- package/lib/components/DeleteConfirmAction/index.js +50 -51
- package/lib/components/DeleteConfirmAction/index.js.map +7 -1
- package/lib/components/ModalAction/index.d.ts +45 -5
- package/lib/components/ModalAction/index.js +303 -243
- package/lib/components/ModalAction/index.js.map +7 -1
- package/lib/components/index.js +63 -11
- package/lib/components/index.js.map +7 -1
- package/lib/hooks/index.js +49 -5
- package/lib/hooks/index.js.map +7 -1
- package/lib/hooks/useContextValidator.js +47 -11
- package/lib/hooks/useContextValidator.js.map +7 -1
- package/lib/hooks/useLocalizedText.js +41 -15
- package/lib/hooks/useLocalizedText.js.map +7 -1
- package/lib/hooks/useRefFunction.js +34 -21
- package/lib/hooks/useRefFunction.js.map +7 -1
- package/lib/hooks/useT.js +43 -11
- package/lib/hooks/useT.js.map +7 -1
- package/lib/hooks/useValidator.js +41 -12
- package/lib/hooks/useValidator.js.map +7 -1
- package/lib/hooks/useValidatorBuilder.js +149 -132
- package/lib/hooks/useValidatorBuilder.js.map +7 -1
- package/lib/hooks/useValidators.js +104 -67
- package/lib/hooks/useValidators.js.map +7 -1
- package/lib/index.js +26 -3
- package/lib/index.js.map +7 -1
- package/lib/locales/index.js +58 -15
- package/lib/locales/index.js.map +7 -1
- package/lib/locales/langs/en-US.js +46 -22
- package/lib/locales/langs/en-US.js.map +7 -1
- package/lib/locales/langs/en.js +37 -3
- package/lib/locales/langs/en.js.map +7 -1
- package/lib/locales/langs/zh-CN.js +46 -22
- package/lib/locales/langs/zh-CN.js.map +7 -1
- package/lib/utils/index.js +1 -2
- package/lib/utils/index.js.map +7 -1
- package/package.json +14 -15
- package/es/hooks/useValidateContext.d.ts +0 -2
- package/es/hooks/useValidateContext.js +0 -16
- package/es/hooks/useValidateContext.js.map +0 -1
- package/lib/hooks/useValidateContext.d.ts +0 -2
- package/lib/hooks/useValidateContext.js +0 -16
- package/lib/hooks/useValidateContext.js.map +0 -1
|
@@ -1,259 +1,319 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
10
|
};
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
for (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
20
18
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/components/ModalAction/index.tsx
|
|
30
|
+
var ModalAction_exports = {};
|
|
31
|
+
__export(ModalAction_exports, {
|
|
32
|
+
SubmitWithoutClosingSymbol: () => SubmitWithoutClosingSymbol,
|
|
33
|
+
default: () => ModalAction_default,
|
|
34
|
+
genModalActionRenderer: () => genModalActionRenderer,
|
|
35
|
+
withDefaultModalActionProps: () => withDefaultModalActionProps,
|
|
36
|
+
withModalAction: () => withModalAction
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(ModalAction_exports);
|
|
39
|
+
var import_react = require("react");
|
|
40
|
+
var import_antd = require("antd");
|
|
41
|
+
var import_react_is = require("react-is");
|
|
42
|
+
var import_useContextValidator = __toESM(require("../../hooks/useContextValidator"));
|
|
43
|
+
var SubmitWithoutClosingSymbol = Symbol("[SubmitWithoutClose]");
|
|
44
|
+
var genModalActionRenderer = (defaultProps) => {
|
|
45
|
+
const ModalActionRenderer = (props, ref) => {
|
|
46
|
+
const [userModalProps, setUserModalProps] = (0, import_react.useState)({});
|
|
47
|
+
let mergedProps = mergeProps(defaultProps, props);
|
|
48
|
+
mergedProps = mergeProps(mergedProps, userModalProps);
|
|
49
|
+
const {
|
|
50
|
+
formComp,
|
|
51
|
+
formProps,
|
|
52
|
+
triggerComponent: Trigger = import_antd.Button,
|
|
53
|
+
triggerEvent = "onClick",
|
|
54
|
+
triggerProps,
|
|
55
|
+
open: openInProps,
|
|
56
|
+
destroyOnClose = true,
|
|
57
|
+
maskClosable = false,
|
|
58
|
+
onOk,
|
|
59
|
+
afterOk,
|
|
60
|
+
onCancel,
|
|
61
|
+
onClose,
|
|
62
|
+
children,
|
|
63
|
+
...restProps
|
|
64
|
+
} = mergedProps;
|
|
65
|
+
(0, import_useContextValidator.default)();
|
|
66
|
+
const FormComp = formComp;
|
|
67
|
+
const triggerEventArgsRef = (0, import_react.useRef)(void 0);
|
|
68
|
+
const [open, setOpen] = (0, import_react.useState)(false);
|
|
69
|
+
const saveFuncRef = (0, import_react.useRef)(void 0);
|
|
70
|
+
const [isSaving, setIsSaving] = (0, import_react.useState)(false);
|
|
71
|
+
const [formCompRef, setFormCompRef] = (0, import_react.useState)(null);
|
|
72
|
+
const [form, setForm] = (0, import_react.useState)();
|
|
73
|
+
const formRef = (0, import_react.useRef)(form);
|
|
74
|
+
formRef.current = form;
|
|
75
|
+
const destroyOnCloseRef = (0, import_react.useRef)(destroyOnClose);
|
|
76
|
+
destroyOnCloseRef.current = destroyOnClose;
|
|
77
|
+
const openListenerRef = (0, import_react.useRef)(void 0);
|
|
78
|
+
(0, import_react.useEffect)(() => {
|
|
79
|
+
if (openInProps) {
|
|
80
|
+
setOpen(openInProps);
|
|
81
|
+
}
|
|
82
|
+
}, [openInProps]);
|
|
83
|
+
(0, import_react.useEffect)(() => {
|
|
84
|
+
if (!destroyOnCloseRef.current && open && formRef.current) {
|
|
85
|
+
formRef.current.resetFields();
|
|
86
|
+
}
|
|
87
|
+
}, [open]);
|
|
88
|
+
const showInProps = triggerProps == null ? void 0 : triggerProps.show;
|
|
89
|
+
const showTrigger = (0, import_react.useMemo)(() => {
|
|
90
|
+
if (typeof showInProps === "boolean") {
|
|
91
|
+
return showInProps;
|
|
92
|
+
} else if (typeof showInProps === "function") {
|
|
93
|
+
return showInProps(formProps);
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}, [showInProps, formProps]);
|
|
97
|
+
const showModal = (0, import_react.useCallback)(() => {
|
|
98
|
+
var _a;
|
|
99
|
+
setOpen(true);
|
|
100
|
+
(_a = openListenerRef.current) == null ? void 0 : _a.call(openListenerRef, true);
|
|
101
|
+
}, []);
|
|
102
|
+
const hideModal = (0, import_react.useCallback)(() => {
|
|
103
|
+
var _a;
|
|
104
|
+
setOpen(false);
|
|
105
|
+
(_a = openListenerRef.current) == null ? void 0 : _a.call(openListenerRef, false);
|
|
106
|
+
}, []);
|
|
107
|
+
const setOpenListener = (0, import_react.useCallback)(
|
|
108
|
+
(listener) => {
|
|
36
109
|
var _a;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
110
|
+
openListenerRef.current = listener;
|
|
111
|
+
(_a = openListenerRef.current) == null ? void 0 : _a.call(openListenerRef, open);
|
|
112
|
+
},
|
|
113
|
+
[open]
|
|
114
|
+
);
|
|
115
|
+
const setOnSaveHandler = (0, import_react.useCallback)((handler) => {
|
|
116
|
+
saveFuncRef.current = handler;
|
|
117
|
+
}, []);
|
|
118
|
+
const handleSetOpen = (0, import_react.useCallback)((open2) => {
|
|
119
|
+
var _a;
|
|
120
|
+
setOpen(open2);
|
|
121
|
+
(_a = openListenerRef.current) == null ? void 0 : _a.call(openListenerRef, open2);
|
|
122
|
+
}, []);
|
|
123
|
+
(0, import_react.useImperativeHandle)(ref, () => ({ ...formCompRef, show: showModal }), [
|
|
124
|
+
formCompRef,
|
|
125
|
+
showModal
|
|
126
|
+
]);
|
|
127
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, showTrigger && /* @__PURE__ */ React.createElement(
|
|
128
|
+
Trigger,
|
|
129
|
+
{
|
|
130
|
+
...triggerProps,
|
|
131
|
+
...triggerEvent ? {
|
|
132
|
+
[triggerEvent]: (...args) => {
|
|
133
|
+
triggerEventArgsRef.current = args;
|
|
134
|
+
showModal();
|
|
135
|
+
if (triggerProps && typeof triggerProps[triggerEvent] === "function") {
|
|
136
|
+
triggerProps[triggerEvent](...args);
|
|
59
137
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
138
|
+
}
|
|
139
|
+
} : {}
|
|
140
|
+
},
|
|
141
|
+
triggerProps.children ?? children
|
|
142
|
+
), /* @__PURE__ */ React.createElement(
|
|
143
|
+
import_antd.Modal,
|
|
144
|
+
{
|
|
145
|
+
open,
|
|
146
|
+
confirmLoading: isSaving,
|
|
147
|
+
destroyOnClose,
|
|
148
|
+
maskClosable,
|
|
149
|
+
onOk: async (e) => {
|
|
150
|
+
var _a;
|
|
151
|
+
let formData;
|
|
152
|
+
try {
|
|
153
|
+
formData = await (form == null ? void 0 : form.validateFields());
|
|
154
|
+
} catch (e2) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (Object.keys(formData).length === 0) {
|
|
158
|
+
console.warn(
|
|
159
|
+
"form.getFieldsValue() is empty. Please use the form instance passed to formComp instead of creating the form instance yourself."
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
setIsSaving(true);
|
|
164
|
+
let result = await ((_a = saveFuncRef.current) == null ? void 0 : _a.call(saveFuncRef, formData, ...triggerEventArgsRef.current ?? []));
|
|
165
|
+
if (result === SubmitWithoutClosingSymbol) {
|
|
166
|
+
throw new Error("SubmitWithoutClosing");
|
|
65
167
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
triggerEventArgsRef.current = args;
|
|
106
|
-
showModal();
|
|
107
|
-
if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {
|
|
108
|
-
triggerProps[triggerEvent](...args);
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
}
|
|
112
|
-
: {}), { children: (_a = triggerProps.children) !== null && _a !== void 0 ? _a : children })), _jsxs(Modal, Object.assign({ open: open, confirmLoading: isSaving, destroyOnClose: destroyOnClose, maskClosable: maskClosable, onOk: (e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
113
|
-
var _a, _b, _c, _d;
|
|
114
|
-
let formData;
|
|
115
|
-
try {
|
|
116
|
-
formData = (yield (form === null || form === void 0 ? void 0 : form.validateFields()));
|
|
117
|
-
}
|
|
118
|
-
catch (e) {
|
|
119
|
-
// Validation error, should not throw error
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
if (Object.keys(formData).length === 0) {
|
|
123
|
-
console.warn('form.getFieldsValue() is empty. Please use the form instance passed to formComp instead of creating the form instance yourself.');
|
|
124
|
-
}
|
|
125
|
-
try {
|
|
126
|
-
setIsSaving(true);
|
|
127
|
-
// First call onSave of the form component
|
|
128
|
-
let result = yield ((_a = saveFuncRef.current) === null || _a === void 0 ? void 0 : _a.call(saveFuncRef, formData, ...((_b = triggerEventArgsRef.current) !== null && _b !== void 0 ? _b : [])));
|
|
129
|
-
// The onSave of the form component has the ability to prevent the dialog from closing
|
|
130
|
-
if (result === SubmitWithoutClosingSymbol) {
|
|
131
|
-
throw new Error('SubmitWithoutClosing');
|
|
132
|
-
}
|
|
133
|
-
// Then call onOk of the dialog, support asynchronous, and will pass the return value of onSave, if any
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
135
|
-
result = yield (onOk === null || onOk === void 0 ? void 0 : onOk((_c = result) !== null && _c !== void 0 ? _c : formData, ...((_d = triggerEventArgsRef.current) !== null && _d !== void 0 ? _d : [])));
|
|
136
|
-
// onOk also has the ability to prevent the dialog from closing
|
|
137
|
-
if (result === SubmitWithoutClosingSymbol) {
|
|
138
|
-
throw new Error('SubmitWithoutClosing');
|
|
139
|
-
}
|
|
140
|
-
// If onOK is successful, close the dialog and trigger the afterOk event
|
|
141
|
-
hideModal();
|
|
142
|
-
afterOk === null || afterOk === void 0 ? void 0 : afterOk(result);
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
console.error(error);
|
|
146
|
-
}
|
|
147
|
-
finally {
|
|
148
|
-
setIsSaving(false);
|
|
149
|
-
}
|
|
150
|
-
}), onCancel: (e) => __awaiter(void 0, void 0, void 0, function* () {
|
|
151
|
-
hideModal();
|
|
152
|
-
onCancel === null || onCancel === void 0 ? void 0 : onCancel(e);
|
|
153
|
-
}), onClose: (e) => {
|
|
154
|
-
hideModal();
|
|
155
|
-
onClose === null || onClose === void 0 ? void 0 : onClose(e);
|
|
156
|
-
} }, restProps, { children: [_jsx(FormCreator, { onCreate: setForm }), form && (_jsx(FormComp, Object.assign({ ref: isForwardRef(FormComp) ? setFormCompRef : undefined }, formProps, { form: form, onOpenChange: setOpenListener, onSave: setOnSaveHandler, triggerEventData: triggerEventArgsRef.current, setOpen: handleSetOpen, updateModalProps: setUserModalProps })))] }))] }));
|
|
157
|
-
};
|
|
158
|
-
return ModalActionRenderer;
|
|
168
|
+
result = await (onOk == null ? void 0 : onOk(result ?? formData, ...triggerEventArgsRef.current ?? []));
|
|
169
|
+
if (result === SubmitWithoutClosingSymbol) {
|
|
170
|
+
throw new Error("SubmitWithoutClosing");
|
|
171
|
+
}
|
|
172
|
+
hideModal();
|
|
173
|
+
afterOk == null ? void 0 : afterOk(result);
|
|
174
|
+
} catch (error) {
|
|
175
|
+
console.error(error);
|
|
176
|
+
} finally {
|
|
177
|
+
setIsSaving(false);
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
onCancel: async (e) => {
|
|
181
|
+
hideModal();
|
|
182
|
+
onCancel == null ? void 0 : onCancel(e);
|
|
183
|
+
},
|
|
184
|
+
onClose: (e) => {
|
|
185
|
+
hideModal();
|
|
186
|
+
onClose == null ? void 0 : onClose(e);
|
|
187
|
+
},
|
|
188
|
+
...restProps
|
|
189
|
+
},
|
|
190
|
+
/* @__PURE__ */ React.createElement(FormCreator, { onCreate: setForm }),
|
|
191
|
+
form && /* @__PURE__ */ React.createElement(
|
|
192
|
+
FormComp,
|
|
193
|
+
{
|
|
194
|
+
ref: (0, import_react_is.isForwardRef)(FormComp) ? setFormCompRef : void 0,
|
|
195
|
+
...formProps,
|
|
196
|
+
form,
|
|
197
|
+
onOpenChange: setOpenListener,
|
|
198
|
+
onSave: setOnSaveHandler,
|
|
199
|
+
triggerEventData: triggerEventArgsRef.current,
|
|
200
|
+
setOpen: handleSetOpen,
|
|
201
|
+
updateModalProps: setUserModalProps
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
));
|
|
205
|
+
};
|
|
206
|
+
return ModalActionRenderer;
|
|
159
207
|
};
|
|
160
208
|
function mergeProps(first, second) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
209
|
+
return {
|
|
210
|
+
...first,
|
|
211
|
+
...second,
|
|
212
|
+
okButtonProps: {
|
|
213
|
+
...first == null ? void 0 : first.okButtonProps,
|
|
214
|
+
...second == null ? void 0 : second.okButtonProps
|
|
215
|
+
},
|
|
216
|
+
cancelButtonProps: {
|
|
217
|
+
...first == null ? void 0 : first.cancelButtonProps,
|
|
218
|
+
...second == null ? void 0 : second.cancelButtonProps
|
|
219
|
+
},
|
|
220
|
+
bodyProps: {
|
|
221
|
+
...first == null ? void 0 : first.bodyProps,
|
|
222
|
+
...second == null ? void 0 : second.bodyProps
|
|
223
|
+
},
|
|
224
|
+
maskProps: {
|
|
225
|
+
...first == null ? void 0 : first.maskProps,
|
|
226
|
+
...second == null ? void 0 : second.maskProps
|
|
227
|
+
},
|
|
228
|
+
wrapProps: {
|
|
229
|
+
...first == null ? void 0 : first.wrapProps,
|
|
230
|
+
...second == null ? void 0 : second.wrapProps
|
|
231
|
+
},
|
|
232
|
+
triggerProps: {
|
|
233
|
+
...first == null ? void 0 : first.triggerProps,
|
|
234
|
+
...second == null ? void 0 : second.triggerProps,
|
|
235
|
+
style: {
|
|
236
|
+
...(first == null ? void 0 : first.triggerProps) && "style" in first.triggerProps && typeof first.triggerProps.style === "object" ? first.triggerProps.style : {},
|
|
237
|
+
...(second == null ? void 0 : second.triggerProps) && "style" in second.triggerProps && typeof second.triggerProps.style === "object" ? second.triggerProps.style : {}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
166
241
|
}
|
|
167
242
|
function FormCreator(props) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return null;
|
|
243
|
+
const { onCreate } = props;
|
|
244
|
+
const onCreateRef = (0, import_react.useRef)(onCreate);
|
|
245
|
+
onCreateRef.current = onCreate;
|
|
246
|
+
const [form] = import_antd.Form.useForm();
|
|
247
|
+
(0, import_react.useEffect)(() => {
|
|
248
|
+
onCreateRef.current(form);
|
|
249
|
+
return () => {
|
|
250
|
+
onCreateRef.current(void 0);
|
|
251
|
+
};
|
|
252
|
+
}, [form]);
|
|
253
|
+
return null;
|
|
180
254
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const WithDefaultProps = forwardRef((props, ref) => {
|
|
191
|
-
const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;
|
|
192
|
-
const defaults = useDefaultProps();
|
|
193
|
-
const mergedProps = mergeProps(defaults, props);
|
|
194
|
-
WithDefaultProps.displayName = 'ForwardedRef(WithDefaultProps)';
|
|
195
|
-
return _jsx(WrappedComponent, Object.assign({ ref: ref }, mergedProps));
|
|
196
|
-
});
|
|
197
|
-
return WithDefaultProps;
|
|
255
|
+
var withDefaultModalActionProps = (WrappedComponent, defaultProps) => {
|
|
256
|
+
const WithDefaultProps = (0, import_react.forwardRef)((props, ref) => {
|
|
257
|
+
const useDefaultProps = typeof defaultProps === "function" ? defaultProps : () => defaultProps;
|
|
258
|
+
const defaults = useDefaultProps();
|
|
259
|
+
const mergedProps = mergeProps(defaults, props);
|
|
260
|
+
WithDefaultProps.displayName = "ForwardedRef(WithDefaultProps)";
|
|
261
|
+
return /* @__PURE__ */ React.createElement(WrappedComponent, { ref, ...mergedProps });
|
|
262
|
+
});
|
|
263
|
+
return WithDefaultProps;
|
|
198
264
|
};
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
forwardedModalAction.displayName =
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// Type of switch trigger
|
|
217
|
-
patchedComp.Switch = withDefaultModalActionProps(comp, {
|
|
218
|
-
triggerComponent: Switch,
|
|
219
|
-
triggerEvent: 'onChange',
|
|
220
|
-
triggerProps: {},
|
|
265
|
+
var renderModalAction = genModalActionRenderer({});
|
|
266
|
+
var forwardedModalAction = (0, import_react.forwardRef)(renderModalAction);
|
|
267
|
+
forwardedModalAction.displayName = "ForwardedRef(ModalAction)";
|
|
268
|
+
var addTriggers = (comp) => {
|
|
269
|
+
const patchedComp = comp;
|
|
270
|
+
patchedComp.Button = withDefaultModalActionProps(comp, {
|
|
271
|
+
triggerComponent: import_antd.Button,
|
|
272
|
+
triggerEvent: "onClick",
|
|
273
|
+
triggerProps: {}
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
275
|
+
});
|
|
276
|
+
patchedComp.Switch = withDefaultModalActionProps(
|
|
277
|
+
comp,
|
|
278
|
+
{
|
|
279
|
+
triggerComponent: import_antd.Switch,
|
|
280
|
+
triggerEvent: "onChange",
|
|
281
|
+
triggerProps: {}
|
|
221
282
|
}
|
|
222
283
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return patchedComp;
|
|
284
|
+
);
|
|
285
|
+
patchedComp.Link = withDefaultModalActionProps(comp, {
|
|
286
|
+
triggerComponent: import_antd.Typography.Link,
|
|
287
|
+
triggerEvent: "onClick",
|
|
288
|
+
triggerProps: {
|
|
289
|
+
style: { whiteSpace: "nowrap" }
|
|
290
|
+
}
|
|
291
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
292
|
+
});
|
|
293
|
+
return patchedComp;
|
|
234
294
|
};
|
|
235
|
-
|
|
236
|
-
* **EN:** Dialog component with trigger
|
|
237
|
-
*
|
|
238
|
-
* **CN:** 带触发器的弹窗组件
|
|
239
|
-
*/
|
|
240
|
-
const ModalAction = addTriggers(forwardedModalAction);
|
|
295
|
+
var ModalAction = addTriggers(forwardedModalAction);
|
|
241
296
|
ModalAction.SubmitWithoutClosing = SubmitWithoutClosingSymbol;
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
});
|
|
256
|
-
return addTriggers(withForm);
|
|
297
|
+
function withModalAction(formComp, defaultProps) {
|
|
298
|
+
const withForm = withDefaultModalActionProps(
|
|
299
|
+
forwardedModalAction,
|
|
300
|
+
() => {
|
|
301
|
+
const useDefaultProps = typeof defaultProps === "function" ? defaultProps : () => defaultProps;
|
|
302
|
+
const defaults = useDefaultProps();
|
|
303
|
+
return {
|
|
304
|
+
formComp,
|
|
305
|
+
...defaults
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
);
|
|
309
|
+
return addTriggers(withForm);
|
|
257
310
|
}
|
|
258
|
-
|
|
259
|
-
|
|
311
|
+
var ModalAction_default = ModalAction;
|
|
312
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
313
|
+
0 && (module.exports = {
|
|
314
|
+
SubmitWithoutClosingSymbol,
|
|
315
|
+
genModalActionRenderer,
|
|
316
|
+
withDefaultModalActionProps,
|
|
317
|
+
withModalAction
|
|
318
|
+
});
|
|
319
|
+
//# sourceMappingURL=index.js.map
|