@gmfe/table-x 2.14.20 → 2.14.26-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +4 -0
- package/README.md +13 -13
- package/package.json +4 -4
- package/src/base/index.js +142 -142
- package/src/base/td.js +56 -56
- package/src/base/th.js +48 -48
- package/src/base/thead.js +26 -26
- package/src/base/tr.js +53 -53
- package/src/base/virtualized.js +219 -219
- package/src/hoc/diy_table_x/components/diy_table_x_modal.js +135 -135
- package/src/hoc/diy_table_x/components/modal_list.js +78 -78
- package/src/hoc/diy_table_x/components/modal_selector.js +56 -56
- package/src/hoc/diy_table_x/index.js +196 -196
- package/src/hoc/edit_table_x.js +20 -20
- package/src/hoc/expand_table_x/index.js +140 -140
- package/src/hoc/expand_table_x/util.js +27 -27
- package/src/hoc/fixed_columns_table_x.js +29 -29
- package/src/hoc/select_table_x/cell.js +51 -51
- package/src/hoc/select_table_x/header.js +28 -28
- package/src/hoc/select_table_x/index.js +139 -139
- package/src/hoc/select_table_x/util.js +10 -10
- package/src/hoc/sortable_table_x.js +52 -52
- package/src/hoc/sub_table_x.js +44 -44
- package/src/index.js +53 -53
- package/src/index.less +515 -515
- package/src/stories/table_x.stories.js +324 -324
- package/src/stories/table_x_hoc.stories.js +427 -427
- package/src/stories/table_x_hoc_select_expand.stories.js +256 -256
- package/src/util/batch_action_bar.js +124 -124
- package/src/util/edit.js +83 -83
- package/src/util/index.js +191 -191
- package/src/util/operation.js +249 -249
- package/src/util/sort_header.js +49 -49
- package/src/variables.less +28 -28
- package/svg/business.svg +20 -20
- package/svg/check-detail.svg +18 -18
- package/svg/closeup.svg +20 -20
- package/svg/delete.svg +10 -10
- package/svg/edit-pen.svg +17 -17
- package/svg/empty.svg +27 -27
- package/svg/expand.svg +21 -21
- package/svg/pen.svg +12 -12
- package/svg/recover.svg +33 -33
- package/svg/remove.svg +1 -1
- package/svg/setting.svg +17 -17
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import _ from 'lodash'
|
|
3
|
-
import { Flex, Popover, Button } from '@gmfe/react'
|
|
4
|
-
import styled from 'styled-components'
|
|
5
|
-
import { getLocale } from '@gmfe/locales'
|
|
6
|
-
import PropTypes from 'prop-types'
|
|
7
|
-
import SVGRemove from '../../svg/remove.svg'
|
|
8
|
-
import SVGDelete from '../../svg/delete.svg'
|
|
9
|
-
import SVGEdit from '../../svg/edit-pen.svg'
|
|
10
|
-
import SVGBusiness from '../../svg/business.svg'
|
|
11
|
-
|
|
12
|
-
const ICON_MAP = {
|
|
13
|
-
delete: <SVGDelete />,
|
|
14
|
-
edit: <SVGEdit />,
|
|
15
|
-
business: <SVGBusiness />
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const Icon = styled.span`
|
|
19
|
-
padding-right: 4px;
|
|
20
|
-
`
|
|
21
|
-
|
|
22
|
-
const BatchActionBar = props => {
|
|
23
|
-
const {
|
|
24
|
-
isSelectAll,
|
|
25
|
-
pure,
|
|
26
|
-
count,
|
|
27
|
-
batchActions,
|
|
28
|
-
toggleSelectAll,
|
|
29
|
-
onClose,
|
|
30
|
-
extra
|
|
31
|
-
} = props
|
|
32
|
-
|
|
33
|
-
let selectAllBtn = null
|
|
34
|
-
// 如果pure = true,不展示[勾选所有页内容]按钮
|
|
35
|
-
if (!pure) {
|
|
36
|
-
selectAllBtn = isSelectAll ? (
|
|
37
|
-
<Button
|
|
38
|
-
type='primary'
|
|
39
|
-
className='gm-margin-left-20'
|
|
40
|
-
onClick={() => toggleSelectAll(false)}
|
|
41
|
-
>
|
|
42
|
-
{getLocale('勾选当前页内容')}
|
|
43
|
-
</Button>
|
|
44
|
-
) : (
|
|
45
|
-
<Button
|
|
46
|
-
type='primary'
|
|
47
|
-
className='gm-margin-left-20'
|
|
48
|
-
onClick={() => toggleSelectAll(true)}
|
|
49
|
-
>
|
|
50
|
-
{getLocale('勾选所有页内容')}
|
|
51
|
-
</Button>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<Flex className='gm-react-table-select-batch-action-bar' alignCenter>
|
|
57
|
-
<Popover
|
|
58
|
-
type='hover'
|
|
59
|
-
popup={<div className='gm-padding-5'>{getLocale('取消批量勾选')}</div>}
|
|
60
|
-
bottom
|
|
61
|
-
left
|
|
62
|
-
offset={-8}
|
|
63
|
-
showArrow
|
|
64
|
-
>
|
|
65
|
-
<span style={{ display: 'block', width: '12px' }} className='gm-cursor'>
|
|
66
|
-
<SVGRemove onClick={onClose} />
|
|
67
|
-
</span>
|
|
68
|
-
</Popover>
|
|
69
|
-
{selectAllBtn}
|
|
70
|
-
{_.isNumber(count) ? (
|
|
71
|
-
<div className='gm-text-bold gm-margin-left-20'>
|
|
72
|
-
{getLocale('已选择')}
|
|
73
|
-
<span className='text-primary'>{count}</span>
|
|
74
|
-
{getLocale('项')}
|
|
75
|
-
</div>
|
|
76
|
-
) : (
|
|
77
|
-
<div className='gm-text-bold gm-margin-left-20'>
|
|
78
|
-
{getLocale('已选择')}
|
|
79
|
-
<span className='text-primary'>{getLocale('所有')}</span>
|
|
80
|
-
{getLocale('页')}
|
|
81
|
-
</div>
|
|
82
|
-
)}
|
|
83
|
-
{extra}
|
|
84
|
-
{batchActions.length && <div className='gm-margin-left-20'>|</div>}
|
|
85
|
-
{batchActions.map(
|
|
86
|
-
o =>
|
|
87
|
-
o.show !== false && (
|
|
88
|
-
<div
|
|
89
|
-
data-id={o.dataId}
|
|
90
|
-
onClick={o.onClick} // eslint-disable-line
|
|
91
|
-
className='gm-text-hover-primary gm-cursor gm-text-bold'
|
|
92
|
-
style={{ marginLeft: '30px' }}
|
|
93
|
-
key={o.name}
|
|
94
|
-
>
|
|
95
|
-
{ICON_MAP[o.type] && <Icon>{ICON_MAP[o.type]}</Icon>}
|
|
96
|
-
{o.name}
|
|
97
|
-
</div>
|
|
98
|
-
)
|
|
99
|
-
)}
|
|
100
|
-
</Flex>
|
|
101
|
-
)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
BatchActionBar.propTypes = {
|
|
105
|
-
/** pure=true,不展示[勾选所有页内容]按钮,也没有勾选所有页相关操作 */
|
|
106
|
-
pure: PropTypes.bool,
|
|
107
|
-
/** 是否选中所有页 */
|
|
108
|
-
isSelectAll: PropTypes.bool,
|
|
109
|
-
/** 选中多少项 */
|
|
110
|
-
count: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
|
|
111
|
-
/** 批量操作按钮 */
|
|
112
|
-
batchActions: PropTypes.array.isRequired,
|
|
113
|
-
/** 所有页/当前页 切换函数 */
|
|
114
|
-
toggleSelectAll: PropTypes.func,
|
|
115
|
-
/** 点击关闭BatchActionBar的回调函数 */
|
|
116
|
-
onClose: PropTypes.func.isRequired,
|
|
117
|
-
extra: PropTypes.node
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
BatchActionBar.defaultProps = {
|
|
121
|
-
toggleSelectAll: () => {}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
export default BatchActionBar
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import _ from 'lodash'
|
|
3
|
+
import { Flex, Popover, Button } from '@gmfe/react'
|
|
4
|
+
import styled from 'styled-components'
|
|
5
|
+
import { getLocale } from '@gmfe/locales'
|
|
6
|
+
import PropTypes from 'prop-types'
|
|
7
|
+
import SVGRemove from '../../svg/remove.svg'
|
|
8
|
+
import SVGDelete from '../../svg/delete.svg'
|
|
9
|
+
import SVGEdit from '../../svg/edit-pen.svg'
|
|
10
|
+
import SVGBusiness from '../../svg/business.svg'
|
|
11
|
+
|
|
12
|
+
const ICON_MAP = {
|
|
13
|
+
delete: <SVGDelete />,
|
|
14
|
+
edit: <SVGEdit />,
|
|
15
|
+
business: <SVGBusiness />
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Icon = styled.span`
|
|
19
|
+
padding-right: 4px;
|
|
20
|
+
`
|
|
21
|
+
|
|
22
|
+
const BatchActionBar = props => {
|
|
23
|
+
const {
|
|
24
|
+
isSelectAll,
|
|
25
|
+
pure,
|
|
26
|
+
count,
|
|
27
|
+
batchActions,
|
|
28
|
+
toggleSelectAll,
|
|
29
|
+
onClose,
|
|
30
|
+
extra
|
|
31
|
+
} = props
|
|
32
|
+
|
|
33
|
+
let selectAllBtn = null
|
|
34
|
+
// 如果pure = true,不展示[勾选所有页内容]按钮
|
|
35
|
+
if (!pure) {
|
|
36
|
+
selectAllBtn = isSelectAll ? (
|
|
37
|
+
<Button
|
|
38
|
+
type='primary'
|
|
39
|
+
className='gm-margin-left-20'
|
|
40
|
+
onClick={() => toggleSelectAll(false)}
|
|
41
|
+
>
|
|
42
|
+
{getLocale('勾选当前页内容')}
|
|
43
|
+
</Button>
|
|
44
|
+
) : (
|
|
45
|
+
<Button
|
|
46
|
+
type='primary'
|
|
47
|
+
className='gm-margin-left-20'
|
|
48
|
+
onClick={() => toggleSelectAll(true)}
|
|
49
|
+
>
|
|
50
|
+
{getLocale('勾选所有页内容')}
|
|
51
|
+
</Button>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Flex className='gm-react-table-select-batch-action-bar' alignCenter>
|
|
57
|
+
<Popover
|
|
58
|
+
type='hover'
|
|
59
|
+
popup={<div className='gm-padding-5'>{getLocale('取消批量勾选')}</div>}
|
|
60
|
+
bottom
|
|
61
|
+
left
|
|
62
|
+
offset={-8}
|
|
63
|
+
showArrow
|
|
64
|
+
>
|
|
65
|
+
<span style={{ display: 'block', width: '12px' }} className='gm-cursor'>
|
|
66
|
+
<SVGRemove onClick={onClose} />
|
|
67
|
+
</span>
|
|
68
|
+
</Popover>
|
|
69
|
+
{selectAllBtn}
|
|
70
|
+
{_.isNumber(count) ? (
|
|
71
|
+
<div className='gm-text-bold gm-margin-left-20'>
|
|
72
|
+
{getLocale('已选择')}
|
|
73
|
+
<span className='text-primary'>{count}</span>
|
|
74
|
+
{getLocale('项')}
|
|
75
|
+
</div>
|
|
76
|
+
) : (
|
|
77
|
+
<div className='gm-text-bold gm-margin-left-20'>
|
|
78
|
+
{getLocale('已选择')}
|
|
79
|
+
<span className='text-primary'>{getLocale('所有')}</span>
|
|
80
|
+
{getLocale('页')}
|
|
81
|
+
</div>
|
|
82
|
+
)}
|
|
83
|
+
{extra}
|
|
84
|
+
{batchActions.length && <div className='gm-margin-left-20'>|</div>}
|
|
85
|
+
{batchActions.map(
|
|
86
|
+
o =>
|
|
87
|
+
o.show !== false && (
|
|
88
|
+
<div
|
|
89
|
+
data-id={o.dataId}
|
|
90
|
+
onClick={o.onClick} // eslint-disable-line
|
|
91
|
+
className='gm-text-hover-primary gm-cursor gm-text-bold'
|
|
92
|
+
style={{ marginLeft: '30px' }}
|
|
93
|
+
key={o.name}
|
|
94
|
+
>
|
|
95
|
+
{ICON_MAP[o.type] && <Icon>{ICON_MAP[o.type]}</Icon>}
|
|
96
|
+
{o.name}
|
|
97
|
+
</div>
|
|
98
|
+
)
|
|
99
|
+
)}
|
|
100
|
+
</Flex>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
BatchActionBar.propTypes = {
|
|
105
|
+
/** pure=true,不展示[勾选所有页内容]按钮,也没有勾选所有页相关操作 */
|
|
106
|
+
pure: PropTypes.bool,
|
|
107
|
+
/** 是否选中所有页 */
|
|
108
|
+
isSelectAll: PropTypes.bool,
|
|
109
|
+
/** 选中多少项 */
|
|
110
|
+
count: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
|
|
111
|
+
/** 批量操作按钮 */
|
|
112
|
+
batchActions: PropTypes.array.isRequired,
|
|
113
|
+
/** 所有页/当前页 切换函数 */
|
|
114
|
+
toggleSelectAll: PropTypes.func,
|
|
115
|
+
/** 点击关闭BatchActionBar的回调函数 */
|
|
116
|
+
onClose: PropTypes.func.isRequired,
|
|
117
|
+
extra: PropTypes.node
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
BatchActionBar.defaultProps = {
|
|
121
|
+
toggleSelectAll: () => {}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export default BatchActionBar
|
package/src/util/edit.js
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import React, { useRef } from 'react'
|
|
2
|
-
import classNames from 'classnames'
|
|
3
|
-
import PropTypes from 'prop-types'
|
|
4
|
-
import { Popover } from '@gmfe/react'
|
|
5
|
-
import SVGEditPen from '../../svg/edit-pen.svg'
|
|
6
|
-
import SVGPlusSquare from '../../svg/plus-square.svg'
|
|
7
|
-
import SVGMinusSquare from '../../svg/minus-square.svg'
|
|
8
|
-
import { OperationCell, OperationIconTip } from './operation'
|
|
9
|
-
import { getLocale } from '@gmfe/locales'
|
|
10
|
-
|
|
11
|
-
const EditButton = ({ popupRender, right }) => {
|
|
12
|
-
const refPopover = useRef(null)
|
|
13
|
-
const closePopup = () => refPopover.current.apiDoSetActive(false)
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<Popover
|
|
17
|
-
ref={refPopover}
|
|
18
|
-
right={right}
|
|
19
|
-
popup={popupRender(closePopup)}
|
|
20
|
-
offset={right ? 24 : -24}
|
|
21
|
-
showArrow
|
|
22
|
-
arrowLeft={right ? 'calc(100% - 42px)' : 26}
|
|
23
|
-
animName={false}
|
|
24
|
-
>
|
|
25
|
-
<span className='gm-table-x-edit-button'>
|
|
26
|
-
<OperationIconTip tip={getLocale('编辑')}>
|
|
27
|
-
<span>
|
|
28
|
-
<SVGEditPen />
|
|
29
|
-
</span>
|
|
30
|
-
</OperationIconTip>
|
|
31
|
-
</span>
|
|
32
|
-
</Popover>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
EditButton.propTypes = {
|
|
37
|
-
popupRender: PropTypes.func.isRequired,
|
|
38
|
-
right: PropTypes.bool
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const EditOperation = props => {
|
|
42
|
-
return (
|
|
43
|
-
<OperationCell>
|
|
44
|
-
<Popover
|
|
45
|
-
showArrow
|
|
46
|
-
type='hover'
|
|
47
|
-
popup={<div className='gm-padding-5'>添加</div>}
|
|
48
|
-
disabled={!props.onAddRow}
|
|
49
|
-
>
|
|
50
|
-
<span
|
|
51
|
-
onClick={props.onAddRow}
|
|
52
|
-
className={classNames('gm-table-x-edit-action-add', {
|
|
53
|
-
disabled: !props.onAddRow
|
|
54
|
-
})}
|
|
55
|
-
>
|
|
56
|
-
<SVGPlusSquare />
|
|
57
|
-
</span>
|
|
58
|
-
</Popover>
|
|
59
|
-
<Popover
|
|
60
|
-
showArrow
|
|
61
|
-
type='hover'
|
|
62
|
-
popup={<div className='gm-padding-5'>删除</div>}
|
|
63
|
-
disabled={!props.onDeleteRow}
|
|
64
|
-
>
|
|
65
|
-
<span
|
|
66
|
-
onClick={props.onDeleteRow}
|
|
67
|
-
className={classNames('gm-table-x-edit-action-delete', {
|
|
68
|
-
disabled: !props.onDeleteRow
|
|
69
|
-
})}
|
|
70
|
-
>
|
|
71
|
-
<SVGMinusSquare />
|
|
72
|
-
</span>
|
|
73
|
-
</Popover>
|
|
74
|
-
</OperationCell>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
EditOperation.propTypes = {
|
|
79
|
-
onAddRow: PropTypes.func,
|
|
80
|
-
onDeleteRow: PropTypes.func
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export { EditButton, EditOperation }
|
|
1
|
+
import React, { useRef } from 'react'
|
|
2
|
+
import classNames from 'classnames'
|
|
3
|
+
import PropTypes from 'prop-types'
|
|
4
|
+
import { Popover } from '@gmfe/react'
|
|
5
|
+
import SVGEditPen from '../../svg/edit-pen.svg'
|
|
6
|
+
import SVGPlusSquare from '../../svg/plus-square.svg'
|
|
7
|
+
import SVGMinusSquare from '../../svg/minus-square.svg'
|
|
8
|
+
import { OperationCell, OperationIconTip } from './operation'
|
|
9
|
+
import { getLocale } from '@gmfe/locales'
|
|
10
|
+
|
|
11
|
+
const EditButton = ({ popupRender, right }) => {
|
|
12
|
+
const refPopover = useRef(null)
|
|
13
|
+
const closePopup = () => refPopover.current.apiDoSetActive(false)
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Popover
|
|
17
|
+
ref={refPopover}
|
|
18
|
+
right={right}
|
|
19
|
+
popup={popupRender(closePopup)}
|
|
20
|
+
offset={right ? 24 : -24}
|
|
21
|
+
showArrow
|
|
22
|
+
arrowLeft={right ? 'calc(100% - 42px)' : 26}
|
|
23
|
+
animName={false}
|
|
24
|
+
>
|
|
25
|
+
<span className='gm-table-x-edit-button'>
|
|
26
|
+
<OperationIconTip tip={getLocale('编辑')}>
|
|
27
|
+
<span>
|
|
28
|
+
<SVGEditPen />
|
|
29
|
+
</span>
|
|
30
|
+
</OperationIconTip>
|
|
31
|
+
</span>
|
|
32
|
+
</Popover>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
EditButton.propTypes = {
|
|
37
|
+
popupRender: PropTypes.func.isRequired,
|
|
38
|
+
right: PropTypes.bool
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const EditOperation = props => {
|
|
42
|
+
return (
|
|
43
|
+
<OperationCell>
|
|
44
|
+
<Popover
|
|
45
|
+
showArrow
|
|
46
|
+
type='hover'
|
|
47
|
+
popup={<div className='gm-padding-5'>添加</div>}
|
|
48
|
+
disabled={!props.onAddRow}
|
|
49
|
+
>
|
|
50
|
+
<span
|
|
51
|
+
onClick={props.onAddRow}
|
|
52
|
+
className={classNames('gm-table-x-edit-action-add', {
|
|
53
|
+
disabled: !props.onAddRow
|
|
54
|
+
})}
|
|
55
|
+
>
|
|
56
|
+
<SVGPlusSquare />
|
|
57
|
+
</span>
|
|
58
|
+
</Popover>
|
|
59
|
+
<Popover
|
|
60
|
+
showArrow
|
|
61
|
+
type='hover'
|
|
62
|
+
popup={<div className='gm-padding-5'>删除</div>}
|
|
63
|
+
disabled={!props.onDeleteRow}
|
|
64
|
+
>
|
|
65
|
+
<span
|
|
66
|
+
onClick={props.onDeleteRow}
|
|
67
|
+
className={classNames('gm-table-x-edit-action-delete', {
|
|
68
|
+
disabled: !props.onDeleteRow
|
|
69
|
+
})}
|
|
70
|
+
>
|
|
71
|
+
<SVGMinusSquare />
|
|
72
|
+
</span>
|
|
73
|
+
</Popover>
|
|
74
|
+
</OperationCell>
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
EditOperation.propTypes = {
|
|
79
|
+
onAddRow: PropTypes.func,
|
|
80
|
+
onDeleteRow: PropTypes.func
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export { EditButton, EditOperation }
|