xph-crud 0.3.2 → 0.3.3

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.
@@ -14,95 +14,75 @@ export interface IFunctionToolbarParams<T = TDataSourceItem> {
14
14
  */
15
15
  export type TApiTableProps<T = TDataSourceItem, J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}, L extends TXphExtendComponentPropsMap = {}> = {
16
16
  /**
17
- * @default []
18
- * @description 列配置项
17
+ * 列配置项,默认为`[]`
19
18
  */
20
19
  columns?: TColumnProps<T, J, K>[];
21
20
  /**
22
- * @default true
23
- * @description 首次是否自动请求
21
+ * 首次是否自动请求,默认为`true`
24
22
  */
25
23
  autoRequest?: boolean;
26
24
  /**
27
- * @default -
28
- * @description 获取datasource的api
25
+ * 获取datasource的api
29
26
  */
30
27
  api?: (params: any) => Promise<any>;
31
28
  /**
32
- * @default -
33
- * @description 格式化返回的datasource
29
+ * 格式化返回的datasource
34
30
  */
35
31
  formatDataSource?: (data: any) => any[];
36
32
  /**
37
- * @default -
38
- * @description 是否开启前端自动分页(当api不支持分页时可用)
33
+ * 是否开启前端自动分页(当api不支持分页时可用)
39
34
  */
40
35
  autoPagination?: boolean;
41
36
  /**
42
- * @default -
43
- * @description 单选 / 多选
37
+ * 单选 / 多选
44
38
  */
45
39
  rowSelection?: RowSelectionType | TableRowSelection<T>;
46
40
  /**
47
- * @default { pageSize: 20, total: 0, showTotal: (total) => `共:${total} 条`, current: 1, pageSizeOptions: [10, 20, 50, 100], showSizeChanger: true, showQuickJumper: true, }
48
- * @description 分页配置(因为分页器是独立出来的,使用table的分页器布局需要修改样式)
41
+ * 分页配置(因为分页器是独立出来的,使用table的分页器布局需要修改样式)
42
+ * 默认为`{ pageSize: 20, total: 0, showTotal: (total) => `共:$\\{total\\} 条`, current: 1, pageSizeOptions: [10, 20, 50, 100], showSizeChanger: true, showQuickJumper: true, }`
49
43
  */
50
44
  pagination?: false | PaginationProps;
51
45
  /**
52
- * @default false
53
- * @description 表格撑满父容器(virtual为true时,默认fullHeight为true)
46
+ * 表格撑满父容器(virtual为true时,默认fullHeight为true),默认为`false`
54
47
  */
55
48
  fullHeight?: boolean;
56
49
  /**
57
- * @default -
58
- * @description 顶部操作栏配置,函数时可以传递参数,参数是什么由调用方决定
50
+ * 顶部操作栏配置,函数时可以传递参数,参数是什么由调用方决定
59
51
  */
60
52
  toolbar?: IXphActionsProps<L> | ((e: IFunctionToolbarParams<T>) => IXphActionsProps<L>);
61
53
  /**
62
- * @default { pageSize: "pageSize", current: "current", }
63
- * @description 分页请求参数中传递到接口的属性名
54
+ * 分页请求参数中传递到接口的属性名
55
+ * 默认为`{ pageSize: "pageSize", current: "current", }`
64
56
  */
65
57
  requestFields?: {
66
- /**
67
- * @default "current"
68
- * @description 当前页
69
- */
70
58
  current?: string;
71
- /**
72
- * @default "pageSize"
73
- * @description 当前页大小
74
- */
75
59
  pageSize?: string;
76
60
  };
77
61
  /**
78
- * @default { current: "current", list: "data", total: "total", }
79
- * @description 响应结果中获取数据的属性名
62
+ * 响应结果中获取数据的属性名
63
+ * 默认为`{ current: "current", list: "data", total: "total", }`
80
64
  */
81
65
  responseFields?: {
82
- /**
83
- * @default "current"
84
- * @description 当前页
85
- */
86
66
  current?: string;
87
- /**
88
- * @default "data"
89
- * @description 列表
90
- */
91
67
  list?: string;
92
- /**
93
- * @default "total"
94
- * @description 所有页总数
95
- */
96
68
  total?: string;
97
69
  };
98
70
  /**
99
- * @default -
100
- * @description 排序、筛选变化时触发
71
+ * 排序、筛选变化时触发
101
72
  */
102
73
  onChange?: (filters: any, sorter: any, extra: any) => void;
103
74
  } & Omit<TableProps<T>, "rowSelection" | "columns" | "loading" | "dataSource" | "pagination">;
104
75
  export type TApiTableActionType = {
76
+ /**
77
+ * 重置事件(重置页码、表单后重新请求)
78
+ */
105
79
  resetAllData: () => Promise<void>;
80
+ /**
81
+ * 重置事件(重置表单后重新请求)
82
+ */
106
83
  resetData: () => Promise<void>;
84
+ /**
85
+ * 刷新数据
86
+ */
107
87
  reloadData: () => Promise<void>;
108
88
  } & TableRef;
@@ -9,7 +9,7 @@ import { TXphExtendComponentPropsMap } from '../../../common';
9
9
  type TBaseColumnType<T> = {} & ColumnType<T>;
10
10
  export interface IComponentColumnProps<T, J extends TXphExtendComponentPropsMap = {}, K extends TXphExtendComponentPropsMap = {}> extends Omit<TBaseColumnType<T>, "render"> {
11
11
  /**
12
- * @description 单元格渲染属性(原理也是使用render渲染不同的内容)
12
+ * 单元格渲染属性(原理也是使用render渲染不同的内容)
13
13
  */
14
14
  cellFunc: ((props: {
15
15
  text: any;
@@ -2,11 +2,20 @@ import { IXphFormProps, IXphFormActionType } from '../../../form';
2
2
  import { TXphExtendComponentPropsMap, IXphDialogProps, IXphDialogActionType } from '../../../common';
3
3
 
4
4
  export type TCrudFormDialogProps<T extends TXphExtendComponentPropsMap = {}> = Omit<IXphDialogProps, "onOk" | "onCancel"> & {
5
+ /**
6
+ * crud弹窗的form配置
7
+ */
5
8
  formProps: IXphFormProps<T>;
9
+ /**
10
+ * crud弹窗点击确定的回调
11
+ */
6
12
  onOk?: (event: {
7
13
  values: any;
8
14
  data: any;
9
15
  }) => Promise<any>;
16
+ /**
17
+ * crud弹窗点击取消回调
18
+ */
10
19
  onCancel?: (event: {
11
20
  values: any;
12
21
  data: any;
@@ -14,22 +23,23 @@ export type TCrudFormDialogProps<T extends TXphExtendComponentPropsMap = {}> = O
14
23
  };
15
24
  export interface IOpenActionConfig {
16
25
  /**
17
- * @description 回填表单的内容
26
+ * 回填表单的内容
18
27
  */
19
28
  data: any;
20
29
  /**
21
- * @description 点击确定的回调(如果弹窗传递了onOk属性就不用传这个了,这个是为了方便所有操作都在open函数中处理)
30
+ * 点击确定的回调(如果弹窗传递了onOk属性就不用传这个了,这个是为了方便所有操作都在open函数中处理)
22
31
  */
23
32
  ok?: (event: {
24
33
  values: any;
25
34
  }) => Promise<any>;
26
35
  /**
27
- * @description 点击取消的回调(如果弹窗传递了onCancel属性就不用传这个了,这个是为了方便所有操作都在open函数中处理)
36
+ * 点击取消的回调(如果弹窗传递了onCancel属性就不用传这个了,这个是为了方便所有操作都在open函数中处理)
28
37
  */
29
38
  cancel?: (event: {
30
39
  values: any;
31
40
  }) => Promise<any>;
32
41
  }
33
42
  export interface ICrudFormDialogActionType extends IXphFormActionType, Omit<IXphDialogActionType, "open"> {
43
+ /** 打开crud弹窗 */
34
44
  open: (config: IOpenActionConfig) => Promise<void>;
35
45
  }
@@ -2,11 +2,14 @@ import { IXphFormProps, IXphFormActionType } from '../../../form';
2
2
  import { TXphExtendComponentPropsMap } from '../../../common';
3
3
 
4
4
  export type TSearchFormActionType = IXphFormActionType & {
5
+ /**
6
+ * 设置表单的loading
7
+ */
5
8
  setFormLoading: (loading: boolean) => void;
6
9
  };
7
10
  export type TSearchFormProps<T extends TXphExtendComponentPropsMap = {}> = IXphFormProps<T> & {
8
11
  /**
9
- * @description 是否显示搜索 & 重置按钮
12
+ * 是否显示搜索 & 重置按钮
10
13
  */
11
14
  showSearch?: boolean;
12
15
  };
@@ -12,23 +12,23 @@ export type TDataSourceItem = Record<PropertyKey, any>;
12
12
  */
13
13
  export type TTableProps<RecordType = TDataSourceItem, CellFuncExtendPropsMap extends TXphExtendComponentPropsMap = {}, ActionsExtendPropsMap extends TXphExtendComponentPropsMap = {}, ToolbarExtendPropsMap extends TXphExtendComponentPropsMap = {}, FormExtendPropsMap extends TXphExtendComponentPropsMap = {}> = {
14
14
  /**
15
- * @description 表格配置
15
+ * 表格配置
16
16
  */
17
17
  table?: TApiTableProps<RecordType, CellFuncExtendPropsMap, ActionsExtendPropsMap, ToolbarExtendPropsMap>;
18
18
  /**
19
- * @description 搜索表单配置项
19
+ * 搜索表单配置项
20
20
  */
21
21
  searchForm?: TSearchFormProps<FormExtendPropsMap>;
22
22
  /**
23
- * @description (新增 / 修改)表单弹窗配置项
23
+ * (新增 / 修改)表单弹窗配置项
24
24
  */
25
25
  crudFormDialog?: TCrudFormDialogProps<FormExtendPropsMap>;
26
26
  /**
27
- * @description 分页改变事件
27
+ * 分页改变事件
28
28
  */
29
29
  onPaginationChange?: (page: number, pageSize: number) => void;
30
30
  /**
31
- * @description 列表选中事件
31
+ * 列表选中事件
32
32
  */
33
33
  onRowSelectionChange?: (selectedRowKeys: React.Key[], selectedRows: RecordType[]) => void;
34
34
  };
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
- {
2
- "name": "xph-crud",
3
- "version": "0.3.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
- "dayjs": "^1.11.13"
23
- },
24
- "dependencies": {
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
+ {
2
+ "name": "xph-crud",
3
+ "version": "0.3.3",
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
+ "scripts": {
14
+ "examples": "vite",
15
+ "build": "tsc && vite build",
16
+ "docs": "cd docs && npm run start",
17
+ "build:docs": "cd docs && npm run build",
18
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "peerDependencies": {
25
+ "@ant-design/icons": "5.3.2",
26
+ "antd": "^5.14.2",
27
+ "react": "^18.2.0",
28
+ "react-dom": "^18.2.0",
29
+ "dayjs": "^1.11.13"
30
+ },
31
+ "dependencies": {
32
+ "lodash-es": "^4.17.21"
33
+ },
34
+ "devDependencies": {
35
+ "@types/lodash-es": "^4.17.12",
36
+ "@types/node": "^20.14.2",
37
+ "@types/react": "^18.2.66",
38
+ "@types/react-dom": "^18.2.22",
39
+ "@typescript-eslint/eslint-plugin": "^7.2.0",
40
+ "@typescript-eslint/parser": "^7.2.0",
41
+ "@vitejs/plugin-react": "^4.2.1",
42
+ "eslint": "^8.57.0",
43
+ "eslint-plugin-react-hooks": "^4.6.0",
44
+ "eslint-plugin-react-refresh": "^0.4.6",
45
+ "typescript": "^5.2.2",
46
+ "vite": "^5.2.0",
47
+ "vite-plugin-dts": "^3.9.1"
48
+ },
49
+ "license": "ISC",
50
+ "author": "XiaoPiHong",
51
+ "homepage": "https://github.com/XiaoPiHong/xph-crud",
52
+ "bugs": {
53
+ "url": "https://github.com/XiaoPiHong/xph-crud/issues",
54
+ "email": "260094892@qq.com"
55
+ },
56
+ "repository": {
57
+ "type": "git",
58
+ "url": "https://github.com/XiaoPiHong/xph-crud.git"
59
+ },
60
+ "engines": {
61
+ "node": ">=16"
62
+ }
63
+ }