@tiny-codes/react-easy 1.4.20 → 1.4.22
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/es/components/ModalAction/index.d.ts +22 -10
- package/es/components/ModalAction/index.js +17 -5
- package/es/components/ModalAction/index.js.map +1 -1
- package/es/hooks/useMovable.js +36 -16
- package/es/hooks/useMovable.js.map +1 -1
- package/lib/components/ModalAction/index.d.ts +22 -10
- package/lib/components/ModalAction/index.js +16 -13
- package/lib/components/ModalAction/index.js.map +2 -2
- package/lib/hooks/useMovable.js +27 -13
- package/lib/hooks/useMovable.js.map +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
# Changelog
|
|
4
4
|
|
|
5
|
+
## 1.4.22
|
|
6
|
+
|
|
7
|
+
2025-11-10
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
#### `withModalAction`
|
|
12
|
+
|
|
13
|
+
- ✨ Add a second argument `ref` to the `defaultProps` function to access the internal ref of the `ModalAction` component.
|
|
14
|
+
|
|
15
|
+
## 1.4.21
|
|
16
|
+
|
|
17
|
+
2025-10-22
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
#### `useMovable`
|
|
22
|
+
|
|
23
|
+
- ✨ Improve position clamping on window resize, and make sure the movable element always stays within the viewport.
|
|
24
|
+
|
|
5
25
|
## 1.4.20
|
|
6
26
|
|
|
7
27
|
2025-10-17
|
|
@@ -124,14 +124,15 @@ export interface ModalActionTrigger<FormData extends object, P extends FormCompP
|
|
|
124
124
|
*/
|
|
125
125
|
children?: ReactNode;
|
|
126
126
|
}
|
|
127
|
-
export type ModalActionRef<R> = R & {
|
|
127
|
+
export type ModalActionRef<R = {}, FormData extends object = any> = R & {
|
|
128
|
+
form: FormInstance<FormData> | undefined;
|
|
128
129
|
/**
|
|
129
130
|
* - **EN:** Show the dialog
|
|
130
131
|
* - **CN:** 显示弹框
|
|
131
132
|
*/
|
|
132
133
|
show: () => void;
|
|
133
134
|
};
|
|
134
|
-
export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>, ref: ForwardedRef<ModalActionRef<Ref>>) => import("react/jsx-runtime").JSX.Element;
|
|
135
|
+
export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>, ref: ForwardedRef<ModalActionRef<Ref, FormData>>) => import("react/jsx-runtime").JSX.Element;
|
|
135
136
|
/**
|
|
136
137
|
* - **EN:** Add default properties to the ModalAction component
|
|
137
138
|
* - **CN:** 给ModalAction组件添加默认属性
|
|
@@ -139,7 +140,7 @@ export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionP
|
|
|
139
140
|
* @param WrappedComponent ModalAction component | ModalAction组件
|
|
140
141
|
* @param defaultProps Default properties | 默认属性
|
|
141
142
|
*/
|
|
142
|
-
export declare const withDefaultModalActionProps: <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(WrappedComponent: ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>>, defaultProps?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>> | ((actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>) | undefined) => import("react").ForwardRefExoticComponent<Omit<ModalProps, "onOk"> & ModalActionTrigger<FormData, P, TriggerProp, Event> & {
|
|
143
|
+
export declare const withDefaultModalActionProps: <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(WrappedComponent: ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>>, defaultProps?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>> | ((actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>, ref: ModalActionRef<Ref, FormData> | null) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>) | undefined) => import("react").ForwardRefExoticComponent<Omit<ModalProps, "onOk"> & ModalActionTrigger<FormData, P, TriggerProp, Event> & {
|
|
143
144
|
/**
|
|
144
145
|
* - **EN:** Form editing component, do not use the Form component inside the component, the form
|
|
145
146
|
* component and form instance are automatically created by the parent component
|
|
@@ -164,27 +165,27 @@ export declare const withDefaultModalActionProps: <FormData extends object, P ex
|
|
|
164
165
|
* - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
|
|
165
166
|
*/
|
|
166
167
|
afterOk?: ((data?: any) => void) | undefined;
|
|
167
|
-
} & RefAttributes<ModalActionRef<Ref>>>;
|
|
168
|
+
} & RefAttributes<ModalActionRef<Ref, FormData>>>;
|
|
168
169
|
/**
|
|
169
170
|
* - **EN:** ModalAction component type
|
|
170
171
|
* - **CN:** ModalAction组件的类型
|
|
171
172
|
*/
|
|
172
|
-
export type ModalActionInterface<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object> = ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>>;
|
|
173
|
+
export type ModalActionInterface<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object> = ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>>;
|
|
173
174
|
/**
|
|
174
175
|
* - **EN:** ModalAction component with generic type
|
|
175
176
|
* - **CN:** ModalAction泛型组件的类型
|
|
176
177
|
*/
|
|
177
|
-
export type GenericModalActionInterface = <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>) => ReactNode;
|
|
178
|
+
export type GenericModalActionInterface = <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>) => ReactNode;
|
|
178
179
|
/**
|
|
179
180
|
* - **EN:** ModalAction with specified trigger type (specified form component)
|
|
180
181
|
* - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)
|
|
181
182
|
*/
|
|
182
|
-
type ModalActionWithTrigger<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object, OMIT extends string = never> = ComponentType<Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref>>>;
|
|
183
|
+
type ModalActionWithTrigger<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object, OMIT extends string = never> = ComponentType<Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref, FormData>>>;
|
|
183
184
|
/**
|
|
184
185
|
* - **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)
|
|
185
186
|
* - **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)
|
|
186
187
|
*/
|
|
187
|
-
type GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object>(props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref>>) => ReactNode;
|
|
188
|
+
type GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object>(props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref, FormData>>) => ReactNode;
|
|
188
189
|
/**
|
|
189
190
|
* - **EN:** Built-in trigger types (specified form components)
|
|
190
191
|
* - **CN:** 内置的几种触发器类型(已指定表单组件)
|
|
@@ -227,7 +228,7 @@ interface GenericTypedTriggers<OMIT extends string = never> {
|
|
|
227
228
|
*/
|
|
228
229
|
Link: GenericModalActionWithTrigger<LinkProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;
|
|
229
230
|
}
|
|
230
|
-
type WithGenericTriggers<FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object, OMIT extends string = never> = (<TriggerProp extends object, Event extends keyof TriggerProp>(props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> & RefAttributes<ModalActionRef<Ref>>) => ReactNode) & (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);
|
|
231
|
+
type WithGenericTriggers<FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object, OMIT extends string = never> = (<TriggerProp extends object, Event extends keyof TriggerProp>(props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> & RefAttributes<ModalActionRef<Ref, FormData>>) => ReactNode) & (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);
|
|
231
232
|
/**
|
|
232
233
|
* - **EN:** Dialog component with trigger
|
|
233
234
|
* - **CN:** 带触发器的弹窗组件
|
|
@@ -258,6 +259,17 @@ export type ModalActionWithStatic = typeof ModalAction & {
|
|
|
258
259
|
* @param formComp Component of dialog content | 弹窗内容组件
|
|
259
260
|
* @param defaultProps Default properties of the dialog | 弹窗的默认属性
|
|
260
261
|
*/
|
|
261
|
-
export declare function withModalAction<FormData extends object, P extends FormCompPropsConstraint<FormData>, OuterTriggerProp extends object, OuterEvent extends keyof OuterTriggerProp, Ref extends object>(formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>, defaultProps?: Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>> | ((
|
|
262
|
+
export declare function withModalAction<FormData extends object, P extends FormCompPropsConstraint<FormData>, OuterTriggerProp extends object, OuterEvent extends keyof OuterTriggerProp, Ref extends object>(formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>, defaultProps?: Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>> | ((
|
|
263
|
+
/**
|
|
264
|
+
* - **EN:** Actual properties passed to the ModalAction component
|
|
265
|
+
* - **CN:** 实际传递给ModalAction组件的属性
|
|
266
|
+
*/
|
|
267
|
+
actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>,
|
|
268
|
+
/**
|
|
269
|
+
* - **EN:** Ref of the ModalAction component. Note that this ref may be null because the
|
|
270
|
+
* component has not been rendered yet when executed for the first time.
|
|
271
|
+
* - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。
|
|
272
|
+
*/
|
|
273
|
+
ref: ModalActionRef<Ref, FormData> | null) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)): WithGenericTriggers<FormData, P, Ref, "formComp">;
|
|
262
274
|
declare const _default: ModalActionWithStatic;
|
|
263
275
|
export default _default;
|
|
@@ -34,6 +34,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
34
34
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
35
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
36
36
|
export var SubmitWithoutClosingSymbol = Symbol('[SubmitWithoutClose]');
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any
|
|
39
|
+
|
|
37
40
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
41
|
export var genModalActionRenderer = function genModalActionRenderer(defaultProps) {
|
|
39
42
|
var ModalActionRenderer = function ModalActionRenderer(props, ref) {
|
|
@@ -152,9 +155,10 @@ export var genModalActionRenderer = function genModalActionRenderer(defaultProps
|
|
|
152
155
|
// Output ref
|
|
153
156
|
useImperativeHandle(ref, function () {
|
|
154
157
|
return _objectSpread(_objectSpread({}, formCompRef), {}, {
|
|
158
|
+
form: form,
|
|
155
159
|
show: showModal
|
|
156
160
|
});
|
|
157
|
-
}, [formCompRef, showModal]);
|
|
161
|
+
}, [formCompRef, showModal, form]);
|
|
158
162
|
|
|
159
163
|
// Render the trigger component
|
|
160
164
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -327,14 +331,18 @@ function FormCreator(props) {
|
|
|
327
331
|
*/
|
|
328
332
|
export var withDefaultModalActionProps = function withDefaultModalActionProps(WrappedComponent, defaultProps) {
|
|
329
333
|
var WithDefaultProps = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
334
|
+
var modalActionRef = useRef(null);
|
|
330
335
|
var useDefaultProps = typeof defaultProps === 'function' ? defaultProps : function () {
|
|
331
336
|
return defaultProps;
|
|
332
337
|
};
|
|
333
|
-
var defaults = useDefaultProps(props);
|
|
338
|
+
var defaults = useDefaultProps(props, modalActionRef.current);
|
|
334
339
|
var mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);
|
|
335
340
|
WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';
|
|
341
|
+
useImperativeHandle(ref, function () {
|
|
342
|
+
return modalActionRef.current;
|
|
343
|
+
}, []);
|
|
336
344
|
return /*#__PURE__*/_jsx(WrappedComponent, _objectSpread({
|
|
337
|
-
ref:
|
|
345
|
+
ref: modalActionRef
|
|
338
346
|
}, mergedProps));
|
|
339
347
|
});
|
|
340
348
|
return WithDefaultProps;
|
|
@@ -437,14 +445,18 @@ ModalAction.SubmitWithoutClosing = SubmitWithoutClosingSymbol;
|
|
|
437
445
|
export function withModalAction(formComp, defaultProps) {
|
|
438
446
|
var ForwardedModalAction = forwardedModalAction;
|
|
439
447
|
var WithDefaultProps = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
448
|
+
var modalActionRef = useRef(null);
|
|
440
449
|
var useDefaultProps = typeof defaultProps === 'function' ? defaultProps : function () {
|
|
441
450
|
return defaultProps;
|
|
442
451
|
};
|
|
443
|
-
var defaults = useDefaultProps(props);
|
|
452
|
+
var defaults = useDefaultProps(props, modalActionRef.current);
|
|
444
453
|
var mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);
|
|
445
454
|
WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';
|
|
455
|
+
useImperativeHandle(ref, function () {
|
|
456
|
+
return modalActionRef.current;
|
|
457
|
+
}, []);
|
|
446
458
|
return /*#__PURE__*/_jsx(ForwardedModalAction, _objectSpread({
|
|
447
|
-
ref:
|
|
459
|
+
ref: modalActionRef,
|
|
448
460
|
formComp: formComp
|
|
449
461
|
}, mergedProps));
|
|
450
462
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_regeneratorRuntime","e","t","r","Object","prototype","n","hasOwnProperty","o","defineProperty","value","i","Symbol","a","iterator","c","asyncIterator","u","toStringTag","define","enumerable","configurable","writable","wrap","Generator","create","Context","makeInvokeMethod","tryCatch","type","arg","call","h","l","f","s","y","GeneratorFunction","GeneratorFunctionPrototype","p","d","getPrototypeOf","v","values","g","defineIteratorMethods","forEach","_invoke","AsyncIterator","invoke","_typeof","resolve","__await","then","callInvokeWithMethodAndArg","Error","done","method","delegate","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","return","TypeError","resultName","next","nextLoc","pushTryEntry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","isNaN","length","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","keys","reverse","pop","prev","charAt","slice","stop","rval","handle","complete","finish","catch","_catch","delegateYield","_toConsumableArray","arr","_arrayWithoutHoles","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","iter","Array","from","isArray","_arrayLikeToArray","asyncGeneratorStep","gen","reject","_next","_throw","key","info","error","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","ownKeys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","_objectSpread","_defineProperty","getOwnPropertyDescriptors","defineProperties","obj","_toPropertyKey","_toPrimitive","String","toPrimitive","Number","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_nonIterableRest","minLen","toString","test","len","arr2","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","Button","Form","Modal","Switch","Typography","isForwardRef","useContextValidator","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","SubmitWithoutClosingSymbol","genModalActionRenderer","defaultProps","ModalActionRenderer","props","ref","_children","_useState","_useState2","userModalProps","setUserModalProps","mergedProps","mergeProps","_mergedProps","formComp","formProps","_mergedProps$triggerC","triggerComponent","Trigger","_mergedProps$triggerE","triggerEvent","triggerProps","openInProps","open","_mergedProps$destroyO","destroyOnClose","_mergedProps$destroyO2","destroyOnHidden","_mergedProps$maskClos","maskClosable","okButtonProps","cancelButtonProps","onOk","afterOk","onCancel","afterClose","children","restProps","_excluded","FormComp","triggerEventArgsRef","_useState3","_useState4","setOpen","saveFuncRef","_useState5","_useState6","isSaving","setIsSaving","_useState7","_useState8","formCompRef","setFormCompRef","_useState9","_useState10","form","setForm","formRef","current","destroyOnCloseRef","openListenerRef","resetFields","showInProps","show","showTrigger","showModal","_openListenerRef$curr","hideModal","_openListenerRef$curr2","setOpenListener","listener","_openListenerRef$curr3","setOnSaveHandler","handler","handleSetOpen","_openListenerRef$curr4","_len","_key","confirmLoading","loading","disabled","_callee","formData","_saveFuncRef$current","_triggerEventArgsRef$","result","_ref3","_triggerEventArgsRef$2","_callee$","_context","validateFields","t0","console","warn","concat","t1","_ref4","_callee2","_callee2$","_context2","_x","FormCreator","onCreate","onOpenChange","onSave","triggerEventData","updateModalProps","first","second","bodyProps","maskProps","wrapProps","style","onCreateRef","_Form$useForm","useForm","_Form$useForm2","withDefaultModalActionProps","WrappedComponent","WithDefaultProps","useDefaultProps","defaults","renderModalAction","forwardedModalAction","addTriggers","comp","patchedComp","Link","whiteSpace","ModalAction","SubmitWithoutClosing","withModalAction","ForwardedModalAction"],"sources":["../../../src/components/ModalAction/index.tsx"],"sourcesContent":["import type { ComponentType, FC, ForwardedRef, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport type { ButtonProps, FormInstance, ModalProps, SwitchProps } from 'antd';\nimport { Button, Form, Modal, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { isForwardRef } from 'react-is';\nimport useContextValidator from '../../hooks/useContextValidator';\n\n/**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\nexport const SubmitWithoutClosingSymbol = Symbol('[SubmitWithoutClose]');\n\nexport type ModalActionProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = Omit<ModalProps, 'onOk'> &\n ModalActionTrigger<FormData, P, TriggerProp, Event> & {\n /**\n * - **EN:** Form editing component, do not use the Form component inside the component, the form\n * component and form instance are automatically created by the parent component\n * - **CN:** 表单编辑组件,组件内部不要使用Form组件,表单组件及表单实例由父组件自动创建\n */\n formComp: ComponentType<P & RefAttributes<Ref>>;\n /**\n * - **EN:** Props of the form editing component\n * - **CN:** 表单编辑组件的Props属性\n */\n formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>;\n /**\n * - **EN:** The callback when clicks the confirmation button, support asynchronous saving, return\n * `SubmitWithoutClosingSymbol` can prevent the dialog from closing, return other values will\n * be passed to the `afterOk` event, if any\n * - **CN:** 点击确认按钮的回调,支持异步保存,返回`SubmitWithoutClosingSymbol`可以阻止弹框关闭,返回其他值会传递给`afterOk`事件,如果有的话\n */\n onOk?: (\n formData: FormData,\n // @ts-expect-error: because TP[E] should be a function type\n ...args: Parameters<TriggerProp[Event]>\n ) => unknown | Promise<unknown>;\n /**\n * - **EN:** The callback after the confirmation event is completed, it will not be triggered when\n * it fails, the parameter is the return value of `onOk`\n * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface FormCompPropsConstraint<FormData> {\n /**\n * - **EN:** Automatically generated form instance, use this form instance in FormComp, do not\n * create a new instance\n * - **CN:** 自动生成的表单实例,编辑表单要使用这个表单实例,不要新创建实例\n */\n form: FormInstance<FormData>;\n /**\n * - **EN:** Register the form save event, the callback function passed in will be called when the\n * confirm button is clicked, support asynchronous saving\n * - **CN:** 注册表单保存事件,传入的回调函数会在点击确认按钮时被调用,支持异步保存\n *\n * @param handler Event handler | 事件处理函数\n */\n onSave: (\n handler: (\n /**\n * - **EN:** Form data\n * - **CN:** 表单数据\n */\n formData: FormData,\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get\n * the value of the switch; for the `Button` type trigger, you can get the click event\n * object of the button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值;对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n ...triggerEventData: any[]\n ) => unknown | Promise<unknown>\n ) => void;\n /**\n * - **EN:** Listen to the open and close status of the dialog. When `destroyOnHidden` is set to\n * false, the form component instance is cached, and the dialog can only be listened to in this\n * way\n * - **CN:** 监听弹框打开关闭状态。当`destroyOnHidden`设置为false时,表单组件实例被缓存,只能通过这种方式监听弹框\n *\n * @param handler Event handler | 事件处理函数\n */\n onOpenChange: (handler: ModalProps['afterOpenChange']) => void;\n /**\n * - **EN:** Set the dialog open status\n * - **CN:** 设置弹框打开状态\n *\n * @param open Whether is open or not | 弹窗是否打开\n */\n setOpen: (open: boolean) => void;\n /**\n * - **EN:** Modify the properties of the dialog, such as title, width, button properties, etc.\n * - **CN:** 修改弹窗的属性,例如标题、宽度,按钮属性等\n */\n updateModalProps: (props: Partial<ModalProps>) => void;\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get the\n * value of the switch; for the `Button` type trigger, you can get the click event object of the\n * button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值,对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n triggerEventData?: any[];\n}\n\nexport interface ModalActionTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n> {\n /**\n * - **EN:** Trigger component, click to show the dialog\n * - **CN:** 弹窗触发器组件,点击触发显示弹框\n */\n triggerComponent?: ComponentType<TriggerProp> | FC<TriggerProp>;\n /**\n * - **EN:** Props of the trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TriggerProp & {\n /**\n * - **EN:** Set a custom function to determine whether to show the trigger button\n * - **CN:** 设置一个自定义函数,用于判断是否显示触发器按钮\n *\n * @default true\n *\n * @param formProps Form component props | 表单组件的props\n */\n show?: boolean | ((formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>) => boolean);\n };\n /**\n * - **EN:** The event name that triggers the dialog\n * - **CN:** 触发弹窗的事件名称\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: Event;\n /**\n * - **EN:** Custom trigger content\n * - **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\nexport type ModalActionRef<R> = R & {\n /**\n * - **EN:** Show the dialog\n * - **CN:** 显示弹框\n */\n show: () => void;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const genModalActionRenderer = (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => {\n const ModalActionRenderer = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n >(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n ref: ForwardedRef<ModalActionRef<Ref>>\n ) => {\n const [userModalProps, setUserModalProps] = useState<Partial<ModalProps>>({});\n let mergedProps = mergeProps<FormData, P, TriggerProp, Event, Ref>(defaultProps, props);\n mergedProps = mergeProps(mergedProps, userModalProps as typeof props);\n const {\n formComp,\n formProps,\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as Event,\n triggerProps,\n open: openInProps,\n destroyOnClose = true,\n destroyOnHidden = true,\n maskClosable = false,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n onCancel,\n afterClose,\n children,\n ...restProps\n } = mergedProps;\n useContextValidator();\n const FormComp = formComp as ComponentType<FormCompPropsConstraint<FormData> & RefAttributes<Ref>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n const [open, setOpen] = useState(false);\n const saveFuncRef = useRef<(formData: FormData, ...args: any[]) => unknown>(undefined);\n const [isSaving, setIsSaving] = useState(false);\n const [formCompRef, setFormCompRef] = useState<Ref | null>(null);\n const [form, setForm] = useState<FormInstance<FormData>>();\n const formRef = useRef<FormInstance<FormData>>(form);\n formRef.current = form;\n const destroyOnCloseRef = useRef(destroyOnClose);\n destroyOnCloseRef.current = destroyOnClose || destroyOnHidden;\n const openListenerRef = useRef<ModalProps['afterOpenChange']>(undefined);\n\n // Listen to the open props changes\n useEffect(() => {\n if (openInProps) {\n setOpen(openInProps);\n }\n }, [openInProps]);\n\n // Reset the form after closed\n useEffect(() => {\n if (!destroyOnCloseRef.current && open && formRef.current) {\n formRef.current.resetFields();\n }\n }, [open]);\n\n // show trigger\n const showInProps = triggerProps?.show;\n const showTrigger = useMemo(() => {\n if (typeof showInProps === 'boolean') {\n return showInProps;\n } else if (typeof showInProps === 'function') {\n return showInProps(formProps);\n }\n return true;\n }, [showInProps, formProps]);\n\n // Show the dialog\n const showModal = useCallback(() => {\n setOpen(true);\n openListenerRef.current?.(true);\n }, []);\n // Hide the dialog\n const hideModal = useCallback(() => {\n setOpen(false);\n openListenerRef.current?.(false);\n }, []);\n // Set the dialog status listener\n const setOpenListener = useCallback(\n (listener: ModalProps['afterOpenChange']) => {\n openListenerRef.current = listener;\n // Call once when initialized\n openListenerRef.current?.(open);\n },\n [open]\n );\n // Receive the onSave callback method passed by the form component\n const setOnSaveHandler: FormCompPropsConstraint<FormData>['onSave'] = useCallback((handler) => {\n saveFuncRef.current = handler;\n }, []);\n // Set the dialog status and trigger the onOpenChange event of the form component\n const handleSetOpen = useCallback((open: boolean) => {\n setOpen(open);\n openListenerRef.current?.(open);\n }, []);\n\n // Output ref\n useImperativeHandle(ref, () => ({ ...formCompRef, show: showModal }) as ModalActionRef<Ref>, [\n formCompRef,\n showModal,\n ]);\n\n // Render the trigger component\n return (\n <>\n {showTrigger && (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n showModal();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args);\n }\n },\n }\n : {}) as TriggerProp)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n )}\n <Modal\n open={open}\n confirmLoading={isSaving}\n destroyOnClose={destroyOnClose}\n destroyOnHidden={destroyOnHidden}\n maskClosable={maskClosable}\n okButtonProps={{\n loading: isSaving,\n ...okButtonProps,\n }}\n cancelButtonProps={{\n disabled: isSaving,\n ...cancelButtonProps,\n }}\n onOk={async () => {\n let formData: FormData;\n try {\n formData = (await form?.validateFields()) as FormData;\n } catch (e) {\n // Validation error, should not throw error\n return;\n }\n if (Object.keys(formData).length === 0) {\n console.warn(\n 'form.getFieldsValue() is empty. Please use the form instance passed to formComp instead of creating the form instance yourself.'\n );\n }\n try {\n setIsSaving(true);\n // First call onSave of the form component\n let result = await saveFuncRef.current?.(formData, ...(triggerEventArgsRef.current ?? []));\n // The onSave of the form component has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // Then call onOk of the dialog, support asynchronous, and will pass the return value of onSave, if any\n if (onOk) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result = await onOk((result as FormData) ?? formData, ...((triggerEventArgsRef.current ?? []) as any));\n }\n // onOk also has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // If onOK is successful, close the dialog and trigger the afterOk event\n hideModal();\n afterOk?.(result);\n } catch (error) {\n console.error(error);\n } finally {\n setIsSaving(false);\n }\n }}\n onCancel={async (e) => {\n hideModal();\n onCancel?.(e);\n }}\n afterClose={() => {\n hideModal();\n afterClose?.();\n }}\n {...restProps}\n >\n <FormCreator<FormData> onCreate={setForm} />\n {form && (\n <FormComp\n ref={isForwardRef(FormComp) ? setFormCompRef : undefined}\n {...formProps}\n form={form}\n onOpenChange={setOpenListener}\n onSave={setOnSaveHandler}\n triggerEventData={triggerEventArgsRef.current}\n setOpen={handleSetOpen}\n updateModalProps={setUserModalProps}\n />\n )}\n </Modal>\n </>\n );\n };\n return ModalActionRenderer;\n};\n\nfunction mergeProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n first?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>,\n second?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n) {\n return {\n ...first,\n ...second,\n okButtonProps: {\n ...first?.okButtonProps,\n ...second?.okButtonProps,\n },\n cancelButtonProps: {\n ...first?.cancelButtonProps,\n ...second?.cancelButtonProps,\n },\n bodyProps: {\n ...first?.bodyProps,\n ...second?.bodyProps,\n },\n maskProps: {\n ...first?.maskProps,\n ...second?.maskProps,\n },\n wrapProps: {\n ...first?.wrapProps,\n ...second?.wrapProps,\n },\n formProps: {\n ...first?.formProps,\n ...second?.formProps,\n },\n triggerProps: {\n ...first?.triggerProps,\n ...second?.triggerProps,\n style: {\n ...(first?.triggerProps && 'style' in first.triggerProps && typeof first.triggerProps.style === 'object'\n ? first.triggerProps.style\n : {}),\n ...(second?.triggerProps && 'style' in second.triggerProps && typeof second.triggerProps.style === 'object'\n ? second.triggerProps.style\n : {}),\n },\n },\n } as unknown as ModalActionProps<FormData, P, TriggerProp, Event, Ref>;\n}\n\nfunction FormCreator<FD extends object>(props: { onCreate: (form: FormInstance<FD> | undefined) => void }) {\n const { onCreate } = props;\n const onCreateRef = useRef(onCreate);\n onCreateRef.current = onCreate;\n const [form] = Form.useForm<FD>();\n\n // output ref\n useEffect(() => {\n onCreateRef.current(form);\n return () => {\n onCreateRef.current(undefined);\n };\n }, [form]);\n\n return null;\n}\n\n/**\n * - **EN:** Add default properties to the ModalAction component\n * - **CN:** 给ModalAction组件添加默认属性\n *\n * @param WrappedComponent ModalAction component | ModalAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultModalActionProps = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n WrappedComponent: ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>\n >,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n | ((\n actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>\n ) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>)\n) => {\n const WithDefaultProps = forwardRef<ModalActionRef<Ref>, ModalActionProps<FormData, P, TriggerProp, Event, Ref>>(\n (props, ref) => {\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props);\n const mergedProps =\n typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n return <WrappedComponent ref={ref} {...mergedProps} />;\n }\n );\n return WithDefaultProps;\n};\n\nconst renderModalAction = genModalActionRenderer({});\nconst forwardedModalAction = forwardRef(renderModalAction);\nforwardedModalAction.displayName = 'ForwardRef(ModalAction)';\n/**\n * - **EN:** ModalAction component type\n * - **CN:** ModalAction组件的类型\n */\nexport type ModalActionInterface<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>>;\n/**\n * - **EN:** ModalAction component with generic type\n * - **CN:** ModalAction泛型组件的类型\n */\nexport type GenericModalActionInterface = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>\n) => ReactNode;\n/**\n * - **EN:** ModalAction with specified trigger type (specified form component)\n * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)\n */\ntype ModalActionWithTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n OMIT extends string = never,\n> = ComponentType<\n Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref>>\n>;\n\n/**\n * - **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)\n * - **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)\n */\ntype GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n>(\n props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref>>\n) => ReactNode;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\nexport interface TypedTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: ModalActionWithTrigger<FormData, P, ButtonProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: ModalActionWithTrigger<FormData, P, SwitchProps, 'onChange', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: ModalActionWithTrigger<FormData, P, LinkProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\n/**\n * - **EN:** Built-in trigger types (generic types, unspecified form components)\n * - **CN:** 内置的几种触发器类型(泛型类型,未指定表单组件)\n */\ninterface GenericTypedTriggers<OMIT extends string = never> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: GenericModalActionWithTrigger<ButtonProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: GenericModalActionWithTrigger<SwitchProps, 'onChange', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: GenericModalActionWithTrigger<LinkProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\ntype WithGenericTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> = (<TriggerProp extends object, Event extends keyof TriggerProp>(\n props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> & RefAttributes<ModalActionRef<Ref>>\n) => ReactNode) &\n (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);\n\n/**\n * - **EN:** Add trigger types to the ModalAction component\n * - **CN:** 给ModalAction组件添加子触发器类型\n */\nconst addTriggers = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n OMIT extends string = never,\n>(\n comp: ComponentType<\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref> & RefAttributes<ModalActionRef<Ref>>\n >\n) => {\n const patchedComp = comp as WithGenericTriggers<FormData, P, Ref, OMIT>;\n // Type of button trigger\n patchedComp.Button = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, ButtonProps, 'onClick', Ref>,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of switch trigger\n patchedComp.Switch = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, SwitchProps, 'onChange', Ref>,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of link trigger\n patchedComp.Link = withDefaultModalActionProps(comp as ModalActionInterface<FormData, P, LinkProps, 'onClick', Ref>, {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n return patchedComp;\n};\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nconst ModalAction = addTriggers(forwardedModalAction);\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nexport type ModalActionWithStatic = typeof ModalAction & {\n /**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\n SubmitWithoutClosing: symbol;\n};\n(ModalAction as ModalActionWithStatic).SubmitWithoutClosing = SubmitWithoutClosingSymbol;\n\n/**\n * - **EN:** Generate a dialog component based on the editing form component\n * - **CN:** 基于编辑表单组件生成一个弹框组件\n *\n * @template FormData Form data type | 表单数据类型\n * @template P Form component props type | 表单组件的props类型\n * @template OuterTriggerProp Outer trigger props type | 外部触发器的props类型\n * @template OuterEvent Outer trigger event type | 外部触发器的事件类型\n * @template Ref Form component ref type | 表单组件的ref类型\n *\n * @param formComp Component of dialog content | 弹窗内容组件\n * @param defaultProps Default properties of the dialog | 弹窗的默认属性\n */\nexport function withModalAction<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>\n | ((\n actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>\n ) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)\n) {\n const ForwardedModalAction = forwardedModalAction as unknown as ModalActionInterface<\n FormData,\n P,\n OuterTriggerProp,\n OuterEvent,\n Ref\n >;\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref>,\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>\n >((props, ref) => {\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props);\n const mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n return (\n <ForwardedModalAction\n ref={ref}\n formComp={formComp}\n {...(mergedProps as Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)}\n />\n );\n });\n return addTriggers<FormData, P, OuterTriggerProp, OuterEvent, Ref, 'formComp'>(WithDefaultProps);\n}\n\nexport default ModalAction as ModalActionWithStatic;\n"],"mappings":";;+CACA,qJAAAA,mBAAA,YAAAA,oBAAA,WAAAC,CAAA,SAAAC,CAAA,EAAAD,CAAA,OAAAE,CAAA,GAAAC,MAAA,CAAAC,SAAA,EAAAC,CAAA,GAAAH,CAAA,CAAAI,cAAA,EAAAC,CAAA,GAAAJ,MAAA,CAAAK,cAAA,cAAAP,CAAA,EAAAD,CAAA,EAAAE,CAAA,IAAAD,CAAA,CAAAD,CAAA,IAAAE,CAAA,CAAAO,KAAA,KAAAC,CAAA,wBAAAC,MAAA,GAAAA,MAAA,OAAAC,CAAA,GAAAF,CAAA,CAAAG,QAAA,kBAAAC,CAAA,GAAAJ,CAAA,CAAAK,aAAA,uBAAAC,CAAA,GAAAN,CAAA,CAAAO,WAAA,8BAAAC,OAAAjB,CAAA,EAAAD,CAAA,EAAAE,CAAA,WAAAC,MAAA,CAAAK,cAAA,CAAAP,CAAA,EAAAD,CAAA,IAAAS,KAAA,EAAAP,CAAA,EAAAiB,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AAeA,CAO7BrH,QAAmF,EACnFZ,YAImF,EACnF;EACA,IAAMkI,oBAAoB,GAAGT,oBAM5B;EACD,IAAMJ,gBAAgB,gBAAG3I,UAAU,CAGjC,UAACwB,KAAK,EAAEC,GAAG,EAAK;IAChB,IAAMmH,eAAe,GAAG,OAAOtH,YAAY,KAAK,UAAU,GAAGA,YAAY,GAAG;MAAA,OAAMA,YAAY;IAAA;IAC9F,IAAMuH,QAAQ,GAAGD,eAAe,CAACpH,KAAK,CAAC;IACvC,IAAMO,WAAW,GAAG,OAAOT,YAAY,KAAK,UAAU,GAAGU,UAAU,CAACR,KAAK,EAAEqH,QAAQ,CAAC,GAAG7G,UAAU,CAAC6G,QAAQ,EAAErH,KAAK,CAAC;IAClHmH,gBAAgB,CAAC9N,WAAW,GAAG,8BAA8B;IAC7D,oBACEkG,IAAA,CAACyI,oBAAoB,EAAApL,aAAA;MACnBqD,GAAG,EAAEA,GAAI;MACTS,QAAQ,EAAEA;IAAS,GACdH,WAAW,CACjB,CAAC;EAEN,CAAC,CAAC;EACF,OAAOiH,WAAW,CAA6DL,gBAAgB,CAAC;AAClG;AAEA,eAAeU,WAAW"}
|
|
1
|
+
{"version":3,"names":["_regeneratorRuntime","e","t","r","Object","prototype","n","hasOwnProperty","o","defineProperty","value","i","Symbol","a","iterator","c","asyncIterator","u","toStringTag","define","enumerable","configurable","writable","wrap","Generator","create","Context","makeInvokeMethod","tryCatch","type","arg","call","h","l","f","s","y","GeneratorFunction","GeneratorFunctionPrototype","p","d","getPrototypeOf","v","values","g","defineIteratorMethods","forEach","_invoke","AsyncIterator","invoke","_typeof","resolve","__await","then","callInvokeWithMethodAndArg","Error","done","method","delegate","maybeInvokeDelegate","sent","_sent","dispatchException","abrupt","return","TypeError","resultName","next","nextLoc","pushTryEntry","tryLoc","catchLoc","finallyLoc","afterLoc","tryEntries","push","resetTryEntry","completion","reset","isNaN","length","displayName","isGeneratorFunction","constructor","name","mark","setPrototypeOf","__proto__","awrap","async","Promise","keys","reverse","pop","prev","charAt","slice","stop","rval","handle","complete","finish","catch","_catch","delegateYield","_toConsumableArray","arr","_arrayWithoutHoles","_iterableToArray","_unsupportedIterableToArray","_nonIterableSpread","iter","Array","from","isArray","_arrayLikeToArray","asyncGeneratorStep","gen","reject","_next","_throw","key","info","error","_asyncToGenerator","fn","self","args","arguments","apply","err","undefined","ownKeys","getOwnPropertySymbols","filter","getOwnPropertyDescriptor","_objectSpread","_defineProperty","getOwnPropertyDescriptors","defineProperties","obj","_toPropertyKey","_toPrimitive","String","toPrimitive","Number","_objectWithoutProperties","source","excluded","target","_objectWithoutPropertiesLoose","sourceSymbolKeys","indexOf","propertyIsEnumerable","sourceKeys","_slicedToArray","_arrayWithHoles","_iterableToArrayLimit","_nonIterableRest","minLen","toString","test","len","arr2","forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","useState","Button","Form","Modal","Switch","Typography","isForwardRef","useContextValidator","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","SubmitWithoutClosingSymbol","genModalActionRenderer","defaultProps","ModalActionRenderer","props","ref","_children","_useState","_useState2","userModalProps","setUserModalProps","mergedProps","mergeProps","_mergedProps","formComp","formProps","_mergedProps$triggerC","triggerComponent","Trigger","_mergedProps$triggerE","triggerEvent","triggerProps","openInProps","open","_mergedProps$destroyO","destroyOnClose","_mergedProps$destroyO2","destroyOnHidden","_mergedProps$maskClos","maskClosable","okButtonProps","cancelButtonProps","onOk","afterOk","onCancel","afterClose","children","restProps","_excluded","FormComp","triggerEventArgsRef","_useState3","_useState4","setOpen","saveFuncRef","_useState5","_useState6","isSaving","setIsSaving","_useState7","_useState8","formCompRef","setFormCompRef","_useState9","_useState10","form","setForm","formRef","current","destroyOnCloseRef","openListenerRef","resetFields","showInProps","show","showTrigger","showModal","_openListenerRef$curr","hideModal","_openListenerRef$curr2","setOpenListener","listener","_openListenerRef$curr3","setOnSaveHandler","handler","handleSetOpen","_openListenerRef$curr4","_len","_key","confirmLoading","loading","disabled","_callee","formData","_saveFuncRef$current","_triggerEventArgsRef$","result","_ref3","_triggerEventArgsRef$2","_callee$","_context","validateFields","t0","console","warn","concat","t1","_ref4","_callee2","_callee2$","_context2","_x","FormCreator","onCreate","onOpenChange","onSave","triggerEventData","updateModalProps","first","second","bodyProps","maskProps","wrapProps","style","onCreateRef","_Form$useForm","useForm","_Form$useForm2","withDefaultModalActionProps","WrappedComponent","WithDefaultProps","modalActionRef","useDefaultProps","defaults","renderModalAction","forwardedModalAction","addTriggers","comp","patchedComp","Link","whiteSpace","ModalAction","SubmitWithoutClosing","withModalAction","ForwardedModalAction"],"sources":["../../../src/components/ModalAction/index.tsx"],"sourcesContent":["import type { ComponentType, FC, ForwardedRef, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport type { ButtonProps, FormInstance, ModalProps, SwitchProps } from 'antd';\nimport { Button, Form, Modal, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { isForwardRef } from 'react-is';\nimport useContextValidator from '../../hooks/useContextValidator';\n\n/**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\nexport const SubmitWithoutClosingSymbol = Symbol('[SubmitWithoutClose]');\n\nexport type ModalActionProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = Omit<ModalProps, 'onOk'> &\n ModalActionTrigger<FormData, P, TriggerProp, Event> & {\n /**\n * - **EN:** Form editing component, do not use the Form component inside the component, the form\n * component and form instance are automatically created by the parent component\n * - **CN:** 表单编辑组件,组件内部不要使用Form组件,表单组件及表单实例由父组件自动创建\n */\n formComp: ComponentType<P & RefAttributes<Ref>>;\n /**\n * - **EN:** Props of the form editing component\n * - **CN:** 表单编辑组件的Props属性\n */\n formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>;\n /**\n * - **EN:** The callback when clicks the confirmation button, support asynchronous saving, return\n * `SubmitWithoutClosingSymbol` can prevent the dialog from closing, return other values will\n * be passed to the `afterOk` event, if any\n * - **CN:** 点击确认按钮的回调,支持异步保存,返回`SubmitWithoutClosingSymbol`可以阻止弹框关闭,返回其他值会传递给`afterOk`事件,如果有的话\n */\n onOk?: (\n formData: FormData,\n // @ts-expect-error: because TP[E] should be a function type\n ...args: Parameters<TriggerProp[Event]>\n ) => unknown | Promise<unknown>;\n /**\n * - **EN:** The callback after the confirmation event is completed, it will not be triggered when\n * it fails, the parameter is the return value of `onOk`\n * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface FormCompPropsConstraint<FormData> {\n /**\n * - **EN:** Automatically generated form instance, use this form instance in FormComp, do not\n * create a new instance\n * - **CN:** 自动生成的表单实例,编辑表单要使用这个表单实例,不要新创建实例\n */\n form: FormInstance<FormData>;\n /**\n * - **EN:** Register the form save event, the callback function passed in will be called when the\n * confirm button is clicked, support asynchronous saving\n * - **CN:** 注册表单保存事件,传入的回调函数会在点击确认按钮时被调用,支持异步保存\n *\n * @param handler Event handler | 事件处理函数\n */\n onSave: (\n handler: (\n /**\n * - **EN:** Form data\n * - **CN:** 表单数据\n */\n formData: FormData,\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get\n * the value of the switch; for the `Button` type trigger, you can get the click event\n * object of the button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值;对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n ...triggerEventData: any[]\n ) => unknown | Promise<unknown>\n ) => void;\n /**\n * - **EN:** Listen to the open and close status of the dialog. When `destroyOnHidden` is set to\n * false, the form component instance is cached, and the dialog can only be listened to in this\n * way\n * - **CN:** 监听弹框打开关闭状态。当`destroyOnHidden`设置为false时,表单组件实例被缓存,只能通过这种方式监听弹框\n *\n * @param handler Event handler | 事件处理函数\n */\n onOpenChange: (handler: ModalProps['afterOpenChange']) => void;\n /**\n * - **EN:** Set the dialog open status\n * - **CN:** 设置弹框打开状态\n *\n * @param open Whether is open or not | 弹窗是否打开\n */\n setOpen: (open: boolean) => void;\n /**\n * - **EN:** Modify the properties of the dialog, such as title, width, button properties, etc.\n * - **CN:** 修改弹窗的属性,例如标题、宽度,按钮属性等\n */\n updateModalProps: (props: Partial<ModalProps>) => void;\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get the\n * value of the switch; for the `Button` type trigger, you can get the click event object of the\n * button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值,对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n triggerEventData?: any[];\n}\n\nexport interface ModalActionTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n> {\n /**\n * - **EN:** Trigger component, click to show the dialog\n * - **CN:** 弹窗触发器组件,点击触发显示弹框\n */\n triggerComponent?: ComponentType<TriggerProp> | FC<TriggerProp>;\n /**\n * - **EN:** Props of the trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TriggerProp & {\n /**\n * - **EN:** Set a custom function to determine whether to show the trigger button\n * - **CN:** 设置一个自定义函数,用于判断是否显示触发器按钮\n *\n * @default true\n *\n * @param formProps Form component props | 表单组件的props\n */\n show?: boolean | ((formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>) => boolean);\n };\n /**\n * - **EN:** The event name that triggers the dialog\n * - **CN:** 触发弹窗的事件名称\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: Event;\n /**\n * - **EN:** Custom trigger content\n * - **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\n// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any\nexport type ModalActionRef<R = {}, FormData extends object = any> = R & {\n form: FormInstance<FormData> | undefined;\n /**\n * - **EN:** Show the dialog\n * - **CN:** 显示弹框\n */\n show: () => void;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const genModalActionRenderer = (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => {\n const ModalActionRenderer = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n >(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n ref: ForwardedRef<ModalActionRef<Ref, FormData>>\n ) => {\n const [userModalProps, setUserModalProps] = useState<Partial<ModalProps>>({});\n let mergedProps = mergeProps<FormData, P, TriggerProp, Event, Ref>(defaultProps, props);\n mergedProps = mergeProps(mergedProps, userModalProps as typeof props);\n const {\n formComp,\n formProps,\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as Event,\n triggerProps,\n open: openInProps,\n destroyOnClose = true,\n destroyOnHidden = true,\n maskClosable = false,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n onCancel,\n afterClose,\n children,\n ...restProps\n } = mergedProps;\n useContextValidator();\n const FormComp = formComp as ComponentType<FormCompPropsConstraint<FormData> & RefAttributes<Ref>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n const [open, setOpen] = useState(false);\n const saveFuncRef = useRef<(formData: FormData, ...args: any[]) => unknown>(undefined);\n const [isSaving, setIsSaving] = useState(false);\n const [formCompRef, setFormCompRef] = useState<Ref | null>(null);\n const [form, setForm] = useState<FormInstance<FormData>>();\n const formRef = useRef<FormInstance<FormData>>(form);\n formRef.current = form;\n const destroyOnCloseRef = useRef(destroyOnClose);\n destroyOnCloseRef.current = destroyOnClose || destroyOnHidden;\n const openListenerRef = useRef<ModalProps['afterOpenChange']>(undefined);\n\n // Listen to the open props changes\n useEffect(() => {\n if (openInProps) {\n setOpen(openInProps);\n }\n }, [openInProps]);\n\n // Reset the form after closed\n useEffect(() => {\n if (!destroyOnCloseRef.current && open && formRef.current) {\n formRef.current.resetFields();\n }\n }, [open]);\n\n // show trigger\n const showInProps = triggerProps?.show;\n const showTrigger = useMemo(() => {\n if (typeof showInProps === 'boolean') {\n return showInProps;\n } else if (typeof showInProps === 'function') {\n return showInProps(formProps);\n }\n return true;\n }, [showInProps, formProps]);\n\n // Show the dialog\n const showModal = useCallback(() => {\n setOpen(true);\n openListenerRef.current?.(true);\n }, []);\n // Hide the dialog\n const hideModal = useCallback(() => {\n setOpen(false);\n openListenerRef.current?.(false);\n }, []);\n // Set the dialog status listener\n const setOpenListener = useCallback(\n (listener: ModalProps['afterOpenChange']) => {\n openListenerRef.current = listener;\n // Call once when initialized\n openListenerRef.current?.(open);\n },\n [open]\n );\n // Receive the onSave callback method passed by the form component\n const setOnSaveHandler: FormCompPropsConstraint<FormData>['onSave'] = useCallback((handler) => {\n saveFuncRef.current = handler;\n }, []);\n // Set the dialog status and trigger the onOpenChange event of the form component\n const handleSetOpen = useCallback((open: boolean) => {\n setOpen(open);\n openListenerRef.current?.(open);\n }, []);\n\n // Output ref\n useImperativeHandle(ref, () => ({ ...formCompRef, form, show: showModal }) as ModalActionRef<Ref, FormData>, [\n formCompRef,\n showModal,\n form,\n ]);\n\n // Render the trigger component\n return (\n <>\n {showTrigger && (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n showModal();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args);\n }\n },\n }\n : {}) as TriggerProp)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n )}\n <Modal\n open={open}\n confirmLoading={isSaving}\n destroyOnClose={destroyOnClose}\n destroyOnHidden={destroyOnHidden}\n maskClosable={maskClosable}\n okButtonProps={{\n loading: isSaving,\n ...okButtonProps,\n }}\n cancelButtonProps={{\n disabled: isSaving,\n ...cancelButtonProps,\n }}\n onOk={async () => {\n let formData: FormData;\n try {\n formData = (await form?.validateFields()) as FormData;\n } catch (e) {\n // Validation error, should not throw error\n return;\n }\n if (Object.keys(formData).length === 0) {\n console.warn(\n 'form.getFieldsValue() is empty. Please use the form instance passed to formComp instead of creating the form instance yourself.'\n );\n }\n try {\n setIsSaving(true);\n // First call onSave of the form component\n let result = await saveFuncRef.current?.(formData, ...(triggerEventArgsRef.current ?? []));\n // The onSave of the form component has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // Then call onOk of the dialog, support asynchronous, and will pass the return value of onSave, if any\n if (onOk) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result = await onOk((result as FormData) ?? formData, ...((triggerEventArgsRef.current ?? []) as any));\n }\n // onOk also has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // If onOK is successful, close the dialog and trigger the afterOk event\n hideModal();\n afterOk?.(result);\n } catch (error) {\n console.error(error);\n } finally {\n setIsSaving(false);\n }\n }}\n onCancel={async (e) => {\n hideModal();\n onCancel?.(e);\n }}\n afterClose={() => {\n hideModal();\n afterClose?.();\n }}\n {...restProps}\n >\n <FormCreator<FormData> onCreate={setForm} />\n {form && (\n <FormComp\n ref={isForwardRef(FormComp) ? setFormCompRef : undefined}\n {...formProps}\n form={form}\n onOpenChange={setOpenListener}\n onSave={setOnSaveHandler}\n triggerEventData={triggerEventArgsRef.current}\n setOpen={handleSetOpen}\n updateModalProps={setUserModalProps}\n />\n )}\n </Modal>\n </>\n );\n };\n return ModalActionRenderer;\n};\n\nfunction mergeProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n first?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>,\n second?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n) {\n return {\n ...first,\n ...second,\n okButtonProps: {\n ...first?.okButtonProps,\n ...second?.okButtonProps,\n },\n cancelButtonProps: {\n ...first?.cancelButtonProps,\n ...second?.cancelButtonProps,\n },\n bodyProps: {\n ...first?.bodyProps,\n ...second?.bodyProps,\n },\n maskProps: {\n ...first?.maskProps,\n ...second?.maskProps,\n },\n wrapProps: {\n ...first?.wrapProps,\n ...second?.wrapProps,\n },\n formProps: {\n ...first?.formProps,\n ...second?.formProps,\n },\n triggerProps: {\n ...first?.triggerProps,\n ...second?.triggerProps,\n style: {\n ...(first?.triggerProps && 'style' in first.triggerProps && typeof first.triggerProps.style === 'object'\n ? first.triggerProps.style\n : {}),\n ...(second?.triggerProps && 'style' in second.triggerProps && typeof second.triggerProps.style === 'object'\n ? second.triggerProps.style\n : {}),\n },\n },\n } as unknown as ModalActionProps<FormData, P, TriggerProp, Event, Ref>;\n}\n\nfunction FormCreator<FD extends object>(props: { onCreate: (form: FormInstance<FD> | undefined) => void }) {\n const { onCreate } = props;\n const onCreateRef = useRef(onCreate);\n onCreateRef.current = onCreate;\n const [form] = Form.useForm<FD>();\n\n // output ref\n useEffect(() => {\n onCreateRef.current(form);\n return () => {\n onCreateRef.current(undefined);\n };\n }, [form]);\n\n return null;\n}\n\n/**\n * - **EN:** Add default properties to the ModalAction component\n * - **CN:** 给ModalAction组件添加默认属性\n *\n * @param WrappedComponent ModalAction component | ModalAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultModalActionProps = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n WrappedComponent: ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n >,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n | ((\n /**\n * - **EN:** Actual properties passed to the ModalAction component\n * - **CN:** 实际传递给ModalAction组件的属性\n */\n actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n /**\n * - **EN:** Ref of the ModalAction component. Note that this ref may be null because the\n * component has not been rendered yet when executed for the first time.\n * - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。\n */\n ref: ModalActionRef<Ref, FormData> | null\n ) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>)\n) => {\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref, FormData>,\n ModalActionProps<FormData, P, TriggerProp, Event, Ref>\n >((props, ref) => {\n const modalActionRef = useRef<ModalActionRef<Ref, FormData>>(null);\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props, modalActionRef.current);\n const mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n\n useImperativeHandle(ref, () => modalActionRef.current as ModalActionRef<Ref, FormData>, []);\n\n return <WrappedComponent ref={modalActionRef} {...mergedProps} />;\n });\n return WithDefaultProps;\n};\n\nconst renderModalAction = genModalActionRenderer({});\nconst forwardedModalAction = forwardRef(renderModalAction);\nforwardedModalAction.displayName = 'ForwardRef(ModalAction)';\n/**\n * - **EN:** ModalAction component type\n * - **CN:** ModalAction组件的类型\n */\nexport type ModalActionInterface<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n>;\n/**\n * - **EN:** ModalAction component with generic type\n * - **CN:** ModalAction泛型组件的类型\n */\nexport type GenericModalActionInterface = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode;\n/**\n * - **EN:** ModalAction with specified trigger type (specified form component)\n * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)\n */\ntype ModalActionWithTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n OMIT extends string = never,\n> = ComponentType<\n Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n>;\n\n/**\n * - **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)\n * - **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)\n */\ntype GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n>(\n props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\nexport interface TypedTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: ModalActionWithTrigger<FormData, P, ButtonProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: ModalActionWithTrigger<FormData, P, SwitchProps, 'onChange', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: ModalActionWithTrigger<FormData, P, LinkProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\n/**\n * - **EN:** Built-in trigger types (generic types, unspecified form components)\n * - **CN:** 内置的几种触发器类型(泛型类型,未指定表单组件)\n */\ninterface GenericTypedTriggers<OMIT extends string = never> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: GenericModalActionWithTrigger<ButtonProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: GenericModalActionWithTrigger<SwitchProps, 'onChange', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: GenericModalActionWithTrigger<LinkProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\ntype WithGenericTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> = (<TriggerProp extends object, Event extends keyof TriggerProp>(\n props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode) &\n (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);\n\n/**\n * - **EN:** Add trigger types to the ModalAction component\n * - **CN:** 给ModalAction组件添加子触发器类型\n */\nconst addTriggers = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n OMIT extends string = never,\n>(\n comp: ComponentType<\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n >\n) => {\n const patchedComp = comp as WithGenericTriggers<FormData, P, Ref, OMIT>;\n // Type of button trigger\n patchedComp.Button = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, ButtonProps, 'onClick', Ref>,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of switch trigger\n patchedComp.Switch = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, SwitchProps, 'onChange', Ref>,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of link trigger\n patchedComp.Link = withDefaultModalActionProps(comp as ModalActionInterface<FormData, P, LinkProps, 'onClick', Ref>, {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n return patchedComp;\n};\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nconst ModalAction = addTriggers(forwardedModalAction);\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nexport type ModalActionWithStatic = typeof ModalAction & {\n /**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\n SubmitWithoutClosing: symbol;\n};\n(ModalAction as ModalActionWithStatic).SubmitWithoutClosing = SubmitWithoutClosingSymbol;\n\n/**\n * - **EN:** Generate a dialog component based on the editing form component\n * - **CN:** 基于编辑表单组件生成一个弹框组件\n *\n * @template FormData Form data type | 表单数据类型\n * @template P Form component props type | 表单组件的props类型\n * @template OuterTriggerProp Outer trigger props type | 外部触发器的props类型\n * @template OuterEvent Outer trigger event type | 外部触发器的事件类型\n * @template Ref Form component ref type | 表单组件的ref类型\n *\n * @param formComp Component of dialog content | 弹窗内容组件\n * @param defaultProps Default properties of the dialog | 弹窗的默认属性\n */\nexport function withModalAction<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>\n | ((\n /**\n * - **EN:** Actual properties passed to the ModalAction component\n * - **CN:** 实际传递给ModalAction组件的属性\n */\n actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>,\n /**\n * - **EN:** Ref of the ModalAction component. Note that this ref may be null because the\n * component has not been rendered yet when executed for the first time.\n * - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。\n */\n ref: ModalActionRef<Ref, FormData> | null\n ) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)\n) {\n const ForwardedModalAction = forwardedModalAction as unknown as ModalActionInterface<\n FormData,\n P,\n OuterTriggerProp,\n OuterEvent,\n Ref\n >;\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref, FormData>,\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>\n >((props, ref) => {\n const modalActionRef = useRef<ModalActionRef<Ref, FormData>>(null);\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props, modalActionRef.current);\n const mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n\n useImperativeHandle(ref, () => modalActionRef.current as ModalActionRef<Ref, FormData>, []);\n\n return (\n <ForwardedModalAction\n ref={modalActionRef}\n formComp={formComp}\n {...(mergedProps as Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)}\n />\n );\n });\n return addTriggers<Form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IAAA;IAC9F,IAAMwH,QAAQ,GAAGD,eAAe,CAACrH,KAAK,EAAEoH,cAAc,CAAC9D,OAAO,CAAC;IAC/D,IAAM/C,WAAW,GAAG,OAAOT,YAAY,KAAK,UAAU,GAAGU,UAAU,CAACR,KAAK,EAAEsH,QAAQ,CAAC,GAAG9G,UAAU,CAAC8G,QAAQ,EAAEtH,KAAK,CAAC;IAClHmH,gBAAgB,CAAC9N,WAAW,GAAG,8BAA8B;IAE7DsF,mBAAmB,CAACsB,GAAG,EAAE;MAAA,OAAMmH,cAAc,CAAC9D,OAAO;IAAA,CAAiC,EAAE,EAAE,CAAC;IAE3F,oBACE/D,IAAA,CAAC0I,oBAAoB,EAAArL,aAAA;MACnBqD,GAAG,EAAEmH,cAAe;MACpB1G,QAAQ,EAAEA;IAAS,GACdH,WAAW,CACjB,CAAC;EAEN,CAAC,CAAC;EACF,OAAOkH,WAAW,CAA6DN,gBAAgB,CAAC;AAClG;AAEA,eAAeW,WAAW"}
|
package/es/hooks/useMovable.js
CHANGED
|
@@ -27,6 +27,7 @@ var useMovable = function useMovable(props) {
|
|
|
27
27
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
28
|
position = _useState2[0],
|
|
29
29
|
setPosition = _useState2[1];
|
|
30
|
+
var positionRef = useRefValue(position);
|
|
30
31
|
var draggingRef = useRef(false);
|
|
31
32
|
var dragOffsetRef = useRef({
|
|
32
33
|
x: 0,
|
|
@@ -65,24 +66,43 @@ var useMovable = function useMovable(props) {
|
|
|
65
66
|
e.preventDefault();
|
|
66
67
|
});
|
|
67
68
|
|
|
68
|
-
//
|
|
69
|
+
// 调整:在窗口 resize 时自动收敛位置,防止超出可视区域
|
|
69
70
|
useEffect(function () {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
savePositionRef.current(pos);
|
|
71
|
+
var clampToViewport = function clampToViewport() {
|
|
72
|
+
var _containerRef$current3;
|
|
73
|
+
var pos = positionRef.current;
|
|
74
|
+
if (!pos) return;
|
|
75
|
+
|
|
76
|
+
// Refresh the container size before each convergence to ensure accurate boundaries.
|
|
77
|
+
var rect = (_containerRef$current3 = containerRef.current) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.getBoundingClientRect();
|
|
78
|
+
if (rect) {
|
|
79
|
+
sizeRef.current = {
|
|
80
|
+
w: rect.width,
|
|
81
|
+
h: rect.height
|
|
82
|
+
};
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
var maxLeft = Math.max(0, window.innerWidth - sizeRef.current.w);
|
|
85
|
+
var maxTop = Math.max(0, window.innerHeight - sizeRef.current.h);
|
|
86
|
+
var clampedLeft = Math.min(Math.max(0, pos.left), maxLeft);
|
|
87
|
+
var clampedTop = Math.min(Math.max(0, pos.top), maxTop);
|
|
88
|
+
if (clampedLeft !== pos.left || clampedTop !== pos.top) {
|
|
89
|
+
var next = {
|
|
90
|
+
left: clampedLeft,
|
|
91
|
+
top: clampedTop
|
|
92
|
+
};
|
|
93
|
+
setPosition(next);
|
|
94
|
+
if (storageKeyRef.current) {
|
|
95
|
+
savePositionRef.current(next);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
window.addEventListener('resize', clampToViewport);
|
|
100
|
+
// Calibrate immediately after the first mount/position change.
|
|
101
|
+
clampToViewport();
|
|
102
|
+
return function () {
|
|
103
|
+
window.removeEventListener('resize', clampToViewport);
|
|
104
|
+
};
|
|
105
|
+
}, [containerRef]);
|
|
86
106
|
|
|
87
107
|
// Update position during dragging; restrict within the visible area.
|
|
88
108
|
useEffect(function () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useRef","useState","useLocalStorage","useRefFunction","useRefValue","useMovable","props","enabled","containerRef","ignoreSelectors","storageKey","storageKeyRef","_useLocalStorage","_useLocalStorage2","_slicedToArray","savedPosition","savePosition","savePositionRef","_useState","undefined","_useState2","position","setPosition","draggingRef","dragOffsetRef","x","y","sizeRef","w","h","handlePointerDown","e","_position$left","_position$top","target","closest","join","current","rect","getBoundingClientRect","width","height","currentLeft","left","currentTop","top","clientX","clientY","_containerRef$current","_containerRef$current2","setPointerCapture","call","pointerId","_unused","preventDefault","maxLeft","Math","max","window","innerWidth","maxTop","innerHeight","clampedLeft","min","clampedTop","pos","onMove","newLeft","newTop","onUp","addEventListener","removeEventListener","onPointerDown"],"sources":["../../src/hooks/useMovable.ts"],"sourcesContent":["import { type RefObject, useEffect, useRef, useState } from 'react';\nimport { useLocalStorage } from 'react-use';\nimport useRefFunction from './useRefFunction';\nimport useRefValue from './useRefValue';\n\nexport interface UseMovableProps {\n /**\n * - **EN:** Whether dragging is enabled, default is `true`\n * - **CN:** 是否启用拖动,默认`true`\n */\n enabled?: boolean;\n /**\n * - **EN:** The ref of the container element\n * - **CN:** 容器元素的ref\n */\n containerRef: RefObject<HTMLElement>;\n /**\n * - **EN:** Selectors of elements that should not trigger dragging, e.g., interactive controls\n * - **CN:** 不应触发拖动的元素的选择器,例如交互控件\n */\n ignoreSelectors?: string[];\n /**\n * - **EN:** Key for storing position in localStorage; if not provided, position won't be saved\n * - **CN:** 用于在 localStorage 中存储位置的键;如果未提供,则不会保存位置\n */\n storageKey?: string;\n}\n\n/**\n * - **EN:** Hook to make an element movable by dragging, with position persistence using localStorage\n * - **CN:** 通过拖动使元素可移动的钩子,并使用 localStorage 持久化位置\n */\nconst useMovable = (props: UseMovableProps) => {\n const { enabled, containerRef, ignoreSelectors, storageKey } = props;\n\n const storageKeyRef = useRefValue(storageKey);\n const [savedPosition, savePosition] = useLocalStorage<MovePosition>(storageKey ?? '');\n const savePositionRef = useRefValue(savePosition);\n const [position, setPosition] = useState<MovePosition | undefined>(savedPosition ?? undefined);\n const draggingRef = useRef(false);\n const dragOffsetRef = useRef({ x: 0, y: 0 });\n const sizeRef = useRef({ w: 0, h: 0 });\n\n // Drag start (exclude interactive controls)\n const handlePointerDown = useRefFunction((e: React.PointerEvent<HTMLDivElement>) => {\n const target = e.target as HTMLElement;\n // Set the selector for elements that do not trigger dragging\n if (ignoreSelectors && target.closest(ignoreSelectors.join(','))) return;\n\n if (!containerRef.current) return;\n const rect = containerRef.current.getBoundingClientRect();\n sizeRef.current = { w: rect.width, h: rect.height };\n const currentLeft = position?.left ?? rect.left;\n const currentTop = position?.top ?? rect.top;\n\n dragOffsetRef.current = { x: e.clientX - currentLeft, y: e.clientY - currentTop };\n draggingRef.current = true;\n try {\n containerRef.current.setPointerCapture?.(e.pointerId);\n } catch {\n // do nothing\n }\n e.preventDefault();\n });\n\n // Adjust position when window size changes\n useEffect(() => {\n if (!position) return;\n const maxLeft = Math.max(0, window.innerWidth - sizeRef.current.w);\n const maxTop = Math.max(0, window.innerHeight - sizeRef.current.h);\n const clampedLeft = Math.min(Math.max(0, position.left), maxLeft);\n const clampedTop = Math.min(Math.max(0, position.top), maxTop);\n if (clampedLeft !== position.left || clampedTop !== position.top) {\n const pos = { left: clampedLeft, top: clampedTop };\n setPosition(pos);\n if (storageKeyRef.current) {\n savePositionRef.current(pos);\n }\n }\n }, [position]);\n\n // Update position during dragging; restrict within the visible area.\n useEffect(() => {\n const onMove = (e: PointerEvent) => {\n if (!draggingRef.current) return;\n const newLeft = e.clientX - dragOffsetRef.current.x;\n const newTop = e.clientY - dragOffsetRef.current.y;\n const maxLeft = Math.max(0, window.innerWidth - sizeRef.current.w);\n const maxTop = Math.max(0, window.innerHeight - sizeRef.current.h);\n const clampedLeft = Math.min(Math.max(0, newLeft), maxLeft);\n const clampedTop = Math.min(Math.max(0, newTop), maxTop);\n const pos = { left: clampedLeft, top: clampedTop };\n setPosition(pos);\n if (storageKeyRef.current) {\n savePositionRef.current(pos);\n }\n };\n const onUp = () => {\n if (draggingRef.current) draggingRef.current = false;\n };\n if (enabled) {\n window.addEventListener('pointermove', onMove);\n window.addEventListener('pointerup', onUp);\n window.addEventListener('pointercancel', onUp);\n }\n return () => {\n window.removeEventListener('pointermove', onMove);\n window.removeEventListener('pointerup', onUp);\n window.removeEventListener('pointercancel', onUp);\n };\n }, [enabled]);\n\n return {\n onPointerDown: handlePointerDown,\n position,\n };\n};\n\nexport interface MovePosition {\n left: number;\n top: number;\n}\n\nexport default useMovable;\n"],"mappings":";;;;;;AAAA,SAAyBA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnE,SAASC,eAAe,QAAQ,WAAW;AAC3C,OAAOC,cAAc;AACrB,OAAOC,WAAW;AAyBlB;AACA;AACA;AACA;AACA,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAIC,KAAsB,EAAK;EAC7C,IAAQC,OAAO,GAAgDD,KAAK,CAA5DC,OAAO;IAAEC,YAAY,GAAkCF,KAAK,CAAnDE,YAAY;IAAEC,eAAe,GAAiBH,KAAK,CAArCG,eAAe;IAAEC,UAAU,GAAKJ,KAAK,CAApBI,UAAU;EAE1D,IAAMC,aAAa,GAAGP,WAAW,CAACM,UAAU,CAAC;EAC7C,IAAAE,gBAAA,GAAsCV,eAAe,CAAeQ,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,EAAE,CAAC;IAAAG,iBAAA,GAAAC,cAAA,CAAAF,gBAAA;IAA9EG,aAAa,GAAAF,iBAAA;IAAEG,YAAY,GAAAH,iBAAA;EAClC,IAAMI,eAAe,GAAGb,WAAW,CAACY,YAAY,CAAC;EACjD,IAAAE,SAAA,GAAgCjB,QAAQ,CAA2Bc,aAAa,aAAbA,aAAa,cAAbA,aAAa,GAAII,SAAS,CAAC;IAAAC,UAAA,GAAAN,cAAA,CAAAI,SAAA;IAAvFG,QAAQ,GAAAD,UAAA;IAAEE,WAAW,GAAAF,UAAA;EAC5B,IAAMG,WAAW,GAAGvB,MAAM,CAAC,KAAK,CAAC;EACjC,IAAMwB,aAAa,GAAGxB,MAAM,CAAC;IAAEyB,CA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,EAAED,IAAI,CAAC;MAC1CX,MAAM,CAACY,gBAAgB,CAAC,eAAe,EAAED,IAAI,CAAC;IAChD;IACA,OAAO,YAAM;MACXX,MAAM,CAACa,mBAAmB,CAAC,aAAa,EAAEL,MAAM,CAAC;MACjDR,MAAM,CAACa,mBAAmB,CAAC,WAAW,EAAEF,IAAI,CAAC;MAC7CX,MAAM,CAACa,mBAAmB,CAAC,eAAe,EAAEF,IAAI,CAAC;IACnD,CAAC;EACH,CAAC,EAAE,CAAC9D,OAAO,CAAC,CAAC;EAEb,OAAO;IACLiE,aAAa,EAAE1C,iBAAiB;IAChCT,QAAQ,EAARA;EACF,CAAC;AACH,CAAC;AAOD,eAAehB,UAAU"}
|
|
1
|
+
{"version":3,"names":["useEffect","useRef","useState","useLocalStorage","useRefFunction","useRefValue","useMovable","props","enabled","containerRef","ignoreSelectors","storageKey","storageKeyRef","_useLocalStorage","_useLocalStorage2","_slicedToArray","savedPosition","savePosition","savePositionRef","_useState","undefined","_useState2","position","setPosition","positionRef","draggingRef","dragOffsetRef","x","y","sizeRef","w","h","handlePointerDown","e","_position$left","_position$top","target","closest","join","current","rect","getBoundingClientRect","width","height","currentLeft","left","currentTop","top","clientX","clientY","_containerRef$current","_containerRef$current2","setPointerCapture","call","pointerId","_unused","preventDefault","clampToViewport","_containerRef$current3","pos","maxLeft","Math","max","window","innerWidth","maxTop","innerHeight","clampedLeft","min","clampedTop","next","addEventListener","removeEventListener","onMove","newLeft","newTop","onUp","onPointerDown"],"sources":["../../src/hooks/useMovable.ts"],"sourcesContent":["import { type RefObject, useEffect, useRef, useState } from 'react';\nimport { useLocalStorage } from 'react-use';\nimport useRefFunction from './useRefFunction';\nimport useRefValue from './useRefValue';\n\nexport interface UseMovableProps {\n /**\n * - **EN:** Whether dragging is enabled, default is `true`\n * - **CN:** 是否启用拖动,默认`true`\n */\n enabled?: boolean;\n /**\n * - **EN:** The ref of the container element\n * - **CN:** 容器元素的ref\n */\n containerRef: RefObject<HTMLElement>;\n /**\n * - **EN:** Selectors of elements that should not trigger dragging, e.g., interactive controls\n * - **CN:** 不应触发拖动的元素的选择器,例如交互控件\n */\n ignoreSelectors?: string[];\n /**\n * - **EN:** Key for storing position in localStorage; if not provided, position won't be saved\n * - **CN:** 用于在 localStorage 中存储位置的键;如果未提供,则不会保存位置\n */\n storageKey?: string;\n}\n\n/**\n * - **EN:** Hook to make an element movable by dragging, with position persistence using localStorage\n * - **CN:** 通过拖动使元素可移动的钩子,并使用 localStorage 持久化位置\n */\nconst useMovable = (props: UseMovableProps) => {\n const { enabled, containerRef, ignoreSelectors, storageKey } = props;\n\n const storageKeyRef = useRefValue(storageKey);\n const [savedPosition, savePosition] = useLocalStorage<MovePosition>(storageKey ?? '');\n const savePositionRef = useRefValue(savePosition);\n const [position, setPosition] = useState<MovePosition | undefined>(savedPosition ?? undefined);\n const positionRef = useRefValue(position);\n const draggingRef = useRef(false);\n const dragOffsetRef = useRef({ x: 0, y: 0 });\n const sizeRef = useRef({ w: 0, h: 0 });\n\n // Drag start (exclude interactive controls)\n const handlePointerDown = useRefFunction((e: React.PointerEvent<HTMLDivElement>) => {\n const target = e.target as HTMLElement;\n // Set the selector for elements that do not trigger dragging\n if (ignoreSelectors && target.closest(ignoreSelectors.join(','))) return;\n\n if (!containerRef.current) return;\n const rect = containerRef.current.getBoundingClientRect();\n sizeRef.current = { w: rect.width, h: rect.height };\n const currentLeft = position?.left ?? rect.left;\n const currentTop = position?.top ?? rect.top;\n\n dragOffsetRef.current = { x: e.clientX - currentLeft, y: e.clientY - currentTop };\n draggingRef.current = true;\n try {\n containerRef.current.setPointerCapture?.(e.pointerId);\n } catch {\n // do nothing\n }\n e.preventDefault();\n });\n\n // 调整:在窗口 resize 时自动收敛位置,防止超出可视区域\n useEffect(() => {\n const clampToViewport = () => {\n const pos = positionRef.current;\n if (!pos) return;\n\n // Refresh the container size before each convergence to ensure accurate boundaries.\n const rect = containerRef.current?.getBoundingClientRect();\n if (rect) {\n sizeRef.current = { w: rect.width, h: rect.height };\n }\n\n const maxLeft = Math.max(0, window.innerWidth - sizeRef.current.w);\n const maxTop = Math.max(0, window.innerHeight - sizeRef.current.h);\n const clampedLeft = Math.min(Math.max(0, pos.left), maxLeft);\n const clampedTop = Math.min(Math.max(0, pos.top), maxTop);\n\n if (clampedLeft !== pos.left || clampedTop !== pos.top) {\n const next = { left: clampedLeft, top: clampedTop };\n setPosition(next);\n if (storageKeyRef.current) {\n savePositionRef.current(next);\n }\n }\n };\n\n window.addEventListener('resize', clampToViewport);\n // Calibrate immediately after the first mount/position change.\n clampToViewport();\n\n return () => {\n window.removeEventListener('resize', clampToViewport);\n };\n }, [containerRef]);\n\n // Update position during dragging; restrict within the visible area.\n useEffect(() => {\n const onMove = (e: PointerEvent) => {\n if (!draggingRef.current) return;\n const newLeft = e.clientX - dragOffsetRef.current.x;\n const newTop = e.clientY - dragOffsetRef.current.y;\n const maxLeft = Math.max(0, window.innerWidth - sizeRef.current.w);\n const maxTop = Math.max(0, window.innerHeight - sizeRef.current.h);\n const clampedLeft = Math.min(Math.max(0, newLeft), maxLeft);\n const clampedTop = Math.min(Math.max(0, newTop), maxTop);\n const pos = { left: clampedLeft, top: clampedTop };\n setPosition(pos);\n if (storageKeyRef.current) {\n savePositionRef.current(pos);\n }\n };\n const onUp = () => {\n if (draggingRef.current) draggingRef.current = false;\n };\n if (enabled) {\n window.addEventListener('pointermove', onMove);\n window.addEventListener('pointerup', onUp);\n window.addEventListener('pointercancel', onUp);\n }\n return () => {\n window.removeEventListener('pointermove', onMove);\n window.removeEventListener('pointerup', onUp);\n window.removeEventListener('pointercancel', onUp);\n };\n }, [enabled]);\n\n return {\n onPointerDown: handlePointerDown,\n position,\n };\n};\n\nexport interface MovePosition {\n left: number;\n top: number;\n}\n\nexport default useMovable;\n"],"mappings":";;;;;;AAAA,SAAyBA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnE,SAASC,eAAe,QAAQ,WAAW;AAC3C,OAAOC,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B;IACF,CAAC;IACD,IAAMiB,IAAI,GAAG,SAAPA,IAAIA,CAAA,EAAS;MACjB,IAAInD,WAAW,CAACc,OAAO,EAAEd,WAAW,CAACc,OAAO,GAAG,KAAK;IACtD,CAAC;IACD,IAAI/B,OAAO,EAAE;MACXuD,MAAM,CAACQ,gBAAgB,CAAC,aAAa,EAAEE,MAAM,CAAC;MAC9CV,MAAM,CAACQ,gBAAgB,CAAC,WAAW,EAAEK,IAAI,CAAC;MAC1Cb,MAAM,CAACQ,gBAAgB,CAAC,eAAe,EAAEK,IAAI,CAAC;IAChD;IACA,OAAO,YAAM;MACXb,MAAM,CAACS,mBAAmB,CAAC,aAAa,EAAEC,MAAM,CAAC;MACjDV,MAAM,CAACS,mBAAmB,CAAC,WAAW,EAAEI,IAAI,CAAC;MAC7Cb,MAAM,CAACS,mBAAmB,CAAC,eAAe,EAAEI,IAAI,CAAC;IACnD,CAAC;EACH,CAAC,EAAE,CAACpE,OAAO,CAAC,CAAC;EAEb,OAAO;IACLqE,aAAa,EAAE7C,iBAAiB;IAChCV,QAAQ,EAARA;EACF,CAAC;AACH,CAAC;AAOD,eAAehB,UAAU"}
|
|
@@ -124,14 +124,15 @@ export interface ModalActionTrigger<FormData extends object, P extends FormCompP
|
|
|
124
124
|
*/
|
|
125
125
|
children?: ReactNode;
|
|
126
126
|
}
|
|
127
|
-
export type ModalActionRef<R> = R & {
|
|
127
|
+
export type ModalActionRef<R = {}, FormData extends object = any> = R & {
|
|
128
|
+
form: FormInstance<FormData> | undefined;
|
|
128
129
|
/**
|
|
129
130
|
* - **EN:** Show the dialog
|
|
130
131
|
* - **CN:** 显示弹框
|
|
131
132
|
*/
|
|
132
133
|
show: () => void;
|
|
133
134
|
};
|
|
134
|
-
export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>, ref: ForwardedRef<ModalActionRef<Ref>>) => import("react/jsx-runtime").JSX.Element;
|
|
135
|
+
export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>, ref: ForwardedRef<ModalActionRef<Ref, FormData>>) => import("react/jsx-runtime").JSX.Element;
|
|
135
136
|
/**
|
|
136
137
|
* - **EN:** Add default properties to the ModalAction component
|
|
137
138
|
* - **CN:** 给ModalAction组件添加默认属性
|
|
@@ -139,7 +140,7 @@ export declare const genModalActionRenderer: (defaultProps: Partial<ModalActionP
|
|
|
139
140
|
* @param WrappedComponent ModalAction component | ModalAction组件
|
|
140
141
|
* @param defaultProps Default properties | 默认属性
|
|
141
142
|
*/
|
|
142
|
-
export declare const withDefaultModalActionProps: <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(WrappedComponent: ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>>, defaultProps?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>> | ((actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>) | undefined) => import("react").ForwardRefExoticComponent<Omit<ModalProps, "onOk"> & ModalActionTrigger<FormData, P, TriggerProp, Event> & {
|
|
143
|
+
export declare const withDefaultModalActionProps: <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(WrappedComponent: ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>>, defaultProps?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>> | ((actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>, ref: ModalActionRef<Ref, FormData> | null) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>) | undefined) => import("react").ForwardRefExoticComponent<Omit<ModalProps, "onOk"> & ModalActionTrigger<FormData, P, TriggerProp, Event> & {
|
|
143
144
|
/**
|
|
144
145
|
* - **EN:** Form editing component, do not use the Form component inside the component, the form
|
|
145
146
|
* component and form instance are automatically created by the parent component
|
|
@@ -164,27 +165,27 @@ export declare const withDefaultModalActionProps: <FormData extends object, P ex
|
|
|
164
165
|
* - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值
|
|
165
166
|
*/
|
|
166
167
|
afterOk?: ((data?: any) => void) | undefined;
|
|
167
|
-
} & RefAttributes<ModalActionRef<Ref>>>;
|
|
168
|
+
} & RefAttributes<ModalActionRef<Ref, FormData>>>;
|
|
168
169
|
/**
|
|
169
170
|
* - **EN:** ModalAction component type
|
|
170
171
|
* - **CN:** ModalAction组件的类型
|
|
171
172
|
*/
|
|
172
|
-
export type ModalActionInterface<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object> = ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>>;
|
|
173
|
+
export type ModalActionInterface<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object> = ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>>;
|
|
173
174
|
/**
|
|
174
175
|
* - **EN:** ModalAction component with generic type
|
|
175
176
|
* - **CN:** ModalAction泛型组件的类型
|
|
176
177
|
*/
|
|
177
|
-
export type GenericModalActionInterface = <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>) => ReactNode;
|
|
178
|
+
export type GenericModalActionInterface = <FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object>(props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>) => ReactNode;
|
|
178
179
|
/**
|
|
179
180
|
* - **EN:** ModalAction with specified trigger type (specified form component)
|
|
180
181
|
* - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)
|
|
181
182
|
*/
|
|
182
|
-
type ModalActionWithTrigger<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object, OMIT extends string = never> = ComponentType<Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref>>>;
|
|
183
|
+
type ModalActionWithTrigger<FormData extends object, P extends FormCompPropsConstraint<FormData>, TriggerProp extends object, Event extends keyof TriggerProp, Ref extends object, OMIT extends string = never> = ComponentType<Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref, FormData>>>;
|
|
183
184
|
/**
|
|
184
185
|
* - **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)
|
|
185
186
|
* - **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)
|
|
186
187
|
*/
|
|
187
|
-
type GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object>(props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref>>) => ReactNode;
|
|
188
|
+
type GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object>(props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> & RefAttributes<ModalActionRef<Ref, FormData>>) => ReactNode;
|
|
188
189
|
/**
|
|
189
190
|
* - **EN:** Built-in trigger types (specified form components)
|
|
190
191
|
* - **CN:** 内置的几种触发器类型(已指定表单组件)
|
|
@@ -227,7 +228,7 @@ interface GenericTypedTriggers<OMIT extends string = never> {
|
|
|
227
228
|
*/
|
|
228
229
|
Link: GenericModalActionWithTrigger<LinkProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;
|
|
229
230
|
}
|
|
230
|
-
type WithGenericTriggers<FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object, OMIT extends string = never> = (<TriggerProp extends object, Event extends keyof TriggerProp>(props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> & RefAttributes<ModalActionRef<Ref>>) => ReactNode) & (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);
|
|
231
|
+
type WithGenericTriggers<FormData extends object, P extends FormCompPropsConstraint<FormData>, Ref extends object, OMIT extends string = never> = (<TriggerProp extends object, Event extends keyof TriggerProp>(props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> & RefAttributes<ModalActionRef<Ref, FormData>>) => ReactNode) & (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);
|
|
231
232
|
/**
|
|
232
233
|
* - **EN:** Dialog component with trigger
|
|
233
234
|
* - **CN:** 带触发器的弹窗组件
|
|
@@ -258,6 +259,17 @@ export type ModalActionWithStatic = typeof ModalAction & {
|
|
|
258
259
|
* @param formComp Component of dialog content | 弹窗内容组件
|
|
259
260
|
* @param defaultProps Default properties of the dialog | 弹窗的默认属性
|
|
260
261
|
*/
|
|
261
|
-
export declare function withModalAction<FormData extends object, P extends FormCompPropsConstraint<FormData>, OuterTriggerProp extends object, OuterEvent extends keyof OuterTriggerProp, Ref extends object>(formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>, defaultProps?: Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>> | ((
|
|
262
|
+
export declare function withModalAction<FormData extends object, P extends FormCompPropsConstraint<FormData>, OuterTriggerProp extends object, OuterEvent extends keyof OuterTriggerProp, Ref extends object>(formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>, defaultProps?: Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>> | ((
|
|
263
|
+
/**
|
|
264
|
+
* - **EN:** Actual properties passed to the ModalAction component
|
|
265
|
+
* - **CN:** 实际传递给ModalAction组件的属性
|
|
266
|
+
*/
|
|
267
|
+
actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>,
|
|
268
|
+
/**
|
|
269
|
+
* - **EN:** Ref of the ModalAction component. Note that this ref may be null because the
|
|
270
|
+
* component has not been rendered yet when executed for the first time.
|
|
271
|
+
* - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。
|
|
272
|
+
*/
|
|
273
|
+
ref: ModalActionRef<Ref, FormData> | null) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)): WithGenericTriggers<FormData, P, Ref, "formComp">;
|
|
262
274
|
declare const _default: ModalActionWithStatic;
|
|
263
275
|
export default _default;
|
|
@@ -123,9 +123,10 @@ var genModalActionRenderer = (defaultProps) => {
|
|
|
123
123
|
setOpen(open2);
|
|
124
124
|
(_a = openListenerRef.current) == null ? void 0 : _a.call(openListenerRef, open2);
|
|
125
125
|
}, []);
|
|
126
|
-
(0, import_react.useImperativeHandle)(ref, () => ({ ...formCompRef, show: showModal }), [
|
|
126
|
+
(0, import_react.useImperativeHandle)(ref, () => ({ ...formCompRef, form, show: showModal }), [
|
|
127
127
|
formCompRef,
|
|
128
|
-
showModal
|
|
128
|
+
showModal,
|
|
129
|
+
form
|
|
129
130
|
]);
|
|
130
131
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, showTrigger && /* @__PURE__ */ React.createElement(
|
|
131
132
|
Trigger,
|
|
@@ -271,15 +272,15 @@ function FormCreator(props) {
|
|
|
271
272
|
return null;
|
|
272
273
|
}
|
|
273
274
|
var withDefaultModalActionProps = (WrappedComponent, defaultProps) => {
|
|
274
|
-
const WithDefaultProps = (0, import_react.forwardRef)(
|
|
275
|
-
(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
);
|
|
275
|
+
const WithDefaultProps = (0, import_react.forwardRef)((props, ref) => {
|
|
276
|
+
const modalActionRef = (0, import_react.useRef)(null);
|
|
277
|
+
const useDefaultProps = typeof defaultProps === "function" ? defaultProps : () => defaultProps;
|
|
278
|
+
const defaults = useDefaultProps(props, modalActionRef.current);
|
|
279
|
+
const mergedProps = typeof defaultProps === "function" ? mergeProps(props, defaults) : mergeProps(defaults, props);
|
|
280
|
+
WithDefaultProps.displayName = "ForwardRef(WithDefaultProps)";
|
|
281
|
+
(0, import_react.useImperativeHandle)(ref, () => modalActionRef.current, []);
|
|
282
|
+
return /* @__PURE__ */ React.createElement(WrappedComponent, { ref: modalActionRef, ...mergedProps });
|
|
283
|
+
});
|
|
283
284
|
return WithDefaultProps;
|
|
284
285
|
};
|
|
285
286
|
var renderModalAction = genModalActionRenderer({});
|
|
@@ -320,14 +321,16 @@ ModalAction.SubmitWithoutClosing = SubmitWithoutClosingSymbol;
|
|
|
320
321
|
function withModalAction(formComp, defaultProps) {
|
|
321
322
|
const ForwardedModalAction = forwardedModalAction;
|
|
322
323
|
const WithDefaultProps = (0, import_react.forwardRef)((props, ref) => {
|
|
324
|
+
const modalActionRef = (0, import_react.useRef)(null);
|
|
323
325
|
const useDefaultProps = typeof defaultProps === "function" ? defaultProps : () => defaultProps;
|
|
324
|
-
const defaults = useDefaultProps(props);
|
|
326
|
+
const defaults = useDefaultProps(props, modalActionRef.current);
|
|
325
327
|
const mergedProps = typeof defaultProps === "function" ? mergeProps(props, defaults) : mergeProps(defaults, props);
|
|
326
328
|
WithDefaultProps.displayName = "ForwardRef(WithDefaultProps)";
|
|
329
|
+
(0, import_react.useImperativeHandle)(ref, () => modalActionRef.current, []);
|
|
327
330
|
return /* @__PURE__ */ React.createElement(
|
|
328
331
|
ForwardedModalAction,
|
|
329
332
|
{
|
|
330
|
-
ref,
|
|
333
|
+
ref: modalActionRef,
|
|
331
334
|
formComp,
|
|
332
335
|
...mergedProps
|
|
333
336
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/ModalAction/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { ComponentType, FC, ForwardedRef, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport type { ButtonProps, FormInstance, ModalProps, SwitchProps } from 'antd';\nimport { Button, Form, Modal, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { isForwardRef } from 'react-is';\nimport useContextValidator from '../../hooks/useContextValidator';\n\n/**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\nexport const SubmitWithoutClosingSymbol = Symbol('[SubmitWithoutClose]');\n\nexport type ModalActionProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = Omit<ModalProps, 'onOk'> &\n ModalActionTrigger<FormData, P, TriggerProp, Event> & {\n /**\n * - **EN:** Form editing component, do not use the Form component inside the component, the form\n * component and form instance are automatically created by the parent component\n * - **CN:** 表单编辑组件,组件内部不要使用Form组件,表单组件及表单实例由父组件自动创建\n */\n formComp: ComponentType<P & RefAttributes<Ref>>;\n /**\n * - **EN:** Props of the form editing component\n * - **CN:** 表单编辑组件的Props属性\n */\n formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>;\n /**\n * - **EN:** The callback when clicks the confirmation button, support asynchronous saving, return\n * `SubmitWithoutClosingSymbol` can prevent the dialog from closing, return other values will\n * be passed to the `afterOk` event, if any\n * - **CN:** 点击确认按钮的回调,支持异步保存,返回`SubmitWithoutClosingSymbol`可以阻止弹框关闭,返回其他值会传递给`afterOk`事件,如果有的话\n */\n onOk?: (\n formData: FormData,\n // @ts-expect-error: because TP[E] should be a function type\n ...args: Parameters<TriggerProp[Event]>\n ) => unknown | Promise<unknown>;\n /**\n * - **EN:** The callback after the confirmation event is completed, it will not be triggered when\n * it fails, the parameter is the return value of `onOk`\n * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface FormCompPropsConstraint<FormData> {\n /**\n * - **EN:** Automatically generated form instance, use this form instance in FormComp, do not\n * create a new instance\n * - **CN:** 自动生成的表单实例,编辑表单要使用这个表单实例,不要新创建实例\n */\n form: FormInstance<FormData>;\n /**\n * - **EN:** Register the form save event, the callback function passed in will be called when the\n * confirm button is clicked, support asynchronous saving\n * - **CN:** 注册表单保存事件,传入的回调函数会在点击确认按钮时被调用,支持异步保存\n *\n * @param handler Event handler | 事件处理函数\n */\n onSave: (\n handler: (\n /**\n * - **EN:** Form data\n * - **CN:** 表单数据\n */\n formData: FormData,\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get\n * the value of the switch; for the `Button` type trigger, you can get the click event\n * object of the button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值;对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n ...triggerEventData: any[]\n ) => unknown | Promise<unknown>\n ) => void;\n /**\n * - **EN:** Listen to the open and close status of the dialog. When `destroyOnHidden` is set to\n * false, the form component instance is cached, and the dialog can only be listened to in this\n * way\n * - **CN:** 监听弹框打开关闭状态。当`destroyOnHidden`设置为false时,表单组件实例被缓存,只能通过这种方式监听弹框\n *\n * @param handler Event handler | 事件处理函数\n */\n onOpenChange: (handler: ModalProps['afterOpenChange']) => void;\n /**\n * - **EN:** Set the dialog open status\n * - **CN:** 设置弹框打开状态\n *\n * @param open Whether is open or not | 弹窗是否打开\n */\n setOpen: (open: boolean) => void;\n /**\n * - **EN:** Modify the properties of the dialog, such as title, width, button properties, etc.\n * - **CN:** 修改弹窗的属性,例如标题、宽度,按钮属性等\n */\n updateModalProps: (props: Partial<ModalProps>) => void;\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get the\n * value of the switch; for the `Button` type trigger, you can get the click event object of the\n * button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值,对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n triggerEventData?: any[];\n}\n\nexport interface ModalActionTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n> {\n /**\n * - **EN:** Trigger component, click to show the dialog\n * - **CN:** 弹窗触发器组件,点击触发显示弹框\n */\n triggerComponent?: ComponentType<TriggerProp> | FC<TriggerProp>;\n /**\n * - **EN:** Props of the trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TriggerProp & {\n /**\n * - **EN:** Set a custom function to determine whether to show the trigger button\n * - **CN:** 设置一个自定义函数,用于判断是否显示触发器按钮\n *\n * @default true\n *\n * @param formProps Form component props | 表单组件的props\n */\n show?: boolean | ((formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>) => boolean);\n };\n /**\n * - **EN:** The event name that triggers the dialog\n * - **CN:** 触发弹窗的事件名称\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: Event;\n /**\n * - **EN:** Custom trigger content\n * - **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\nexport type ModalActionRef<R> = R & {\n /**\n * - **EN:** Show the dialog\n * - **CN:** 显示弹框\n */\n show: () => void;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const genModalActionRenderer = (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => {\n const ModalActionRenderer = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n >(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n ref: ForwardedRef<ModalActionRef<Ref>>\n ) => {\n const [userModalProps, setUserModalProps] = useState<Partial<ModalProps>>({});\n let mergedProps = mergeProps<FormData, P, TriggerProp, Event, Ref>(defaultProps, props);\n mergedProps = mergeProps(mergedProps, userModalProps as typeof props);\n const {\n formComp,\n formProps,\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as Event,\n triggerProps,\n open: openInProps,\n destroyOnClose = true,\n destroyOnHidden = true,\n maskClosable = false,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n onCancel,\n afterClose,\n children,\n ...restProps\n } = mergedProps;\n useContextValidator();\n const FormComp = formComp as ComponentType<FormCompPropsConstraint<FormData> & RefAttributes<Ref>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n const [open, setOpen] = useState(false);\n const saveFuncRef = useRef<(formData: FormData, ...args: any[]) => unknown>(undefined);\n const [isSaving, setIsSaving] = useState(false);\n const [formCompRef, setFormCompRef] = useState<Ref | null>(null);\n const [form, setForm] = useState<FormInstance<FormData>>();\n const formRef = useRef<FormInstance<FormData>>(form);\n formRef.current = form;\n const destroyOnCloseRef = useRef(destroyOnClose);\n destroyOnCloseRef.current = destroyOnClose || destroyOnHidden;\n const openListenerRef = useRef<ModalProps['afterOpenChange']>(undefined);\n\n // Listen to the open props changes\n useEffect(() => {\n if (openInProps) {\n setOpen(openInProps);\n }\n }, [openInProps]);\n\n // Reset the form after closed\n useEffect(() => {\n if (!destroyOnCloseRef.current && open && formRef.current) {\n formRef.current.resetFields();\n }\n }, [open]);\n\n // show trigger\n const showInProps = triggerProps?.show;\n const showTrigger = useMemo(() => {\n if (typeof showInProps === 'boolean') {\n return showInProps;\n } else if (typeof showInProps === 'function') {\n return showInProps(formProps);\n }\n return true;\n }, [showInProps, formProps]);\n\n // Show the dialog\n const showModal = useCallback(() => {\n setOpen(true);\n openListenerRef.current?.(true);\n }, []);\n // Hide the dialog\n const hideModal = useCallback(() => {\n setOpen(false);\n openListenerRef.current?.(false);\n }, []);\n // Set the dialog status listener\n const setOpenListener = useCallback(\n (listener: ModalProps['afterOpenChange']) => {\n openListenerRef.current = listener;\n // Call once when initialized\n openListenerRef.current?.(open);\n },\n [open]\n );\n // Receive the onSave callback method passed by the form component\n const setOnSaveHandler: FormCompPropsConstraint<FormData>['onSave'] = useCallback((handler) => {\n saveFuncRef.current = handler;\n }, []);\n // Set the dialog status and trigger the onOpenChange event of the form component\n const handleSetOpen = useCallback((open: boolean) => {\n setOpen(open);\n openListenerRef.current?.(open);\n }, []);\n\n // Output ref\n useImperativeHandle(ref, () => ({ ...formCompRef, show: showModal }) as ModalActionRef<Ref>, [\n formCompRef,\n showModal,\n ]);\n\n // Render the trigger component\n return (\n <>\n {showTrigger && (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n showModal();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args);\n }\n },\n }\n : {}) as TriggerProp)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n )}\n <Modal\n open={open}\n confirmLoading={isSaving}\n destroyOnClose={destroyOnClose}\n destroyOnHidden={destroyOnHidden}\n maskClosable={maskClosable}\n okButtonProps={{\n loading: isSaving,\n ...okButtonProps,\n }}\n cancelButtonProps={{\n disabled: isSaving,\n ...cancelButtonProps,\n }}\n onOk={async () => {\n let formData: FormData;\n try {\n formData = (await form?.validateFields()) as FormData;\n } catch (e) {\n // Validation error, should not throw error\n return;\n }\n if (Object.keys(formData).length === 0) {\n console.warn(\n 'form.getFieldsValue() is empty. Please use the form instance passed to formComp instead of creating the form instance yourself.'\n );\n }\n try {\n setIsSaving(true);\n // First call onSave of the form component\n let result = await saveFuncRef.current?.(formData, ...(triggerEventArgsRef.current ?? []));\n // The onSave of the form component has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // Then call onOk of the dialog, support asynchronous, and will pass the return value of onSave, if any\n if (onOk) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result = await onOk((result as FormData) ?? formData, ...((triggerEventArgsRef.current ?? []) as any));\n }\n // onOk also has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // If onOK is successful, close the dialog and trigger the afterOk event\n hideModal();\n afterOk?.(result);\n } catch (error) {\n console.error(error);\n } finally {\n setIsSaving(false);\n }\n }}\n onCancel={async (e) => {\n hideModal();\n onCancel?.(e);\n }}\n afterClose={() => {\n hideModal();\n afterClose?.();\n }}\n {...restProps}\n >\n <FormCreator<FormData> onCreate={setForm} />\n {form && (\n <FormComp\n ref={isForwardRef(FormComp) ? setFormCompRef : undefined}\n {...formProps}\n form={form}\n onOpenChange={setOpenListener}\n onSave={setOnSaveHandler}\n triggerEventData={triggerEventArgsRef.current}\n setOpen={handleSetOpen}\n updateModalProps={setUserModalProps}\n />\n )}\n </Modal>\n </>\n );\n };\n return ModalActionRenderer;\n};\n\nfunction mergeProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n first?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>,\n second?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n) {\n return {\n ...first,\n ...second,\n okButtonProps: {\n ...first?.okButtonProps,\n ...second?.okButtonProps,\n },\n cancelButtonProps: {\n ...first?.cancelButtonProps,\n ...second?.cancelButtonProps,\n },\n bodyProps: {\n ...first?.bodyProps,\n ...second?.bodyProps,\n },\n maskProps: {\n ...first?.maskProps,\n ...second?.maskProps,\n },\n wrapProps: {\n ...first?.wrapProps,\n ...second?.wrapProps,\n },\n formProps: {\n ...first?.formProps,\n ...second?.formProps,\n },\n triggerProps: {\n ...first?.triggerProps,\n ...second?.triggerProps,\n style: {\n ...(first?.triggerProps && 'style' in first.triggerProps && typeof first.triggerProps.style === 'object'\n ? first.triggerProps.style\n : {}),\n ...(second?.triggerProps && 'style' in second.triggerProps && typeof second.triggerProps.style === 'object'\n ? second.triggerProps.style\n : {}),\n },\n },\n } as unknown as ModalActionProps<FormData, P, TriggerProp, Event, Ref>;\n}\n\nfunction FormCreator<FD extends object>(props: { onCreate: (form: FormInstance<FD> | undefined) => void }) {\n const { onCreate } = props;\n const onCreateRef = useRef(onCreate);\n onCreateRef.current = onCreate;\n const [form] = Form.useForm<FD>();\n\n // output ref\n useEffect(() => {\n onCreateRef.current(form);\n return () => {\n onCreateRef.current(undefined);\n };\n }, [form]);\n\n return null;\n}\n\n/**\n * - **EN:** Add default properties to the ModalAction component\n * - **CN:** 给ModalAction组件添加默认属性\n *\n * @param WrappedComponent ModalAction component | ModalAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultModalActionProps = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n WrappedComponent: ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>\n >,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n | ((\n actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>\n ) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>)\n) => {\n const WithDefaultProps = forwardRef<ModalActionRef<Ref>, ModalActionProps<FormData, P, TriggerProp, Event, Ref>>(\n (props, ref) => {\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props);\n const mergedProps =\n typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n return <WrappedComponent ref={ref} {...mergedProps} />;\n }\n );\n return WithDefaultProps;\n};\n\nconst renderModalAction = genModalActionRenderer({});\nconst forwardedModalAction = forwardRef(renderModalAction);\nforwardedModalAction.displayName = 'ForwardRef(ModalAction)';\n/**\n * - **EN:** ModalAction component type\n * - **CN:** ModalAction组件的类型\n */\nexport type ModalActionInterface<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = ComponentType<ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>>;\n/**\n * - **EN:** ModalAction component with generic type\n * - **CN:** ModalAction泛型组件的类型\n */\nexport type GenericModalActionInterface = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref>>\n) => ReactNode;\n/**\n * - **EN:** ModalAction with specified trigger type (specified form component)\n * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)\n */\ntype ModalActionWithTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n OMIT extends string = never,\n> = ComponentType<\n Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref>>\n>;\n\n/**\n * - **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)\n * - **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)\n */\ntype GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n>(\n props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref>>\n) => ReactNode;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\nexport interface TypedTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: ModalActionWithTrigger<FormData, P, ButtonProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: ModalActionWithTrigger<FormData, P, SwitchProps, 'onChange', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: ModalActionWithTrigger<FormData, P, LinkProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\n/**\n * - **EN:** Built-in trigger types (generic types, unspecified form components)\n * - **CN:** 内置的几种触发器类型(泛型类型,未指定表单组件)\n */\ninterface GenericTypedTriggers<OMIT extends string = never> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: GenericModalActionWithTrigger<ButtonProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: GenericModalActionWithTrigger<SwitchProps, 'onChange', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: GenericModalActionWithTrigger<LinkProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\ntype WithGenericTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> = (<TriggerProp extends object, Event extends keyof TriggerProp>(\n props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> & RefAttributes<ModalActionRef<Ref>>\n) => ReactNode) &\n (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);\n\n/**\n * - **EN:** Add trigger types to the ModalAction component\n * - **CN:** 给ModalAction组件添加子触发器类型\n */\nconst addTriggers = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n OMIT extends string = never,\n>(\n comp: ComponentType<\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref> & RefAttributes<ModalActionRef<Ref>>\n >\n) => {\n const patchedComp = comp as WithGenericTriggers<FormData, P, Ref, OMIT>;\n // Type of button trigger\n patchedComp.Button = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, ButtonProps, 'onClick', Ref>,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of switch trigger\n patchedComp.Switch = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, SwitchProps, 'onChange', Ref>,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of link trigger\n patchedComp.Link = withDefaultModalActionProps(comp as ModalActionInterface<FormData, P, LinkProps, 'onClick', Ref>, {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n return patchedComp;\n};\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nconst ModalAction = addTriggers(forwardedModalAction);\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nexport type ModalActionWithStatic = typeof ModalAction & {\n /**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\n SubmitWithoutClosing: symbol;\n};\n(ModalAction as ModalActionWithStatic).SubmitWithoutClosing = SubmitWithoutClosingSymbol;\n\n/**\n * - **EN:** Generate a dialog component based on the editing form component\n * - **CN:** 基于编辑表单组件生成一个弹框组件\n *\n * @template FormData Form data type | 表单数据类型\n * @template P Form component props type | 表单组件的props类型\n * @template OuterTriggerProp Outer trigger props type | 外部触发器的props类型\n * @template OuterEvent Outer trigger event type | 外部触发器的事件类型\n * @template Ref Form component ref type | 表单组件的ref类型\n *\n * @param formComp Component of dialog content | 弹窗内容组件\n * @param defaultProps Default properties of the dialog | 弹窗的默认属性\n */\nexport function withModalAction<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>\n | ((\n actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>\n ) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)\n) {\n const ForwardedModalAction = forwardedModalAction as unknown as ModalActionInterface<\n FormData,\n P,\n OuterTriggerProp,\n OuterEvent,\n Ref\n >;\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref>,\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>\n >((props, ref) => {\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props);\n const mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n return (\n <ForwardedModalAction\n ref={ref}\n formComp={formComp}\n {...(mergedProps as Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)}\n />\n );\n });\n return addTriggers<FormData, P, OuterTriggerProp, OuterEvent, Ref, 'formComp'>(WithDefaultProps);\n}\n\nexport default ModalAction as ModalActionWithStatic;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAmG;AAEnG,kBAAwD;AAExD,sBAA6B;AAC7B,iCAAgC;AAOzB,IAAM,6BAA6B,OAAO,sBAAsB;
|
|
4
|
+
"sourcesContent": ["import type { ComponentType, FC, ForwardedRef, ReactNode, RefAttributes } from 'react';\nimport { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport type { ButtonProps, FormInstance, ModalProps, SwitchProps } from 'antd';\nimport { Button, Form, Modal, Switch, Typography } from 'antd';\nimport type { LinkProps } from 'antd/es/typography/Link';\nimport { isForwardRef } from 'react-is';\nimport useContextValidator from '../../hooks/useContextValidator';\n\n/**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\nexport const SubmitWithoutClosingSymbol = Symbol('[SubmitWithoutClose]');\n\nexport type ModalActionProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = Omit<ModalProps, 'onOk'> &\n ModalActionTrigger<FormData, P, TriggerProp, Event> & {\n /**\n * - **EN:** Form editing component, do not use the Form component inside the component, the form\n * component and form instance are automatically created by the parent component\n * - **CN:** 表单编辑组件,组件内部不要使用Form组件,表单组件及表单实例由父组件自动创建\n */\n formComp: ComponentType<P & RefAttributes<Ref>>;\n /**\n * - **EN:** Props of the form editing component\n * - **CN:** 表单编辑组件的Props属性\n */\n formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>;\n /**\n * - **EN:** The callback when clicks the confirmation button, support asynchronous saving, return\n * `SubmitWithoutClosingSymbol` can prevent the dialog from closing, return other values will\n * be passed to the `afterOk` event, if any\n * - **CN:** 点击确认按钮的回调,支持异步保存,返回`SubmitWithoutClosingSymbol`可以阻止弹框关闭,返回其他值会传递给`afterOk`事件,如果有的话\n */\n onOk?: (\n formData: FormData,\n // @ts-expect-error: because TP[E] should be a function type\n ...args: Parameters<TriggerProp[Event]>\n ) => unknown | Promise<unknown>;\n /**\n * - **EN:** The callback after the confirmation event is completed, it will not be triggered when\n * it fails, the parameter is the return value of `onOk`\n * - **CN:** 确认事件完成后的回调,失败时不会触发,参数为`onOk`的返回值\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n afterOk?: (data?: any) => void;\n };\n\nexport interface FormCompPropsConstraint<FormData> {\n /**\n * - **EN:** Automatically generated form instance, use this form instance in FormComp, do not\n * create a new instance\n * - **CN:** 自动生成的表单实例,编辑表单要使用这个表单实例,不要新创建实例\n */\n form: FormInstance<FormData>;\n /**\n * - **EN:** Register the form save event, the callback function passed in will be called when the\n * confirm button is clicked, support asynchronous saving\n * - **CN:** 注册表单保存事件,传入的回调函数会在点击确认按钮时被调用,支持异步保存\n *\n * @param handler Event handler | 事件处理函数\n */\n onSave: (\n handler: (\n /**\n * - **EN:** Form data\n * - **CN:** 表单数据\n */\n formData: FormData,\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get\n * the value of the switch; for the `Button` type trigger, you can get the click event\n * object of the button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值;对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n ...triggerEventData: any[]\n ) => unknown | Promise<unknown>\n ) => void;\n /**\n * - **EN:** Listen to the open and close status of the dialog. When `destroyOnHidden` is set to\n * false, the form component instance is cached, and the dialog can only be listened to in this\n * way\n * - **CN:** 监听弹框打开关闭状态。当`destroyOnHidden`设置为false时,表单组件实例被缓存,只能通过这种方式监听弹框\n *\n * @param handler Event handler | 事件处理函数\n */\n onOpenChange: (handler: ModalProps['afterOpenChange']) => void;\n /**\n * - **EN:** Set the dialog open status\n * - **CN:** 设置弹框打开状态\n *\n * @param open Whether is open or not | 弹窗是否打开\n */\n setOpen: (open: boolean) => void;\n /**\n * - **EN:** Modify the properties of the dialog, such as title, width, button properties, etc.\n * - **CN:** 修改弹窗的属性,例如标题、宽度,按钮属性等\n */\n updateModalProps: (props: Partial<ModalProps>) => void;\n /**\n * - **EN:** Trigger click event data, for example, for the `Switch` type trigger, you can get the\n * value of the switch; for the `Button` type trigger, you can get the click event object of the\n * button\n * - **CN:** 触发器点击的事件数据,例如,对于`Switch`类型的触发器,可以获取点击开关的值,对于`Button`类型的触发器,可以获取按钮的点击事件对象\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n triggerEventData?: any[];\n}\n\nexport interface ModalActionTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n> {\n /**\n * - **EN:** Trigger component, click to show the dialog\n * - **CN:** 弹窗触发器组件,点击触发显示弹框\n */\n triggerComponent?: ComponentType<TriggerProp> | FC<TriggerProp>;\n /**\n * - **EN:** Props of the trigger component\n * - **CN:** 触发器组件的Props属性\n */\n triggerProps?: TriggerProp & {\n /**\n * - **EN:** Set a custom function to determine whether to show the trigger button\n * - **CN:** 设置一个自定义函数,用于判断是否显示触发器按钮\n *\n * @default true\n *\n * @param formProps Form component props | 表单组件的props\n */\n show?: boolean | ((formProps?: Omit<P, keyof FormCompPropsConstraint<FormData>>) => boolean);\n };\n /**\n * - **EN:** The event name that triggers the dialog\n * - **CN:** 触发弹窗的事件名称\n * - `Button`: 'onClick'\n * - `Switch`: 'onChange'\n * - `Link`: 'onClick'\n */\n triggerEvent?: Event;\n /**\n * - **EN:** Custom trigger content\n * - **CN:** 自定义触发器内容\n */\n children?: ReactNode;\n}\n// eslint-disable-next-line @typescript-eslint/ban-types, @typescript-eslint/no-explicit-any\nexport type ModalActionRef<R = {}, FormData extends object = any> = R & {\n form: FormInstance<FormData> | undefined;\n /**\n * - **EN:** Show the dialog\n * - **CN:** 显示弹框\n */\n show: () => void;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const genModalActionRenderer = (defaultProps: Partial<ModalActionProps<any, any, any, never, never>>) => {\n const ModalActionRenderer = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n >(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n ref: ForwardedRef<ModalActionRef<Ref, FormData>>\n ) => {\n const [userModalProps, setUserModalProps] = useState<Partial<ModalProps>>({});\n let mergedProps = mergeProps<FormData, P, TriggerProp, Event, Ref>(defaultProps, props);\n mergedProps = mergeProps(mergedProps, userModalProps as typeof props);\n const {\n formComp,\n formProps,\n triggerComponent: Trigger = Button,\n triggerEvent = 'onClick' as Event,\n triggerProps,\n open: openInProps,\n destroyOnClose = true,\n destroyOnHidden = true,\n maskClosable = false,\n okButtonProps,\n cancelButtonProps,\n onOk,\n afterOk,\n onCancel,\n afterClose,\n children,\n ...restProps\n } = mergedProps;\n useContextValidator();\n const FormComp = formComp as ComponentType<FormCompPropsConstraint<FormData> & RefAttributes<Ref>>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const triggerEventArgsRef = useRef<any[]>(undefined);\n const [open, setOpen] = useState(false);\n const saveFuncRef = useRef<(formData: FormData, ...args: any[]) => unknown>(undefined);\n const [isSaving, setIsSaving] = useState(false);\n const [formCompRef, setFormCompRef] = useState<Ref | null>(null);\n const [form, setForm] = useState<FormInstance<FormData>>();\n const formRef = useRef<FormInstance<FormData>>(form);\n formRef.current = form;\n const destroyOnCloseRef = useRef(destroyOnClose);\n destroyOnCloseRef.current = destroyOnClose || destroyOnHidden;\n const openListenerRef = useRef<ModalProps['afterOpenChange']>(undefined);\n\n // Listen to the open props changes\n useEffect(() => {\n if (openInProps) {\n setOpen(openInProps);\n }\n }, [openInProps]);\n\n // Reset the form after closed\n useEffect(() => {\n if (!destroyOnCloseRef.current && open && formRef.current) {\n formRef.current.resetFields();\n }\n }, [open]);\n\n // show trigger\n const showInProps = triggerProps?.show;\n const showTrigger = useMemo(() => {\n if (typeof showInProps === 'boolean') {\n return showInProps;\n } else if (typeof showInProps === 'function') {\n return showInProps(formProps);\n }\n return true;\n }, [showInProps, formProps]);\n\n // Show the dialog\n const showModal = useCallback(() => {\n setOpen(true);\n openListenerRef.current?.(true);\n }, []);\n // Hide the dialog\n const hideModal = useCallback(() => {\n setOpen(false);\n openListenerRef.current?.(false);\n }, []);\n // Set the dialog status listener\n const setOpenListener = useCallback(\n (listener: ModalProps['afterOpenChange']) => {\n openListenerRef.current = listener;\n // Call once when initialized\n openListenerRef.current?.(open);\n },\n [open]\n );\n // Receive the onSave callback method passed by the form component\n const setOnSaveHandler: FormCompPropsConstraint<FormData>['onSave'] = useCallback((handler) => {\n saveFuncRef.current = handler;\n }, []);\n // Set the dialog status and trigger the onOpenChange event of the form component\n const handleSetOpen = useCallback((open: boolean) => {\n setOpen(open);\n openListenerRef.current?.(open);\n }, []);\n\n // Output ref\n useImperativeHandle(ref, () => ({ ...formCompRef, form, show: showModal }) as ModalActionRef<Ref, FormData>, [\n formCompRef,\n showModal,\n form,\n ]);\n\n // Render the trigger component\n return (\n <>\n {showTrigger && (\n <Trigger\n {...triggerProps}\n // Trigger event\n {...((triggerEvent\n ? {\n [triggerEvent]: (...args: any[]) => {\n triggerEventArgsRef.current = args;\n showModal();\n if (triggerProps && typeof triggerProps[triggerEvent] === 'function') {\n (triggerProps[triggerEvent] as (...args: any[]) => void)(...args);\n }\n },\n }\n : {}) as TriggerProp)}\n >\n {(triggerProps as { children?: ReactNode }).children ?? children}\n </Trigger>\n )}\n <Modal\n open={open}\n confirmLoading={isSaving}\n destroyOnClose={destroyOnClose}\n destroyOnHidden={destroyOnHidden}\n maskClosable={maskClosable}\n okButtonProps={{\n loading: isSaving,\n ...okButtonProps,\n }}\n cancelButtonProps={{\n disabled: isSaving,\n ...cancelButtonProps,\n }}\n onOk={async () => {\n let formData: FormData;\n try {\n formData = (await form?.validateFields()) as FormData;\n } catch (e) {\n // Validation error, should not throw error\n return;\n }\n if (Object.keys(formData).length === 0) {\n console.warn(\n 'form.getFieldsValue() is empty. Please use the form instance passed to formComp instead of creating the form instance yourself.'\n );\n }\n try {\n setIsSaving(true);\n // First call onSave of the form component\n let result = await saveFuncRef.current?.(formData, ...(triggerEventArgsRef.current ?? []));\n // The onSave of the form component has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // Then call onOk of the dialog, support asynchronous, and will pass the return value of onSave, if any\n if (onOk) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result = await onOk((result as FormData) ?? formData, ...((triggerEventArgsRef.current ?? []) as any));\n }\n // onOk also has the ability to prevent the dialog from closing\n if (result === SubmitWithoutClosingSymbol) {\n throw new Error('SubmitWithoutClosing');\n }\n // If onOK is successful, close the dialog and trigger the afterOk event\n hideModal();\n afterOk?.(result);\n } catch (error) {\n console.error(error);\n } finally {\n setIsSaving(false);\n }\n }}\n onCancel={async (e) => {\n hideModal();\n onCancel?.(e);\n }}\n afterClose={() => {\n hideModal();\n afterClose?.();\n }}\n {...restProps}\n >\n <FormCreator<FormData> onCreate={setForm} />\n {form && (\n <FormComp\n ref={isForwardRef(FormComp) ? setFormCompRef : undefined}\n {...formProps}\n form={form}\n onOpenChange={setOpenListener}\n onSave={setOnSaveHandler}\n triggerEventData={triggerEventArgsRef.current}\n setOpen={handleSetOpen}\n updateModalProps={setUserModalProps}\n />\n )}\n </Modal>\n </>\n );\n };\n return ModalActionRenderer;\n};\n\nfunction mergeProps<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n first?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>,\n second?: Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n) {\n return {\n ...first,\n ...second,\n okButtonProps: {\n ...first?.okButtonProps,\n ...second?.okButtonProps,\n },\n cancelButtonProps: {\n ...first?.cancelButtonProps,\n ...second?.cancelButtonProps,\n },\n bodyProps: {\n ...first?.bodyProps,\n ...second?.bodyProps,\n },\n maskProps: {\n ...first?.maskProps,\n ...second?.maskProps,\n },\n wrapProps: {\n ...first?.wrapProps,\n ...second?.wrapProps,\n },\n formProps: {\n ...first?.formProps,\n ...second?.formProps,\n },\n triggerProps: {\n ...first?.triggerProps,\n ...second?.triggerProps,\n style: {\n ...(first?.triggerProps && 'style' in first.triggerProps && typeof first.triggerProps.style === 'object'\n ? first.triggerProps.style\n : {}),\n ...(second?.triggerProps && 'style' in second.triggerProps && typeof second.triggerProps.style === 'object'\n ? second.triggerProps.style\n : {}),\n },\n },\n } as unknown as ModalActionProps<FormData, P, TriggerProp, Event, Ref>;\n}\n\nfunction FormCreator<FD extends object>(props: { onCreate: (form: FormInstance<FD> | undefined) => void }) {\n const { onCreate } = props;\n const onCreateRef = useRef(onCreate);\n onCreateRef.current = onCreate;\n const [form] = Form.useForm<FD>();\n\n // output ref\n useEffect(() => {\n onCreateRef.current(form);\n return () => {\n onCreateRef.current(undefined);\n };\n }, [form]);\n\n return null;\n}\n\n/**\n * - **EN:** Add default properties to the ModalAction component\n * - **CN:** 给ModalAction组件添加默认属性\n *\n * @param WrappedComponent ModalAction component | ModalAction组件\n * @param defaultProps Default properties | 默认属性\n */\nexport const withDefaultModalActionProps = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n WrappedComponent: ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n >,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>\n | ((\n /**\n * - **EN:** Actual properties passed to the ModalAction component\n * - **CN:** 实际传递给ModalAction组件的属性\n */\n actualProps: ModalActionProps<FormData, P, TriggerProp, Event, Ref>,\n /**\n * - **EN:** Ref of the ModalAction component. Note that this ref may be null because the\n * component has not been rendered yet when executed for the first time.\n * - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。\n */\n ref: ModalActionRef<Ref, FormData> | null\n ) => Partial<ModalActionProps<FormData, P, TriggerProp, Event, Ref>>)\n) => {\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref, FormData>,\n ModalActionProps<FormData, P, TriggerProp, Event, Ref>\n >((props, ref) => {\n const modalActionRef = useRef<ModalActionRef<Ref, FormData>>(null);\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props, modalActionRef.current);\n const mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n\n useImperativeHandle(ref, () => modalActionRef.current as ModalActionRef<Ref, FormData>, []);\n\n return <WrappedComponent ref={modalActionRef} {...mergedProps} />;\n });\n return WithDefaultProps;\n};\n\nconst renderModalAction = genModalActionRenderer({});\nconst forwardedModalAction = forwardRef(renderModalAction);\nforwardedModalAction.displayName = 'ForwardRef(ModalAction)';\n/**\n * - **EN:** ModalAction component type\n * - **CN:** ModalAction组件的类型\n */\nexport type ModalActionInterface<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n> = ComponentType<\n ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n>;\n/**\n * - **EN:** ModalAction component with generic type\n * - **CN:** ModalAction泛型组件的类型\n */\nexport type GenericModalActionInterface = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n>(\n props: ModalActionProps<FormData, P, TriggerProp, Event, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode;\n/**\n * - **EN:** ModalAction with specified trigger type (specified form component)\n * - **CN:** 已指定Trigger类型的ModalAction(并且已指定表单组件)\n */\ntype ModalActionWithTrigger<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n TriggerProp extends object,\n Event extends keyof TriggerProp,\n Ref extends object,\n OMIT extends string = never,\n> = ComponentType<\n Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n>;\n\n/**\n * - **EN:** ModalAction with specified trigger type (unspecified form component, keep generic)\n * - **CN:** 已指定Trigger类型的ModalAction(未指定表单组件,保持泛型)\n */\ntype GenericModalActionWithTrigger<TP extends object, E extends keyof TP, OMIT extends string = never> = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n>(\n props: Omit<ModalActionProps<FormData, P, TP, E, Ref>, 'triggerComponent' | 'triggerEvent' | OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode;\n\n/**\n * - **EN:** Built-in trigger types (specified form components)\n * - **CN:** 内置的几种触发器类型(已指定表单组件)\n */\nexport interface TypedTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: ModalActionWithTrigger<FormData, P, ButtonProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: ModalActionWithTrigger<FormData, P, SwitchProps, 'onChange', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: ModalActionWithTrigger<FormData, P, LinkProps, 'onClick', Ref, 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\n/**\n * - **EN:** Built-in trigger types (generic types, unspecified form components)\n * - **CN:** 内置的几种触发器类型(泛型类型,未指定表单组件)\n */\ninterface GenericTypedTriggers<OMIT extends string = never> {\n /**\n * - **EN:** Dialog with button type trigger\n * - **CN:** 按钮类型的弹窗\n */\n Button: GenericModalActionWithTrigger<ButtonProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with switch type trigger\n * - **CN:** 开关类型的弹窗\n */\n Switch: GenericModalActionWithTrigger<SwitchProps, 'onChange', 'triggerComponent' | 'triggerEvent' | OMIT>;\n /**\n * - **EN:** Dialog with link type trigger\n * - **CN:** 链接类型的弹窗\n */\n Link: GenericModalActionWithTrigger<LinkProps, 'onClick', 'triggerComponent' | 'triggerEvent' | OMIT>;\n}\ntype WithGenericTriggers<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n Ref extends object,\n OMIT extends string = never,\n> = (<TriggerProp extends object, Event extends keyof TriggerProp>(\n props: Omit<ModalActionProps<FormData, P, TriggerProp, Event, Ref>, OMIT> &\n RefAttributes<ModalActionRef<Ref, FormData>>\n) => ReactNode) &\n (P extends never ? GenericTypedTriggers<OMIT> : TypedTriggers<FormData, P, Ref, OMIT>);\n\n/**\n * - **EN:** Add trigger types to the ModalAction component\n * - **CN:** 给ModalAction组件添加子触发器类型\n */\nconst addTriggers = <\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n OMIT extends string = never,\n>(\n comp: ComponentType<\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref> & RefAttributes<ModalActionRef<Ref, FormData>>\n >\n) => {\n const patchedComp = comp as WithGenericTriggers<FormData, P, Ref, OMIT>;\n // Type of button trigger\n patchedComp.Button = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, ButtonProps, 'onClick', Ref>,\n {\n triggerComponent: Button,\n triggerEvent: 'onClick',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of switch trigger\n patchedComp.Switch = withDefaultModalActionProps(\n comp as ModalActionInterface<FormData, P, SwitchProps, 'onChange', Ref>,\n {\n triggerComponent: Switch,\n triggerEvent: 'onChange',\n triggerProps: {},\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // Type of link trigger\n patchedComp.Link = withDefaultModalActionProps(comp as ModalActionInterface<FormData, P, LinkProps, 'onClick', Ref>, {\n triggerComponent: Typography.Link,\n triggerEvent: 'onClick',\n triggerProps: {\n style: { whiteSpace: 'nowrap' },\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n return patchedComp;\n};\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nconst ModalAction = addTriggers(forwardedModalAction);\n\n/**\n * - **EN:** Dialog component with trigger\n * - **CN:** 带触发器的弹窗组件\n */\nexport type ModalActionWithStatic = typeof ModalAction & {\n /**\n * - **EN:** Symbol for not closing the dialog when submitting the form, which takes effect when\n * returning in the `onSave` event of the editing form component\n * - **CN:** 提交表单时不关闭弹框的Symbol,在编辑表单组件的`onSave`事件中返回时生效\n */\n SubmitWithoutClosing: symbol;\n};\n(ModalAction as ModalActionWithStatic).SubmitWithoutClosing = SubmitWithoutClosingSymbol;\n\n/**\n * - **EN:** Generate a dialog component based on the editing form component\n * - **CN:** 基于编辑表单组件生成一个弹框组件\n *\n * @template FormData Form data type | 表单数据类型\n * @template P Form component props type | 表单组件的props类型\n * @template OuterTriggerProp Outer trigger props type | 外部触发器的props类型\n * @template OuterEvent Outer trigger event type | 外部触发器的事件类型\n * @template Ref Form component ref type | 表单组件的ref类型\n *\n * @param formComp Component of dialog content | 弹窗内容组件\n * @param defaultProps Default properties of the dialog | 弹窗的默认属性\n */\nexport function withModalAction<\n FormData extends object,\n P extends FormCompPropsConstraint<FormData>,\n OuterTriggerProp extends object,\n OuterEvent extends keyof OuterTriggerProp,\n Ref extends object,\n>(\n formComp: ComponentType<P & FormCompPropsConstraint<FormData> & RefAttributes<Ref>>,\n defaultProps?:\n | Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>\n | ((\n /**\n * - **EN:** Actual properties passed to the ModalAction component\n * - **CN:** 实际传递给ModalAction组件的属性\n */\n actualProps: ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>,\n /**\n * - **EN:** Ref of the ModalAction component. Note that this ref may be null because the\n * component has not been rendered yet when executed for the first time.\n * - **CN:** ModalAction组件的ref对象。注意,该ref可能为null,因为第一次执行时组件还未渲染。\n */\n ref: ModalActionRef<Ref, FormData> | null\n ) => Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)\n) {\n const ForwardedModalAction = forwardedModalAction as unknown as ModalActionInterface<\n FormData,\n P,\n OuterTriggerProp,\n OuterEvent,\n Ref\n >;\n const WithDefaultProps = forwardRef<\n ModalActionRef<Ref, FormData>,\n ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>\n >((props, ref) => {\n const modalActionRef = useRef<ModalActionRef<Ref, FormData>>(null);\n const useDefaultProps = typeof defaultProps === 'function' ? defaultProps : () => defaultProps;\n const defaults = useDefaultProps(props, modalActionRef.current);\n const mergedProps = typeof defaultProps === 'function' ? mergeProps(props, defaults) : mergeProps(defaults, props);\n WithDefaultProps.displayName = 'ForwardRef(WithDefaultProps)';\n\n useImperativeHandle(ref, () => modalActionRef.current as ModalActionRef<Ref, FormData>, []);\n\n return (\n <ForwardedModalAction\n ref={modalActionRef}\n formComp={formComp}\n {...(mergedProps as Partial<ModalActionProps<FormData, P, OuterTriggerProp, OuterEvent, Ref>>)}\n />\n );\n });\n return addTriggers<FormData, P, OuterTriggerProp, OuterEvent, Ref, 'formComp'>(WithDefaultProps);\n}\n\nexport default ModalAction as ModalActionWithStatic;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAAmG;AAEnG,kBAAwD;AAExD,sBAA6B;AAC7B,iCAAgC;AAOzB,IAAM,6BAA6B,OAAO,sBAAsB;AAyJhE,IAAM,yBAAyB,CAAC,iBAAyE;AAC9G,QAAM,sBAAsB,CAO1B,OACA,QACG;AACH,UAAM,CAAC,gBAAgB,iBAAiB,QAAI,uBAA8B,CAAC,CAAC;AAC5E,QAAI,cAAc,WAAiD,cAAc,KAAK;AACtF,kBAAc,WAAW,aAAa,cAA8B;AACpE,UAAM;AAAA,MACJ;AAAA,MACA;AAAA,MACA,kBAAkB,UAAU;AAAA,MAC5B,eAAe;AAAA,MACf;AAAA,MACA,MAAM;AAAA,MACN,iBAAiB;AAAA,MACjB,kBAAkB;AAAA,MAClB,eAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,GAAG;AAAA,IACL,IAAI;AACJ,mCAAAA,SAAoB;AACpB,UAAM,WAAW;AAEjB,UAAM,0BAAsB,qBAAc,MAAS;AACnD,UAAM,CAAC,MAAM,OAAO,QAAI,uBAAS,KAAK;AACtC,UAAM,kBA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
}
|
package/lib/hooks/useMovable.js
CHANGED
|
@@ -42,6 +42,7 @@ var useMovable = (props) => {
|
|
|
42
42
|
const [savedPosition, savePosition] = (0, import_react_use.useLocalStorage)(storageKey ?? "");
|
|
43
43
|
const savePositionRef = (0, import_useRefValue.default)(savePosition);
|
|
44
44
|
const [position, setPosition] = (0, import_react.useState)(savedPosition ?? void 0);
|
|
45
|
+
const positionRef = (0, import_useRefValue.default)(position);
|
|
45
46
|
const draggingRef = (0, import_react.useRef)(false);
|
|
46
47
|
const dragOffsetRef = (0, import_react.useRef)({ x: 0, y: 0 });
|
|
47
48
|
const sizeRef = (0, import_react.useRef)({ w: 0, h: 0 });
|
|
@@ -65,20 +66,33 @@ var useMovable = (props) => {
|
|
|
65
66
|
e.preventDefault();
|
|
66
67
|
});
|
|
67
68
|
(0, import_react.useEffect)(() => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
setPosition(pos);
|
|
77
|
-
if (storageKeyRef.current) {
|
|
78
|
-
savePositionRef.current(pos);
|
|
69
|
+
const clampToViewport = () => {
|
|
70
|
+
var _a;
|
|
71
|
+
const pos = positionRef.current;
|
|
72
|
+
if (!pos)
|
|
73
|
+
return;
|
|
74
|
+
const rect = (_a = containerRef.current) == null ? void 0 : _a.getBoundingClientRect();
|
|
75
|
+
if (rect) {
|
|
76
|
+
sizeRef.current = { w: rect.width, h: rect.height };
|
|
79
77
|
}
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
const maxLeft = Math.max(0, window.innerWidth - sizeRef.current.w);
|
|
79
|
+
const maxTop = Math.max(0, window.innerHeight - sizeRef.current.h);
|
|
80
|
+
const clampedLeft = Math.min(Math.max(0, pos.left), maxLeft);
|
|
81
|
+
const clampedTop = Math.min(Math.max(0, pos.top), maxTop);
|
|
82
|
+
if (clampedLeft !== pos.left || clampedTop !== pos.top) {
|
|
83
|
+
const next = { left: clampedLeft, top: clampedTop };
|
|
84
|
+
setPosition(next);
|
|
85
|
+
if (storageKeyRef.current) {
|
|
86
|
+
savePositionRef.current(next);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
window.addEventListener("resize", clampToViewport);
|
|
91
|
+
clampToViewport();
|
|
92
|
+
return () => {
|
|
93
|
+
window.removeEventListener("resize", clampToViewport);
|
|
94
|
+
};
|
|
95
|
+
}, [containerRef]);
|
|
82
96
|
(0, import_react.useEffect)(() => {
|
|
83
97
|
const onMove = (e) => {
|
|
84
98
|
if (!draggingRef.current)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/hooks/useMovable.ts"],
|
|
4
|
-
"sourcesContent": ["import { type RefObject, useEffect, useRef, useState } from 'react';\nimport { useLocalStorage } from 'react-use';\nimport useRefFunction from './useRefFunction';\nimport useRefValue from './useRefValue';\n\nexport interface UseMovableProps {\n /**\n * - **EN:** Whether dragging is enabled, default is `true`\n * - **CN:** 是否启用拖动,默认`true`\n */\n enabled?: boolean;\n /**\n * - **EN:** The ref of the container element\n * - **CN:** 容器元素的ref\n */\n containerRef: RefObject<HTMLElement>;\n /**\n * - **EN:** Selectors of elements that should not trigger dragging, e.g., interactive controls\n * - **CN:** 不应触发拖动的元素的选择器,例如交互控件\n */\n ignoreSelectors?: string[];\n /**\n * - **EN:** Key for storing position in localStorage; if not provided, position won't be saved\n * - **CN:** 用于在 localStorage 中存储位置的键;如果未提供,则不会保存位置\n */\n storageKey?: string;\n}\n\n/**\n * - **EN:** Hook to make an element movable by dragging, with position persistence using localStorage\n * - **CN:** 通过拖动使元素可移动的钩子,并使用 localStorage 持久化位置\n */\nconst useMovable = (props: UseMovableProps) => {\n const { enabled, containerRef, ignoreSelectors, storageKey } = props;\n\n const storageKeyRef = useRefValue(storageKey);\n const [savedPosition, savePosition] = useLocalStorage<MovePosition>(storageKey ?? '');\n const savePositionRef = useRefValue(savePosition);\n const [position, setPosition] = useState<MovePosition | undefined>(savedPosition ?? undefined);\n const draggingRef = useRef(false);\n const dragOffsetRef = useRef({ x: 0, y: 0 });\n const sizeRef = useRef({ w: 0, h: 0 });\n\n // Drag start (exclude interactive controls)\n const handlePointerDown = useRefFunction((e: React.PointerEvent<HTMLDivElement>) => {\n const target = e.target as HTMLElement;\n // Set the selector for elements that do not trigger dragging\n if (ignoreSelectors && target.closest(ignoreSelectors.join(','))) return;\n\n if (!containerRef.current) return;\n const rect = containerRef.current.getBoundingClientRect();\n sizeRef.current = { w: rect.width, h: rect.height };\n const currentLeft = position?.left ?? rect.left;\n const currentTop = position?.top ?? rect.top;\n\n dragOffsetRef.current = { x: e.clientX - currentLeft, y: e.clientY - currentTop };\n draggingRef.current = true;\n try {\n containerRef.current.setPointerCapture?.(e.pointerId);\n } catch {\n // do nothing\n }\n e.preventDefault();\n });\n\n //
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4D;AAC5D,uBAAgC;AAChC,4BAA2B;AAC3B,yBAAwB;AA6BxB,IAAM,aAAa,CAAC,UAA2B;AAC7C,QAAM,EAAE,SAAS,cAAc,iBAAiB,WAAW,IAAI;AAE/D,QAAM,oBAAgB,mBAAAA,SAAY,UAAU;AAC5C,QAAM,CAAC,eAAe,YAAY,QAAI,kCAA8B,cAAc,EAAE;AACpF,QAAM,sBAAkB,mBAAAA,SAAY,YAAY;AAChD,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAmC,iBAAiB,MAAS;AAC7F,QAAM,kBAAc,qBAAO,KAAK;AAChC,QAAM,oBAAgB,qBAAO,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;AAC3C,QAAM,cAAU,qBAAO,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;AAGrC,QAAM,wBAAoB,sBAAAC,SAAe,CAAC,MAA0C;
|
|
4
|
+
"sourcesContent": ["import { type RefObject, useEffect, useRef, useState } from 'react';\nimport { useLocalStorage } from 'react-use';\nimport useRefFunction from './useRefFunction';\nimport useRefValue from './useRefValue';\n\nexport interface UseMovableProps {\n /**\n * - **EN:** Whether dragging is enabled, default is `true`\n * - **CN:** 是否启用拖动,默认`true`\n */\n enabled?: boolean;\n /**\n * - **EN:** The ref of the container element\n * - **CN:** 容器元素的ref\n */\n containerRef: RefObject<HTMLElement>;\n /**\n * - **EN:** Selectors of elements that should not trigger dragging, e.g., interactive controls\n * - **CN:** 不应触发拖动的元素的选择器,例如交互控件\n */\n ignoreSelectors?: string[];\n /**\n * - **EN:** Key for storing position in localStorage; if not provided, position won't be saved\n * - **CN:** 用于在 localStorage 中存储位置的键;如果未提供,则不会保存位置\n */\n storageKey?: string;\n}\n\n/**\n * - **EN:** Hook to make an element movable by dragging, with position persistence using localStorage\n * - **CN:** 通过拖动使元素可移动的钩子,并使用 localStorage 持久化位置\n */\nconst useMovable = (props: UseMovableProps) => {\n const { enabled, containerRef, ignoreSelectors, storageKey } = props;\n\n const storageKeyRef = useRefValue(storageKey);\n const [savedPosition, savePosition] = useLocalStorage<MovePosition>(storageKey ?? '');\n const savePositionRef = useRefValue(savePosition);\n const [position, setPosition] = useState<MovePosition | undefined>(savedPosition ?? undefined);\n const positionRef = useRefValue(position);\n const draggingRef = useRef(false);\n const dragOffsetRef = useRef({ x: 0, y: 0 });\n const sizeRef = useRef({ w: 0, h: 0 });\n\n // Drag start (exclude interactive controls)\n const handlePointerDown = useRefFunction((e: React.PointerEvent<HTMLDivElement>) => {\n const target = e.target as HTMLElement;\n // Set the selector for elements that do not trigger dragging\n if (ignoreSelectors && target.closest(ignoreSelectors.join(','))) return;\n\n if (!containerRef.current) return;\n const rect = containerRef.current.getBoundingClientRect();\n sizeRef.current = { w: rect.width, h: rect.height };\n const currentLeft = position?.left ?? rect.left;\n const currentTop = position?.top ?? rect.top;\n\n dragOffsetRef.current = { x: e.clientX - currentLeft, y: e.clientY - currentTop };\n draggingRef.current = true;\n try {\n containerRef.current.setPointerCapture?.(e.pointerId);\n } catch {\n // do nothing\n }\n e.preventDefault();\n });\n\n // 调整:在窗口 resize 时自动收敛位置,防止超出可视区域\n useEffect(() => {\n const clampToViewport = () => {\n const pos = positionRef.current;\n if (!pos) return;\n\n // Refresh the container size before each convergence to ensure accurate boundaries.\n const rect = containerRef.current?.getBoundingClientRect();\n if (rect) {\n sizeRef.current = { w: rect.width, h: rect.height };\n }\n\n const maxLeft = Math.max(0, window.innerWidth - sizeRef.current.w);\n const maxTop = Math.max(0, window.innerHeight - sizeRef.current.h);\n const clampedLeft = Math.min(Math.max(0, pos.left), maxLeft);\n const clampedTop = Math.min(Math.max(0, pos.top), maxTop);\n\n if (clampedLeft !== pos.left || clampedTop !== pos.top) {\n const next = { left: clampedLeft, top: clampedTop };\n setPosition(next);\n if (storageKeyRef.current) {\n savePositionRef.current(next);\n }\n }\n };\n\n window.addEventListener('resize', clampToViewport);\n // Calibrate immediately after the first mount/position change.\n clampToViewport();\n\n return () => {\n window.removeEventListener('resize', clampToViewport);\n };\n }, [containerRef]);\n\n // Update position during dragging; restrict within the visible area.\n useEffect(() => {\n const onMove = (e: PointerEvent) => {\n if (!draggingRef.current) return;\n const newLeft = e.clientX - dragOffsetRef.current.x;\n const newTop = e.clientY - dragOffsetRef.current.y;\n const maxLeft = Math.max(0, window.innerWidth - sizeRef.current.w);\n const maxTop = Math.max(0, window.innerHeight - sizeRef.current.h);\n const clampedLeft = Math.min(Math.max(0, newLeft), maxLeft);\n const clampedTop = Math.min(Math.max(0, newTop), maxTop);\n const pos = { left: clampedLeft, top: clampedTop };\n setPosition(pos);\n if (storageKeyRef.current) {\n savePositionRef.current(pos);\n }\n };\n const onUp = () => {\n if (draggingRef.current) draggingRef.current = false;\n };\n if (enabled) {\n window.addEventListener('pointermove', onMove);\n window.addEventListener('pointerup', onUp);\n window.addEventListener('pointercancel', onUp);\n }\n return () => {\n window.removeEventListener('pointermove', onMove);\n window.removeEventListener('pointerup', onUp);\n window.removeEventListener('pointercancel', onUp);\n };\n }, [enabled]);\n\n return {\n onPointerDown: handlePointerDown,\n position,\n };\n};\n\nexport interface MovePosition {\n left: number;\n top: number;\n}\n\nexport default useMovable;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA4D;AAC5D,uBAAgC;AAChC,4BAA2B;AAC3B,yBAAwB;AA6BxB,IAAM,aAAa,CAAC,UAA2B;AAC7C,QAAM,EAAE,SAAS,cAAc,iBAAiB,WAAW,IAAI;AAE/D,QAAM,oBAAgB,mBAAAA,SAAY,UAAU;AAC5C,QAAM,CAAC,eAAe,YAAY,QAAI,kCAA8B,cAAc,EAAE;AACpF,QAAM,sBAAkB,mBAAAA,SAAY,YAAY;AAChD,QAAM,CAAC,UAAU,WAAW,QAAI,uBAAmC,iBAAiB,MAAS;AAC7F,QAAM,kBAAc,mBAAAA,SAAY,QAAQ;AACxC,QAAM,kBAAc,qBAAO,KAAK;AAChC,QAAM,oBAAgB,qBAAO,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;AAC3C,QAAM,cAAU,qBAAO,EAAE,GAAG,GAAG,GAAG,EAAE,CAAC;AAGrC,QAAM,wBAAoB,sBAAAC,SAAe,CAAC,MAA0C;AA7CtF;AA8CI,UAAM,SAAS,EAAE;AAEjB,QAAI,mBAAmB,OAAO,QAAQ,gBAAgB,KAAK,GAAG,CAAC;AAAG;AAElE,QAAI,CAAC,aAAa;AAAS;AAC3B,UAAM,OAAO,aAAa,QAAQ,sBAAsB;AACxD,YAAQ,UAAU,EAAE,GAAG,KAAK,OAAO,GAAG,KAAK,OAAO;AAClD,UAAM,eAAc,qCAAU,SAAQ,KAAK;AAC3C,UAAM,cAAa,qCAAU,QAAO,KAAK;AAEzC,kBAAc,UAAU,EAAE,GAAG,EAAE,UAAU,aAAa,GAAG,EAAE,UAAU,WAAW;AAChF,gBAAY,U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