xmirror-components 1.0.30-alpha.7 → 1.0.30
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 +1158 -10
- package/build/dist/index.cjs +65 -34
- package/build/dist/index.mjs +4342 -2757
- 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/components/Table/ResizableColumns/index.d.ts +9 -0
- package/build/es/components/Table/ResizableColumns/index.js +76 -0
- package/build/es/components/Table/ResizableColumns/styles.d.ts +8 -0
- package/build/es/components/Table/ResizableColumns/styles.js +11 -0
- package/build/es/components/Table/index.js +3 -2
- package/build/es/components/Table/types.d.ts +4 -0
- package/build/es/components/Table/utils.d.ts +6 -0
- package/build/es/components/Table/utils.js +13 -0
- package/build/es/hooks/useTable/index.js +20 -14
- package/build/es/hooks/useTable/types.d.ts +8 -29
- 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/components/Table/ResizableColumns/index.js +114 -0
- package/build/lib/components/Table/ResizableColumns/styles.js +17 -0
- package/build/lib/components/Table/index.js +3 -2
- package/build/lib/components/Table/utils.js +17 -0
- package/build/lib/hooks/useTable/index.js +21 -15
- package/build/lib/index.d.ts +8 -36
- 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 +7 -5
- 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/components/Table/ResizableColumns/index.d.ts +9 -0
- package/build/types/components/Table/ResizableColumns/styles.d.ts +8 -0
- package/build/types/components/Table/types.d.ts +4 -0
- package/build/types/components/Table/utils.d.ts +6 -0
- package/build/types/hooks/useTable/types.d.ts +8 -29
- 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 +7 -5
|
@@ -9,18 +9,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
12
|
import React from 'react';
|
|
13
|
+
import IntlProvider from '../IntlProvider';
|
|
14
|
+
import { messages } from '../../locale';
|
|
24
15
|
// 递归合并函数
|
|
25
16
|
function deepMerge(target, source) {
|
|
26
17
|
var result = __assign({}, target);
|
|
@@ -40,14 +31,20 @@ var baseConfig = {
|
|
|
40
31
|
iconButton: {
|
|
41
32
|
size: 'small',
|
|
42
33
|
render: function (_a) {
|
|
43
|
-
var children = _a.children
|
|
34
|
+
var children = _a.children;
|
|
44
35
|
return children;
|
|
45
36
|
}
|
|
46
37
|
},
|
|
47
|
-
iconFont: {}
|
|
38
|
+
iconFont: {},
|
|
39
|
+
locale: 'zh'
|
|
48
40
|
};
|
|
49
41
|
export var ConfigContext = React.createContext(baseConfig);
|
|
50
42
|
export default function ConfigProvider(_a) {
|
|
51
43
|
var children = _a.children, config = _a.config;
|
|
52
|
-
|
|
44
|
+
var mergeConfig = deepMerge(baseConfig, config);
|
|
45
|
+
return (React.createElement(ConfigContext.Provider, { value: mergeConfig },
|
|
46
|
+
React.createElement(IntlProvider, { config: {
|
|
47
|
+
locale: config.locale,
|
|
48
|
+
messages: messages
|
|
49
|
+
} }, children)));
|
|
53
50
|
}
|
|
@@ -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,8 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { IntlContext } from '../index';
|
|
3
|
+
import { formatMessageFn } from '../useIntl';
|
|
4
|
+
export default function FormattedMessage(_a) {
|
|
5
|
+
var id = _a.id, defaultMessage = _a.defaultMessage, values = _a.values;
|
|
6
|
+
var _b = useContext(IntlContext), messages = _b.messages, locale = _b.locale;
|
|
7
|
+
return formatMessageFn({ messages: messages, locale: locale })({ id: id, defaultMessage: defaultMessage, values: values });
|
|
8
|
+
}
|
|
@@ -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,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { messages } from '../../locale';
|
|
3
|
+
import FormattedMessage from './FormattedMessage';
|
|
4
|
+
import useIntl from './useIntl';
|
|
5
|
+
var baseConfig = {
|
|
6
|
+
locale: 'zh',
|
|
7
|
+
messages: messages
|
|
8
|
+
};
|
|
9
|
+
export var IntlContext = React.createContext(baseConfig);
|
|
10
|
+
export default function IntlProvider(_a) {
|
|
11
|
+
var children = _a.children, config = _a.config;
|
|
12
|
+
return (React.createElement(IntlContext.Provider, { value: {
|
|
13
|
+
locale: config.locale,
|
|
14
|
+
messages: messages
|
|
15
|
+
} }, children));
|
|
16
|
+
}
|
|
17
|
+
export { FormattedMessage, useIntl };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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 {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { IntlContext } from '../index';
|
|
3
|
+
export var formatMessageFn = function (_a) {
|
|
4
|
+
var messages = _a.messages, locale = _a.locale;
|
|
5
|
+
return function (_a) {
|
|
6
|
+
var _b;
|
|
7
|
+
var id = _a.id, defaultMessage = _a.defaultMessage, values = _a.values;
|
|
8
|
+
var message = ((_b = messages === null || messages === void 0 ? void 0 : messages[locale]) === null || _b === void 0 ? void 0 : _b[id]) || defaultMessage;
|
|
9
|
+
if (typeof values === 'object') {
|
|
10
|
+
Object.keys(values).forEach(function (key) {
|
|
11
|
+
message = message.replace("{".concat(key, "}"), values[key]);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return message;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default function useIntl() {
|
|
18
|
+
var _a = useContext(IntlContext), messages = _a.messages, locale = _a.locale;
|
|
19
|
+
return {
|
|
20
|
+
$t: function (_a, values) {
|
|
21
|
+
var id = _a.id, defaultMessage = _a.defaultMessage;
|
|
22
|
+
return formatMessageFn({ messages: messages, locale: locale })({ id: id, defaultMessage: defaultMessage, values: values });
|
|
23
|
+
},
|
|
24
|
+
formatMessage: formatMessageFn({ messages: messages, locale: locale })
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -6,6 +6,7 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
6
6
|
import { Button } from 'antd';
|
|
7
7
|
import { CaretUpOutlined } from '@ant-design/icons';
|
|
8
8
|
import styled from '@emotion/styled';
|
|
9
|
+
import { FormattedMessage } from '../../IntlProvider';
|
|
9
10
|
var AnimatedIcon = styled(CaretUpOutlined, {
|
|
10
11
|
shouldForwardProp: function (prop) { return prop !== 'show'; },
|
|
11
12
|
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n transition: transform 0.3s ease-in-out;\n transform: rotate(", ");\n"], ["\n transition: transform 0.3s ease-in-out;\n transform: rotate(", ");\n"])), function (props) { return props.show ? '0deg' : '180deg'; });
|
|
@@ -24,7 +25,7 @@ function ToggleButton(_a) {
|
|
|
24
25
|
onChange === null || onChange === void 0 ? void 0 : onChange(!(panel === null || panel === void 0 ? void 0 : panel.show));
|
|
25
26
|
}, [panel]);
|
|
26
27
|
return (React.createElement(Button, { type: "link", style: { paddingLeft: 0, paddingRight: 0 }, onClick: toggle },
|
|
27
|
-
"
|
|
28
|
+
React.createElement(FormattedMessage, { id: "comgponent.searcharea.togle", defaultMessage: '高级搜索' }),
|
|
28
29
|
React.createElement(AnimatedIcon, { show: show })));
|
|
29
30
|
}
|
|
30
31
|
export default ToggleButton;
|
|
@@ -30,6 +30,7 @@ import { UpOutlined } from '@ant-design/icons';
|
|
|
30
30
|
import styled from '@emotion/styled';
|
|
31
31
|
import Item from './Item';
|
|
32
32
|
import ToggleButton from './ToggleButton';
|
|
33
|
+
import { FormattedMessage } from '../IntlProvider';
|
|
33
34
|
var AnimatedContainer = styled('div', {
|
|
34
35
|
shouldForwardProp: function (prop) { return prop !== 'show'; },
|
|
35
36
|
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n overflow: hidden;\n transition: max-height 0.4s ease-in-out;\n max-height: ", ";\n"], ["\n overflow: hidden;\n transition: max-height 0.4s ease-in-out;\n max-height: ", ";\n"])), function (props) { return props.show ? '450px' : '0'; });
|
|
@@ -106,13 +107,15 @@ function InternalSearchArea(_a) {
|
|
|
106
107
|
: children,
|
|
107
108
|
React.createElement(Col, { flex: 1 },
|
|
108
109
|
React.createElement(SearchAreaHandle, null,
|
|
109
|
-
React.createElement(Button, { loading: loading, type: "primary", onClick: submit },
|
|
110
|
-
|
|
110
|
+
React.createElement(Button, { loading: loading, type: "primary", onClick: submit },
|
|
111
|
+
React.createElement(FormattedMessage, { id: "component.searcharea.submit", defaultMessage: '筛选' })),
|
|
112
|
+
React.createElement(Button, { loading: loading, onClick: reset },
|
|
113
|
+
React.createElement(FormattedMessage, { id: "component.searcharea.reset", defaultMessage: '重置' })),
|
|
111
114
|
React.createElement(Button, { type: "link", style: {
|
|
112
115
|
paddingLeft: 0,
|
|
113
116
|
paddingRight: 0
|
|
114
117
|
}, onClick: close },
|
|
115
|
-
"
|
|
118
|
+
React.createElement(FormattedMessage, { id: "component.searcharea.close", defaultMessage: '收起' }),
|
|
116
119
|
React.createElement(UpOutlined, null))))))));
|
|
117
120
|
}
|
|
118
121
|
var SearchArea = InternalSearchArea;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useMemo, useRef } from 'react';
|
|
2
|
-
import { FormattedMessage } from '
|
|
2
|
+
import { FormattedMessage } from '../../IntlProvider';
|
|
3
3
|
import { Checkbox, Col } from 'antd';
|
|
4
4
|
import { CSSTransition } from 'react-transition-group';
|
|
5
5
|
import { CloseOutlined } from '@ant-design/icons';
|
|
@@ -9,7 +9,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
9
9
|
};
|
|
10
10
|
import React, { useMemo, useRef } from 'react';
|
|
11
11
|
import { Checkbox, Popover } from 'antd';
|
|
12
|
-
import { FormattedMessage } from '
|
|
12
|
+
import { FormattedMessage } from '../../IntlProvider';
|
|
13
13
|
import { HolderOutlined } from '@ant-design/icons';
|
|
14
14
|
// import { message, IconFont } from 'xmirror-components'
|
|
15
15
|
import { message } from '../../AntdApp';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ResizeCallbackData } from 'react-resizable';
|
|
3
|
+
interface TitlePropsType {
|
|
4
|
+
width: number;
|
|
5
|
+
onResize: (e: React.SyntheticEvent<Element>, data: ResizeCallbackData) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const ResizableTitle: React.FC<Readonly<React.HTMLAttributes<any> & TitlePropsType>>;
|
|
8
|
+
export declare const resizableColumns: (columns: any[], tableId: string) => any[];
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import React, { useMemo, useState } from 'react';
|
|
24
|
+
import { useLocalStorageState } from 'ahooks';
|
|
25
|
+
import { MenuOutlined } from '@ant-design/icons';
|
|
26
|
+
import { Resizable } from 'react-resizable';
|
|
27
|
+
import { dataIndexToString } from '../utils';
|
|
28
|
+
import { ResizableHandle } from './styles';
|
|
29
|
+
export var ResizableTitle = function (props) {
|
|
30
|
+
var onResize = props.onResize, width = props.width, restProps = __rest(props, ["onResize", "width"]);
|
|
31
|
+
var _a = useState(false), resizing = _a[0], setResizing = _a[1];
|
|
32
|
+
if (!width) {
|
|
33
|
+
return React.createElement("th", __assign({}, restProps));
|
|
34
|
+
}
|
|
35
|
+
var onResizeStart = function (_e) {
|
|
36
|
+
setResizing(true);
|
|
37
|
+
};
|
|
38
|
+
var onResizeStop = function (_e) {
|
|
39
|
+
setResizing(false);
|
|
40
|
+
};
|
|
41
|
+
return (React.createElement(Resizable, { width: width, height: 0, handle: React.createElement(ResizableHandle, { className: resizing ? 'resizing' : '', onClick: function (e) { return e.stopPropagation(); } },
|
|
42
|
+
React.createElement(MenuOutlined, { className: "react-resizable-handle-icon" })), onResize: onResize, onResizeStart: onResizeStart, onResizeStop: onResizeStop, draggableOpts: { enableUserSelectHack: false } },
|
|
43
|
+
React.createElement("th", __assign({}, restProps))));
|
|
44
|
+
};
|
|
45
|
+
export var resizableColumns = function (columns, tableId) {
|
|
46
|
+
// const [columnsWidth, setColumnsWidth] = useSetState({})
|
|
47
|
+
var _a = useLocalStorageState('table-resizable_' + tableId, {}), columnsWidth = _a[0], setColumnsWidth = _a[1];
|
|
48
|
+
var handleResize = function (column) {
|
|
49
|
+
return function (_, _a) {
|
|
50
|
+
var size = _a.size;
|
|
51
|
+
var dataIndex = dataIndexToString(column === null || column === void 0 ? void 0 : column.dataIndex);
|
|
52
|
+
setColumnsWidth(function (value) {
|
|
53
|
+
var _a;
|
|
54
|
+
return __assign(__assign({}, value), (_a = {}, _a[dataIndex] = size.width, _a));
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
return useMemo(function () {
|
|
59
|
+
return columns.map(function (col) {
|
|
60
|
+
var dataIndex = col.dataIndex;
|
|
61
|
+
if (Array.isArray(col.dataIndex)) {
|
|
62
|
+
dataIndex = col.dataIndex.join('.');
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
dataIndex = col.dataIndex;
|
|
66
|
+
}
|
|
67
|
+
var width = (columnsWidth === null || columnsWidth === void 0 ? void 0 : columnsWidth[dataIndex]) || col.width;
|
|
68
|
+
return __assign(__assign({}, col), { width: width, onHeaderCell: function (column) {
|
|
69
|
+
return {
|
|
70
|
+
width: column.width,
|
|
71
|
+
onResize: handleResize(column)
|
|
72
|
+
};
|
|
73
|
+
} });
|
|
74
|
+
});
|
|
75
|
+
}, [columns, columnsWidth]);
|
|
76
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 可调整大小的列拖拽手柄样式组件
|
|
3
|
+
* 用于表格列宽调整功能
|
|
4
|
+
*/
|
|
5
|
+
export declare const ResizableHandle: import("@emotion/styled").StyledComponent<{
|
|
6
|
+
theme?: import("@emotion/react").Theme;
|
|
7
|
+
as?: React.ElementType;
|
|
8
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import styled from '@emotion/styled';
|
|
6
|
+
/**
|
|
7
|
+
* 可调整大小的列拖拽手柄样式组件
|
|
8
|
+
* 用于表格列宽调整功能
|
|
9
|
+
*/
|
|
10
|
+
export var ResizableHandle = styled.span(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 6px;\n height: 30px;\n margin: auto 0;\n text-align: center;\n cursor: col-resize;\n user-select: none;\n background: #f0f0f0;\n border: 1px solid #d3d3d3;\n border-radius: 3px;\n opacity: 0;\n transition: all 0.1s;\n\n &.resizing,\n &:hover {\n opacity: 1;\n }\n\n .react-resizable-handle-icon {\n display: inline-block;\n transform: rotateZ(90deg) scale(0.3);\n }\n"], ["\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 6px;\n height: 30px;\n margin: auto 0;\n text-align: center;\n cursor: col-resize;\n user-select: none;\n background: #f0f0f0;\n border: 1px solid #d3d3d3;\n border-radius: 3px;\n opacity: 0;\n transition: all 0.1s;\n\n &.resizing,\n &:hover {\n opacity: 1;\n }\n\n .react-resizable-handle-icon {\n display: inline-block;\n transform: rotateZ(90deg) scale(0.3);\n }\n"])));
|
|
11
|
+
var templateObject_1;
|
|
@@ -15,9 +15,10 @@ import { useLocalStorageState } from 'ahooks';
|
|
|
15
15
|
import { DownOutlined } from '@ant-design/icons';
|
|
16
16
|
import PopoverSetColumns from './PopoverSetColumns';
|
|
17
17
|
import Footer from './Footer';
|
|
18
|
+
import { resizableColumns, ResizableTitle } from './ResizableColumns';
|
|
18
19
|
import { TableWrapper } from './styles';
|
|
19
20
|
function Index(props, ref) {
|
|
20
|
-
var _a = props.columns, columns = _a === void 0 ? [] : _a, columnsSort = props.columnsSort, columnsVisible = props.columnsVisible, _b = props.tableId, tableId = _b === void 0 ? '' : _b, pagination = props.pagination, dataSource = props.dataSource;
|
|
21
|
+
var _a = props.columns, columns = _a === void 0 ? [] : _a, columnsSort = props.columnsSort, columnsVisible = props.columnsVisible, _b = props.tableId, tableId = _b === void 0 ? '' : _b, pagination = props.pagination, dataSource = props.dataSource, columnsResizable = props.columnsResizable;
|
|
21
22
|
var pathname = location.pathname;
|
|
22
23
|
var _tableId = pathname + tableId;
|
|
23
24
|
var _c = useLocalStorageState('TABLE_' + _tableId, {
|
|
@@ -184,6 +185,6 @@ function Index(props, ref) {
|
|
|
184
185
|
return (React.createElement(TableWrapper, { ref: ref },
|
|
185
186
|
React.createElement(Table, __assign({ ref: tableRef, scroll: {
|
|
186
187
|
x: 900
|
|
187
|
-
} }, props, { pagination: paginationProps, columns: renderColumns }))));
|
|
188
|
+
}, components: { header: { cell: columnsResizable ? ResizableTitle : undefined } } }, props, { pagination: paginationProps, columns: columnsResizable ? resizableColumns(renderColumns, tableId) : renderColumns }))));
|
|
188
189
|
}
|
|
189
190
|
export default forwardRef(Index);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 将 dataIndex 转换为字符串
|
|
3
|
+
* @param dataIndex - 数据索引,可能是字符串或数组
|
|
4
|
+
* @returns 转换后的字符串
|
|
5
|
+
*/
|
|
6
|
+
export var dataIndexToString = function (dataIndex) {
|
|
7
|
+
if (!dataIndex)
|
|
8
|
+
return '';
|
|
9
|
+
if (Array.isArray(dataIndex)) {
|
|
10
|
+
return dataIndex.join('.');
|
|
11
|
+
}
|
|
12
|
+
return dataIndex;
|
|
13
|
+
};
|
|
@@ -55,7 +55,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
55
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
56
|
};
|
|
57
57
|
import { useEffect, useRef, useState, useCallback } from 'react';
|
|
58
|
-
import { useIntl } from '
|
|
58
|
+
import { useIntl } from '../../components/IntlProvider';
|
|
59
59
|
import { useMemoizedFn } from 'ahooks';
|
|
60
60
|
import { message } from '../../components/AntdApp';
|
|
61
61
|
var ORDER_MAP = {
|
|
@@ -72,10 +72,10 @@ var defaultOptions = {
|
|
|
72
72
|
},
|
|
73
73
|
showRowSelection: false,
|
|
74
74
|
multiPageSelection: false,
|
|
75
|
-
onBeforeRequest: function (
|
|
75
|
+
onBeforeRequest: function (_) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
76
76
|
return [2 /*return*/, undefined];
|
|
77
77
|
}); }); },
|
|
78
|
-
onAfterRequest: function (
|
|
78
|
+
onAfterRequest: function (_) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
79
79
|
return [2 /*return*/, undefined];
|
|
80
80
|
}); }); }
|
|
81
81
|
};
|
|
@@ -150,7 +150,6 @@ function useTable(request, options) {
|
|
|
150
150
|
total: total
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
|
-
console.log(list);
|
|
154
153
|
if (list.length === 0 && current && current > 1 && total && total > 0) {
|
|
155
154
|
maxPage = Math.ceil(total / size);
|
|
156
155
|
initList(maxPage, pageSize, auto);
|
|
@@ -199,10 +198,11 @@ function useTable(request, options) {
|
|
|
199
198
|
}, []);
|
|
200
199
|
/**
|
|
201
200
|
* 列表多选执行
|
|
202
|
-
* @param
|
|
201
|
+
* @param selectedRowKeys 选中的key数组
|
|
203
202
|
* @param selectedRows 被选中的项
|
|
203
|
+
* @param info 选择信息
|
|
204
204
|
*/
|
|
205
|
-
var onSelectChange = useCallback(function (_, selectedRows) {
|
|
205
|
+
var onSelectChange = useCallback(function (_, selectedRows, __) {
|
|
206
206
|
setSelectedRows(selectedRows);
|
|
207
207
|
}, []);
|
|
208
208
|
/**
|
|
@@ -243,7 +243,7 @@ function useTable(request, options) {
|
|
|
243
243
|
* @param order 排序的值
|
|
244
244
|
*/
|
|
245
245
|
var onChangeTable = useCallback(function (pagination, filter, order) {
|
|
246
|
-
var _a;
|
|
246
|
+
var _a, _b, _c;
|
|
247
247
|
// 处理筛选参数
|
|
248
248
|
Object.entries(filter).forEach(function (_a) {
|
|
249
249
|
var key = _a[0], value = _a[1];
|
|
@@ -255,20 +255,26 @@ function useTable(request, options) {
|
|
|
255
255
|
}
|
|
256
256
|
});
|
|
257
257
|
// 处理排序参数
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
// 如果 order 是数组,取第一个元素
|
|
259
|
+
var sortInfo = Array.isArray(order) ? order[0] : order;
|
|
260
|
+
if (sortInfo === null || sortInfo === void 0 ? void 0 : sortInfo.order) {
|
|
261
|
+
if ((_a = sortInfo === null || sortInfo === void 0 ? void 0 : sortInfo.column) === null || _a === void 0 ? void 0 : _a.sort) {
|
|
262
|
+
searchParams.column = sortInfo.column.sort;
|
|
261
263
|
}
|
|
262
|
-
else {
|
|
263
|
-
|
|
264
|
+
else if (sortInfo.field) {
|
|
265
|
+
// 处理 field 可能是数组的情况
|
|
266
|
+
searchParams.column = Array.isArray(sortInfo.field) ? sortInfo.field[0] : sortInfo.field;
|
|
264
267
|
}
|
|
265
|
-
searchParams.order = ORDER_MAP[
|
|
268
|
+
searchParams.order = ORDER_MAP[sortInfo.order];
|
|
266
269
|
}
|
|
267
270
|
else {
|
|
268
271
|
searchParams.column = null;
|
|
269
272
|
searchParams.order = null;
|
|
270
273
|
}
|
|
271
|
-
|
|
274
|
+
// 使用当前分页值作为默认值,处理可能为 undefined 的情况
|
|
275
|
+
var currentPage = (_b = pagination.current) !== null && _b !== void 0 ? _b : paginationRef.current.current;
|
|
276
|
+
var currentPageSize = (_c = pagination.pageSize) !== null && _c !== void 0 ? _c : paginationRef.current.pageSize;
|
|
277
|
+
initList(currentPage, currentPageSize);
|
|
272
278
|
}, [initList, searchParams]);
|
|
273
279
|
// 初始化
|
|
274
280
|
useEffect(function () {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TableComponentProps } from '../../components/Table/types';
|
|
2
2
|
export type BaseRecord = Record<string, unknown>;
|
|
3
3
|
/**
|
|
4
4
|
* json 格式响应
|
|
@@ -23,16 +23,14 @@ export interface RequestParams {
|
|
|
23
23
|
[key: string]: unknown;
|
|
24
24
|
}
|
|
25
25
|
export interface TableChangeParams {
|
|
26
|
-
current
|
|
27
|
-
pageSize
|
|
26
|
+
current?: number;
|
|
27
|
+
pageSize?: number;
|
|
28
28
|
}
|
|
29
|
-
export type FilterParams = Record<string,
|
|
29
|
+
export type FilterParams = Record<string, any>;
|
|
30
30
|
export interface SortParams {
|
|
31
|
-
field
|
|
32
|
-
order
|
|
33
|
-
column?:
|
|
34
|
-
sort?: string;
|
|
35
|
-
};
|
|
31
|
+
field?: any;
|
|
32
|
+
order?: 'ascend' | 'descend' | null;
|
|
33
|
+
column?: any;
|
|
36
34
|
}
|
|
37
35
|
export interface OptionsProps<T = BaseRecord> {
|
|
38
36
|
/**
|
|
@@ -81,26 +79,7 @@ export interface ReturnData<T = BaseRecord> {
|
|
|
81
79
|
/**
|
|
82
80
|
* 列表 props,拓展到 table 上
|
|
83
81
|
*/
|
|
84
|
-
tableProps:
|
|
85
|
-
rowKey: string;
|
|
86
|
-
loading: boolean;
|
|
87
|
-
dataSource: T[];
|
|
88
|
-
rowSelection?: {
|
|
89
|
-
selectedRowKeys: Array<string | number>;
|
|
90
|
-
onChange?: (selectedRowKeys: Array<string | number>, selectedRows: T[], info: {
|
|
91
|
-
type: RowSelectMethod;
|
|
92
|
-
}) => void;
|
|
93
|
-
};
|
|
94
|
-
onChange: (pagination: TableChangeParams, filter: FilterParams, order: SortParams) => void;
|
|
95
|
-
pagination: {
|
|
96
|
-
showQuickJumper: boolean;
|
|
97
|
-
showSizeChanger: boolean;
|
|
98
|
-
showTotal: (total: number) => string;
|
|
99
|
-
total: number;
|
|
100
|
-
current: number;
|
|
101
|
-
pageSize: number;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
82
|
+
tableProps: TableComponentProps;
|
|
104
83
|
/**
|
|
105
84
|
* 列表搜索
|
|
106
85
|
*/
|
|
@@ -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,27 @@
|
|
|
1
|
+
var messages = {
|
|
2
|
+
'operation.add': 'Add',
|
|
3
|
+
'operation.delete': 'Delete',
|
|
4
|
+
'operation.batchDelete': 'Batch Delete',
|
|
5
|
+
'operation.edit': 'Edit',
|
|
6
|
+
'operation.download': 'Download',
|
|
7
|
+
'operation.logout': 'Logout',
|
|
8
|
+
'operation.export': 'Export',
|
|
9
|
+
'operation.close': 'Close',
|
|
10
|
+
'operation.details': 'Details',
|
|
11
|
+
'operation.confirm': 'Confirm',
|
|
12
|
+
'operation.save': 'Save',
|
|
13
|
+
'operation.cancel': 'Cancel',
|
|
14
|
+
// Components
|
|
15
|
+
'component.table.selected': '{length} selected',
|
|
16
|
+
'component.table.total': 'Total {total} items',
|
|
17
|
+
'component.table.visibleError': 'At least one field must be visible',
|
|
18
|
+
'component.searcharea.toggle': 'Advanced Search',
|
|
19
|
+
'component.searcharea.submit': 'Submit',
|
|
20
|
+
'component.searcharea.reset': 'Reset',
|
|
21
|
+
'component.searcharea.close': 'Close',
|
|
22
|
+
// Messages
|
|
23
|
+
'message.delete': 'This action cannot be undone, confirm delete?',
|
|
24
|
+
'message.success': 'Operation successful',
|
|
25
|
+
'table.pagination.total': 'Total {total} items',
|
|
26
|
+
};
|
|
27
|
+
export default messages;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|