@mi-avalon/libs 0.0.5 → 0.0.7
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/LICENSE +2 -2
- package/README.md +159 -2
- package/dist/components/ItemsRow/index.d.ts +43 -0
- package/dist/components/MBreadcrumb/index.d.ts +18 -0
- package/dist/components/MDescriptions/index.d.ts +65 -0
- package/dist/components/MForm/MFormItemConst.d.ts +27 -0
- package/dist/components/MForm/index.d.ts +10 -0
- package/dist/components/MForm/type.d.ts +184 -0
- package/dist/components/MSearch/index.d.ts +27 -0
- package/dist/components/MTable/index.d.ts +12 -0
- package/dist/components/MiModal/index.d.ts +16 -0
- package/dist/components/ThemeContext/CompThemeProvider.d.ts +9 -0
- package/dist/components/ThemeContext/index.d.ts +8 -0
- package/dist/components/index.d.ts +9 -1
- package/dist/constants/date.d.ts +11 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/pageInfo.d.ts +1 -0
- package/dist/constants/pattern.d.ts +24 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useFuncRequest.d.ts +16 -0
- package/dist/hooks/useInterval.d.ts +8 -0
- package/dist/hooks/usePagination.d.ts +42 -0
- package/dist/hooks/useQuery.d.ts +3 -0
- package/dist/hooks/useReactive.d.ts +2 -0
- package/dist/hooks/useTimeout.d.ts +8 -0
- package/dist/hooks/useVirtualList.d.ts +74 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +8 -9
- package/dist/libs.cjs.development.js +2094 -0
- package/dist/libs.cjs.development.js.map +1 -0
- package/dist/libs.cjs.production.min.js +2 -0
- package/dist/libs.cjs.production.min.js.map +1 -0
- package/dist/libs.esm.js +2060 -0
- package/dist/libs.esm.js.map +1 -0
- package/dist/utils/calc.d.ts +20 -0
- package/dist/utils/index.d.ts +5 -1
- package/dist/utils/nextTick.d.ts +14 -0
- package/dist/utils/openModal.d.ts +15 -0
- package/dist/utils/util.d.ts +4 -0
- package/dist/utils/version.d.ts +70 -0
- package/package.json +67 -37
- package/src/components/ItemsRow/index.scss +18 -0
- package/src/components/ItemsRow/index.tsx +85 -0
- package/src/components/MBreadcrumb/index.scss +82 -0
- package/src/components/MBreadcrumb/index.tsx +93 -0
- package/src/components/MDescriptions/index.tsx +131 -0
- package/src/components/MForm/MFormItemConst.tsx +206 -0
- package/src/components/MForm/index.scss +13 -0
- package/src/components/MForm/index.tsx +97 -0
- package/src/components/MForm/type.ts +229 -0
- package/src/components/MSearch/index.scss +63 -0
- package/src/components/MSearch/index.tsx +173 -0
- package/src/components/MTable/index.tsx +22 -0
- package/src/components/MiModal/index.tsx +106 -0
- package/src/components/ThemeContext/CompThemeProvider.tsx +19 -0
- package/src/components/ThemeContext/index.ts +20 -0
- package/src/components/index.ts +9 -0
- package/src/constants/date.ts +11 -0
- package/src/constants/index.ts +3 -0
- package/src/constants/pageInfo.ts +1 -0
- package/src/constants/pattern.ts +53 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useFuncRequest.ts +100 -0
- package/src/hooks/useInterval.ts +50 -0
- package/src/hooks/usePagination.ts +184 -0
- package/src/hooks/useQuery.ts +6 -0
- package/src/hooks/useReactive.ts +26 -0
- package/src/hooks/useTimeout.ts +50 -0
- package/src/hooks/useVirtualList.ts +209 -0
- package/src/index.tsx +4 -0
- package/src/utils/calc.ts +92 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/nextTick.ts +89 -0
- package/src/utils/openModal.tsx +137 -0
- package/src/utils/util.ts +37 -0
- package/src/utils/version.ts +206 -0
- package/dist/components/MyButton/index.d.ts +0 -6
- package/dist/components/MyButton/index.js +0 -291
- package/dist/components/index.js +0 -6
- package/dist/utils/format.d.ts +0 -2
- package/dist/utils/format.js +0 -5
- package/dist/utils/index.js +0 -5
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 顾冬杰
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
18
18
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,160 @@
|
|
|
1
|
-
#
|
|
1
|
+
# TSDX React User Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.
|
|
4
|
+
|
|
5
|
+
> This TSDX setup is meant for developing React component libraries (not apps!) that can be published to NPM. If you’re looking to build a React-based app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.
|
|
6
|
+
|
|
7
|
+
> If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.
|
|
12
|
+
|
|
13
|
+
The recommended workflow is to run TSDX in one terminal:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm start # or yarn start
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This builds to `/dist` and runs the project in watch mode so any edits you save inside `src` causes a rebuild to `/dist`.
|
|
20
|
+
|
|
21
|
+
Then run the example inside another:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
cd example
|
|
25
|
+
npm i # or yarn to install dependencies
|
|
26
|
+
npm start # or yarn start
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, we use [Parcel's aliasing](https://parceljs.org/module_resolution.html#aliases).
|
|
30
|
+
|
|
31
|
+
To do a one-off build, use `npm run build` or `yarn build`.
|
|
32
|
+
|
|
33
|
+
To run tests, use `npm test` or `yarn test`.
|
|
34
|
+
|
|
35
|
+
## Configuration
|
|
36
|
+
|
|
37
|
+
Code quality is set up for you with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
|
|
38
|
+
|
|
39
|
+
### Jest
|
|
40
|
+
|
|
41
|
+
Jest tests are set up to run with `npm test` or `yarn test`.
|
|
42
|
+
|
|
43
|
+
### Bundle analysis
|
|
44
|
+
|
|
45
|
+
Calculates the real cost of your library using [size-limit](https://github.com/ai/size-limit) with `npm run size` and visulize it with `npm run analyze`.
|
|
46
|
+
|
|
47
|
+
#### Setup Files
|
|
48
|
+
|
|
49
|
+
This is the folder structure we set up for you:
|
|
50
|
+
|
|
51
|
+
```txt
|
|
52
|
+
/example
|
|
53
|
+
index.html
|
|
54
|
+
index.tsx # test your component here in a demo app
|
|
55
|
+
package.json
|
|
56
|
+
tsconfig.json
|
|
57
|
+
/src
|
|
58
|
+
index.tsx # EDIT THIS
|
|
59
|
+
/test
|
|
60
|
+
blah.test.tsx # EDIT THIS
|
|
61
|
+
.gitignore
|
|
62
|
+
package.json
|
|
63
|
+
README.md # EDIT THIS
|
|
64
|
+
tsconfig.json
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### React Testing Library
|
|
68
|
+
|
|
69
|
+
We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
|
|
70
|
+
|
|
71
|
+
### Rollup
|
|
72
|
+
|
|
73
|
+
TSDX uses [Rollup](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
|
|
74
|
+
|
|
75
|
+
### TypeScript
|
|
76
|
+
|
|
77
|
+
`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
|
|
78
|
+
|
|
79
|
+
## Continuous Integration
|
|
80
|
+
|
|
81
|
+
### GitHub Actions
|
|
82
|
+
|
|
83
|
+
Two actions are added by default:
|
|
84
|
+
|
|
85
|
+
- `main` which installs deps w/ cache, lints, tests, and builds on all pushes against a Node and OS matrix
|
|
86
|
+
- `size` which comments cost comparison of your library on every pull request using [`size-limit`](https://github.com/ai/size-limit)
|
|
87
|
+
|
|
88
|
+
## Optimizations
|
|
89
|
+
|
|
90
|
+
Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
// ./types/index.d.ts
|
|
94
|
+
declare var __DEV__: boolean;
|
|
95
|
+
|
|
96
|
+
// inside your code...
|
|
97
|
+
if (__DEV__) {
|
|
98
|
+
console.log('foo');
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
|
|
103
|
+
|
|
104
|
+
## Module Formats
|
|
105
|
+
|
|
106
|
+
CJS, ESModules, and UMD module formats are supported.
|
|
107
|
+
|
|
108
|
+
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
|
|
109
|
+
|
|
110
|
+
## Deploying the Example Playground
|
|
111
|
+
|
|
112
|
+
The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
cd example # if not already in the example folder
|
|
116
|
+
npm run build # builds to dist
|
|
117
|
+
netlify deploy # deploy the dist folder
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Alternatively, if you already have a git repo connected, you can set up continuous deployment with Netlify:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
netlify init
|
|
124
|
+
# build command: yarn build && cd example && yarn && yarn build
|
|
125
|
+
# directory to deploy: example/dist
|
|
126
|
+
# pick yes for netlify.toml
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Named Exports
|
|
130
|
+
|
|
131
|
+
Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
|
|
132
|
+
|
|
133
|
+
## Including Styles
|
|
134
|
+
|
|
135
|
+
There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
|
|
136
|
+
|
|
137
|
+
For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
|
|
138
|
+
|
|
139
|
+
## Publishing to NPM
|
|
140
|
+
|
|
141
|
+
We recommend using [np](https://github.com/sindresorhus/np).
|
|
142
|
+
|
|
143
|
+
## Usage with Lerna
|
|
144
|
+
|
|
145
|
+
When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
|
|
146
|
+
|
|
147
|
+
The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
|
|
148
|
+
|
|
149
|
+
Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
|
|
150
|
+
|
|
151
|
+
```diff
|
|
152
|
+
"alias": {
|
|
153
|
+
- "react": "../node_modules/react",
|
|
154
|
+
- "react-dom": "../node_modules/react-dom"
|
|
155
|
+
+ "react": "../../../node_modules/react",
|
|
156
|
+
+ "react-dom": "../../../node_modules/react-dom"
|
|
157
|
+
},
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ButtonProps } from 'antd';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* 默认配置按钮,也可以通过render() 渲染其他组件
|
|
5
|
+
*/
|
|
6
|
+
export interface IRowItem {
|
|
7
|
+
/**
|
|
8
|
+
* 按钮名称
|
|
9
|
+
*/
|
|
10
|
+
label?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 按钮类型
|
|
13
|
+
*/
|
|
14
|
+
type?: ButtonProps['type'];
|
|
15
|
+
/**
|
|
16
|
+
* 如果没有指定Render,则是按钮的onClick
|
|
17
|
+
*/
|
|
18
|
+
onClick?: (e: any) => void;
|
|
19
|
+
/**
|
|
20
|
+
* 其他按钮属性
|
|
21
|
+
*/
|
|
22
|
+
btnProps?: ButtonProps;
|
|
23
|
+
/**
|
|
24
|
+
* item 的className
|
|
25
|
+
*/
|
|
26
|
+
className?: string;
|
|
27
|
+
/**
|
|
28
|
+
* 自定义渲染
|
|
29
|
+
*/
|
|
30
|
+
render?: () => React.ReactNode;
|
|
31
|
+
}
|
|
32
|
+
export interface IItemRowProps {
|
|
33
|
+
route?: Array<{
|
|
34
|
+
name: string;
|
|
35
|
+
url?: string;
|
|
36
|
+
}>;
|
|
37
|
+
items?: IRowItem[];
|
|
38
|
+
style?: React.CSSProperties;
|
|
39
|
+
className?: string;
|
|
40
|
+
offsetTop?: number;
|
|
41
|
+
}
|
|
42
|
+
declare const ItemsRow: (props: IItemRowProps) => React.JSX.Element | null;
|
|
43
|
+
export default ItemsRow;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { IRowItem } from '../ItemsRow';
|
|
3
|
+
import './index.scss';
|
|
4
|
+
export interface RouteItem {
|
|
5
|
+
name: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IMBreadcrumbProps {
|
|
9
|
+
routes?: RouteItem[];
|
|
10
|
+
customItems?: IRowItem[];
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
className?: string;
|
|
13
|
+
offsetTop?: number;
|
|
14
|
+
mainAppBaseUrl?: string;
|
|
15
|
+
microAppName?: string;
|
|
16
|
+
}
|
|
17
|
+
declare const MBreadcrumb: React.FC<IMBreadcrumbProps>;
|
|
18
|
+
export default MBreadcrumb;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IMDescriptionItem {
|
|
3
|
+
label: React.ReactNode;
|
|
4
|
+
value: React.ReactNode;
|
|
5
|
+
span?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface IMDescriptionProps {
|
|
8
|
+
/**
|
|
9
|
+
* 描述列表的数据[{label: '', value: '',}, ...]
|
|
10
|
+
*/
|
|
11
|
+
data: IMDescriptionItem[];
|
|
12
|
+
/**
|
|
13
|
+
* 标题
|
|
14
|
+
*/
|
|
15
|
+
title?: React.ReactNode;
|
|
16
|
+
/**
|
|
17
|
+
* 需要显示的列数
|
|
18
|
+
* @default 3
|
|
19
|
+
*/
|
|
20
|
+
column?: 1 | 2 | 3 | 4;
|
|
21
|
+
/**
|
|
22
|
+
* 行高
|
|
23
|
+
*/
|
|
24
|
+
lineHeight?: number;
|
|
25
|
+
/**
|
|
26
|
+
* 标签对齐方式
|
|
27
|
+
* @default 'left'
|
|
28
|
+
*/
|
|
29
|
+
align?: 'left' | 'center' | 'right';
|
|
30
|
+
/**
|
|
31
|
+
* 标签和值的布局配置
|
|
32
|
+
*/
|
|
33
|
+
itemLayout?: {
|
|
34
|
+
label?: number | undefined;
|
|
35
|
+
value?: number | undefined;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* 是否显示冒号
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
colon?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* 是否显示边框
|
|
44
|
+
* @default false
|
|
45
|
+
*/
|
|
46
|
+
bordered?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* 自定义样式
|
|
49
|
+
*/
|
|
50
|
+
style?: React.CSSProperties;
|
|
51
|
+
/**
|
|
52
|
+
* 自定义类名
|
|
53
|
+
*/
|
|
54
|
+
className?: string;
|
|
55
|
+
/**
|
|
56
|
+
* 标签样式
|
|
57
|
+
*/
|
|
58
|
+
labelStyle?: React.CSSProperties;
|
|
59
|
+
/**
|
|
60
|
+
* 内容样式
|
|
61
|
+
*/
|
|
62
|
+
contentStyle?: React.CSSProperties;
|
|
63
|
+
}
|
|
64
|
+
declare const DetailDescriptions: React.FC<IMDescriptionProps>;
|
|
65
|
+
export default DetailDescriptions;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IMFormCascaderItem, IMFormChkBoxGroupItem, IMFormDatePickerItem, IMFormInputItem, IMFormInputNumItem, IMFormItem, IMFormMentionsItem, IMFormRadioGroupItem, IMFormRangePickerItem, IMFormSelectItem, IMFormSliderItem, IMFormTextItem, IMFormTreeSelectItem, IMFormUploadItem } from './type';
|
|
3
|
+
export declare class MFormItemConst {
|
|
4
|
+
static readonly labelCol: {
|
|
5
|
+
span: number;
|
|
6
|
+
};
|
|
7
|
+
static readonly wrapperCol: {
|
|
8
|
+
span: number;
|
|
9
|
+
};
|
|
10
|
+
static readonly defaultRowGutter = 24;
|
|
11
|
+
static getDefaultArrayPlaceholder(item: IMFormItem): [string, string];
|
|
12
|
+
static getDefaultPlaceholder(item: IMFormItem): string | undefined;
|
|
13
|
+
static input: (item: IMFormInputItem) => React.JSX.Element;
|
|
14
|
+
static password: (item: IMFormInputItem) => React.JSX.Element;
|
|
15
|
+
static text: (item: IMFormTextItem) => React.JSX.Element;
|
|
16
|
+
static inputNumber: (item: IMFormInputNumItem) => React.JSX.Element;
|
|
17
|
+
static datePicker: (item: IMFormDatePickerItem) => React.JSX.Element;
|
|
18
|
+
static rangePicker: (item: IMFormRangePickerItem) => React.JSX.Element;
|
|
19
|
+
static select: (item: IMFormSelectItem) => React.JSX.Element;
|
|
20
|
+
static radio: (item: IMFormRadioGroupItem) => React.JSX.Element;
|
|
21
|
+
static checkbox: (item: IMFormChkBoxGroupItem) => React.JSX.Element;
|
|
22
|
+
static upload: (item: IMFormUploadItem) => React.JSX.Element;
|
|
23
|
+
static mentions: (item: IMFormMentionsItem) => React.JSX.Element;
|
|
24
|
+
static cascader: (item: IMFormCascaderItem) => React.JSX.Element;
|
|
25
|
+
static treeSelect: (item: IMFormTreeSelectItem) => React.JSX.Element;
|
|
26
|
+
static slider: (item: IMFormSliderItem) => React.JSX.Element;
|
|
27
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
import { IMFormProps } from './type';
|
|
4
|
+
declare function MForm(props: IMFormProps): React.JSX.Element;
|
|
5
|
+
declare namespace MForm {
|
|
6
|
+
var displayName: string;
|
|
7
|
+
}
|
|
8
|
+
export default MForm;
|
|
9
|
+
export * from './MFormItemConst';
|
|
10
|
+
export * from './type';
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { CascaderAutoProps, FormInstance, FormItemProps, FormProps, InputNumberProps, InputProps, MentionsProps, RadioGroupProps, RowProps, SelectProps, SliderSingleProps, TreeSelectProps, UploadProps } from 'antd';
|
|
2
|
+
import { CheckboxGroupProps } from 'antd/es/checkbox';
|
|
3
|
+
import { RangePickerProps } from 'antd/es/date-picker';
|
|
4
|
+
import { Rule } from 'antd/es/form';
|
|
5
|
+
import { TextAreaProps } from 'antd/es/input';
|
|
6
|
+
import { SliderRangeProps } from 'antd/es/slider';
|
|
7
|
+
import { DatePickerProps } from 'antd/lib';
|
|
8
|
+
import { ReactElement } from 'react';
|
|
9
|
+
export declare enum MFormItemTypeEnum {
|
|
10
|
+
Input = "input",
|
|
11
|
+
InputNumber = "inputNumber",
|
|
12
|
+
Text = "text",
|
|
13
|
+
Password = "password",
|
|
14
|
+
Radio = "radio",
|
|
15
|
+
Select = "select",
|
|
16
|
+
Checkbox = "checkbox",
|
|
17
|
+
DatePicker = "datePicker",
|
|
18
|
+
RangePicker = "rangePicker",
|
|
19
|
+
Upload = "upload",
|
|
20
|
+
Mentions = "mentions",
|
|
21
|
+
Cascader = "cascader",
|
|
22
|
+
TreeSelect = "treeSelect",
|
|
23
|
+
Slider = "slider"
|
|
24
|
+
}
|
|
25
|
+
export declare type MFormItemLayout = {
|
|
26
|
+
span?: number;
|
|
27
|
+
offset?: number;
|
|
28
|
+
};
|
|
29
|
+
export interface IMFormProps {
|
|
30
|
+
/**
|
|
31
|
+
* 一行显示几个label 默认1个, 其他:2, 3, 4
|
|
32
|
+
*/
|
|
33
|
+
column?: 1 | 2 | 3 | 4;
|
|
34
|
+
/**
|
|
35
|
+
* 需要的数据: [ { label: ...,id: ..., required: ..., type: ..., ... }, ... ]
|
|
36
|
+
*/
|
|
37
|
+
formItems: IMFormItem[];
|
|
38
|
+
/**
|
|
39
|
+
* Antd const [form] = useForm()
|
|
40
|
+
*/
|
|
41
|
+
form?: FormInstance;
|
|
42
|
+
/**
|
|
43
|
+
* 表单其他属性
|
|
44
|
+
*/
|
|
45
|
+
formProps?: FormProps;
|
|
46
|
+
/**
|
|
47
|
+
* 全局 MFormItem layout, 默认为 {labelCol:{span: 7}, wrapperCol: {span: 7}}
|
|
48
|
+
* @type {{labelCol: MFormItemLayout, wrapperCol: MFormItemLayout}}
|
|
49
|
+
* @memberof MFormItem
|
|
50
|
+
*/
|
|
51
|
+
itemLayout?: {
|
|
52
|
+
labelCol?: MFormItemLayout;
|
|
53
|
+
wrapperCol?: MFormItemLayout;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Antd Row 的其他属性
|
|
57
|
+
*/
|
|
58
|
+
formRowProps?: RowProps;
|
|
59
|
+
}
|
|
60
|
+
export interface IMFormBaseItem {
|
|
61
|
+
/**
|
|
62
|
+
* 属性名
|
|
63
|
+
*/
|
|
64
|
+
id: string;
|
|
65
|
+
/**
|
|
66
|
+
* label名称
|
|
67
|
+
*/
|
|
68
|
+
label: string;
|
|
69
|
+
/**
|
|
70
|
+
* 组件是否禁用
|
|
71
|
+
*/
|
|
72
|
+
disabled?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* form类型 FORM_TYPE
|
|
75
|
+
*/
|
|
76
|
+
type?: MFormItemTypeEnum;
|
|
77
|
+
/**
|
|
78
|
+
* 初始值
|
|
79
|
+
*/
|
|
80
|
+
initialValue?: any;
|
|
81
|
+
/**
|
|
82
|
+
* rules required的验证消息, 不填写则不验证
|
|
83
|
+
*/
|
|
84
|
+
required?: string;
|
|
85
|
+
/**
|
|
86
|
+
* rule-max, 正则,验证消息
|
|
87
|
+
*/
|
|
88
|
+
rules?: Rule[];
|
|
89
|
+
/**
|
|
90
|
+
* 自定义form
|
|
91
|
+
*/
|
|
92
|
+
render?: (form?: FormInstance) => ReactElement;
|
|
93
|
+
/**
|
|
94
|
+
* Antd MForm.Item 的其他属性
|
|
95
|
+
*/
|
|
96
|
+
formItemProps?: FormItemProps;
|
|
97
|
+
/**
|
|
98
|
+
* MFormItem layout, 默认为 {labelCol:{span: 7}, wrapperCol: {span: 7}}
|
|
99
|
+
* @type {{labelCol: MFormItemLayout, wrapperCol: MFormItemLayout}}
|
|
100
|
+
* @memberof MFormItem
|
|
101
|
+
*/
|
|
102
|
+
itemLayout?: {
|
|
103
|
+
labelCol?: MFormItemLayout;
|
|
104
|
+
wrapperCol?: MFormItemLayout;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* 当前表单占据行的宽度 1-24 默认 24 / column
|
|
108
|
+
*/
|
|
109
|
+
span?: number;
|
|
110
|
+
/**
|
|
111
|
+
* 是否显示当前组件 默认显示
|
|
112
|
+
*/
|
|
113
|
+
show?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* item组件的其他属性
|
|
116
|
+
*/
|
|
117
|
+
props?: any;
|
|
118
|
+
}
|
|
119
|
+
export interface IMFormInputItem extends IMFormBaseItem {
|
|
120
|
+
type: MFormItemTypeEnum.Input | MFormItemTypeEnum.Password;
|
|
121
|
+
props?: InputProps;
|
|
122
|
+
placeholder?: string;
|
|
123
|
+
maxLength?: number;
|
|
124
|
+
}
|
|
125
|
+
export interface IMFormInputNumItem extends IMFormBaseItem {
|
|
126
|
+
type: MFormItemTypeEnum.InputNumber;
|
|
127
|
+
props?: InputNumberProps;
|
|
128
|
+
placeholder?: string;
|
|
129
|
+
maxLength?: number;
|
|
130
|
+
}
|
|
131
|
+
export interface IMFormTextItem extends IMFormBaseItem {
|
|
132
|
+
type: MFormItemTypeEnum.Text;
|
|
133
|
+
props?: TextAreaProps;
|
|
134
|
+
placeholder?: string;
|
|
135
|
+
maxLength?: number;
|
|
136
|
+
}
|
|
137
|
+
export interface IMFormRadioGroupItem extends IMFormBaseItem {
|
|
138
|
+
type: MFormItemTypeEnum.Radio;
|
|
139
|
+
props?: RadioGroupProps;
|
|
140
|
+
}
|
|
141
|
+
export interface IMFormChkBoxGroupItem extends IMFormBaseItem {
|
|
142
|
+
type: MFormItemTypeEnum.Checkbox;
|
|
143
|
+
props?: CheckboxGroupProps;
|
|
144
|
+
}
|
|
145
|
+
export interface IMFormSelectItem<T = any> extends IMFormBaseItem {
|
|
146
|
+
type: MFormItemTypeEnum.Select;
|
|
147
|
+
placeholder?: string;
|
|
148
|
+
props?: SelectProps<T>;
|
|
149
|
+
}
|
|
150
|
+
export interface IMFormDatePickerItem extends IMFormBaseItem {
|
|
151
|
+
type: MFormItemTypeEnum.DatePicker;
|
|
152
|
+
placeholder?: string;
|
|
153
|
+
props?: DatePickerProps;
|
|
154
|
+
}
|
|
155
|
+
export interface IMFormRangePickerItem extends IMFormBaseItem {
|
|
156
|
+
type: MFormItemTypeEnum.RangePicker;
|
|
157
|
+
placeholder?: [string, string];
|
|
158
|
+
props?: RangePickerProps;
|
|
159
|
+
}
|
|
160
|
+
export interface IMFormUploadItem extends IMFormBaseItem {
|
|
161
|
+
type: MFormItemTypeEnum.Upload;
|
|
162
|
+
children?: ReactElement;
|
|
163
|
+
props?: UploadProps;
|
|
164
|
+
}
|
|
165
|
+
export interface IMFormMentionsItem extends IMFormBaseItem {
|
|
166
|
+
type: MFormItemTypeEnum.Mentions;
|
|
167
|
+
placeholder?: string;
|
|
168
|
+
props?: MentionsProps;
|
|
169
|
+
}
|
|
170
|
+
export interface IMFormCascaderItem extends IMFormBaseItem {
|
|
171
|
+
type: MFormItemTypeEnum.Cascader;
|
|
172
|
+
placeholder?: string;
|
|
173
|
+
props?: CascaderAutoProps;
|
|
174
|
+
}
|
|
175
|
+
export interface IMFormTreeSelectItem extends IMFormBaseItem {
|
|
176
|
+
type: MFormItemTypeEnum.TreeSelect;
|
|
177
|
+
placeholder?: string;
|
|
178
|
+
props?: TreeSelectProps;
|
|
179
|
+
}
|
|
180
|
+
export interface IMFormSliderItem extends IMFormBaseItem {
|
|
181
|
+
type: MFormItemTypeEnum.Slider;
|
|
182
|
+
props?: SliderSingleProps | SliderRangeProps;
|
|
183
|
+
}
|
|
184
|
+
export declare type IMFormItem = IMFormInputItem | IMFormInputNumItem | IMFormSelectItem | IMFormChkBoxGroupItem | IMFormRadioGroupItem | IMFormTextItem | IMFormDatePickerItem | IMFormRangePickerItem | IMFormUploadItem | IMFormMentionsItem | IMFormCascaderItem | IMFormTreeSelectItem | IMFormSliderItem;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ButtonProps } from 'antd';
|
|
2
|
+
import { FormInstance } from 'antd/lib';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { IMFormItem } from '../MForm';
|
|
5
|
+
import './index.scss';
|
|
6
|
+
export interface IMSearchProps {
|
|
7
|
+
form?: FormInstance;
|
|
8
|
+
/**
|
|
9
|
+
* 需要的数据: [ { lable: ...,id: ..., required: ..., type: ..., }, ... ]
|
|
10
|
+
*/
|
|
11
|
+
searchItems: IMFormItem[];
|
|
12
|
+
className?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 搜索按钮 params返回form表单的数据
|
|
15
|
+
*/
|
|
16
|
+
onSearch?: (params: any, isReset: boolean) => any;
|
|
17
|
+
/**
|
|
18
|
+
* 搜索项默认展开,不填写默认false
|
|
19
|
+
*/
|
|
20
|
+
defaultShowAll?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 自定义按钮
|
|
23
|
+
*/
|
|
24
|
+
customButtons?: ButtonProps[];
|
|
25
|
+
}
|
|
26
|
+
declare const MSearch: React.FC<IMSearchProps>;
|
|
27
|
+
export default MSearch;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格
|
|
3
|
+
*/
|
|
4
|
+
import { TableProps } from 'antd';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
export interface IMTableProps extends TableProps {
|
|
7
|
+
}
|
|
8
|
+
declare function MTable(props: IMTableProps): React.JSX.Element;
|
|
9
|
+
declare namespace MTable {
|
|
10
|
+
var displayName: string;
|
|
11
|
+
}
|
|
12
|
+
export default MTable;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ThemeConfig } from 'antd';
|
|
2
|
+
import React, { Component } from 'react';
|
|
3
|
+
import { IModalBaseProps } from '../../utils';
|
|
4
|
+
export declare type IMiModalProps = IModalBaseProps & {
|
|
5
|
+
mode?: string;
|
|
6
|
+
};
|
|
7
|
+
declare class MiModal extends Component<IMiModalProps> {
|
|
8
|
+
static setMode: (mode: string) => void;
|
|
9
|
+
static setThemeConfig: (fn: (m: string) => ThemeConfig) => void;
|
|
10
|
+
static open: (props: IMiModalProps) => import("../../utils").IModalControls<IMiModalProps>;
|
|
11
|
+
getTheme(): ThemeConfig;
|
|
12
|
+
handleCancel: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
13
|
+
handleOk: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
14
|
+
render(): React.JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
export default MiModal;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ThemeConfig } from 'antd';
|
|
3
|
+
interface ThemeContextType {
|
|
4
|
+
theme?: ThemeConfig;
|
|
5
|
+
}
|
|
6
|
+
export declare const MiThemeProvider: import("react").Provider<ThemeContextType>;
|
|
7
|
+
export declare function useMiThemeConfig(): ThemeContextType;
|
|
8
|
+
export * from './CompThemeProvider';
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { default as ItemRow } from './ItemsRow';
|
|
2
|
+
export { default as MBreadcrumb } from './MBreadcrumb';
|
|
3
|
+
export { default as MDescriptions } from './MDescriptions';
|
|
4
|
+
export * from './MForm';
|
|
5
|
+
export { default as MForm } from './MForm';
|
|
6
|
+
export { default as MiModal } from './MiModal';
|
|
7
|
+
export { default as MSearch } from './MSearch';
|
|
8
|
+
export { default as MTable } from './MTable';
|
|
9
|
+
export * from './ThemeContext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const PAGE_SIZE = 10;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare class PatternType {
|
|
2
|
+
static readonly integerRegex: RegExp;
|
|
3
|
+
static readonly positiveIntegerRegex: RegExp;
|
|
4
|
+
static readonly negativeIntegerRegex: RegExp;
|
|
5
|
+
static readonly floatRegex: RegExp;
|
|
6
|
+
static readonly letter: RegExp;
|
|
7
|
+
static readonly chinese: RegExp;
|
|
8
|
+
static readonly number: RegExp;
|
|
9
|
+
static readonly username: RegExp;
|
|
10
|
+
static readonly strongUsername: RegExp;
|
|
11
|
+
static readonly password: RegExp;
|
|
12
|
+
static readonly strongPassword: RegExp;
|
|
13
|
+
static readonly phone: RegExp;
|
|
14
|
+
static readonly phoneWithAreaCode: RegExp;
|
|
15
|
+
static readonly email: RegExp;
|
|
16
|
+
static readonly idCard: RegExp;
|
|
17
|
+
static readonly bankCard: RegExp;
|
|
18
|
+
static readonly zipCode: RegExp;
|
|
19
|
+
static readonly ip: RegExp;
|
|
20
|
+
static readonly url: RegExp;
|
|
21
|
+
static readonly carNumber: RegExp;
|
|
22
|
+
static readonly time: RegExp;
|
|
23
|
+
static readonly date: RegExp;
|
|
24
|
+
}
|