@mpxjs/webpack-plugin 2.10.3-beta.4 → 2.10.3-beta.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.
@@ -82,7 +82,7 @@ const Input = forwardRef((props, ref) => {
82
82
  const lineCount = useRef(0);
83
83
  const [inputValue, setInputValue] = useState(defaultValue);
84
84
  const [contentHeight, setContentHeight] = useState(0);
85
- const [selection, setSelection] = useState({ start: -1, end: -1 });
85
+ const [selection, setSelection] = useState({ start: -1, end: tmpValue.current.length });
86
86
  const styleObj = extendObject({ padding: 0, backgroundColor: '#fff' }, style, multiline && autoHeight
87
87
  ? { height: 'auto', minHeight: Math.max(style?.minHeight || 35, contentHeight) }
88
88
  : {});
@@ -94,15 +94,17 @@ const Input = forwardRef((props, ref) => {
94
94
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef });
95
95
  useEffect(() => {
96
96
  if (inputValue !== value) {
97
- setInputValue(parseValue(value));
97
+ const parsed = parseValue(value);
98
+ tmpValue.current = parsed;
99
+ setInputValue(parsed);
98
100
  }
99
101
  }, [value]);
100
102
  useEffect(() => {
101
- if (typeof cursor === 'number') {
102
- setSelection({ start: cursor, end: cursor });
103
+ if (selectionStart > -1) {
104
+ setSelection({ start: selectionStart, end: selectionEnd === -1 ? tmpValue.current.length : selectionEnd });
103
105
  }
104
- else if (selectionStart >= 0 && selectionEnd >= 0 && selectionStart !== selectionEnd) {
105
- setSelection({ start: selectionStart, end: selectionEnd });
106
+ else if (typeof cursor === 'number') {
107
+ setSelection({ start: cursor, end: cursor });
106
108
  }
107
109
  }, [cursor, selectionStart, selectionEnd]);
108
110
  // have not selection on the Android platformg
@@ -211,6 +213,7 @@ const Input = forwardRef((props, ref) => {
211
213
  }
212
214
  };
213
215
  const resetValue = () => {
216
+ tmpValue.current = '';
214
217
  setInputValue('');
215
218
  };
216
219
  const getValue = () => {
@@ -255,7 +258,7 @@ const Input = forwardRef((props, ref) => {
255
258
  maxLength: maxlength === -1 ? undefined : maxlength,
256
259
  editable: !disabled,
257
260
  autoFocus: !!autoFocus || !!focus,
258
- selection: selection,
261
+ selection: selectionStart > -1 || typeof cursor === 'number' ? selection : undefined,
259
262
  selectionColor: cursorColor,
260
263
  blurOnSubmit: !multiline && !confirmHold,
261
264
  underlineColorAndroid: 'rgba(0,0,0,0)',
@@ -195,7 +195,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
195
195
 
196
196
  const [inputValue, setInputValue] = useState(defaultValue)
197
197
  const [contentHeight, setContentHeight] = useState(0)
198
- const [selection, setSelection] = useState({ start: -1, end: -1 })
198
+ const [selection, setSelection] = useState({ start: -1, end: tmpValue.current.length })
199
199
 
200
200
  const styleObj = extendObject(
201
201
  { padding: 0, backgroundColor: '#fff' },
@@ -221,15 +221,17 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
221
221
 
222
222
  useEffect(() => {
223
223
  if (inputValue !== value) {
224
- setInputValue(parseValue(value))
224
+ const parsed = parseValue(value)
225
+ tmpValue.current = parsed
226
+ setInputValue(parsed)
225
227
  }
226
228
  }, [value])
227
229
 
228
230
  useEffect(() => {
229
- if (typeof cursor === 'number') {
231
+ if (selectionStart > -1) {
232
+ setSelection({ start: selectionStart, end: selectionEnd === -1 ? tmpValue.current.length : selectionEnd })
233
+ } else if (typeof cursor === 'number') {
230
234
  setSelection({ start: cursor, end: cursor })
231
- } else if (selectionStart >= 0 && selectionEnd >= 0 && selectionStart !== selectionEnd) {
232
- setSelection({ start: selectionStart, end: selectionEnd })
233
235
  }
234
236
  }, [cursor, selectionStart, selectionEnd])
235
237
 
@@ -388,6 +390,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
388
390
  }
389
391
 
390
392
  const resetValue = () => {
393
+ tmpValue.current = ''
391
394
  setInputValue('')
392
395
  }
393
396
 
@@ -440,7 +443,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
440
443
  maxLength: maxlength === -1 ? undefined : maxlength,
441
444
  editable: !disabled,
442
445
  autoFocus: !!autoFocus || !!focus,
443
- selection: selection,
446
+ selection: selectionStart > -1 || typeof cursor === 'number' ? selection : undefined,
444
447
  selectionColor: cursorColor,
445
448
  blurOnSubmit: !multiline && !confirmHold,
446
449
  underlineColorAndroid: 'rgba(0,0,0,0)',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.3-beta.4",
3
+ "version": "2.10.3-beta.5",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"