xph-crud 0.0.1

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 (78) hide show
  1. package/README.md +64 -0
  2. package/dist/index.js +3246 -0
  3. package/dist/index.umd.cjs +25 -0
  4. package/dist/style.css +1 -0
  5. package/dist/types/common/index.d.ts +3 -0
  6. package/dist/types/common/src/componnets/actions/actions.d.ts +4 -0
  7. package/dist/types/common/src/componnets/actions/components/button.d.ts +4 -0
  8. package/dist/types/common/src/componnets/actions/components/dropdown.d.ts +4 -0
  9. package/dist/types/common/src/componnets/actions/components/index.d.ts +5 -0
  10. package/dist/types/common/src/componnets/actions/components/more.d.ts +7 -0
  11. package/dist/types/common/src/componnets/actions/hooks/index.d.ts +8 -0
  12. package/dist/types/common/src/componnets/actions/hooks/useActionItems.d.ts +6 -0
  13. package/dist/types/common/src/componnets/actions/hooks/useActionsProps.d.ts +5 -0
  14. package/dist/types/common/src/componnets/actions/hooks/useExtendActions.d.ts +5 -0
  15. package/dist/types/common/src/componnets/actions/hooks/useRenderContent.d.ts +6 -0
  16. package/dist/types/common/src/componnets/actions/types/actionItem.d.ts +67 -0
  17. package/dist/types/common/src/componnets/actions/types/actions.d.ts +15 -0
  18. package/dist/types/common/src/componnets/actions/types/index.d.ts +2 -0
  19. package/dist/types/common/src/componnets/dialog/dialog.d.ts +2 -0
  20. package/dist/types/common/src/componnets/dialog/types/dialog.d.ts +9 -0
  21. package/dist/types/common/src/componnets/index.d.ts +5 -0
  22. package/dist/types/common/src/hooks/index.d.ts +3 -0
  23. package/dist/types/common/src/hooks/useExtendCompProps.d.ts +45 -0
  24. package/dist/types/common/src/utils/index.d.ts +1 -0
  25. package/dist/types/form/index.d.ts +5 -0
  26. package/dist/types/form/src/components/ActionGroup/index.d.ts +6 -0
  27. package/dist/types/form/src/components/ApiAutoComplete/index.d.ts +15 -0
  28. package/dist/types/form/src/components/ApiSelect/index.d.ts +15 -0
  29. package/dist/types/form/src/components/ApiTransfer/index.d.ts +13 -0
  30. package/dist/types/form/src/components/ApiTreeSelect/index.d.ts +15 -0
  31. package/dist/types/form/src/components/AutoUpload/index.d.ts +28 -0
  32. package/dist/types/form/src/components/Collapse/index.d.ts +7 -0
  33. package/dist/types/form/src/components/FormItem/index.d.ts +11 -0
  34. package/dist/types/form/src/components/index.d.ts +5 -0
  35. package/dist/types/form/src/form.d.ts +8 -0
  36. package/dist/types/form/src/helper.d.ts +14 -0
  37. package/dist/types/form/src/hooks/index.d.ts +16 -0
  38. package/dist/types/form/src/hooks/useApiComonentCache.d.ts +24 -0
  39. package/dist/types/form/src/hooks/useExtendForm.d.ts +5 -0
  40. package/dist/types/form/src/hooks/useForm.d.ts +20 -0
  41. package/dist/types/form/src/hooks/useFormAction.d.ts +12 -0
  42. package/dist/types/form/src/hooks/useFormCollapse.d.ts +11 -0
  43. package/dist/types/form/src/hooks/useFormItem.d.ts +40 -0
  44. package/dist/types/form/src/hooks/useFormProps.d.ts +6 -0
  45. package/dist/types/form/src/hooks/useFormValues.d.ts +11 -0
  46. package/dist/types/form/src/types/component.d.ts +35 -0
  47. package/dist/types/form/src/types/form.d.ts +86 -0
  48. package/dist/types/form/src/types/formItem.d.ts +54 -0
  49. package/dist/types/form/src/types/index.d.ts +3 -0
  50. package/dist/types/index.d.ts +3 -0
  51. package/dist/types/table/index.d.ts +4 -0
  52. package/dist/types/table/src/components/searchForm/components/cacheForm/index.d.ts +6 -0
  53. package/dist/types/table/src/components/searchForm/index.d.ts +9 -0
  54. package/dist/types/table/src/components/table/components/cellFunc/cellFunc.d.ts +5 -0
  55. package/dist/types/table/src/components/table/components/cellFunc/components/actions.d.ts +5 -0
  56. package/dist/types/table/src/components/table/components/cellFunc/components/index.d.ts +12 -0
  57. package/dist/types/table/src/components/table/components/cellFunc/components/link.d.ts +5 -0
  58. package/dist/types/table/src/components/table/components/cellFunc/types/cellFunc.d.ts +43 -0
  59. package/dist/types/table/src/components/table/components/cellFunc/types/index.d.ts +1 -0
  60. package/dist/types/table/src/components/table/index.d.ts +9 -0
  61. package/dist/types/table/src/hooks/index.d.ts +18 -0
  62. package/dist/types/table/src/hooks/useExtendTable.d.ts +7 -0
  63. package/dist/types/table/src/hooks/usePagination.d.ts +18 -0
  64. package/dist/types/table/src/hooks/useRowSelection.d.ts +9 -0
  65. package/dist/types/table/src/hooks/useSearchForm.d.ts +6 -0
  66. package/dist/types/table/src/hooks/useTable.d.ts +24 -0
  67. package/dist/types/table/src/hooks/useTableColumns.d.ts +6 -0
  68. package/dist/types/table/src/hooks/useTableProps.d.ts +6 -0
  69. package/dist/types/table/src/hooks/useTableScroll.d.ts +10 -0
  70. package/dist/types/table/src/hooks/useTopToolbar.d.ts +7 -0
  71. package/dist/types/table/src/table.d.ts +8 -0
  72. package/dist/types/table/src/types/apiTable.d.ts +35 -0
  73. package/dist/types/table/src/types/column.d.ts +32 -0
  74. package/dist/types/table/src/types/crudForm.d.ts +3 -0
  75. package/dist/types/table/src/types/index.d.ts +5 -0
  76. package/dist/types/table/src/types/searchForm.d.ts +9 -0
  77. package/dist/types/table/src/types/table.d.ts +25 -0
  78. package/package.json +63 -0
@@ -0,0 +1,32 @@
1
+ import { ColumnType, ColumnGroupType } from 'antd/es/table';
2
+ import { TDataSourceItem } from './table';
3
+ import { ICellProps, TCellComponentType } from '../components/table/components/cellFunc/types';
4
+
5
+ /** 扩展一下antd column的属性,不一定要扩展,只是预留 */
6
+ type TBaseColumnType<T> = {} & ColumnType<T>;
7
+ export interface IComponentColumnProps<T, U extends TCellComponentType> extends Omit<TBaseColumnType<T>, "render"> {
8
+ /** 单元格渲染属性(原理也是使用render渲染不同的内容) */
9
+ cellFunc: ((props: {
10
+ text: any;
11
+ record: T;
12
+ index: number;
13
+ }) => ICellProps<U>[]) | ICellProps<U>[];
14
+ }
15
+ export interface IRenderColumnProps<T> extends Omit<TBaseColumnType<T>, "render"> {
16
+ render?: ColumnType<T>["render"];
17
+ }
18
+ export interface IGroupColumnProps<T> extends Omit<ColumnGroupType<T>, "children"> {
19
+ children: Array<TColumnProps<T>>;
20
+ }
21
+ type Without<T, K> = {
22
+ [P in Exclude<keyof T, K>]?: never;
23
+ };
24
+ type XOR<T extends any[]> = T extends [infer A, infer B, ...infer Rest] ? A | B extends object ? (Without<A, keyof B> & B) | (Without<B, keyof A> & A) | XOR<[A | B, ...Rest]> : A | B : T extends [infer A] ? A : never;
25
+ export type TColumnProps<RecordType = TDataSourceItem, ComponentType extends TCellComponentType = TCellComponentType> = XOR<[
26
+ IComponentColumnProps<RecordType, ComponentType>,
27
+ IRenderColumnProps<RecordType>,
28
+ IGroupColumnProps<RecordType>
29
+ ]>;
30
+ export declare function isComponentColumnProps<T, U extends TCellComponentType>(column: TColumnProps<T, U>): column is IComponentColumnProps<T, U>;
31
+ export declare function isChildrenColumnProps<T>(column: TColumnProps<T>): column is IGroupColumnProps<T>;
32
+ export {};
@@ -0,0 +1,3 @@
1
+ import { IXphFormProps } from '../../../form';
2
+
3
+ export type TCrudFormProps = IXphFormProps & {};
@@ -0,0 +1,5 @@
1
+ export * from './table';
2
+ export * from './searchForm';
3
+ export * from './crudForm';
4
+ export * from './apiTable';
5
+ export * from './column';
@@ -0,0 +1,9 @@
1
+ import { IXphFormProps, IXphFormActionType } from '../../../form';
2
+
3
+ export type TSearchFormActionType = IXphFormActionType & {
4
+ setFormLoading: (loading: boolean) => void;
5
+ };
6
+ export type TSearchFormProps = IXphFormProps & {
7
+ /** 是否显示搜索 & 重置按钮 */
8
+ showSearch?: boolean;
9
+ };
@@ -0,0 +1,25 @@
1
+ import { TableRef } from 'antd/es/table';
2
+ import { TSearchFormProps } from './searchForm';
3
+ import { TCrudFormProps } from './crudForm';
4
+ import { TApiTableProps } from './apiTable';
5
+
6
+ /** 行数据 */
7
+ export type TDataSourceItem = Record<PropertyKey, any>;
8
+ /** 整个组件的配置 */
9
+ export type TTableProps<RecordType = TDataSourceItem> = {
10
+ /** 表格配置 */
11
+ table?: TApiTableProps<RecordType>;
12
+ /** 搜索表单配置项 */
13
+ searchForm?: TSearchFormProps;
14
+ /** 新增 / 修改表单配置项 */
15
+ crudForm?: TCrudFormProps;
16
+ /** 分页改变事件 */
17
+ onPaginationChange?: (page: number, pageSize: number) => void;
18
+ /** 列表选中事件 */
19
+ onRowSelectionChange?: (selectedRowKeys: React.Key[], selectedRows: RecordType[]) => void;
20
+ };
21
+ export type TTableActionType = {
22
+ resetAllData: () => Promise<void>;
23
+ resetData: () => Promise<void>;
24
+ reloadData: () => Promise<void>;
25
+ } & TableRef;
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "xph-crud",
3
+ "version": "0.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
+ "scripts": {
14
+ "web": "vite",
15
+ "build": "tsc && vite build",
16
+ "example": "cd example && npm run start",
17
+ "build:example": "cd example && 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
+ },
30
+ "dependencies": {
31
+ "dayjs": "^1.11.10",
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
+ }