antd-mobile 5.41.0-alpha.1 → 5.41.0-alpha.3
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 +1480 -1410
- package/2x/bundle/antd-mobile.cjs.js +7 -7
- package/2x/bundle/antd-mobile.es.development.js +442 -372
- package/2x/bundle/antd-mobile.es.js +4843 -4796
- package/2x/bundle/antd-mobile.umd.development.js +1480 -1410
- package/2x/bundle/antd-mobile.umd.js +7 -7
- package/2x/cjs/components/avatar/avatar.d.ts +3 -1
- package/2x/cjs/components/avatar/avatar.js +4 -2
- package/2x/cjs/components/calendar/calendar.js +4 -4
- package/2x/cjs/components/ellipsis/useMeasure.js +4 -3
- package/2x/cjs/components/image/image.d.ts +1 -1
- package/2x/cjs/components/image/image.js +5 -5
- package/2x/cjs/components/image-viewer/image-viewer.d.ts +7 -4
- package/2x/cjs/components/image-viewer/index.d.ts +2 -1
- package/2x/cjs/components/image-viewer/methods.js +1 -1
- package/2x/cjs/components/image-viewer/slide.d.ts +3 -2
- package/2x/cjs/components/image-viewer/slide.js +2 -1
- package/2x/cjs/components/image-viewer/slides.d.ts +3 -2
- package/2x/cjs/components/input/input.d.ts +1 -1
- package/2x/cjs/components/input/input.js +1 -3
- package/2x/cjs/components/input/useInputHandleKeyDown.d.ts +1 -3
- package/2x/cjs/components/input/useInputHandleKeyDown.js +1 -12
- package/2x/cjs/components/number-keyboard/number-keyboard.js +21 -12
- package/2x/cjs/components/picker/index.d.ts +4 -2
- package/2x/cjs/components/swiper/swiper.d.ts +3 -3
- package/2x/cjs/components/swiper/swiper.js +47 -38
- package/2x/cjs/components/text-area/text-area.d.ts +1 -1
- package/2x/cjs/components/text-area/text-area.js +6 -7
- package/2x/es/components/avatar/avatar.d.ts +3 -1
- package/2x/es/components/avatar/avatar.js +4 -2
- package/2x/es/components/calendar/calendar.js +4 -4
- package/2x/es/components/ellipsis/useMeasure.js +4 -3
- package/2x/es/components/image/image.d.ts +1 -1
- package/2x/es/components/image/image.js +6 -6
- package/2x/es/components/image-viewer/image-viewer.d.ts +7 -4
- package/2x/es/components/image-viewer/index.d.ts +2 -1
- package/2x/es/components/image-viewer/methods.js +1 -1
- package/2x/es/components/image-viewer/slide.d.ts +3 -2
- package/2x/es/components/image-viewer/slide.js +2 -1
- package/2x/es/components/image-viewer/slides.d.ts +3 -2
- package/2x/es/components/input/input.d.ts +1 -1
- package/2x/es/components/input/input.js +1 -3
- package/2x/es/components/input/useInputHandleKeyDown.d.ts +1 -3
- package/2x/es/components/input/useInputHandleKeyDown.js +1 -12
- package/2x/es/components/number-keyboard/number-keyboard.js +21 -12
- package/2x/es/components/picker/index.d.ts +4 -2
- package/2x/es/components/swiper/swiper.d.ts +3 -3
- package/2x/es/components/swiper/swiper.js +28 -19
- package/2x/es/components/text-area/text-area.d.ts +1 -1
- package/2x/es/components/text-area/text-area.js +6 -7
- package/2x/package.json +1 -1
- package/bundle/antd-mobile.cjs.development.js +1480 -1410
- package/bundle/antd-mobile.cjs.js +7 -7
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +442 -372
- package/bundle/antd-mobile.es.js +4843 -4796
- package/bundle/antd-mobile.umd.development.js +1480 -1410
- package/bundle/antd-mobile.umd.js +7 -7
- package/cjs/components/avatar/avatar.d.ts +3 -1
- package/cjs/components/avatar/avatar.js +4 -2
- package/cjs/components/calendar/calendar.js +4 -4
- package/cjs/components/ellipsis/useMeasure.js +4 -3
- package/cjs/components/image/image.d.ts +1 -1
- package/cjs/components/image/image.js +5 -5
- package/cjs/components/image-viewer/image-viewer.d.ts +7 -4
- package/cjs/components/image-viewer/index.d.ts +2 -1
- package/cjs/components/image-viewer/methods.js +1 -1
- package/cjs/components/image-viewer/slide.d.ts +3 -2
- package/cjs/components/image-viewer/slide.js +2 -1
- package/cjs/components/image-viewer/slides.d.ts +3 -2
- package/cjs/components/input/input.d.ts +1 -1
- package/cjs/components/input/input.js +1 -3
- package/cjs/components/input/useInputHandleKeyDown.d.ts +1 -3
- package/cjs/components/input/useInputHandleKeyDown.js +1 -12
- package/cjs/components/number-keyboard/number-keyboard.js +21 -12
- package/cjs/components/picker/index.d.ts +4 -2
- package/cjs/components/swiper/swiper.d.ts +3 -3
- package/cjs/components/swiper/swiper.js +47 -38
- package/cjs/components/text-area/text-area.d.ts +1 -1
- package/cjs/components/text-area/text-area.js +6 -7
- package/es/components/avatar/avatar.d.ts +3 -1
- package/es/components/avatar/avatar.js +4 -2
- package/es/components/calendar/calendar.js +4 -4
- package/es/components/ellipsis/useMeasure.js +4 -3
- package/es/components/image/image.d.ts +1 -1
- package/es/components/image/image.js +6 -6
- package/es/components/image-viewer/image-viewer.d.ts +7 -4
- package/es/components/image-viewer/index.d.ts +2 -1
- package/es/components/image-viewer/methods.js +1 -1
- package/es/components/image-viewer/slide.d.ts +3 -2
- package/es/components/image-viewer/slide.js +2 -1
- package/es/components/image-viewer/slides.d.ts +3 -2
- package/es/components/input/input.d.ts +1 -1
- package/es/components/input/input.js +1 -3
- package/es/components/input/useInputHandleKeyDown.d.ts +1 -3
- package/es/components/input/useInputHandleKeyDown.js +1 -12
- package/es/components/number-keyboard/number-keyboard.js +21 -12
- package/es/components/picker/index.d.ts +4 -2
- package/es/components/swiper/swiper.d.ts +3 -3
- package/es/components/swiper/swiper.js +28 -19
- package/es/components/text-area/text-area.d.ts +1 -1
- package/es/components/text-area/text-area.js +6 -7
- package/package.json +1 -1
- package/umd/antd-mobile.js +1 -1
|
@@ -4,14 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TextArea = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
7
|
var _ahooks = require("ahooks");
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _runes = _interopRequireDefault(require("runes2"));
|
|
10
|
+
var _useInputHandleKeyDown = _interopRequireDefault(require("../../components/input/useInputHandleKeyDown"));
|
|
11
|
+
var _devLog = require("../../utils/dev-log");
|
|
10
12
|
var _nativeProps = require("../../utils/native-props");
|
|
11
13
|
var _usePropsValue = require("../../utils/use-props-value");
|
|
12
14
|
var _withDefaultProps = require("../../utils/with-default-props");
|
|
13
|
-
var _devLog = require("../../utils/dev-log");
|
|
14
|
-
var _useInputHandleKeyDown = _interopRequireDefault(require("../../components/input/useInputHandleKeyDown"));
|
|
15
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
17
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -42,9 +42,7 @@ const TextArea = (0, _react.forwardRef)((p, ref) => {
|
|
|
42
42
|
const hiddenTextAreaRef = (0, _react.useRef)(null);
|
|
43
43
|
const handleKeydown = (0, _useInputHandleKeyDown.default)({
|
|
44
44
|
onEnterPress: props.onEnterPress,
|
|
45
|
-
onKeyDown: props.onKeyDown
|
|
46
|
-
nativeInputRef: nativeTextAreaRef,
|
|
47
|
-
enterKeyHint: props.enterKeyHint
|
|
45
|
+
onKeyDown: props.onKeyDown
|
|
48
46
|
});
|
|
49
47
|
(0, _react.useImperativeHandle)(ref, () => ({
|
|
50
48
|
clear: () => {
|
|
@@ -140,7 +138,8 @@ const TextArea = (0, _react.forwardRef)((p, ref) => {
|
|
|
140
138
|
onFocus: props.onFocus,
|
|
141
139
|
onBlur: props.onBlur,
|
|
142
140
|
onClick: props.onClick,
|
|
143
|
-
onKeyDown: handleKeydown
|
|
141
|
+
onKeyDown: handleKeydown,
|
|
142
|
+
enterKeyHint: props.enterKeyHint
|
|
144
143
|
}), count, autoSize && _react.default.createElement("textarea", {
|
|
145
144
|
ref: hiddenTextAreaRef,
|
|
146
145
|
className: `${classPrefix}-element ${classPrefix}-element-hidden`,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { FC, ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
2
3
|
import { NativeProps } from '../../utils/native-props';
|
|
3
4
|
import { ImageProps } from '../image';
|
|
4
5
|
export declare type AvatarProps = {
|
|
5
6
|
src: string;
|
|
6
7
|
fallback?: ReactNode;
|
|
7
8
|
fit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
|
|
8
|
-
|
|
9
|
+
onClick?: (event: React.MouseEvent<HTMLDivElement | HTMLImageElement, Event>) => void;
|
|
10
|
+
} & Pick<ImageProps, 'alt' | 'lazy' | 'onError' | 'onLoad'> & NativeProps<'--size' | '--border-radius'>;
|
|
9
11
|
export declare const Avatar: FC<AvatarProps>;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
|
-
import { Fallback } from './fallback';
|
|
5
4
|
import Image from '../image';
|
|
5
|
+
import { Fallback } from './fallback';
|
|
6
6
|
const classPrefix = 'adm-avatar';
|
|
7
7
|
const defaultProps = {
|
|
8
8
|
fallback: React.createElement(Fallback, null),
|
|
9
9
|
fit: 'cover'
|
|
10
10
|
};
|
|
11
11
|
export const Avatar = p => {
|
|
12
|
+
var _a;
|
|
12
13
|
const props = mergeProps(defaultProps, p);
|
|
14
|
+
const mergedSrc = ((_a = props.src) === null || _a === void 0 ? void 0 : _a.trim()) || undefined;
|
|
13
15
|
return withNativeProps(props, React.createElement(Image, {
|
|
14
16
|
className: classPrefix,
|
|
15
|
-
src:
|
|
17
|
+
src: mergedSrc,
|
|
16
18
|
fallback: props.fallback,
|
|
17
19
|
placeholder: props.fallback,
|
|
18
20
|
alt: props.alt,
|
|
@@ -87,12 +87,12 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
87
87
|
};
|
|
88
88
|
const header = React.createElement("div", {
|
|
89
89
|
className: `${classPrefix}-header`
|
|
90
|
-
}, React.createElement("a", {
|
|
90
|
+
}, props.prevYearButton !== null && React.createElement("a", {
|
|
91
91
|
className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-year`,
|
|
92
92
|
onClick: () => {
|
|
93
93
|
handlePageChange('subtract', 1, 'year');
|
|
94
94
|
}
|
|
95
|
-
}, props.prevYearButton), React.createElement("a", {
|
|
95
|
+
}, props.prevYearButton), props.prevMonthButton !== null && React.createElement("a", {
|
|
96
96
|
className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-month`,
|
|
97
97
|
onClick: () => {
|
|
98
98
|
handlePageChange('subtract', 1, 'month');
|
|
@@ -102,12 +102,12 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
102
102
|
}, replaceMessage(locale.Calendar.yearAndMonth, {
|
|
103
103
|
year: current.year().toString(),
|
|
104
104
|
month: (current.month() + 1).toString()
|
|
105
|
-
})), React.createElement("a", {
|
|
105
|
+
})), props.nextMonthButton !== null && React.createElement("a", {
|
|
106
106
|
className: classNames(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-month`),
|
|
107
107
|
onClick: () => {
|
|
108
108
|
handlePageChange('add', 1, 'month');
|
|
109
109
|
}
|
|
110
|
-
}, props.nextMonthButton), React.createElement("a", {
|
|
110
|
+
}, props.nextMonthButton), props.nextYearButton !== null && React.createElement("a", {
|
|
111
111
|
className: classNames(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-year`),
|
|
112
112
|
onClick: () => {
|
|
113
113
|
handlePageChange('add', 1, 'year');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEvent } from 'rc-util';
|
|
2
|
+
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { unstable_batchedUpdates } from 'react-dom';
|
|
4
5
|
import runes from 'runes2';
|
|
@@ -27,11 +28,11 @@ export default function useMeasure(containerRef, content, rows, direction, expan
|
|
|
27
28
|
});
|
|
28
29
|
});
|
|
29
30
|
// Initialize
|
|
30
|
-
|
|
31
|
+
useLayoutEffect(() => {
|
|
31
32
|
startMeasure();
|
|
32
33
|
}, [contentChars, rows]);
|
|
33
34
|
// Measure element height
|
|
34
|
-
|
|
35
|
+
useLayoutEffect(() => {
|
|
35
36
|
var _a, _b;
|
|
36
37
|
if (status === 1 /* PREPARE */) {
|
|
37
38
|
const fullMeasureHeight = ((_a = fullMeasureRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) || 0;
|
|
@@ -46,7 +47,7 @@ export default function useMeasure(containerRef, content, rows, direction, expan
|
|
|
46
47
|
}
|
|
47
48
|
}, [status]);
|
|
48
49
|
// Walking measure
|
|
49
|
-
|
|
50
|
+
useLayoutEffect(() => {
|
|
50
51
|
var _a;
|
|
51
52
|
if (status === 2 /* MEASURE_WALKING */) {
|
|
52
53
|
const diff = walkingIndexes[1] - walkingIndexes[0];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
3
|
-
import { withNativeProps } from '../../utils/native-props';
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
4
2
|
import { staged } from 'staged-components';
|
|
3
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
5
4
|
import { toCSSLength } from '../../utils/to-css-length';
|
|
6
|
-
import { LazyDetector } from './lazy-detector';
|
|
7
5
|
import { useIsomorphicUpdateLayoutEffect } from '../../utils/use-isomorphic-update-layout-effect';
|
|
8
|
-
import {
|
|
6
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
9
7
|
import { BrokenImageIcon } from './broken-image-icon';
|
|
8
|
+
import { ImageIcon } from './image-icon';
|
|
9
|
+
import { LazyDetector } from './lazy-detector';
|
|
10
10
|
const classPrefix = `adm-image`;
|
|
11
11
|
const defaultProps = {
|
|
12
12
|
fit: 'fill',
|
|
@@ -42,7 +42,7 @@ export const Image = staged(p => {
|
|
|
42
42
|
}
|
|
43
43
|
}, []);
|
|
44
44
|
function renderInner() {
|
|
45
|
-
if (failed) {
|
|
45
|
+
if (failed || src === undefined && !srcSet) {
|
|
46
46
|
return React.createElement(React.Fragment, null, props.fallback);
|
|
47
47
|
}
|
|
48
48
|
const img = React.createElement("img", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FC, ReactNode } from 'react';
|
|
1
|
+
import type { FC, ReactNode, RefObject } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { GetContainer } from '../../utils/render-to-container';
|
|
4
4
|
import { SlidesRef } from './slides';
|
|
@@ -10,7 +10,8 @@ export declare type ImageViewerProps = {
|
|
|
10
10
|
onClose?: () => void;
|
|
11
11
|
afterClose?: () => void;
|
|
12
12
|
renderFooter?: (image: string) => ReactNode;
|
|
13
|
-
imageRender?: (image: string, { index }: {
|
|
13
|
+
imageRender?: (image: string, { ref, index }: {
|
|
14
|
+
ref: RefObject<HTMLImageElement>;
|
|
14
15
|
index: number;
|
|
15
16
|
}) => ReactNode;
|
|
16
17
|
classNames?: {
|
|
@@ -25,7 +26,8 @@ export declare type MultiImageViewerProps = Omit<ImageViewerProps, 'image' | 're
|
|
|
25
26
|
defaultIndex?: number;
|
|
26
27
|
onIndexChange?: (index: number) => void;
|
|
27
28
|
renderFooter?: (image: string, index: number) => ReactNode;
|
|
28
|
-
imageRender?: (image: string, { index }: {
|
|
29
|
+
imageRender?: (image: string, { ref, index }: {
|
|
30
|
+
ref: RefObject<HTMLImageElement>;
|
|
29
31
|
index: number;
|
|
30
32
|
}) => ReactNode;
|
|
31
33
|
};
|
|
@@ -34,7 +36,8 @@ export declare const MultiImageViewer: React.ForwardRefExoticComponent<Omit<Imag
|
|
|
34
36
|
defaultIndex?: number | undefined;
|
|
35
37
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
36
38
|
renderFooter?: ((image: string, index: number) => ReactNode) | undefined;
|
|
37
|
-
imageRender?: ((image: string, { index }: {
|
|
39
|
+
imageRender?: ((image: string, { ref, index }: {
|
|
40
|
+
ref: RefObject<HTMLImageElement>;
|
|
38
41
|
index: number;
|
|
39
42
|
}) => ReactNode) | undefined;
|
|
40
43
|
} & React.RefAttributes<SlidesRef>>;
|
|
@@ -8,7 +8,8 @@ declare const _default: import("react").FC<import("./image-viewer").ImageViewerP
|
|
|
8
8
|
defaultIndex?: number | undefined;
|
|
9
9
|
onIndexChange?: ((index: number) => void) | undefined;
|
|
10
10
|
renderFooter?: ((image: string, index: number) => import("react").ReactNode) | undefined;
|
|
11
|
-
imageRender?: ((image: string, { index }: {
|
|
11
|
+
imageRender?: ((image: string, { ref, index }: {
|
|
12
|
+
ref: import("react").RefObject<HTMLImageElement>;
|
|
12
13
|
index: number;
|
|
13
14
|
}) => import("react").ReactNode) | undefined;
|
|
14
15
|
} & import("react").RefAttributes<import("./slides").SlidesRef>> & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ImageViewer, MultiImageViewer } from './image-viewer';
|
|
3
2
|
import { renderImperatively } from '../../utils/render-imperatively';
|
|
3
|
+
import { ImageViewer, MultiImageViewer } from './image-viewer';
|
|
4
4
|
const handlerSet = new Set();
|
|
5
5
|
export function showImageViewer(props) {
|
|
6
6
|
clearImageViewer();
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { FC, MutableRefObject, ReactNode } from 'react';
|
|
1
|
+
import type { FC, MutableRefObject, ReactNode, RefObject } from 'react';
|
|
2
2
|
declare type Props = {
|
|
3
3
|
image: string;
|
|
4
4
|
maxZoom: number | 'auto';
|
|
5
5
|
onTap?: () => void;
|
|
6
6
|
onZoomChange?: (zoom: number) => void;
|
|
7
7
|
dragLockRef?: MutableRefObject<boolean>;
|
|
8
|
-
imageRender?: (image: string, { index }: {
|
|
8
|
+
imageRender?: (image: string, { ref, index }: {
|
|
9
|
+
ref: RefObject<HTMLImageElement>;
|
|
9
10
|
index: number;
|
|
10
11
|
}) => ReactNode;
|
|
11
12
|
index?: number;
|
|
@@ -222,7 +222,8 @@ export const Slide = props => {
|
|
|
222
222
|
}
|
|
223
223
|
});
|
|
224
224
|
const customRendering = typeof imageRender === 'function' && imageRender(props.image, {
|
|
225
|
-
|
|
225
|
+
ref: imgRef,
|
|
226
|
+
index: index !== null && index !== void 0 ? index : 0
|
|
226
227
|
});
|
|
227
228
|
return React.createElement("div", {
|
|
228
229
|
className: `${classPrefix}-slide`
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode, RefObject } from 'react';
|
|
2
2
|
export declare type SlidesType = {
|
|
3
3
|
images: string[];
|
|
4
4
|
onTap?: () => void;
|
|
5
5
|
maxZoom: number;
|
|
6
6
|
defaultIndex: number;
|
|
7
7
|
onIndexChange?: (index: number) => void;
|
|
8
|
-
imageRender?: (image: string, { index }: {
|
|
8
|
+
imageRender?: (image: string, { ref, index }: {
|
|
9
|
+
ref: RefObject<HTMLImageElement>;
|
|
9
10
|
index: number;
|
|
10
11
|
}) => ReactNode;
|
|
11
12
|
};
|
|
@@ -22,7 +22,7 @@ export declare type InputRef = {
|
|
|
22
22
|
blur: () => void;
|
|
23
23
|
nativeElement: HTMLInputElement | null;
|
|
24
24
|
};
|
|
25
|
-
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "disabled" | "onPaste" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "type" | "step" | "
|
|
25
|
+
export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "id" | "onClick" | "disabled" | "onPaste" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "type" | "step" | "autoCapitalize" | "autoFocus" | "enterKeyHint" | "autoCorrect" | "inputMode" | "placeholder" | "name" | "readOnly" | "autoComplete" | "maxLength" | "minLength"> & {
|
|
26
26
|
value?: string | undefined;
|
|
27
27
|
defaultValue?: string | undefined;
|
|
28
28
|
onChange?: ((val: string) => void) | undefined;
|
|
@@ -26,9 +26,7 @@ export const Input = forwardRef((props, ref) => {
|
|
|
26
26
|
const nativeInputRef = useRef(null);
|
|
27
27
|
const handleKeydown = useInputHandleKeyDown({
|
|
28
28
|
onEnterPress: mergedProps.onEnterPress,
|
|
29
|
-
onKeyDown: mergedProps.onKeyDown
|
|
30
|
-
nativeInputRef,
|
|
31
|
-
enterKeyHint: mergedProps.enterKeyHint
|
|
29
|
+
onKeyDown: mergedProps.onKeyDown
|
|
32
30
|
});
|
|
33
31
|
useImperativeHandle(ref, () => ({
|
|
34
32
|
clear: () => {
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
interface InputHandleKeyDownType<T> {
|
|
2
2
|
onEnterPress?: (e: React.KeyboardEvent<T>) => void;
|
|
3
3
|
onKeyDown?: (e: React.KeyboardEvent<T>) => void;
|
|
4
|
-
enterKeyHint?: React.InputHTMLAttributes<HTMLInputElement>['enterKeyHint'];
|
|
5
|
-
nativeInputRef: React.RefObject<T>;
|
|
6
4
|
}
|
|
7
|
-
export default function useInputHandleKeyDown<T extends HTMLInputElement | HTMLTextAreaElement>({ onEnterPress, onKeyDown
|
|
5
|
+
export default function useInputHandleKeyDown<T extends HTMLInputElement | HTMLTextAreaElement>({ onEnterPress, onKeyDown }: InputHandleKeyDownType<T>): (e: React.KeyboardEvent<T>) => void;
|
|
8
6
|
export {};
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
2
1
|
export default function useInputHandleKeyDown({
|
|
3
2
|
onEnterPress,
|
|
4
|
-
onKeyDown
|
|
5
|
-
nativeInputRef,
|
|
6
|
-
enterKeyHint
|
|
3
|
+
onKeyDown
|
|
7
4
|
}) {
|
|
8
5
|
const handleKeydown = e => {
|
|
9
6
|
if (onEnterPress && (e.code === 'Enter' || e.keyCode === 13)) {
|
|
@@ -11,13 +8,5 @@ export default function useInputHandleKeyDown({
|
|
|
11
8
|
}
|
|
12
9
|
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
13
10
|
};
|
|
14
|
-
useIsomorphicLayoutEffect(() => {
|
|
15
|
-
const ele = nativeInputRef.current;
|
|
16
|
-
if (!enterKeyHint || !ele) return;
|
|
17
|
-
ele.setAttribute('enterkeyhint', enterKeyHint);
|
|
18
|
-
return () => {
|
|
19
|
-
ele.removeAttribute('enterkeyhint');
|
|
20
|
-
};
|
|
21
|
-
}, [enterKeyHint]);
|
|
22
11
|
return handleKeydown;
|
|
23
12
|
}
|
|
@@ -108,6 +108,7 @@ export const NumberKeyboard = p => {
|
|
|
108
108
|
};
|
|
109
109
|
const renderKey = (key, index) => {
|
|
110
110
|
const isNumberKey = /^\d$/.test(key);
|
|
111
|
+
const isBackspace = key === 'BACKSPACE';
|
|
111
112
|
const className = classNames(`${classPrefix}-key`, {
|
|
112
113
|
[`${classPrefix}-key-number`]: isNumberKey,
|
|
113
114
|
[`${classPrefix}-key-sign`]: !isNumberKey && key,
|
|
@@ -115,25 +116,29 @@ export const NumberKeyboard = p => {
|
|
|
115
116
|
});
|
|
116
117
|
const ariaProps = key ? {
|
|
117
118
|
role: 'button',
|
|
118
|
-
title: key,
|
|
119
|
+
title: isBackspace ? locale.Input.clear : key,
|
|
119
120
|
tabIndex: -1
|
|
120
121
|
} : undefined;
|
|
121
122
|
return React.createElement("div", Object.assign({
|
|
122
123
|
key: key,
|
|
123
124
|
className: className,
|
|
124
|
-
|
|
125
|
+
// 仅为 backspace 绑定,支持长按快速删除
|
|
126
|
+
onTouchStart: isBackspace ? () => {
|
|
127
|
+
stopContinueClear();
|
|
128
|
+
startContinueClear();
|
|
129
|
+
} : undefined,
|
|
130
|
+
onTouchEnd: isBackspace ? e => {
|
|
131
|
+
stopContinueClear();
|
|
132
|
+
onKeyPress(e, key);
|
|
133
|
+
} : undefined,
|
|
134
|
+
// <div role="button" title="1" onTouchEnd={e => {}}>1</div> 安卓上 talback 可读不可点
|
|
135
|
+
// see https://ua-gilded-eef7f9.netlify.app/grid-button-bug.html
|
|
136
|
+
// 所以还是绑定 click,通过 touchEnd 的 preventDefault 防重复触发
|
|
137
|
+
onClick: e => {
|
|
125
138
|
stopContinueClear();
|
|
126
|
-
if (key === 'BACKSPACE') {
|
|
127
|
-
startContinueClear();
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
onTouchEnd: e => {
|
|
131
139
|
onKeyPress(e, key);
|
|
132
|
-
if (key === 'BACKSPACE') {
|
|
133
|
-
stopContinueClear();
|
|
134
|
-
}
|
|
135
140
|
}
|
|
136
|
-
}, ariaProps),
|
|
141
|
+
}, ariaProps), isBackspace ? React.createElement(TextDeletionOutline, null) : key);
|
|
137
142
|
};
|
|
138
143
|
return React.createElement(Popup, {
|
|
139
144
|
visible: visible,
|
|
@@ -165,8 +170,12 @@ export const NumberKeyboard = p => {
|
|
|
165
170
|
startContinueClear();
|
|
166
171
|
},
|
|
167
172
|
onTouchEnd: e => {
|
|
173
|
+
stopContinueClear();
|
|
168
174
|
onKeyPress(e, 'BACKSPACE');
|
|
175
|
+
},
|
|
176
|
+
onClick: e => {
|
|
169
177
|
stopContinueClear();
|
|
178
|
+
onKeyPress(e, 'BACKSPACE');
|
|
170
179
|
},
|
|
171
180
|
onContextMenu: e => {
|
|
172
181
|
// Long press should not trigger native context menu
|
|
@@ -177,7 +186,7 @@ export const NumberKeyboard = p => {
|
|
|
177
186
|
tabIndex: -1
|
|
178
187
|
}, React.createElement(TextDeletionOutline, null)), React.createElement("div", {
|
|
179
188
|
className: `${classPrefix}-key ${classPrefix}-key-extra ${classPrefix}-key-ok`,
|
|
180
|
-
|
|
189
|
+
onClick: e => onKeyPress(e, 'OK'),
|
|
181
190
|
role: 'button',
|
|
182
191
|
tabIndex: -1,
|
|
183
192
|
"aria-label": confirmText
|
|
@@ -2,7 +2,7 @@ import './picker.less';
|
|
|
2
2
|
import { prompt } from './prompt';
|
|
3
3
|
export type { PickerProps, PickerRef, PickerActions } from './picker';
|
|
4
4
|
export type { PickerValue, PickerColumnItem, PickerColumn, PickerValueExtend, } from '../picker-view';
|
|
5
|
-
declare const _default: import("react").NamedExoticComponent<{
|
|
5
|
+
declare const _default: import("react").NamedExoticComponent<Omit<{
|
|
6
6
|
columns: import("../picker-view").PickerColumn[] | ((value: import("../picker-view").PickerValue[]) => import("../picker-view").PickerColumn[]);
|
|
7
7
|
value?: import("../picker-view").PickerValue[] | undefined;
|
|
8
8
|
defaultValue?: import("../picker-view").PickerValue[] | undefined;
|
|
@@ -26,7 +26,9 @@ declare const _default: import("react").NamedExoticComponent<{
|
|
|
26
26
|
className?: string | undefined;
|
|
27
27
|
style?: (import("react").CSSProperties & Partial<Record<"--header-button-font-size" | "--title-font-size" | "--item-font-size" | "--item-height", string>>) | undefined;
|
|
28
28
|
tabIndex?: number | undefined;
|
|
29
|
-
} & import("react").AriaAttributes & import("react").RefAttributes<import("./picker").PickerActions
|
|
29
|
+
} & import("react").AriaAttributes & import("react").RefAttributes<import("./picker").PickerActions>, "ref"> & {
|
|
30
|
+
ref?: ((instance: import("./picker").PickerActions | null) => void) | import("react").RefObject<import("./picker").PickerActions> | null | undefined;
|
|
31
|
+
}> & {
|
|
30
32
|
readonly type: import("react").ForwardRefExoticComponent<{
|
|
31
33
|
columns: import("../picker-view").PickerColumn[] | ((value: import("../picker-view").PickerValue[]) => import("../picker-view").PickerColumn[]);
|
|
32
34
|
value?: import("../picker-view").PickerValue[] | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import type { ReactNode, ReactElement } from 'react';
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
4
|
import { PageIndicatorProps } from '../page-indicator';
|
|
5
5
|
declare const eventToPropRecord: {
|
|
@@ -59,10 +59,10 @@ export declare const Swiper: React.ForwardRefExoticComponent<{
|
|
|
59
59
|
/**
|
|
60
60
|
* renderProps is only work when `total` used
|
|
61
61
|
*/
|
|
62
|
-
children?:
|
|
62
|
+
children?: ReactElement<any, string | React.JSXElementConstructor<any>> | ReactElement<any, string | React.JSXElementConstructor<any>>[] | ((index: number) => ReactElement) | undefined;
|
|
63
63
|
} & {
|
|
64
64
|
className?: string | undefined;
|
|
65
|
-
style?: (
|
|
65
|
+
style?: (CSSProperties & Partial<Record<"--width" | "--height" | "--border-radius" | "--track-padding", string>>) | undefined;
|
|
66
66
|
tabIndex?: number | undefined;
|
|
67
67
|
} & React.AriaAttributes & React.RefAttributes<SwiperRef>>;
|
|
68
68
|
export {};
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { withNativeProps } from '../../utils/native-props';
|
|
3
|
-
import { mergeProps } from '../../utils/with-default-props';
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
import { SwiperItem } from './swiper-item';
|
|
6
|
-
import { devWarning } from '../../utils/dev-log';
|
|
7
|
-
import { useSpring, animated } from '@react-spring/web';
|
|
1
|
+
import { animated, useSpring } from '@react-spring/web';
|
|
8
2
|
import { useDrag } from '@use-gesture/react';
|
|
9
|
-
import
|
|
3
|
+
import { useGetState, useIsomorphicLayoutEffect } from 'ahooks';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import toArray from 'rc-util/lib/Children/toArray';
|
|
6
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
10
7
|
import { staged } from 'staged-components';
|
|
11
|
-
import { useRefState } from '../../utils/use-ref-state';
|
|
12
8
|
import { bound } from '../../utils/bound';
|
|
13
|
-
import {
|
|
9
|
+
import { devWarning } from '../../utils/dev-log';
|
|
10
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
11
|
+
import { useRefState } from '../../utils/use-ref-state';
|
|
12
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
14
13
|
import { mergeFuncProps } from '../../utils/with-func-props';
|
|
14
|
+
import PageIndicator from '../page-indicator';
|
|
15
|
+
import { SwiperItem } from './swiper-item';
|
|
15
16
|
const classPrefix = `adm-swiper`;
|
|
16
17
|
const eventToPropRecord = {
|
|
17
18
|
'mousedown': 'onMouseDown',
|
|
@@ -56,14 +57,15 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
56
57
|
if (typeof children === 'function') {
|
|
57
58
|
renderChildren = children;
|
|
58
59
|
} else {
|
|
59
|
-
|
|
60
|
+
const childrenArray = toArray(children);
|
|
61
|
+
validChildren = childrenArray.filter(child => {
|
|
60
62
|
if (!React.isValidElement(child)) return null;
|
|
61
63
|
if (child.type !== SwiperItem) {
|
|
62
64
|
devWarning('Swiper', 'The children of `Swiper` must be `Swiper.Item` components.');
|
|
63
|
-
return
|
|
65
|
+
return false;
|
|
64
66
|
}
|
|
65
67
|
count++;
|
|
66
|
-
return
|
|
68
|
+
return true;
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
return {
|
|
@@ -236,7 +238,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
236
238
|
}, [autoplay, autoplayInterval, dragging, mergedTotal]);
|
|
237
239
|
// ============================== Render ==============================
|
|
238
240
|
// Render Item
|
|
239
|
-
function renderItem(index, child) {
|
|
241
|
+
function renderItem(index, child, key) {
|
|
240
242
|
let itemStyle = {};
|
|
241
243
|
if (loop) {
|
|
242
244
|
itemStyle = {
|
|
@@ -255,10 +257,10 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
255
257
|
[`${classPrefix}-slide-active`]: current === index
|
|
256
258
|
}),
|
|
257
259
|
style: itemStyle,
|
|
258
|
-
key: index
|
|
260
|
+
key: key !== null && key !== void 0 ? key : index
|
|
259
261
|
}, child);
|
|
260
262
|
}
|
|
261
|
-
|
|
263
|
+
const renderStableItems = () => {
|
|
262
264
|
if (renderChildren && total) {
|
|
263
265
|
const offsetCount = 2;
|
|
264
266
|
const startIndex = Math.max(current - offsetCount, 0);
|
|
@@ -274,9 +276,16 @@ export const Swiper = forwardRef(staged((p, ref) => {
|
|
|
274
276
|
}
|
|
275
277
|
}), items);
|
|
276
278
|
}
|
|
277
|
-
|
|
278
|
-
return
|
|
279
|
-
|
|
279
|
+
if (validChildren) {
|
|
280
|
+
return validChildren.map((child, index) => {
|
|
281
|
+
var _a;
|
|
282
|
+
return renderItem(index, child, (_a = child === null || child === void 0 ? void 0 : child.key) !== null && _a !== void 0 ? _a : index);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
};
|
|
287
|
+
function renderItems() {
|
|
288
|
+
return renderStableItems();
|
|
280
289
|
}
|
|
281
290
|
// Render Track Inner
|
|
282
291
|
function renderTrackInner() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
4
|
export declare type TextAreaProps = Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'autoComplete' | 'autoFocus' | 'disabled' | 'readOnly' | 'name' | 'onFocus' | 'onBlur' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick' | 'onKeyDown'> & {
|
|
5
5
|
onChange?: (val: string) => void;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
2
1
|
import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
2
|
+
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
|
|
3
3
|
import runes from 'runes2';
|
|
4
|
+
import useInputHandleKeyDown from '../../components/input/useInputHandleKeyDown';
|
|
5
|
+
import { devError } from '../../utils/dev-log';
|
|
4
6
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
7
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
6
8
|
import { mergeProps } from '../../utils/with-default-props';
|
|
7
|
-
import { devError } from '../../utils/dev-log';
|
|
8
|
-
import useInputHandleKeyDown from '../../components/input/useInputHandleKeyDown';
|
|
9
9
|
const classPrefix = 'adm-text-area';
|
|
10
10
|
const defaultProps = {
|
|
11
11
|
rows: 2,
|
|
@@ -33,9 +33,7 @@ export const TextArea = forwardRef((p, ref) => {
|
|
|
33
33
|
const hiddenTextAreaRef = useRef(null);
|
|
34
34
|
const handleKeydown = useInputHandleKeyDown({
|
|
35
35
|
onEnterPress: props.onEnterPress,
|
|
36
|
-
onKeyDown: props.onKeyDown
|
|
37
|
-
nativeInputRef: nativeTextAreaRef,
|
|
38
|
-
enterKeyHint: props.enterKeyHint
|
|
36
|
+
onKeyDown: props.onKeyDown
|
|
39
37
|
});
|
|
40
38
|
useImperativeHandle(ref, () => ({
|
|
41
39
|
clear: () => {
|
|
@@ -131,7 +129,8 @@ export const TextArea = forwardRef((p, ref) => {
|
|
|
131
129
|
onFocus: props.onFocus,
|
|
132
130
|
onBlur: props.onBlur,
|
|
133
131
|
onClick: props.onClick,
|
|
134
|
-
onKeyDown: handleKeydown
|
|
132
|
+
onKeyDown: handleKeydown,
|
|
133
|
+
enterKeyHint: props.enterKeyHint
|
|
135
134
|
}), count, autoSize && React.createElement("textarea", {
|
|
136
135
|
ref: hiddenTextAreaRef,
|
|
137
136
|
className: `${classPrefix}-element ${classPrefix}-element-hidden`,
|
package/2x/package.json
CHANGED