xmirror-components 1.0.30-alpha.8 → 1.0.31
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/README.md +1129 -11
- package/build/dist/index.cjs +36 -36
- package/build/dist/index.mjs +1914 -1884
- package/build/es/components/ConfigProvider/index.js +11 -14
- package/build/es/components/ConfigProvider/types.d.ts +2 -0
- package/build/es/components/IntlProvider/FormattedMessage/index.d.ts +7 -0
- package/build/es/components/IntlProvider/FormattedMessage/index.js +8 -0
- package/build/es/components/IntlProvider/index.d.ts +12 -0
- package/build/es/components/IntlProvider/index.js +17 -0
- package/build/es/components/IntlProvider/types.d.ts +7 -0
- package/build/es/components/IntlProvider/types.js +1 -0
- package/build/es/components/IntlProvider/useIntl/index.d.ts +14 -0
- package/build/es/components/IntlProvider/useIntl/index.js +26 -0
- package/build/es/components/SearchArea/ToggleButton/index.js +2 -1
- package/build/es/components/SearchArea/index.js +6 -3
- package/build/es/components/Table/Footer/index.d.ts +1 -1
- package/build/es/components/Table/Footer/index.js +1 -1
- package/build/es/components/Table/PopoverSetColumns/index.js +1 -1
- package/build/es/hooks/useTable/index.d.ts +2 -2
- package/build/es/hooks/useTable/index.js +1 -1
- package/build/es/hooks/useTable/types.d.ts +3 -3
- package/build/es/locale/en-us.d.ts +25 -0
- package/build/es/locale/en-us.js +27 -0
- package/build/es/locale/index.d.ts +3 -0
- package/build/es/locale/index.js +7 -0
- package/build/es/locale/types.d.ts +9 -0
- package/build/es/locale/types.js +1 -0
- package/build/es/locale/zh-cn.d.ts +25 -0
- package/build/es/locale/zh-cn.js +28 -0
- package/build/lib/components/ConfigProvider/index.js +11 -14
- package/build/lib/components/IntlProvider/FormattedMessage/index.js +11 -0
- package/build/lib/components/IntlProvider/index.js +25 -0
- package/build/lib/components/IntlProvider/types.js +2 -0
- package/build/lib/components/IntlProvider/useIntl/index.js +31 -0
- package/build/lib/components/SearchArea/ToggleButton/index.js +2 -1
- package/build/lib/components/SearchArea/index.js +6 -3
- package/build/lib/components/Table/Footer/index.js +2 -2
- package/build/lib/components/Table/PopoverSetColumns/index.js +2 -2
- package/build/lib/hooks/useTable/index.js +2 -2
- package/build/lib/index.d.ts +7 -4
- package/build/lib/locale/en-us.d.ts +25 -0
- package/build/lib/locale/en-us.js +29 -0
- package/build/lib/locale/index.d.ts +3 -0
- package/build/lib/locale/index.js +13 -0
- package/build/lib/locale/types.d.ts +9 -0
- package/build/lib/locale/types.js +2 -0
- package/build/lib/locale/zh-cn.d.ts +25 -0
- package/build/lib/locale/zh-cn.js +30 -0
- package/build/package.json +1 -1
- package/build/types/components/ConfigProvider/types.d.ts +2 -0
- package/build/types/components/IntlProvider/FormattedMessage/index.d.ts +7 -0
- package/build/types/components/IntlProvider/index.d.ts +12 -0
- package/build/types/components/IntlProvider/types.d.ts +7 -0
- package/build/types/components/IntlProvider/useIntl/index.d.ts +14 -0
- package/build/types/components/Table/Footer/index.d.ts +1 -1
- package/build/types/hooks/useTable/index.d.ts +2 -2
- package/build/types/hooks/useTable/types.d.ts +3 -3
- package/build/types/locale/en-us.d.ts +25 -0
- package/build/types/locale/index.d.ts +3 -0
- package/build/types/locale/types.d.ts +9 -0
- package/build/types/locale/zh-cn.d.ts +25 -0
- package/package.json +1 -1
|
@@ -57,7 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
57
57
|
};
|
|
58
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
59
|
var react_1 = require("react");
|
|
60
|
-
var
|
|
60
|
+
var IntlProvider_1 = require("../../components/IntlProvider");
|
|
61
61
|
var ahooks_1 = require("ahooks");
|
|
62
62
|
var AntdApp_1 = require("../../components/AntdApp");
|
|
63
63
|
var ORDER_MAP = {
|
|
@@ -84,7 +84,7 @@ var defaultOptions = {
|
|
|
84
84
|
function useTable(request, options) {
|
|
85
85
|
var _this = this;
|
|
86
86
|
if (options === void 0) { options = {}; }
|
|
87
|
-
var intl = (0,
|
|
87
|
+
var intl = (0, IntlProvider_1.useIntl)();
|
|
88
88
|
var _a = __assign(__assign({}, defaultOptions), options), rowKey = _a.rowKey, interval = _a.interval, immediate = _a.immediate, defaultPagination = _a.defaultPagination, showRowSelection = _a.showRowSelection, multiPageSelection = _a.multiPageSelection, onBeforeRequest = _a.onBeforeRequest, onAfterRequest = _a.onAfterRequest;
|
|
89
89
|
var tableTimerRef = (0, react_1.useRef)(null);
|
|
90
90
|
var _b = (0, react_1.useState)(false), loading = _b[0], setLoading = _b[1];
|
package/build/lib/index.d.ts
CHANGED
|
@@ -126,6 +126,7 @@ export declare const ConfigContext: default_2.Context<ConfigContextProps>;
|
|
|
126
126
|
declare interface ConfigContextProps {
|
|
127
127
|
iconButton: IconButtonConfig;
|
|
128
128
|
iconFont: IconFontConfig;
|
|
129
|
+
locale: MessagesKeys;
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
export declare function ConfigProvider({ children, config }: ConfigProviderProps): default_2.JSX.Element;
|
|
@@ -229,6 +230,8 @@ declare interface InternalSearchAreaProps extends FormProps<any> {
|
|
|
229
230
|
|
|
230
231
|
export declare let message: MessageInstance;
|
|
231
232
|
|
|
233
|
+
declare type MessagesKeys = 'zh' | 'en';
|
|
234
|
+
|
|
232
235
|
export declare let modal: Omit<ModalStaticFunctions, 'warn'>;
|
|
233
236
|
|
|
234
237
|
export declare let notification: NotificationInstance;
|
|
@@ -278,17 +281,17 @@ declare interface OptionsProps<T = BaseRecord> {
|
|
|
278
281
|
* 响应时回调
|
|
279
282
|
* @param response 响应数据
|
|
280
283
|
*/
|
|
281
|
-
onAfterRequest?: (response: ResponseType_2<
|
|
284
|
+
onAfterRequest?: <R = T>(response: ResponseType_2<R>) => Promise<ResponseType_2<R> | undefined> | R[] | undefined;
|
|
282
285
|
}
|
|
283
286
|
|
|
284
|
-
declare interface PaginationResponse<T
|
|
287
|
+
declare interface PaginationResponse<T> {
|
|
285
288
|
records: T[];
|
|
286
289
|
total: number;
|
|
287
290
|
current: number;
|
|
288
291
|
size: number;
|
|
289
292
|
}
|
|
290
293
|
|
|
291
|
-
declare type RequestFunction<T = BaseRecord> = (params:
|
|
294
|
+
declare type RequestFunction<T = BaseRecord, P = RequestParams> = (params: P) => Promise<ResponseType_2<T>>;
|
|
292
295
|
|
|
293
296
|
declare interface RequestParams {
|
|
294
297
|
pageNum: number;
|
|
@@ -447,7 +450,7 @@ declare interface ToggleButtonProps {
|
|
|
447
450
|
|
|
448
451
|
export declare function useRequest<TData, TParams extends unknown[]>(service: Service<TData, TParams>, options?: Options<TData, TParams>, plugins?: Array<Plugin_2<TData, TParams>>): WrappedResult<TData, TParams>;
|
|
449
452
|
|
|
450
|
-
export declare function useTable<T
|
|
453
|
+
export declare function useTable<T = BaseRecord, P = RequestParams>(request: RequestFunction<T, P>, options?: OptionsProps<T>): ReturnData<T>;
|
|
451
454
|
|
|
452
455
|
declare interface WrappedResult<TData, TParams extends unknown[]> extends Omit<Result<TData, TParams>, 'data'> {
|
|
453
456
|
/**
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
'operation.add': string;
|
|
3
|
+
'operation.delete': string;
|
|
4
|
+
'operation.batchDelete': string;
|
|
5
|
+
'operation.edit': string;
|
|
6
|
+
'operation.download': string;
|
|
7
|
+
'operation.logout': string;
|
|
8
|
+
'operation.export': string;
|
|
9
|
+
'operation.close': string;
|
|
10
|
+
'operation.details': string;
|
|
11
|
+
'operation.confirm': string;
|
|
12
|
+
'operation.save': string;
|
|
13
|
+
'operation.cancel': string;
|
|
14
|
+
'component.table.selected': string;
|
|
15
|
+
'component.table.total': string;
|
|
16
|
+
'component.table.visibleError': string;
|
|
17
|
+
'component.searcharea.toggle': string;
|
|
18
|
+
'component.searcharea.submit': string;
|
|
19
|
+
'component.searcharea.reset': string;
|
|
20
|
+
'component.searcharea.close': string;
|
|
21
|
+
'message.delete': string;
|
|
22
|
+
'message.success': string;
|
|
23
|
+
'table.pagination.total': string;
|
|
24
|
+
};
|
|
25
|
+
export default messages;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var messages = {
|
|
4
|
+
'operation.add': 'Add',
|
|
5
|
+
'operation.delete': 'Delete',
|
|
6
|
+
'operation.batchDelete': 'Batch Delete',
|
|
7
|
+
'operation.edit': 'Edit',
|
|
8
|
+
'operation.download': 'Download',
|
|
9
|
+
'operation.logout': 'Logout',
|
|
10
|
+
'operation.export': 'Export',
|
|
11
|
+
'operation.close': 'Close',
|
|
12
|
+
'operation.details': 'Details',
|
|
13
|
+
'operation.confirm': 'Confirm',
|
|
14
|
+
'operation.save': 'Save',
|
|
15
|
+
'operation.cancel': 'Cancel',
|
|
16
|
+
// Components
|
|
17
|
+
'component.table.selected': '{length} selected',
|
|
18
|
+
'component.table.total': 'Total {total} items',
|
|
19
|
+
'component.table.visibleError': 'At least one field must be visible',
|
|
20
|
+
'component.searcharea.toggle': 'Advanced Search',
|
|
21
|
+
'component.searcharea.submit': 'Submit',
|
|
22
|
+
'component.searcharea.reset': 'Reset',
|
|
23
|
+
'component.searcharea.close': 'Close',
|
|
24
|
+
// Messages
|
|
25
|
+
'message.delete': 'This action cannot be undone, confirm delete?',
|
|
26
|
+
'message.success': 'Operation successful',
|
|
27
|
+
'table.pagination.total': 'Total {total} items',
|
|
28
|
+
};
|
|
29
|
+
exports.default = messages;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.messages = void 0;
|
|
7
|
+
var zh_cn_1 = __importDefault(require("./zh-cn"));
|
|
8
|
+
var en_us_1 = __importDefault(require("./en-us"));
|
|
9
|
+
var messages = {
|
|
10
|
+
zh: zh_cn_1.default,
|
|
11
|
+
en: en_us_1.default
|
|
12
|
+
};
|
|
13
|
+
exports.messages = messages;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
'operation.add': string;
|
|
3
|
+
'operation.delete': string;
|
|
4
|
+
'operation.batchDelete': string;
|
|
5
|
+
'operation.edit': string;
|
|
6
|
+
'operation.download': string;
|
|
7
|
+
'operation.logout': string;
|
|
8
|
+
'operation.export': string;
|
|
9
|
+
'operation.close': string;
|
|
10
|
+
'operation.details': string;
|
|
11
|
+
'operation.confirm': string;
|
|
12
|
+
'operation.save': string;
|
|
13
|
+
'operation.cancel': string;
|
|
14
|
+
'component.table.selected': string;
|
|
15
|
+
'component.table.total': string;
|
|
16
|
+
'component.table.visibleError': string;
|
|
17
|
+
'component.searcharea.toggle': string;
|
|
18
|
+
'component.searcharea.submit': string;
|
|
19
|
+
'component.searcharea.reset': string;
|
|
20
|
+
'component.searcharea.close': string;
|
|
21
|
+
'message.delete': string;
|
|
22
|
+
'message.success': string;
|
|
23
|
+
'table.pagination.total': string;
|
|
24
|
+
};
|
|
25
|
+
export default messages;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var messages = {
|
|
4
|
+
// 操作类
|
|
5
|
+
'operation.add': '添加',
|
|
6
|
+
'operation.delete': '删除',
|
|
7
|
+
'operation.batchDelete': '批量删除',
|
|
8
|
+
'operation.edit': '编辑',
|
|
9
|
+
'operation.download': '下载',
|
|
10
|
+
'operation.logout': '退出登录',
|
|
11
|
+
'operation.export': '导出',
|
|
12
|
+
'operation.close': '关闭',
|
|
13
|
+
'operation.details': '详情',
|
|
14
|
+
'operation.confirm': '确认',
|
|
15
|
+
'operation.save': '保存',
|
|
16
|
+
'operation.cancel': '取消',
|
|
17
|
+
// 组件
|
|
18
|
+
'component.table.selected': '已选{length}条',
|
|
19
|
+
'component.table.total': '共{total}条',
|
|
20
|
+
'component.table.visibleError': '列表最少保留一个字段',
|
|
21
|
+
'component.searcharea.toggle': '高级搜索',
|
|
22
|
+
'component.searcharea.submit': '筛选',
|
|
23
|
+
'component.searcharea.reset': '重置',
|
|
24
|
+
'component.searcharea.close': '收起',
|
|
25
|
+
// 提示类
|
|
26
|
+
'message.delete': '删除操作无法恢复,确认删除?',
|
|
27
|
+
'message.success': '操作成功',
|
|
28
|
+
'table.pagination.total': '共{total}条',
|
|
29
|
+
};
|
|
30
|
+
exports.default = messages;
|
package/build/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { IconButtonProps } from "../IconButton";
|
|
3
3
|
import { IconFontProps } from "../IconFont";
|
|
4
|
+
import { type MessagesKeys } from "../../locale";
|
|
4
5
|
type IconButtonConfig = Pick<IconButtonProps, 'size' | 'className' | 'style'> & {
|
|
5
6
|
render: (props: IconButtonProps & {
|
|
6
7
|
children: React.ReactNode;
|
|
@@ -10,6 +11,7 @@ type IconFontConfig = Pick<IconFontProps, 'className' | 'style'>;
|
|
|
10
11
|
export interface ConfigContextProps {
|
|
11
12
|
iconButton: IconButtonConfig;
|
|
12
13
|
iconFont: IconFontConfig;
|
|
14
|
+
locale: MessagesKeys;
|
|
13
15
|
}
|
|
14
16
|
export type ConfigProviderConfigProps = Partial<ConfigContextProps>;
|
|
15
17
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IntlContextProps, IntlProviderConfigProps } from './types';
|
|
3
|
+
export type { IntlProviderConfigProps, IntlContextProps } from './types';
|
|
4
|
+
import FormattedMessage from './FormattedMessage';
|
|
5
|
+
import useIntl from './useIntl';
|
|
6
|
+
export declare const IntlContext: React.Context<IntlContextProps>;
|
|
7
|
+
interface IntlProviderProps {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
config: IntlProviderConfigProps;
|
|
10
|
+
}
|
|
11
|
+
export default function IntlProvider({ children, config }: IntlProviderProps): React.JSX.Element;
|
|
12
|
+
export { FormattedMessage, useIntl };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface FormattedMessageProps {
|
|
2
|
+
id: string;
|
|
3
|
+
defaultMessage?: string;
|
|
4
|
+
values?: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
export declare const formatMessageFn: ({ messages, locale }: {
|
|
7
|
+
messages: any;
|
|
8
|
+
locale: string;
|
|
9
|
+
}) => ({ id, defaultMessage, values }: FormattedMessageProps) => any;
|
|
10
|
+
export default function useIntl(): {
|
|
11
|
+
$t: ({ id, defaultMessage }: FormattedMessageProps, values?: Record<string, any>) => any;
|
|
12
|
+
formatMessage: ({ id, defaultMessage, values }: FormattedMessageProps) => any;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type OptionsProps, type ReturnData, type BaseRecord, type RequestFunction } from './types';
|
|
2
|
-
declare function useTable<T
|
|
1
|
+
import { type OptionsProps, type ReturnData, type BaseRecord, type RequestParams, type RequestFunction } from './types';
|
|
2
|
+
declare function useTable<T = BaseRecord, P = RequestParams>(request: RequestFunction<T, P>, options?: OptionsProps<T>): ReturnData<T>;
|
|
3
3
|
export default useTable;
|
|
@@ -8,7 +8,7 @@ export interface ResponseJSON<T = any> {
|
|
|
8
8
|
message: string;
|
|
9
9
|
data: T;
|
|
10
10
|
}
|
|
11
|
-
export interface PaginationResponse<T
|
|
11
|
+
export interface PaginationResponse<T> {
|
|
12
12
|
records: T[];
|
|
13
13
|
total: number;
|
|
14
14
|
current: number;
|
|
@@ -69,7 +69,7 @@ export interface OptionsProps<T = BaseRecord> {
|
|
|
69
69
|
* 响应时回调
|
|
70
70
|
* @param response 响应数据
|
|
71
71
|
*/
|
|
72
|
-
onAfterRequest?: (response: ResponseType<
|
|
72
|
+
onAfterRequest?: <R = T>(response: ResponseType<R>) => Promise<ResponseType<R> | undefined> | R[] | undefined;
|
|
73
73
|
}
|
|
74
74
|
export interface ReturnData<T = BaseRecord> {
|
|
75
75
|
/**
|
|
@@ -120,4 +120,4 @@ export interface ReturnData<T = BaseRecord> {
|
|
|
120
120
|
selectedRowKeys: Array<string | number>;
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
|
-
export type RequestFunction<T = BaseRecord> = (params:
|
|
123
|
+
export type RequestFunction<T = BaseRecord, P = RequestParams> = (params: P) => Promise<ResponseType<T>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
'operation.add': string;
|
|
3
|
+
'operation.delete': string;
|
|
4
|
+
'operation.batchDelete': string;
|
|
5
|
+
'operation.edit': string;
|
|
6
|
+
'operation.download': string;
|
|
7
|
+
'operation.logout': string;
|
|
8
|
+
'operation.export': string;
|
|
9
|
+
'operation.close': string;
|
|
10
|
+
'operation.details': string;
|
|
11
|
+
'operation.confirm': string;
|
|
12
|
+
'operation.save': string;
|
|
13
|
+
'operation.cancel': string;
|
|
14
|
+
'component.table.selected': string;
|
|
15
|
+
'component.table.total': string;
|
|
16
|
+
'component.table.visibleError': string;
|
|
17
|
+
'component.searcharea.toggle': string;
|
|
18
|
+
'component.searcharea.submit': string;
|
|
19
|
+
'component.searcharea.reset': string;
|
|
20
|
+
'component.searcharea.close': string;
|
|
21
|
+
'message.delete': string;
|
|
22
|
+
'message.success': string;
|
|
23
|
+
'table.pagination.total': string;
|
|
24
|
+
};
|
|
25
|
+
export default messages;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const messages: {
|
|
2
|
+
'operation.add': string;
|
|
3
|
+
'operation.delete': string;
|
|
4
|
+
'operation.batchDelete': string;
|
|
5
|
+
'operation.edit': string;
|
|
6
|
+
'operation.download': string;
|
|
7
|
+
'operation.logout': string;
|
|
8
|
+
'operation.export': string;
|
|
9
|
+
'operation.close': string;
|
|
10
|
+
'operation.details': string;
|
|
11
|
+
'operation.confirm': string;
|
|
12
|
+
'operation.save': string;
|
|
13
|
+
'operation.cancel': string;
|
|
14
|
+
'component.table.selected': string;
|
|
15
|
+
'component.table.total': string;
|
|
16
|
+
'component.table.visibleError': string;
|
|
17
|
+
'component.searcharea.toggle': string;
|
|
18
|
+
'component.searcharea.submit': string;
|
|
19
|
+
'component.searcharea.reset': string;
|
|
20
|
+
'component.searcharea.close': string;
|
|
21
|
+
'message.delete': string;
|
|
22
|
+
'message.success': string;
|
|
23
|
+
'table.pagination.total': string;
|
|
24
|
+
};
|
|
25
|
+
export default messages;
|