@arco-design/mobile-react 2.38.3 → 2.38.4
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/CHANGELOG.md +12 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/action-sheet/index.d.ts +0 -1
- package/cjs/date-picker/index.d.ts +1 -1
- package/cjs/date-picker/index.js +3 -0
- package/cjs/dialog/index.d.ts +0 -1
- package/cjs/form/form-item.d.ts +5 -4
- package/cjs/form/form-item.js +1 -1
- package/cjs/form/type.d.ts +2 -3
- package/cjs/form/useForm.d.ts +1 -1
- package/cjs/pull-refresh/android-pull-refresh.d.ts +1 -1
- package/cjs/pull-refresh/hooks.d.ts +2 -2
- package/cjs/pull-refresh/ios-pull-refresh.d.ts +1 -1
- package/cjs/pull-refresh/ios-pull-refresh.js +3 -1
- package/cjs/pull-refresh/model.d.ts +0 -1
- package/cjs/stepper/hooks/useValue.d.ts +1 -1
- package/cjs/stepper/type.d.ts +1 -1
- package/cjs/swipe-action/type.d.ts +1 -1
- package/cjs/uploader/upload/upload.d.ts +4 -4
- package/dist/index.js +1299 -1296
- package/dist/index.min.js +4 -4
- package/esm/action-sheet/index.d.ts +0 -1
- package/esm/date-picker/index.d.ts +1 -1
- package/esm/date-picker/index.js +3 -0
- package/esm/dialog/index.d.ts +0 -1
- package/esm/form/form-item.d.ts +5 -4
- package/esm/form/form-item.js +5 -5
- package/esm/form/type.d.ts +2 -3
- package/esm/form/useForm.d.ts +1 -1
- package/esm/form/useForm.js +3 -3
- package/esm/pull-refresh/android-pull-refresh.d.ts +1 -1
- package/esm/pull-refresh/android-pull-refresh.js +2 -2
- package/esm/pull-refresh/hooks.d.ts +2 -2
- package/esm/pull-refresh/hooks.js +2 -2
- package/esm/pull-refresh/ios-pull-refresh.d.ts +1 -1
- package/esm/pull-refresh/ios-pull-refresh.js +2 -1
- package/esm/pull-refresh/model.d.ts +0 -1
- package/esm/stepper/hooks/useValue.d.ts +1 -1
- package/esm/stepper/hooks/useValue.js +2 -2
- package/esm/stepper/type.d.ts +1 -1
- package/esm/swipe-action/type.d.ts +1 -1
- package/esm/uploader/upload/upload.d.ts +4 -4
- package/esm/uploader/upload/upload.js +3 -3
- package/esnext/action-sheet/index.d.ts +0 -1
- package/esnext/date-picker/index.d.ts +1 -1
- package/esnext/date-picker/index.js +5 -0
- package/esnext/dialog/index.d.ts +0 -1
- package/esnext/form/form-item.d.ts +5 -4
- package/esnext/form/form-item.js +11 -6
- package/esnext/form/type.d.ts +2 -3
- package/esnext/form/useForm.d.ts +1 -1
- package/esnext/form/useForm.js +4 -5
- package/esnext/pull-refresh/android-pull-refresh.d.ts +1 -1
- package/esnext/pull-refresh/android-pull-refresh.js +2 -2
- package/esnext/pull-refresh/hooks.d.ts +2 -2
- package/esnext/pull-refresh/hooks.js +3 -3
- package/esnext/pull-refresh/ios-pull-refresh.d.ts +1 -1
- package/esnext/pull-refresh/ios-pull-refresh.js +2 -1
- package/esnext/pull-refresh/model.d.ts +0 -1
- package/esnext/stepper/hooks/useValue.d.ts +1 -1
- package/esnext/stepper/hooks/useValue.js +2 -2
- package/esnext/stepper/type.d.ts +1 -1
- package/esnext/swipe-action/type.d.ts +1 -1
- package/esnext/uploader/upload/upload.d.ts +4 -4
- package/esnext/uploader/upload/upload.js +3 -3
- package/package.json +3 -3
- package/umd/action-sheet/index.d.ts +0 -1
- package/umd/date-picker/index.d.ts +1 -1
- package/umd/date-picker/index.js +3 -0
- package/umd/dialog/index.d.ts +0 -1
- package/umd/form/form-item.d.ts +5 -4
- package/umd/form/form-item.js +1 -1
- package/umd/form/type.d.ts +2 -3
- package/umd/form/useForm.d.ts +1 -1
- package/umd/pull-refresh/android-pull-refresh.d.ts +1 -1
- package/umd/pull-refresh/hooks.d.ts +2 -2
- package/umd/pull-refresh/ios-pull-refresh.d.ts +1 -1
- package/umd/pull-refresh/ios-pull-refresh.js +5 -5
- package/umd/pull-refresh/model.d.ts +0 -1
- package/umd/stepper/hooks/useValue.d.ts +1 -1
- package/umd/stepper/type.d.ts +1 -1
- package/umd/swipe-action/type.d.ts +1 -1
- package/umd/uploader/upload/upload.d.ts +4 -4
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ReactNode, CSSProperties } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { Promise } from 'es6-promise';
|
|
4
3
|
import type { PopupProps, PopupRef } from '../popup';
|
|
5
4
|
import type { OpenBaseProps } from '../masking';
|
|
6
5
|
export interface ActionSheetItemOptions {
|
package/esm/date-picker/index.js
CHANGED
|
@@ -462,6 +462,9 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
462
462
|
useEffect(function () {
|
|
463
463
|
_updateRangeValue(currentTs);
|
|
464
464
|
}, [currentTs]);
|
|
465
|
+
useEffect(function () {
|
|
466
|
+
setCurrentTs(isRange ? Math.min(maxTs, Math.max(minTs, userSetCurrentTs[0])) : Math.min(maxTs, Math.max(minTs, userSetCurrentTs)));
|
|
467
|
+
}, [userSetCurrentTs, maxTs, minTs, isRange]);
|
|
465
468
|
useEffect(function () {
|
|
466
469
|
if (visible) {
|
|
467
470
|
// 初始化当前时间
|
package/esm/dialog/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ILocale } from '@arco-design/mobile-utils';
|
|
4
|
-
import type { Promise } from 'es6-promise';
|
|
5
4
|
import type { MaskingCommonProps, MaskingRef, OpenBaseProps } from '../masking';
|
|
6
5
|
export * from './methods';
|
|
7
6
|
export interface FooterButtonOptions {
|
package/esm/form/form-item.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import React, { PureComponent } from 'react';
|
|
3
3
|
import { FormItemContext } from './form-item-context';
|
|
4
|
-
import { IFieldError, FieldValue, IFormItemInnerProps, FormItemProps, ValidateStatus, FormItemRef,
|
|
4
|
+
import type { IFieldError, FieldValue, IFormItemInnerProps, FormItemProps, ValidateStatus, FormItemRef, IFormItemContext } from './type';
|
|
5
|
+
import { ValueChangeType } from './type';
|
|
5
6
|
interface IFormItemInnerState {
|
|
6
7
|
validateStatus: ValidateStatus;
|
|
7
8
|
errors?: ReactNode[];
|
|
@@ -19,7 +20,7 @@ declare class FormItemInner extends PureComponent<IFormItemInnerProps, IFormItem
|
|
|
19
20
|
changeType: ValueChangeType;
|
|
20
21
|
} | undefined) => void;
|
|
21
22
|
getInitialValue: () => any;
|
|
22
|
-
getFieldError: () =>
|
|
23
|
+
getFieldError: () => ReactNode[];
|
|
23
24
|
isFieldTouched: () => boolean;
|
|
24
25
|
getAllRuleValidateTriggers: () => string[];
|
|
25
26
|
validateField: (validateTrigger?: string | undefined) => Promise<IFieldError>;
|
package/esm/form/form-item.js
CHANGED
|
@@ -6,10 +6,10 @@ var _excluded = ["label", "field", "disabled", "layout", "style", "extra", "requ
|
|
|
6
6
|
/* eslint-disable react/no-unused-class-component-methods */
|
|
7
7
|
import React, { forwardRef, PureComponent, useContext, useImperativeHandle, useRef, useState } from 'react';
|
|
8
8
|
import { cls, Validator, ValidatorType } from '@arco-design/mobile-utils';
|
|
9
|
-
import { Promise } from 'es6-promise';
|
|
9
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
10
10
|
import { FormItemContext } from './form-item-context';
|
|
11
11
|
import { GlobalContext } from '../context-provider';
|
|
12
|
-
import {
|
|
12
|
+
import { ValueChangeType, FormInternalComponentType } from './type';
|
|
13
13
|
import { getDefaultValueForInterComponent, getErrorAndWarnings, isFieldRequired } from './utils';
|
|
14
14
|
import { DefaultDatePickerLinkedContainer, DefaultPickerLinkedContainer } from './linked-container';
|
|
15
15
|
|
|
@@ -107,7 +107,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
|
|
|
107
107
|
var fieldValidator = new Validator((_Validator = {}, _Validator[field] = curRules, _Validator), {
|
|
108
108
|
validateMessages: validateMessages
|
|
109
109
|
});
|
|
110
|
-
return new
|
|
110
|
+
return new ES6Promise(function (resolve) {
|
|
111
111
|
var _fieldValidator$valid;
|
|
112
112
|
|
|
113
113
|
fieldValidator.validate((_fieldValidator$valid = {}, _fieldValidator$valid[field] = value, _fieldValidator$valid), function (errorsMap) {
|
|
@@ -122,7 +122,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
|
|
|
122
122
|
warnings: warnings,
|
|
123
123
|
errorTypes: errorTypes
|
|
124
124
|
});
|
|
125
|
-
|
|
125
|
+
resolve({
|
|
126
126
|
errors: _this._errors,
|
|
127
127
|
warnings: warnings,
|
|
128
128
|
value: value,
|
|
@@ -133,7 +133,7 @@ var FormItemInner = /*#__PURE__*/function (_PureComponent) {
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
return
|
|
136
|
+
return ES6Promise.resolve({
|
|
137
137
|
errors: [],
|
|
138
138
|
warnings: [],
|
|
139
139
|
value: value,
|
package/esm/form/type.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IRules } from '@arco-design/mobile-utils';
|
|
2
|
-
import { ReactElement, ReactNode } from 'react';
|
|
3
|
-
import { Promise } from 'es6-promise';
|
|
1
|
+
import type { IRules } from '@arco-design/mobile-utils';
|
|
2
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
4
3
|
export declare type FieldValue = any;
|
|
5
4
|
export declare type FieldItem = Record<string, FieldValue>;
|
|
6
5
|
export declare type ILayout = 'horizontal' | 'vertical' | 'inline';
|
package/esm/form/useForm.d.ts
CHANGED
package/esm/form/useForm.js
CHANGED
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
|
|
3
3
|
/* eslint-disable no-console */
|
|
4
4
|
import { useRef } from 'react';
|
|
5
|
-
import { Promise } from 'es6-promise';
|
|
5
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
6
6
|
import { ValueChangeType } from './type';
|
|
7
7
|
import { deepClone } from './utils';
|
|
8
8
|
|
|
@@ -254,8 +254,8 @@ var FormData = function FormData() {
|
|
|
254
254
|
return errors;
|
|
255
255
|
}));
|
|
256
256
|
});
|
|
257
|
-
var summaryPromise = new
|
|
258
|
-
|
|
257
|
+
var summaryPromise = new ES6Promise(function (resolve, reject) {
|
|
258
|
+
ES6Promise.all(promiseList).then(function (res) {
|
|
259
259
|
var errorResults = res.filter(function (item) {
|
|
260
260
|
var _item$errors;
|
|
261
261
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PullRefreshRef, PullRefreshBasicProps } from './model';
|
|
2
|
+
import type { PullRefreshRef, PullRefreshBasicProps } from './model';
|
|
3
3
|
export declare const PullRefresh: React.ForwardRefExoticComponent<PullRefreshBasicProps & React.RefAttributes<PullRefreshRef>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useRef, forwardRef, useCallback, useMemo, useContext, useEffect, useImperativeHandle } from 'react';
|
|
3
3
|
import { cls, nextTick, defaultLocale } from '@arco-design/mobile-utils';
|
|
4
|
-
import { Promise } from 'es6-promise';
|
|
4
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
5
5
|
import Loading from '../loading';
|
|
6
6
|
import { GlobalContext } from '../context-provider';
|
|
7
7
|
import { PullRefreshStatus } from './model';
|
|
@@ -151,7 +151,7 @@ export var PullRefresh = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
151
151
|
}, [disabled, ifShouldHandle]);
|
|
152
152
|
|
|
153
153
|
var refresh = function refresh() {
|
|
154
|
-
return new
|
|
154
|
+
return new ES6Promise(function (resolve) {
|
|
155
155
|
setStatus(PullRefreshStatus.Loading);
|
|
156
156
|
nextTick(function () {
|
|
157
157
|
scroll(tipsHeight, 300);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from 'react';
|
|
2
|
-
import { Promise } from 'es6-promise';
|
|
2
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
3
3
|
import { PullRefreshStatus } from './model';
|
|
4
4
|
export declare const useCommonState: ({ onRefresh, loosingMinHeight, }: {
|
|
5
5
|
onRefresh?: (() => Promise<void>) | undefined;
|
|
@@ -13,7 +13,7 @@ export declare const useCommonState: ({ onRefresh, loosingMinHeight, }: {
|
|
|
13
13
|
labelRef: RefObject<HTMLDivElement>;
|
|
14
14
|
domRef: RefObject<HTMLDivElement>;
|
|
15
15
|
loosingHeight: number;
|
|
16
|
-
handleRefresh: () =>
|
|
16
|
+
handleRefresh: () => ES6Promise<[void | undefined, unknown]>;
|
|
17
17
|
tipsHeight: number;
|
|
18
18
|
};
|
|
19
19
|
export declare const useAddScrollEvents: ({ domRef, handleTouchStart, handleTouchMove, handleTouchEnd, }: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useRef, useMemo, useEffect, useCallback } from 'react';
|
|
2
|
-
import { Promise } from 'es6-promise';
|
|
2
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
3
3
|
import { PullRefreshStatus } from './model';
|
|
4
4
|
export var useCommonState = function useCommonState(_ref) {
|
|
5
5
|
var onRefresh = _ref.onRefresh,
|
|
@@ -29,7 +29,7 @@ export var useCommonState = function useCommonState(_ref) {
|
|
|
29
29
|
loadingRef.current = true; // 避免动画过快,最短加载时间
|
|
30
30
|
// @en Minimum load time, avoid animation too fast
|
|
31
31
|
|
|
32
|
-
return
|
|
32
|
+
return ES6Promise.all([onRefresh == null ? void 0 : onRefresh(), new ES6Promise(function (resolve) {
|
|
33
33
|
// 最少加载一秒
|
|
34
34
|
// @en Load at least one second
|
|
35
35
|
setTimeout(function () {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PullRefreshRef, PullRefreshBasicProps } from './model';
|
|
2
|
+
import type { PullRefreshRef, PullRefreshBasicProps } from './model';
|
|
3
3
|
export declare const PullRefresh: React.ForwardRefExoticComponent<PullRefreshBasicProps & React.RefAttributes<PullRefreshRef>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useState, useRef, forwardRef, useCallback, useContext, useEffect, useMemo, useImperativeHandle } from 'react';
|
|
3
3
|
import { cls, defaultLocale } from '@arco-design/mobile-utils';
|
|
4
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
4
5
|
import Loading from '../loading';
|
|
5
6
|
import { GlobalContext } from '../context-provider';
|
|
6
7
|
import { PullRefreshStatus } from './model';
|
|
@@ -124,7 +125,7 @@ export var PullRefresh = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
124
125
|
}, [disabled, ifShouldHandle]);
|
|
125
126
|
|
|
126
127
|
var refresh = function refresh() {
|
|
127
|
-
return new
|
|
128
|
+
return new ES6Promise(function (resolve) {
|
|
128
129
|
if (domRef.current) {
|
|
129
130
|
domRef.current.style.overflow = 'hidden';
|
|
130
131
|
var animationKey = new Date().getTime();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { StepperProps } from '..';
|
|
2
|
+
import type { StepperProps } from '..';
|
|
3
3
|
export default function useValue(params: Required<Pick<StepperProps, 'defaultValue' | 'min' | 'max' | 'digits'>> & Pick<StepperProps, 'formatter' | 'value'>): {
|
|
4
4
|
updateValue: (updater: number | ((oldValue: number) => number)) => void;
|
|
5
5
|
actualInputValue: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { Promise } from 'es6-promise';
|
|
2
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
3
3
|
export default function useValue(params) {
|
|
4
4
|
var defaultValue = params.defaultValue,
|
|
5
5
|
formatter = params.formatter,
|
|
@@ -16,7 +16,7 @@ export default function useValue(params) {
|
|
|
16
16
|
var tempValue = typeof updater === 'function' ? updater(innerValue) : updater;
|
|
17
17
|
|
|
18
18
|
if (formatter) {
|
|
19
|
-
new
|
|
19
|
+
new ES6Promise(function (resolve) {
|
|
20
20
|
resolve(formatter(Number(tempValue)));
|
|
21
21
|
}).then(function (result) {
|
|
22
22
|
var res = Math.max(min, Math.min(max, result));
|
package/esm/stepper/type.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Promise } from 'es6-promise';
|
|
4
|
-
import { AdapterFile, CommonFileItem, UploadCommonProps } from './type';
|
|
2
|
+
import type React from 'react';
|
|
3
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
4
|
+
import type { AdapterFile, CommonFileItem, UploadCommonProps } from './type';
|
|
5
5
|
export declare class Upload<FileItem extends CommonFileItem = CommonFileItem> {
|
|
6
6
|
props: UploadCommonProps<FileItem>;
|
|
7
7
|
fileRef: React.MutableRefObject<HTMLInputElement | null>;
|
|
@@ -17,4 +17,4 @@ export declare class Upload<FileItem extends CommonFileItem = CommonFileItem> {
|
|
|
17
17
|
handleClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, file: FileItem, index: number) => void;
|
|
18
18
|
handleTouchStart: (e: React.TouchEvent<HTMLDivElement>, image: FileItem, index: number) => void;
|
|
19
19
|
}
|
|
20
|
-
export declare const parseFile: (file: AdapterFile) =>
|
|
20
|
+
export declare const parseFile: (file: AdapterFile) => ES6Promise<unknown>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import { Promise } from 'es6-promise';
|
|
2
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
3
3
|
export var Upload = /*#__PURE__*/function () {
|
|
4
4
|
// click && longPress
|
|
5
5
|
function Upload(props, fileRef, cacheRef) {
|
|
@@ -11,7 +11,7 @@ export var Upload = /*#__PURE__*/function () {
|
|
|
11
11
|
this.timeOutEvent = void 0;
|
|
12
12
|
|
|
13
13
|
this.handleFile = function (newFiles) {
|
|
14
|
-
|
|
14
|
+
ES6Promise.all(newFiles.map(function (file) {
|
|
15
15
|
return parseFile(file);
|
|
16
16
|
})).then(function (parseFiles) {
|
|
17
17
|
var res = parseFiles.map(function (url, index) {
|
|
@@ -147,7 +147,7 @@ export var Upload = /*#__PURE__*/function () {
|
|
|
147
147
|
return Upload;
|
|
148
148
|
}();
|
|
149
149
|
export var parseFile = function parseFile(file) {
|
|
150
|
-
return new
|
|
150
|
+
return new ES6Promise(function (resolve, reject) {
|
|
151
151
|
if (file.url) {
|
|
152
152
|
resolve(file.url);
|
|
153
153
|
} else {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ReactNode, CSSProperties } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { Promise } from 'es6-promise';
|
|
4
3
|
import type { PopupProps, PopupRef } from '../popup';
|
|
5
4
|
import type { OpenBaseProps } from '../masking';
|
|
6
5
|
export interface ActionSheetItemOptions {
|
|
@@ -329,6 +329,11 @@ const DatePicker = forwardRef((props, ref) => {
|
|
|
329
329
|
useEffect(() => {
|
|
330
330
|
_updateRangeValue(currentTs);
|
|
331
331
|
}, [currentTs]);
|
|
332
|
+
useEffect(() => {
|
|
333
|
+
setCurrentTs(isRange
|
|
334
|
+
? Math.min(maxTs, Math.max(minTs, userSetCurrentTs[0]))
|
|
335
|
+
: Math.min(maxTs, Math.max(minTs, userSetCurrentTs)));
|
|
336
|
+
}, [userSetCurrentTs, maxTs, minTs, isRange]);
|
|
332
337
|
useEffect(() => {
|
|
333
338
|
if (visible) {
|
|
334
339
|
// 初始化当前时间
|
package/esnext/dialog/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ILocale } from '@arco-design/mobile-utils';
|
|
4
|
-
import type { Promise } from 'es6-promise';
|
|
5
4
|
import type { MaskingCommonProps, MaskingRef, OpenBaseProps } from '../masking';
|
|
6
5
|
export * from './methods';
|
|
7
6
|
export interface FooterButtonOptions {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import React, { PureComponent } from 'react';
|
|
3
3
|
import { FormItemContext } from './form-item-context';
|
|
4
|
-
import { IFieldError, FieldValue, IFormItemInnerProps, FormItemProps, ValidateStatus, FormItemRef,
|
|
4
|
+
import type { IFieldError, FieldValue, IFormItemInnerProps, FormItemProps, ValidateStatus, FormItemRef, IFormItemContext } from './type';
|
|
5
|
+
import { ValueChangeType } from './type';
|
|
5
6
|
interface IFormItemInnerState {
|
|
6
7
|
validateStatus: ValidateStatus;
|
|
7
8
|
errors?: ReactNode[];
|
|
@@ -19,7 +20,7 @@ declare class FormItemInner extends PureComponent<IFormItemInnerProps, IFormItem
|
|
|
19
20
|
changeType: ValueChangeType;
|
|
20
21
|
} | undefined) => void;
|
|
21
22
|
getInitialValue: () => any;
|
|
22
|
-
getFieldError: () =>
|
|
23
|
+
getFieldError: () => ReactNode[];
|
|
23
24
|
isFieldTouched: () => boolean;
|
|
24
25
|
getAllRuleValidateTriggers: () => string[];
|
|
25
26
|
validateField: (validateTrigger?: string | undefined) => Promise<IFieldError>;
|
package/esnext/form/form-item.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/* eslint-disable react/no-unused-class-component-methods */
|
|
2
1
|
import React, { forwardRef, PureComponent, useContext, useImperativeHandle, useRef, useState, } from 'react';
|
|
3
2
|
import { cls, Validator, ValidatorType } from '@arco-design/mobile-utils';
|
|
4
|
-
import { Promise } from 'es6-promise';
|
|
3
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
5
4
|
import { FormItemContext } from './form-item-context';
|
|
6
5
|
import { GlobalContext } from '../context-provider';
|
|
7
|
-
import {
|
|
6
|
+
import { ValueChangeType, FormInternalComponentType } from './type';
|
|
8
7
|
import { getDefaultValueForInterComponent, getErrorAndWarnings, isFieldRequired } from './utils';
|
|
9
8
|
import { DefaultDatePickerLinkedContainer, DefaultPickerLinkedContainer } from './linked-container';
|
|
10
9
|
class FormItemInner extends PureComponent {
|
|
@@ -64,7 +63,7 @@ class FormItemInner extends PureComponent {
|
|
|
64
63
|
if (curRules?.length && field) {
|
|
65
64
|
const fieldDom = this.props.getFormItemRef();
|
|
66
65
|
const fieldValidator = new Validator({ [field]: curRules }, { validateMessages });
|
|
67
|
-
return new
|
|
66
|
+
return new ES6Promise(resolve => {
|
|
68
67
|
fieldValidator.validate({ [field]: value }, (errorsMap) => {
|
|
69
68
|
const { errors, warnings, errorTypes } = getErrorAndWarnings(errorsMap?.[field] || []);
|
|
70
69
|
this._errors = errors;
|
|
@@ -73,7 +72,7 @@ class FormItemInner extends PureComponent {
|
|
|
73
72
|
warnings,
|
|
74
73
|
errorTypes,
|
|
75
74
|
});
|
|
76
|
-
|
|
75
|
+
resolve({
|
|
77
76
|
errors: this._errors,
|
|
78
77
|
warnings,
|
|
79
78
|
value,
|
|
@@ -83,7 +82,13 @@ class FormItemInner extends PureComponent {
|
|
|
83
82
|
});
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
|
-
return
|
|
85
|
+
return ES6Promise.resolve({
|
|
86
|
+
errors: [],
|
|
87
|
+
warnings: [],
|
|
88
|
+
value,
|
|
89
|
+
field,
|
|
90
|
+
dom: null,
|
|
91
|
+
});
|
|
87
92
|
};
|
|
88
93
|
this.setFieldData = (value) => {
|
|
89
94
|
const { field, trigger = 'onChange' } = this.props;
|
package/esnext/form/type.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { IRules } from '@arco-design/mobile-utils';
|
|
2
|
-
import { ReactElement, ReactNode } from 'react';
|
|
3
|
-
import { Promise } from 'es6-promise';
|
|
1
|
+
import type { IRules } from '@arco-design/mobile-utils';
|
|
2
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
4
3
|
export declare type FieldValue = any;
|
|
5
4
|
export declare type FieldItem = Record<string, FieldValue>;
|
|
6
5
|
export declare type ILayout = 'horizontal' | 'vertical' | 'inline';
|
package/esnext/form/useForm.d.ts
CHANGED
package/esnext/form/useForm.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import { useRef } from 'react';
|
|
3
|
-
import { Promise } from 'es6-promise';
|
|
4
|
-
import { ValueChangeType
|
|
2
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
3
|
+
import { ValueChangeType } from './type';
|
|
5
4
|
import { deepClone } from './utils';
|
|
6
5
|
const defaultFunc = () => { };
|
|
7
6
|
export const defaultFormDataMethods = {
|
|
@@ -186,8 +185,8 @@ class FormData {
|
|
|
186
185
|
const promise = entity.validateField();
|
|
187
186
|
promiseList.push(promise.then(errors => errors));
|
|
188
187
|
});
|
|
189
|
-
const summaryPromise = new
|
|
190
|
-
|
|
188
|
+
const summaryPromise = new ES6Promise((resolve, reject) => {
|
|
189
|
+
ES6Promise.all(promiseList).then((res) => {
|
|
191
190
|
const errorResults = res.filter(item => item?.errors?.length);
|
|
192
191
|
if (errorResults.length) {
|
|
193
192
|
reject(errorResults);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PullRefreshRef, PullRefreshBasicProps } from './model';
|
|
2
|
+
import type { PullRefreshRef, PullRefreshBasicProps } from './model';
|
|
3
3
|
export declare const PullRefresh: React.ForwardRefExoticComponent<PullRefreshBasicProps & React.RefAttributes<PullRefreshRef>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef, forwardRef, useCallback, useMemo, useContext, useEffect, useImperativeHandle, } from 'react';
|
|
2
2
|
import { cls, nextTick, defaultLocale } from '@arco-design/mobile-utils';
|
|
3
|
-
import { Promise } from 'es6-promise';
|
|
3
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
4
4
|
import Loading from '../loading';
|
|
5
5
|
import { GlobalContext } from '../context-provider';
|
|
6
6
|
import { PullRefreshStatus } from './model';
|
|
@@ -78,7 +78,7 @@ export const PullRefresh = forwardRef((props, ref) => {
|
|
|
78
78
|
}
|
|
79
79
|
setStatus(PullRefreshStatus.Pulling);
|
|
80
80
|
}, [disabled, ifShouldHandle]);
|
|
81
|
-
const refresh = () => new
|
|
81
|
+
const refresh = () => new ES6Promise(resolve => {
|
|
82
82
|
setStatus(PullRefreshStatus.Loading);
|
|
83
83
|
nextTick(() => {
|
|
84
84
|
scroll(tipsHeight, 300);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RefObject } from 'react';
|
|
2
|
-
import { Promise } from 'es6-promise';
|
|
2
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
3
3
|
import { PullRefreshStatus } from './model';
|
|
4
4
|
export declare const useCommonState: ({ onRefresh, loosingMinHeight, }: {
|
|
5
5
|
onRefresh?: (() => Promise<void>) | undefined;
|
|
@@ -13,7 +13,7 @@ export declare const useCommonState: ({ onRefresh, loosingMinHeight, }: {
|
|
|
13
13
|
labelRef: RefObject<HTMLDivElement>;
|
|
14
14
|
domRef: RefObject<HTMLDivElement>;
|
|
15
15
|
loosingHeight: number;
|
|
16
|
-
handleRefresh: () =>
|
|
16
|
+
handleRefresh: () => ES6Promise<[void | undefined, unknown]>;
|
|
17
17
|
tipsHeight: number;
|
|
18
18
|
};
|
|
19
19
|
export declare const useAddScrollEvents: ({ domRef, handleTouchStart, handleTouchMove, handleTouchEnd, }: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState, useRef, useMemo, useEffect, useCallback } from 'react';
|
|
2
|
-
import { Promise } from 'es6-promise';
|
|
2
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
3
3
|
import { PullRefreshStatus } from './model';
|
|
4
4
|
export const useCommonState = ({ onRefresh, loosingMinHeight, }) => {
|
|
5
5
|
const [status, setStatus] = useState(PullRefreshStatus.Static);
|
|
@@ -15,9 +15,9 @@ export const useCommonState = ({ onRefresh, loosingMinHeight, }) => {
|
|
|
15
15
|
loadingRef.current = true;
|
|
16
16
|
// 避免动画过快,最短加载时间
|
|
17
17
|
// @en Minimum load time, avoid animation too fast
|
|
18
|
-
return
|
|
18
|
+
return ES6Promise.all([
|
|
19
19
|
onRefresh?.(),
|
|
20
|
-
new
|
|
20
|
+
new ES6Promise(resolve => {
|
|
21
21
|
// 最少加载一秒
|
|
22
22
|
// @en Load at least one second
|
|
23
23
|
setTimeout(() => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PullRefreshRef, PullRefreshBasicProps } from './model';
|
|
2
|
+
import type { PullRefreshRef, PullRefreshBasicProps } from './model';
|
|
3
3
|
export declare const PullRefresh: React.ForwardRefExoticComponent<PullRefreshBasicProps & React.RefAttributes<PullRefreshRef>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState, useRef, forwardRef, useCallback, useContext, useEffect, useMemo, useImperativeHandle, } from 'react';
|
|
2
2
|
import { cls, defaultLocale } from '@arco-design/mobile-utils';
|
|
3
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
3
4
|
import Loading from '../loading';
|
|
4
5
|
import { GlobalContext } from '../context-provider';
|
|
5
6
|
import { PullRefreshStatus } from './model';
|
|
@@ -68,7 +69,7 @@ export const PullRefresh = forwardRef((props, ref) => {
|
|
|
68
69
|
domRef.current.scrollTop = 1;
|
|
69
70
|
}
|
|
70
71
|
}, [disabled, ifShouldHandle]);
|
|
71
|
-
const refresh = () => new
|
|
72
|
+
const refresh = () => new ES6Promise(resolve => {
|
|
72
73
|
if (domRef.current) {
|
|
73
74
|
domRef.current.style.overflow = 'hidden';
|
|
74
75
|
const animationKey = new Date().getTime();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StepperProps } from '..';
|
|
1
|
+
import type { StepperProps } from '..';
|
|
2
2
|
export default function useValue(params: Required<Pick<StepperProps, 'defaultValue' | 'min' | 'max' | 'digits'>> & Pick<StepperProps, 'formatter' | 'value'>): {
|
|
3
3
|
updateValue: (updater: number | ((oldValue: number) => number)) => void;
|
|
4
4
|
actualInputValue: number;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
-
import { Promise } from 'es6-promise';
|
|
2
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
3
3
|
export default function useValue(params) {
|
|
4
4
|
const { defaultValue, formatter, max, min, value, digits } = params;
|
|
5
5
|
const [innerValue, setInnerValue] = useState(defaultValue);
|
|
6
6
|
const updateValue = (updater) => {
|
|
7
7
|
const tempValue = typeof updater === 'function' ? updater(innerValue) : updater;
|
|
8
8
|
if (formatter) {
|
|
9
|
-
new
|
|
9
|
+
new ES6Promise(resolve => {
|
|
10
10
|
resolve(formatter(Number(tempValue)));
|
|
11
11
|
}).then((result) => {
|
|
12
12
|
const res = Math.max(min, Math.min(max, result));
|
package/esnext/stepper/type.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Promise } from 'es6-promise';
|
|
4
|
-
import { AdapterFile, CommonFileItem, UploadCommonProps } from './type';
|
|
2
|
+
import type React from 'react';
|
|
3
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
4
|
+
import type { AdapterFile, CommonFileItem, UploadCommonProps } from './type';
|
|
5
5
|
export declare class Upload<FileItem extends CommonFileItem = CommonFileItem> {
|
|
6
6
|
props: UploadCommonProps<FileItem>;
|
|
7
7
|
fileRef: React.MutableRefObject<HTMLInputElement | null>;
|
|
@@ -17,4 +17,4 @@ export declare class Upload<FileItem extends CommonFileItem = CommonFileItem> {
|
|
|
17
17
|
handleClick: (e: React.MouseEvent<HTMLDivElement, MouseEvent>, file: FileItem, index: number) => void;
|
|
18
18
|
handleTouchStart: (e: React.TouchEvent<HTMLDivElement>, image: FileItem, index: number) => void;
|
|
19
19
|
}
|
|
20
|
-
export declare const parseFile: (file: AdapterFile) =>
|
|
20
|
+
export declare const parseFile: (file: AdapterFile) => ES6Promise<unknown>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Promise } from 'es6-promise';
|
|
1
|
+
import { Promise as ES6Promise } from 'es6-promise';
|
|
2
2
|
export class Upload {
|
|
3
3
|
constructor(props, fileRef, cacheRef) {
|
|
4
4
|
// 解析文件生成预览
|
|
5
5
|
this.handleFile = (newFiles) => {
|
|
6
|
-
|
|
6
|
+
ES6Promise.all(newFiles.map(file => parseFile(file))).then(parseFiles => {
|
|
7
7
|
const res = parseFiles.map((url, index) => ({
|
|
8
8
|
url,
|
|
9
9
|
status: typeof this.props.upload === 'function' ? 'loading' : 'loaded',
|
|
@@ -101,7 +101,7 @@ export class Upload {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
export const parseFile = (file) => {
|
|
104
|
-
return new
|
|
104
|
+
return new ES6Promise((resolve, reject) => {
|
|
105
105
|
if (file.url) {
|
|
106
106
|
resolve(file.url);
|
|
107
107
|
}
|