@mi-avalon/libs 0.0.6 → 0.0.8
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/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 -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 +2 -0
- package/dist/libs.cjs.development.js +1534 -62
- package/dist/libs.cjs.development.js.map +1 -1
- package/dist/libs.cjs.production.min.js +1 -1
- package/dist/libs.cjs.production.min.js.map +1 -1
- package/dist/libs.esm.js +1518 -63
- package/dist/libs.esm.js.map +1 -1
- package/package.json +19 -7
- package/src/constants/date.ts +0 -11
- package/src/constants/index.ts +0 -3
- package/src/constants/pageInfo.ts +0 -1
- package/src/constants/pattern.ts +0 -53
- package/src/index.tsx +0 -4
- package/src/utils/calc.ts +0 -92
- package/src/utils/index.ts +0 -5
- package/src/utils/nextTick.ts +0 -89
- package/src/utils/openModal.tsx +0 -137
- package/src/utils/util.ts +0 -37
- package/src/utils/version.ts +0 -206
|
@@ -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';
|
|
@@ -0,0 +1,9 @@
|
|
|
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,16 @@
|
|
|
1
|
+
declare type UnwrapPromise<T> = T extends Promise<infer U> ? U : T;
|
|
2
|
+
export declare type UseFuncRequestOptions<T extends (...args: any[]) => Promise<any>> = {
|
|
3
|
+
autoRunArgs?: Parameters<T>;
|
|
4
|
+
onBefore?: (...args: Parameters<T>) => boolean | Promise<boolean>;
|
|
5
|
+
onSuccess?: (data: UnwrapPromise<ReturnType<T>>) => void | Promise<void>;
|
|
6
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
7
|
+
onFinally?: () => void | Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export declare function useFuncRequest<T extends (...args: any[]) => Promise<any>>(asyncFunc: T, options?: UseFuncRequestOptions<T>): {
|
|
10
|
+
run: (...args: Parameters<T>) => Promise<any>;
|
|
11
|
+
cancel: () => void;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
error: Error | null;
|
|
14
|
+
data: UnwrapPromise<ReturnType<T>> | null;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare type Callback = () => void;
|
|
2
|
+
interface UseTimeoutReturn {
|
|
3
|
+
start: Callback;
|
|
4
|
+
isRunning: boolean;
|
|
5
|
+
clear: Callback;
|
|
6
|
+
}
|
|
7
|
+
declare function useInterval(callback: Callback, delay: number | null, immediate?: boolean): UseTimeoutReturn;
|
|
8
|
+
export { useInterval };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface IPaginationProps {
|
|
3
|
+
current: number;
|
|
4
|
+
pageSize: number;
|
|
5
|
+
total: number;
|
|
6
|
+
onChange: (page: number, pageSize: number) => Promise<void>;
|
|
7
|
+
onShowSizeChange: (size: number, current: number) => Promise<void>;
|
|
8
|
+
showTotal?: (t: number) => React.ReactNode;
|
|
9
|
+
showQuickJumper?: boolean;
|
|
10
|
+
showSizeChanger?: boolean;
|
|
11
|
+
}
|
|
12
|
+
interface PaginationResult<T> {
|
|
13
|
+
tableProps: {
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
dataSource: T[];
|
|
16
|
+
};
|
|
17
|
+
loading?: boolean;
|
|
18
|
+
dataSource: T[];
|
|
19
|
+
paginationProps: IPaginationProps;
|
|
20
|
+
isFirstComplete: boolean;
|
|
21
|
+
refresh: (resetPage?: boolean) => Promise<void>;
|
|
22
|
+
debounceRefresh: (resetPage?: boolean) => void;
|
|
23
|
+
setDataSource: (data: T[]) => void;
|
|
24
|
+
}
|
|
25
|
+
interface IServerParams {
|
|
26
|
+
offset: number;
|
|
27
|
+
limit: number;
|
|
28
|
+
current: number;
|
|
29
|
+
}
|
|
30
|
+
declare type IInfoBack<T> = {
|
|
31
|
+
dataSource: T[];
|
|
32
|
+
total: number;
|
|
33
|
+
};
|
|
34
|
+
declare type IInfoServer<T> = (params: IServerParams) => IInfoBack<T> | Promise<IInfoBack<T>>;
|
|
35
|
+
interface IInfoOption<T> {
|
|
36
|
+
isReady?: boolean;
|
|
37
|
+
dataSource?: T[];
|
|
38
|
+
current?: number;
|
|
39
|
+
pageSize?: number;
|
|
40
|
+
}
|
|
41
|
+
export declare const usePagination: <T>(server: IInfoServer<T>, deps?: any[] | undefined, option?: IInfoOption<T> | undefined) => PaginationResult<T>;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare type Callback = () => void;
|
|
2
|
+
interface UseTimeoutReturn {
|
|
3
|
+
start: Callback;
|
|
4
|
+
isRunning: boolean;
|
|
5
|
+
clear: Callback;
|
|
6
|
+
}
|
|
7
|
+
declare function useTimeout(callback: Callback, delay: number | null, immediate?: boolean): UseTimeoutReturn;
|
|
8
|
+
export { useTimeout };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { DependencyList } from 'react';
|
|
2
|
+
export interface IPaginationResult<T> {
|
|
3
|
+
/**
|
|
4
|
+
* 数据
|
|
5
|
+
*
|
|
6
|
+
* @memberof IPaginationResult
|
|
7
|
+
*/
|
|
8
|
+
dataSource: T[];
|
|
9
|
+
/**
|
|
10
|
+
* 加载状态
|
|
11
|
+
*
|
|
12
|
+
* @memberof IPaginationResult
|
|
13
|
+
*/
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* 是否完成了一次请求
|
|
17
|
+
*
|
|
18
|
+
* @memberof IPaginationResult
|
|
19
|
+
*/
|
|
20
|
+
isFirstComplete: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 分页信息
|
|
23
|
+
*
|
|
24
|
+
* @memberof IPaginationResult
|
|
25
|
+
*/
|
|
26
|
+
paginationProps: {
|
|
27
|
+
current: number;
|
|
28
|
+
pageSize: number;
|
|
29
|
+
total: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* reset 是否重置查询
|
|
33
|
+
*
|
|
34
|
+
* @memberof IPaginationResult
|
|
35
|
+
*/
|
|
36
|
+
refresh: (reset?: boolean) => Promise<void>;
|
|
37
|
+
debounceRefresh: (reset?: boolean) => void;
|
|
38
|
+
setDataSource: (data: T[]) => void;
|
|
39
|
+
setTotal: (total: number) => void;
|
|
40
|
+
}
|
|
41
|
+
interface IServerParams {
|
|
42
|
+
offset: number;
|
|
43
|
+
limit: number;
|
|
44
|
+
current: number;
|
|
45
|
+
}
|
|
46
|
+
declare type IInfoBack<T> = {
|
|
47
|
+
dataSource: T[];
|
|
48
|
+
total: number;
|
|
49
|
+
};
|
|
50
|
+
declare type IInfoServer<T> = (params: IServerParams) => IInfoBack<T> | Promise<IInfoBack<T>>;
|
|
51
|
+
interface IInfoOption<T> {
|
|
52
|
+
/**
|
|
53
|
+
* 第一次是否执行server
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
isReady?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 默认的数据
|
|
59
|
+
*
|
|
60
|
+
*/
|
|
61
|
+
dataSource?: T[];
|
|
62
|
+
/**
|
|
63
|
+
* 默认当前第几页
|
|
64
|
+
*
|
|
65
|
+
*/
|
|
66
|
+
current?: number;
|
|
67
|
+
/**
|
|
68
|
+
* 默认一页几条数据
|
|
69
|
+
*
|
|
70
|
+
*/
|
|
71
|
+
pageSize?: number;
|
|
72
|
+
}
|
|
73
|
+
export declare const useVirtualList: <T>(server: IInfoServer<T>, deps?: DependencyList | undefined, option?: IInfoOption<T> | undefined) => IPaginationResult<T>;
|
|
74
|
+
export {};
|
package/dist/index.d.ts
CHANGED