@gmfe/react 2.14.17 → 2.14.19-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/package.json +3 -3
- package/src/common/hooks/index.js +3 -3
- package/src/common/hooks/use_mutation_observer.js +25 -25
- package/src/common/util.js +52 -52
- package/src/component/affix/affix.stories.js +13 -13
- package/src/component/affix/index.js +21 -21
- package/src/component/box/box.js +31 -31
- package/src/component/box/box.stories.js +94 -94
- package/src/component/box/box_form.js +77 -77
- package/src/component/box/box_panel.js +91 -91
- package/src/component/box/box_table.js +51 -51
- package/src/component/box/index.js +6 -6
- package/src/component/box/style.less +39 -39
- package/src/component/button/button.stories.js +91 -91
- package/src/component/button/index.js +92 -92
- package/src/component/button/style.less +114 -114
- package/src/component/calendar/calendar.js +52 -52
- package/src/component/calendar/calendar.stories.js +57 -57
- package/src/component/calendar/content.js +89 -89
- package/src/component/calendar/day.js +109 -109
- package/src/component/calendar/head.js +243 -243
- package/src/component/calendar/index.js +4 -4
- package/src/component/calendar/range_calendar.js +150 -150
- package/src/component/calendar/style.less +140 -140
- package/src/component/calendar/week.js +27 -27
- package/src/component/carousel/carousel.js +178 -178
- package/src/component/carousel/stories.js +50 -50
- package/src/component/carousel/style.less +48 -48
- package/src/component/cascader/cascader.js +443 -443
- package/src/component/cascader/cascader.select.js +195 -195
- package/src/component/cascader/stories.js +240 -240
- package/src/component/cascader/style.less +122 -122
- package/src/component/checkbox/checkbox.js +86 -86
- package/src/component/checkbox/checkbox_group.js +66 -66
- package/src/component/checkbox/index.js +4 -4
- package/src/component/checkbox/stories.js +103 -103
- package/src/component/checkbox/style.less +88 -88
- package/src/component/collapse/collapse.stories.js +18 -18
- package/src/component/collapse/index.js +36 -36
- package/src/component/color_picker/index.js +190 -190
- package/src/component/color_picker/stories.js +17 -17
- package/src/component/color_picker/style.less +41 -41
- package/src/component/date_picker/date_picker.stories.js +102 -102
- package/src/component/date_picker/index.js +217 -217
- package/src/component/date_picker/overlay.js +119 -119
- package/src/component/date_picker/style.less +22 -22
- package/src/component/date_picker/time_select.js +62 -62
- package/src/component/date_range_picker/date_range_picker.stories.js +196 -196
- package/src/component/date_range_picker/index.js +206 -206
- package/src/component/date_range_picker/left.js +127 -127
- package/src/component/date_range_picker/overlay.js +202 -202
- package/src/component/date_range_picker/style.less +46 -46
- package/src/component/date_range_picker/time_range_select.js +150 -150
- package/src/component/date_range_picker/two.js +129 -129
- package/src/component/date_range_picker/util.js +42 -42
- package/src/component/dialog/index.js +240 -240
- package/src/component/dialog/stories.js +125 -125
- package/src/component/divider/index.js +28 -28
- package/src/component/divider/stories.js +5 -5
- package/src/component/divider/style.less +15 -15
- package/src/component/drawer/index.js +107 -107
- package/src/component/drawer/style.less +43 -43
- package/src/component/drop_down/drop_down.js +84 -84
- package/src/component/drop_down/drop_down_item.js +43 -43
- package/src/component/drop_down/drop_down_items.js +22 -22
- package/src/component/drop_down/index.js +5 -5
- package/src/component/drop_down/stories.js +38 -38
- package/src/component/drop_down/style.less +21 -21
- package/src/component/drop_select/index.js +208 -208
- package/src/component/drop_select/style.less +69 -69
- package/src/component/dropper/index.js +62 -62
- package/src/component/dropper/style.less +18 -18
- package/src/component/editable_text/editable_text.stories.js +47 -47
- package/src/component/editable_text/index.js +106 -106
- package/src/component/editable_text/style.less +29 -29
- package/src/component/filter_select/filter.select.js +416 -416
- package/src/component/filter_select/multiple.filter.select.js +425 -425
- package/src/component/filter_select/style.less +117 -117
- package/src/component/flex/index.js +132 -132
- package/src/component/flex/stories.js +13 -13
- package/src/component/flex/style.less +101 -101
- package/src/component/flip_number/index.js +196 -196
- package/src/component/flip_number/stories.js +25 -25
- package/src/component/flip_number/utils.js +50 -50
- package/src/component/form/form.js +153 -153
- package/src/component/form/form.stories.js +553 -553
- package/src/component/form/form_block.js +59 -59
- package/src/component/form/form_button.js +29 -29
- package/src/component/form/form_group.js +173 -173
- package/src/component/form/form_item.js +163 -163
- package/src/component/form/form_panel.js +71 -71
- package/src/component/form/index.js +8 -8
- package/src/component/form/style.less +130 -130
- package/src/component/form/util.js +13 -13
- package/src/component/function_set/function_set.stories.js +91 -91
- package/src/component/function_set/index.js +98 -98
- package/src/component/function_set/overlay.js +56 -56
- package/src/component/grid/col.js +72 -72
- package/src/component/grid/grid.stories.js +123 -123
- package/src/component/grid/index.js +4 -4
- package/src/component/grid/mixin.less +48 -48
- package/src/component/grid/row.js +44 -44
- package/src/component/grid/style.less +26 -26
- package/src/component/grid/util.js +11 -11
- package/src/component/icon_down_up/index.js +28 -28
- package/src/component/icon_down_up/stories.js +18 -18
- package/src/component/icon_down_up/style.less +8 -8
- package/src/component/image_preview/index.js +20 -20
- package/src/component/image_preview/preview_modal.js +193 -193
- package/src/component/image_preview/style.less +119 -119
- package/src/component/img_uploader/index.js +149 -149
- package/src/component/img_uploader/index.stories.js +51 -51
- package/src/component/img_uploader/style.less +22 -22
- package/src/component/input/index.js +19 -19
- package/src/component/input_number/index.js +73 -73
- package/src/component/input_number/number.js +158 -158
- package/src/component/input_number/stories.js +21 -21
- package/src/component/input_number/style.less +10 -10
- package/src/component/layout_root/index.js +165 -165
- package/src/component/lazy_img/index.js +68 -68
- package/src/component/level_list/index.js +120 -120
- package/src/component/level_list/level_item.js +64 -64
- package/src/component/level_list/level_list.stories.js +139 -139
- package/src/component/level_list/style.less +47 -47
- package/src/component/level_list/util.js +22 -22
- package/src/component/level_select/index.js +240 -240
- package/src/component/level_select/level_select.stories.js +67 -67
- package/src/component/list/base.js +155 -155
- package/src/component/list/index.js +93 -93
- package/src/component/list/list.stories.js +99 -99
- package/src/component/list/style.less +58 -58
- package/src/component/loading/index.js +45 -45
- package/src/component/loading/loading_chunk.js +59 -59
- package/src/component/loading/loading_full_screen.js +62 -62
- package/src/component/loading/stories.js +46 -46
- package/src/component/loading/style.less +92 -92
- package/src/component/mask/index.js +34 -34
- package/src/component/mask/style.less +10 -10
- package/src/component/modal/clean_modal.js +36 -36
- package/src/component/modal/index.js +293 -293
- package/src/component/modal/right_side_modal.js +37 -37
- package/src/component/modal/stories.js +96 -96
- package/src/component/modal/style.less +145 -145
- package/src/component/more_select/base.js +517 -517
- package/src/component/more_select/index.js +91 -91
- package/src/component/more_select/stories.js +261 -261
- package/src/component/more_select/style.less +130 -130
- package/src/component/nav/index.js +269 -269
- package/src/component/nav/nav.stories.js +133 -133
- package/src/component/nav/style.less +156 -156
- package/src/component/nprogress/index.js +34 -34
- package/src/component/nprogress/stories.js +22 -22
- package/src/component/nprogress/style.less +39 -39
- package/src/component/pagination/base.js +67 -67
- package/src/component/pagination/left.js +65 -65
- package/src/component/pagination/page.js +120 -120
- package/src/component/pagination/page_peek.js +96 -96
- package/src/component/pagination/pagination.js +54 -54
- package/src/component/pagination/pagination.stories.js +104 -104
- package/src/component/pagination/pagination_text.js +71 -71
- package/src/component/pagination/pagination_v2.js +30 -30
- package/src/component/pagination/right.js +67 -67
- package/src/component/pagination/style.less +52 -52
- package/src/component/pagination/util.js +5 -5
- package/src/component/picture_preview/index.js +21 -21
- package/src/component/popover/index.js +373 -373
- package/src/component/popover/stories.js +101 -101
- package/src/component/popup/index.js +4 -4
- package/src/component/popup/popup.js +172 -172
- package/src/component/popup/popup_content_confirm.js +67 -67
- package/src/component/popup/style.less +105 -105
- package/src/component/price/index.js +147 -147
- package/src/component/price/stories.js +34 -34
- package/src/component/progress/index.js +101 -101
- package/src/component/progress/stories.js +60 -60
- package/src/component/progress/style.less +88 -88
- package/src/component/progress_circle/index.js +116 -116
- package/src/component/progress_circle/stories.js +54 -54
- package/src/component/progress_circle/style.less +17 -17
- package/src/component/radio/index.js +4 -4
- package/src/component/radio/radio.js +76 -76
- package/src/component/radio/radio_group.js +51 -51
- package/src/component/radio/stories.js +80 -80
- package/src/component/radio/style.less +63 -63
- package/src/component/recommend_input/index.js +118 -118
- package/src/component/recommend_input/recommend_input.stories.js +56 -56
- package/src/component/recommend_input/style.less +25 -25
- package/src/component/select/index.js +4 -4
- package/src/component/select/option.js +22 -22
- package/src/component/select/select.js +186 -186
- package/src/component/select/select.stories.js +79 -79
- package/src/component/select/style.less +4 -4
- package/src/component/selection/index.js +132 -132
- package/src/component/selection/selection.stories.js +41 -41
- package/src/component/selection/style.less +67 -67
- package/src/component/sheet/index.js +7 -7
- package/src/component/sheet/sheet.js +348 -348
- package/src/component/sheet/sheet_action.js +16 -16
- package/src/component/sheet/sheet_batch_action.js +16 -16
- package/src/component/sheet/sheet_column.js +21 -21
- package/src/component/sheet/sheet_select.js +31 -31
- package/src/component/sheet/stories.js +210 -210
- package/src/component/sheet/style.less +95 -95
- package/src/component/steps/index.js +66 -66
- package/src/component/steps/steps.stories.js +15 -15
- package/src/component/steps/style.less +39 -39
- package/src/component/storage/index.js +54 -54
- package/src/component/storage/stories.js +38 -38
- package/src/component/switch/index.js +118 -118
- package/src/component/switch/stories.js +7 -7
- package/src/component/switch/style.less +70 -70
- package/src/component/table_select/index.js +152 -152
- package/src/component/table_select/style.less +12 -12
- package/src/component/table_select/table_select.stories.js +91 -91
- package/src/component/table_select/util.js +21 -21
- package/src/component/tabs/style.less +33 -33
- package/src/component/tabs/tabs.js +97 -97
- package/src/component/tabs/tabs.stories.js +48 -48
- package/src/component/time_span/style.less +45 -45
- package/src/component/time_span/time_span.js +183 -183
- package/src/component/time_span/time_span.stories.js +66 -66
- package/src/component/time_span/time_span_picker.js +112 -112
- package/src/component/time_span/time_span_picker.stories.js +71 -71
- package/src/component/tip/index.js +168 -168
- package/src/component/tip/stories.js +54 -54
- package/src/component/tip/style.less +41 -41
- package/src/component/tool_tip/index.js +58 -58
- package/src/component/tool_tip/stories.js +36 -36
- package/src/component/transfer/box.js +186 -141
- package/src/component/transfer/index.js +4 -4
- package/src/component/transfer/stories.js +108 -118
- package/src/component/transfer/style.less +34 -34
- package/src/component/transfer/transfer.js +181 -173
- package/src/component/transfer/transfer_group.js +178 -178
- package/src/component/transfer_v2/index.js +171 -171
- package/src/component/transfer_v2/transfer_v2.stories.js +226 -226
- package/src/component/tree/bottom.js +41 -41
- package/src/component/tree/index.js +205 -205
- package/src/component/tree/item.js +154 -154
- package/src/component/tree/list.js +151 -151
- package/src/component/tree/style.less +147 -147
- package/src/component/tree/tree.stories.js +241 -241
- package/src/component/tree/util.js +24 -24
- package/src/component/tree_v2/bottom.js +40 -40
- package/src/component/tree_v2/index.js +260 -260
- package/src/component/tree_v2/list.js +230 -230
- package/src/component/tree_v2/style.less +38 -38
- package/src/component/tree_v2/tree.stories.js +419 -419
- package/src/component/tree_v2/util.js +185 -185
- package/src/component/uploader/index.js +108 -108
- package/src/component/uploader/style.less +24 -24
- package/src/component/uploader/uploader.stories.js +51 -51
- package/src/css/arrow.less +56 -56
- package/src/css/bg.less +52 -52
- package/src/css/border.less +40 -40
- package/src/css/cover.less +236 -236
- package/src/css/cursor.less +19 -19
- package/src/css/display.less +16 -16
- package/src/css/distance.less +324 -324
- package/src/css/error.less +10 -10
- package/src/css/other.less +16 -16
- package/src/css/overflow.less +23 -23
- package/src/css/position.less +11 -11
- package/src/css/rotate.less +28 -28
- package/src/css/shadow.less +11 -11
- package/src/css/stories.js +104 -104
- package/src/css/svg.less +51 -51
- package/src/css/text.less +120 -120
- package/src/css/variables.less +62 -62
- package/src/event_type.js +16 -16
- package/src/fonts/glyphicons-halflings-regular.svg +542 -542
- package/src/index.js +237 -237
- package/src/index.less +108 -108
- package/src/less/.csscomb.json +304 -304
- package/src/less/.csslintrc +19 -19
- package/src/less/alerts.less +72 -72
- package/src/less/badges.less +65 -65
- package/src/less/bootstrap.less +51 -51
- package/src/less/breadcrumbs.less +25 -25
- package/src/less/button-groups.less +253 -253
- package/src/less/buttons.less +186 -186
- package/src/less/carousel.less +269 -269
- package/src/less/close.less +33 -33
- package/src/less/code.less +68 -68
- package/src/less/component-animations.less +39 -39
- package/src/less/custom.less +37 -37
- package/src/less/dropdowns.less +215 -215
- package/src/less/forms.less +612 -612
- package/src/less/glyphicons.less +1614 -1614
- package/src/less/grid.less +76 -76
- package/src/less/input-groups.less +175 -175
- package/src/less/jumbotron.less +53 -53
- package/src/less/labels.less +64 -64
- package/src/less/list-group.less +126 -126
- package/src/less/media.less +66 -66
- package/src/less/mixins/alerts.less +14 -14
- package/src/less/mixins/background-variant.less +9 -9
- package/src/less/mixins/border-radius.less +21 -21
- package/src/less/mixins/buttons.less +65 -65
- package/src/less/mixins/center-block.less +7 -7
- package/src/less/mixins/clearfix.less +22 -22
- package/src/less/mixins/forms.less +84 -84
- package/src/less/mixins/gradients.less +59 -59
- package/src/less/mixins/grid-framework.less +96 -96
- package/src/less/mixins/grid.less +134 -134
- package/src/less/mixins/hide-text.less +21 -21
- package/src/less/mixins/image.less +25 -25
- package/src/less/mixins/labels.less +12 -12
- package/src/less/mixins/list-group.less +30 -30
- package/src/less/mixins/nav-divider.less +10 -10
- package/src/less/mixins/nav-vertical-align.less +9 -9
- package/src/less/mixins/opacity.less +8 -8
- package/src/less/mixins/pagination.less +24 -24
- package/src/less/mixins/panels.less +24 -24
- package/src/less/mixins/progress-bar.less +10 -10
- package/src/less/mixins/reset-filter.less +8 -8
- package/src/less/mixins/reset-text.less +18 -18
- package/src/less/mixins/resize.less +6 -6
- package/src/less/mixins/responsive-visibility.less +21 -21
- package/src/less/mixins/size.less +10 -10
- package/src/less/mixins/tab-focus.less +9 -9
- package/src/less/mixins/table-row.less +28 -28
- package/src/less/mixins/text-emphasis.less +9 -9
- package/src/less/mixins/text-overflow.less +8 -8
- package/src/less/mixins/vendor-prefixes.less +254 -254
- package/src/less/mixins.less +36 -36
- package/src/less/modals.less +163 -163
- package/src/less/navbar.less +651 -651
- package/src/less/navs.less +236 -236
- package/src/less/normalize.less +424 -424
- package/src/less/pager.less +54 -54
- package/src/less/pagination.less +90 -90
- package/src/less/panels.less +274 -274
- package/src/less/popovers.less +140 -140
- package/src/less/print.less +103 -103
- package/src/less/progress-bars.less +92 -92
- package/src/less/responsive-embed.less +35 -35
- package/src/less/responsive-utilities.less +209 -209
- package/src/less/scaffolding.less +154 -154
- package/src/less/tables.less +228 -228
- package/src/less/theme.less +344 -344
- package/src/less/thumbnails.less +35 -35
- package/src/less/tooltip.less +115 -115
- package/src/less/type.less +352 -352
- package/src/less/utilities.less +57 -57
- package/src/less/variables.less +833 -833
- package/src/less/wells.less +29 -29
- package/src/sotries.js +4 -4
- package/src/validator/index.js +10 -10
- package/src/validator/rules.js +66 -66
- package/src/validator/type.js +10 -10
- package/src/validator/validator.js +86 -86
- package/src/var.less +4 -4
- package/svg/calendar-month.svg +8 -8
- package/svg/calendar-year.svg +13 -13
- package/svg/calendar.svg +17 -17
- package/svg/check-detail.svg +18 -18
- package/svg/close-circle.svg +13 -13
- package/svg/closeup.svg +20 -20
- package/svg/delete.svg +10 -10
- package/svg/down-small.svg +1 -1
- package/svg/down.svg +1 -1
- package/svg/edit-box.svg +17 -17
- package/svg/edit-pen.svg +17 -17
- package/svg/empty.svg +27 -27
- package/svg/expand.svg +21 -21
- package/svg/left-small.svg +1 -1
- package/svg/more.svg +10 -10
- package/svg/next.svg +40 -40
- package/svg/pen.svg +12 -12
- package/svg/remove.svg +1 -1
- package/svg/right-small.svg +1 -1
- package/svg/search.svg +8 -8
- package/svg/setting.svg +17 -17
- package/svg/up-small.svg +1 -1
- package/svg/up.svg +1 -1
@@ -1,348 +1,348 @@
|
|
1
|
-
import { getLocale } from '@gmfe/locales'
|
2
|
-
import React from 'react'
|
3
|
-
import ReactDOM from 'react-dom'
|
4
|
-
import PropTypes from 'prop-types'
|
5
|
-
import Pagination from '../pagination/pagination.js'
|
6
|
-
import PaginationText from '../pagination/pagination_text.js'
|
7
|
-
import _ from 'lodash'
|
8
|
-
import classNames from 'classnames'
|
9
|
-
import SheetColumn from './sheet_column'
|
10
|
-
import SheetAction from './sheet_action'
|
11
|
-
import SheetSelect from './sheet_select'
|
12
|
-
import SheetBatchAction from './sheet_batch_action'
|
13
|
-
import Loading from '../loading'
|
14
|
-
import Flex from '../flex'
|
15
|
-
import { warn } from '@gm-common/tool'
|
16
|
-
|
17
|
-
class Sheet extends React.Component {
|
18
|
-
constructor(props) {
|
19
|
-
super(props)
|
20
|
-
this.checkboxOrRadioName = 'sheet_checkbox_radio_' + Math.random()
|
21
|
-
|
22
|
-
warn('Sheet Deprecated. Use Table instead.')
|
23
|
-
}
|
24
|
-
|
25
|
-
handleSelect(select, i, event) {
|
26
|
-
// 恩,很复杂
|
27
|
-
const { checked } = event.target
|
28
|
-
if (select.props.onChange) {
|
29
|
-
const { list } = this.props
|
30
|
-
if (select.props.isRadio) {
|
31
|
-
_.each(list, v => {
|
32
|
-
if (!select.props.isDisabled(v)) {
|
33
|
-
v._gm_select = false
|
34
|
-
}
|
35
|
-
})
|
36
|
-
list[i]._gm_select = true
|
37
|
-
} else {
|
38
|
-
list[i]._gm_select = checked
|
39
|
-
}
|
40
|
-
select.props.onChange(list)
|
41
|
-
} else {
|
42
|
-
select.props.onSelect(checked, i)
|
43
|
-
}
|
44
|
-
}
|
45
|
-
|
46
|
-
handleSelectAll(select, event) {
|
47
|
-
// 恩,很复杂
|
48
|
-
const { checked } = event.target
|
49
|
-
if (select.props.onChange) {
|
50
|
-
const { list } = this.props
|
51
|
-
_.each(list, v => {
|
52
|
-
if (!select.props.isDisabled(v)) {
|
53
|
-
v._gm_select = checked
|
54
|
-
}
|
55
|
-
})
|
56
|
-
select.props.onChange(list)
|
57
|
-
} else {
|
58
|
-
select.props.onSelectAll(checked)
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
handleExpanded(index) {
|
63
|
-
const { onExpand } = this.props
|
64
|
-
onExpand && onExpand(index)
|
65
|
-
}
|
66
|
-
|
67
|
-
handleExpandedAll = () => {
|
68
|
-
const { onExpandAll } = this.props
|
69
|
-
onExpandAll && onExpandAll()
|
70
|
-
}
|
71
|
-
|
72
|
-
renderTr(select, columns, actions) {
|
73
|
-
const { loading, list = [], enableEmptyTip, expandedRowRender } = this.props
|
74
|
-
|
75
|
-
if (loading) {
|
76
|
-
return (
|
77
|
-
<tr>
|
78
|
-
<td colSpan='99' className='text-center' style={{ padding: '10px' }}>
|
79
|
-
<Loading size={30} />
|
80
|
-
</td>
|
81
|
-
</tr>
|
82
|
-
)
|
83
|
-
}
|
84
|
-
|
85
|
-
if (enableEmptyTip && list.length === 0) {
|
86
|
-
return (
|
87
|
-
<tr>
|
88
|
-
<td colSpan='99' className='text-center'>
|
89
|
-
{enableEmptyTip === true ? getLocale('没有数据') : enableEmptyTip}
|
90
|
-
</td>
|
91
|
-
</tr>
|
92
|
-
)
|
93
|
-
}
|
94
|
-
|
95
|
-
const trs = []
|
96
|
-
|
97
|
-
_.each(list, (value, index) => {
|
98
|
-
trs.push(
|
99
|
-
<tr {...this.props.getTrProps(index)} key={index}>
|
100
|
-
{expandedRowRender && (
|
101
|
-
<td>
|
102
|
-
<i
|
103
|
-
className={classNames(
|
104
|
-
'gm-sheet-expanded-icon text-primary glyphicon',
|
105
|
-
{
|
106
|
-
'glyphicon-minus': value.__gm_expanded,
|
107
|
-
'glyphicon-plus': !value.__gm_expanded
|
108
|
-
}
|
109
|
-
)}
|
110
|
-
onClick={this.handleExpanded.bind(this, index)}
|
111
|
-
/>
|
112
|
-
</td>
|
113
|
-
)}
|
114
|
-
{select && (
|
115
|
-
<td>
|
116
|
-
<input
|
117
|
-
type={select.props.isRadio ? 'radio' : 'checkbox'}
|
118
|
-
name={this.checkboxOrRadioName}
|
119
|
-
className='gm-cursor'
|
120
|
-
checked={value._gm_select || false}
|
121
|
-
onChange={this.handleSelect.bind(this, select, index)}
|
122
|
-
disabled={select.props.isDisabled(value)}
|
123
|
-
/>
|
124
|
-
</td>
|
125
|
-
)}
|
126
|
-
{_.map(columns, (v, i) => {
|
127
|
-
const {
|
128
|
-
children,
|
129
|
-
field,
|
130
|
-
name, // eslint-disable-line
|
131
|
-
placeholder,
|
132
|
-
render,
|
133
|
-
...rest
|
134
|
-
} = v.props
|
135
|
-
if (typeof children === 'function') {
|
136
|
-
return (
|
137
|
-
<td key={i} {...rest}>
|
138
|
-
{children(value[field], index, value)}
|
139
|
-
</td>
|
140
|
-
)
|
141
|
-
} else if (typeof render === 'function') {
|
142
|
-
return (
|
143
|
-
<td key={i} {...rest}>
|
144
|
-
{render(value[field], index, value)}
|
145
|
-
</td>
|
146
|
-
)
|
147
|
-
} else {
|
148
|
-
const tdV = value[field]
|
149
|
-
if (
|
150
|
-
placeholder !== undefined &&
|
151
|
-
(tdV === undefined || tdV === null)
|
152
|
-
) {
|
153
|
-
return (
|
154
|
-
<td key={i} {...rest}>
|
155
|
-
{placeholder}
|
156
|
-
</td>
|
157
|
-
)
|
158
|
-
}
|
159
|
-
return (
|
160
|
-
<td key={i} {...rest}>
|
161
|
-
{tdV}
|
162
|
-
</td>
|
163
|
-
)
|
164
|
-
}
|
165
|
-
})}
|
166
|
-
{actions ? (
|
167
|
-
<td className='text-center'>
|
168
|
-
{actions.props.children(value, index)}
|
169
|
-
</td>
|
170
|
-
) : null}
|
171
|
-
</tr>
|
172
|
-
)
|
173
|
-
|
174
|
-
if (expandedRowRender && value.__gm_expanded) {
|
175
|
-
trs.push(
|
176
|
-
<tr className='gm-sheet-expanded-tr' key={index + '_expanded'}>
|
177
|
-
<td className='gm-sheet-expanded-td' colSpan='99'>
|
178
|
-
{expandedRowRender(index)}
|
179
|
-
</td>
|
180
|
-
</tr>
|
181
|
-
)
|
182
|
-
}
|
183
|
-
})
|
184
|
-
|
185
|
-
return trs
|
186
|
-
}
|
187
|
-
|
188
|
-
render() {
|
189
|
-
const { list = [], scrollX, expandedRowRender } = this.props
|
190
|
-
let select = false
|
191
|
-
let isSelectAll = false
|
192
|
-
let isHasContract = false
|
193
|
-
let pagination
|
194
|
-
let paginationText
|
195
|
-
|
196
|
-
const columns = []
|
197
|
-
let actions = false
|
198
|
-
let batchs = false
|
199
|
-
const others = []
|
200
|
-
|
201
|
-
_.each(React.Children.toArray(this.props.children), value => {
|
202
|
-
if (value !== null && value !== undefined) {
|
203
|
-
if (value.type.displayName === SheetColumn.displayName) {
|
204
|
-
columns.push(value)
|
205
|
-
} else if (value.type.displayName === SheetAction.displayName) {
|
206
|
-
actions = value
|
207
|
-
} else if (value.type.displayName === SheetSelect.displayName) {
|
208
|
-
select = value
|
209
|
-
} else if (value.type.displayName === SheetBatchAction.displayName) {
|
210
|
-
batchs = value
|
211
|
-
} else if (value.type.displayName === Pagination.displayName) {
|
212
|
-
pagination = value
|
213
|
-
} else if (value.type.displayName === PaginationText.displayName) {
|
214
|
-
paginationText = value
|
215
|
-
} else {
|
216
|
-
others.push(value)
|
217
|
-
}
|
218
|
-
}
|
219
|
-
})
|
220
|
-
|
221
|
-
if (select && list.length > 0) {
|
222
|
-
// 存在有效行,且不存在未选中的行
|
223
|
-
isSelectAll =
|
224
|
-
_.find(list, value => !select.props.isDisabled(value)) &&
|
225
|
-
!_.find(
|
226
|
-
list,
|
227
|
-
value => !select.props.isDisabled(value) && !value._gm_select
|
228
|
-
)
|
229
|
-
}
|
230
|
-
// 检查是否有某一列收起
|
231
|
-
if (expandedRowRender && list.length) {
|
232
|
-
isHasContract = !!_.find(list, l => !l.__gm_expanded)
|
233
|
-
}
|
234
|
-
|
235
|
-
return (
|
236
|
-
<div className={classNames('gm-sheet', this.props.className)}>
|
237
|
-
{select && batchs ? (
|
238
|
-
<div className='gm-margin-bottom-5 text-right'>
|
239
|
-
{batchs.props.children}
|
240
|
-
</div>
|
241
|
-
) : null}
|
242
|
-
|
243
|
-
{isSelectAll && select.props.hasSelectTip && (
|
244
|
-
<div className='gm-box-shadow-bottom gm-sheet-select-all-tip'>
|
245
|
-
<span className='gm-sheet-select-all-tip-arrow' />
|
246
|
-
{select.props.selectAllTip}
|
247
|
-
</div>
|
248
|
-
)}
|
249
|
-
|
250
|
-
<div
|
251
|
-
className={
|
252
|
-
'gm-sheet-table' + (scrollX ? ' gm-sheet-table-scroll-x' : '')
|
253
|
-
}
|
254
|
-
>
|
255
|
-
<table className='table table-striped table-hover table-bordered'>
|
256
|
-
<thead>
|
257
|
-
<tr>
|
258
|
-
{expandedRowRender && (
|
259
|
-
<th className='gm-sheet-th-expanded'>
|
260
|
-
<i
|
261
|
-
className={classNames(
|
262
|
-
'gm-sheet-expanded-icon text-primary glyphicon',
|
263
|
-
{
|
264
|
-
'glyphicon-minus': !isHasContract,
|
265
|
-
'glyphicon-plus': isHasContract
|
266
|
-
}
|
267
|
-
)}
|
268
|
-
onClick={this.handleExpandedAll}
|
269
|
-
/>
|
270
|
-
</th>
|
271
|
-
)}
|
272
|
-
{select && (
|
273
|
-
<th className='gm-sheet-select'>
|
274
|
-
{!select.props.isRadio && (
|
275
|
-
<div>
|
276
|
-
<input
|
277
|
-
type='checkbox'
|
278
|
-
checked={isSelectAll}
|
279
|
-
onChange={this.handleSelectAll.bind(this, select)}
|
280
|
-
/>
|
281
|
-
</div>
|
282
|
-
)}
|
283
|
-
</th>
|
284
|
-
)}
|
285
|
-
{_.map(columns, (value, index) => {
|
286
|
-
const {
|
287
|
-
children,
|
288
|
-
field,
|
289
|
-
name,
|
290
|
-
placeholder,
|
291
|
-
render, // eslint-disable-line
|
292
|
-
...rest
|
293
|
-
} = value.props
|
294
|
-
return (
|
295
|
-
<th key={index} {...rest}>
|
296
|
-
{value.props.name}
|
297
|
-
</th>
|
298
|
-
)
|
299
|
-
})}
|
300
|
-
{actions && <th className='text-center'>操作</th>}
|
301
|
-
</tr>
|
302
|
-
</thead>
|
303
|
-
<tbody>{this.renderTr(select, columns, actions)}</tbody>
|
304
|
-
</table>
|
305
|
-
</div>
|
306
|
-
{(pagination || paginationText) && (
|
307
|
-
<Flex justifyEnd alignCenter className='gm-padding-20'>
|
308
|
-
{paginationText && <div>{paginationText}</div>}
|
309
|
-
{pagination && <div>{pagination}</div>}
|
310
|
-
</Flex>
|
311
|
-
)}
|
312
|
-
{others}
|
313
|
-
</div>
|
314
|
-
)
|
315
|
-
}
|
316
|
-
}
|
317
|
-
|
318
|
-
Sheet.findTableDOM = function(ref) {
|
319
|
-
return ReactDOM.findDOMNode(ref).getElementsByTagName('table')[0]
|
320
|
-
}
|
321
|
-
|
322
|
-
Sheet.propTypes = {
|
323
|
-
list: PropTypes.array.isRequired,
|
324
|
-
loading: PropTypes.bool,
|
325
|
-
enableEmptyTip: PropTypes.oneOfType([
|
326
|
-
PropTypes.bool,
|
327
|
-
PropTypes.string,
|
328
|
-
PropTypes.element
|
329
|
-
]),
|
330
|
-
className: PropTypes.string,
|
331
|
-
getTrProps: PropTypes.func,
|
332
|
-
scrollX: PropTypes.bool,
|
333
|
-
expandedRowRender: PropTypes.func,
|
334
|
-
onExpand: PropTypes.func,
|
335
|
-
onExpandAll: PropTypes.func,
|
336
|
-
children: PropTypes.any
|
337
|
-
}
|
338
|
-
|
339
|
-
Sheet.defaultProps = {
|
340
|
-
list: [],
|
341
|
-
loading: false,
|
342
|
-
getTrProps: () => {
|
343
|
-
return {}
|
344
|
-
},
|
345
|
-
scrollX: false
|
346
|
-
}
|
347
|
-
|
348
|
-
export default Sheet
|
1
|
+
import { getLocale } from '@gmfe/locales'
|
2
|
+
import React from 'react'
|
3
|
+
import ReactDOM from 'react-dom'
|
4
|
+
import PropTypes from 'prop-types'
|
5
|
+
import Pagination from '../pagination/pagination.js'
|
6
|
+
import PaginationText from '../pagination/pagination_text.js'
|
7
|
+
import _ from 'lodash'
|
8
|
+
import classNames from 'classnames'
|
9
|
+
import SheetColumn from './sheet_column'
|
10
|
+
import SheetAction from './sheet_action'
|
11
|
+
import SheetSelect from './sheet_select'
|
12
|
+
import SheetBatchAction from './sheet_batch_action'
|
13
|
+
import Loading from '../loading'
|
14
|
+
import Flex from '../flex'
|
15
|
+
import { warn } from '@gm-common/tool'
|
16
|
+
|
17
|
+
class Sheet extends React.Component {
|
18
|
+
constructor(props) {
|
19
|
+
super(props)
|
20
|
+
this.checkboxOrRadioName = 'sheet_checkbox_radio_' + Math.random()
|
21
|
+
|
22
|
+
warn('Sheet Deprecated. Use Table instead.')
|
23
|
+
}
|
24
|
+
|
25
|
+
handleSelect(select, i, event) {
|
26
|
+
// 恩,很复杂
|
27
|
+
const { checked } = event.target
|
28
|
+
if (select.props.onChange) {
|
29
|
+
const { list } = this.props
|
30
|
+
if (select.props.isRadio) {
|
31
|
+
_.each(list, v => {
|
32
|
+
if (!select.props.isDisabled(v)) {
|
33
|
+
v._gm_select = false
|
34
|
+
}
|
35
|
+
})
|
36
|
+
list[i]._gm_select = true
|
37
|
+
} else {
|
38
|
+
list[i]._gm_select = checked
|
39
|
+
}
|
40
|
+
select.props.onChange(list)
|
41
|
+
} else {
|
42
|
+
select.props.onSelect(checked, i)
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
handleSelectAll(select, event) {
|
47
|
+
// 恩,很复杂
|
48
|
+
const { checked } = event.target
|
49
|
+
if (select.props.onChange) {
|
50
|
+
const { list } = this.props
|
51
|
+
_.each(list, v => {
|
52
|
+
if (!select.props.isDisabled(v)) {
|
53
|
+
v._gm_select = checked
|
54
|
+
}
|
55
|
+
})
|
56
|
+
select.props.onChange(list)
|
57
|
+
} else {
|
58
|
+
select.props.onSelectAll(checked)
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
handleExpanded(index) {
|
63
|
+
const { onExpand } = this.props
|
64
|
+
onExpand && onExpand(index)
|
65
|
+
}
|
66
|
+
|
67
|
+
handleExpandedAll = () => {
|
68
|
+
const { onExpandAll } = this.props
|
69
|
+
onExpandAll && onExpandAll()
|
70
|
+
}
|
71
|
+
|
72
|
+
renderTr(select, columns, actions) {
|
73
|
+
const { loading, list = [], enableEmptyTip, expandedRowRender } = this.props
|
74
|
+
|
75
|
+
if (loading) {
|
76
|
+
return (
|
77
|
+
<tr>
|
78
|
+
<td colSpan='99' className='text-center' style={{ padding: '10px' }}>
|
79
|
+
<Loading size={30} />
|
80
|
+
</td>
|
81
|
+
</tr>
|
82
|
+
)
|
83
|
+
}
|
84
|
+
|
85
|
+
if (enableEmptyTip && list.length === 0) {
|
86
|
+
return (
|
87
|
+
<tr>
|
88
|
+
<td colSpan='99' className='text-center'>
|
89
|
+
{enableEmptyTip === true ? getLocale('没有数据') : enableEmptyTip}
|
90
|
+
</td>
|
91
|
+
</tr>
|
92
|
+
)
|
93
|
+
}
|
94
|
+
|
95
|
+
const trs = []
|
96
|
+
|
97
|
+
_.each(list, (value, index) => {
|
98
|
+
trs.push(
|
99
|
+
<tr {...this.props.getTrProps(index)} key={index}>
|
100
|
+
{expandedRowRender && (
|
101
|
+
<td>
|
102
|
+
<i
|
103
|
+
className={classNames(
|
104
|
+
'gm-sheet-expanded-icon text-primary glyphicon',
|
105
|
+
{
|
106
|
+
'glyphicon-minus': value.__gm_expanded,
|
107
|
+
'glyphicon-plus': !value.__gm_expanded
|
108
|
+
}
|
109
|
+
)}
|
110
|
+
onClick={this.handleExpanded.bind(this, index)}
|
111
|
+
/>
|
112
|
+
</td>
|
113
|
+
)}
|
114
|
+
{select && (
|
115
|
+
<td>
|
116
|
+
<input
|
117
|
+
type={select.props.isRadio ? 'radio' : 'checkbox'}
|
118
|
+
name={this.checkboxOrRadioName}
|
119
|
+
className='gm-cursor'
|
120
|
+
checked={value._gm_select || false}
|
121
|
+
onChange={this.handleSelect.bind(this, select, index)}
|
122
|
+
disabled={select.props.isDisabled(value)}
|
123
|
+
/>
|
124
|
+
</td>
|
125
|
+
)}
|
126
|
+
{_.map(columns, (v, i) => {
|
127
|
+
const {
|
128
|
+
children,
|
129
|
+
field,
|
130
|
+
name, // eslint-disable-line
|
131
|
+
placeholder,
|
132
|
+
render,
|
133
|
+
...rest
|
134
|
+
} = v.props
|
135
|
+
if (typeof children === 'function') {
|
136
|
+
return (
|
137
|
+
<td key={i} {...rest}>
|
138
|
+
{children(value[field], index, value)}
|
139
|
+
</td>
|
140
|
+
)
|
141
|
+
} else if (typeof render === 'function') {
|
142
|
+
return (
|
143
|
+
<td key={i} {...rest}>
|
144
|
+
{render(value[field], index, value)}
|
145
|
+
</td>
|
146
|
+
)
|
147
|
+
} else {
|
148
|
+
const tdV = value[field]
|
149
|
+
if (
|
150
|
+
placeholder !== undefined &&
|
151
|
+
(tdV === undefined || tdV === null)
|
152
|
+
) {
|
153
|
+
return (
|
154
|
+
<td key={i} {...rest}>
|
155
|
+
{placeholder}
|
156
|
+
</td>
|
157
|
+
)
|
158
|
+
}
|
159
|
+
return (
|
160
|
+
<td key={i} {...rest}>
|
161
|
+
{tdV}
|
162
|
+
</td>
|
163
|
+
)
|
164
|
+
}
|
165
|
+
})}
|
166
|
+
{actions ? (
|
167
|
+
<td className='text-center'>
|
168
|
+
{actions.props.children(value, index)}
|
169
|
+
</td>
|
170
|
+
) : null}
|
171
|
+
</tr>
|
172
|
+
)
|
173
|
+
|
174
|
+
if (expandedRowRender && value.__gm_expanded) {
|
175
|
+
trs.push(
|
176
|
+
<tr className='gm-sheet-expanded-tr' key={index + '_expanded'}>
|
177
|
+
<td className='gm-sheet-expanded-td' colSpan='99'>
|
178
|
+
{expandedRowRender(index)}
|
179
|
+
</td>
|
180
|
+
</tr>
|
181
|
+
)
|
182
|
+
}
|
183
|
+
})
|
184
|
+
|
185
|
+
return trs
|
186
|
+
}
|
187
|
+
|
188
|
+
render() {
|
189
|
+
const { list = [], scrollX, expandedRowRender } = this.props
|
190
|
+
let select = false
|
191
|
+
let isSelectAll = false
|
192
|
+
let isHasContract = false
|
193
|
+
let pagination
|
194
|
+
let paginationText
|
195
|
+
|
196
|
+
const columns = []
|
197
|
+
let actions = false
|
198
|
+
let batchs = false
|
199
|
+
const others = []
|
200
|
+
|
201
|
+
_.each(React.Children.toArray(this.props.children), value => {
|
202
|
+
if (value !== null && value !== undefined) {
|
203
|
+
if (value.type.displayName === SheetColumn.displayName) {
|
204
|
+
columns.push(value)
|
205
|
+
} else if (value.type.displayName === SheetAction.displayName) {
|
206
|
+
actions = value
|
207
|
+
} else if (value.type.displayName === SheetSelect.displayName) {
|
208
|
+
select = value
|
209
|
+
} else if (value.type.displayName === SheetBatchAction.displayName) {
|
210
|
+
batchs = value
|
211
|
+
} else if (value.type.displayName === Pagination.displayName) {
|
212
|
+
pagination = value
|
213
|
+
} else if (value.type.displayName === PaginationText.displayName) {
|
214
|
+
paginationText = value
|
215
|
+
} else {
|
216
|
+
others.push(value)
|
217
|
+
}
|
218
|
+
}
|
219
|
+
})
|
220
|
+
|
221
|
+
if (select && list.length > 0) {
|
222
|
+
// 存在有效行,且不存在未选中的行
|
223
|
+
isSelectAll =
|
224
|
+
_.find(list, value => !select.props.isDisabled(value)) &&
|
225
|
+
!_.find(
|
226
|
+
list,
|
227
|
+
value => !select.props.isDisabled(value) && !value._gm_select
|
228
|
+
)
|
229
|
+
}
|
230
|
+
// 检查是否有某一列收起
|
231
|
+
if (expandedRowRender && list.length) {
|
232
|
+
isHasContract = !!_.find(list, l => !l.__gm_expanded)
|
233
|
+
}
|
234
|
+
|
235
|
+
return (
|
236
|
+
<div className={classNames('gm-sheet', this.props.className)}>
|
237
|
+
{select && batchs ? (
|
238
|
+
<div className='gm-margin-bottom-5 text-right'>
|
239
|
+
{batchs.props.children}
|
240
|
+
</div>
|
241
|
+
) : null}
|
242
|
+
|
243
|
+
{isSelectAll && select.props.hasSelectTip && (
|
244
|
+
<div className='gm-box-shadow-bottom gm-sheet-select-all-tip'>
|
245
|
+
<span className='gm-sheet-select-all-tip-arrow' />
|
246
|
+
{select.props.selectAllTip}
|
247
|
+
</div>
|
248
|
+
)}
|
249
|
+
|
250
|
+
<div
|
251
|
+
className={
|
252
|
+
'gm-sheet-table' + (scrollX ? ' gm-sheet-table-scroll-x' : '')
|
253
|
+
}
|
254
|
+
>
|
255
|
+
<table className='table table-striped table-hover table-bordered'>
|
256
|
+
<thead>
|
257
|
+
<tr>
|
258
|
+
{expandedRowRender && (
|
259
|
+
<th className='gm-sheet-th-expanded'>
|
260
|
+
<i
|
261
|
+
className={classNames(
|
262
|
+
'gm-sheet-expanded-icon text-primary glyphicon',
|
263
|
+
{
|
264
|
+
'glyphicon-minus': !isHasContract,
|
265
|
+
'glyphicon-plus': isHasContract
|
266
|
+
}
|
267
|
+
)}
|
268
|
+
onClick={this.handleExpandedAll}
|
269
|
+
/>
|
270
|
+
</th>
|
271
|
+
)}
|
272
|
+
{select && (
|
273
|
+
<th className='gm-sheet-select'>
|
274
|
+
{!select.props.isRadio && (
|
275
|
+
<div>
|
276
|
+
<input
|
277
|
+
type='checkbox'
|
278
|
+
checked={isSelectAll}
|
279
|
+
onChange={this.handleSelectAll.bind(this, select)}
|
280
|
+
/>
|
281
|
+
</div>
|
282
|
+
)}
|
283
|
+
</th>
|
284
|
+
)}
|
285
|
+
{_.map(columns, (value, index) => {
|
286
|
+
const {
|
287
|
+
children,
|
288
|
+
field,
|
289
|
+
name,
|
290
|
+
placeholder,
|
291
|
+
render, // eslint-disable-line
|
292
|
+
...rest
|
293
|
+
} = value.props
|
294
|
+
return (
|
295
|
+
<th key={index} {...rest}>
|
296
|
+
{value.props.name}
|
297
|
+
</th>
|
298
|
+
)
|
299
|
+
})}
|
300
|
+
{actions && <th className='text-center'>操作</th>}
|
301
|
+
</tr>
|
302
|
+
</thead>
|
303
|
+
<tbody>{this.renderTr(select, columns, actions)}</tbody>
|
304
|
+
</table>
|
305
|
+
</div>
|
306
|
+
{(pagination || paginationText) && (
|
307
|
+
<Flex justifyEnd alignCenter className='gm-padding-20'>
|
308
|
+
{paginationText && <div>{paginationText}</div>}
|
309
|
+
{pagination && <div>{pagination}</div>}
|
310
|
+
</Flex>
|
311
|
+
)}
|
312
|
+
{others}
|
313
|
+
</div>
|
314
|
+
)
|
315
|
+
}
|
316
|
+
}
|
317
|
+
|
318
|
+
Sheet.findTableDOM = function(ref) {
|
319
|
+
return ReactDOM.findDOMNode(ref).getElementsByTagName('table')[0]
|
320
|
+
}
|
321
|
+
|
322
|
+
Sheet.propTypes = {
|
323
|
+
list: PropTypes.array.isRequired,
|
324
|
+
loading: PropTypes.bool,
|
325
|
+
enableEmptyTip: PropTypes.oneOfType([
|
326
|
+
PropTypes.bool,
|
327
|
+
PropTypes.string,
|
328
|
+
PropTypes.element
|
329
|
+
]),
|
330
|
+
className: PropTypes.string,
|
331
|
+
getTrProps: PropTypes.func,
|
332
|
+
scrollX: PropTypes.bool,
|
333
|
+
expandedRowRender: PropTypes.func,
|
334
|
+
onExpand: PropTypes.func,
|
335
|
+
onExpandAll: PropTypes.func,
|
336
|
+
children: PropTypes.any
|
337
|
+
}
|
338
|
+
|
339
|
+
Sheet.defaultProps = {
|
340
|
+
list: [],
|
341
|
+
loading: false,
|
342
|
+
getTrProps: () => {
|
343
|
+
return {}
|
344
|
+
},
|
345
|
+
scrollX: false
|
346
|
+
}
|
347
|
+
|
348
|
+
export default Sheet
|