@mpxjs/webpack-plugin 2.10.4-beta.19 → 2.10.4-beta.19-input
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/lib/runtime/components/react/dist/getInnerListeners.js +36 -22
- package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +145 -0
- package/lib/runtime/components/react/dist/mpx-button.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-canvas/Image.js +2 -4
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +20 -17
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-image.jsx +33 -20
- package/lib/runtime/components/react/dist/mpx-input.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-label.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +8 -3
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +205 -79
- package/lib/runtime/components/react/dist/mpx-picker/index.jsx +11 -13
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +8 -7
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +29 -11
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.jsx +3 -5
- package/lib/runtime/components/react/dist/mpx-progress.jsx +163 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +9 -2
- package/lib/runtime/components/react/dist/mpx-radio.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +104 -51
- package/lib/runtime/components/react/dist/mpx-slider.jsx +321 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +3 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +11 -9
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +203 -141
- package/lib/runtime/components/react/dist/mpx-switch.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-text.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-video.jsx +7 -2
- package/lib/runtime/components/react/dist/mpx-view.jsx +28 -26
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +34 -29
- package/lib/runtime/components/react/dist/useAnimationHooks.js +12 -89
- package/lib/runtime/components/react/dist/utils.jsx +199 -114
- package/lib/runtime/components/react/mpx-input.tsx +6 -6
- package/package.json +1 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { useEffect, useCallback, useMemo, useRef, isValidElement, useContext, useState, Children, cloneElement } from 'react';
|
|
1
|
+
import { useEffect, useCallback, useMemo, useRef, isValidElement, useContext, useState, Children, cloneElement, createElement } from 'react';
|
|
2
2
|
import { Image } from 'react-native';
|
|
3
3
|
import { isObject, isFunction, isNumber, hasOwn, diffAndCloneA, error, warn } from '@mpxjs/utils';
|
|
4
4
|
import { VarContext, ScrollViewContext, RouteContext } from './context';
|
|
5
5
|
import { ExpressionParser, parseFunc, ReplaceSource } from './parser';
|
|
6
6
|
import { initialWindowMetrics } from 'react-native-safe-area-context';
|
|
7
7
|
import FastImage from '@d11/react-native-fast-image';
|
|
8
|
-
import { runOnJS } from 'react-native-reanimated';
|
|
9
8
|
import { Gesture } from 'react-native-gesture-handler';
|
|
10
9
|
export const TEXT_STYLE_REGEX = /color|font.*|text.*|letterSpacing|lineHeight|includeFontPadding|writingDirection/;
|
|
11
10
|
export const PERCENT_REGEX = /^\s*-?\d+(\.\d+)?%\s*$/;
|
|
@@ -26,6 +25,7 @@ const unoVarDecRegExp = /^--un-/;
|
|
|
26
25
|
const unoVarUseRegExp = /var\(--un-/;
|
|
27
26
|
const calcUseRegExp = /calc\(/;
|
|
28
27
|
const envUseRegExp = /env\(/;
|
|
28
|
+
const filterRegExp = /(calc|env|%)/;
|
|
29
29
|
const safeAreaInsetMap = {
|
|
30
30
|
'safe-area-inset-top': 'top',
|
|
31
31
|
'safe-area-inset-right': 'right',
|
|
@@ -121,6 +121,8 @@ const selfPercentRule = {
|
|
|
121
121
|
};
|
|
122
122
|
const parentHeightPercentRule = {
|
|
123
123
|
height: true,
|
|
124
|
+
minHeight: true,
|
|
125
|
+
maxHeight: true,
|
|
124
126
|
top: true,
|
|
125
127
|
bottom: true
|
|
126
128
|
};
|
|
@@ -181,10 +183,11 @@ function resolveVar(input, varContext) {
|
|
|
181
183
|
});
|
|
182
184
|
return global.__formatValue(replaced.source());
|
|
183
185
|
}
|
|
184
|
-
function transformVar(styleObj, varKeyPaths, varContext) {
|
|
186
|
+
function transformVar(styleObj, varKeyPaths, varContext, visitOther) {
|
|
185
187
|
varKeyPaths.forEach((varKeyPath) => {
|
|
186
188
|
setStyle(styleObj, varKeyPath, ({ target, key, value }) => {
|
|
187
189
|
target[key] = resolveVar(value, varContext);
|
|
190
|
+
visitOther({ target, key, value: target[key], keyPath: varKeyPath });
|
|
188
191
|
});
|
|
189
192
|
});
|
|
190
193
|
}
|
|
@@ -224,28 +227,122 @@ function transformCalc(styleObj, calcKeyPaths, formatter) {
|
|
|
224
227
|
});
|
|
225
228
|
});
|
|
226
229
|
}
|
|
227
|
-
const stringifyProps = ['fontWeight'];
|
|
228
230
|
function transformStringify(styleObj) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
if (isNumber(styleObj.fontWeight)) {
|
|
232
|
+
styleObj.fontWeight = '' + styleObj.fontWeight;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function transformPosition(styleObj, meta) {
|
|
236
|
+
if (styleObj.position === 'fixed') {
|
|
237
|
+
styleObj.position = 'absolute';
|
|
238
|
+
meta.hasPositionFixed = true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// 多value解析
|
|
242
|
+
function parseValues(str, char = ' ') {
|
|
243
|
+
let stack = 0;
|
|
244
|
+
let temp = '';
|
|
245
|
+
const result = [];
|
|
246
|
+
for (let i = 0; i < str.length; i++) {
|
|
247
|
+
if (str[i] === '(') {
|
|
248
|
+
stack++;
|
|
249
|
+
}
|
|
250
|
+
else if (str[i] === ')') {
|
|
251
|
+
stack--;
|
|
252
|
+
}
|
|
253
|
+
// 非括号内 或者 非分隔字符且非空
|
|
254
|
+
if (stack !== 0 || (str[i] !== char && str[i] !== ' ')) {
|
|
255
|
+
temp += str[i];
|
|
256
|
+
}
|
|
257
|
+
if ((stack === 0 && str[i] === char) || i === str.length - 1) {
|
|
258
|
+
result.push(temp);
|
|
259
|
+
temp = '';
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
// parse string transform, eg: transform: 'rotateX(45deg) rotateZ(0.785398rad)'
|
|
265
|
+
function parseTransform(transformStr) {
|
|
266
|
+
const values = parseValues(transformStr);
|
|
267
|
+
const transform = [];
|
|
268
|
+
values.forEach(item => {
|
|
269
|
+
const match = item.match(/([/\w]+)\((.+)\)/);
|
|
270
|
+
if (match && match.length >= 3) {
|
|
271
|
+
let key = match[1];
|
|
272
|
+
const val = match[2];
|
|
273
|
+
switch (key) {
|
|
274
|
+
case 'translateX':
|
|
275
|
+
case 'translateY':
|
|
276
|
+
case 'scaleX':
|
|
277
|
+
case 'scaleY':
|
|
278
|
+
case 'rotateX':
|
|
279
|
+
case 'rotateY':
|
|
280
|
+
case 'rotateZ':
|
|
281
|
+
case 'rotate':
|
|
282
|
+
case 'skewX':
|
|
283
|
+
case 'skewY':
|
|
284
|
+
case 'perspective':
|
|
285
|
+
// rotate 处理成 rotateZ
|
|
286
|
+
key = key === 'rotate' ? 'rotateZ' : key;
|
|
287
|
+
// 单个值处理
|
|
288
|
+
transform.push({ [key]: global.__formatValue(val) });
|
|
289
|
+
break;
|
|
290
|
+
case 'matrix':
|
|
291
|
+
transform.push({ [key]: parseValues(val, ',').map(val => +val) });
|
|
292
|
+
break;
|
|
293
|
+
case 'translate':
|
|
294
|
+
case 'scale':
|
|
295
|
+
case 'skew':
|
|
296
|
+
case 'translate3d': // x y 支持 z不支持
|
|
297
|
+
case 'scale3d': // x y 支持 z不支持
|
|
298
|
+
{
|
|
299
|
+
// 2 个以上的值处理
|
|
300
|
+
key = key.replace('3d', '');
|
|
301
|
+
const vals = parseValues(val, ',').splice(0, 3);
|
|
302
|
+
// scale(.5) === scaleX(.5) scaleY(.5)
|
|
303
|
+
if (vals.length === 1 && key === 'scale') {
|
|
304
|
+
vals.push(vals[0]);
|
|
305
|
+
}
|
|
306
|
+
const xyz = ['X', 'Y', 'Z'];
|
|
307
|
+
transform.push(...vals.map((v, index) => {
|
|
308
|
+
return { [`${key}${xyz[index] || ''}`]: global.__formatValue(v.trim()) };
|
|
309
|
+
}));
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
232
313
|
}
|
|
233
314
|
});
|
|
315
|
+
return transform;
|
|
316
|
+
}
|
|
317
|
+
// format style transform
|
|
318
|
+
function transformTransform(style) {
|
|
319
|
+
if (!style.transform || Array.isArray(style.transform))
|
|
320
|
+
return;
|
|
321
|
+
style.transform = parseTransform(style.transform);
|
|
322
|
+
}
|
|
323
|
+
function transformBoxShadow(styleObj) {
|
|
324
|
+
if (!styleObj.boxShadow)
|
|
325
|
+
return;
|
|
326
|
+
styleObj.boxShadow = parseValues(styleObj.boxShadow).reduce((res, i, idx) => {
|
|
327
|
+
return `${res}${idx === 0 ? '' : ' '}${global.__formatValue(i)}`;
|
|
328
|
+
}, '');
|
|
234
329
|
}
|
|
235
330
|
export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight }) {
|
|
236
331
|
const varStyle = {};
|
|
237
332
|
const unoVarStyle = {};
|
|
238
333
|
const normalStyle = {};
|
|
239
|
-
const normalStyleRef = useRef({});
|
|
240
|
-
const normalStyleChangedRef = useRef(false);
|
|
241
334
|
let hasVarDec = false;
|
|
242
335
|
let hasVarUse = false;
|
|
336
|
+
let hasSelfPercent = false;
|
|
243
337
|
const varKeyPaths = [];
|
|
244
338
|
const unoVarKeyPaths = [];
|
|
339
|
+
const percentKeyPaths = [];
|
|
340
|
+
const calcKeyPaths = [];
|
|
341
|
+
const envKeyPaths = [];
|
|
245
342
|
const [width, setWidth] = useState(0);
|
|
246
343
|
const [height, setHeight] = useState(0);
|
|
247
344
|
const navigation = useNavigation();
|
|
248
|
-
function varVisitor({ key, value, keyPath }) {
|
|
345
|
+
function varVisitor({ target, key, value, keyPath }) {
|
|
249
346
|
if (keyPath.length === 1) {
|
|
250
347
|
if (unoVarDecRegExp.test(key)) {
|
|
251
348
|
unoVarStyle[key] = value;
|
|
@@ -269,6 +366,33 @@ export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext
|
|
|
269
366
|
hasVarUse = true;
|
|
270
367
|
varKeyPaths.push(keyPath.slice());
|
|
271
368
|
}
|
|
369
|
+
else {
|
|
370
|
+
visitOther({ target, key, value, keyPath });
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function envVisitor({ value, keyPath }) {
|
|
375
|
+
if (envUseRegExp.test(value)) {
|
|
376
|
+
envKeyPaths.push(keyPath.slice());
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
function calcVisitor({ value, keyPath }) {
|
|
380
|
+
if (calcUseRegExp.test(value)) {
|
|
381
|
+
calcKeyPaths.push(keyPath.slice());
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function percentVisitor({ key, value, keyPath }) {
|
|
385
|
+
if (hasOwn(selfPercentRule, key) && PERCENT_REGEX.test(value)) {
|
|
386
|
+
hasSelfPercent = true;
|
|
387
|
+
percentKeyPaths.push(keyPath.slice());
|
|
388
|
+
}
|
|
389
|
+
else if ((key === 'fontSize' || key === 'lineHeight') && PERCENT_REGEX.test(value)) {
|
|
390
|
+
percentKeyPaths.push(keyPath.slice());
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function visitOther({ target, key, value, keyPath }) {
|
|
394
|
+
if (filterRegExp.test(value)) {
|
|
395
|
+
[envVisitor, percentVisitor, calcVisitor].forEach(visitor => visitor({ target, key, value, keyPath }));
|
|
272
396
|
}
|
|
273
397
|
}
|
|
274
398
|
// traverse var & generate normalStyle
|
|
@@ -289,96 +413,61 @@ export function useTransformStyle(styleObj = {}, { enableVar, externalVarContext
|
|
|
289
413
|
if (diffAndCloneA(varContextRef.current, newVarContext).diff) {
|
|
290
414
|
varContextRef.current = newVarContext;
|
|
291
415
|
}
|
|
292
|
-
transformVar(normalStyle, varKeyPaths, varContextRef.current);
|
|
416
|
+
transformVar(normalStyle, varKeyPaths, varContextRef.current, visitOther);
|
|
293
417
|
}
|
|
294
418
|
// apply unocss var
|
|
295
419
|
if (unoVarKeyPaths.length) {
|
|
296
|
-
transformVar(normalStyle, unoVarKeyPaths, unoVarStyle);
|
|
297
|
-
}
|
|
298
|
-
const { clone, diff } = diffAndCloneA(normalStyle, normalStyleRef.current);
|
|
299
|
-
if (diff) {
|
|
300
|
-
normalStyleRef.current = clone;
|
|
301
|
-
normalStyleChangedRef.current = !normalStyleChangedRef.current;
|
|
420
|
+
transformVar(normalStyle, unoVarKeyPaths, unoVarStyle, visitOther);
|
|
302
421
|
}
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
percentKeyPaths.push(keyPath.slice());
|
|
324
|
-
}
|
|
325
|
-
else if ((key === 'fontSize' || key === 'lineHeight') && PERCENT_REGEX.test(value)) {
|
|
326
|
-
percentKeyPaths.push(keyPath.slice());
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
function transformPosition(styleObj) {
|
|
330
|
-
if (styleObj.position === 'fixed') {
|
|
331
|
-
hasPositionFixed = true;
|
|
332
|
-
styleObj.position = 'absolute';
|
|
333
|
-
}
|
|
422
|
+
const percentConfig = {
|
|
423
|
+
width,
|
|
424
|
+
height,
|
|
425
|
+
fontSize: normalStyle.fontSize,
|
|
426
|
+
parentWidth,
|
|
427
|
+
parentHeight,
|
|
428
|
+
parentFontSize
|
|
429
|
+
};
|
|
430
|
+
const positionMeta = {
|
|
431
|
+
hasPositionFixed: false
|
|
432
|
+
};
|
|
433
|
+
// apply env
|
|
434
|
+
transformEnv(normalStyle, envKeyPaths, navigation);
|
|
435
|
+
// apply percent
|
|
436
|
+
transformPercent(normalStyle, percentKeyPaths, percentConfig);
|
|
437
|
+
// apply calc
|
|
438
|
+
transformCalc(normalStyle, calcKeyPaths, (value, key) => {
|
|
439
|
+
if (PERCENT_REGEX.test(value)) {
|
|
440
|
+
const resolved = resolvePercent(value, key, percentConfig);
|
|
441
|
+
return typeof resolved === 'number' ? resolved : 0;
|
|
334
442
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
height,
|
|
340
|
-
fontSize: normalStyle.fontSize,
|
|
341
|
-
parentWidth,
|
|
342
|
-
parentHeight,
|
|
343
|
-
parentFontSize
|
|
344
|
-
};
|
|
345
|
-
// apply env
|
|
346
|
-
transformEnv(normalStyle, envKeyPaths, navigation);
|
|
347
|
-
// apply percent
|
|
348
|
-
transformPercent(normalStyle, percentKeyPaths, percentConfig);
|
|
349
|
-
// apply calc
|
|
350
|
-
transformCalc(normalStyle, calcKeyPaths, (value, key) => {
|
|
351
|
-
if (PERCENT_REGEX.test(value)) {
|
|
352
|
-
const resolved = resolvePercent(value, key, percentConfig);
|
|
353
|
-
return typeof resolved === 'number' ? resolved : 0;
|
|
443
|
+
else {
|
|
444
|
+
const formatted = global.__formatValue(value);
|
|
445
|
+
if (typeof formatted === 'number') {
|
|
446
|
+
return formatted;
|
|
354
447
|
}
|
|
355
448
|
else {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
return formatted;
|
|
359
|
-
}
|
|
360
|
-
else {
|
|
361
|
-
warn('calc() only support number, px, rpx, % temporarily.');
|
|
362
|
-
return 0;
|
|
363
|
-
}
|
|
449
|
+
warn('calc() only support number, px, rpx, % temporarily.');
|
|
450
|
+
return 0;
|
|
364
451
|
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
return extendObject({
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
// apply position
|
|
455
|
+
transformPosition(normalStyle, positionMeta);
|
|
456
|
+
// transform number enum stringify
|
|
457
|
+
transformStringify(normalStyle);
|
|
458
|
+
// transform rpx to px
|
|
459
|
+
transformBoxShadow(normalStyle);
|
|
460
|
+
// transform 字符串格式转化数组格式
|
|
461
|
+
transformTransform(normalStyle);
|
|
462
|
+
return {
|
|
377
463
|
hasVarDec,
|
|
378
464
|
varContextRef,
|
|
379
465
|
setWidth,
|
|
380
|
-
setHeight
|
|
381
|
-
|
|
466
|
+
setHeight,
|
|
467
|
+
normalStyle,
|
|
468
|
+
hasSelfPercent,
|
|
469
|
+
hasPositionFixed: positionMeta.hasPositionFixed
|
|
470
|
+
};
|
|
382
471
|
}
|
|
383
472
|
export function traverseStyle(styleObj, visitors) {
|
|
384
473
|
const keyPath = [];
|
|
@@ -387,12 +476,7 @@ export function traverseStyle(styleObj, visitors) {
|
|
|
387
476
|
target.forEach((value, index) => {
|
|
388
477
|
const key = String(index);
|
|
389
478
|
keyPath.push(key);
|
|
390
|
-
visitors.forEach(visitor => visitor({
|
|
391
|
-
target,
|
|
392
|
-
key,
|
|
393
|
-
value,
|
|
394
|
-
keyPath
|
|
395
|
-
}));
|
|
479
|
+
visitors.forEach(visitor => visitor({ target, key, value, keyPath }));
|
|
396
480
|
traverse(value);
|
|
397
481
|
keyPath.pop();
|
|
398
482
|
});
|
|
@@ -450,19 +534,8 @@ export const useLayout = ({ props, hasSelfPercent, setWidth, setHeight, onLayout
|
|
|
450
534
|
}
|
|
451
535
|
if (enableOffset) {
|
|
452
536
|
nodeRef.current?.measure((x, y, width, height, offsetLeft, offsetTop) => {
|
|
453
|
-
const {
|
|
454
|
-
layoutRef.current = {
|
|
455
|
-
x,
|
|
456
|
-
y: y - navigationY,
|
|
457
|
-
width,
|
|
458
|
-
height,
|
|
459
|
-
offsetLeft,
|
|
460
|
-
offsetTop: offsetTop - navigationY,
|
|
461
|
-
_x: x,
|
|
462
|
-
_y: y,
|
|
463
|
-
_offsetLeft: offsetLeft,
|
|
464
|
-
_offsetTop: offsetTop
|
|
465
|
-
};
|
|
537
|
+
const { top: navigationY = 0 } = navigation?.layout || {};
|
|
538
|
+
layoutRef.current = { x, y: y - navigationY, width, height, offsetLeft, offsetTop: offsetTop - navigationY };
|
|
466
539
|
});
|
|
467
540
|
}
|
|
468
541
|
onLayout && onLayout(e);
|
|
@@ -538,7 +611,7 @@ export function getCurrentPage(pageId) {
|
|
|
538
611
|
}
|
|
539
612
|
export function renderImage(imageProps, enableFastImage = false) {
|
|
540
613
|
const Component = enableFastImage ? FastImage : Image;
|
|
541
|
-
return
|
|
614
|
+
return createElement(Component, imageProps);
|
|
542
615
|
}
|
|
543
616
|
export function pickStyle(styleObj = {}, pickedKeys, callback) {
|
|
544
617
|
return pickedKeys.reduce((acc, key) => {
|
|
@@ -589,13 +662,11 @@ export function useHover({ enableHover, hoverStartTime, hoverStayTime, disabled
|
|
|
589
662
|
const gesture = useMemo(() => {
|
|
590
663
|
return Gesture.Pan()
|
|
591
664
|
.onTouchesDown(() => {
|
|
592
|
-
|
|
593
|
-
runOnJS(setStartTimer)();
|
|
665
|
+
setStartTimer();
|
|
594
666
|
})
|
|
595
667
|
.onTouchesUp(() => {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
});
|
|
668
|
+
setStayTimer();
|
|
669
|
+
}).runOnJS(true);
|
|
599
670
|
}, []);
|
|
600
671
|
if (gestureRef) {
|
|
601
672
|
gesture.simultaneousWithExternalGesture(gestureRef);
|
|
@@ -605,3 +676,17 @@ export function useHover({ enableHover, hoverStartTime, hoverStayTime, disabled
|
|
|
605
676
|
gesture
|
|
606
677
|
};
|
|
607
678
|
}
|
|
679
|
+
export function useRunOnJSCallback(callbackMapRef) {
|
|
680
|
+
const invokeCallback = useCallback((key, ...args) => {
|
|
681
|
+
const callback = callbackMapRef.current[key];
|
|
682
|
+
// eslint-disable-next-line node/no-callback-literal
|
|
683
|
+
if (isFunction(callback))
|
|
684
|
+
return callback(...args);
|
|
685
|
+
}, []);
|
|
686
|
+
useEffect(() => {
|
|
687
|
+
return () => {
|
|
688
|
+
callbackMapRef.current = {};
|
|
689
|
+
};
|
|
690
|
+
}, []);
|
|
691
|
+
return invokeCallback;
|
|
692
|
+
}
|
|
@@ -117,11 +117,11 @@ export interface PrivateInputProps {
|
|
|
117
117
|
|
|
118
118
|
type FinalInputProps = InputProps & PrivateInputProps
|
|
119
119
|
|
|
120
|
-
const
|
|
121
|
-
text: '
|
|
120
|
+
const inputModeMap: Record<Type, string> = {
|
|
121
|
+
text: 'text',
|
|
122
122
|
number: 'numeric',
|
|
123
|
-
idcard: '
|
|
124
|
-
digit:
|
|
123
|
+
idcard: 'text',
|
|
124
|
+
digit: 'decimal'
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps>((props: FinalInputProps, ref): JSX.Element => {
|
|
@@ -181,7 +181,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
181
181
|
return ''
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
const
|
|
184
|
+
const inputMode = inputModeMap[type]
|
|
185
185
|
const defaultValue = parseValue(value)
|
|
186
186
|
const textAlignVertical = multiline ? 'top' : 'auto'
|
|
187
187
|
|
|
@@ -438,7 +438,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
|
|
|
438
438
|
ref: nodeRef,
|
|
439
439
|
style: extendObject({}, normalStyle, layoutStyle),
|
|
440
440
|
allowFontScaling,
|
|
441
|
-
|
|
441
|
+
inputMode: inputMode,
|
|
442
442
|
secureTextEntry: !!password,
|
|
443
443
|
defaultValue: defaultValue,
|
|
444
444
|
value: inputValue,
|