@tiny-codes/react-easy 1.0.0
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 +20 -0
- package/LICENSE +21 -0
- package/README.md +194 -0
- package/README.zh-CN.md +190 -0
- package/es/components/ConfigProvider/context.d.ts +49 -0
- package/es/components/ConfigProvider/context.js +5 -0
- package/es/components/ConfigProvider/context.js.map +1 -0
- package/es/components/ConfigProvider/index.d.ts +12 -0
- package/es/components/ConfigProvider/index.js +24 -0
- package/es/components/ConfigProvider/index.js.map +1 -0
- package/es/components/ConfirmAction/index.d.ts +178 -0
- package/es/components/ConfirmAction/index.js +150 -0
- package/es/components/ConfirmAction/index.js.map +1 -0
- package/es/components/DeleteConfirmAction/index.d.ts +8 -0
- package/es/components/DeleteConfirmAction/index.js +55 -0
- package/es/components/DeleteConfirmAction/index.js.map +1 -0
- package/es/components/ModalAction/index.d.ts +237 -0
- package/es/components/ModalAction/index.js +259 -0
- package/es/components/ModalAction/index.js.map +1 -0
- package/es/components/index.d.ts +9 -0
- package/es/components/index.js +9 -0
- package/es/components/index.js.map +1 -0
- package/es/hooks/index.d.ts +1 -0
- package/es/hooks/index.js +2 -0
- package/es/hooks/index.js.map +1 -0
- package/es/hooks/useLocalizedText.d.ts +11 -0
- package/es/hooks/useLocalizedText.js +16 -0
- package/es/hooks/useLocalizedText.js.map +1 -0
- package/es/hooks/useRefFunction.d.ts +13 -0
- package/es/hooks/useRefFunction.js +22 -0
- package/es/hooks/useRefFunction.js.map +1 -0
- package/es/hooks/useValidateContext.d.ts +2 -0
- package/es/hooks/useValidateContext.js +16 -0
- package/es/hooks/useValidateContext.js.map +1 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +3 -0
- package/es/index.js.map +1 -0
- package/lib/components/ConfigProvider/context.d.ts +49 -0
- package/lib/components/ConfigProvider/context.js +5 -0
- package/lib/components/ConfigProvider/context.js.map +1 -0
- package/lib/components/ConfigProvider/index.d.ts +12 -0
- package/lib/components/ConfigProvider/index.js +24 -0
- package/lib/components/ConfigProvider/index.js.map +1 -0
- package/lib/components/ConfirmAction/index.d.ts +178 -0
- package/lib/components/ConfirmAction/index.js +150 -0
- package/lib/components/ConfirmAction/index.js.map +1 -0
- package/lib/components/DeleteConfirmAction/index.d.ts +8 -0
- package/lib/components/DeleteConfirmAction/index.js +55 -0
- package/lib/components/DeleteConfirmAction/index.js.map +1 -0
- package/lib/components/ModalAction/index.d.ts +237 -0
- package/lib/components/ModalAction/index.js +259 -0
- package/lib/components/ModalAction/index.js.map +1 -0
- package/lib/components/index.d.ts +9 -0
- package/lib/components/index.js +9 -0
- package/lib/components/index.js.map +1 -0
- package/lib/hooks/index.d.ts +1 -0
- package/lib/hooks/index.js +2 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/useLocalizedText.d.ts +11 -0
- package/lib/hooks/useLocalizedText.js +16 -0
- package/lib/hooks/useLocalizedText.js.map +1 -0
- package/lib/hooks/useRefFunction.d.ts +13 -0
- package/lib/hooks/useRefFunction.js +22 -0
- package/lib/hooks/useRefFunction.js.map +1 -0
- package/lib/hooks/useValidateContext.d.ts +2 -0
- package/lib/hooks/useValidateContext.js +16 -0
- package/lib/hooks/useValidateContext.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
23
|
+
import { Button, Form, Modal, Switch, Typography } from 'antd';
|
|
24
|
+
import { isForwardRef } from 'react-is';
|
|
25
|
+
import useValidateContext from '../../hooks/useValidateContext';
|
|
26
|
+
/**
|
|
27
|
+
* **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when
|
|
28
|
+
* returning in the `onSave` event of the editing form component
|
|
29
|
+
*
|
|
30
|
+
* **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效
|
|
31
|
+
*/
|
|
32
|
+
export const SubmitWithoutClosingSymbol = Symbol('[SubmitWithoutClose]');
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
export const genModalActionRenderer = (defaultProps) => {
|
|
35
|
+
const ModalActionRenderer = (props, ref) => {
|
|
36
|
+
var _a;
|
|
37
|
+
const [userModalProps, setUserModalProps] = useState({});
|
|
38
|
+
let mergedProps = mergeProps(defaultProps, props);
|
|
39
|
+
mergedProps = mergeProps(mergedProps, userModalProps);
|
|
40
|
+
const { formComp, formProps, triggerComponent: Trigger = Button, triggerEvent = 'onClick', triggerProps, open: openInProps, destroyOnClose = true, maskClosable = false, onOk, afterOk, onCancel, onClose, children } = mergedProps, restProps = __rest(mergedProps, ["formComp", "formProps", "triggerComponent", "triggerEvent", "triggerProps", "open", "destroyOnClose", "maskClosable", "onOk", "afterOk", "onCancel", "onClose", "children"]);
|
|
41
|
+
useValidateContext();
|
|
42
|
+
const FormComp = formComp;
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
const triggerEventArgsRef = useRef(undefined);
|
|
45
|
+
const [open, setOpen] = useState(false);
|
|
46
|
+
const saveFuncRef = useRef(undefined);
|
|
47
|
+
const [isSaving, setIsSaving] = useState(false);
|
|
48
|
+
const [formCompRef, setFormCompRef] = useState(null);
|
|
49
|
+
const [form, setForm] = useState();
|
|
50
|
+
const formRef = useRef(form);
|
|
51
|
+
formRef.current = form;
|
|
52
|
+
const destroyOnCloseRef = useRef(destroyOnClose);
|
|
53
|
+
destroyOnCloseRef.current = destroyOnClose;
|
|
54
|
+
const openListenerRef = useRef(undefined);
|
|
55
|
+
// Listen to the open props changes
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (openInProps) {
|
|
58
|
+
setOpen(openInProps);
|
|
59
|
+
}
|
|
60
|
+
}, [openInProps]);
|
|
61
|
+
// Reset the form after closed
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (!destroyOnCloseRef.current && open && formRef.current) {
|
|
64
|
+
formRef.current.resetFields();
|
|
65
|
+
}
|
|
66
|
+
}, [open]);
|
|
67
|
+
// Show the dialog
|
|
68
|
+
const showModal = useCallback(() => {
|
|
69
|
+
var _a;
|
|
70
|
+
setOpen(true);
|
|
71
|
+
(_a = openListenerRef.current) === null || _a === void 0 ? void 0 : _a.call(openListenerRef, true);
|
|
72
|
+
}, []);
|
|
73
|
+
// Hide the dialog
|
|
74
|
+
const hideModal = useCallback(() => {
|
|
75
|
+
var _a;
|
|
76
|
+
setOpen(false);
|
|
77
|
+
(_a = openListenerRef.current) === null || _a === void 0 ? void 0 : _a.call(openListenerRef, false);
|
|
78
|
+
}, []);
|
|
79
|
+
// Set the dialog status listener
|
|
80
|
+
const setOpenListener = useCallback((listener) => {
|
|
81
|
+
var _a;
|
|
82
|
+
openListenerRef.current = listener;
|
|
83
|
+
// Call once when initialized
|
|
84
|
+
(_a = openListenerRef.current) === null || _a === void 0 ? void 0 : _a.call(openListenerRef, open);
|
|
85
|
+
}, [open]);
|
|
86
|
+
// Receive the onSave callback method passed by the form component
|
|
87
|
+
const setOnSaveHandler = useCallback((handler) => {
|
|
88
|
+
saveFuncRef.current = handler;
|
|
89
|
+
}, []);
|
|
90
|
+
// Set the dialog status and trigger the onOpenChange event of the form component
|
|
91
|
+
const handleSetOpen = useCallback((open) => {
|
|
92
|
+
var _a;
|
|
93
|
+
setOpen(open);
|
|
94
|
+
(_a = openListenerRef.current) === null || _a === void 0 ? void 0 : _a.call(openListenerRef, open);
|
|
95
|
+
}, []);
|
|
96
|
+
// Output ref
|
|
97
|
+
useImperativeHandle(ref, () => (Object.assign(Object.assign({}, formCompRef), { show: showModal })), [
|
|
98
|
+
formCompRef,
|
|
99
|
+
showModal,
|
|
100
|
+
]);
|
|
101
|
+
// Render the trigger component
|
|
102
|
+
return (_jsxs(_Fragment, { children: [_jsx(Trigger, Object.assign({}, triggerProps, (triggerEvent
|
|
103
|
+
? {
|
|
104
|
+
[triggerEvent]: (...args) => {
|
|
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;
|
|
159
|
+
};
|
|
160
|
+
function mergeProps(first, second) {
|
|
161
|
+
return Object.assign(Object.assign(Object.assign({}, first), second), { okButtonProps: Object.assign(Object.assign({}, first === null || first === void 0 ? void 0 : first.okButtonProps), second === null || second === void 0 ? void 0 : second.okButtonProps), cancelButtonProps: Object.assign(Object.assign({}, first === null || first === void 0 ? void 0 : first.cancelButtonProps), second === null || second === void 0 ? void 0 : second.cancelButtonProps), bodyProps: Object.assign(Object.assign({}, first === null || first === void 0 ? void 0 : first.bodyProps), second === null || second === void 0 ? void 0 : second.bodyProps), maskProps: Object.assign(Object.assign({}, first === null || first === void 0 ? void 0 : first.maskProps), second === null || second === void 0 ? void 0 : second.maskProps), wrapProps: Object.assign(Object.assign({}, first === null || first === void 0 ? void 0 : first.wrapProps), second === null || second === void 0 ? void 0 : second.wrapProps), triggerProps: Object.assign(Object.assign(Object.assign({}, first === null || first === void 0 ? void 0 : first.triggerProps), second === null || second === void 0 ? void 0 : second.triggerProps), { style: Object.assign(Object.assign({}, ((first === null || first === void 0 ? void 0 : first.triggerProps) && 'style' in first.triggerProps && typeof first.triggerProps.style === 'object'
|
|
162
|
+
? first.triggerProps.style
|
|
163
|
+
: {})), ((second === null || second === void 0 ? void 0 : second.triggerProps) && 'style' in second.triggerProps && typeof second.triggerProps.style === 'object'
|
|
164
|
+
? second.triggerProps.style
|
|
165
|
+
: {})) }) });
|
|
166
|
+
}
|
|
167
|
+
function FormCreator(props) {
|
|
168
|
+
const { onCreate } = props;
|
|
169
|
+
const onCreateRef = useRef(onCreate);
|
|
170
|
+
onCreateRef.current = onCreate;
|
|
171
|
+
const [form] = Form.useForm();
|
|
172
|
+
// output ref
|
|
173
|
+
useEffect(() => {
|
|
174
|
+
onCreateRef.current(form);
|
|
175
|
+
return () => {
|
|
176
|
+
onCreateRef.current(undefined);
|
|
177
|
+
};
|
|
178
|
+
}, [form]);
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* **EN:** Add default properties to the ModalAction component
|
|
183
|
+
*
|
|
184
|
+
* **CN:** 给ModalAction组件添加默认属性
|
|
185
|
+
*
|
|
186
|
+
* @param WrappedComponent ModalAction component | ModalAction组件
|
|
187
|
+
* @param defaultProps Default properties | 默认属性
|
|
188
|
+
*/
|
|
189
|
+
export const withDefaultModalActionProps = (WrappedComponent, defaultProps) => {
|
|
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;
|
|
198
|
+
};
|
|
199
|
+
const renderModalAction = genModalActionRenderer({});
|
|
200
|
+
const forwardedModalAction = forwardRef(renderModalAction);
|
|
201
|
+
forwardedModalAction.displayName = 'ForwardedRef(ModalAction)';
|
|
202
|
+
/**
|
|
203
|
+
* **EN:** Add trigger types to the ModalAction component
|
|
204
|
+
*
|
|
205
|
+
* **CN:** 给ModalAction组件添加子触发器类型
|
|
206
|
+
*/
|
|
207
|
+
const addTriggers = (comp) => {
|
|
208
|
+
const patchedComp = comp;
|
|
209
|
+
// Type of button trigger
|
|
210
|
+
patchedComp.Button = withDefaultModalActionProps(comp, {
|
|
211
|
+
triggerComponent: Button,
|
|
212
|
+
triggerEvent: 'onClick',
|
|
213
|
+
triggerProps: {},
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
215
|
+
});
|
|
216
|
+
// Type of switch trigger
|
|
217
|
+
patchedComp.Switch = withDefaultModalActionProps(comp, {
|
|
218
|
+
triggerComponent: Switch,
|
|
219
|
+
triggerEvent: 'onChange',
|
|
220
|
+
triggerProps: {},
|
|
221
|
+
}
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
+
);
|
|
224
|
+
// Type of link trigger
|
|
225
|
+
patchedComp.Link = withDefaultModalActionProps(comp, {
|
|
226
|
+
triggerComponent: Typography.Link,
|
|
227
|
+
triggerEvent: 'onClick',
|
|
228
|
+
triggerProps: {
|
|
229
|
+
style: { whiteSpace: 'nowrap' },
|
|
230
|
+
},
|
|
231
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
232
|
+
});
|
|
233
|
+
return patchedComp;
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* **EN:** Dialog component with trigger
|
|
237
|
+
*
|
|
238
|
+
* **CN:** 带触发器的弹窗组件
|
|
239
|
+
*/
|
|
240
|
+
const ModalAction = addTriggers(forwardedModalAction);
|
|
241
|
+
ModalAction.SubmitWithoutClosing = SubmitWithoutClosingSymbol;
|
|
242
|
+
/**
|
|
243
|
+
* **EN:** Generate a dialog component based on the editing form component
|
|
244
|
+
*
|
|
245
|
+
* **CN:** 基于编辑表单组件生成一个弹框组件
|
|
246
|
+
*
|
|
247
|
+
* @param formComp Component of dialog content | 弹窗内容组件
|
|
248
|
+
* @param defaultProps Default properties of the dialog | 弹窗的默认属性
|
|
249
|
+
*/
|
|
250
|
+
export function withModalAction(formComp, defaultProps) {
|
|
251
|
+
const withForm = withDefaultModalActionProps(forwardedModalAction, () => {
|
|
252
|
+
const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;
|
|
253
|
+
const defaults = useDefaultProps();
|
|
254
|
+
return Object.assign({ formComp }, defaults);
|
|
255
|
+
});
|
|
256
|
+
return addTriggers(withForm);
|
|
257
|
+
}
|
|
258
|
+
export default ModalAction;
|
|
259
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ModalAction/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElG,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,kBAAkB,MAAM,gCAAgC,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAoGzE,8DAA8D;AAC9D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,YAAoE,EAAE,EAAE;IAC7G,MAAM,mBAAmB,GAAG,CAO1B,KAA4C,EAC5C,GAAuC,EACvC,EAAE;;QACF,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAsB,EAAE,CAAC,CAAC;QAC9E,IAAI,WAAW,GAAG,UAAU,CAAsB,YAAY,EAAE,KAAK,CAAC,CAAC;QACvE,WAAW,GAAG,UAAU,CAAC,WAAW,EAAE,cAA8B,CAAC,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C;IACV,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,GAAG,WAAW,CAAC,oBAAoB,CAAC,CAAC;AAgBrD,WAAqC,CAAC,oBAAoB,GAAG,0BAA0B,CAAC;AAEzF;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAO7B,QAA+E,EAC/E,YAEoE;IAEpE,MAAM,QAAQ,GAAG,2BAA2B,CAC1C,oBAAsF,EACtF,GAAG,EAAE;QACH,MAAM,eAAe,GAAG,OAAO,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC;QAC/F,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;QACnC,uBACE,QAAQ,IACL,QAAQ,EACX;IACJ,CAAC,CAGc,CAAC;IAClB,OAAO,WAAW,CAA4C,QAAQ,CAAC,CAAC;AAC1E,CAAC;AAED,eAAe,WAAoC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './ConfigProvider';
|
|
2
|
+
export { default as ConfigProvider } from './ConfigProvider';
|
|
3
|
+
export type { ConfirmActionProps, ConfirmActionTrigger, ConfirmActionRef } from './ConfirmAction';
|
|
4
|
+
export { withDefaultConfirmActionProps } from './ConfirmAction';
|
|
5
|
+
export { default as ConfirmAction } from './ConfirmAction';
|
|
6
|
+
export { default as DeleteConfirmAction } from './DeleteConfirmAction';
|
|
7
|
+
export type { ModalActionProps, FormCompPropsConstraint, ModalActionTrigger, ModalActionRef } from './ModalAction';
|
|
8
|
+
export { withDefaultModalActionProps, withModalAction } from './ModalAction';
|
|
9
|
+
export { default as ModalAction } from './ModalAction';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './ConfigProvider';
|
|
2
|
+
export { default as ConfigProvider } from './ConfigProvider';
|
|
3
|
+
export { withDefaultConfirmActionProps } from './ConfirmAction';
|
|
4
|
+
export { default as ConfirmAction } from './ConfirmAction';
|
|
5
|
+
// export * from './DeleteConfirmAction';
|
|
6
|
+
export { default as DeleteConfirmAction } from './DeleteConfirmAction';
|
|
7
|
+
export { withDefaultModalActionProps, withModalAction } from './ModalAction';
|
|
8
|
+
export { default as ModalAction } from './ModalAction';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,EAAE,6BAA6B,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,yCAAyC;AACzC,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as useRefFunction } from './useRefFunction';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AntHelperContextProps } from '../components/ConfigProvider/context';
|
|
2
|
+
/**
|
|
3
|
+
* A custom hook that converts input content to localized text using the localize method from
|
|
4
|
+
* AntdHelperContext
|
|
5
|
+
*
|
|
6
|
+
* @param content - The content to be localized
|
|
7
|
+
*
|
|
8
|
+
* @returns The localized text
|
|
9
|
+
*/
|
|
10
|
+
declare const useLocalizedText: NonNullable<AntHelperContextProps['localize']>;
|
|
11
|
+
export default useLocalizedText;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import AntdHelperContext from '../components/ConfigProvider/context';
|
|
3
|
+
/**
|
|
4
|
+
* A custom hook that converts input content to localized text using the localize method from
|
|
5
|
+
* AntdHelperContext
|
|
6
|
+
*
|
|
7
|
+
* @param content - The content to be localized
|
|
8
|
+
*
|
|
9
|
+
* @returns The localized text
|
|
10
|
+
*/
|
|
11
|
+
const useLocalizedText = (content, args) => {
|
|
12
|
+
const { localize } = useContext(AntdHelperContext);
|
|
13
|
+
return localize ? localize(content, args) : content;
|
|
14
|
+
};
|
|
15
|
+
export default useLocalizedText;
|
|
16
|
+
//# sourceMappingURL=useLocalizedText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLocalizedText.js","sourceRoot":"","sources":["../../src/hooks/useLocalizedText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,iBAAiD,MAAM,sCAAsC,CAAC;AAErG;;;;;;;GAOG;AACH,MAAM,gBAAgB,GAAmD,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;IACzF,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACnD,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAE,OAAqB,CAAC;AACrE,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **EN:** Generate an immutable function reference, the dependencies inside the function will be
|
|
3
|
+
* updated in real time, but the function itself will not change, which is very useful when used as
|
|
4
|
+
* a dependency of `useEffect`.
|
|
5
|
+
*
|
|
6
|
+
* **CN:** 生成一个引用不可变的函数,函数内部的依赖项会保持实时更新,但函数本身不会变化,在作为 `useEffect` 的依赖时非常有用
|
|
7
|
+
*
|
|
8
|
+
* @param fn Function body | 函数体
|
|
9
|
+
*
|
|
10
|
+
* @returns An function with immutable reference | 引用不可变的函数
|
|
11
|
+
*/
|
|
12
|
+
declare const useRefFunction: <T extends (...args: any[]) => any>(fn: T | undefined) => T;
|
|
13
|
+
export default useRefFunction;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useCallback, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* **EN:** Generate an immutable function reference, the dependencies inside the function will be
|
|
4
|
+
* updated in real time, but the function itself will not change, which is very useful when used as
|
|
5
|
+
* a dependency of `useEffect`.
|
|
6
|
+
*
|
|
7
|
+
* **CN:** 生成一个引用不可变的函数,函数内部的依赖项会保持实时更新,但函数本身不会变化,在作为 `useEffect` 的依赖时非常有用
|
|
8
|
+
*
|
|
9
|
+
* @param fn Function body | 函数体
|
|
10
|
+
*
|
|
11
|
+
* @returns An function with immutable reference | 引用不可变的函数
|
|
12
|
+
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const useRefFunction = (fn) => {
|
|
15
|
+
const ref = useRef(fn);
|
|
16
|
+
ref.current = fn;
|
|
17
|
+
// eslint-disable-next-line eslint-comments/no-restricted-disable
|
|
18
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
|
+
return useCallback(((...args) => { var _a; return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.call(ref, ...args); }), []);
|
|
20
|
+
};
|
|
21
|
+
export default useRefFunction;
|
|
22
|
+
//# sourceMappingURL=useRefFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRefFunction.js","sourceRoot":"","sources":["../../src/hooks/useRefFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,8DAA8D;AAC9D,MAAM,cAAc,GAAG,CAAoC,EAAiB,EAAE,EAAE;IAC9E,MAAM,GAAG,GAAG,MAAM,CAAgB,EAAE,CAAC,CAAC;IACtC,GAAG,CAAC,OAAO,GAAG,EAAE,CAAC;IACjB,iEAAiE;IACjE,uDAAuD;IACvD,OAAO,WAAW,CAAC,CAAC,CAAC,GAAG,IAAW,EAAE,EAAE,WAAC,OAAA,MAAA,GAAG,CAAC,OAAO,oDAAG,GAAG,IAAI,CAAC,CAAA,EAAA,CAAM,EAAE,EAAE,CAAC,CAAC;AAC5E,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import AntHelperContext, { defaultContextValue } from '../components/ConfigProvider/context';
|
|
3
|
+
const useValidateContext = () => {
|
|
4
|
+
const context = useContext(AntHelperContext);
|
|
5
|
+
if (!context || context === defaultContextValue) {
|
|
6
|
+
console.warn(`ConfigProvider should be wrapped outside of any components of @tiny-codes/react-easy!
|
|
7
|
+
|
|
8
|
+
import { ConfigProvider } from '@tiny-codes/react-easy';
|
|
9
|
+
<ConfigProvider>
|
|
10
|
+
<App />
|
|
11
|
+
</ConfigProvider>`);
|
|
12
|
+
}
|
|
13
|
+
return context;
|
|
14
|
+
};
|
|
15
|
+
export default useValidateContext;
|
|
16
|
+
//# sourceMappingURL=useValidateContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useValidateContext.js","sourceRoot":"","sources":["../../src/hooks/useValidateContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,gBAAgB,EAAE,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE7F,MAAM,kBAAkB,GAAG,GAAG,EAAE;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,IAAI,OAAO,KAAK,mBAAmB,EAAE,CAAC;QAChD,OAAO,CAAC,IAAI,CACV;;;;;kBAKY,CACb,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tiny-codes/react-easy",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Helps you use React and AntDesign more easily",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"antd",
|
|
8
|
+
"ant-design",
|
|
9
|
+
"hoc",
|
|
10
|
+
"hooks"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/shijistar/react-easy#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/shijistar/react-easy/issues"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/shijistar/react-easy.git"
|
|
19
|
+
},
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"author": "李凤宝(Leo) <shijistar@gmail.com>",
|
|
22
|
+
"main": "lib/index.js",
|
|
23
|
+
"module": "es/index.js",
|
|
24
|
+
"types": "lib/index.d.ts",
|
|
25
|
+
"files": [
|
|
26
|
+
"lib",
|
|
27
|
+
"es",
|
|
28
|
+
"CHANGELOG.md"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"prepare": "husky",
|
|
32
|
+
"build:es": "tsc -p tsconfig.es.json",
|
|
33
|
+
"build": "run-p build:lib build:es",
|
|
34
|
+
"build:lib": "tsc -p tsconfig.lib.json",
|
|
35
|
+
"build:test": "tsc -p tsconfig.test.json",
|
|
36
|
+
"test": "#jest",
|
|
37
|
+
"prepublishOnly": "npm run test && npm run build"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@tiny-codes/code-style-all-in-one": "^1.0.0",
|
|
41
|
+
"@types/jest": "^29.5.14",
|
|
42
|
+
"@types/node": "^22.13.1",
|
|
43
|
+
"@types/react": "^19.0.8",
|
|
44
|
+
"@types/react-dom": "^19.0.3",
|
|
45
|
+
"@types/react-is": "^19.0.0",
|
|
46
|
+
"antd": "^5.23.4",
|
|
47
|
+
"father": "^4.5.2",
|
|
48
|
+
"jest": "^29.7.0",
|
|
49
|
+
"npm-run-all2": "^7.0.2",
|
|
50
|
+
"react": "^19.0.0",
|
|
51
|
+
"react-dom": "^19.0.0",
|
|
52
|
+
"react-is": "^19.0.0",
|
|
53
|
+
"ts-jest": "^29.2.5",
|
|
54
|
+
"typescript": "^5.7.3"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"antd": ">=5.1.0",
|
|
58
|
+
"react": ">=16.8.0",
|
|
59
|
+
"react-is": ">=16.8.0"
|
|
60
|
+
}
|
|
61
|
+
}
|