xph-crud 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/index.js +2751 -2074
  2. package/dist/index.umd.cjs +9 -9
  3. package/dist/style.css +1 -1
  4. package/dist/types/common/src/componnets/actions/types/actions.d.ts +2 -0
  5. package/dist/types/common/src/componnets/dialog/components/headerBtns/index.d.ts +17 -0
  6. package/dist/types/common/src/componnets/dialog/components/minimizeDialog/index.d.ts +12 -0
  7. package/dist/types/common/src/componnets/dialog/dialog.d.ts +12 -2
  8. package/dist/types/common/src/componnets/dialog/hooks/index.d.ts +28 -0
  9. package/dist/types/common/src/componnets/dialog/hooks/useDialogActions.d.ts +7 -0
  10. package/dist/types/common/src/componnets/dialog/hooks/useDialogChangeRecord.d.ts +12 -0
  11. package/dist/types/common/src/componnets/dialog/hooks/useDialogContentMaxHeight.d.ts +13 -0
  12. package/dist/types/common/src/componnets/dialog/hooks/useDialogFooter.d.ts +6 -0
  13. package/dist/types/common/src/componnets/dialog/hooks/useDialogPosition.d.ts +14 -0
  14. package/dist/types/common/src/componnets/dialog/hooks/useDialogProps.d.ts +7 -0
  15. package/dist/types/common/src/componnets/dialog/hooks/useDialogSize.d.ts +19 -0
  16. package/dist/types/common/src/componnets/dialog/hooks/useDialogZoom.d.ts +23 -0
  17. package/dist/types/common/src/componnets/dialog/hooks/useDragDialog.d.ts +10 -0
  18. package/dist/types/common/src/componnets/dialog/hooks/useExtendDialog.d.ts +4 -0
  19. package/dist/types/common/src/componnets/dialog/hooks/useMinimizeDialog.d.ts +11 -0
  20. package/dist/types/common/src/componnets/dialog/hooks/useOnPropsSizeChange.d.ts +17 -0
  21. package/dist/types/common/src/componnets/dialog/hooks/useResizeDialog.d.ts +23 -0
  22. package/dist/types/common/src/componnets/dialog/hooks/useTopShowDialog.d.ts +13 -0
  23. package/dist/types/common/src/componnets/dialog/types/dialog.d.ts +21 -2
  24. package/dist/types/common/src/componnets/dialog/types/index.d.ts +1 -0
  25. package/dist/types/common/src/componnets/index.d.ts +3 -1
  26. package/dist/types/common/src/componnets/portal/portal.d.ts +7 -0
  27. package/dist/types/common/src/hooks/useExtendCompProps.d.ts +3 -0
  28. package/dist/types/table/index.d.ts +3 -2
  29. package/dist/types/table/src/components/crudFormDialog/index.d.ts +11 -0
  30. package/dist/types/table/src/components/searchForm/index.d.ts +1 -1
  31. package/dist/types/table/src/components/table/index.d.ts +2 -2
  32. package/dist/types/table/src/hooks/index.d.ts +2 -0
  33. package/dist/types/table/src/hooks/useCrudFormDialog.d.ts +7 -0
  34. package/dist/types/table/src/types/apiTable.d.ts +7 -1
  35. package/dist/types/table/src/types/crudFormDialog.d.ts +8 -0
  36. package/dist/types/table/src/types/index.d.ts +1 -1
  37. package/dist/types/table/src/types/table.d.ts +5 -10
  38. package/package.json +1 -1
  39. package/dist/types/table/src/components/searchForm/components/cacheForm/index.d.ts +0 -6
  40. package/dist/types/table/src/types/crudForm.d.ts +0 -4
@@ -0,0 +1,7 @@
1
+ import { IDialogProps } from '../types';
2
+
3
+ declare const useDialogPorps: (dialogProps: IDialogProps) => {
4
+ dialogProps: IDialogProps;
5
+ baseDialogProps: Partial<IDialogProps>;
6
+ };
7
+ export default useDialogPorps;
@@ -0,0 +1,19 @@
1
+ import { IDialogProps } from '../types';
2
+ import { IDialogChangeRecord } from '../hooks';
3
+
4
+ /**
5
+ * @description 首次打开弹窗的时候,限制弹窗的宽高(不得大于弹窗容器可视区域的宽高)
6
+ */
7
+ declare const useDialogInitSize: (container: HTMLElement, baseDialogProps: IDialogProps, dialogProps: IDialogProps, setDialogChangeRecord: ({ left, top, width, height, }: IDialogChangeRecord) => void) => {
8
+ dialogWidth: string | number;
9
+ dialogHeight: string | number;
10
+ initWidth: import('react').MutableRefObject<string | number>;
11
+ initHeight: import('react').MutableRefObject<string | number>;
12
+ curPropsWidth: number;
13
+ curPropsHeight: string | number;
14
+ setDialogSize: ({ width: newWidth, height: newHeight, }: {
15
+ width?: string | number | undefined;
16
+ height?: string | number | undefined;
17
+ }) => void;
18
+ };
19
+ export default useDialogInitSize;
@@ -0,0 +1,23 @@
1
+ import { IDialogChangeRecord } from '../hooks';
2
+
3
+ declare const useDialogZoom: ({ container, dialogChangeRecord, close, setDialogSize, setDialogPosition, }: {
4
+ container: HTMLElement;
5
+ dialogChangeRecord: React.MutableRefObject<IDialogChangeRecord>;
6
+ close: () => void;
7
+ setDialogSize: (size: {
8
+ width: number | string;
9
+ height: number | string;
10
+ }) => void;
11
+ setDialogPosition: (position: {
12
+ left: number;
13
+ top: number;
14
+ }) => void;
15
+ }) => {
16
+ minimizeVisible: boolean;
17
+ maximizeVisible: boolean;
18
+ onMinimize: () => void;
19
+ onMaximize: (type: "minimize" | "maximize") => void;
20
+ onRecovery: () => void;
21
+ onClose: () => void;
22
+ };
23
+ export default useDialogZoom;
@@ -0,0 +1,10 @@
1
+ declare const useDragDialog: ({ container, dialogHeaderRef, dialogRef, setDialogPosition, }: {
2
+ container: HTMLElement;
3
+ dialogHeaderRef: React.RefObject<HTMLDivElement>;
4
+ dialogRef: React.RefObject<HTMLDivElement>;
5
+ setDialogPosition: (position: {
6
+ left: number;
7
+ top: number;
8
+ }) => void;
9
+ }) => {};
10
+ export default useDragDialog;
@@ -0,0 +1,4 @@
1
+ declare const useExtendDialog: () => {
2
+ extendDialogProps: import('../types/dialog').IDialogProps | undefined;
3
+ };
4
+ export default useExtendDialog;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ declare const useMinimizeDialog: () => {
3
+ minimizeTop: number;
4
+ minimizeLeft: number;
5
+ minimizeRef: import('react').RefObject<HTMLDivElement>;
6
+ setMinimizePosition: ({ left, top, }: {
7
+ left?: number | undefined;
8
+ top?: number | undefined;
9
+ }) => void;
10
+ };
11
+ export default useMinimizeDialog;
@@ -0,0 +1,17 @@
1
+ declare const useOnPropsSizeChange: ({ visible, container, initWidth, initHeight, curPropsWidth, curPropsHeight, setDialogSize, setDialogPosition, }: {
2
+ visible: boolean;
3
+ container: HTMLElement;
4
+ initWidth: React.MutableRefObject<string | number>;
5
+ initHeight: React.MutableRefObject<string | number>;
6
+ curPropsWidth: number | string;
7
+ curPropsHeight: number | string;
8
+ setDialogSize: (size: {
9
+ width?: number | string;
10
+ height?: number | string;
11
+ }) => void;
12
+ setDialogPosition: (position: {
13
+ left?: number;
14
+ top?: number;
15
+ }) => void;
16
+ }) => void;
17
+ export default useOnPropsSizeChange;
@@ -0,0 +1,23 @@
1
+ import { MouseEvent } from 'react';
2
+
3
+ declare const useResizeDialog: ({ visible, container, dialogRef, setDialogSize, setDialogPosition, }: {
4
+ visible: boolean;
5
+ container: HTMLElement;
6
+ dialogRef: React.RefObject<HTMLDivElement>;
7
+ setDialogSize: (size: {
8
+ width: number | string;
9
+ height: number | string;
10
+ }) => void;
11
+ setDialogPosition: (position: {
12
+ left: number;
13
+ top: number;
14
+ }) => void;
15
+ }) => {
16
+ resizingState: boolean;
17
+ DashedBox: () => import("react/jsx-runtime").JSX.Element;
18
+ onMousedownResizeLt: (event: MouseEvent) => void;
19
+ onMousedownResizeRt: (event: MouseEvent) => void;
20
+ onMousedownResizeRb: (event: MouseEvent) => void;
21
+ onMousedownResizeLb: (event: MouseEvent) => void;
22
+ };
23
+ export default useResizeDialog;
@@ -0,0 +1,13 @@
1
+ declare const useTopShowDialog: ({ visible, dialogRef, minimizeRef, container, }: {
2
+ visible: boolean;
3
+ dialogRef: React.RefObject<HTMLDivElement>;
4
+ minimizeRef: React.RefObject<HTMLDivElement>;
5
+ container: HTMLElement;
6
+ }) => {
7
+ dialogTopShowClassConfig: {
8
+ xphDialog: string;
9
+ xphDialogWrapper: string;
10
+ xphMinimizeDialog: string;
11
+ };
12
+ };
13
+ export default useTopShowDialog;
@@ -1,9 +1,28 @@
1
+ import { ButtonProps } from 'antd';
2
+
1
3
  export interface IDialogProps {
2
- visible?: boolean;
4
+ width?: number;
5
+ height?: number;
6
+ mask?: boolean;
3
7
  title?: string;
4
- content?: string;
8
+ okProps?: Omit<ButtonProps, "children" | "onClick">;
9
+ cancelProps?: Omit<ButtonProps, "children" | "onClick">;
5
10
  okText?: string;
6
11
  cancelText?: string;
12
+ /** 点击确定按钮触发该事件 */
7
13
  onOk?: () => void;
14
+ /** 点击取消按钮触发该事件 */
8
15
  onCancel?: () => void;
16
+ renderFooter?: () => React.ReactElement;
17
+ renderTitle?: () => React.ReactElement;
18
+ /** 打开的时候会触发该事件 */
19
+ onOpen?: () => void;
20
+ /** 关闭的时候会触发该事件 */
21
+ onClose?: () => void;
22
+ /** 挂载弹窗的容器,默认是body */
23
+ getPopperContainer?: () => HTMLElement | null;
24
+ }
25
+ export interface IDialogActionType {
26
+ open: () => void;
27
+ close: () => void;
9
28
  }
@@ -0,0 +1 @@
1
+ export * from './dialog';
@@ -1,5 +1,7 @@
1
1
  import { default as XphActions } from './actions/actions';
2
2
  import { TActionItemProps as TXphActionItemProps, IActionsProps as IXphActionsProps } from './actions/types';
3
3
  import { default as XphDialog } from './dialog/dialog';
4
+ import { IDialogProps as IXphDialogProps, IDialogActionType as IXphDialogActionType } from './dialog/types';
5
+ import { default as XphPortal } from './portal/portal';
4
6
 
5
- export { XphActions, TXphActionItemProps, IXphActionsProps, XphDialog };
7
+ export { XphActions, TXphActionItemProps, IXphActionsProps, XphDialog, IXphDialogProps, IXphDialogActionType, XphPortal, };
@@ -0,0 +1,7 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare const Portal: ({ children, getPopperContainer, }: {
4
+ children: React.ReactElement;
5
+ getPopperContainer: () => HTMLElement | null;
6
+ }) => React.ReactPortal | null;
7
+ export default Portal;
@@ -2,6 +2,7 @@ import { default as React } from 'react';
2
2
  import { IXphActionsProps } from '../componnets';
3
3
  import { IXphFormProps } from '../../../form';
4
4
  import { TXphTableProps } from '../../../table';
5
+ import { IXphDialogProps } from '../..';
5
6
 
6
7
  export interface IExtendProps {
7
8
  /** 表单的属性 */
@@ -10,6 +11,8 @@ export interface IExtendProps {
10
11
  table?: TXphTableProps;
11
12
  /** 操作组的属性 */
12
13
  actions?: IXphActionsProps;
14
+ /** 弹窗的属性 */
15
+ dialog?: IXphDialogProps;
13
16
  }
14
17
  export interface IExtendComp {
15
18
  /** 扩展的表单项 */
@@ -1,4 +1,5 @@
1
1
  import { default as XphTable } from './src/table';
2
- import { TTableProps as TXphTableProps, TTableActionType as TXphTableActionType, TDataSourceItem as TXphDataSourceItem, TColumnProps as TXphColumnProps, TApiTableProps as TXphApiTableProps, TSearchFormProps as TXphSearchFormProps, TCrudFormProps as TXphCrudFormProps, IMainProps as IXphMainProps } from './src/types';
2
+ import { default as XphCrudFormDialog } from './src/components/crudFormDialog';
3
+ import { TTableProps as TXphTableProps, TTableActionType as TXphTableActionType, TDataSourceItem as TXphDataSourceItem, TColumnProps as TXphColumnProps, TApiTableProps as TXphApiTableProps, TSearchFormProps as TXphSearchFormProps, IMainProps as IXphMainProps, TCrudFormDialogProps as TXphCrudFormDialogProps } from './src/types';
3
4
 
4
- export { XphTable, TXphTableProps, TXphTableActionType, TXphDataSourceItem, TXphColumnProps, TXphApiTableProps, TXphSearchFormProps, TXphCrudFormProps, IXphMainProps, };
5
+ export { XphTable, TXphTableProps, TXphTableActionType, TXphDataSourceItem, TXphColumnProps, TXphApiTableProps, TXphSearchFormProps, IXphMainProps, XphCrudFormDialog, TXphCrudFormDialogProps, };
@@ -0,0 +1,11 @@
1
+ import { ForwardedRef } from 'react';
2
+ import { ICrudFormDialogActionType, TCrudFormDialogProps } from '../../types';
3
+ import { TXphExtendComponentPropsMap } from '../../../../common';
4
+
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 & {
7
+ formProps: import('../../../../form').IXphFormProps<T>;
8
+ } & {
9
+ ref?: ForwardedRef<ICrudFormDialogActionType> | undefined;
10
+ }) => ReturnType<typeof CrudFormDialog>;
11
+ export default ForwardedCrudFormDialog;
@@ -1,7 +1,7 @@
1
1
  import { RefObject } from 'react';
2
2
  import { TTableActionType, TSearchFormActionType } from '../../types';
3
3
 
4
- declare const SearchForm: import('react').ForwardRefExoticComponent<import('../../../..').IXphFormProps<{}> & {
4
+ declare const SearchForm: import('react').ForwardRefExoticComponent<import('../../../../form').IXphFormProps<{}> & {
5
5
  showSearch?: boolean | undefined;
6
6
  } & {
7
7
  tableRef: RefObject<TTableActionType>;
@@ -1,9 +1,9 @@
1
1
  import { RefObject } from 'react';
2
- import { TTableProps, TSearchFormActionType, TTableActionType } from '../../types';
2
+ import { TTableProps, TSearchFormActionType, TApiTableActionType } from '../../types';
3
3
 
4
4
  declare const Table: import('react').ForwardRefExoticComponent<{
5
5
  fullHeight?: boolean | undefined;
6
6
  tableProps: TTableProps;
7
7
  searchFormRef: RefObject<TSearchFormActionType>;
8
- } & import('react').RefAttributes<TTableActionType>>;
8
+ } & import('react').RefAttributes<TApiTableActionType>>;
9
9
  export default Table;
@@ -16,3 +16,5 @@ export { default as useTopToolbar } from './useTopToolbar';
16
16
  export * from './useTopToolbar';
17
17
  export { default as useExtendTable } from './useExtendTable';
18
18
  export * from './useExtendTable';
19
+ export { default as useCrudFormDialog } from './useCrudFormDialog';
20
+ export * from './useCrudFormDialog';
@@ -0,0 +1,7 @@
1
+ import { TTableProps, ICrudFormDialogActionType } from '../types';
2
+
3
+ declare const useCrudFormDialog: ({ crudFormDialog }: TTableProps) => {
4
+ crudFormDialogRef: import('react').RefObject<ICrudFormDialogActionType>;
5
+ crudFormProps: import('../types').TCrudFormDialogProps<{}> | undefined;
6
+ };
7
+ export default useCrudFormDialog;
@@ -1,8 +1,9 @@
1
1
  import { TableProps, PaginationProps } from 'antd';
2
+ import { TableRef } from 'antd/es/table';
2
3
  import { TableRowSelection, RowSelectionType } from 'antd/lib/table/interface';
3
- import { IXphActionsProps, TXphExtendComponentPropsMap } from '../../../common';
4
4
  import { TDataSourceItem } from './table';
5
5
  import { TColumnProps } from './column';
6
+ import { TXphExtendComponentPropsMap, IXphActionsProps } from '../../../common';
6
7
 
7
8
  export interface IFunctionToolbarParams<T = TDataSourceItem> {
8
9
  loading: boolean;
@@ -33,3 +34,8 @@ export type TApiTableProps<T = TDataSourceItem, J extends TXphExtendComponentPro
33
34
  } & Omit<TableProps<T>,
34
35
  /** 内部控制的属性/重写的属性 */
35
36
  "rowSelection" | "columns" | "loading" | "dataSource" | "pagination">;
37
+ export type TApiTableActionType = {
38
+ resetAllData: () => Promise<void>;
39
+ resetData: () => Promise<void>;
40
+ reloadData: () => Promise<void>;
41
+ } & TableRef;
@@ -0,0 +1,8 @@
1
+ import { IXphFormProps, IXphFormActionType } from '../../../form';
2
+ import { TXphExtendComponentPropsMap, IXphDialogProps, IXphDialogActionType } from '../../../common';
3
+
4
+ export type TCrudFormDialogProps<T extends TXphExtendComponentPropsMap = {}> = IXphDialogProps & {
5
+ formProps: IXphFormProps<T>;
6
+ };
7
+ export interface ICrudFormDialogActionType extends IXphFormActionType, IXphDialogActionType {
8
+ }
@@ -1,6 +1,6 @@
1
1
  export * from './table';
2
2
  export * from './searchForm';
3
- export * from './crudForm';
3
+ export * from './crudFormDialog';
4
4
  export * from './apiTable';
5
5
  export * from './column';
6
6
  export * from '../components/table/components/cellFunc/types';
@@ -1,7 +1,6 @@
1
- import { TableRef } from 'antd/es/table';
2
1
  import { TSearchFormProps } from './searchForm';
3
- import { TCrudFormProps } from './crudForm';
4
- import { TApiTableProps } from './apiTable';
2
+ import { ICrudFormDialogActionType, TCrudFormDialogProps } from './crudFormDialog';
3
+ import { TApiTableProps, TApiTableActionType } from './apiTable';
5
4
  import { TXphExtendComponentPropsMap } from '../../../common';
6
5
 
7
6
  /** 行数据 */
@@ -22,15 +21,11 @@ FormExtendPropsMap extends TXphExtendComponentPropsMap = {}> = {
22
21
  table?: TApiTableProps<RecordType, CellFuncExtendPropsMap, ActionsExtendPropsMap, ToolbarExtendPropsMap>;
23
22
  /** 搜索表单配置项 */
24
23
  searchForm?: TSearchFormProps<FormExtendPropsMap>;
25
- /** 新增 / 修改表单配置项 */
26
- crudForm?: TCrudFormProps<FormExtendPropsMap>;
24
+ /** (新增 / 修改)表单弹窗配置项 */
25
+ crudFormDialog?: TCrudFormDialogProps<FormExtendPropsMap>;
27
26
  /** 分页改变事件 */
28
27
  onPaginationChange?: (page: number, pageSize: number) => void;
29
28
  /** 列表选中事件 */
30
29
  onRowSelectionChange?: (selectedRowKeys: React.Key[], selectedRows: RecordType[]) => void;
31
30
  };
32
- export type TTableActionType = {
33
- resetAllData: () => Promise<void>;
34
- resetData: () => Promise<void>;
35
- reloadData: () => Promise<void>;
36
- } & TableRef;
31
+ export type TTableActionType = TApiTableActionType & ICrudFormDialogActionType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xph-crud",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -1,6 +0,0 @@
1
- import { TSearchFormActionType } from '../../../../types';
2
-
3
- declare const _default: import('react').MemoExoticComponent<import('react').ForwardRefExoticComponent<{
4
- getBindProps: () => any;
5
- } & import('react').RefAttributes<TSearchFormActionType>>>;
6
- export default _default;
@@ -1,4 +0,0 @@
1
- import { IXphFormProps } from '../../../form';
2
- import { TXphExtendComponentPropsMap } from '../../../common';
3
-
4
- export type TCrudFormProps<T extends TXphExtendComponentPropsMap = {}> = IXphFormProps<T> & {};