@zykj2024/much-library 1.1.6 → 1.1.7-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/McContainer/demo/generic.d.ts +8 -0
- package/dist/McContainer/demo/generic.js +91 -0
- package/dist/McContainer/index.d.ts +147 -108
- package/dist/McContainer/index.js +16 -7
- package/dist/McEllipsis/demo/base.d.ts +6 -0
- package/dist/McEllipsis/demo/base.js +22 -0
- package/dist/McEllipsis/demo/middle.d.ts +6 -0
- package/dist/McEllipsis/demo/middle.js +24 -0
- package/dist/McEllipsis/demo/table.d.ts +5 -0
- package/dist/McEllipsis/demo/table.js +93 -0
- package/dist/McEllipsis/demo/tooltip-size.d.ts +6 -0
- package/dist/McEllipsis/demo/tooltip-size.js +20 -0
- package/dist/McEllipsis/demo/tooltip.d.ts +6 -0
- package/dist/McEllipsis/demo/tooltip.js +53 -0
- package/dist/McEllipsis/index.css +4 -0
- package/dist/McEllipsis/index.d.ts +40 -0
- package/dist/McEllipsis/index.js +115 -0
- package/dist/McGroupPanel/index.css +8 -3
- package/dist/McGroupPanel/index.d.ts +1 -0
- package/dist/McGroupPanel/index.js +156 -141
- package/dist/McInputNumber/index.d.ts +3 -0
- package/dist/McInputNumber/index.js +16 -9
- package/dist/McListSelect/comps/ListSelect.d.ts +67 -0
- package/dist/McListSelect/comps/ListSelect.js +289 -0
- package/dist/McListSelect/comps/ListSelectPanel.d.ts +138 -0
- package/dist/McListSelect/comps/ListSelectPanel.js +451 -0
- package/dist/McListSelect/comps/SelectedItem.d.ts +17 -0
- package/dist/McListSelect/comps/SelectedItem.js +76 -0
- package/dist/McListSelect/demo/base.d.ts +6 -0
- package/dist/McListSelect/demo/base.js +125 -0
- package/dist/McListSelect/demo/inexistent.d.ts +6 -0
- package/dist/McListSelect/demo/inexistent.js +111 -0
- package/dist/McListSelect/demo/layout.d.ts +6 -0
- package/dist/McListSelect/demo/layout.js +70 -0
- package/dist/McListSelect/demo/other.d.ts +6 -0
- package/dist/McListSelect/demo/other.js +68 -0
- package/dist/McListSelect/demo/panel-inexistent.d.ts +6 -0
- package/dist/McListSelect/demo/panel-inexistent.js +86 -0
- package/dist/McListSelect/index.css +273 -0
- package/dist/McListSelect/index.d.ts +10 -0
- package/dist/McListSelect/index.js +5 -0
- package/dist/McListSelect/mock/index.d.ts +1 -0
- package/dist/McListSelect/mock/index.js +27 -0
- package/dist/McModalProvider/index.d.ts +2 -2
- package/dist/McThemeConfig/layoutStyle.d.ts +1 -1
- package/dist/McThemeConfig/layoutStyle.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/package.json +3 -1
@@ -0,0 +1,91 @@
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
2
|
+
/**
|
3
|
+
* title: 泛型
|
4
|
+
* description: 更好的代码提示及类型推断
|
5
|
+
* transform: true
|
6
|
+
* compact: true
|
7
|
+
*/
|
8
|
+
|
9
|
+
import { McContainer, McInput } from "../..";
|
10
|
+
import { useRef, useState } from 'react';
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
12
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
13
|
+
var tableData = Array.from({
|
14
|
+
length: 5
|
15
|
+
}, function (_, index) {
|
16
|
+
return {
|
17
|
+
id: index + 1,
|
18
|
+
name: "\u59D3\u540D".concat(index + 1),
|
19
|
+
age: 18 + index
|
20
|
+
};
|
21
|
+
});
|
22
|
+
export default (function () {
|
23
|
+
var _useState = useState(tableData),
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
25
|
+
dataSource = _useState2[0],
|
26
|
+
setDataSource = _useState2[1];
|
27
|
+
var _useState3 = useState(false),
|
28
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
29
|
+
loading = _useState4[0],
|
30
|
+
setLoading = _useState4[1];
|
31
|
+
var mcContainerRef = useRef(null);
|
32
|
+
var columns = [{
|
33
|
+
title: 'ID',
|
34
|
+
dataIndex: 'id'
|
35
|
+
}, {
|
36
|
+
title: '姓名',
|
37
|
+
dataIndex: 'name'
|
38
|
+
}, {
|
39
|
+
title: '年龄',
|
40
|
+
dataIndex: 'age'
|
41
|
+
}, {
|
42
|
+
title: '操作',
|
43
|
+
dataIndex: 'id',
|
44
|
+
width: 100,
|
45
|
+
render: function render() {
|
46
|
+
return /*#__PURE__*/_jsx("a", {
|
47
|
+
children: "\u7F16\u8F91"
|
48
|
+
});
|
49
|
+
}
|
50
|
+
}];
|
51
|
+
var queryItems = /*#__PURE__*/_jsx(_Fragment, {
|
52
|
+
children: /*#__PURE__*/_jsx(McInput, {
|
53
|
+
label: "\u59D3\u540D",
|
54
|
+
name: "name",
|
55
|
+
style: {
|
56
|
+
width: 270
|
57
|
+
}
|
58
|
+
})
|
59
|
+
});
|
60
|
+
var onQuery = function onQuery(data) {
|
61
|
+
var _mcContainerRef$curre;
|
62
|
+
var queryData = (_mcContainerRef$curre = mcContainerRef.current) === null || _mcContainerRef$curre === void 0 ? void 0 : _mcContainerRef$curre.getQueryParams();
|
63
|
+
// 加了泛型后,data. queryData.就会有类型推断
|
64
|
+
console.log(data.a, queryData === null || queryData === void 0 ? void 0 : queryData.a);
|
65
|
+
return new Promise(function (resolve) {
|
66
|
+
setLoading(true);
|
67
|
+
setTimeout(function () {
|
68
|
+
setDataSource(tableData);
|
69
|
+
setLoading(false);
|
70
|
+
resolve();
|
71
|
+
}, 1000);
|
72
|
+
});
|
73
|
+
};
|
74
|
+
return (
|
75
|
+
/*#__PURE__*/
|
76
|
+
// 添加泛型后,组件下写的第一个属性会没有代码提示。
|
77
|
+
_jsx(McContainer, {
|
78
|
+
ref: mcContainerRef,
|
79
|
+
height: "100%",
|
80
|
+
immediateQuery: false,
|
81
|
+
loading: loading,
|
82
|
+
onQuery: onQuery,
|
83
|
+
queryItems: queryItems,
|
84
|
+
tableProps: {
|
85
|
+
columns: columns,
|
86
|
+
dataSource: dataSource,
|
87
|
+
rowKey: 'id'
|
88
|
+
}
|
89
|
+
})
|
90
|
+
);
|
91
|
+
});
|
@@ -1,153 +1,192 @@
|
|
1
1
|
import { ButtonProps, TableProps } from 'antd';
|
2
|
-
import { CSSProperties,
|
2
|
+
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
3
3
|
import './index.less';
|
4
|
-
|
4
|
+
/** 请求参数 */
|
5
|
+
type QueryParamsType<T = any> = {
|
6
|
+
/** 当前页码 */
|
7
|
+
current: number;
|
8
|
+
/** 每页显示的记录数 */
|
9
|
+
pageSize: number;
|
10
|
+
} & T;
|
11
|
+
/** 批量操作配置接口 */
|
12
|
+
interface BatchConfig {
|
13
|
+
/** 是否显示批量操作按钮 */
|
14
|
+
show?: boolean;
|
15
|
+
/** 批量操作按钮的文本 */
|
16
|
+
buttonText?: string;
|
17
|
+
/** 批量操作按钮的属性 */
|
18
|
+
buttonProps?: ButtonProps;
|
19
|
+
/** 批量操作按钮在操作栏中的位置 */
|
20
|
+
order?: number;
|
21
|
+
}
|
22
|
+
/** McContainer 组件 Props 类型定义 */
|
23
|
+
export interface McContainerProps<T> {
|
24
|
+
/** 组件的自定义样式 */
|
5
25
|
style?: CSSProperties;
|
26
|
+
/** 组件的自定义类名 */
|
6
27
|
className?: string;
|
7
|
-
/**
|
28
|
+
/**
|
29
|
+
* 页面容器的高度
|
30
|
+
* @default 'calc(100vh - 88px)' 即视口高度-菜单header高度56px-页面上下内边距16px*2
|
31
|
+
*/
|
8
32
|
height?: string;
|
9
|
-
/**
|
33
|
+
/**
|
34
|
+
* 页面容器的背景色
|
35
|
+
* @default '#ffffff'
|
36
|
+
*/
|
10
37
|
backgroundColor?: string;
|
11
38
|
/**
|
12
|
-
*
|
39
|
+
* 是否展示头部遮罩
|
40
|
+
* @default true
|
13
41
|
*/
|
14
42
|
showCell?: boolean;
|
15
43
|
/**
|
16
|
-
*
|
17
|
-
|
18
|
-
|
44
|
+
* 是否触发首次查询
|
45
|
+
* @description 若使用场景为需自定义默认查询参数,可将该属性设置为false,
|
46
|
+
* 并手动调用setDefaultQueryParams方法重新设置默认查询参数,而后调用query方法触发查询
|
47
|
+
* @default true
|
48
|
+
*/
|
19
49
|
immediateQuery?: boolean;
|
20
|
-
/**
|
50
|
+
/**
|
51
|
+
* 加载中状态(已覆盖table组件的loading)
|
52
|
+
* @default false
|
53
|
+
*/
|
21
54
|
loading?: boolean;
|
22
55
|
/** 加载loading下方的文案,默认为测试中 */
|
23
56
|
loadingText?: string;
|
24
57
|
/**
|
25
58
|
* 查询项(不受展开、收起按钮控制显示隐藏的查询项)
|
26
|
-
|
27
|
-
|
28
|
-
<>
|
29
|
-
<McSelect
|
30
|
-
label="下拉选择器"
|
31
|
-
name="name1"
|
32
|
-
/>
|
33
|
-
<McCascader
|
34
|
-
label="级联选择器"
|
35
|
-
name="name2"
|
36
|
-
/>
|
37
|
-
<McDateRange
|
38
|
-
label="日期范围选择器"
|
39
|
-
name="name3"
|
40
|
-
/>
|
41
|
-
<McInput.Search
|
42
|
-
name="name4"
|
43
|
-
onSearch={() => mcContainerRef.current?.query({ current: 1 })}
|
44
|
-
/>
|
45
|
-
</>
|
46
|
-
*/
|
59
|
+
* @description 建议结合 McSelect、McCascader、McDateRange、McInput 等组件使用
|
60
|
+
*/
|
47
61
|
queryItems?: ReactElement;
|
48
|
-
/**
|
62
|
+
/**
|
63
|
+
* 是否显示查询按钮
|
64
|
+
* @default true
|
65
|
+
*/
|
49
66
|
showQuery?: boolean;
|
50
|
-
/**
|
67
|
+
/**
|
68
|
+
* 是否显示重置按钮
|
69
|
+
* @default true
|
70
|
+
*/
|
51
71
|
showReset?: boolean;
|
52
|
-
/**
|
72
|
+
/**
|
73
|
+
* 是否显示展开、收起按钮
|
74
|
+
* @default false
|
75
|
+
*/
|
53
76
|
showCollapse?: boolean;
|
54
|
-
/**
|
77
|
+
/** 可折叠的查询项(可通过展开、收起按钮控制显示隐藏的查询项) */
|
55
78
|
collapsibleQueryItems?: ReactElement;
|
56
|
-
/**
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
[key: string]: any;
|
79
|
+
/**
|
80
|
+
* 查询回调事件
|
81
|
+
* @param params - 分页参数
|
82
|
+
* @param filters - 过滤条件
|
83
|
+
* @param sorter - 排序条件
|
84
|
+
* @param extra - 额外信息,包含当前数据源和触发的操作类型
|
85
|
+
*/
|
86
|
+
onQuery?: (params: QueryParamsType<T>, filters?: Record<string, any>, sorter?: Record<string, any>, extra?: {
|
87
|
+
currentDataSource: any[];
|
88
|
+
action: 'paginate' | 'sort' | 'filter';
|
67
89
|
}) => void;
|
68
|
-
/**
|
90
|
+
/**
|
91
|
+
* 重置按钮回调事件
|
92
|
+
* @description 若设置该属性,则在点击重置按钮时不再触发onQuery事件
|
93
|
+
*/
|
94
|
+
onReset?: (params?: QueryParamsType<T>) => void;
|
95
|
+
/**
|
96
|
+
* 查询区自定义渲染
|
97
|
+
* @description 若设置为null,则不显示查询区
|
98
|
+
*/
|
69
99
|
queryRender?: ReactNode;
|
70
100
|
/**
|
71
|
-
*
|
72
|
-
|
73
|
-
|
74
|
-
<Button type="primary">操作1</Button>
|
75
|
-
<Button>操作2</Button>
|
76
|
-
</>
|
77
|
-
*/
|
101
|
+
* 操作栏
|
102
|
+
* @description 若未设置该项,则不显示
|
103
|
+
*/
|
78
104
|
actionBar?: ReactElement;
|
79
105
|
/**
|
80
|
-
*
|
106
|
+
* 操作栏自定义渲染
|
81
107
|
* @param batchEl - 批量操作按钮实例
|
82
|
-
* @returns 操作栏元素
|
83
108
|
*/
|
84
109
|
actionBarRender?: (batchEl: ReactNode) => ReactNode;
|
85
|
-
/**
|
110
|
+
/**
|
111
|
+
* 批量操作已选项数量
|
112
|
+
* @description 当数量大于0时,显示批量操作栏
|
113
|
+
*/
|
86
114
|
batchNum?: number;
|
87
115
|
/**
|
88
|
-
*
|
89
|
-
|
90
|
-
|
91
|
-
<Button>批量操作1</Button>
|
92
|
-
<Button>批量操作2</Button>
|
93
|
-
</>
|
94
|
-
*/
|
116
|
+
* 批量操作按钮区
|
117
|
+
* @description 若未设置该项,则不显示
|
118
|
+
*/
|
95
119
|
batchBtns?: ReactNode;
|
96
|
-
/**
|
97
|
-
|
98
|
-
* @param show - 是否显示批量操作按钮(默认不显示 false)
|
99
|
-
* @param buttonText - 批量操作按钮文字
|
100
|
-
* @param buttonProps - 批量操作按钮属性
|
101
|
-
* @param order - 批量操作按钮在操作栏中的位置(默认为最后一个)
|
102
|
-
*/
|
103
|
-
batch?: {
|
104
|
-
show?: boolean;
|
105
|
-
buttonText?: string;
|
106
|
-
buttonProps?: ButtonProps;
|
107
|
-
order?: number;
|
108
|
-
};
|
120
|
+
/** 批量操作按钮配置 */
|
121
|
+
batch?: BatchConfig;
|
109
122
|
/** 批量操作取消按钮回调事件 */
|
110
123
|
onCancel?: () => void;
|
111
124
|
/** 表格组件属性 */
|
112
125
|
tableProps?: TableProps<any>;
|
113
|
-
/**
|
126
|
+
/**
|
127
|
+
* 数据表格区自定义渲染
|
128
|
+
* @description 若设置为null,则不显示数据表格区
|
129
|
+
*/
|
114
130
|
tableRender?: ReactNode;
|
115
|
-
/**
|
131
|
+
/**
|
132
|
+
* 当前分页数据为空且非第一页时,是否自动会退到上一个分页
|
133
|
+
* @default false
|
134
|
+
*/
|
116
135
|
autoBackPagination?: boolean;
|
117
|
-
/**
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
136
|
+
/**
|
137
|
+
* 折叠事件的回调
|
138
|
+
* @param collapsed - 是否折叠
|
139
|
+
*/
|
140
|
+
onCollapse?: (collapsed: boolean) => void;
|
141
|
+
}
|
142
|
+
/** McContainer 组件 Ref 类型定义 */
|
143
|
+
export interface McContainerRef<T = any> {
|
122
144
|
/**
|
123
145
|
* 调用查询的方法
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
146
|
+
* @description 可通过传参更新查询参数的状态后触发查询,所设置的属性仅会覆盖原查询参数对应的属性
|
147
|
+
* @param params - 查询参数,仅支持设置过name属性的查询项
|
148
|
+
*/
|
149
|
+
query: (params?: QueryParamsType<T>) => void;
|
150
|
+
/**
|
151
|
+
* 调用重置的方法
|
152
|
+
* @description 重置查询参数为默认值
|
153
|
+
*/
|
132
154
|
reset: () => void;
|
133
155
|
/**
|
134
156
|
* 设置默认查询参数
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
/**
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
157
|
+
* @description 用于重置使用,仅对设置过name属性的查询项有效
|
158
|
+
* 仅对设置过name属性的查询项(和current、pageSize)有效,查询项自身已绑定value属性的除外,需自行编写相关业务逻辑代码进行状态管理;
|
159
|
+
* 可通过该方法配置默认查询的分页参数;
|
160
|
+
* 设置的查询参数将覆盖原有默认值,如:setDefaultQueryParams({pageSize: 10, status: 1}),设置后的默认查询参数为{current: 1, pageSize: 10, status: 1}
|
161
|
+
* 原有默认值 {current: 1, pageSize: 20}(若未开启分页功能,默认值为{}
|
162
|
+
* @param params - 默认查询参数
|
163
|
+
*/
|
164
|
+
setDefaultQueryParams: (params: QueryParamsType<T>) => void;
|
165
|
+
/**
|
166
|
+
* 设置单个查询项的参数
|
167
|
+
* @description 仅支持设置过name属性的查询项
|
168
|
+
* @param name - 查询项名称
|
169
|
+
* @param value - 查询项值
|
170
|
+
*/
|
171
|
+
setQueryParam: (name: keyof QueryParamsType<T>, value: any) => void;
|
172
|
+
/**
|
173
|
+
* 获取单个查询项的参数
|
174
|
+
* @description 仅支持设置过name属性的查询项
|
175
|
+
* @param name - 查询项名称
|
176
|
+
*/
|
177
|
+
getQueryParam: (name: keyof QueryParamsType<T>) => any;
|
178
|
+
/**
|
179
|
+
* 获取所有查询项的参数
|
180
|
+
* @returns 当前可见的查询项的参数集
|
181
|
+
*/
|
182
|
+
getQueryParams: () => QueryParamsType<T>;
|
183
|
+
/**
|
184
|
+
* 重置查询参数
|
185
|
+
* @description 重置为默认查询参数
|
186
|
+
*/
|
150
187
|
resetQueryParams: () => void;
|
151
|
-
}
|
152
|
-
declare const McContainer:
|
188
|
+
}
|
189
|
+
declare const McContainer: <T>(props: McContainerProps<T> & {
|
190
|
+
ref?: React.ForwardedRef<McContainerRef<T>>;
|
191
|
+
}) => JSX.Element;
|
153
192
|
export default McContainer;
|
@@ -7,10 +7,22 @@ import { isNumber } from 'lodash';
|
|
7
7
|
import { CaretDownFilled, DoubleLeftOutlined } from 'much-icons';
|
8
8
|
import { Children, cloneElement, forwardRef, isValidElement, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
9
9
|
import "./index.css";
|
10
|
+
|
11
|
+
/** 请求参数 */
|
12
|
+
|
13
|
+
/** 批量操作配置接口 */
|
14
|
+
|
15
|
+
/** McContainer 组件 Props 类型定义 */
|
16
|
+
|
17
|
+
/** McContainer 组件 Ref 类型定义 */
|
10
18
|
import { jsx as _jsx } from "react/jsx-runtime";
|
11
19
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
12
20
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
-
|
21
|
+
/**
|
22
|
+
* McContainer 组件
|
23
|
+
* @description 一个通用的容器组件,支持查询、表格、批量操作等功能
|
24
|
+
*/
|
25
|
+
var ContainerPanel = function ContainerPanel(props, ref) {
|
14
26
|
var _tableProps$dataSourc;
|
15
27
|
var style = props.style,
|
16
28
|
className = props.className,
|
@@ -171,15 +183,13 @@ var McContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
171
183
|
};
|
172
184
|
|
173
185
|
// 格式化查询参数(返回当前可见的查询项的参数集)
|
174
|
-
var formatQueryParams = function formatQueryParams() {
|
186
|
+
var formatQueryParams = function formatQueryParams(params) {
|
175
187
|
var _tableProps$paginatio;
|
176
|
-
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
177
188
|
var _params = tableRender || tableRender === null || (tableProps === null || tableProps === void 0 ? void 0 : tableProps.pagination) === false || tableProps !== null && tableProps !== void 0 && (_tableProps$paginatio = tableProps.pagination) !== null && _tableProps$paginatio !== void 0 && _tableProps$paginatio.hasOwnProperty('onChange') || tableProps !== null && tableProps !== void 0 && tableProps.hasOwnProperty('onChange') ? {} : {
|
178
189
|
current: params.current,
|
179
190
|
pageSize: params.pageSize
|
180
191
|
};
|
181
192
|
var fn = function fn(items) {
|
182
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
183
193
|
items && Children.map(items.props.children ? items.props.children : items, function (item) {
|
184
194
|
if (item !== null && item !== void 0 && item.props) {
|
185
195
|
var _item$props2;
|
@@ -199,7 +209,6 @@ var McContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
199
209
|
var query = function query(params) {
|
200
210
|
if (params) {
|
201
211
|
var _params = _objectSpread({}, queryParamsRef.current);
|
202
|
-
// 仅支持设置过name属性的查询项(和current、pageSize)
|
203
212
|
Object.entries(params).forEach(function (_ref2) {
|
204
213
|
var _ref3 = _slicedToArray(_ref2, 2),
|
205
214
|
key = _ref3[0],
|
@@ -255,7 +264,6 @@ var McContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
255
264
|
Object.keys(_params).forEach(function (k) {
|
256
265
|
return !allNamesRef.current.includes(k) && allNamesRef.current.push(k);
|
257
266
|
});
|
258
|
-
// 仅支持设置过name属性的查询项(和current、pageSize)
|
259
267
|
Object.entries(params).forEach(function (_ref4) {
|
260
268
|
var _ref5 = _slicedToArray(_ref4, 2),
|
261
269
|
key = _ref5[0],
|
@@ -509,5 +517,6 @@ var McContainer = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
509
517
|
})]
|
510
518
|
})
|
511
519
|
});
|
512
|
-
}
|
520
|
+
};
|
521
|
+
var McContainer = /*#__PURE__*/forwardRef(ContainerPanel);
|
513
522
|
export default McContainer;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* title: 基本使用
|
3
|
+
* description: 单行末尾省略<br>设置 `rows` 多行末尾省略
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { McEllipsis } from "../..";
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
|
+
export default (function () {
|
10
|
+
var longText = '一-二-三-四-五-六-七-八-九-十=壹-贰-叁-肆-伍-陆-柒-捌-玖-拾=yī-èr-sān-sì-wǔ-liù-qī-bā-jiǔ-shí=one-two-three-four-five-six-seven-eight-nine-ten';
|
11
|
+
return /*#__PURE__*/_jsxs("div", {
|
12
|
+
style: {
|
13
|
+
width: 240
|
14
|
+
},
|
15
|
+
children: [/*#__PURE__*/_jsx(McEllipsis, {
|
16
|
+
text: '单行末尾省略:' + longText
|
17
|
+
}), /*#__PURE__*/_jsx("hr", {}), /*#__PURE__*/_jsx(McEllipsis, {
|
18
|
+
text: '3行末尾省略:' + longText,
|
19
|
+
rows: 3
|
20
|
+
})]
|
21
|
+
});
|
22
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* title: 中间省略
|
3
|
+
* description: 设置 `middle` 使用中间省略<br>设置 `suffixCount` 结尾显示的字个数
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { McEllipsis } from "../..";
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
9
|
+
export default (function () {
|
10
|
+
var longText = '一-二-三-四-五-六-七-八-九-十=壹-贰-叁-肆-伍-陆-柒-捌-玖-拾=yī-èr-sān-sì-wǔ-liù-qī-bā-jiǔ-shí=one-two-three-four-five-six-seven-eight-nine-ten';
|
11
|
+
return /*#__PURE__*/_jsxs("div", {
|
12
|
+
style: {
|
13
|
+
width: 240
|
14
|
+
},
|
15
|
+
children: [/*#__PURE__*/_jsx(McEllipsis, {
|
16
|
+
text: '中间省略:' + longText,
|
17
|
+
middle: true
|
18
|
+
}), /*#__PURE__*/_jsx("hr", {}), /*#__PURE__*/_jsx(McEllipsis, {
|
19
|
+
text: '结尾显示10个字:' + longText,
|
20
|
+
middle: true,
|
21
|
+
suffixCount: 10
|
22
|
+
})]
|
23
|
+
});
|
24
|
+
});
|
@@ -0,0 +1,93 @@
|
|
1
|
+
/**
|
2
|
+
* title: 表格内使用
|
3
|
+
*/
|
4
|
+
|
5
|
+
import { Table } from 'antd';
|
6
|
+
import { McEllipsis } from "../..";
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
export default (function () {
|
9
|
+
var longText = '一-二-三-四-五-六-七-八-九-十=壹-贰-叁-肆-伍-陆-柒-捌-玖-拾=yī-èr-sān-sì-wǔ-liù-qī-bā-jiǔ-shí=one-two-three-four-five-six-seven-eight-nine-ten';
|
10
|
+
var dataSource = [];
|
11
|
+
for (var i = 0; i < 100; i++) {
|
12
|
+
dataSource.push({
|
13
|
+
id: i,
|
14
|
+
column1: '单行末尾省略 ' + longText + i,
|
15
|
+
column2: '单行中间省略 ' + longText + i,
|
16
|
+
column3: '3行末尾省略 ' + longText + i,
|
17
|
+
column4: '3行末尾省略可复制 ' + longText + i,
|
18
|
+
column5: '自定义提示内容 ' + longText + i,
|
19
|
+
column6: '2行末尾省略不提示 ' + longText + i
|
20
|
+
});
|
21
|
+
}
|
22
|
+
var columns = [{
|
23
|
+
title: '单行末尾省略',
|
24
|
+
dataIndex: 'column1',
|
25
|
+
width: 120,
|
26
|
+
render: function render(_) {
|
27
|
+
return /*#__PURE__*/_jsx(McEllipsis, {
|
28
|
+
text: _
|
29
|
+
});
|
30
|
+
}
|
31
|
+
}, {
|
32
|
+
title: '单行中间省略',
|
33
|
+
dataIndex: 'column2',
|
34
|
+
width: 120,
|
35
|
+
render: function render(_) {
|
36
|
+
return /*#__PURE__*/_jsx(McEllipsis, {
|
37
|
+
text: _,
|
38
|
+
middle: true
|
39
|
+
});
|
40
|
+
}
|
41
|
+
}, {
|
42
|
+
title: '3行末尾省略',
|
43
|
+
dataIndex: 'column3',
|
44
|
+
width: 120,
|
45
|
+
render: function render(_) {
|
46
|
+
return /*#__PURE__*/_jsx(McEllipsis, {
|
47
|
+
text: _,
|
48
|
+
rows: 3
|
49
|
+
});
|
50
|
+
}
|
51
|
+
}, {
|
52
|
+
title: '3行末尾省略可复制',
|
53
|
+
dataIndex: 'column4',
|
54
|
+
width: 140,
|
55
|
+
render: function render(_) {
|
56
|
+
return /*#__PURE__*/_jsx(McEllipsis, {
|
57
|
+
text: _,
|
58
|
+
rows: 3,
|
59
|
+
copyable: true
|
60
|
+
});
|
61
|
+
}
|
62
|
+
}, {
|
63
|
+
title: '自定义提示内容',
|
64
|
+
dataIndex: 'column5',
|
65
|
+
width: 120,
|
66
|
+
render: function render(_) {
|
67
|
+
return /*#__PURE__*/_jsx(McEllipsis, {
|
68
|
+
text: _,
|
69
|
+
tooltip: "\u6211\u662F\u81EA\u5B9A\u4E49\u63D0\u793A\u5185\u5BB9"
|
70
|
+
});
|
71
|
+
}
|
72
|
+
}, {
|
73
|
+
title: '2行末尾省略不提示',
|
74
|
+
dataIndex: 'column6',
|
75
|
+
width: 140,
|
76
|
+
render: function render(_) {
|
77
|
+
return /*#__PURE__*/_jsx(McEllipsis, {
|
78
|
+
text: _,
|
79
|
+
rows: 2,
|
80
|
+
tooltip: false
|
81
|
+
});
|
82
|
+
}
|
83
|
+
}];
|
84
|
+
return /*#__PURE__*/_jsx(Table, {
|
85
|
+
size: "small",
|
86
|
+
columns: columns,
|
87
|
+
dataSource: dataSource,
|
88
|
+
rowKey: "id",
|
89
|
+
scroll: {
|
90
|
+
y: 300
|
91
|
+
}
|
92
|
+
});
|
93
|
+
});
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/**
|
2
|
+
* title: 提示框宽高
|
3
|
+
* description: 设置 `tooltipMaxWidth` 和 `tooltipMaxHeight` 可控制提示框最大宽高,避免内容过多时显示异常
|
4
|
+
*/
|
5
|
+
|
6
|
+
import { McEllipsis } from "../..";
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
8
|
+
export default (function () {
|
9
|
+
var longText = '一-二-三-四-五-六-七-八-九-十=壹-贰-叁-肆-伍-陆-柒-捌-玖-拾=yī-èr-sān-sì-wǔ-liù-qī-bā-jiǔ-shí=one-two-three-four-five-six-seven-eight-nine-ten';
|
10
|
+
return /*#__PURE__*/_jsx("div", {
|
11
|
+
style: {
|
12
|
+
width: 240
|
13
|
+
},
|
14
|
+
children: /*#__PURE__*/_jsx(McEllipsis, {
|
15
|
+
text: '提示框宽高:' + longText,
|
16
|
+
tooltipMaxWidth: 200,
|
17
|
+
tooltipMaxHeight: 100
|
18
|
+
})
|
19
|
+
});
|
20
|
+
});
|