@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,208 +1,208 @@
|
|
1
|
-
import { getLocale } from '@gmfe/locales'
|
2
|
-
import React from 'react'
|
3
|
-
import PropTypes from 'prop-types'
|
4
|
-
import classNames from 'classnames'
|
5
|
-
|
6
|
-
class DropSelect extends React.Component {
|
7
|
-
constructor(props) {
|
8
|
-
super(props)
|
9
|
-
this.state = {
|
10
|
-
activeIndex: null
|
11
|
-
}
|
12
|
-
|
13
|
-
this.documentClickHandler = this.documentClickHandler.bind(this)
|
14
|
-
this.onEscapeKeyUp = this.onEscapeKeyUp.bind(this)
|
15
|
-
}
|
16
|
-
|
17
|
-
componentDidMount() {
|
18
|
-
window.document.addEventListener('click', this.documentClickHandler)
|
19
|
-
window.document.addEventListener('keydown', this.onEscapeKeyUp)
|
20
|
-
}
|
21
|
-
|
22
|
-
componentDidUpdate() {
|
23
|
-
const dom = this.refSelectPanel.querySelector('.gm-dropselect-list .active')
|
24
|
-
dom && dom.scrollIntoViewIfNeeded() // scrollIntoView
|
25
|
-
}
|
26
|
-
|
27
|
-
componentWillUnmount() {
|
28
|
-
window.document.removeEventListener('click', this.documentClickHandler)
|
29
|
-
window.document.removeEventListener('keydown', this.onEscapeKeyUp)
|
30
|
-
}
|
31
|
-
|
32
|
-
processData(data) {
|
33
|
-
return Object.assign(
|
34
|
-
{
|
35
|
-
loading: false,
|
36
|
-
actions: [],
|
37
|
-
list: [],
|
38
|
-
columns: []
|
39
|
-
},
|
40
|
-
data
|
41
|
-
)
|
42
|
-
}
|
43
|
-
|
44
|
-
documentClickHandler(e) {
|
45
|
-
if (!this.refSelectPanel.contains(e.target)) {
|
46
|
-
this.setState({
|
47
|
-
activeIndex: null
|
48
|
-
})
|
49
|
-
this.props.onHide()
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
handleKeyDown(size, e) {
|
54
|
-
// 列表为空
|
55
|
-
if (!size) {
|
56
|
-
return
|
57
|
-
}
|
58
|
-
|
59
|
-
let activeIndex = this.state.activeIndex
|
60
|
-
|
61
|
-
// 键盘 上键
|
62
|
-
if (e.keyCode === 38) {
|
63
|
-
if (activeIndex === null) {
|
64
|
-
activeIndex = size
|
65
|
-
}
|
66
|
-
|
67
|
-
activeIndex--
|
68
|
-
} else if (e.keyCode === 40) {
|
69
|
-
// 键盘 下键
|
70
|
-
if (activeIndex === null) {
|
71
|
-
activeIndex = -1
|
72
|
-
}
|
73
|
-
|
74
|
-
activeIndex++
|
75
|
-
} else if (e.keyCode === 13) {
|
76
|
-
// 键盘 回车
|
77
|
-
if (activeIndex === null) {
|
78
|
-
return
|
79
|
-
}
|
80
|
-
this.props.onEnter(activeIndex)
|
81
|
-
} else {
|
82
|
-
return
|
83
|
-
}
|
84
|
-
|
85
|
-
this.setState({
|
86
|
-
activeIndex: (size + activeIndex) % size
|
87
|
-
})
|
88
|
-
}
|
89
|
-
|
90
|
-
onEscapeKeyUp(e) {
|
91
|
-
if (e.keyCode === 27) {
|
92
|
-
this.props.onHide()
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
render() {
|
97
|
-
const thisProps = this.props
|
98
|
-
|
99
|
-
const show = thisProps.show
|
100
|
-
const { loading, list, columns, actions } = this.processData(
|
101
|
-
this.props.data
|
102
|
-
)
|
103
|
-
const { activeIndex } = this.state
|
104
|
-
let coolList
|
105
|
-
|
106
|
-
const coolTitle = columns.map(col => {
|
107
|
-
return (
|
108
|
-
<div className='gm-ellipsis' key={col.field}>
|
109
|
-
{col.name}
|
110
|
-
</div>
|
111
|
-
)
|
112
|
-
})
|
113
|
-
|
114
|
-
if (loading) {
|
115
|
-
coolList = (
|
116
|
-
<li className='gm-dropselect-item'>
|
117
|
-
<span> </span>
|
118
|
-
<i className='glyphicon glyphicon-refresh glyphicon-spin' />
|
119
|
-
</li>
|
120
|
-
)
|
121
|
-
} else {
|
122
|
-
coolList = list.map((rowData, rowIndex) => {
|
123
|
-
const cls = classNames('gm-dropselect-item', {
|
124
|
-
active: activeIndex === rowIndex
|
125
|
-
})
|
126
|
-
const row = columns.map((col, index) => {
|
127
|
-
const field = col.field
|
128
|
-
const value = rowData[field]
|
129
|
-
if (col.render) {
|
130
|
-
const val = col.render(value, rowData, rowIndex)
|
131
|
-
return (
|
132
|
-
<div className='gm-ellipsis' style={{ flex: '1' }} key={index}>
|
133
|
-
{val}
|
134
|
-
</div>
|
135
|
-
)
|
136
|
-
} else {
|
137
|
-
return (
|
138
|
-
<div className='gm-ellipsis' key={index}>
|
139
|
-
{value}
|
140
|
-
</div>
|
141
|
-
)
|
142
|
-
}
|
143
|
-
})
|
144
|
-
const actionDom = actions.map((action, index) => {
|
145
|
-
const disabled = action.getDisabled
|
146
|
-
? action.getDisabled(rowData, rowIndex)
|
147
|
-
: false
|
148
|
-
return (
|
149
|
-
<button
|
150
|
-
className={action.className}
|
151
|
-
onClick={action.onClick.bind(null, rowData)}
|
152
|
-
disabled={disabled}
|
153
|
-
key={index}
|
154
|
-
>
|
155
|
-
{action.text}
|
156
|
-
</button>
|
157
|
-
)
|
158
|
-
})
|
159
|
-
|
160
|
-
return (
|
161
|
-
<li className={cls} key={rowData.id}>
|
162
|
-
{row}
|
163
|
-
{actionDom.length ? <div>{actionDom}</div> : null}
|
164
|
-
</li>
|
165
|
-
)
|
166
|
-
})
|
167
|
-
}
|
168
|
-
|
169
|
-
return (
|
170
|
-
<div
|
171
|
-
className={classNames('gm-dropselect', thisProps.className)}
|
172
|
-
ref={ref => (this.refSelectPanel = ref)}
|
173
|
-
onKeyDown={this.handleKeyDown.bind(this, list.length)}
|
174
|
-
>
|
175
|
-
{thisProps.children}
|
176
|
-
<div className='gm-dropselect-wrap'>
|
177
|
-
<div
|
178
|
-
className='gm-dropselect-list-wrap gm-box-shadow-bottom'
|
179
|
-
style={{ display: show ? 'block' : 'none' }}
|
180
|
-
>
|
181
|
-
<ul className='gm-dropselect-list'>
|
182
|
-
<li className='gm-dropselect-item gm-dropselect-title'>
|
183
|
-
{coolTitle}
|
184
|
-
{!!actions.length && <div>{getLocale('操作')}</div>}
|
185
|
-
</li>
|
186
|
-
{coolList}
|
187
|
-
</ul>
|
188
|
-
</div>
|
189
|
-
</div>
|
190
|
-
</div>
|
191
|
-
)
|
192
|
-
}
|
193
|
-
}
|
194
|
-
|
195
|
-
DropSelect.propTypes = {
|
196
|
-
show: PropTypes.bool.isRequired,
|
197
|
-
data: PropTypes.object,
|
198
|
-
onEnter: PropTypes.func,
|
199
|
-
onHide: PropTypes.func
|
200
|
-
}
|
201
|
-
|
202
|
-
DropSelect.defaultProps = {
|
203
|
-
onEnter: index => {
|
204
|
-
console.log('onEnter index:', index)
|
205
|
-
}
|
206
|
-
}
|
207
|
-
|
208
|
-
export default DropSelect
|
1
|
+
import { getLocale } from '@gmfe/locales'
|
2
|
+
import React from 'react'
|
3
|
+
import PropTypes from 'prop-types'
|
4
|
+
import classNames from 'classnames'
|
5
|
+
|
6
|
+
class DropSelect extends React.Component {
|
7
|
+
constructor(props) {
|
8
|
+
super(props)
|
9
|
+
this.state = {
|
10
|
+
activeIndex: null
|
11
|
+
}
|
12
|
+
|
13
|
+
this.documentClickHandler = this.documentClickHandler.bind(this)
|
14
|
+
this.onEscapeKeyUp = this.onEscapeKeyUp.bind(this)
|
15
|
+
}
|
16
|
+
|
17
|
+
componentDidMount() {
|
18
|
+
window.document.addEventListener('click', this.documentClickHandler)
|
19
|
+
window.document.addEventListener('keydown', this.onEscapeKeyUp)
|
20
|
+
}
|
21
|
+
|
22
|
+
componentDidUpdate() {
|
23
|
+
const dom = this.refSelectPanel.querySelector('.gm-dropselect-list .active')
|
24
|
+
dom && dom.scrollIntoViewIfNeeded() // scrollIntoView
|
25
|
+
}
|
26
|
+
|
27
|
+
componentWillUnmount() {
|
28
|
+
window.document.removeEventListener('click', this.documentClickHandler)
|
29
|
+
window.document.removeEventListener('keydown', this.onEscapeKeyUp)
|
30
|
+
}
|
31
|
+
|
32
|
+
processData(data) {
|
33
|
+
return Object.assign(
|
34
|
+
{
|
35
|
+
loading: false,
|
36
|
+
actions: [],
|
37
|
+
list: [],
|
38
|
+
columns: []
|
39
|
+
},
|
40
|
+
data
|
41
|
+
)
|
42
|
+
}
|
43
|
+
|
44
|
+
documentClickHandler(e) {
|
45
|
+
if (!this.refSelectPanel.contains(e.target)) {
|
46
|
+
this.setState({
|
47
|
+
activeIndex: null
|
48
|
+
})
|
49
|
+
this.props.onHide()
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
handleKeyDown(size, e) {
|
54
|
+
// 列表为空
|
55
|
+
if (!size) {
|
56
|
+
return
|
57
|
+
}
|
58
|
+
|
59
|
+
let activeIndex = this.state.activeIndex
|
60
|
+
|
61
|
+
// 键盘 上键
|
62
|
+
if (e.keyCode === 38) {
|
63
|
+
if (activeIndex === null) {
|
64
|
+
activeIndex = size
|
65
|
+
}
|
66
|
+
|
67
|
+
activeIndex--
|
68
|
+
} else if (e.keyCode === 40) {
|
69
|
+
// 键盘 下键
|
70
|
+
if (activeIndex === null) {
|
71
|
+
activeIndex = -1
|
72
|
+
}
|
73
|
+
|
74
|
+
activeIndex++
|
75
|
+
} else if (e.keyCode === 13) {
|
76
|
+
// 键盘 回车
|
77
|
+
if (activeIndex === null) {
|
78
|
+
return
|
79
|
+
}
|
80
|
+
this.props.onEnter(activeIndex)
|
81
|
+
} else {
|
82
|
+
return
|
83
|
+
}
|
84
|
+
|
85
|
+
this.setState({
|
86
|
+
activeIndex: (size + activeIndex) % size
|
87
|
+
})
|
88
|
+
}
|
89
|
+
|
90
|
+
onEscapeKeyUp(e) {
|
91
|
+
if (e.keyCode === 27) {
|
92
|
+
this.props.onHide()
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
render() {
|
97
|
+
const thisProps = this.props
|
98
|
+
|
99
|
+
const show = thisProps.show
|
100
|
+
const { loading, list, columns, actions } = this.processData(
|
101
|
+
this.props.data
|
102
|
+
)
|
103
|
+
const { activeIndex } = this.state
|
104
|
+
let coolList
|
105
|
+
|
106
|
+
const coolTitle = columns.map(col => {
|
107
|
+
return (
|
108
|
+
<div className='gm-ellipsis' key={col.field}>
|
109
|
+
{col.name}
|
110
|
+
</div>
|
111
|
+
)
|
112
|
+
})
|
113
|
+
|
114
|
+
if (loading) {
|
115
|
+
coolList = (
|
116
|
+
<li className='gm-dropselect-item'>
|
117
|
+
<span> </span>
|
118
|
+
<i className='glyphicon glyphicon-refresh glyphicon-spin' />
|
119
|
+
</li>
|
120
|
+
)
|
121
|
+
} else {
|
122
|
+
coolList = list.map((rowData, rowIndex) => {
|
123
|
+
const cls = classNames('gm-dropselect-item', {
|
124
|
+
active: activeIndex === rowIndex
|
125
|
+
})
|
126
|
+
const row = columns.map((col, index) => {
|
127
|
+
const field = col.field
|
128
|
+
const value = rowData[field]
|
129
|
+
if (col.render) {
|
130
|
+
const val = col.render(value, rowData, rowIndex)
|
131
|
+
return (
|
132
|
+
<div className='gm-ellipsis' style={{ flex: '1' }} key={index}>
|
133
|
+
{val}
|
134
|
+
</div>
|
135
|
+
)
|
136
|
+
} else {
|
137
|
+
return (
|
138
|
+
<div className='gm-ellipsis' key={index}>
|
139
|
+
{value}
|
140
|
+
</div>
|
141
|
+
)
|
142
|
+
}
|
143
|
+
})
|
144
|
+
const actionDom = actions.map((action, index) => {
|
145
|
+
const disabled = action.getDisabled
|
146
|
+
? action.getDisabled(rowData, rowIndex)
|
147
|
+
: false
|
148
|
+
return (
|
149
|
+
<button
|
150
|
+
className={action.className}
|
151
|
+
onClick={action.onClick.bind(null, rowData)}
|
152
|
+
disabled={disabled}
|
153
|
+
key={index}
|
154
|
+
>
|
155
|
+
{action.text}
|
156
|
+
</button>
|
157
|
+
)
|
158
|
+
})
|
159
|
+
|
160
|
+
return (
|
161
|
+
<li className={cls} key={rowData.id}>
|
162
|
+
{row}
|
163
|
+
{actionDom.length ? <div>{actionDom}</div> : null}
|
164
|
+
</li>
|
165
|
+
)
|
166
|
+
})
|
167
|
+
}
|
168
|
+
|
169
|
+
return (
|
170
|
+
<div
|
171
|
+
className={classNames('gm-dropselect', thisProps.className)}
|
172
|
+
ref={ref => (this.refSelectPanel = ref)}
|
173
|
+
onKeyDown={this.handleKeyDown.bind(this, list.length)}
|
174
|
+
>
|
175
|
+
{thisProps.children}
|
176
|
+
<div className='gm-dropselect-wrap'>
|
177
|
+
<div
|
178
|
+
className='gm-dropselect-list-wrap gm-box-shadow-bottom'
|
179
|
+
style={{ display: show ? 'block' : 'none' }}
|
180
|
+
>
|
181
|
+
<ul className='gm-dropselect-list'>
|
182
|
+
<li className='gm-dropselect-item gm-dropselect-title'>
|
183
|
+
{coolTitle}
|
184
|
+
{!!actions.length && <div>{getLocale('操作')}</div>}
|
185
|
+
</li>
|
186
|
+
{coolList}
|
187
|
+
</ul>
|
188
|
+
</div>
|
189
|
+
</div>
|
190
|
+
</div>
|
191
|
+
)
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
DropSelect.propTypes = {
|
196
|
+
show: PropTypes.bool.isRequired,
|
197
|
+
data: PropTypes.object,
|
198
|
+
onEnter: PropTypes.func,
|
199
|
+
onHide: PropTypes.func
|
200
|
+
}
|
201
|
+
|
202
|
+
DropSelect.defaultProps = {
|
203
|
+
onEnter: index => {
|
204
|
+
console.log('onEnter index:', index)
|
205
|
+
}
|
206
|
+
}
|
207
|
+
|
208
|
+
export default DropSelect
|
@@ -1,69 +1,69 @@
|
|
1
|
-
.gm-dropselect {
|
2
|
-
vertical-align: middle;
|
3
|
-
}
|
4
|
-
|
5
|
-
.gm-dropselect-wrap {
|
6
|
-
height: 0;
|
7
|
-
overflow: visible;
|
8
|
-
position: relative;
|
9
|
-
z-index: 10000;
|
10
|
-
}
|
11
|
-
|
12
|
-
.gm-dropselect-wrap .gm-dropselect-list-wrap {
|
13
|
-
border-radius: 0 0 4px 4px;
|
14
|
-
overflow: hidden;
|
15
|
-
background-color: #fff;
|
16
|
-
border-top: none;
|
17
|
-
position: absolute;
|
18
|
-
width: 100%;
|
19
|
-
cursor: default;
|
20
|
-
max-height: 230px;
|
21
|
-
overflow-y: auto;
|
22
|
-
}
|
23
|
-
|
24
|
-
.gm-dropselect-list-wrap .gm-dropselect-list li {
|
25
|
-
overflow: hidden;
|
26
|
-
display: flex;
|
27
|
-
justify-content: center;
|
28
|
-
align-items: center;
|
29
|
-
border-bottom: 1px solid @list-group-border;
|
30
|
-
}
|
31
|
-
|
32
|
-
.gm-dropselect-list li:not(.gm-dropselect-title):hover {
|
33
|
-
background-color: @list-group-hover-bg;
|
34
|
-
}
|
35
|
-
|
36
|
-
.gm-dropselect-list-wrap .gm-dropselect-list {
|
37
|
-
margin-bottom: 0;
|
38
|
-
list-style: none;
|
39
|
-
padding: 0;
|
40
|
-
}
|
41
|
-
|
42
|
-
.gm-dropselect-list-wrap .gm-dropselect-item {
|
43
|
-
line-height: 32px;
|
44
|
-
font-size: 12px;
|
45
|
-
height: 45px;
|
46
|
-
|
47
|
-
&.active {
|
48
|
-
background-color: @list-group-hover-bg;
|
49
|
-
}
|
50
|
-
}
|
51
|
-
|
52
|
-
.gm-dropselect-list-wrap .gm-dropselect-list .gm-dropselect-title {
|
53
|
-
overflow: hidden;
|
54
|
-
background-color: @gray-lighter;
|
55
|
-
}
|
56
|
-
|
57
|
-
.gm-dropselect-list-wrap .gm-dropselect-list li div {
|
58
|
-
flex: 1;
|
59
|
-
text-align: center;
|
60
|
-
display: flex;
|
61
|
-
justify-content: center;
|
62
|
-
}
|
63
|
-
|
64
|
-
.gm-ellipsis {
|
65
|
-
display: block !important;
|
66
|
-
white-space: nowrap;
|
67
|
-
text-overflow: ellipsis;
|
68
|
-
overflow: hidden;
|
69
|
-
}
|
1
|
+
.gm-dropselect {
|
2
|
+
vertical-align: middle;
|
3
|
+
}
|
4
|
+
|
5
|
+
.gm-dropselect-wrap {
|
6
|
+
height: 0;
|
7
|
+
overflow: visible;
|
8
|
+
position: relative;
|
9
|
+
z-index: 10000;
|
10
|
+
}
|
11
|
+
|
12
|
+
.gm-dropselect-wrap .gm-dropselect-list-wrap {
|
13
|
+
border-radius: 0 0 4px 4px;
|
14
|
+
overflow: hidden;
|
15
|
+
background-color: #fff;
|
16
|
+
border-top: none;
|
17
|
+
position: absolute;
|
18
|
+
width: 100%;
|
19
|
+
cursor: default;
|
20
|
+
max-height: 230px;
|
21
|
+
overflow-y: auto;
|
22
|
+
}
|
23
|
+
|
24
|
+
.gm-dropselect-list-wrap .gm-dropselect-list li {
|
25
|
+
overflow: hidden;
|
26
|
+
display: flex;
|
27
|
+
justify-content: center;
|
28
|
+
align-items: center;
|
29
|
+
border-bottom: 1px solid @list-group-border;
|
30
|
+
}
|
31
|
+
|
32
|
+
.gm-dropselect-list li:not(.gm-dropselect-title):hover {
|
33
|
+
background-color: @list-group-hover-bg;
|
34
|
+
}
|
35
|
+
|
36
|
+
.gm-dropselect-list-wrap .gm-dropselect-list {
|
37
|
+
margin-bottom: 0;
|
38
|
+
list-style: none;
|
39
|
+
padding: 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
.gm-dropselect-list-wrap .gm-dropselect-item {
|
43
|
+
line-height: 32px;
|
44
|
+
font-size: 12px;
|
45
|
+
height: 45px;
|
46
|
+
|
47
|
+
&.active {
|
48
|
+
background-color: @list-group-hover-bg;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
.gm-dropselect-list-wrap .gm-dropselect-list .gm-dropselect-title {
|
53
|
+
overflow: hidden;
|
54
|
+
background-color: @gray-lighter;
|
55
|
+
}
|
56
|
+
|
57
|
+
.gm-dropselect-list-wrap .gm-dropselect-list li div {
|
58
|
+
flex: 1;
|
59
|
+
text-align: center;
|
60
|
+
display: flex;
|
61
|
+
justify-content: center;
|
62
|
+
}
|
63
|
+
|
64
|
+
.gm-ellipsis {
|
65
|
+
display: block !important;
|
66
|
+
white-space: nowrap;
|
67
|
+
text-overflow: ellipsis;
|
68
|
+
overflow: hidden;
|
69
|
+
}
|
@@ -1,62 +1,62 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import PropTypes from 'prop-types'
|
3
|
-
import { is } from '@gm-common/tool'
|
4
|
-
|
5
|
-
class Dropper extends React.Component {
|
6
|
-
handleDrop = e => {
|
7
|
-
e.preventDefault()
|
8
|
-
|
9
|
-
const { multiple, onDrop } = this.props
|
10
|
-
|
11
|
-
const droppedFiles = e.dataTransfer ? e.dataTransfer.files : e.target.files
|
12
|
-
const max = multiple ? droppedFiles.length : 1
|
13
|
-
const files = []
|
14
|
-
|
15
|
-
for (let i = 0; i < max; i++) {
|
16
|
-
const file = droppedFiles[i]
|
17
|
-
file.preview = window.URL.createObjectURL(file)
|
18
|
-
files.push(file)
|
19
|
-
}
|
20
|
-
onDrop(files, e)
|
21
|
-
}
|
22
|
-
|
23
|
-
handleClick = () => {
|
24
|
-
this.refInput.value = null
|
25
|
-
this.refInput.click()
|
26
|
-
}
|
27
|
-
|
28
|
-
render() {
|
29
|
-
const { className, children, accept, multiple } = this.props
|
30
|
-
const cn = className || 'gm-dropper-default'
|
31
|
-
|
32
|
-
return (
|
33
|
-
<div className='gm-dropper'>
|
34
|
-
<div className={cn} onClick={this.handleClick} onDrop={this.handleDrop}>
|
35
|
-
{children}
|
36
|
-
</div>
|
37
|
-
<input
|
38
|
-
type='file'
|
39
|
-
ref={ref => (this.refInput = ref)}
|
40
|
-
className='gm-dropper-input'
|
41
|
-
multiple={!is.weixin() && multiple}
|
42
|
-
accept={accept}
|
43
|
-
onChange={this.handleDrop}
|
44
|
-
/>
|
45
|
-
</div>
|
46
|
-
)
|
47
|
-
}
|
48
|
-
}
|
49
|
-
|
50
|
-
Dropper.defaultProps = {
|
51
|
-
multiple: false
|
52
|
-
}
|
53
|
-
|
54
|
-
Dropper.propTypes = {
|
55
|
-
multiple: PropTypes.bool,
|
56
|
-
onDrop: PropTypes.func.isRequired,
|
57
|
-
accept: PropTypes.string,
|
58
|
-
children: PropTypes.any,
|
59
|
-
className: PropTypes.string
|
60
|
-
}
|
61
|
-
// TODO 重构
|
62
|
-
export default Dropper
|
1
|
+
import React from 'react'
|
2
|
+
import PropTypes from 'prop-types'
|
3
|
+
import { is } from '@gm-common/tool'
|
4
|
+
|
5
|
+
class Dropper extends React.Component {
|
6
|
+
handleDrop = e => {
|
7
|
+
e.preventDefault()
|
8
|
+
|
9
|
+
const { multiple, onDrop } = this.props
|
10
|
+
|
11
|
+
const droppedFiles = e.dataTransfer ? e.dataTransfer.files : e.target.files
|
12
|
+
const max = multiple ? droppedFiles.length : 1
|
13
|
+
const files = []
|
14
|
+
|
15
|
+
for (let i = 0; i < max; i++) {
|
16
|
+
const file = droppedFiles[i]
|
17
|
+
file.preview = window.URL.createObjectURL(file)
|
18
|
+
files.push(file)
|
19
|
+
}
|
20
|
+
onDrop(files, e)
|
21
|
+
}
|
22
|
+
|
23
|
+
handleClick = () => {
|
24
|
+
this.refInput.value = null
|
25
|
+
this.refInput.click()
|
26
|
+
}
|
27
|
+
|
28
|
+
render() {
|
29
|
+
const { className, children, accept, multiple } = this.props
|
30
|
+
const cn = className || 'gm-dropper-default'
|
31
|
+
|
32
|
+
return (
|
33
|
+
<div className='gm-dropper'>
|
34
|
+
<div className={cn} onClick={this.handleClick} onDrop={this.handleDrop}>
|
35
|
+
{children}
|
36
|
+
</div>
|
37
|
+
<input
|
38
|
+
type='file'
|
39
|
+
ref={ref => (this.refInput = ref)}
|
40
|
+
className='gm-dropper-input'
|
41
|
+
multiple={!is.weixin() && multiple}
|
42
|
+
accept={accept}
|
43
|
+
onChange={this.handleDrop}
|
44
|
+
/>
|
45
|
+
</div>
|
46
|
+
)
|
47
|
+
}
|
48
|
+
}
|
49
|
+
|
50
|
+
Dropper.defaultProps = {
|
51
|
+
multiple: false
|
52
|
+
}
|
53
|
+
|
54
|
+
Dropper.propTypes = {
|
55
|
+
multiple: PropTypes.bool,
|
56
|
+
onDrop: PropTypes.func.isRequired,
|
57
|
+
accept: PropTypes.string,
|
58
|
+
children: PropTypes.any,
|
59
|
+
className: PropTypes.string
|
60
|
+
}
|
61
|
+
// TODO 重构
|
62
|
+
export default Dropper
|