xph-crud 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1843 -1823
- package/dist/index.umd.cjs +8 -8
- package/dist/style.css +1 -1
- package/dist/types/common/src/componnets/dialog/components/headerBtns/index.d.ts +8 -4
- package/dist/types/common/src/componnets/dialog/components/minimizeDialog/index.d.ts +1 -0
- package/dist/types/common/src/componnets/dialog/hooks/index.d.ts +4 -2
- package/dist/types/common/src/componnets/dialog/hooks/useDialogActions.d.ts +1 -1
- package/dist/types/common/src/componnets/dialog/hooks/useDialogContentMaxHeight.d.ts +6 -5
- package/dist/types/common/src/componnets/dialog/hooks/useDialogFooter.d.ts +1 -1
- package/dist/types/common/src/componnets/dialog/hooks/useDialogProps.d.ts +19 -1
- package/dist/types/common/src/componnets/dialog/hooks/useDialogZoom.d.ts +3 -3
- package/dist/types/common/src/componnets/dialog/hooks/useDragDialog.d.ts +4 -2
- package/dist/types/common/src/componnets/dialog/hooks/useMinResizeRecord.d.ts +8 -0
- package/dist/types/common/src/componnets/dialog/hooks/useOnContainerSizeChange.d.ts +10 -7
- package/dist/types/common/src/componnets/dialog/hooks/usePopperContainerSize.d.ts +15 -0
- package/dist/types/common/src/componnets/dialog/hooks/useResizeDialog.d.ts +3 -2
- package/dist/types/common/src/componnets/dialog/types/dialog.d.ts +6 -3
- package/dist/types/table/src/components/crudFormDialog/index.d.ts +9 -1
- package/dist/types/table/src/types/crudFormDialog.d.ts +26 -3
- package/package.json +63 -63
- package/dist/types/common/src/componnets/dialog/hooks/useOnVisableChange.d.ts +0 -21
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { IDialogProps } from '../types';
|
|
2
2
|
|
|
3
3
|
declare const useDialogPorps: (dialogProps: IDialogProps) => {
|
|
4
|
-
dialogProps:
|
|
4
|
+
dialogProps: {
|
|
5
|
+
getPopperContainer: () => HTMLElement;
|
|
6
|
+
width?: number | undefined;
|
|
7
|
+
height?: number | undefined;
|
|
8
|
+
mask?: boolean | undefined;
|
|
9
|
+
title?: string | undefined;
|
|
10
|
+
okProps?: Omit<import('antd').ButtonProps, "children" | "onClick"> | undefined;
|
|
11
|
+
cancelProps?: Omit<import('antd').ButtonProps, "children" | "onClick"> | undefined;
|
|
12
|
+
okText?: string | undefined;
|
|
13
|
+
cancelText?: string | undefined;
|
|
14
|
+
onOk?: ((args: any) => Promise<void>) | undefined;
|
|
15
|
+
onCancel?: ((args: any) => Promise<void>) | undefined;
|
|
16
|
+
renderFooter?: (({ loading }: {
|
|
17
|
+
loading: boolean;
|
|
18
|
+
}) => import('react').ReactElement<any, string | import('react').JSXElementConstructor<any>>) | undefined;
|
|
19
|
+
renderTitle?: (() => import('react').ReactElement<any, string | import('react').JSXElementConstructor<any>>) | undefined;
|
|
20
|
+
onOpen?: (() => void) | undefined;
|
|
21
|
+
onClose?: (() => void) | undefined;
|
|
22
|
+
};
|
|
5
23
|
baseDialogProps: Partial<IDialogProps>;
|
|
6
24
|
};
|
|
7
25
|
export default useDialogPorps;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { IDialogChangeRecord } from '../hooks';
|
|
1
|
+
import { IDialogChangeRecord, IContainerSizeTarget } from '../hooks';
|
|
2
2
|
|
|
3
|
-
declare const useDialogZoom: ({
|
|
4
|
-
|
|
3
|
+
declare const useDialogZoom: ({ containerSizeTarget, dialogChangeRecord, close, setDialogSize, setDialogPosition, }: {
|
|
4
|
+
containerSizeTarget: React.MutableRefObject<IContainerSizeTarget>;
|
|
5
5
|
dialogChangeRecord: React.MutableRefObject<IDialogChangeRecord>;
|
|
6
6
|
close: () => void;
|
|
7
7
|
setDialogSize: (size: {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { IContainerSizeTarget } from '../hooks';
|
|
2
|
+
|
|
3
|
+
declare const useDragDialog: ({ containerSizeTarget, dialogHeaderRef, dialogRef, setDialogPosition, }: {
|
|
4
|
+
containerSizeTarget: React.MutableRefObject<IContainerSizeTarget>;
|
|
3
5
|
dialogHeaderRef: React.RefObject<HTMLDivElement>;
|
|
4
6
|
dialogRef: React.RefObject<HTMLDivElement>;
|
|
5
7
|
setDialogPosition: (position: {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const useMinResizeRecord: (visible: any, dialogRef: React.RefObject<HTMLDivElement>, dialogWidth: number | string, dialogHeight: number | string) => {
|
|
3
|
+
minResizeRecord: import('react').MutableRefObject<{
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
} | null>;
|
|
7
|
+
};
|
|
8
|
+
export default useMinResizeRecord;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { IDialogProps } from '../types';
|
|
2
2
|
|
|
3
|
-
declare const useOnContainerSizeChange: ({
|
|
4
|
-
visible: boolean;
|
|
3
|
+
declare const useOnContainerSizeChange: ({ container, dialogProps, baseDialogProps, }: {
|
|
5
4
|
container: HTMLElement;
|
|
6
|
-
dialogRef: React.RefObject<HTMLDivElement>;
|
|
7
5
|
dialogProps: IDialogProps;
|
|
8
6
|
baseDialogProps: IDialogProps;
|
|
9
7
|
}) => {
|
|
8
|
+
containerSizeTarget: import('react').MutableRefObject<import('./usePopperContainerSize').IContainerSizeTarget>;
|
|
10
9
|
parentResizeRecord: number;
|
|
11
10
|
initLeft: import('react').MutableRefObject<number>;
|
|
12
11
|
initTop: import('react').MutableRefObject<number>;
|
|
@@ -14,9 +13,13 @@ declare const useOnContainerSizeChange: ({ visible, container, dialogRef, dialog
|
|
|
14
13
|
initHeight: import('react').MutableRefObject<string | number>;
|
|
15
14
|
curPropsWidth: number;
|
|
16
15
|
curPropsHeight: string | number;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
16
|
+
setInitPosition: (position: {
|
|
17
|
+
left: number;
|
|
18
|
+
top: number;
|
|
19
|
+
}) => void;
|
|
20
|
+
setInitSize: (size: {
|
|
21
|
+
width: number | string;
|
|
22
|
+
height: number | string;
|
|
23
|
+
}) => void;
|
|
21
24
|
};
|
|
22
25
|
export default useOnContainerSizeChange;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/** 开启了mask后默认挂载到body,因为mask是固定定位,所以后续的所有计算都是基于innerWidth、innerHeight */
|
|
3
|
+
export interface IContainerSizeTarget {
|
|
4
|
+
clientWidth: number;
|
|
5
|
+
clientHeight: number;
|
|
6
|
+
scrollWidth: number;
|
|
7
|
+
scrollHeight: number;
|
|
8
|
+
}
|
|
9
|
+
declare const usePopperContainerSize: ({ container }: {
|
|
10
|
+
container: HTMLElement;
|
|
11
|
+
}) => {
|
|
12
|
+
containerSizeTarget: import('react').MutableRefObject<IContainerSizeTarget>;
|
|
13
|
+
setContainerSizeTarget: () => void;
|
|
14
|
+
};
|
|
15
|
+
export default usePopperContainerSize;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MouseEvent } from 'react';
|
|
2
|
+
import { IContainerSizeTarget } from '../hooks';
|
|
2
3
|
|
|
3
|
-
declare const useResizeDialog: ({
|
|
4
|
-
|
|
4
|
+
declare const useResizeDialog: ({ containerSizeTarget, dialogRef, minResizeRecord, setDialogSize, setDialogPosition, }: {
|
|
5
|
+
containerSizeTarget: React.MutableRefObject<IContainerSizeTarget>;
|
|
5
6
|
dialogRef: React.RefObject<HTMLDivElement>;
|
|
6
7
|
minResizeRecord: React.MutableRefObject<{
|
|
7
8
|
width: number;
|
|
@@ -10,10 +10,12 @@ export interface IDialogProps {
|
|
|
10
10
|
okText?: string;
|
|
11
11
|
cancelText?: string;
|
|
12
12
|
/** 点击确定按钮触发该事件 */
|
|
13
|
-
onOk?: () => void
|
|
13
|
+
onOk?: (args: any) => Promise<void>;
|
|
14
14
|
/** 点击取消按钮触发该事件 */
|
|
15
|
-
onCancel?: () => void
|
|
16
|
-
renderFooter?: (
|
|
15
|
+
onCancel?: (args: any) => Promise<void>;
|
|
16
|
+
renderFooter?: ({ loading }: {
|
|
17
|
+
loading: boolean;
|
|
18
|
+
}) => React.ReactElement;
|
|
17
19
|
renderTitle?: () => React.ReactElement;
|
|
18
20
|
/** 打开的时候会触发该事件 */
|
|
19
21
|
onOpen?: () => void;
|
|
@@ -25,4 +27,5 @@ export interface IDialogProps {
|
|
|
25
27
|
export interface IDialogActionType {
|
|
26
28
|
open: () => Promise<void>;
|
|
27
29
|
close: () => void;
|
|
30
|
+
setLoading: (loading: boolean) => void;
|
|
28
31
|
}
|
|
@@ -3,8 +3,16 @@ import { ICrudFormDialogActionType, TCrudFormDialogProps } from '../../types';
|
|
|
3
3
|
import { TXphExtendComponentPropsMap } from '../../../../common';
|
|
4
4
|
|
|
5
5
|
declare const CrudFormDialog: (props: TCrudFormDialogProps, ref: ForwardedRef<ICrudFormDialogActionType>) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
declare const ForwardedCrudFormDialog: <T extends TXphExtendComponentPropsMap = {}>(props: import('../../../../common').IXphDialogProps & {
|
|
6
|
+
declare const ForwardedCrudFormDialog: <T extends TXphExtendComponentPropsMap = {}>(props: Omit<import('../../../../common').IXphDialogProps, "onOk" | "onCancel"> & {
|
|
7
7
|
formProps: import('../../../../form').IXphFormProps<T>;
|
|
8
|
+
onOk?: (({ values, data }: {
|
|
9
|
+
values: any;
|
|
10
|
+
data: any;
|
|
11
|
+
}) => Promise<any>) | undefined;
|
|
12
|
+
onCancel?: (({ values, data }: {
|
|
13
|
+
values: any;
|
|
14
|
+
data: any;
|
|
15
|
+
}) => Promise<any>) | undefined;
|
|
8
16
|
} & {
|
|
9
17
|
ref?: ForwardedRef<ICrudFormDialogActionType> | undefined;
|
|
10
18
|
}) => ReturnType<typeof CrudFormDialog>;
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import { IXphFormProps, IXphFormActionType } from '../../../form';
|
|
2
2
|
import { TXphExtendComponentPropsMap, IXphDialogProps, IXphDialogActionType } from '../../../common';
|
|
3
3
|
|
|
4
|
-
export type TCrudFormDialogProps<T extends TXphExtendComponentPropsMap = {}> = IXphDialogProps & {
|
|
4
|
+
export type TCrudFormDialogProps<T extends TXphExtendComponentPropsMap = {}> = Omit<IXphDialogProps, "onOk" | "onCancel"> & {
|
|
5
5
|
formProps: IXphFormProps<T>;
|
|
6
|
+
onOk?: ({ values, data }: {
|
|
7
|
+
values: any;
|
|
8
|
+
data: any;
|
|
9
|
+
}) => Promise<any>;
|
|
10
|
+
onCancel?: ({ values, data }: {
|
|
11
|
+
values: any;
|
|
12
|
+
data: any;
|
|
13
|
+
}) => Promise<any>;
|
|
6
14
|
};
|
|
7
|
-
export interface
|
|
8
|
-
|
|
15
|
+
export interface IOpenActionConfig {
|
|
16
|
+
/** 回填表单的内容 */
|
|
17
|
+
data: any;
|
|
18
|
+
/**
|
|
19
|
+
* @description 点击确定的回调(如果弹窗传递了onOk属性就不用传这个了,这个是为了方便所有操作都在open函数中处理)
|
|
20
|
+
* @param values 表单项的值(如果弹窗传递了onCancel属性就不用传这个了,这个是为了方便所有操作都在close函数中处理)
|
|
21
|
+
*/
|
|
22
|
+
ok?: ({ values }: {
|
|
23
|
+
values: any;
|
|
24
|
+
}) => Promise<any>;
|
|
25
|
+
/** 点击取消的回调 */
|
|
26
|
+
cancel?: ({ values }: {
|
|
27
|
+
values: any;
|
|
28
|
+
}) => Promise<any>;
|
|
29
|
+
}
|
|
30
|
+
export interface ICrudFormDialogActionType extends IXphFormActionType, Omit<IXphDialogActionType, "open"> {
|
|
31
|
+
open: (config: IOpenActionConfig) => Promise<void>;
|
|
9
32
|
}
|
package/package.json
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "xph-crud",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/types/index.d.ts",
|
|
7
|
-
"description": "This is a configurable component library based on React",
|
|
8
|
-
"keywords": [
|
|
9
|
-
"react",
|
|
10
|
-
"ant-design",
|
|
11
|
-
"configurable-component"
|
|
12
|
-
],
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
},
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
},
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
"
|
|
62
|
-
}
|
|
63
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "xph-crud",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"description": "This is a configurable component library based on React",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"react",
|
|
10
|
+
"ant-design",
|
|
11
|
+
"configurable-component"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"@ant-design/icons": "5.3.2",
|
|
19
|
+
"antd": "^5.14.2",
|
|
20
|
+
"react": "^18.2.0",
|
|
21
|
+
"react-dom": "^18.2.0"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"dayjs": "^1.11.10",
|
|
25
|
+
"lodash-es": "^4.17.21"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/lodash-es": "^4.17.12",
|
|
29
|
+
"@types/node": "^20.14.2",
|
|
30
|
+
"@types/react": "^18.2.66",
|
|
31
|
+
"@types/react-dom": "^18.2.22",
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
33
|
+
"@typescript-eslint/parser": "^7.2.0",
|
|
34
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
35
|
+
"eslint": "^8.57.0",
|
|
36
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
37
|
+
"eslint-plugin-react-refresh": "^0.4.6",
|
|
38
|
+
"typescript": "^5.2.2",
|
|
39
|
+
"vite": "^5.2.0",
|
|
40
|
+
"vite-plugin-dts": "^3.9.1"
|
|
41
|
+
},
|
|
42
|
+
"license": "ISC",
|
|
43
|
+
"author": "XiaoPiHong",
|
|
44
|
+
"homepage": "https://github.com/XiaoPiHong/xph-crud",
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/XiaoPiHong/xph-crud/issues",
|
|
47
|
+
"email": "260094892@qq.com"
|
|
48
|
+
},
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/XiaoPiHong/xph-crud.git"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=16"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"examples": "vite",
|
|
58
|
+
"build": "tsc && vite build",
|
|
59
|
+
"docs": "cd docs && npm run start",
|
|
60
|
+
"build:docs": "cd docs && npm run build",
|
|
61
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
declare const useOnVisableChange: ({ visible, initWidth, initHeight, initLeft, initTop, minResizeRecord, dialogRef, setDialogSize, setDialogPosition, }: {
|
|
2
|
-
visible: boolean;
|
|
3
|
-
initWidth: React.MutableRefObject<string | number>;
|
|
4
|
-
initHeight: React.MutableRefObject<string | number>;
|
|
5
|
-
initLeft: React.MutableRefObject<number>;
|
|
6
|
-
initTop: React.MutableRefObject<number>;
|
|
7
|
-
minResizeRecord: React.MutableRefObject<{
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
} | null>;
|
|
11
|
-
dialogRef: React.RefObject<HTMLDivElement>;
|
|
12
|
-
setDialogSize: (size: {
|
|
13
|
-
width?: number | string;
|
|
14
|
-
height?: number | string;
|
|
15
|
-
}) => void;
|
|
16
|
-
setDialogPosition: (position: {
|
|
17
|
-
left?: number;
|
|
18
|
-
top?: number;
|
|
19
|
-
}) => void;
|
|
20
|
-
}) => void;
|
|
21
|
-
export default useOnVisableChange;
|