antd-mobile 5.30.0 → 5.31.1
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/README.md +1 -1
- package/2x/bundle/antd-mobile.cjs.development.js +283 -234
- package/2x/bundle/antd-mobile.cjs.js +9 -9
- package/2x/bundle/antd-mobile.es.development.js +283 -234
- package/2x/bundle/antd-mobile.es.js +4172 -4128
- package/2x/bundle/antd-mobile.umd.development.js +283 -234
- package/2x/bundle/antd-mobile.umd.js +9 -9
- package/2x/bundle/style.css +2 -0
- package/2x/cjs/components/avatar/avatar.js +1 -1
- package/2x/cjs/components/button/button.d.ts +2 -2
- package/2x/cjs/components/cascader/cascader.js +1 -6
- package/2x/cjs/components/cascader-view/cascader-view.d.ts +1 -0
- package/2x/cjs/components/cascader-view/cascader-view.js +2 -1
- 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/ellipsis/ellipsis.d.ts +2 -2
- package/2x/cjs/components/ellipsis/ellipsis.js +17 -17
- package/2x/cjs/components/form/form-subscribe.js +1 -1
- package/2x/cjs/components/image/image.d.ts +1 -1
- package/2x/cjs/components/image/image.js +1 -0
- package/2x/cjs/components/input/input.d.ts +2 -4
- package/2x/cjs/components/list/list-item.d.ts +1 -1
- package/2x/cjs/components/notice-bar/notice-bar.css +2 -0
- package/2x/cjs/components/notice-bar/notice-bar.d.ts +2 -0
- package/2x/cjs/components/notice-bar/notice-bar.js +2 -1
- package/2x/cjs/components/popup/popup.d.ts +1 -0
- package/2x/cjs/components/popup/popup.js +2 -0
- package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +4 -2
- package/2x/cjs/components/slider/slider.js +6 -4
- package/2x/cjs/components/swiper/swiper.js +16 -12
- package/2x/cjs/components/text-area/text-area.d.ts +1 -1
- package/2x/cjs/utils/reduce-and-restore-motion.js +1 -1
- package/2x/es/components/avatar/avatar.js +1 -1
- package/2x/es/components/button/button.d.ts +2 -2
- package/2x/es/components/cascader/cascader.js +1 -6
- package/2x/es/components/cascader-view/cascader-view.d.ts +1 -0
- package/2x/es/components/cascader-view/cascader-view.js +2 -1
- 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/ellipsis/ellipsis.d.ts +2 -2
- package/2x/es/components/ellipsis/ellipsis.js +17 -17
- package/2x/es/components/form/form-subscribe.js +1 -1
- package/2x/es/components/image/image.d.ts +1 -1
- package/2x/es/components/image/image.js +1 -0
- package/2x/es/components/input/input.d.ts +2 -4
- package/2x/es/components/list/list-item.d.ts +1 -1
- package/2x/es/components/notice-bar/notice-bar.css +2 -0
- package/2x/es/components/notice-bar/notice-bar.d.ts +2 -0
- package/2x/es/components/notice-bar/notice-bar.js +2 -1
- package/2x/es/components/popup/popup.d.ts +1 -0
- package/2x/es/components/popup/popup.js +2 -0
- package/2x/es/components/pull-to-refresh/pull-to-refresh.js +4 -2
- package/2x/es/components/slider/slider.js +6 -4
- package/2x/es/components/swiper/swiper.js +17 -13
- package/2x/es/components/text-area/text-area.d.ts +1 -1
- package/2x/es/utils/reduce-and-restore-motion.js +1 -1
- package/2x/package.json +2 -2
- package/README.md +1 -1
- package/bundle/antd-mobile.cjs.development.js +283 -234
- package/bundle/antd-mobile.cjs.js +9 -9
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +283 -234
- package/bundle/antd-mobile.es.js +4172 -4128
- package/bundle/antd-mobile.umd.development.js +283 -234
- package/bundle/antd-mobile.umd.js +9 -9
- package/bundle/style.css +1 -1
- package/cjs/components/avatar/avatar.js +1 -1
- package/cjs/components/button/button.d.ts +2 -2
- package/cjs/components/cascader/cascader.js +1 -6
- package/cjs/components/cascader-view/cascader-view.d.ts +1 -0
- package/cjs/components/cascader-view/cascader-view.js +2 -1
- package/cjs/components/date-picker/date-picker.d.ts +1 -1
- package/cjs/components/date-picker/index.d.ts +1 -1
- package/cjs/components/ellipsis/ellipsis.d.ts +2 -2
- package/cjs/components/ellipsis/ellipsis.js +17 -17
- package/cjs/components/form/form-subscribe.js +1 -1
- package/cjs/components/image/image.d.ts +1 -1
- package/cjs/components/image/image.js +1 -0
- package/cjs/components/input/input.d.ts +2 -4
- package/cjs/components/list/list-item.d.ts +1 -1
- package/cjs/components/notice-bar/notice-bar.css +2 -0
- package/cjs/components/notice-bar/notice-bar.d.ts +2 -0
- package/cjs/components/notice-bar/notice-bar.js +2 -1
- package/cjs/components/popup/popup.d.ts +1 -0
- package/cjs/components/popup/popup.js +2 -0
- package/cjs/components/pull-to-refresh/pull-to-refresh.js +4 -2
- package/cjs/components/slider/slider.js +6 -4
- package/cjs/components/swiper/swiper.js +16 -12
- package/cjs/components/text-area/text-area.d.ts +1 -1
- package/cjs/utils/reduce-and-restore-motion.js +1 -1
- package/es/components/avatar/avatar.js +1 -1
- package/es/components/button/button.d.ts +2 -2
- package/es/components/cascader/cascader.js +1 -6
- package/es/components/cascader-view/cascader-view.d.ts +1 -0
- package/es/components/cascader-view/cascader-view.js +2 -1
- package/es/components/date-picker/date-picker.d.ts +1 -1
- package/es/components/date-picker/index.d.ts +1 -1
- package/es/components/ellipsis/ellipsis.d.ts +2 -2
- package/es/components/ellipsis/ellipsis.js +17 -17
- package/es/components/form/form-subscribe.js +1 -1
- package/es/components/image/image.d.ts +1 -1
- package/es/components/image/image.js +1 -0
- package/es/components/input/input.d.ts +2 -4
- package/es/components/list/list-item.d.ts +1 -1
- package/es/components/notice-bar/notice-bar.css +2 -0
- package/es/components/notice-bar/notice-bar.d.ts +2 -0
- package/es/components/notice-bar/notice-bar.js +2 -1
- package/es/components/popup/popup.d.ts +1 -0
- package/es/components/popup/popup.js +2 -0
- package/es/components/pull-to-refresh/pull-to-refresh.js +4 -2
- package/es/components/slider/slider.js +6 -4
- package/es/components/swiper/swiper.js +17 -13
- package/es/components/text-area/text-area.d.ts +1 -1
- package/es/utils/reduce-and-restore-motion.js +1 -1
- package/package.json +2 -2
- package/umd/antd-mobile.js +1 -1
|
@@ -15,7 +15,7 @@ const FormSubscribe = props => {
|
|
|
15
15
|
const form = (0, _react.useContext)(_rcFieldForm.FieldContext);
|
|
16
16
|
const value = form.getFieldsValue(props.to);
|
|
17
17
|
// Memo to avoid useless render
|
|
18
|
-
const childNode = _react.default.useMemo(() => props.children(value, form), [JSON.stringify(value)]);
|
|
18
|
+
const childNode = _react.default.useMemo(() => props.children(value, form), [JSON.stringify(value), props.children]);
|
|
19
19
|
return _react.default.createElement(_react.default.Fragment, null, childNode, props.to.map(namePath => _react.default.createElement(Watcher, {
|
|
20
20
|
key: namePath.toString(),
|
|
21
21
|
form: form,
|
|
@@ -14,5 +14,5 @@ export declare type ImageProps = {
|
|
|
14
14
|
onError?: (event: React.SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
15
15
|
onLoad?: (event: React.SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
16
16
|
onContainerClick?: (event: React.MouseEvent<HTMLDivElement, Event>) => void;
|
|
17
|
-
} & NativeProps<'--width' | '--height'> & Pick<React.ImgHTMLAttributes<HTMLImageElement>, 'crossOrigin' | 'decoding' | 'loading' | 'referrerPolicy' | 'sizes' | 'srcSet' | 'useMap'>;
|
|
17
|
+
} & NativeProps<'--width' | '--height'> & Pick<React.ImgHTMLAttributes<HTMLImageElement>, 'crossOrigin' | 'decoding' | 'loading' | 'referrerPolicy' | 'sizes' | 'srcSet' | 'useMap' | 'id'>;
|
|
18
18
|
export declare const Image: React.FC<ImageProps>;
|
|
@@ -4,7 +4,7 @@ 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' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step'> & {
|
|
7
|
+
export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step' | 'id'> & {
|
|
8
8
|
value?: string;
|
|
9
9
|
defaultValue?: string;
|
|
10
10
|
onChange?: (val: string) => void;
|
|
@@ -14,7 +14,6 @@ export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength
|
|
|
14
14
|
clearable?: boolean;
|
|
15
15
|
onlyShowClearWhenFocus?: boolean;
|
|
16
16
|
onClear?: () => void;
|
|
17
|
-
id?: string;
|
|
18
17
|
onEnterPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
19
18
|
enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
20
19
|
min?: number;
|
|
@@ -26,7 +25,7 @@ export declare type InputRef = {
|
|
|
26
25
|
blur: () => void;
|
|
27
26
|
nativeElement: HTMLInputElement | null;
|
|
28
27
|
};
|
|
29
|
-
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "
|
|
28
|
+
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "type" | "step" | "autoFocus" | "autoCapitalize" | "autoCorrect" | "inputMode" | "name" | "autoComplete" | "maxLength" | "minLength"> & {
|
|
30
29
|
value?: string | undefined;
|
|
31
30
|
defaultValue?: string | undefined;
|
|
32
31
|
onChange?: ((val: string) => void) | undefined;
|
|
@@ -36,7 +35,6 @@ export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProp
|
|
|
36
35
|
clearable?: boolean | undefined;
|
|
37
36
|
onlyShowClearWhenFocus?: boolean | undefined;
|
|
38
37
|
onClear?: (() => void) | undefined;
|
|
39
|
-
id?: string | undefined;
|
|
40
38
|
onEnterPress?: ((e: React.KeyboardEvent<HTMLInputElement>) => void) | undefined;
|
|
41
39
|
enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined;
|
|
42
40
|
min?: number | undefined;
|
|
@@ -9,6 +9,6 @@ export declare type ListItemProps = {
|
|
|
9
9
|
clickable?: boolean;
|
|
10
10
|
arrow?: boolean | ReactNode;
|
|
11
11
|
disabled?: boolean;
|
|
12
|
-
onClick?: (e: React.MouseEvent) => void;
|
|
12
|
+
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
13
13
|
} & NativeProps<'--prefix-width' | '--align-items' | '--active-background-color'>;
|
|
14
14
|
export declare const ListItem: FC<ListItemProps>;
|
|
@@ -13,6 +13,8 @@ export declare type NoticeBarProps = {
|
|
|
13
13
|
closeable?: boolean;
|
|
14
14
|
/** Callback when closed */
|
|
15
15
|
onClose?: () => void;
|
|
16
|
+
/** Event when click */
|
|
17
|
+
onClick?: () => void;
|
|
16
18
|
/** Additional operating area, displayed to the left of the close button */
|
|
17
19
|
extra?: React.ReactNode;
|
|
18
20
|
/** Radio icon on the left */
|
|
@@ -73,7 +73,8 @@ const NoticeBar = (0, _react.memo)(p => {
|
|
|
73
73
|
return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
|
|
74
74
|
className: (0, _classnames.default)(classPrefix, `${classPrefix}-${props.color}`, {
|
|
75
75
|
[`${classPrefix}-wrap`]: props.wrap
|
|
76
|
-
})
|
|
76
|
+
}),
|
|
77
|
+
onClick: props.onClick
|
|
77
78
|
}, props.icon && _react.default.createElement("span", {
|
|
78
79
|
className: `${classPrefix}-left`
|
|
79
80
|
}, props.icon), _react.default.createElement("span", {
|
|
@@ -3,5 +3,6 @@ import { NativeProps } from '../../utils/native-props';
|
|
|
3
3
|
import { PopupBaseProps } from './popup-base-props';
|
|
4
4
|
export declare type PopupProps = PopupBaseProps & PropsWithChildren<{
|
|
5
5
|
position?: 'bottom' | 'top' | 'left' | 'right';
|
|
6
|
+
closeOnSwipe?: boolean;
|
|
6
7
|
}> & NativeProps<'--z-index'>;
|
|
7
8
|
export declare const Popup: FC<PopupProps>;
|
|
@@ -25,6 +25,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
25
25
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
26
|
const classPrefix = `adm-popup`;
|
|
27
27
|
const defaultProps = Object.assign(Object.assign({}, _popupBaseProps.defaultPopupBaseProps), {
|
|
28
|
+
closeOnSwipe: false,
|
|
28
29
|
position: 'bottom'
|
|
29
30
|
});
|
|
30
31
|
const Popup = p => {
|
|
@@ -67,6 +68,7 @@ const Popup = p => {
|
|
|
67
68
|
swipe: [, swipeY]
|
|
68
69
|
}) => {
|
|
69
70
|
var _a;
|
|
71
|
+
if (!props.closeOnSwipe) return;
|
|
70
72
|
if (swipeY === 1 && props.position === 'bottom' || swipeY === -1 && props.position === 'top') {
|
|
71
73
|
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
72
74
|
}
|
|
@@ -49,6 +49,7 @@ const PullToRefresh = p => {
|
|
|
49
49
|
config: {
|
|
50
50
|
tension: 300,
|
|
51
51
|
friction: 30,
|
|
52
|
+
round: true,
|
|
52
53
|
clamp: true
|
|
53
54
|
}
|
|
54
55
|
}));
|
|
@@ -108,7 +109,8 @@ const PullToRefresh = p => {
|
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
const [, y] = state.movement;
|
|
111
|
-
|
|
112
|
+
const parsedY = Math.ceil(y);
|
|
113
|
+
if (state.first && parsedY > 0) {
|
|
112
114
|
const target = state.event.target;
|
|
113
115
|
if (!target || !(target instanceof Element)) return;
|
|
114
116
|
let scrollParent = (0, _getScrollParent.getScrollParent)(target);
|
|
@@ -133,7 +135,7 @@ const PullToRefresh = p => {
|
|
|
133
135
|
event.preventDefault();
|
|
134
136
|
}
|
|
135
137
|
event.stopPropagation();
|
|
136
|
-
const height = Math.max((0, _rubberband.rubberbandIfOutOfBounds)(
|
|
138
|
+
const height = Math.max((0, _rubberband.rubberbandIfOutOfBounds)(parsedY, 0, 0, headHeight * 5, 0.5), 0);
|
|
137
139
|
api.start({
|
|
138
140
|
height
|
|
139
141
|
});
|
|
@@ -87,13 +87,14 @@ const Slider = p => {
|
|
|
87
87
|
const pointList = (0, _react.useMemo)(() => {
|
|
88
88
|
if (marks) {
|
|
89
89
|
return Object.keys(marks).map(parseFloat).sort((a, b) => a - b);
|
|
90
|
-
} else {
|
|
90
|
+
} else if (ticks) {
|
|
91
91
|
const points = [];
|
|
92
92
|
for (let i = (0, _miniDecimal.default)(min); i.lessEquals((0, _miniDecimal.default)(max)); i = i.add(step)) {
|
|
93
93
|
points.push(i.toNumber());
|
|
94
94
|
}
|
|
95
95
|
return points;
|
|
96
96
|
}
|
|
97
|
+
return [];
|
|
97
98
|
}, [marks, ticks, step, min, max]);
|
|
98
99
|
function getValueByPosition(position) {
|
|
99
100
|
const newPosition = position < min ? min : position > max ? max : position;
|
|
@@ -102,9 +103,10 @@ const Slider = p => {
|
|
|
102
103
|
if (pointList.length) {
|
|
103
104
|
value = (0, _nearest.nearest)(pointList, newPosition);
|
|
104
105
|
} else {
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
106
|
+
// 使用 MiniDecimal 避免精度问题
|
|
107
|
+
const cell = Math.round((newPosition - min) / step);
|
|
108
|
+
const nextVal = (0, _miniDecimal.default)(cell).multi(step);
|
|
109
|
+
value = (0, _miniDecimal.default)(min).add(nextVal.toString()).toNumber();
|
|
108
110
|
}
|
|
109
111
|
return value;
|
|
110
112
|
}
|
|
@@ -44,6 +44,7 @@ let currentUid;
|
|
|
44
44
|
const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) => {
|
|
45
45
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
46
46
|
const [uid] = (0, _react.useState)({});
|
|
47
|
+
const timeoutRef = (0, _react.useRef)(null);
|
|
47
48
|
const isVertical = props.direction === 'vertical';
|
|
48
49
|
const slideRatio = props.slideSize / 100;
|
|
49
50
|
const offsetRatio = props.trackOffset / 100;
|
|
@@ -82,7 +83,7 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
82
83
|
const trackPixels = isVertical ? track.offsetHeight : track.offsetWidth;
|
|
83
84
|
return trackPixels * props.slideSize / 100;
|
|
84
85
|
}
|
|
85
|
-
const [current, setCurrent] = (0,
|
|
86
|
+
const [current, setCurrent, getCurrent] = (0, _ahooks.useGetState)(props.defaultIndex);
|
|
86
87
|
const [dragging, setDragging, draggingRef] = (0, _useRefState.useRefState)(false);
|
|
87
88
|
function boundIndex(current) {
|
|
88
89
|
let min = 0;
|
|
@@ -180,10 +181,10 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
180
181
|
var _a;
|
|
181
182
|
const roundedIndex = Math.round(index);
|
|
182
183
|
const targetIndex = loop ? modulus(roundedIndex, count) : (0, _bound.bound)(roundedIndex, 0, count - 1);
|
|
183
|
-
|
|
184
|
-
if (targetIndex !== current) {
|
|
184
|
+
if (targetIndex !== getCurrent()) {
|
|
185
185
|
(_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, targetIndex);
|
|
186
186
|
}
|
|
187
|
+
setCurrent(targetIndex);
|
|
187
188
|
api.start({
|
|
188
189
|
position: (loop ? roundedIndex : boundIndex(roundedIndex)) * 100,
|
|
189
190
|
immediate
|
|
@@ -210,16 +211,17 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
210
211
|
autoplay,
|
|
211
212
|
autoplayInterval
|
|
212
213
|
} = props;
|
|
214
|
+
const runTimeSwiper = () => {
|
|
215
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
216
|
+
swipeNext();
|
|
217
|
+
runTimeSwiper();
|
|
218
|
+
}, autoplayInterval);
|
|
219
|
+
};
|
|
213
220
|
(0, _react.useEffect)(() => {
|
|
214
221
|
if (!autoplay || dragging) return;
|
|
215
|
-
|
|
216
|
-
function tick() {
|
|
217
|
-
interval = window.setTimeout(tick, autoplayInterval);
|
|
218
|
-
swipeNext();
|
|
219
|
-
}
|
|
220
|
-
interval = window.setTimeout(tick, autoplayInterval);
|
|
222
|
+
runTimeSwiper();
|
|
221
223
|
return () => {
|
|
222
|
-
if (
|
|
224
|
+
if (timeoutRef.current) window.clearTimeout(timeoutRef.current);
|
|
223
225
|
};
|
|
224
226
|
}, [autoplay, autoplayInterval, dragging, count]);
|
|
225
227
|
function renderTrackInner() {
|
|
@@ -249,9 +251,11 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
249
251
|
style: {
|
|
250
252
|
[isVertical ? 'y' : 'x']: position.to(position => `${-position}%`)
|
|
251
253
|
}
|
|
252
|
-
}, _react.default.Children.map(validChildren, child => {
|
|
254
|
+
}, _react.default.Children.map(validChildren, (child, index) => {
|
|
253
255
|
return _react.default.createElement("div", {
|
|
254
|
-
className: `${classPrefix}-slide
|
|
256
|
+
className: (0, _classnames.default)(`${classPrefix}-slide`, {
|
|
257
|
+
[`${classPrefix}-slide-active`]: current === index
|
|
258
|
+
})
|
|
255
259
|
}, child);
|
|
256
260
|
}));
|
|
257
261
|
}
|
|
@@ -21,7 +21,7 @@ export declare type TextAreaRef = {
|
|
|
21
21
|
blur: () => void;
|
|
22
22
|
nativeElement: HTMLTextAreaElement | null;
|
|
23
23
|
};
|
|
24
|
-
export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "onClick" | "disabled" | "
|
|
24
|
+
export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "onClick" | "disabled" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "autoFocus" | "name" | "readOnly" | "autoComplete"> & {
|
|
25
25
|
onChange?: ((val: string) => void) | undefined;
|
|
26
26
|
value?: string | undefined;
|
|
27
27
|
defaultValue?: string | undefined;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
|
-
import Image from '../image';
|
|
4
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
5
4
|
import { Fallback } from './fallback';
|
|
5
|
+
import Image from '../image';
|
|
6
6
|
const classPrefix = 'adm-avatar';
|
|
7
7
|
const defaultProps = {
|
|
8
8
|
fallback: React.createElement(Fallback, null),
|
|
@@ -14,7 +14,7 @@ export declare type ButtonProps = {
|
|
|
14
14
|
type?: 'submit' | 'reset' | 'button';
|
|
15
15
|
shape?: 'default' | 'rounded' | 'rectangular';
|
|
16
16
|
children?: React.ReactNode;
|
|
17
|
-
} & Pick<NativeButtonProps, 'onMouseDown' | 'onMouseUp' | 'onTouchStart' | 'onTouchEnd'> & NativeProps<'--text-color' | '--background-color' | '--border-radius' | '--border-width' | '--border-style' | '--border-color'>;
|
|
17
|
+
} & Pick<NativeButtonProps, 'onMouseDown' | 'onMouseUp' | 'onTouchStart' | 'onTouchEnd' | 'id'> & NativeProps<'--text-color' | '--background-color' | '--border-radius' | '--border-width' | '--border-style' | '--border-color'>;
|
|
18
18
|
export declare type ButtonRef = {
|
|
19
19
|
nativeElement: HTMLButtonElement | null;
|
|
20
20
|
};
|
|
@@ -31,7 +31,7 @@ export declare const Button: React.ForwardRefExoticComponent<{
|
|
|
31
31
|
type?: "reset" | "submit" | "button" | undefined;
|
|
32
32
|
shape?: "default" | "rounded" | "rectangular" | undefined;
|
|
33
33
|
children?: React.ReactNode;
|
|
34
|
-
} & Pick<NativeButtonProps, "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & {
|
|
34
|
+
} & Pick<NativeButtonProps, "id" | "onMouseDown" | "onMouseUp" | "onTouchEnd" | "onTouchStart"> & {
|
|
35
35
|
className?: string | undefined;
|
|
36
36
|
style?: (React.CSSProperties & Partial<Record<"--border-radius" | "--text-color" | "--background-color" | "--border-width" | "--border-style" | "--border-color", string>>) | undefined;
|
|
37
37
|
tabIndex?: number | undefined;
|
|
@@ -56,12 +56,7 @@ export const Cascader = forwardRef((p, ref) => {
|
|
|
56
56
|
if (!visible) {
|
|
57
57
|
setInnerValue(value);
|
|
58
58
|
}
|
|
59
|
-
}, [visible]);
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (!visible) {
|
|
62
|
-
setInnerValue(value);
|
|
63
|
-
}
|
|
64
|
-
}, [value]);
|
|
59
|
+
}, [visible, value]);
|
|
65
60
|
const cascaderElement = withNativeProps(props, React.createElement("div", {
|
|
66
61
|
className: classPrefix
|
|
67
62
|
}, React.createElement("div", {
|
|
@@ -19,5 +19,6 @@ export declare type CascaderViewProps = {
|
|
|
19
19
|
placeholder?: string | ((index: number) => string);
|
|
20
20
|
onTabsChange?: (index: number) => void;
|
|
21
21
|
activeIcon?: ReactNode;
|
|
22
|
+
loading?: boolean;
|
|
22
23
|
} & NativeProps<'--height'>;
|
|
23
24
|
export declare const CascaderView: FC<CascaderViewProps>;
|
|
@@ -72,6 +72,7 @@ export const CascaderView = p => {
|
|
|
72
72
|
}
|
|
73
73
|
setValue(next);
|
|
74
74
|
};
|
|
75
|
+
const whetherLoading = options => props.loading || options === optionSkeleton;
|
|
75
76
|
return withNativeProps(props, React.createElement("div", {
|
|
76
77
|
className: classPrefix
|
|
77
78
|
}, React.createElement(Tabs, {
|
|
@@ -92,7 +93,7 @@ export const CascaderView = p => {
|
|
|
92
93
|
forceRender: true
|
|
93
94
|
}, React.createElement("div", {
|
|
94
95
|
className: `${classPrefix}-content`
|
|
95
|
-
}, level.options
|
|
96
|
+
}, whetherLoading(level.options) ? React.createElement("div", {
|
|
96
97
|
className: `${classPrefix}-skeleton`
|
|
97
98
|
}, React.createElement(Skeleton, {
|
|
98
99
|
className: `${classPrefix}-skeleton-line-1`,
|
|
@@ -18,7 +18,7 @@ export declare type DatePickerProps = Pick<PickerProps, 'onCancel' | 'onClose' |
|
|
|
18
18
|
filter?: DatePickerFilter;
|
|
19
19
|
tillNow?: boolean;
|
|
20
20
|
} & NativeProps;
|
|
21
|
-
export declare const DatePicker: React.ForwardRefExoticComponent<Pick<PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "
|
|
21
|
+
export declare const DatePicker: React.ForwardRefExoticComponent<Pick<PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "closeOnMaskClick" | "onClose" | "cancelText" | "loading" | "mouseWheel" | "loadingContent" | "onCancel" | "confirmText"> & {
|
|
22
22
|
value?: PickerDate | null | undefined;
|
|
23
23
|
defaultValue?: PickerDate | null | undefined;
|
|
24
24
|
onSelect?: ((value: PickerDate) => void) | undefined;
|
|
@@ -2,7 +2,7 @@ import './date-picker.less';
|
|
|
2
2
|
import { prompt } from './prompt';
|
|
3
3
|
export type { DatePickerProps, DatePickerRef } from './date-picker';
|
|
4
4
|
export type { DatePickerFilter } from './date-picker-utils';
|
|
5
|
-
declare const _default: import("react").ForwardRefExoticComponent<Pick<import("../picker").PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "
|
|
5
|
+
declare const _default: import("react").ForwardRefExoticComponent<Pick<import("../picker").PickerProps, "style" | "title" | "onClick" | "visible" | "destroyOnClose" | "forceRender" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "closeOnMaskClick" | "onClose" | "cancelText" | "loading" | "mouseWheel" | "loadingContent" | "onCancel" | "confirmText"> & {
|
|
6
6
|
value?: import("./util").PickerDate | null | undefined;
|
|
7
7
|
defaultValue?: import("./util").PickerDate | null | undefined;
|
|
8
8
|
onSelect?: ((value: import("./util").PickerDate) => void) | undefined;
|
|
@@ -5,8 +5,8 @@ export declare type EllipsisProps = {
|
|
|
5
5
|
content: string;
|
|
6
6
|
direction?: 'start' | 'end' | 'middle';
|
|
7
7
|
rows?: number;
|
|
8
|
-
expandText?:
|
|
9
|
-
collapseText?:
|
|
8
|
+
expandText?: React.ReactNode;
|
|
9
|
+
collapseText?: React.ReactNode;
|
|
10
10
|
stopPropagationForActionButtons?: PropagationEvent[];
|
|
11
11
|
onContentClick?: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
12
12
|
defaultExpanded?: boolean;
|
|
@@ -19,6 +19,8 @@ const defaultProps = {
|
|
|
19
19
|
export const Ellipsis = p => {
|
|
20
20
|
const props = mergeProps(defaultProps, p);
|
|
21
21
|
const rootRef = useRef(null);
|
|
22
|
+
const expandElRef = useRef(null);
|
|
23
|
+
const collapseElRef = useRef(null);
|
|
22
24
|
const [ellipsised, setEllipsised] = useState({});
|
|
23
25
|
const [expanded, setExpanded] = useState(props.defaultExpanded);
|
|
24
26
|
const [exceeded, setExceeded] = useState(false);
|
|
@@ -27,19 +29,18 @@ export const Ellipsis = p => {
|
|
|
27
29
|
return chars.slice(start, end).join('');
|
|
28
30
|
}
|
|
29
31
|
function calcEllipsised() {
|
|
32
|
+
var _a, _b;
|
|
30
33
|
const root = rootRef.current;
|
|
31
34
|
if (!root) return;
|
|
32
|
-
|
|
35
|
+
const originDisplay = root.style.display;
|
|
36
|
+
root.style.display = 'block';
|
|
33
37
|
const originStyle = window.getComputedStyle(root);
|
|
34
38
|
const container = document.createElement('div');
|
|
35
39
|
const styleNames = Array.prototype.slice.apply(originStyle);
|
|
36
40
|
styleNames.forEach(name => {
|
|
37
41
|
container.style.setProperty(name, originStyle.getPropertyValue(name));
|
|
38
42
|
});
|
|
39
|
-
|
|
40
|
-
container.style.left = '999999px';
|
|
41
|
-
container.style.top = '999999px';
|
|
42
|
-
container.style.zIndex = '-1000';
|
|
43
|
+
root.style.display = originDisplay;
|
|
43
44
|
container.style.height = 'auto';
|
|
44
45
|
container.style.minHeight = 'auto';
|
|
45
46
|
container.style.maxHeight = 'auto';
|
|
@@ -56,7 +57,9 @@ export const Ellipsis = p => {
|
|
|
56
57
|
} else {
|
|
57
58
|
setExceeded(true);
|
|
58
59
|
const end = props.content.length;
|
|
59
|
-
const
|
|
60
|
+
const collapseEl = typeof props.collapseText === 'string' ? props.collapseText : (_a = collapseElRef.current) === null || _a === void 0 ? void 0 : _a.innerHTML;
|
|
61
|
+
const expandEl = typeof props.expandText === 'string' ? props.expandText : (_b = expandElRef.current) === null || _b === void 0 ? void 0 : _b.innerHTML;
|
|
62
|
+
const actionText = expanded ? collapseEl : expandEl;
|
|
60
63
|
function check(left, right) {
|
|
61
64
|
if (right - left <= 1) {
|
|
62
65
|
if (props.direction === 'end') {
|
|
@@ -71,9 +74,9 @@ export const Ellipsis = p => {
|
|
|
71
74
|
}
|
|
72
75
|
const middle = Math.round((left + right) / 2);
|
|
73
76
|
if (props.direction === 'end') {
|
|
74
|
-
container.
|
|
77
|
+
container.innerHTML = getSubString(0, middle) + '...' + actionText;
|
|
75
78
|
} else {
|
|
76
|
-
container.
|
|
79
|
+
container.innerHTML = actionText + '...' + getSubString(middle, end);
|
|
77
80
|
}
|
|
78
81
|
if (container.offsetHeight <= maxHeight) {
|
|
79
82
|
if (props.direction === 'end') {
|
|
@@ -98,7 +101,7 @@ export const Ellipsis = p => {
|
|
|
98
101
|
}
|
|
99
102
|
const leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
|
100
103
|
const rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
|
101
|
-
container.
|
|
104
|
+
container.innerHTML = getSubString(0, leftPartMiddle) + '...' + actionText + '...' + getSubString(rightPartMiddle, end);
|
|
102
105
|
if (container.offsetHeight <= maxHeight) {
|
|
103
106
|
return checkMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);
|
|
104
107
|
} else {
|
|
@@ -116,24 +119,21 @@ export const Ellipsis = p => {
|
|
|
116
119
|
calcEllipsised();
|
|
117
120
|
}, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
|
|
118
121
|
const expandActionElement = exceeded && props.expandText ? withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
|
|
122
|
+
ref: expandElRef,
|
|
119
123
|
onClick: () => {
|
|
120
124
|
setExpanded(true);
|
|
121
125
|
}
|
|
122
126
|
}, props.expandText)) : null;
|
|
123
127
|
const collapseActionElement = exceeded && props.collapseText ? withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
|
|
128
|
+
ref: collapseElRef,
|
|
124
129
|
onClick: () => {
|
|
125
130
|
setExpanded(false);
|
|
126
131
|
}
|
|
127
132
|
}, props.collapseText)) : null;
|
|
128
133
|
const renderContent = () => {
|
|
129
|
-
if (!exceeded)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (expanded) {
|
|
133
|
-
return React.createElement(React.Fragment, null, props.content, collapseActionElement);
|
|
134
|
-
} else {
|
|
135
|
-
return React.createElement(React.Fragment, null, ellipsised.leading, expandActionElement, ellipsised.tailing);
|
|
136
|
-
}
|
|
134
|
+
if (!exceeded) return props.content;
|
|
135
|
+
if (expanded) return React.createElement(React.Fragment, null, props.content, collapseActionElement);
|
|
136
|
+
return React.createElement(React.Fragment, null, ellipsised.leading, expandActionElement, ellipsised.tailing);
|
|
137
137
|
};
|
|
138
138
|
return withNativeProps(props, React.createElement("div", {
|
|
139
139
|
ref: rootRef,
|
|
@@ -7,7 +7,7 @@ export const FormSubscribe = props => {
|
|
|
7
7
|
const form = useContext(FieldContext);
|
|
8
8
|
const value = form.getFieldsValue(props.to);
|
|
9
9
|
// Memo to avoid useless render
|
|
10
|
-
const childNode = React.useMemo(() => props.children(value, form), [JSON.stringify(value)]);
|
|
10
|
+
const childNode = React.useMemo(() => props.children(value, form), [JSON.stringify(value), props.children]);
|
|
11
11
|
return React.createElement(React.Fragment, null, childNode, props.to.map(namePath => React.createElement(Watcher, {
|
|
12
12
|
key: namePath.toString(),
|
|
13
13
|
form: form,
|
|
@@ -14,5 +14,5 @@ export declare type ImageProps = {
|
|
|
14
14
|
onError?: (event: React.SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
15
15
|
onLoad?: (event: React.SyntheticEvent<HTMLImageElement, Event>) => void;
|
|
16
16
|
onContainerClick?: (event: React.MouseEvent<HTMLDivElement, Event>) => void;
|
|
17
|
-
} & NativeProps<'--width' | '--height'> & Pick<React.ImgHTMLAttributes<HTMLImageElement>, 'crossOrigin' | 'decoding' | 'loading' | 'referrerPolicy' | 'sizes' | 'srcSet' | 'useMap'>;
|
|
17
|
+
} & NativeProps<'--width' | '--height'> & Pick<React.ImgHTMLAttributes<HTMLImageElement>, 'crossOrigin' | 'decoding' | 'loading' | 'referrerPolicy' | 'sizes' | 'srcSet' | 'useMap' | 'id'>;
|
|
18
18
|
export declare const Image: React.FC<ImageProps>;
|
|
@@ -4,7 +4,7 @@ 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' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step'> & {
|
|
7
|
+
export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'step' | 'id'> & {
|
|
8
8
|
value?: string;
|
|
9
9
|
defaultValue?: string;
|
|
10
10
|
onChange?: (val: string) => void;
|
|
@@ -14,7 +14,6 @@ export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength
|
|
|
14
14
|
clearable?: boolean;
|
|
15
15
|
onlyShowClearWhenFocus?: boolean;
|
|
16
16
|
onClear?: () => void;
|
|
17
|
-
id?: string;
|
|
18
17
|
onEnterPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
19
18
|
enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
20
19
|
min?: number;
|
|
@@ -26,7 +25,7 @@ export declare type InputRef = {
|
|
|
26
25
|
blur: () => void;
|
|
27
26
|
nativeElement: HTMLInputElement | null;
|
|
28
27
|
};
|
|
29
|
-
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "
|
|
28
|
+
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "type" | "step" | "autoFocus" | "autoCapitalize" | "autoCorrect" | "inputMode" | "name" | "autoComplete" | "maxLength" | "minLength"> & {
|
|
30
29
|
value?: string | undefined;
|
|
31
30
|
defaultValue?: string | undefined;
|
|
32
31
|
onChange?: ((val: string) => void) | undefined;
|
|
@@ -36,7 +35,6 @@ export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProp
|
|
|
36
35
|
clearable?: boolean | undefined;
|
|
37
36
|
onlyShowClearWhenFocus?: boolean | undefined;
|
|
38
37
|
onClear?: (() => void) | undefined;
|
|
39
|
-
id?: string | undefined;
|
|
40
38
|
onEnterPress?: ((e: React.KeyboardEvent<HTMLInputElement>) => void) | undefined;
|
|
41
39
|
enterKeyHint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined;
|
|
42
40
|
min?: number | undefined;
|
|
@@ -9,6 +9,6 @@ export declare type ListItemProps = {
|
|
|
9
9
|
clickable?: boolean;
|
|
10
10
|
arrow?: boolean | ReactNode;
|
|
11
11
|
disabled?: boolean;
|
|
12
|
-
onClick?: (e: React.MouseEvent) => void;
|
|
12
|
+
onClick?: (e: React.MouseEvent<HTMLElement>) => void;
|
|
13
13
|
} & NativeProps<'--prefix-width' | '--align-items' | '--active-background-color'>;
|
|
14
14
|
export declare const ListItem: FC<ListItemProps>;
|
|
@@ -13,6 +13,8 @@ export declare type NoticeBarProps = {
|
|
|
13
13
|
closeable?: boolean;
|
|
14
14
|
/** Callback when closed */
|
|
15
15
|
onClose?: () => void;
|
|
16
|
+
/** Event when click */
|
|
17
|
+
onClick?: () => void;
|
|
16
18
|
/** Additional operating area, displayed to the left of the close button */
|
|
17
19
|
extra?: React.ReactNode;
|
|
18
20
|
/** Radio icon on the left */
|
|
@@ -64,7 +64,8 @@ export const NoticeBar = memo(p => {
|
|
|
64
64
|
return withNativeProps(props, React.createElement("div", {
|
|
65
65
|
className: classNames(classPrefix, `${classPrefix}-${props.color}`, {
|
|
66
66
|
[`${classPrefix}-wrap`]: props.wrap
|
|
67
|
-
})
|
|
67
|
+
}),
|
|
68
|
+
onClick: props.onClick
|
|
68
69
|
}, props.icon && React.createElement("span", {
|
|
69
70
|
className: `${classPrefix}-left`
|
|
70
71
|
}, props.icon), React.createElement("span", {
|
|
@@ -3,5 +3,6 @@ import { NativeProps } from '../../utils/native-props';
|
|
|
3
3
|
import { PopupBaseProps } from './popup-base-props';
|
|
4
4
|
export declare type PopupProps = PopupBaseProps & PropsWithChildren<{
|
|
5
5
|
position?: 'bottom' | 'top' | 'left' | 'right';
|
|
6
|
+
closeOnSwipe?: boolean;
|
|
6
7
|
}> & NativeProps<'--z-index'>;
|
|
7
8
|
export declare const Popup: FC<PopupProps>;
|
|
@@ -16,6 +16,7 @@ import { useConfig } from '../config-provider';
|
|
|
16
16
|
import { useDrag } from '@use-gesture/react';
|
|
17
17
|
const classPrefix = `adm-popup`;
|
|
18
18
|
const defaultProps = Object.assign(Object.assign({}, defaultPopupBaseProps), {
|
|
19
|
+
closeOnSwipe: false,
|
|
19
20
|
position: 'bottom'
|
|
20
21
|
});
|
|
21
22
|
export const Popup = p => {
|
|
@@ -58,6 +59,7 @@ export const Popup = p => {
|
|
|
58
59
|
swipe: [, swipeY]
|
|
59
60
|
}) => {
|
|
60
61
|
var _a;
|
|
62
|
+
if (!props.closeOnSwipe) return;
|
|
61
63
|
if (swipeY === 1 && props.position === 'bottom' || swipeY === -1 && props.position === 'top') {
|
|
62
64
|
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
63
65
|
}
|
|
@@ -40,6 +40,7 @@ export const PullToRefresh = p => {
|
|
|
40
40
|
config: {
|
|
41
41
|
tension: 300,
|
|
42
42
|
friction: 30,
|
|
43
|
+
round: true,
|
|
43
44
|
clamp: true
|
|
44
45
|
}
|
|
45
46
|
}));
|
|
@@ -99,7 +100,8 @@ export const PullToRefresh = p => {
|
|
|
99
100
|
return;
|
|
100
101
|
}
|
|
101
102
|
const [, y] = state.movement;
|
|
102
|
-
|
|
103
|
+
const parsedY = Math.ceil(y);
|
|
104
|
+
if (state.first && parsedY > 0) {
|
|
103
105
|
const target = state.event.target;
|
|
104
106
|
if (!target || !(target instanceof Element)) return;
|
|
105
107
|
let scrollParent = getScrollParent(target);
|
|
@@ -124,7 +126,7 @@ export const PullToRefresh = p => {
|
|
|
124
126
|
event.preventDefault();
|
|
125
127
|
}
|
|
126
128
|
event.stopPropagation();
|
|
127
|
-
const height = Math.max(rubberbandIfOutOfBounds(
|
|
129
|
+
const height = Math.max(rubberbandIfOutOfBounds(parsedY, 0, 0, headHeight * 5, 0.5), 0);
|
|
128
130
|
api.start({
|
|
129
131
|
height
|
|
130
132
|
});
|