antd-mobile 5.0.0-rc.23 → 5.0.0-rc.27
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 +6 -6
- package/2x/cjs/components/button/button.css +2 -2
- package/2x/cjs/components/calendar/calendar.js +3 -1
- package/2x/cjs/components/cascade-picker-view/cascade-picker-view.d.ts +1 -2
- package/2x/cjs/components/date-picker/date-picker.d.ts +1 -1
- package/2x/cjs/components/date-picker-view/date-picker-view.d.ts +3 -2
- package/2x/cjs/components/dialog/dialog.css +4 -0
- package/2x/cjs/components/dropdown/dropdown.css +0 -4
- package/2x/cjs/components/dropdown/item.js +3 -1
- package/2x/cjs/components/ellipsis/ellipsis.js +3 -1
- package/2x/cjs/components/empty/empty.css +1 -1
- package/2x/cjs/components/floating-bubble/floating-bubble.css +1 -0
- 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.css +4 -6
- package/2x/cjs/components/form/form-item.d.ts +2 -2
- package/2x/cjs/components/form/form-item.js +9 -5
- package/2x/cjs/components/form/form.css +3 -3
- package/2x/cjs/components/form/form.d.ts +5 -4
- package/2x/cjs/components/form/index.css +7 -9
- package/2x/cjs/components/form/index.d.ts +5 -4
- package/2x/cjs/components/image-uploader/image-uploader.js +1 -1
- package/2x/cjs/components/image-viewer/image-viewer.css +2 -0
- package/2x/cjs/components/image-viewer/image-viewer.js +12 -2
- package/2x/cjs/components/image-viewer/slide.js +11 -7
- package/2x/cjs/components/image-viewer/slides.d.ts +1 -1
- package/2x/cjs/components/index-bar/index-bar.css +2 -1
- package/2x/cjs/components/input/input.d.ts +6 -2
- package/2x/cjs/components/input/input.js +23 -3
- package/2x/cjs/components/list/list.css +8 -10
- package/2x/cjs/components/picker/picker.css +10 -2
- package/2x/cjs/components/picker/picker.d.ts +2 -1
- package/2x/cjs/components/picker/picker.js +3 -1
- package/2x/cjs/components/picker-view/picker-view.css +2 -1
- package/2x/cjs/components/picker-view/picker-view.d.ts +1 -1
- package/2x/cjs/components/picker-view/wheel.js +4 -2
- package/2x/cjs/components/popover/arrow.d.ts +3 -0
- package/2x/cjs/components/popover/arrow.js +26 -0
- package/2x/cjs/components/popover/index.d.ts +10 -20
- package/2x/cjs/components/popover/index.js +4 -2
- package/2x/cjs/components/popover/popover-menu.css +63 -0
- package/2x/cjs/components/popover/popover-menu.d.ts +17 -0
- package/{cjs/components/popover/pop-menu.js → 2x/cjs/components/popover/popover-menu.js} +23 -26
- package/2x/cjs/components/popover/popover.css +90 -318
- package/2x/cjs/components/popover/popover.d.ts +9 -8
- package/2x/cjs/components/popover/popover.js +11 -17
- package/2x/cjs/components/radio/radio.js +2 -3
- 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/text-area/text-area.css +9 -9
- package/2x/cjs/components/text-area/text-area.d.ts +2 -2
- package/2x/cjs/components/text-area/text-area.js +41 -32
- 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/cascade-picker-view/cascade-picker-view.d.ts +1 -2
- package/2x/es/components/date-picker/date-picker.d.ts +1 -1
- package/2x/es/components/date-picker-view/date-picker-view.d.ts +3 -2
- package/2x/es/components/dialog/dialog.css +4 -0
- package/2x/es/components/dropdown/dropdown.css +0 -4
- package/2x/es/components/dropdown/item.js +3 -1
- package/2x/es/components/ellipsis/ellipsis.js +3 -2
- package/2x/es/components/empty/empty.css +1 -1
- package/2x/es/components/floating-bubble/floating-bubble.css +1 -0
- 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.css +4 -6
- package/2x/es/components/form/form-item.d.ts +2 -2
- package/2x/es/components/form/form-item.js +9 -5
- package/2x/es/components/form/form.css +3 -3
- package/2x/es/components/form/form.d.ts +5 -4
- package/2x/es/components/form/index.css +7 -9
- package/2x/es/components/form/index.d.ts +5 -4
- package/2x/es/components/image-uploader/image-uploader.js +3 -3
- package/2x/es/components/image-viewer/image-viewer.css +2 -0
- package/2x/es/components/image-viewer/image-viewer.js +13 -3
- package/2x/es/components/image-viewer/slide.js +11 -7
- package/2x/es/components/image-viewer/slides.d.ts +1 -1
- package/2x/es/components/index-bar/index-bar.css +2 -1
- package/2x/es/components/input/input.d.ts +6 -2
- package/2x/es/components/input/input.js +22 -4
- package/2x/es/components/list/list.css +8 -10
- package/2x/es/components/picker/picker.css +10 -2
- package/2x/es/components/picker/picker.d.ts +2 -1
- package/2x/es/components/picker/picker.js +3 -1
- package/2x/es/components/picker-view/picker-view.css +2 -1
- package/2x/es/components/picker-view/picker-view.d.ts +1 -1
- package/2x/es/components/picker-view/wheel.js +4 -3
- package/2x/es/components/popover/arrow.d.ts +3 -0
- package/2x/es/components/popover/arrow.js +12 -0
- package/2x/es/components/popover/index.d.ts +10 -20
- package/2x/es/components/popover/index.js +3 -2
- package/2x/es/components/popover/popover-menu.css +63 -0
- package/2x/es/components/popover/popover-menu.d.ts +17 -0
- package/2x/es/components/popover/popover-menu.js +52 -0
- package/2x/es/components/popover/popover.css +90 -318
- package/2x/es/components/popover/popover.d.ts +9 -8
- package/2x/es/components/popover/popover.js +10 -17
- package/2x/es/components/radio/radio.js +2 -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/text-area/text-area.css +9 -9
- package/2x/es/components/text-area/text-area.d.ts +2 -2
- package/2x/es/components/text-area/text-area.js +41 -31
- 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 +5 -5
- package/README.md +6 -6
- package/cjs/components/button/button.css +2 -2
- package/cjs/components/calendar/calendar.js +3 -1
- package/cjs/components/cascade-picker-view/cascade-picker-view.d.ts +1 -2
- package/cjs/components/date-picker/date-picker.d.ts +1 -1
- package/cjs/components/date-picker-view/date-picker-view.d.ts +3 -2
- package/cjs/components/dialog/dialog.css +3 -0
- package/cjs/components/dropdown/dropdown.css +0 -3
- package/cjs/components/dropdown/item.js +3 -1
- package/cjs/components/ellipsis/ellipsis.js +3 -1
- package/cjs/components/empty/empty.css +1 -1
- package/cjs/components/floating-bubble/floating-bubble.css +1 -0
- 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.css +4 -5
- package/cjs/components/form/form-item.d.ts +2 -2
- package/cjs/components/form/form-item.js +9 -5
- package/cjs/components/form/form.css +3 -3
- package/cjs/components/form/form.d.ts +5 -4
- package/cjs/components/form/index.css +7 -8
- package/cjs/components/form/index.d.ts +5 -4
- package/cjs/components/image-uploader/image-uploader.js +1 -1
- package/cjs/components/image-viewer/image-viewer.css +2 -0
- package/cjs/components/image-viewer/image-viewer.js +12 -2
- package/cjs/components/image-viewer/slide.js +11 -7
- package/cjs/components/image-viewer/slides.d.ts +1 -1
- package/cjs/components/index-bar/index-bar.css +2 -1
- package/cjs/components/input/input.d.ts +6 -2
- package/cjs/components/input/input.js +23 -3
- package/cjs/components/list/list.css +7 -9
- package/cjs/components/picker/picker.css +9 -2
- package/cjs/components/picker/picker.d.ts +2 -1
- package/cjs/components/picker/picker.js +3 -1
- package/cjs/components/picker-view/picker-view.css +2 -1
- package/cjs/components/picker-view/picker-view.d.ts +1 -1
- package/cjs/components/picker-view/wheel.js +4 -2
- package/cjs/components/popover/arrow.d.ts +3 -0
- package/cjs/components/popover/arrow.js +26 -0
- package/cjs/components/popover/index.d.ts +10 -20
- package/cjs/components/popover/index.js +4 -2
- package/cjs/components/popover/popover-menu.css +52 -0
- package/cjs/components/popover/popover-menu.d.ts +17 -0
- package/{2x/cjs/components/popover/pop-menu.js → cjs/components/popover/popover-menu.js} +23 -26
- package/cjs/components/popover/popover.css +83 -276
- package/cjs/components/popover/popover.d.ts +9 -8
- package/cjs/components/popover/popover.js +11 -17
- package/cjs/components/radio/radio.js +2 -3
- 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/text-area/text-area.css +9 -9
- package/cjs/components/text-area/text-area.d.ts +2 -2
- package/cjs/components/text-area/text-area.js +41 -32
- 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/cascade-picker-view/cascade-picker-view.d.ts +1 -2
- package/es/components/date-picker/date-picker.d.ts +1 -1
- package/es/components/date-picker-view/date-picker-view.d.ts +3 -2
- package/es/components/dialog/dialog.css +3 -0
- package/es/components/dropdown/dropdown.css +0 -3
- package/es/components/dropdown/item.js +3 -1
- package/es/components/ellipsis/ellipsis.js +3 -2
- package/es/components/empty/empty.css +1 -1
- package/es/components/floating-bubble/floating-bubble.css +1 -0
- 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.css +4 -5
- package/es/components/form/form-item.d.ts +2 -2
- package/es/components/form/form-item.js +9 -5
- package/es/components/form/form.css +3 -3
- package/es/components/form/form.d.ts +5 -4
- package/es/components/form/index.css +7 -8
- package/es/components/form/index.d.ts +5 -4
- package/es/components/image-uploader/image-uploader.js +3 -3
- package/es/components/image-viewer/image-viewer.css +2 -0
- package/es/components/image-viewer/image-viewer.js +13 -3
- package/es/components/image-viewer/slide.js +11 -7
- package/es/components/image-viewer/slides.d.ts +1 -1
- package/es/components/index-bar/index-bar.css +2 -1
- package/es/components/input/input.d.ts +6 -2
- package/es/components/input/input.js +22 -4
- package/es/components/list/list.css +7 -9
- package/es/components/picker/picker.css +9 -2
- package/es/components/picker/picker.d.ts +2 -1
- package/es/components/picker/picker.js +3 -1
- package/es/components/picker-view/picker-view.css +2 -1
- package/es/components/picker-view/picker-view.d.ts +1 -1
- package/es/components/picker-view/wheel.js +4 -3
- package/es/components/popover/arrow.d.ts +3 -0
- package/es/components/popover/arrow.js +12 -0
- package/es/components/popover/index.d.ts +10 -20
- package/es/components/popover/index.js +3 -2
- package/es/components/popover/popover-menu.css +52 -0
- package/es/components/popover/popover-menu.d.ts +17 -0
- package/es/components/popover/popover-menu.js +52 -0
- package/es/components/popover/popover.css +83 -276
- package/es/components/popover/popover.d.ts +9 -8
- package/es/components/popover/popover.js +10 -17
- package/es/components/radio/radio.js +2 -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/text-area/text-area.css +9 -9
- package/es/components/text-area/text-area.d.ts +2 -2
- package/es/components/text-area/text-area.js +41 -31
- 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 +5 -5
- package/umd/antd-mobile.js +1 -1
- package/2x/cjs/components/popover/animation.css +0 -111
- package/2x/cjs/components/popover/pop-menu.d.ts +0 -28
- package/2x/es/components/popover/animation.css +0 -111
- package/2x/es/components/popover/pop-menu.d.ts +0 -28
- package/2x/es/components/popover/pop-menu.js +0 -54
- package/cjs/components/popover/animation.css +0 -96
- package/cjs/components/popover/pop-menu.d.ts +0 -28
- package/es/components/popover/animation.css +0 -96
- package/es/components/popover/pop-menu.d.ts +0 -28
- package/es/components/popover/pop-menu.js +0 -54
|
@@ -4,12 +4,13 @@ import classNames from 'classnames';
|
|
|
4
4
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
5
5
|
import { mergeProps } from '../../utils/with-default-props';
|
|
6
6
|
import { withStopPropagation } from '../../utils/with-stop-propagation';
|
|
7
|
+
import { Arrow } from './arrow';
|
|
7
8
|
const classPrefix = `adm-popover`;
|
|
8
|
-
const enterClassName = 'entering';
|
|
9
|
-
const leaveClassName = 'leaving';
|
|
10
9
|
const defaultProps = {
|
|
10
|
+
placement: 'top',
|
|
11
11
|
defaultVisible: false,
|
|
12
|
-
stopPropagation: ['click']
|
|
12
|
+
stopPropagation: ['click'],
|
|
13
|
+
getContainer: () => document.body
|
|
13
14
|
};
|
|
14
15
|
export const Popover = forwardRef((p, ref) => {
|
|
15
16
|
var _a;
|
|
@@ -34,27 +35,19 @@ export const Popover = forwardRef((p, ref) => {
|
|
|
34
35
|
className: `${classPrefix}-inner-content`
|
|
35
36
|
}, props.content));
|
|
36
37
|
return React.createElement(Tooltip, Object.assign({}, props, {
|
|
37
|
-
|
|
38
|
+
placement: props.placement,
|
|
39
|
+
align: props.align,
|
|
40
|
+
overlayClassName: classNames(`${classPrefix}-${mode}`, props.className),
|
|
41
|
+
overlayStyle: props.style,
|
|
38
42
|
destroyTooltipOnHide: props.destroyOnHide,
|
|
39
43
|
prefixCls: classPrefix,
|
|
40
44
|
getTooltipContainer: props.getContainer || (() => document.body),
|
|
41
45
|
visible: visible,
|
|
42
|
-
arrowContent: React.createElement(
|
|
43
|
-
className: `${classPrefix}-arrow-
|
|
46
|
+
arrowContent: React.createElement(Arrow, {
|
|
47
|
+
className: `${classPrefix}-arrow-icon`
|
|
44
48
|
}),
|
|
45
49
|
onVisibleChange: setVisible,
|
|
46
50
|
trigger: (_a = props.trigger) !== null && _a !== void 0 ? _a : [],
|
|
47
|
-
motion: {
|
|
48
|
-
motionName: {
|
|
49
|
-
appear: enterClassName,
|
|
50
|
-
appearActive: enterClassName,
|
|
51
|
-
enter: enterClassName,
|
|
52
|
-
enterActive: enterClassName,
|
|
53
|
-
leaveActive: leaveClassName,
|
|
54
|
-
leave: leaveClassName
|
|
55
|
-
},
|
|
56
|
-
motionDeadline: 200
|
|
57
|
-
},
|
|
58
51
|
overlay: overlay
|
|
59
52
|
}), props.children);
|
|
60
53
|
});
|
|
@@ -53,12 +53,11 @@ export const Radio = p => {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
return withNativeProps(props, React.createElement("label", {
|
|
56
|
-
className: classNames(classPrefix,
|
|
56
|
+
className: classNames(classPrefix, {
|
|
57
57
|
[`${classPrefix}-checked`]: checked,
|
|
58
58
|
[`${classPrefix}-disabled`]: disabled,
|
|
59
59
|
[`${classPrefix}-block`]: props.block
|
|
60
|
-
})
|
|
61
|
-
style: props.style
|
|
60
|
+
})
|
|
62
61
|
}, React.createElement("input", {
|
|
63
62
|
type: 'radio',
|
|
64
63
|
checked: checked,
|
|
@@ -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,4 +1,4 @@
|
|
|
1
|
-
.adm-text-area
|
|
1
|
+
.adm-text-area {
|
|
2
2
|
--font-size: 17px;
|
|
3
3
|
--color: var(--adm-color-text);
|
|
4
4
|
--placeholder-color: var(--adm-color-light);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
max-width: 100%;
|
|
8
8
|
max-height: 100%;
|
|
9
9
|
}
|
|
10
|
-
.adm-text-area {
|
|
10
|
+
.adm-text-area-element {
|
|
11
11
|
font-family: var(--adm-font-family);
|
|
12
12
|
resize: none;
|
|
13
13
|
flex: auto;
|
|
@@ -27,29 +27,29 @@
|
|
|
27
27
|
appearance: none;
|
|
28
28
|
min-height: 1.5em;
|
|
29
29
|
}
|
|
30
|
-
.adm-text-area::placeholder {
|
|
30
|
+
.adm-text-area-element::placeholder {
|
|
31
31
|
color: var(--placeholder-color);
|
|
32
32
|
font-family: inherit;
|
|
33
33
|
}
|
|
34
|
-
.adm-text-area:-webkit-autofill {
|
|
34
|
+
.adm-text-area-element:-webkit-autofill {
|
|
35
35
|
background-color: transparent;
|
|
36
36
|
}
|
|
37
|
-
.adm-text-area:disabled {
|
|
37
|
+
.adm-text-area-element:disabled {
|
|
38
38
|
color: var(--disabled-color);
|
|
39
39
|
cursor: not-allowed;
|
|
40
40
|
opacity: 1;
|
|
41
41
|
-webkit-text-fill-color: var(--disabled-color);
|
|
42
42
|
}
|
|
43
|
-
.adm-text-area:read-only {
|
|
43
|
+
.adm-text-area-element:read-only {
|
|
44
44
|
cursor: default;
|
|
45
45
|
}
|
|
46
|
-
.adm-text-area:invalid {
|
|
46
|
+
.adm-text-area-element:invalid {
|
|
47
47
|
box-shadow: none;
|
|
48
48
|
}
|
|
49
|
-
.adm-text-area::-ms-clear {
|
|
49
|
+
.adm-text-area-element::-ms-clear {
|
|
50
50
|
display: none;
|
|
51
51
|
}
|
|
52
|
-
.adm-text-area[readonly] {
|
|
52
|
+
.adm-text-area-element[readonly] {
|
|
53
53
|
pointer-events: none;
|
|
54
54
|
}
|
|
55
55
|
.adm-text-area-count {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ReactNode } from 'react';
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
|
-
export declare type TextAreaProps = Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'autoComplete' | 'disabled' | 'readOnly' | 'onFocus' | 'onBlur'> & {
|
|
4
|
+
export declare type TextAreaProps = Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'autoComplete' | 'disabled' | 'readOnly' | 'onFocus' | 'onBlur' | 'onCompositionStart' | 'onCompositionEnd'> & {
|
|
5
5
|
onChange?: (val: string) => void;
|
|
6
6
|
value?: string;
|
|
7
7
|
defaultValue?: string;
|
|
@@ -20,7 +20,7 @@ export declare type TextAreaRef = {
|
|
|
20
20
|
focus: () => void;
|
|
21
21
|
blur: () => void;
|
|
22
22
|
};
|
|
23
|
-
export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "disabled" | "onFocus" | "onBlur" | "autoComplete" | "readOnly"> & {
|
|
23
|
+
export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "disabled" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "autoComplete" | "readOnly"> & {
|
|
24
24
|
onChange?: ((val: string) => void) | undefined;
|
|
25
25
|
value?: string | undefined;
|
|
26
26
|
defaultValue?: string | undefined;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { __rest } from "tslib";
|
|
2
1
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
3
|
-
import
|
|
2
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
4
3
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
5
4
|
import { mergeProps } from '../../utils/with-default-props';
|
|
6
5
|
const classPrefix = 'adm-text-area';
|
|
@@ -12,19 +11,11 @@ const defaultProps = {
|
|
|
12
11
|
};
|
|
13
12
|
export const TextArea = forwardRef((p, ref) => {
|
|
14
13
|
const props = mergeProps(defaultProps, p);
|
|
15
|
-
|
|
16
14
|
const {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
onChange: outerOnChange,
|
|
22
|
-
rows: rows,
|
|
23
|
-
autoSize: autoSize,
|
|
24
|
-
showCount
|
|
25
|
-
} = props,
|
|
26
|
-
textAreaProps = __rest(props, ["className", "style", "defaultValue", "value", "onChange", "rows", "autoSize", "showCount"]);
|
|
27
|
-
|
|
15
|
+
autoSize,
|
|
16
|
+
showCount,
|
|
17
|
+
maxLength
|
|
18
|
+
} = props;
|
|
28
19
|
const [value, setValue] = usePropsValue(props);
|
|
29
20
|
const nativeTextAreaRef = useRef(null);
|
|
30
21
|
useImperativeHandle(ref, () => ({
|
|
@@ -64,39 +55,58 @@ export const TextArea = forwardRef((p, ref) => {
|
|
|
64
55
|
|
|
65
56
|
textArea.style.height = `${height}px`;
|
|
66
57
|
}, [value, autoSize]);
|
|
58
|
+
const compositingRef = useRef(false);
|
|
67
59
|
let count;
|
|
60
|
+
const valueLength = [...value].length;
|
|
68
61
|
|
|
69
62
|
if (typeof showCount === 'function') {
|
|
70
|
-
count = showCount(
|
|
63
|
+
count = showCount(valueLength, maxLength);
|
|
71
64
|
} else if (showCount) {
|
|
72
65
|
count = React.createElement("div", {
|
|
73
66
|
className: `${classPrefix}-count`
|
|
74
|
-
},
|
|
67
|
+
}, maxLength === undefined ? valueLength : valueLength + '/' + maxLength);
|
|
75
68
|
}
|
|
76
69
|
|
|
77
|
-
return React.createElement("div", {
|
|
78
|
-
className:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
className: classPrefix,
|
|
84
|
-
rows: rows,
|
|
70
|
+
return withNativeProps(props, React.createElement("div", {
|
|
71
|
+
className: classPrefix
|
|
72
|
+
}, React.createElement("textarea", {
|
|
73
|
+
ref: nativeTextAreaRef,
|
|
74
|
+
className: `${classPrefix}-element`,
|
|
75
|
+
rows: props.rows,
|
|
85
76
|
value: value,
|
|
77
|
+
placeholder: props.placeholder,
|
|
86
78
|
onChange: e => {
|
|
87
|
-
|
|
79
|
+
let v = e.target.value;
|
|
80
|
+
|
|
81
|
+
if (maxLength && !compositingRef.current) {
|
|
82
|
+
v = [...v].slice(0, maxLength).join('');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
setValue(v);
|
|
88
86
|
},
|
|
89
|
-
|
|
87
|
+
id: props.id,
|
|
88
|
+
onCompositionStart: e => {
|
|
90
89
|
var _a;
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
compositingRef.current = true;
|
|
92
|
+
(_a = props.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
93
93
|
},
|
|
94
|
-
|
|
94
|
+
onCompositionEnd: e => {
|
|
95
95
|
var _a;
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
compositingRef.current = false;
|
|
98
|
+
|
|
99
|
+
if (maxLength) {
|
|
100
|
+
setValue([...value].slice(0, maxLength).join(''));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
(_a = props.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
98
104
|
},
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
autoComplete: props.autoComplete,
|
|
106
|
+
disabled: props.disabled,
|
|
107
|
+
readOnly: props.readOnly,
|
|
108
|
+
onFocus: props.onFocus,
|
|
109
|
+
onBlur: props.onBlur
|
|
110
|
+
}), count));
|
|
101
111
|
});
|
|
102
112
|
TextArea.defaultProps = defaultProps;
|
|
@@ -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,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-mobile",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.27",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@react-spring/web": "^9.4.
|
|
6
|
-
"@types/resize-observer-browser": "^0.1.
|
|
7
|
-
"@use-gesture/react": "^10.2.
|
|
8
|
-
"ahooks": "^3.1.
|
|
5
|
+
"@react-spring/web": "^9.4.3",
|
|
6
|
+
"@types/resize-observer-browser": "^0.1.7",
|
|
7
|
+
"@use-gesture/react": "^10.2.6",
|
|
8
|
+
"ahooks": "^3.1.9",
|
|
9
9
|
"antd-mobile-icons": "^0.2.2",
|
|
10
10
|
"antd-mobile-v5-count": "^1.0.1",
|
|
11
11
|
"classnames": "^2.3.1",
|