xph-crud 0.0.8 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
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;
@@ -1,9 +1,12 @@
1
1
  import { MouseEvent } from 'react';
2
2
 
3
- declare const useResizeDialog: ({ visible, container, dialogRef, setDialogSize, setDialogPosition, }: {
4
- visible: boolean;
3
+ declare const useResizeDialog: ({ container, dialogRef, minResizeRecord, setDialogSize, setDialogPosition, }: {
5
4
  container: HTMLElement;
6
5
  dialogRef: React.RefObject<HTMLDivElement>;
6
+ minResizeRecord: React.MutableRefObject<{
7
+ width: number;
8
+ height: number;
9
+ } | null>;
7
10
  setDialogSize: (size: {
8
11
  width: number | string;
9
12
  height: number | string;
@@ -23,6 +23,6 @@ export interface IDialogProps {
23
23
  getPopperContainer?: () => HTMLElement | null;
24
24
  }
25
25
  export interface IDialogActionType {
26
- open: () => void;
26
+ open: () => Promise<void>;
27
27
  close: () => void;
28
28
  }
@@ -1,3 +1,4 @@
1
1
  import { IExtendProps as IXphExtendProps, IExtendComponentProps as IXphExtendComponentProps, ExtendCompPropsProvider as XphExtendCompPropsProvider, useExtendCompProps as useXphExtendCompProps } from './useExtendCompProps';
2
+ import { useAsyncState } from './useAsyncState';
2
3
 
3
- export { IXphExtendProps, IXphExtendComponentProps, XphExtendCompPropsProvider, useXphExtendCompProps, };
4
+ export { IXphExtendProps, IXphExtendComponentProps, XphExtendCompPropsProvider, useXphExtendCompProps, useAsyncState, };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 自定义 Hook 用于异步更新状态
3
+ * @param initialState 初始状态
4
+ * @returns [state, setAsyncState] state 是当前状态,setAsyncState 是更新状态的函数
5
+ */
6
+ export declare const useAsyncState: <T>(initialState: T) => [T, (newState: T) => Promise<void>];
@@ -1,5 +1,5 @@
1
1
  import { default as React } from 'react';
2
2
  import { ICurCellFuncProps, IMainProps } from '../types';
3
3
 
4
- declare const Actions: (Comp: React.ReactElement, curCellFuncProps: ICurCellFuncProps<{}, {}, "actions">, mainProps: IMainProps) => import("react/jsx-runtime").JSX.Element;
4
+ declare const Actions: (Comp: React.JSXElementConstructor<any>, curCellFuncProps: ICurCellFuncProps<{}, {}, "actions">, mainProps: IMainProps) => import("react/jsx-runtime").JSX.Element;
5
5
  export default Actions;
@@ -6,7 +6,11 @@ declare const cellComponentMap: {
6
6
  };
7
7
  /** 操作组 */
8
8
  actions: {
9
- Comp: (Comp: import('react').ReactElement<any, string | import('react').JSXElementConstructor<any>>, curCellFuncProps: import('../types').ICurCellFuncProps<{}, {}, "actions">, mainProps: import('../types').IMainProps) => import("react/jsx-runtime").JSX.Element;
9
+ Comp: (Comp: import('react').JSXElementConstructor<any>, curCellFuncProps: import('../types').ICurCellFuncProps<{}, {}, "actions">, mainProps: import('../types').IMainProps) => import("react/jsx-runtime").JSX.Element;
10
+ };
11
+ /** tag标签 */
12
+ tag: {
13
+ Comp: (Comp: import('react').JSXElementConstructor<any>, curCellFuncProps: import('../types').ICurCellFuncProps<{}, {}, "tag">, mainProps: import('../types').IMainProps) => import("react/jsx-runtime").JSX.Element;
10
14
  };
11
15
  };
12
16
  export { cellComponentMap };
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ import { ICurCellFuncProps, IMainProps } from '../types';
3
+
4
+ /** tag标签使用原生去实现,无需使用antd组件影响性能,而且这个组件的比较特殊,mainProps的优先级最高 */
5
+ declare const Tag: (Comp: React.JSXElementConstructor<any>, curCellFuncProps: ICurCellFuncProps<{}, {}, "tag">, mainProps: IMainProps) => import("react/jsx-runtime").JSX.Element;
6
+ export default Tag;
@@ -1,4 +1,5 @@
1
1
  import { IXphActionsProps, TXphExtendComponentPropsMap } from '../../../../../../../common';
2
+ import { IComponentColumnProps, TDataSourceItem } from '../../../../../types';
2
3
 
3
4
  /** cellFunc中每一项对应的组件componentProps属性映射 */
4
5
  export type TCellComponentPropsMap<CellFuncExtendPropsMap extends TXphExtendComponentPropsMap = {}, ActionsExtendPropsMap extends TXphExtendComponentPropsMap = {}> = {
@@ -9,6 +10,16 @@ export type TCellComponentPropsMap<CellFuncExtendPropsMap extends TXphExtendComp
9
10
  onClick?: () => void;
10
11
  };
11
12
  actions: IXphActionsProps<ActionsExtendPropsMap>;
13
+ tag: {
14
+ /** 标签的枚举 */
15
+ enums: Array<{
16
+ label: string;
17
+ value: any;
18
+ config?: {
19
+ color?: string;
20
+ };
21
+ }>;
22
+ };
12
23
  } & CellFuncExtendPropsMap;
13
24
  type Without<T, K> = {
14
25
  [P in Exclude<keyof T, K>]?: never;
@@ -26,7 +37,7 @@ export type TCellProps<J extends TXphExtendComponentPropsMap = {}, K extends TXp
26
37
  /** CellFunc组件的props */
27
38
  export interface ICellFuncProps<
28
39
  /** 行数据类型 */
29
- T = unknown,
40
+ T = TDataSourceItem,
30
41
  /** 单元格的扩展组件props映射 */
31
42
  J extends TXphExtendComponentPropsMap = {},
32
43
  /** 操作组的扩展组件props映射 */
@@ -36,12 +47,13 @@ K extends TXphExtendComponentPropsMap = {}> {
36
47
  text: any;
37
48
  record: T;
38
49
  index: number;
50
+ column: Omit<IComponentColumnProps<T, K, K>, "cellFunc">;
39
51
  };
40
52
  }
41
53
  /** cellFunc中每一项对应的组件的props */
42
54
  export interface ICurCellFuncProps<J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}, T extends keyof TCellComponentPropsMap<J, K> = keyof TCellComponentPropsMap<J, K>> {
43
55
  curComponentProps?: TCellComponentPropsMap<J, K>[T];
44
- cellFuncProps: ICellFuncProps<unknown, J, K>;
56
+ cellFuncProps: ICellFuncProps<TDataSourceItem, J, K>;
45
57
  }
46
58
  /**
47
59
  *
@@ -53,5 +65,6 @@ export interface ICurCellFuncProps<J extends TXphExtendComponentPropsMap = {}, K
53
65
  export interface IMainProps {
54
66
  mainClick?: () => void;
55
67
  mainStyle?: React.CSSProperties;
68
+ mainHandleText?: () => any;
56
69
  }
57
70
  export {};
@@ -5,4 +5,5 @@ export type TCrudFormDialogProps<T extends TXphExtendComponentPropsMap = {}> = I
5
5
  formProps: IXphFormProps<T>;
6
6
  };
7
7
  export interface ICrudFormDialogActionType extends IXphFormActionType, IXphDialogActionType {
8
+ open: (data?: any) => Promise<void>;
8
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xph-crud",
3
- "version": "0.0.8",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",