@gmfe/react 2.14.2-beta.3 → 2.14.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmfe/react",
3
- "version": "2.14.2-beta.3",
3
+ "version": "2.14.5",
4
4
  "description": "",
5
5
  "author": "liyatang <liyatang@qq.com>",
6
6
  "homepage": "https://github.com/gmfe/gmfe#readme",
@@ -27,7 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@gm-common/tool": "^1.0.0",
30
- "@gmfe/locales": "^2.14.2-beta.3",
30
+ "@gmfe/locales": "^2.14.5",
31
31
  "big.js": "^5.2.2",
32
32
  "classnames": "^2.2.5",
33
33
  "lodash": "^4.17.14",
@@ -35,5 +35,5 @@
35
35
  "prop-types": "^15.7.2",
36
36
  "react-window": "^1.8.5"
37
37
  },
38
- "gitHead": "fbd88a020d964c841d71b29238ebdb318bd6cf54"
38
+ "gitHead": "8435d9b0efcbb9886bcaac338d533496a94cb081"
39
39
  }
@@ -220,10 +220,10 @@ class Cascader extends React.Component {
220
220
  const value = []
221
221
  if (selected.length > 0) {
222
222
  _.each(selected, (v, i) => {
223
- const match = _.find(i === 0 ? data : value[i - 1]?.children, val => {
223
+ const match = _.find(i === 0 ? data : value[i - 1].children, val => {
224
224
  return v === val.value
225
225
  })
226
- match && value.push(match)
226
+ value.push(match)
227
227
  })
228
228
  }
229
229
 
@@ -316,23 +316,23 @@ class Cascader extends React.Component {
316
316
  const value = []
317
317
  if (selected.length > 0) {
318
318
  _.each(selected, (v, i) => {
319
- const match = _.find(i === 0 ? data : value[i - 1]?.children, val => {
319
+ const match = _.find(i === 0 ? data : value[i - 1].children, val => {
320
320
  return v === val.value
321
321
  })
322
- match && value.push(match)
322
+ value.push(match)
323
323
  })
324
324
  }
325
325
 
326
326
  if (!filtrable) {
327
327
  return valueRender
328
328
  ? valueRender(value)
329
- : _.map(value, v => v?.name).join(',')
329
+ : _.map(value, v => v.name).join(',')
330
330
  }
331
331
 
332
332
  return filterInput === null
333
333
  ? valueRender
334
334
  ? valueRender(value)
335
- : _.map(value, v => v?.name).join(',')
335
+ : _.map(value, v => v.name).join(',')
336
336
  : filterInput
337
337
  }
338
338
 
@@ -346,10 +346,10 @@ class Cascader extends React.Component {
346
346
  const value = []
347
347
  if (selected.length > 0) {
348
348
  _.each(selected, (v, i) => {
349
- const match = _.find(i === 0 ? data : value[i - 1]?.children, val => {
349
+ const match = _.find(i === 0 ? data : value[i - 1].children, val => {
350
350
  return v === val.value
351
351
  })
352
- match && value.push(match)
352
+ value.push(match)
353
353
  })
354
354
  }
355
355
 
@@ -33,8 +33,8 @@ class Base extends React.Component {
33
33
  // keyboard 默认第一个位置
34
34
  willActiveIndex: props.isKeyboard ? 0 : null,
35
35
  _style: {}
36
+ // isOnComposition: false
36
37
  }
37
-
38
38
  // 要后于 this.state 执行,因为 getFilterData 用到 searchValue
39
39
 
40
40
  // 有选择才有意义
@@ -49,6 +49,12 @@ class Base extends React.Component {
49
49
  }
50
50
  }
51
51
 
52
+ isOnComposition = false
53
+
54
+ setInputValue = () => {
55
+ this.ref.current.value = this.state.searchValue || ''
56
+ }
57
+
52
58
  apiDoFocus = () => {
53
59
  // 唤起 popover,input autoFocus 会自动聚焦,但是这种方式本质是显示 UI
54
60
  // this.popoverRef.current.apiDoSetActive(true)
@@ -77,6 +83,11 @@ class Base extends React.Component {
77
83
  const dom = findDOMNode(this)
78
84
  const _style = { width: dom.offsetWidth }
79
85
  this.setState({ _style })
86
+ this.setInputValue()
87
+ }
88
+
89
+ componentDidUpdate() {
90
+ this.setInputValue()
80
91
  }
81
92
 
82
93
  componentWillUnmount() {
@@ -102,10 +113,21 @@ class Base extends React.Component {
102
113
  this.setState({
103
114
  searchValue
104
115
  })
105
-
116
+ if (this.isOnComposition && this.props.isEnableChineseCheck) return
106
117
  this.debounceDoSearch(searchValue)
107
118
  }
108
119
 
120
+ handleComposition = evt => {
121
+ if (evt.type === 'compositionend') {
122
+ this.isOnComposition = false
123
+ if (navigator.userAgent.indexOf('Chrome') > -1) {
124
+ this.handleChange(evt)
125
+ }
126
+ return
127
+ }
128
+ this.isOnComposition = true
129
+ }
130
+
109
131
  handleSelected = values => {
110
132
  const { onSelect, data, multiple, selected } = this.props
111
133
  const items = []
@@ -241,7 +263,8 @@ class Base extends React.Component {
241
263
  renderListItem,
242
264
  searchPlaceholder,
243
265
  listHeight,
244
- popupClassName
266
+ popupClassName,
267
+ isEnableChineseCheck
245
268
  } = this.props
246
269
 
247
270
  const { loading, searchValue, willActiveIndex } = this.state
@@ -254,14 +277,28 @@ class Base extends React.Component {
254
277
  onKeyDown={this.handlePopupKeyDown}
255
278
  >
256
279
  <div className='gm-more-select-popup-input'>
257
- <input
258
- autoFocus
259
- className='form-control'
260
- type='text'
261
- value={searchValue}
262
- onChange={this.handleChange}
263
- placeholder={searchPlaceholder}
264
- />
280
+ {isEnableChineseCheck ? (
281
+ <input
282
+ autoFocus
283
+ className='form-control'
284
+ type='text'
285
+ // value={searchValue}
286
+ onChange={this.handleChange}
287
+ placeholder={searchPlaceholder}
288
+ onCompositionStart={this.handleComposition}
289
+ onCompositionUpdate={this.handleComposition}
290
+ onCompositionEnd={this.handleComposition}
291
+ />
292
+ ) : (
293
+ <input
294
+ autoFocus
295
+ className='form-control'
296
+ type='text'
297
+ value={searchValue}
298
+ onChange={this.handleChange}
299
+ placeholder={searchPlaceholder}
300
+ />
301
+ )}
265
302
  </div>
266
303
  <div style={{ height: listHeight }}>
267
304
  {loading && (
@@ -433,6 +470,7 @@ Base.propTypes = {
433
470
  selected: PropTypes.array.isRequired, // item 数组。 非 value,也非引用,原因是想解耦 selected 和 data 的关系。这样当
434
471
  onSelect: PropTypes.func.isRequired, // 返回 item 数组
435
472
  multiple: PropTypes.bool,
473
+ isEnableChineseCheck: PropTypes.bool, // 是否开启中文检查
436
474
 
437
475
  // 状态
438
476
  disabled: PropTypes.bool,