antd-mobile 5.42.3 → 5.43.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/2x/bundle/antd-mobile.cjs.development.js +2383 -2054
- package/2x/bundle/antd-mobile.cjs.js +8 -7
- package/2x/bundle/antd-mobile.es.development.js +1545 -1216
- package/2x/bundle/antd-mobile.es.js +9230 -8978
- package/2x/bundle/antd-mobile.umd.development.js +2380 -2051
- package/2x/bundle/antd-mobile.umd.js +8 -7
- package/2x/bundle/style.css +116 -90
- package/2x/cjs/components/cascader/cascader.css +5 -0
- package/2x/cjs/components/cascader/cascader.d.ts +5 -3
- package/2x/cjs/components/cascader/cascader.js +6 -7
- package/2x/cjs/components/cascader/index.d.ts +2 -1
- package/2x/cjs/components/cascader-view/cascader-view.d.ts +8 -2
- package/2x/cjs/components/cascader-view/cascader-view.js +13 -10
- package/2x/cjs/components/cascader-view/index.d.ts +1 -1
- package/2x/cjs/components/date-picker/date-picker-date-utils.js +4 -10
- package/2x/cjs/components/date-picker/date-picker-week-utils.js +4 -4
- package/2x/cjs/components/date-picker/date-picker.d.ts +1 -1
- package/2x/cjs/components/date-picker/index.d.ts +1 -1
- package/2x/cjs/components/dropdown/dropdown.d.ts +6 -0
- package/2x/cjs/components/dropdown/dropdown.js +38 -7
- package/2x/cjs/components/dropdown/index.d.ts +3 -0
- package/2x/cjs/components/error-block/create-error-block.d.ts +3 -4
- package/2x/cjs/components/error-block/create-error-block.js +2 -2
- package/2x/cjs/components/error-block/images/busy.js +94 -89
- package/2x/cjs/components/error-block/images/default.js +170 -165
- package/2x/cjs/components/error-block/images/disconnected.js +127 -122
- package/2x/cjs/components/error-block/images/empty.js +123 -118
- package/2x/cjs/components/error-block/images/index.d.ts +1 -1
- package/2x/cjs/components/error-block/images/index.js +2 -2
- package/2x/cjs/components/floating-panel/floating-panel.d.ts +2 -0
- package/2x/cjs/components/floating-panel/floating-panel.js +7 -3
- package/2x/cjs/components/form/form-item.js +19 -11
- package/2x/cjs/components/form/index.d.ts +1 -1
- package/2x/cjs/components/input/input.d.ts +4 -2
- package/2x/cjs/components/input/input.js +6 -4
- package/2x/cjs/components/list/list-item.js +1 -1
- package/2x/cjs/components/notice-bar/notice-bar.js +2 -1
- package/2x/cjs/components/passcode-input/passcode-input.css +20 -0
- package/2x/cjs/components/passcode-input/passcode-input.d.ts +2 -0
- package/2x/cjs/components/passcode-input/passcode-input.js +6 -3
- package/2x/cjs/components/popover/popover.js +11 -1
- package/2x/cjs/components/popover/use-showing-guard.d.ts +12 -0
- package/2x/cjs/components/popover/use-showing-guard.js +40 -0
- package/2x/cjs/components/search-bar/search-bar.js +4 -5
- package/2x/cjs/components/segmented/segmented.css +1 -0
- package/2x/cjs/components/swipe-action/swipe-action.js +37 -21
- package/2x/cjs/components/swiper/index.d.ts +3 -1
- package/2x/cjs/components/swiper/swiper.d.ts +9 -2
- package/2x/cjs/components/swiper/swiper.js +36 -18
- package/2x/cjs/components/text-area/text-area.d.ts +1 -1
- package/2x/cjs/components/text-area/text-area.js +4 -3
- package/2x/cjs/components/virtual-input/use-click-outside.js +6 -4
- package/2x/cjs/utils/convert-px.js +7 -2
- package/2x/es/components/cascader/cascader.css +5 -0
- package/2x/es/components/cascader/cascader.d.ts +5 -3
- package/2x/es/components/cascader/cascader.js +7 -8
- package/2x/es/components/cascader/index.d.ts +2 -1
- package/2x/es/components/cascader-view/cascader-view.d.ts +8 -2
- package/2x/es/components/cascader-view/cascader-view.js +12 -9
- package/2x/es/components/cascader-view/index.d.ts +1 -1
- package/2x/es/components/date-picker/date-picker-date-utils.js +4 -9
- package/2x/es/components/date-picker/date-picker-week-utils.js +4 -4
- package/2x/es/components/date-picker/date-picker.d.ts +1 -1
- package/2x/es/components/date-picker/index.d.ts +1 -1
- package/2x/es/components/dropdown/dropdown.d.ts +6 -0
- package/2x/es/components/dropdown/dropdown.js +39 -8
- package/2x/es/components/dropdown/index.d.ts +3 -0
- package/2x/es/components/error-block/create-error-block.d.ts +3 -4
- package/2x/es/components/error-block/create-error-block.js +2 -2
- package/2x/es/components/error-block/images/busy.js +94 -89
- package/2x/es/components/error-block/images/default.js +170 -165
- package/2x/es/components/error-block/images/disconnected.js +127 -122
- package/2x/es/components/error-block/images/empty.js +123 -118
- package/2x/es/components/error-block/images/index.d.ts +1 -1
- package/2x/es/components/error-block/images/index.js +2 -2
- package/2x/es/components/floating-panel/floating-panel.d.ts +2 -0
- package/2x/es/components/floating-panel/floating-panel.js +7 -3
- package/2x/es/components/form/form-item.js +19 -11
- package/2x/es/components/form/index.d.ts +1 -1
- package/2x/es/components/input/input.d.ts +4 -2
- package/2x/es/components/input/input.js +6 -4
- package/2x/es/components/list/list-item.js +1 -1
- package/2x/es/components/notice-bar/notice-bar.js +2 -1
- package/2x/es/components/passcode-input/passcode-input.css +20 -0
- package/2x/es/components/passcode-input/passcode-input.d.ts +2 -0
- package/2x/es/components/passcode-input/passcode-input.js +6 -3
- package/2x/es/components/popover/popover.js +11 -1
- package/2x/es/components/popover/use-showing-guard.d.ts +12 -0
- package/2x/es/components/popover/use-showing-guard.js +34 -0
- package/2x/es/components/search-bar/search-bar.js +4 -5
- package/2x/es/components/segmented/segmented.css +1 -0
- package/2x/es/components/swipe-action/swipe-action.js +37 -21
- package/2x/es/components/swiper/index.d.ts +3 -1
- package/2x/es/components/swiper/swiper.d.ts +9 -2
- package/2x/es/components/swiper/swiper.js +35 -19
- package/2x/es/components/text-area/text-area.d.ts +1 -1
- package/2x/es/components/text-area/text-area.js +4 -3
- package/2x/es/components/virtual-input/use-click-outside.js +7 -4
- package/2x/es/utils/convert-px.js +7 -2
- package/2x/package.json +1 -1
- package/bundle/antd-mobile.cjs.development.js +2383 -2054
- package/bundle/antd-mobile.cjs.js +8 -7
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +1545 -1216
- package/bundle/antd-mobile.es.js +9230 -8978
- package/bundle/antd-mobile.umd.development.js +2380 -2051
- package/bundle/antd-mobile.umd.js +8 -7
- package/bundle/style.css +1 -1
- package/cjs/components/cascader/cascader.css +4 -0
- package/cjs/components/cascader/cascader.d.ts +5 -3
- package/cjs/components/cascader/cascader.js +6 -7
- package/cjs/components/cascader/index.d.ts +2 -1
- package/cjs/components/cascader-view/cascader-view.d.ts +8 -2
- package/cjs/components/cascader-view/cascader-view.js +13 -10
- package/cjs/components/cascader-view/index.d.ts +1 -1
- package/cjs/components/date-picker/date-picker-date-utils.js +4 -10
- package/cjs/components/date-picker/date-picker-week-utils.js +4 -4
- package/cjs/components/date-picker/date-picker.d.ts +1 -1
- package/cjs/components/date-picker/index.d.ts +1 -1
- package/cjs/components/dropdown/dropdown.d.ts +6 -0
- package/cjs/components/dropdown/dropdown.js +38 -7
- package/cjs/components/dropdown/index.d.ts +3 -0
- package/cjs/components/error-block/create-error-block.d.ts +3 -4
- package/cjs/components/error-block/create-error-block.js +2 -2
- package/cjs/components/error-block/images/busy.js +94 -89
- package/cjs/components/error-block/images/default.js +170 -165
- package/cjs/components/error-block/images/disconnected.js +127 -122
- package/cjs/components/error-block/images/empty.js +123 -118
- package/cjs/components/error-block/images/index.d.ts +1 -1
- package/cjs/components/error-block/images/index.js +2 -2
- package/cjs/components/floating-panel/floating-panel.d.ts +2 -0
- package/cjs/components/floating-panel/floating-panel.js +7 -3
- package/cjs/components/form/form-item.js +19 -11
- package/cjs/components/form/index.d.ts +1 -1
- package/cjs/components/input/input.d.ts +4 -2
- package/cjs/components/input/input.js +6 -4
- package/cjs/components/list/list-item.js +1 -1
- package/cjs/components/notice-bar/notice-bar.js +2 -1
- package/cjs/components/passcode-input/passcode-input.css +15 -0
- package/cjs/components/passcode-input/passcode-input.d.ts +2 -0
- package/cjs/components/passcode-input/passcode-input.js +6 -3
- package/cjs/components/popover/popover.js +11 -1
- package/cjs/components/popover/use-showing-guard.d.ts +12 -0
- package/cjs/components/popover/use-showing-guard.js +40 -0
- package/cjs/components/search-bar/search-bar.js +4 -5
- package/cjs/components/segmented/segmented.css +1 -0
- package/cjs/components/swipe-action/swipe-action.js +37 -21
- package/cjs/components/swiper/index.d.ts +3 -1
- package/cjs/components/swiper/swiper.d.ts +9 -2
- package/cjs/components/swiper/swiper.js +36 -18
- package/cjs/components/text-area/text-area.d.ts +1 -1
- package/cjs/components/text-area/text-area.js +4 -3
- package/cjs/components/virtual-input/use-click-outside.js +6 -4
- package/cjs/utils/convert-px.js +7 -2
- package/es/components/cascader/cascader.css +4 -0
- package/es/components/cascader/cascader.d.ts +5 -3
- package/es/components/cascader/cascader.js +7 -8
- package/es/components/cascader/index.d.ts +2 -1
- package/es/components/cascader-view/cascader-view.d.ts +8 -2
- package/es/components/cascader-view/cascader-view.js +12 -9
- package/es/components/cascader-view/index.d.ts +1 -1
- package/es/components/date-picker/date-picker-date-utils.js +4 -9
- package/es/components/date-picker/date-picker-week-utils.js +4 -4
- package/es/components/date-picker/date-picker.d.ts +1 -1
- package/es/components/date-picker/index.d.ts +1 -1
- package/es/components/dropdown/dropdown.d.ts +6 -0
- package/es/components/dropdown/dropdown.js +39 -8
- package/es/components/dropdown/index.d.ts +3 -0
- package/es/components/error-block/create-error-block.d.ts +3 -4
- package/es/components/error-block/create-error-block.js +2 -2
- package/es/components/error-block/images/busy.js +94 -89
- package/es/components/error-block/images/default.js +170 -165
- package/es/components/error-block/images/disconnected.js +127 -122
- package/es/components/error-block/images/empty.js +123 -118
- package/es/components/error-block/images/index.d.ts +1 -1
- package/es/components/error-block/images/index.js +2 -2
- package/es/components/floating-panel/floating-panel.d.ts +2 -0
- package/es/components/floating-panel/floating-panel.js +7 -3
- package/es/components/form/form-item.js +19 -11
- package/es/components/form/index.d.ts +1 -1
- package/es/components/input/input.d.ts +4 -2
- package/es/components/input/input.js +6 -4
- package/es/components/list/list-item.js +1 -1
- package/es/components/notice-bar/notice-bar.js +2 -1
- package/es/components/passcode-input/passcode-input.css +15 -0
- package/es/components/passcode-input/passcode-input.d.ts +2 -0
- package/es/components/passcode-input/passcode-input.js +6 -3
- package/es/components/popover/popover.js +11 -1
- package/es/components/popover/use-showing-guard.d.ts +12 -0
- package/es/components/popover/use-showing-guard.js +34 -0
- package/es/components/search-bar/search-bar.js +4 -5
- package/es/components/segmented/segmented.css +1 -0
- package/es/components/swipe-action/swipe-action.js +37 -21
- package/es/components/swiper/index.d.ts +3 -1
- package/es/components/swiper/swiper.d.ts +9 -2
- package/es/components/swiper/swiper.js +35 -19
- package/es/components/text-area/text-area.d.ts +1 -1
- package/es/components/text-area/text-area.js +4 -3
- package/es/components/virtual-input/use-click-outside.js +7 -4
- package/es/utils/convert-px.js +7 -2
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
|
@@ -14,6 +14,13 @@ import Popover from '../popover';
|
|
|
14
14
|
import { FormContext, NoStyleItemContext } from './context';
|
|
15
15
|
import { isSafeSetRefComponent, toArray } from './utils';
|
|
16
16
|
const NAME_SPLIT = '__SPLIT__';
|
|
17
|
+
function useChildren(children) {
|
|
18
|
+
if (typeof children === 'function') {
|
|
19
|
+
return children;
|
|
20
|
+
}
|
|
21
|
+
const childList = toArray(children);
|
|
22
|
+
return childList.length <= 1 ? childList[0] : childList;
|
|
23
|
+
}
|
|
17
24
|
const classPrefix = `adm-form-item`;
|
|
18
25
|
const MemoInput = React.memo(({
|
|
19
26
|
children
|
|
@@ -138,6 +145,7 @@ export const FormItem = props => {
|
|
|
138
145
|
arrowIcon
|
|
139
146
|
} = props,
|
|
140
147
|
fieldProps = __rest(props, ["style", "label", "help", "helpIcon", "extra", "hasFeedback", "name", "required", "noStyle", "hidden", "layout", "childElementPosition", "description", "disabled", "rules", "children", "messageVariables", "trigger", "validateTrigger", "onClick", "shouldUpdate", "dependencies", "clickable", "arrow", "arrowIcon"]);
|
|
148
|
+
const mergedChildren = useChildren(children);
|
|
141
149
|
const {
|
|
142
150
|
name: formName
|
|
143
151
|
} = useContext(FormContext);
|
|
@@ -208,9 +216,9 @@ export const FormItem = props => {
|
|
|
208
216
|
value: onSubMetaChange
|
|
209
217
|
}, baseChildren)));
|
|
210
218
|
}
|
|
211
|
-
const isRenderProps = typeof
|
|
219
|
+
const isRenderProps = typeof mergedChildren === 'function';
|
|
212
220
|
if (!name && !isRenderProps && !props.dependencies) {
|
|
213
|
-
return renderLayout(
|
|
221
|
+
return renderLayout(mergedChildren);
|
|
214
222
|
}
|
|
215
223
|
let Variables = {};
|
|
216
224
|
Variables.label = typeof label === 'string' ? label : '';
|
|
@@ -243,7 +251,7 @@ export const FormItem = props => {
|
|
|
243
251
|
}
|
|
244
252
|
if (isRenderProps) {
|
|
245
253
|
if ((shouldUpdate || dependencies) && !name) {
|
|
246
|
-
childNode =
|
|
254
|
+
childNode = mergedChildren(context);
|
|
247
255
|
} else {
|
|
248
256
|
if (!(shouldUpdate || dependencies)) {
|
|
249
257
|
devWarning('Form.Item', '`children` of render props only work with `shouldUpdate` or `dependencies`.');
|
|
@@ -255,14 +263,14 @@ export const FormItem = props => {
|
|
|
255
263
|
// not render props
|
|
256
264
|
} else if (dependencies && !name) {
|
|
257
265
|
devWarning('Form.Item', 'Must set `name` or use render props when `dependencies` is set.');
|
|
258
|
-
} else if (React.isValidElement(
|
|
259
|
-
if (
|
|
266
|
+
} else if (React.isValidElement(mergedChildren)) {
|
|
267
|
+
if (mergedChildren.props.defaultValue) {
|
|
260
268
|
devWarning('Form.Item', '`defaultValue` will not work on controlled Field. You should use `initialValues` of Form instead.');
|
|
261
269
|
}
|
|
262
|
-
const childProps = Object.assign(Object.assign({},
|
|
263
|
-
if (isSafeSetRefComponent(
|
|
270
|
+
const childProps = Object.assign(Object.assign({}, mergedChildren.props), control);
|
|
271
|
+
if (isSafeSetRefComponent(mergedChildren)) {
|
|
264
272
|
childProps.ref = instance => {
|
|
265
|
-
const originRef =
|
|
273
|
+
const originRef = mergedChildren.ref;
|
|
266
274
|
if (originRef) {
|
|
267
275
|
if (typeof originRef === 'function') {
|
|
268
276
|
originRef(instance);
|
|
@@ -283,18 +291,18 @@ export const FormItem = props => {
|
|
|
283
291
|
childProps[eventName] = (...args) => {
|
|
284
292
|
var _a, _b, _c;
|
|
285
293
|
(_a = control[eventName]) === null || _a === void 0 ? void 0 : _a.call(control, ...args);
|
|
286
|
-
(_c = (_b =
|
|
294
|
+
(_c = (_b = mergedChildren.props)[eventName]) === null || _c === void 0 ? void 0 : _c.call(_b, ...args);
|
|
287
295
|
};
|
|
288
296
|
});
|
|
289
297
|
childNode = React.createElement(MemoInput, {
|
|
290
298
|
value: control[props.valuePropName || 'value'],
|
|
291
299
|
update: updateRef.current
|
|
292
|
-
}, React.cloneElement(
|
|
300
|
+
}, React.cloneElement(mergedChildren, childProps));
|
|
293
301
|
} else {
|
|
294
302
|
if (name) {
|
|
295
303
|
devWarning('Form.Item', '`name` is only used for validate React element. If you are using Form.Item as layout display, please remove `name` instead.');
|
|
296
304
|
}
|
|
297
|
-
childNode =
|
|
305
|
+
childNode = mergedChildren;
|
|
298
306
|
}
|
|
299
307
|
return renderLayout(childNode, fieldId, meta, isRequired);
|
|
300
308
|
});
|
|
@@ -4,7 +4,7 @@ export declare type FormLayout = 'vertical' | 'horizontal';
|
|
|
4
4
|
export type { FormProps, FormInstance } from './form';
|
|
5
5
|
export type { FormItemProps } from './form-item';
|
|
6
6
|
export type { FormSubscribeProps } from './form-subscribe';
|
|
7
|
-
export type { ValidateMessages, FieldData, NamePath, Rule, RuleObject, RuleRender, } from 'rc-field-form/es/interface';
|
|
7
|
+
export type { ValidateMessages, ValidateOptions, FieldData, NamePath, Rule, RuleObject, RuleRender, } from 'rc-field-form/es/interface';
|
|
8
8
|
export type { FormArrayField, FormArrayOperation, FormArrayProps, } from './form-array';
|
|
9
9
|
declare const _default: import("react").ForwardRefExoticComponent<Pick<import("rc-field-form").FormProps<any>, "form" | "children" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & {
|
|
10
10
|
className?: string | undefined;
|
|
@@ -4,7 +4,8 @@ declare type NativeInputProps = React.DetailedHTMLProps<React.InputHTMLAttribute
|
|
|
4
4
|
declare type AriaProps = {
|
|
5
5
|
role?: string;
|
|
6
6
|
};
|
|
7
|
-
export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'onPaste' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step' | 'id' | 'placeholder' | 'readOnly' | 'disabled'
|
|
7
|
+
export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'onPaste' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step' | 'id' | 'placeholder' | 'readOnly' | 'disabled'> & {
|
|
8
|
+
enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
8
9
|
value?: string;
|
|
9
10
|
defaultValue?: string;
|
|
10
11
|
onChange?: (val: string) => void;
|
|
@@ -22,7 +23,8 @@ export declare type InputRef = {
|
|
|
22
23
|
blur: () => void;
|
|
23
24
|
nativeElement: HTMLInputElement | null;
|
|
24
25
|
};
|
|
25
|
-
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "disabled" | "
|
|
26
|
+
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "disabled" | "name" | "type" | "onPaste" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "autoCapitalize" | "autoFocus" | "autoCorrect" | "inputMode" | "autoComplete" | "maxLength" | "minLength" | "placeholder" | "readOnly" | "step"> & {
|
|
27
|
+
enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined;
|
|
26
28
|
value?: string | undefined;
|
|
27
29
|
defaultValue?: string | undefined;
|
|
28
30
|
onChange?: ((val: string) => void) | undefined;
|
|
@@ -67,7 +67,7 @@ export const Input = forwardRef((props, ref) => {
|
|
|
67
67
|
})();
|
|
68
68
|
return withNativeProps(mergedProps, React.createElement("div", {
|
|
69
69
|
className: classNames(`${classPrefix}`, mergedProps.disabled && `${classPrefix}-disabled`)
|
|
70
|
-
}, React.createElement("input", {
|
|
70
|
+
}, React.createElement("input", Object.assign({
|
|
71
71
|
ref: nativeInputRef,
|
|
72
72
|
className: `${classPrefix}-element`,
|
|
73
73
|
value: value,
|
|
@@ -94,8 +94,10 @@ export const Input = forwardRef((props, ref) => {
|
|
|
94
94
|
minLength: mergedProps.minLength,
|
|
95
95
|
max: mergedProps.max,
|
|
96
96
|
min: mergedProps.min,
|
|
97
|
-
autoComplete: mergedProps.autoComplete
|
|
98
|
-
|
|
97
|
+
autoComplete: mergedProps.autoComplete
|
|
98
|
+
}, {
|
|
99
|
+
enterKeyHint: mergedProps.enterKeyHint
|
|
100
|
+
}, {
|
|
99
101
|
autoFocus: mergedProps.autoFocus,
|
|
100
102
|
pattern: mergedProps.pattern,
|
|
101
103
|
inputMode: mergedProps.inputMode,
|
|
@@ -122,7 +124,7 @@ export const Input = forwardRef((props, ref) => {
|
|
|
122
124
|
"aria-valuemax": mergedProps['aria-valuemax'],
|
|
123
125
|
"aria-valuemin": mergedProps['aria-valuemin'],
|
|
124
126
|
"aria-label": mergedProps['aria-label']
|
|
125
|
-
}), shouldShowClear && React.createElement("div", {
|
|
127
|
+
})), shouldShowClear && React.createElement("div", {
|
|
126
128
|
className: `${classPrefix}-clear`,
|
|
127
129
|
onMouseDown: e => {
|
|
128
130
|
e.preventDefault();
|
|
@@ -17,7 +17,7 @@ export const ListItem = props => {
|
|
|
17
17
|
} = useConfig();
|
|
18
18
|
const clickable = (_a = props.clickable) !== null && _a !== void 0 ? _a : !!props.onClick;
|
|
19
19
|
const showArrow = (_b = arrow !== null && arrow !== void 0 ? arrow : arrowIcon) !== null && _b !== void 0 ? _b : clickable;
|
|
20
|
-
const mergedArrowIcon = mergeProp(componentConfig.arrowIcon, arrow !== true ? arrow :
|
|
20
|
+
const mergedArrowIcon = mergeProp(componentConfig.arrowIcon, arrow !== true ? arrow : undefined, arrowIcon !== true ? arrowIcon : undefined);
|
|
21
21
|
const content = React.createElement("div", {
|
|
22
22
|
className: `${classPrefix}-content`
|
|
23
23
|
}, isNodeWithContent(props.prefix) && React.createElement("div", {
|
|
@@ -93,8 +93,9 @@ export const NoticeBar = memo(props => {
|
|
|
93
93
|
className: `${classPrefix}-right`
|
|
94
94
|
}, mergedProps.extra, mergedProps.closeable && React.createElement("div", {
|
|
95
95
|
className: `${classPrefix}-close`,
|
|
96
|
-
onClick:
|
|
96
|
+
onClick: e => {
|
|
97
97
|
var _a;
|
|
98
|
+
e.stopPropagation();
|
|
98
99
|
setVisible(false);
|
|
99
100
|
(_a = mergedProps.onClose) === null || _a === void 0 ? void 0 : _a.call(mergedProps);
|
|
100
101
|
}
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
display: inline-flex;
|
|
12
12
|
vertical-align: top;
|
|
13
13
|
}
|
|
14
|
+
.adm-passcode-input.adm-passcode-input-rtl .adm-passcode-input-cell-container {
|
|
15
|
+
flex-direction: row-reverse;
|
|
16
|
+
}
|
|
14
17
|
.adm-passcode-input-cell {
|
|
15
18
|
flex: none;
|
|
16
19
|
display: flex;
|
|
@@ -51,6 +54,18 @@
|
|
|
51
54
|
border-color: var(--adm-color-primary);
|
|
52
55
|
box-shadow: 0 0 2px 0 var(--adm-color-primary);
|
|
53
56
|
}
|
|
57
|
+
.adm-passcode-input.adm-passcode-input-rtl:not(.adm-passcode-input-seperated) .adm-passcode-input-cell:first-child {
|
|
58
|
+
border-right: none;
|
|
59
|
+
}
|
|
60
|
+
.adm-passcode-input.adm-passcode-input-rtl:not(.adm-passcode-input-seperated) .adm-passcode-input-cell:last-child {
|
|
61
|
+
border-right: 1px solid var(--border-color);
|
|
62
|
+
}
|
|
63
|
+
.adm-passcode-input.adm-passcode-input-rtl.adm-passcode-input.adm-passcode-input-seperated .adm-passcode-input-cell:first-child {
|
|
64
|
+
margin-right: 0;
|
|
65
|
+
}
|
|
66
|
+
.adm-passcode-input.adm-passcode-input-rtl.adm-passcode-input.adm-passcode-input-seperated .adm-passcode-input-cell:last-child {
|
|
67
|
+
margin-right: var(--cell-gap);
|
|
68
|
+
}
|
|
54
69
|
.adm-passcode-input-seperated.adm-passcode-input-focused {
|
|
55
70
|
outline: none;
|
|
56
71
|
}
|
|
@@ -12,6 +12,7 @@ export declare type PasscodeInputProps = {
|
|
|
12
12
|
seperated?: boolean;
|
|
13
13
|
keyboard?: ReactElement<NumberKeyboardProps>;
|
|
14
14
|
inputMode?: 'numeric' | 'text';
|
|
15
|
+
direction?: 'ltr' | 'rtl';
|
|
15
16
|
onBlur?: () => void;
|
|
16
17
|
onFocus?: () => void;
|
|
17
18
|
onChange?: (val: string) => void;
|
|
@@ -31,6 +32,7 @@ export declare const PasscodeInput: React.ForwardRefExoticComponent<{
|
|
|
31
32
|
seperated?: boolean | undefined;
|
|
32
33
|
keyboard?: ReactElement<NumberKeyboardProps, string | React.JSXElementConstructor<any>> | undefined;
|
|
33
34
|
inputMode?: "text" | "numeric" | undefined;
|
|
35
|
+
direction?: "ltr" | "rtl" | undefined;
|
|
34
36
|
onBlur?: (() => void) | undefined;
|
|
35
37
|
onFocus?: (() => void) | undefined;
|
|
36
38
|
onChange?: ((val: string) => void) | undefined;
|
|
@@ -13,7 +13,8 @@ const defaultProps = {
|
|
|
13
13
|
error: false,
|
|
14
14
|
seperated: false,
|
|
15
15
|
caret: true,
|
|
16
|
-
inputMode: 'numeric'
|
|
16
|
+
inputMode: 'numeric',
|
|
17
|
+
direction: 'ltr'
|
|
17
18
|
};
|
|
18
19
|
export const PasscodeInput = forwardRef((p, ref) => {
|
|
19
20
|
const props = mergeProps(defaultProps, p);
|
|
@@ -70,10 +71,11 @@ export const PasscodeInput = forwardRef((p, ref) => {
|
|
|
70
71
|
(_b = nativeInputRef.current) === null || _b === void 0 ? void 0 : _b.blur();
|
|
71
72
|
}
|
|
72
73
|
}));
|
|
74
|
+
const isRTL = props.direction === 'rtl';
|
|
73
75
|
const renderCells = () => {
|
|
74
76
|
const cells = [];
|
|
75
77
|
const chars = value.split('');
|
|
76
|
-
const caretIndex = chars.length;
|
|
78
|
+
const caretIndex = chars.length;
|
|
77
79
|
const focusedIndex = bound(chars.length, 0, cellLength - 1);
|
|
78
80
|
for (let i = 0; i < cellLength; i++) {
|
|
79
81
|
cells.push(React.createElement("div", {
|
|
@@ -90,7 +92,8 @@ export const PasscodeInput = forwardRef((p, ref) => {
|
|
|
90
92
|
const cls = classNames(classPrefix, {
|
|
91
93
|
[`${classPrefix}-focused`]: focused,
|
|
92
94
|
[`${classPrefix}-error`]: props.error,
|
|
93
|
-
[`${classPrefix}-seperated`]: props.seperated
|
|
95
|
+
[`${classPrefix}-seperated`]: props.seperated,
|
|
96
|
+
[`${classPrefix}-rtl`]: isRTL
|
|
94
97
|
});
|
|
95
98
|
return React.createElement(React.Fragment, null, withNativeProps(props, React.createElement("div", {
|
|
96
99
|
ref: rootRef,
|
|
@@ -12,6 +12,7 @@ import { mergeProps } from '../../utils/with-default-props';
|
|
|
12
12
|
import { withStopPropagation } from '../../utils/with-stop-propagation';
|
|
13
13
|
import { Arrow } from './arrow';
|
|
14
14
|
import { normalizePlacement } from './normalize-placement';
|
|
15
|
+
import { useShowingGuard } from './use-showing-guard';
|
|
15
16
|
import { Wrapper } from './wrapper';
|
|
16
17
|
const classPrefix = `adm-popover`;
|
|
17
18
|
const defaultProps = {
|
|
@@ -29,8 +30,16 @@ export const Popover = forwardRef((p, ref) => {
|
|
|
29
30
|
defaultValue: props.defaultVisible,
|
|
30
31
|
onChange: props.onVisibleChange
|
|
31
32
|
});
|
|
33
|
+
const {
|
|
34
|
+
markShowing,
|
|
35
|
+
isShowing
|
|
36
|
+
} = useShowingGuard();
|
|
32
37
|
useImperativeHandle(ref, () => ({
|
|
33
|
-
show: () =>
|
|
38
|
+
show: () => {
|
|
39
|
+
// 标记进入 show() 触发链,避免同一次点击事件冒泡到 document 时被 useClickAway 立即关闭
|
|
40
|
+
markShowing();
|
|
41
|
+
setVisible(true);
|
|
42
|
+
},
|
|
34
43
|
hide: () => setVisible(false),
|
|
35
44
|
visible
|
|
36
45
|
}), [visible]);
|
|
@@ -131,6 +140,7 @@ export const Popover = forwardRef((p, ref) => {
|
|
|
131
140
|
}, [targetElement, visible]);
|
|
132
141
|
useClickAway(() => {
|
|
133
142
|
if (!props.trigger) return;
|
|
143
|
+
if (isShowing()) return; // 跳过 show() 触发链上的 click-away
|
|
134
144
|
setVisible(false);
|
|
135
145
|
}, [() => {
|
|
136
146
|
var _a;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 保证通过 `ref.show()` 打开的 Popover 不会被同一次交互立即关闭。
|
|
3
|
+
*
|
|
4
|
+
* 当外部元素的点击回调调用 `ref.show()` 时,当前点击事件仍会继续冒泡到
|
|
5
|
+
* document,并触发 `useClickAway`。因此需要在当前事件任务结束前保持 guarding
|
|
6
|
+
* 状态,让 click-away 跳过这一次关闭;进入下一个任务后再解除 guarding,保证
|
|
7
|
+
* 后续的外部点击仍能正常关闭 Popover。
|
|
8
|
+
*/
|
|
9
|
+
export declare function useShowingGuard(): {
|
|
10
|
+
markShowing: () => void;
|
|
11
|
+
isShowing: () => boolean;
|
|
12
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* 保证通过 `ref.show()` 打开的 Popover 不会被同一次交互立即关闭。
|
|
4
|
+
*
|
|
5
|
+
* 当外部元素的点击回调调用 `ref.show()` 时,当前点击事件仍会继续冒泡到
|
|
6
|
+
* document,并触发 `useClickAway`。因此需要在当前事件任务结束前保持 guarding
|
|
7
|
+
* 状态,让 click-away 跳过这一次关闭;进入下一个任务后再解除 guarding,保证
|
|
8
|
+
* 后续的外部点击仍能正常关闭 Popover。
|
|
9
|
+
*/
|
|
10
|
+
export function useShowingGuard() {
|
|
11
|
+
const showingRef = useRef(false);
|
|
12
|
+
const timerRef = useRef();
|
|
13
|
+
const markShowing = () => {
|
|
14
|
+
// 使用 ref 而不是 state,确保同一次事件冒泡到 document 时可以同步读取到标记。
|
|
15
|
+
showingRef.current = true;
|
|
16
|
+
// 连续调用 show() 时重置保护窗口,避免旧定时器提前清除最新一次的标记。
|
|
17
|
+
clearTimeout(timerRef.current);
|
|
18
|
+
timerRef.current = setTimeout(() => {
|
|
19
|
+
// 定时器会在当前事件任务完成后执行,此时可以恢复正常的 click-away 行为。
|
|
20
|
+
showingRef.current = false;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const isShowing = () => showingRef.current;
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
return () => {
|
|
26
|
+
// 组件卸载后不再需要更新 guarding 标记,同时清理未执行的定时器。
|
|
27
|
+
clearTimeout(timerRef.current);
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
return {
|
|
31
|
+
markShowing,
|
|
32
|
+
isShowing
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -27,7 +27,6 @@ export const SearchBar = forwardRef((props, ref) => {
|
|
|
27
27
|
const [value, setValue] = usePropsValue(mergedProps);
|
|
28
28
|
const [hasFocus, setHasFocus] = useState(false);
|
|
29
29
|
const inputRef = useRef(null);
|
|
30
|
-
const composingRef = useRef(false);
|
|
31
30
|
useImperativeHandle(ref, () => ({
|
|
32
31
|
clear: () => {
|
|
33
32
|
var _a;
|
|
@@ -104,9 +103,11 @@ export const SearchBar = forwardRef((props, ref) => {
|
|
|
104
103
|
onClear: mergedProps.onClear,
|
|
105
104
|
type: 'search',
|
|
106
105
|
enterKeyHint: 'search',
|
|
107
|
-
onEnterPress:
|
|
106
|
+
onEnterPress: e => {
|
|
108
107
|
var _a, _b;
|
|
109
|
-
|
|
108
|
+
// Use nativeEvent.isComposing to check IME composition state
|
|
109
|
+
// This is more reliable than maintaining a manual ref
|
|
110
|
+
if (!e.nativeEvent.isComposing) {
|
|
110
111
|
(_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur();
|
|
111
112
|
(_b = mergedProps.onSearch) === null || _b === void 0 ? void 0 : _b.call(mergedProps, value);
|
|
112
113
|
}
|
|
@@ -114,12 +115,10 @@ export const SearchBar = forwardRef((props, ref) => {
|
|
|
114
115
|
"aria-label": locale.SearchBar.name,
|
|
115
116
|
onCompositionStart: e => {
|
|
116
117
|
var _a;
|
|
117
|
-
composingRef.current = true;
|
|
118
118
|
(_a = mergedProps.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
|
|
119
119
|
},
|
|
120
120
|
onCompositionEnd: e => {
|
|
121
121
|
var _a;
|
|
122
|
-
composingRef.current = false;
|
|
123
122
|
(_a = mergedProps.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(mergedProps, e);
|
|
124
123
|
}
|
|
125
124
|
})), renderCancelButton()));
|
|
@@ -46,6 +46,19 @@ export const SwipeAction = forwardRef((p, ref) => {
|
|
|
46
46
|
(_a = dragCancelRef.current) === null || _a === void 0 ? void 0 : _a.call(dragCancelRef);
|
|
47
47
|
draggingRef.current = false;
|
|
48
48
|
}
|
|
49
|
+
function open(side) {
|
|
50
|
+
var _a;
|
|
51
|
+
if (side === 'right') {
|
|
52
|
+
api.start({
|
|
53
|
+
x: -getRightWidth()
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
api.start({
|
|
57
|
+
x: getLeftWidth()
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
(_a = p.onActionsReveal) === null || _a === void 0 ? void 0 : _a.call(p, side);
|
|
61
|
+
}
|
|
49
62
|
const bind = useDrag(state => {
|
|
50
63
|
var _a;
|
|
51
64
|
dragCancelRef.current = state.cancel;
|
|
@@ -109,36 +122,33 @@ export const SwipeAction = forwardRef((p, ref) => {
|
|
|
109
122
|
};
|
|
110
123
|
useImperativeHandle(ref, () => ({
|
|
111
124
|
show: (side = 'right') => {
|
|
112
|
-
|
|
113
|
-
if (side === 'right') {
|
|
114
|
-
api.start({
|
|
115
|
-
x: -getRightWidth()
|
|
116
|
-
});
|
|
117
|
-
} else if (side === 'left') {
|
|
118
|
-
api.start({
|
|
119
|
-
x: getLeftWidth()
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
(_a = p.onActionsReveal) === null || _a === void 0 ? void 0 : _a.call(p, side);
|
|
125
|
+
open(side);
|
|
123
126
|
},
|
|
124
127
|
close
|
|
125
128
|
}));
|
|
126
129
|
useEffect(() => {
|
|
127
130
|
if (!props.closeOnTouchOutside) return;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
+
const root = rootRef.current;
|
|
132
|
+
if (!root) return;
|
|
133
|
+
function onTouchOutside(e) {
|
|
134
|
+
if (x.goal === 0) return;
|
|
135
|
+
if (!(root === null || root === void 0 ? void 0 : root.contains(e.target))) {
|
|
136
|
+
close();
|
|
131
137
|
}
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
}
|
|
139
|
+
function onFocusOutside(e) {
|
|
140
|
+
if (x.goal === 0) return;
|
|
141
|
+
if (!(root === null || root === void 0 ? void 0 : root.contains(e.relatedTarget))) {
|
|
134
142
|
close();
|
|
135
143
|
}
|
|
136
144
|
}
|
|
137
|
-
document.addEventListener('touchstart',
|
|
145
|
+
document.addEventListener('touchstart', onTouchOutside);
|
|
146
|
+
root.addEventListener('focusout', onFocusOutside);
|
|
138
147
|
return () => {
|
|
139
|
-
document.removeEventListener('touchstart',
|
|
148
|
+
document.removeEventListener('touchstart', onTouchOutside);
|
|
149
|
+
root.removeEventListener('focusout', onFocusOutside);
|
|
140
150
|
};
|
|
141
|
-
}, [props.closeOnTouchOutside]);
|
|
151
|
+
}, [props.closeOnTouchOutside, props.onClose]);
|
|
142
152
|
function renderAction(action) {
|
|
143
153
|
var _a, _b;
|
|
144
154
|
const color = (_a = action.color) !== null && _a !== void 0 ? _a : 'light';
|
|
@@ -175,7 +185,10 @@ export const SwipeAction = forwardRef((p, ref) => {
|
|
|
175
185
|
}
|
|
176
186
|
}, withStopPropagation(props.stopPropagation, React.createElement("div", {
|
|
177
187
|
className: `${classPrefix}-actions ${classPrefix}-actions-left`,
|
|
178
|
-
ref: leftRef
|
|
188
|
+
ref: leftRef,
|
|
189
|
+
onFocus: () => {
|
|
190
|
+
if (x.goal !== getLeftWidth()) open('left');
|
|
191
|
+
}
|
|
179
192
|
}, props.leftActions.map(renderAction))), React.createElement("div", {
|
|
180
193
|
className: `${classPrefix}-content`,
|
|
181
194
|
onClickCapture: e => {
|
|
@@ -191,7 +204,10 @@ export const SwipeAction = forwardRef((p, ref) => {
|
|
|
191
204
|
}
|
|
192
205
|
}, props.children)), withStopPropagation(props.stopPropagation, React.createElement("div", {
|
|
193
206
|
className: `${classPrefix}-actions ${classPrefix}-actions-right`,
|
|
194
|
-
ref: rightRef
|
|
207
|
+
ref: rightRef,
|
|
208
|
+
onFocus: () => {
|
|
209
|
+
if (x.goal !== -getRightWidth()) open('right');
|
|
210
|
+
}
|
|
195
211
|
}, props.rightActions.map(renderAction))))));
|
|
196
212
|
});
|
|
197
213
|
const colorRecord = {
|
|
@@ -7,7 +7,9 @@ declare const _default: import("react").ForwardRefExoticComponent<{
|
|
|
7
7
|
autoplayInterval?: number | undefined;
|
|
8
8
|
loop?: boolean | undefined;
|
|
9
9
|
direction?: "vertical" | "horizontal" | undefined;
|
|
10
|
-
onIndexChange?: ((index: number
|
|
10
|
+
onIndexChange?: ((index: number, info: {
|
|
11
|
+
source: import("./swiper").SwiperIndexChangeSource;
|
|
12
|
+
}) => void) | undefined;
|
|
11
13
|
indicatorProps?: Pick<import("../page-indicator").PageIndicatorProps, "style" | "className" | "color"> | undefined;
|
|
12
14
|
indicator?: false | ((total: number, current: number) => import("react").ReactNode) | undefined;
|
|
13
15
|
slideSize?: number | undefined;
|
|
@@ -13,6 +13,7 @@ export declare type SwiperRef = {
|
|
|
13
13
|
swipeNext: () => void;
|
|
14
14
|
swipePrev: () => void;
|
|
15
15
|
};
|
|
16
|
+
export declare type SwiperIndexChangeSource = 'auto' | 'swipe' | 'resize';
|
|
16
17
|
export declare type SwiperProps = {
|
|
17
18
|
defaultIndex?: number;
|
|
18
19
|
allowTouchMove?: boolean;
|
|
@@ -20,7 +21,9 @@ export declare type SwiperProps = {
|
|
|
20
21
|
autoplayInterval?: number;
|
|
21
22
|
loop?: boolean;
|
|
22
23
|
direction?: 'horizontal' | 'vertical';
|
|
23
|
-
onIndexChange?: (index: number
|
|
24
|
+
onIndexChange?: (index: number, info: {
|
|
25
|
+
source: SwiperIndexChangeSource;
|
|
26
|
+
}) => void;
|
|
24
27
|
indicatorProps?: Pick<PageIndicatorProps, 'color' | 'style' | 'className'>;
|
|
25
28
|
indicator?: false | ((total: number, current: number) => ReactNode);
|
|
26
29
|
slideSize?: number;
|
|
@@ -44,7 +47,9 @@ export declare const Swiper: React.ForwardRefExoticComponent<{
|
|
|
44
47
|
autoplayInterval?: number | undefined;
|
|
45
48
|
loop?: boolean | undefined;
|
|
46
49
|
direction?: "vertical" | "horizontal" | undefined;
|
|
47
|
-
onIndexChange?: ((index: number
|
|
50
|
+
onIndexChange?: ((index: number, info: {
|
|
51
|
+
source: SwiperIndexChangeSource;
|
|
52
|
+
}) => void) | undefined;
|
|
48
53
|
indicatorProps?: Pick<PageIndicatorProps, "style" | "className" | "color"> | undefined;
|
|
49
54
|
indicator?: false | ((total: number, current: number) => ReactNode) | undefined;
|
|
50
55
|
slideSize?: number | undefined;
|
|
@@ -65,4 +70,6 @@ export declare const Swiper: React.ForwardRefExoticComponent<{
|
|
|
65
70
|
style?: (CSSProperties & Partial<Record<"--width" | "--height" | "--border-radius" | "--track-padding", string>>) | undefined;
|
|
66
71
|
tabIndex?: number | undefined;
|
|
67
72
|
} & React.AriaAttributes & React.RefAttributes<SwiperRef>>;
|
|
73
|
+
export declare function modulus(value: number, division: number): number;
|
|
74
|
+
export declare function getSwipeToPosition(current: number, targetIndex: number, total: number): number;
|
|
68
75
|
export {};
|
|
@@ -44,7 +44,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
44
44
|
const [uid] = useState({});
|
|
45
45
|
const timeoutRef = useRef(null);
|
|
46
46
|
const isVertical = direction === 'vertical';
|
|
47
|
-
const slideRatio = props.slideSize / 100;
|
|
47
|
+
const slideRatio = Math.max(props.slideSize, 1) / 100;
|
|
48
48
|
const offsetRatio = props.trackOffset / 100;
|
|
49
49
|
const {
|
|
50
50
|
validChildren,
|
|
@@ -153,7 +153,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
153
153
|
const minIndex = Math.floor(offset / slidePixels);
|
|
154
154
|
const maxIndex = minIndex + 1;
|
|
155
155
|
const index = Math.round((offset + velocity * 2000 * direction) / slidePixels);
|
|
156
|
-
swipeTo(bound(index, minIndex, maxIndex));
|
|
156
|
+
swipeTo(bound(index, minIndex, maxIndex), 'swipe', false);
|
|
157
157
|
window.setTimeout(() => {
|
|
158
158
|
setDragging(false);
|
|
159
159
|
});
|
|
@@ -185,34 +185,43 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
185
185
|
touch: true
|
|
186
186
|
}
|
|
187
187
|
});
|
|
188
|
-
function swipeTo(index, immediate = false) {
|
|
188
|
+
function swipeTo(index, source = 'swipe', immediate = false) {
|
|
189
189
|
var _a;
|
|
190
190
|
const roundedIndex = Math.round(index);
|
|
191
191
|
const targetIndex = loop ? modulus(roundedIndex, mergedTotal) : bound(roundedIndex, 0, mergedTotal - 1);
|
|
192
192
|
if (targetIndex !== getCurrent()) {
|
|
193
|
-
(_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, targetIndex
|
|
193
|
+
(_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, targetIndex, {
|
|
194
|
+
source
|
|
195
|
+
});
|
|
194
196
|
}
|
|
195
197
|
setCurrent(targetIndex);
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
198
|
+
if (loop) {
|
|
199
|
+
api.start({
|
|
200
|
+
position: getSwipeToPosition(position.get(), roundedIndex, mergedTotal),
|
|
201
|
+
immediate
|
|
202
|
+
});
|
|
203
|
+
} else {
|
|
204
|
+
api.start({
|
|
205
|
+
position: boundIndex(roundedIndex) * 100,
|
|
206
|
+
immediate
|
|
207
|
+
});
|
|
208
|
+
}
|
|
200
209
|
}
|
|
201
|
-
function swipeNext() {
|
|
202
|
-
swipeTo(Math.round(position.get() / 100) + 1);
|
|
210
|
+
function swipeNext(source = 'swipe') {
|
|
211
|
+
swipeTo(Math.round(position.get() / 100) + 1, source, false);
|
|
203
212
|
}
|
|
204
|
-
function swipePrev() {
|
|
205
|
-
swipeTo(Math.round(position.get() / 100) - 1);
|
|
213
|
+
function swipePrev(source = 'swipe') {
|
|
214
|
+
swipeTo(Math.round(position.get() / 100) - 1, source, false);
|
|
206
215
|
}
|
|
207
216
|
useImperativeHandle(ref, () => ({
|
|
208
|
-
swipeTo,
|
|
217
|
+
swipeTo: index => swipeTo(index, 'swipe', false),
|
|
209
218
|
swipeNext,
|
|
210
219
|
swipePrev
|
|
211
220
|
}));
|
|
212
221
|
useIsomorphicLayoutEffect(() => {
|
|
213
222
|
const maxIndex = mergedTotal - 1;
|
|
214
223
|
if (current > maxIndex) {
|
|
215
|
-
swipeTo(maxIndex, true);
|
|
224
|
+
swipeTo(maxIndex, 'resize', true);
|
|
216
225
|
}
|
|
217
226
|
});
|
|
218
227
|
const {
|
|
@@ -222,9 +231,9 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
222
231
|
const runTimeSwiper = () => {
|
|
223
232
|
timeoutRef.current = window.setTimeout(() => {
|
|
224
233
|
if (autoplay === 'reverse') {
|
|
225
|
-
swipePrev();
|
|
234
|
+
swipePrev('auto');
|
|
226
235
|
} else {
|
|
227
|
-
swipeNext();
|
|
236
|
+
swipeNext('auto');
|
|
228
237
|
}
|
|
229
238
|
runTimeSwiper();
|
|
230
239
|
}, autoplayInterval);
|
|
@@ -241,11 +250,12 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
241
250
|
function renderItem(index, child, key) {
|
|
242
251
|
let itemStyle = {};
|
|
243
252
|
if (loop) {
|
|
253
|
+
// 计算循环模式下定位所需的常量,避免在动画回调中重复计算
|
|
254
|
+
const totalWidth = mergedTotal * 100;
|
|
255
|
+
const flagWidth = Math.min(totalWidth / 2, (offsetRatio / slideRatio + 1) * 100);
|
|
244
256
|
itemStyle = {
|
|
245
257
|
[isVertical ? 'y' : 'x']: position.to(position => {
|
|
246
258
|
let finalPosition = -position + index * 100;
|
|
247
|
-
const totalWidth = mergedTotal * 100;
|
|
248
|
-
const flagWidth = totalWidth / 2;
|
|
249
259
|
finalPosition = modulus(finalPosition + flagWidth, totalWidth) - flagWidth;
|
|
250
260
|
return `${finalPosition}%`;
|
|
251
261
|
}),
|
|
@@ -345,7 +355,13 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
345
355
|
}, mergedProps), renderTrackInner()), indicatorNode));
|
|
346
356
|
};
|
|
347
357
|
}));
|
|
348
|
-
function modulus(value, division) {
|
|
358
|
+
export function modulus(value, division) {
|
|
349
359
|
const remainder = value % division;
|
|
350
360
|
return remainder < 0 ? remainder + division : remainder;
|
|
361
|
+
}
|
|
362
|
+
export function getSwipeToPosition(current, targetIndex, total) {
|
|
363
|
+
const totalWidth = 100 * total;
|
|
364
|
+
let delta = modulus(targetIndex * 100 - current, totalWidth);
|
|
365
|
+
if (delta > totalWidth / 2) delta -= totalWidth;
|
|
366
|
+
return current + delta;
|
|
351
367
|
}
|
|
@@ -23,7 +23,7 @@ export declare type TextAreaRef = {
|
|
|
23
23
|
blur: () => void;
|
|
24
24
|
nativeElement: HTMLTextAreaElement | null;
|
|
25
25
|
};
|
|
26
|
-
export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "onClick" | "disabled" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "autoFocus" | "
|
|
26
|
+
export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "onClick" | "disabled" | "name" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "autoFocus" | "autoComplete" | "readOnly"> & {
|
|
27
27
|
onChange?: ((val: string) => void) | undefined;
|
|
28
28
|
value?: string | undefined;
|
|
29
29
|
defaultValue?: string | undefined;
|