antd-mobile 5.0.0-rc.25 → 5.0.0-rc.26
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/cjs/components/button/button.css +2 -2
- package/2x/cjs/components/calendar/calendar.js +3 -1
- package/2x/cjs/components/ellipsis/ellipsis.js +3 -1
- package/2x/cjs/components/floating-panel/floating-panel.d.ts +7 -5
- package/2x/cjs/components/floating-panel/floating-panel.js +11 -1
- package/2x/cjs/components/form/form-item.d.ts +1 -1
- package/2x/cjs/components/image-uploader/image-uploader.js +1 -1
- package/2x/cjs/components/image-viewer/image-viewer.js +12 -2
- package/2x/cjs/components/image-viewer/slide.js +2 -1
- package/2x/cjs/components/image-viewer/slides.d.ts +1 -1
- package/2x/cjs/components/input/input.js +4 -2
- package/2x/cjs/components/picker-view/wheel.js +4 -2
- package/2x/cjs/components/selector/selector.css +14 -6
- package/2x/cjs/components/selector/selector.d.ts +2 -1
- package/2x/cjs/components/selector/selector.js +3 -2
- package/2x/cjs/components/swiper/swiper.js +1 -1
- package/2x/cjs/components/tabs/tabs.js +2 -2
- package/2x/cjs/components/virtual-input/virtual-input.js +3 -1
- package/2x/cjs/utils/get-scroll-parent.js +1 -1
- package/2x/cjs/utils/use-ref-state.js +1 -1
- package/2x/cjs/utils/use-resize-effect.js +1 -3
- package/2x/cjs/utils/use-tab-list-scroll.js +1 -3
- package/2x/es/components/button/button.css +2 -2
- package/2x/es/components/calendar/calendar.js +3 -2
- package/2x/es/components/ellipsis/ellipsis.js +3 -2
- package/2x/es/components/floating-panel/floating-panel.d.ts +7 -5
- package/2x/es/components/floating-panel/floating-panel.js +9 -1
- package/2x/es/components/form/form-item.d.ts +1 -1
- package/2x/es/components/image-uploader/image-uploader.js +3 -3
- package/2x/es/components/image-viewer/image-viewer.js +13 -3
- package/2x/es/components/image-viewer/slide.js +2 -1
- package/2x/es/components/image-viewer/slides.d.ts +1 -1
- package/2x/es/components/input/input.js +4 -3
- package/2x/es/components/picker-view/wheel.js +4 -3
- package/2x/es/components/selector/selector.css +14 -6
- package/2x/es/components/selector/selector.d.ts +2 -1
- package/2x/es/components/selector/selector.js +3 -2
- package/2x/es/components/swiper/swiper.js +3 -3
- package/2x/es/components/tabs/tabs.js +4 -4
- package/2x/es/components/virtual-input/virtual-input.js +3 -2
- package/2x/es/utils/get-scroll-parent.js +1 -1
- package/2x/es/utils/use-ref-state.js +2 -2
- package/2x/es/utils/use-resize-effect.js +2 -3
- package/2x/es/utils/use-tab-list-scroll.js +2 -3
- package/2x/package.json +3 -3
- package/cjs/components/button/button.css +2 -2
- package/cjs/components/calendar/calendar.js +3 -1
- package/cjs/components/ellipsis/ellipsis.js +3 -1
- package/cjs/components/floating-panel/floating-panel.d.ts +7 -5
- package/cjs/components/floating-panel/floating-panel.js +11 -1
- package/cjs/components/form/form-item.d.ts +1 -1
- package/cjs/components/image-uploader/image-uploader.js +1 -1
- package/cjs/components/image-viewer/image-viewer.js +12 -2
- package/cjs/components/image-viewer/slide.js +2 -1
- package/cjs/components/image-viewer/slides.d.ts +1 -1
- package/cjs/components/input/input.js +4 -2
- package/cjs/components/picker-view/wheel.js +4 -2
- package/cjs/components/selector/selector.css +14 -6
- package/cjs/components/selector/selector.d.ts +2 -1
- package/cjs/components/selector/selector.js +3 -2
- package/cjs/components/swiper/swiper.js +1 -1
- package/cjs/components/tabs/tabs.js +2 -2
- package/cjs/components/virtual-input/virtual-input.js +3 -1
- package/cjs/utils/get-scroll-parent.js +1 -1
- package/cjs/utils/use-ref-state.js +1 -1
- package/cjs/utils/use-resize-effect.js +1 -3
- package/cjs/utils/use-tab-list-scroll.js +1 -3
- package/es/components/button/button.css +2 -2
- package/es/components/calendar/calendar.js +3 -2
- package/es/components/ellipsis/ellipsis.js +3 -2
- package/es/components/floating-panel/floating-panel.d.ts +7 -5
- package/es/components/floating-panel/floating-panel.js +9 -1
- package/es/components/form/form-item.d.ts +1 -1
- package/es/components/image-uploader/image-uploader.js +3 -3
- package/es/components/image-viewer/image-viewer.js +13 -3
- package/es/components/image-viewer/slide.js +2 -1
- package/es/components/image-viewer/slides.d.ts +1 -1
- package/es/components/input/input.js +4 -3
- package/es/components/picker-view/wheel.js +4 -3
- package/es/components/selector/selector.css +14 -6
- package/es/components/selector/selector.d.ts +2 -1
- package/es/components/selector/selector.js +3 -2
- package/es/components/swiper/swiper.js +3 -3
- package/es/components/tabs/tabs.js +4 -4
- package/es/components/virtual-input/virtual-input.js +3 -2
- package/es/utils/get-scroll-parent.js +1 -1
- package/es/utils/use-ref-state.js +2 -2
- package/es/utils/use-resize-effect.js +2 -3
- package/es/utils/use-tab-list-scroll.js +2 -3
- package/package.json +3 -3
- package/umd/antd-mobile.js +1 -1
|
@@ -10,7 +10,7 @@ var _react = require("react");
|
|
|
10
10
|
function useRefState(initialState) {
|
|
11
11
|
const [state, setState] = (0, _react.useState)(initialState);
|
|
12
12
|
const ref = (0, _react.useRef)(state);
|
|
13
|
-
(0, _react.
|
|
13
|
+
(0, _react.useEffect)(() => {
|
|
14
14
|
ref.current = state;
|
|
15
15
|
}, [state]);
|
|
16
16
|
return [state, setState, ref];
|
|
@@ -5,13 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useResizeEffect = useResizeEffect;
|
|
7
7
|
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _ahooks = require("ahooks");
|
|
11
9
|
|
|
12
10
|
function useResizeEffect(effect, targetRef) {
|
|
13
11
|
const fn = (0, _ahooks.useMemoizedFn)(effect);
|
|
14
|
-
(0,
|
|
12
|
+
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
15
13
|
const target = targetRef.current;
|
|
16
14
|
if (!target) return;
|
|
17
15
|
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useTabListScroll = void 0;
|
|
7
7
|
|
|
8
|
-
var _react = require("react");
|
|
9
|
-
|
|
10
8
|
var _web = require("@react-spring/web");
|
|
11
9
|
|
|
12
10
|
var _useMutationEffect = require("./use-mutation-effect");
|
|
@@ -49,7 +47,7 @@ const useTabListScroll = (targetRef, activeIndex) => {
|
|
|
49
47
|
});
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
(0,
|
|
50
|
+
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
53
51
|
animate(true);
|
|
54
52
|
}, []);
|
|
55
53
|
(0, _ahooks.useUpdateLayoutEffect)(() => {
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
display: inline-block;
|
|
13
13
|
box-sizing: border-box;
|
|
14
14
|
height: auto;
|
|
15
|
-
padding:
|
|
15
|
+
padding: 7px 12px;
|
|
16
16
|
margin: 0;
|
|
17
|
-
font-size:
|
|
17
|
+
font-size: 17px;
|
|
18
18
|
line-height: 1.4;
|
|
19
19
|
text-align: center;
|
|
20
20
|
border: var(--border-width) var(--border-style) var(--border-color);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useMemo, useState } from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -7,6 +7,7 @@ import { ArrowLeft } from './arrow-left';
|
|
|
7
7
|
import { ArrowLeftDouble } from './arrow-left-double';
|
|
8
8
|
import { useConfig } from '../config-provider';
|
|
9
9
|
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
10
|
+
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
10
11
|
dayjs.extend(isoWeek);
|
|
11
12
|
const classPrefix = 'adm-calendar';
|
|
12
13
|
const defaultProps = {
|
|
@@ -65,7 +66,7 @@ export const Calendar = p => {
|
|
|
65
66
|
}, [props.selectionMode, props.value, props.defaultValue]);
|
|
66
67
|
const [begin, setBegin] = useState(null);
|
|
67
68
|
const [end, setEnd] = useState(null);
|
|
68
|
-
|
|
69
|
+
useIsomorphicLayoutEffect(() => {
|
|
69
70
|
setBegin(dateRange[0] ? dayjs(dateRange[0]) : null);
|
|
70
71
|
setEnd(dateRange[1] ? dayjs(dateRange[1]) : null);
|
|
71
72
|
}, [dateRange[0], dateRange[1]]);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useRef, useState } from 'react';
|
|
2
2
|
import { mergeProps } from '../../utils/with-default-props';
|
|
3
3
|
import { withNativeProps } from '../../utils/native-props';
|
|
4
4
|
import { useResizeEffect } from '../../utils/use-resize-effect';
|
|
5
|
+
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
5
6
|
const classPrefix = `adm-ellipsis`;
|
|
6
7
|
const defaultProps = {
|
|
7
8
|
direction: 'end',
|
|
@@ -113,7 +114,7 @@ export const Ellipsis = p => {
|
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
useResizeEffect(calcEllipsised, rootRef);
|
|
116
|
-
|
|
117
|
+
useIsomorphicLayoutEffect(() => {
|
|
117
118
|
calcEllipsised();
|
|
118
119
|
}, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
|
|
119
120
|
const expandActionElement = exceeded && props.expandText ? React.createElement("a", {
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
|
-
export declare type FloatingPanelProps = {
|
|
4
|
-
anchors: number[];
|
|
5
|
-
children: ReactNode;
|
|
6
|
-
onHeightChange?: (height: number, animating: boolean) => void;
|
|
7
|
-
} & NativeProps<'--border-radius' | '--z-index'>;
|
|
8
3
|
export declare type FloatingPanelRef = {
|
|
9
4
|
setHeight: (height: number, options?: {
|
|
10
5
|
immediate?: boolean;
|
|
11
6
|
}) => void;
|
|
12
7
|
};
|
|
8
|
+
export declare type FloatingPanelProps = {
|
|
9
|
+
anchors: number[];
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
onHeightChange?: (height: number, animating: boolean) => void;
|
|
12
|
+
handleDraggingOfContent?: boolean;
|
|
13
|
+
} & NativeProps<'--border-radius' | '--z-index'>;
|
|
13
14
|
export declare const FloatingPanel: React.ForwardRefExoticComponent<{
|
|
14
15
|
anchors: number[];
|
|
15
16
|
children: ReactNode;
|
|
16
17
|
onHeightChange?: ((height: number, animating: boolean) => void) | undefined;
|
|
18
|
+
handleDraggingOfContent?: boolean | undefined;
|
|
17
19
|
} & NativeProps<"--z-index" | "--border-radius"> & React.RefAttributes<FloatingPanelRef>>;
|
|
@@ -4,9 +4,15 @@ import { useDrag } from '@use-gesture/react';
|
|
|
4
4
|
import { useSpring, animated } from '@react-spring/web';
|
|
5
5
|
import { supportsPassive } from '../../utils/supports-passive';
|
|
6
6
|
import { nearest } from '../../utils/nearest';
|
|
7
|
-
|
|
7
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
8
|
+
import { useLockScroll } from '../../utils/use-lock-scroll';
|
|
9
|
+
const defaultProps = {
|
|
10
|
+
handleDraggingOfContent: true
|
|
11
|
+
};
|
|
12
|
+
export const FloatingPanel = forwardRef((p, ref) => {
|
|
8
13
|
var _a;
|
|
9
14
|
|
|
15
|
+
const props = mergeProps(defaultProps, p);
|
|
10
16
|
const {
|
|
11
17
|
anchors
|
|
12
18
|
} = props;
|
|
@@ -44,6 +50,7 @@ export const FloatingPanel = forwardRef((props, ref) => {
|
|
|
44
50
|
if (header === target || (header === null || header === void 0 ? void 0 : header.contains(target))) {
|
|
45
51
|
pullingRef.current = true;
|
|
46
52
|
} else {
|
|
53
|
+
if (!props.handleDraggingOfContent) return;
|
|
47
54
|
const reachedTop = y.goal <= bounds.top;
|
|
48
55
|
const content = contentRef.current;
|
|
49
56
|
if (!content) return;
|
|
@@ -101,6 +108,7 @@ export const FloatingPanel = forwardRef((props, ref) => {
|
|
|
101
108
|
});
|
|
102
109
|
}
|
|
103
110
|
}), [api]);
|
|
111
|
+
useLockScroll(elementRef, true);
|
|
104
112
|
return withNativeProps(props, React.createElement(animated.div, {
|
|
105
113
|
ref: elementRef,
|
|
106
114
|
className: 'adm-floating-panel',
|
|
@@ -7,7 +7,7 @@ import type { FormLayout } from './index';
|
|
|
7
7
|
declare type RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode;
|
|
8
8
|
declare type ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode;
|
|
9
9
|
declare type RcFieldProps = Omit<FieldProps, 'children'>;
|
|
10
|
-
export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePropName' | 'name' | 'rules' | 'messageVariables' | 'trigger' | 'validateTrigger' | 'shouldUpdate'> & Pick<ListItemProps, 'style' | 'onClick' | 'extra' | 'arrow'> & {
|
|
10
|
+
export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePropName' | 'name' | 'rules' | 'messageVariables' | 'trigger' | 'validateTrigger' | 'shouldUpdate' | 'initialValue'> & Pick<ListItemProps, 'style' | 'onClick' | 'extra' | 'arrow'> & {
|
|
11
11
|
label?: React.ReactNode;
|
|
12
12
|
help?: React.ReactNode;
|
|
13
13
|
hasFeedback?: boolean;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useRef, useState } from 'react';
|
|
3
3
|
import { AddOutline } from 'antd-mobile-icons';
|
|
4
4
|
import { mergeProps } from '../../utils/with-default-props';
|
|
5
5
|
import ImageViewer from '../image-viewer';
|
|
6
6
|
import PreviewItem from './preview-item';
|
|
7
7
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
8
|
-
import { useMemoizedFn, useUnmount } from 'ahooks';
|
|
8
|
+
import { useIsomorphicLayoutEffect, useMemoizedFn, useUnmount } from 'ahooks';
|
|
9
9
|
import Space from '../space';
|
|
10
10
|
import { withNativeProps } from '../../utils/native-props';
|
|
11
11
|
const classPrefix = `adm-image-uploader`;
|
|
@@ -26,7 +26,7 @@ export const ImageUploader = p => {
|
|
|
26
26
|
setValue(updater(value));
|
|
27
27
|
});
|
|
28
28
|
const [tasks, setTasks] = useState([]);
|
|
29
|
-
|
|
29
|
+
useIsomorphicLayoutEffect(() => {
|
|
30
30
|
setTasks(prev => prev.filter(task => {
|
|
31
31
|
if (task.url === undefined) return true;
|
|
32
32
|
return !value.some(fileItem => fileItem.url === task.url);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
1
|
+
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
2
2
|
import { mergeProps } from '../../utils/with-default-props';
|
|
3
3
|
import { renderToContainer } from '../../utils/render-to-container';
|
|
4
4
|
import Mask from '../mask';
|
|
@@ -35,6 +35,16 @@ const multiDefaultProps = Object.assign(Object.assign({}, defaultProps), {
|
|
|
35
35
|
});
|
|
36
36
|
export const MultiImageViewer = forwardRef((p, ref) => {
|
|
37
37
|
const props = mergeProps(multiDefaultProps, p);
|
|
38
|
+
const [defaultIndex, setDefaultIndex] = useState(props.defaultIndex);
|
|
39
|
+
const slidesRef = useRef(null);
|
|
40
|
+
useImperativeHandle(ref, () => ({
|
|
41
|
+
swipeTo: (index, immediate) => {
|
|
42
|
+
var _a;
|
|
43
|
+
|
|
44
|
+
setDefaultIndex(index);
|
|
45
|
+
(_a = slidesRef.current) === null || _a === void 0 ? void 0 : _a.swipeTo(index, immediate);
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
38
48
|
const node = React.createElement(Mask, {
|
|
39
49
|
visible: props.visible,
|
|
40
50
|
disableBodyScroll: false,
|
|
@@ -43,8 +53,8 @@ export const MultiImageViewer = forwardRef((p, ref) => {
|
|
|
43
53
|
}, React.createElement("div", {
|
|
44
54
|
className: `${classPrefix}-content`
|
|
45
55
|
}, props.images && React.createElement(Slides, {
|
|
46
|
-
ref:
|
|
47
|
-
defaultIndex:
|
|
56
|
+
ref: slidesRef,
|
|
57
|
+
defaultIndex: defaultIndex,
|
|
48
58
|
onIndexChange: props.onIndexChange,
|
|
49
59
|
images: props.images,
|
|
50
60
|
onTap: () => {
|
|
@@ -7,6 +7,6 @@ export declare type SlidesType = {
|
|
|
7
7
|
onIndexChange?: (index: number) => void;
|
|
8
8
|
};
|
|
9
9
|
export declare type SlidesRef = {
|
|
10
|
-
swipeTo: (index: number, immediate
|
|
10
|
+
swipeTo: (index: number, immediate?: boolean) => void;
|
|
11
11
|
};
|
|
12
12
|
export declare const Slides: React.ForwardRefExoticComponent<SlidesType & React.RefAttributes<SlidesRef>>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { useState, forwardRef, useImperativeHandle, useRef
|
|
1
|
+
import React, { useState, forwardRef, useImperativeHandle, useRef } from 'react';
|
|
2
2
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
3
3
|
import { CloseCircleFill } from 'antd-mobile-icons';
|
|
4
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
5
|
import { mergeProps } from '../../utils/with-default-props';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
|
+
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
7
8
|
const classPrefix = `adm-input`;
|
|
8
9
|
const defaultProps = {
|
|
9
10
|
defaultValue: ''
|
|
@@ -39,7 +40,7 @@ export const Input = forwardRef((p, ref) => {
|
|
|
39
40
|
(_a = props.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
40
41
|
};
|
|
41
42
|
|
|
42
|
-
|
|
43
|
+
useIsomorphicLayoutEffect(() => {
|
|
43
44
|
var _a;
|
|
44
45
|
|
|
45
46
|
if (!props.enterKeyHint) return;
|
|
@@ -89,7 +90,7 @@ export const Input = forwardRef((p, ref) => {
|
|
|
89
90
|
onKeyUp: props.onKeyUp,
|
|
90
91
|
onCompositionStart: props.onCompositionStart,
|
|
91
92
|
onCompositionEnd: props.onCompositionEnd
|
|
92
|
-
}), props.clearable && !!value && React.createElement("div", {
|
|
93
|
+
}), props.clearable && !!value && !props.readOnly && React.createElement("div", {
|
|
93
94
|
className: `${classPrefix}-clear`,
|
|
94
95
|
onMouseDown: e => {
|
|
95
96
|
e.preventDefault();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { memo,
|
|
1
|
+
import React, { memo, useRef } from 'react';
|
|
2
2
|
import { useSpring, animated } from '@react-spring/web';
|
|
3
3
|
import { useDrag } from '@use-gesture/react';
|
|
4
4
|
import { convertPx } from '../../utils/convert-px';
|
|
5
5
|
import { rubberbandIfOutOfBounds } from '../../utils/rubberband';
|
|
6
6
|
import { bound } from '../../utils/bound';
|
|
7
7
|
import isEqual from 'lodash/isEqual';
|
|
8
|
+
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
8
9
|
const classPrefix = `adm-picker-view`;
|
|
9
10
|
export const Wheel = memo(props => {
|
|
10
11
|
const itemHeight = convertPx(34);
|
|
@@ -29,7 +30,7 @@ export const Wheel = memo(props => {
|
|
|
29
30
|
}
|
|
30
31
|
}));
|
|
31
32
|
const draggingRef = useRef(false);
|
|
32
|
-
|
|
33
|
+
useIsomorphicLayoutEffect(() => {
|
|
33
34
|
if (draggingRef.current) return;
|
|
34
35
|
if (!value) return;
|
|
35
36
|
const targetIndex = column.findIndex(item => item.value === value);
|
|
@@ -40,7 +41,7 @@ export const Wheel = memo(props => {
|
|
|
40
41
|
immediate: y.goal !== finalPosition
|
|
41
42
|
});
|
|
42
43
|
}, [value, column]);
|
|
43
|
-
|
|
44
|
+
useIsomorphicLayoutEffect(() => {
|
|
44
45
|
if (column.length === 0) {
|
|
45
46
|
if (value !== null) {
|
|
46
47
|
onSelect(null);
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
.adm-selector {
|
|
2
|
-
--color:
|
|
2
|
+
--color: #f5f5f5;
|
|
3
3
|
--checked-color: #e7f1ff;
|
|
4
|
+
--text-color: var(--adm-color-text);
|
|
5
|
+
--checked-text-color: var(--adm-color-primary);
|
|
6
|
+
--border: none;
|
|
7
|
+
--checked-border: none;
|
|
8
|
+
--border-radius: 2px;
|
|
9
|
+
--padding: 8px 16px;
|
|
4
10
|
overflow: hidden;
|
|
5
11
|
font-size: 15px;
|
|
6
12
|
line-height: 1.4;
|
|
@@ -9,11 +15,12 @@
|
|
|
9
15
|
--gap: 12px;
|
|
10
16
|
}
|
|
11
17
|
.adm-selector-item {
|
|
12
|
-
padding:
|
|
18
|
+
padding: var(--padding);
|
|
13
19
|
position: relative;
|
|
14
|
-
background-color:
|
|
15
|
-
border
|
|
16
|
-
|
|
20
|
+
background-color: var(--color);
|
|
21
|
+
border: var(--border);
|
|
22
|
+
border-radius: var(--border-radius);
|
|
23
|
+
color: var(--text-color);
|
|
17
24
|
opacity: 1;
|
|
18
25
|
cursor: pointer;
|
|
19
26
|
display: inline-block;
|
|
@@ -27,8 +34,9 @@
|
|
|
27
34
|
}
|
|
28
35
|
.adm-selector-item-active,
|
|
29
36
|
.adm-selector-item-multiple-active {
|
|
30
|
-
color: var(--
|
|
37
|
+
color: var(--checked-text-color);
|
|
31
38
|
background-color: var(--checked-color);
|
|
39
|
+
border: var(--checked-border);
|
|
32
40
|
}
|
|
33
41
|
.adm-selector-item .adm-selector-check-mark-wrapper {
|
|
34
42
|
position: absolute;
|
|
@@ -16,5 +16,6 @@ export declare type SelectorProps<V> = {
|
|
|
16
16
|
onChange?: (v: V[], extend: {
|
|
17
17
|
items: SelectorOption<V>[];
|
|
18
18
|
}) => void;
|
|
19
|
-
|
|
19
|
+
showCheckMark?: boolean;
|
|
20
|
+
} & NativeProps<'--color' | '--checked-color' | '--text-color' | '--checked-text-color' | '--border' | '--checked-border' | '--border-radius' | '--padding'>;
|
|
20
21
|
export declare const Selector: <V extends string | number>(p: SelectorProps<V>) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)>;
|
|
@@ -10,7 +10,8 @@ import { CheckMark } from './check-mark';
|
|
|
10
10
|
const classPrefix = `adm-selector`;
|
|
11
11
|
const defaultProps = {
|
|
12
12
|
multiple: false,
|
|
13
|
-
defaultValue: []
|
|
13
|
+
defaultValue: [],
|
|
14
|
+
showCheckMark: true
|
|
14
15
|
};
|
|
15
16
|
export const Selector = p => {
|
|
16
17
|
const props = mergeProps(defaultProps, p);
|
|
@@ -55,7 +56,7 @@ export const Selector = p => {
|
|
|
55
56
|
}
|
|
56
57
|
}, option.label, option.description && React.createElement("div", {
|
|
57
58
|
className: `${classPrefix}-item-description`
|
|
58
|
-
}, option.description), active && React.createElement("div", {
|
|
59
|
+
}, option.description), active && props.showCheckMark && React.createElement("div", {
|
|
59
60
|
className: `${classPrefix}-check-mark-wrapper`
|
|
60
61
|
}, React.createElement(CheckMark, null)));
|
|
61
62
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useEffect, useImperativeHandle,
|
|
1
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -10,7 +10,7 @@ import PageIndicator from '../page-indicator';
|
|
|
10
10
|
import { staged } from 'staged-components';
|
|
11
11
|
import { useRefState } from '../../utils/use-ref-state';
|
|
12
12
|
import { bound } from '../../utils/bound';
|
|
13
|
-
import { useUpdateEffect } from 'ahooks';
|
|
13
|
+
import { useIsomorphicLayoutEffect, useUpdateEffect } from 'ahooks';
|
|
14
14
|
const defaultProps = {
|
|
15
15
|
defaultIndex: 0,
|
|
16
16
|
allowTouchMove: true,
|
|
@@ -184,7 +184,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
184
184
|
swipeNext,
|
|
185
185
|
swipePrev
|
|
186
186
|
}));
|
|
187
|
-
|
|
187
|
+
useIsomorphicLayoutEffect(() => {
|
|
188
188
|
const maxIndex = validChildren.length - 1;
|
|
189
189
|
|
|
190
190
|
if (current > maxIndex) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { useRef
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import { useSpring, animated } from '@react-spring/web';
|
|
4
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
5
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
6
6
|
import { bound } from '../../utils/bound';
|
|
7
|
-
import { useUpdateLayoutEffect, useThrottleFn } from 'ahooks';
|
|
7
|
+
import { useUpdateLayoutEffect, useThrottleFn, useIsomorphicLayoutEffect } from 'ahooks';
|
|
8
8
|
import { useMutationEffect } from '../../utils/use-mutation-effect';
|
|
9
9
|
import { useResizeEffect } from '../../utils/use-resize-effect';
|
|
10
10
|
import { mergeProps } from '../../utils/with-default-props';
|
|
@@ -134,7 +134,7 @@ export const Tabs = p => {
|
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
useIsomorphicLayoutEffect(() => {
|
|
138
138
|
animate(true);
|
|
139
139
|
}, []);
|
|
140
140
|
useUpdateLayoutEffect(() => {
|
|
@@ -168,7 +168,7 @@ export const Tabs = p => {
|
|
|
168
168
|
trailing: true,
|
|
169
169
|
leading: true
|
|
170
170
|
});
|
|
171
|
-
|
|
171
|
+
useIsomorphicLayoutEffect(() => {
|
|
172
172
|
updateMask(true);
|
|
173
173
|
}, []);
|
|
174
174
|
return withNativeProps(props, React.createElement("div", {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { forwardRef, useEffect, useImperativeHandle,
|
|
1
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
4
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { CloseCircleFill } from 'antd-mobile-icons';
|
|
7
|
+
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
7
8
|
const classPrefix = 'adm-virtual-input';
|
|
8
9
|
const defaultProps = {
|
|
9
10
|
defaultValue: ''
|
|
@@ -28,7 +29,7 @@ export const VirtualInput = forwardRef((p, ref) => {
|
|
|
28
29
|
content.scrollLeft = content.clientWidth;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
useIsomorphicLayoutEffect(() => {
|
|
32
33
|
scrollToEnd();
|
|
33
34
|
}, [value]);
|
|
34
35
|
useEffect(() => {
|
|
@@ -4,7 +4,7 @@ const defaultRoot = canUseDom ? window : undefined;
|
|
|
4
4
|
|
|
5
5
|
function isElement(node) {
|
|
6
6
|
const ELEMENT_NODE_TYPE = 1;
|
|
7
|
-
return node.
|
|
7
|
+
return node.nodeType === ELEMENT_NODE_TYPE;
|
|
8
8
|
} // https://github.com/youzan/vant/issues/3823
|
|
9
9
|
|
|
10
10
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
2
|
export function useRefState(initialState) {
|
|
3
3
|
const [state, setState] = useState(initialState);
|
|
4
4
|
const ref = useRef(state);
|
|
5
|
-
|
|
5
|
+
useEffect(() => {
|
|
6
6
|
ref.current = state;
|
|
7
7
|
}, [state]);
|
|
8
8
|
return [state, setState, ref];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMemoizedFn } from 'ahooks';
|
|
1
|
+
import { useIsomorphicLayoutEffect, useMemoizedFn } from 'ahooks';
|
|
3
2
|
export function useResizeEffect(effect, targetRef) {
|
|
4
3
|
const fn = useMemoizedFn(effect);
|
|
5
|
-
|
|
4
|
+
useIsomorphicLayoutEffect(() => {
|
|
6
5
|
const target = targetRef.current;
|
|
7
6
|
if (!target) return;
|
|
8
7
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { useLayoutEffect } from 'react';
|
|
2
1
|
import { useSpring } from '@react-spring/web';
|
|
3
2
|
import { useMutationEffect } from './use-mutation-effect';
|
|
4
3
|
import { bound } from './bound';
|
|
5
|
-
import { useUpdateLayoutEffect } from 'ahooks';
|
|
4
|
+
import { useIsomorphicLayoutEffect, useUpdateLayoutEffect } from 'ahooks';
|
|
6
5
|
export const useTabListScroll = (targetRef, activeIndex) => {
|
|
7
6
|
const [{
|
|
8
7
|
scrollLeft
|
|
@@ -37,7 +36,7 @@ export const useTabListScroll = (targetRef, activeIndex) => {
|
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
useIsomorphicLayoutEffect(() => {
|
|
41
40
|
animate(true);
|
|
42
41
|
}, []);
|
|
43
42
|
useUpdateLayoutEffect(() => {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-mobile",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.26",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@react-spring/web": "^9.4.2",
|
|
6
|
-
"@types/resize-observer-browser": "^0.1.
|
|
7
|
-
"@use-gesture/react": "^10.2.
|
|
6
|
+
"@types/resize-observer-browser": "^0.1.7",
|
|
7
|
+
"@use-gesture/react": "^10.2.5",
|
|
8
8
|
"ahooks": "^3.1.9",
|
|
9
9
|
"antd-mobile-icons": "^0.2.2",
|
|
10
10
|
"antd-mobile-v5-count": "^1.0.1",
|