antd-mobile 5.29.1 → 5.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2x/README.md +1 -1
- package/2x/bundle/antd-mobile.cjs.development.js +3919 -3845
- package/2x/bundle/antd-mobile.cjs.js +9 -9
- package/2x/bundle/antd-mobile.es.development.js +3907 -3833
- package/2x/bundle/antd-mobile.es.js +7782 -7731
- package/2x/bundle/antd-mobile.umd.development.js +3919 -3845
- package/2x/bundle/antd-mobile.umd.js +9 -9
- package/2x/bundle/style.css +4 -2
- 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/collapse/collapse.js +3 -1
- package/2x/cjs/components/date-picker/date-picker-date-utils.d.ts +1 -1
- package/2x/cjs/components/date-picker/date-picker-utils.d.ts +1 -1
- package/2x/cjs/components/date-picker/date-picker-week-utils.d.ts +1 -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/dropdown/dropdown.d.ts +3 -0
- package/2x/cjs/components/dropdown/dropdown.js +4 -1
- package/2x/cjs/components/dropdown/index.d.ts +1 -0
- package/2x/cjs/components/ellipsis/ellipsis.d.ts +2 -2
- package/2x/cjs/components/ellipsis/ellipsis.js +18 -18
- package/2x/cjs/components/footer/footer.css +1 -1
- package/2x/cjs/components/form/form-subscribe.js +4 -1
- package/2x/cjs/components/form/form.js +1 -1
- package/2x/cjs/components/form/index.d.ts +1 -1
- package/2x/cjs/components/image/image.d.ts +1 -1
- package/2x/cjs/components/image/image.js +10 -0
- package/2x/cjs/components/image-uploader/image-uploader.js +4 -5
- 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.d.ts +2 -0
- package/2x/cjs/components/notice-bar/notice-bar.js +2 -1
- package/2x/cjs/components/page-indicator/page-indicator.css +1 -1
- package/2x/cjs/components/picker-view/picker-view.d.ts +2 -2
- package/2x/cjs/components/popup/popup.d.ts +1 -0
- package/2x/cjs/components/popup/popup.js +29 -16
- package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +4 -2
- package/2x/cjs/components/search-bar/search-bar.d.ts +2 -2
- package/2x/cjs/components/search-bar/search-bar.js +6 -2
- package/2x/cjs/components/slider/slider.js +6 -4
- package/2x/cjs/components/steps/steps.css +2 -0
- package/2x/cjs/components/swiper/swiper.js +21 -15
- package/2x/cjs/components/text-area/text-area.d.ts +1 -1
- package/2x/cjs/components/text-area/text-area.js +5 -3
- 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/collapse/collapse.js +3 -1
- package/2x/es/components/date-picker/date-picker-date-utils.d.ts +1 -1
- package/2x/es/components/date-picker/date-picker-utils.d.ts +1 -1
- package/2x/es/components/date-picker/date-picker-week-utils.d.ts +1 -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/dropdown/dropdown.d.ts +3 -0
- package/2x/es/components/dropdown/dropdown.js +4 -1
- package/2x/es/components/dropdown/index.d.ts +1 -0
- package/2x/es/components/ellipsis/ellipsis.d.ts +2 -2
- package/2x/es/components/ellipsis/ellipsis.js +18 -18
- package/2x/es/components/footer/footer.css +1 -1
- package/2x/es/components/form/form-subscribe.js +4 -1
- package/2x/es/components/form/form.js +1 -1
- package/2x/es/components/form/index.d.ts +1 -1
- package/2x/es/components/image/image.d.ts +1 -1
- package/2x/es/components/image/image.js +11 -1
- package/2x/es/components/image-uploader/image-uploader.js +4 -5
- 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.d.ts +2 -0
- package/2x/es/components/notice-bar/notice-bar.js +2 -1
- package/2x/es/components/page-indicator/page-indicator.css +1 -1
- package/2x/es/components/picker-view/picker-view.d.ts +2 -2
- package/2x/es/components/popup/popup.d.ts +1 -0
- package/2x/es/components/popup/popup.js +29 -16
- package/2x/es/components/pull-to-refresh/pull-to-refresh.js +4 -2
- package/2x/es/components/search-bar/search-bar.d.ts +2 -2
- package/2x/es/components/search-bar/search-bar.js +6 -2
- package/2x/es/components/slider/slider.js +6 -4
- package/2x/es/components/steps/steps.css +2 -0
- package/2x/es/components/swiper/swiper.js +22 -16
- package/2x/es/components/text-area/text-area.d.ts +1 -1
- package/2x/es/components/text-area/text-area.js +4 -3
- package/2x/es/utils/reduce-and-restore-motion.js +1 -1
- package/2x/package.json +10 -10
- package/README.md +1 -1
- package/bundle/antd-mobile.cjs.development.js +3919 -3845
- package/bundle/antd-mobile.cjs.js +9 -9
- package/bundle/antd-mobile.compatible.umd.js +1 -1
- package/bundle/antd-mobile.es.development.js +3907 -3833
- package/bundle/antd-mobile.es.js +7782 -7731
- package/bundle/antd-mobile.umd.development.js +3919 -3845
- 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/collapse/collapse.js +3 -1
- package/cjs/components/date-picker/date-picker-date-utils.d.ts +1 -1
- package/cjs/components/date-picker/date-picker-utils.d.ts +1 -1
- package/cjs/components/date-picker/date-picker-week-utils.d.ts +1 -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/dropdown/dropdown.d.ts +3 -0
- package/cjs/components/dropdown/dropdown.js +4 -1
- package/cjs/components/dropdown/index.d.ts +1 -0
- package/cjs/components/ellipsis/ellipsis.d.ts +2 -2
- package/cjs/components/ellipsis/ellipsis.js +18 -18
- package/cjs/components/footer/footer.css +1 -1
- package/cjs/components/form/form-subscribe.js +4 -1
- package/cjs/components/form/form.js +1 -1
- package/cjs/components/form/index.d.ts +1 -1
- package/cjs/components/image/image.d.ts +1 -1
- package/cjs/components/image/image.js +10 -0
- package/cjs/components/image-uploader/image-uploader.js +4 -5
- 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.d.ts +2 -0
- package/cjs/components/notice-bar/notice-bar.js +2 -1
- package/cjs/components/page-indicator/page-indicator.css +1 -1
- package/cjs/components/picker-view/picker-view.d.ts +2 -2
- package/cjs/components/popup/popup.d.ts +1 -0
- package/cjs/components/popup/popup.js +29 -16
- package/cjs/components/pull-to-refresh/pull-to-refresh.js +4 -2
- package/cjs/components/search-bar/search-bar.d.ts +2 -2
- package/cjs/components/search-bar/search-bar.js +6 -2
- package/cjs/components/slider/slider.js +6 -4
- package/cjs/components/steps/steps.css +2 -0
- package/cjs/components/swiper/swiper.js +21 -15
- package/cjs/components/text-area/text-area.d.ts +1 -1
- package/cjs/components/text-area/text-area.js +5 -3
- 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/collapse/collapse.js +3 -1
- package/es/components/date-picker/date-picker-date-utils.d.ts +1 -1
- package/es/components/date-picker/date-picker-utils.d.ts +1 -1
- package/es/components/date-picker/date-picker-week-utils.d.ts +1 -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/dropdown/dropdown.d.ts +3 -0
- package/es/components/dropdown/dropdown.js +4 -1
- package/es/components/dropdown/index.d.ts +1 -0
- package/es/components/ellipsis/ellipsis.d.ts +2 -2
- package/es/components/ellipsis/ellipsis.js +18 -18
- package/es/components/footer/footer.css +1 -1
- package/es/components/form/form-subscribe.js +4 -1
- package/es/components/form/form.js +1 -1
- package/es/components/form/index.d.ts +1 -1
- package/es/components/image/image.d.ts +1 -1
- package/es/components/image/image.js +11 -1
- package/es/components/image-uploader/image-uploader.js +4 -5
- 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.d.ts +2 -0
- package/es/components/notice-bar/notice-bar.js +2 -1
- package/es/components/page-indicator/page-indicator.css +1 -1
- package/es/components/picker-view/picker-view.d.ts +2 -2
- package/es/components/popup/popup.d.ts +1 -0
- package/es/components/popup/popup.js +29 -16
- package/es/components/pull-to-refresh/pull-to-refresh.js +4 -2
- package/es/components/search-bar/search-bar.d.ts +2 -2
- package/es/components/search-bar/search-bar.js +6 -2
- package/es/components/slider/slider.js +6 -4
- package/es/components/steps/steps.css +2 -0
- package/es/components/swiper/swiper.js +22 -16
- package/es/components/text-area/text-area.d.ts +1 -1
- package/es/components/text-area/text-area.js +4 -3
- package/es/utils/reduce-and-restore-motion.js +1 -1
- package/package.json +10 -10
- package/umd/antd-mobile.js +1 -1
|
@@ -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
|
});
|
|
@@ -2,7 +2,7 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import { InputRef, InputProps } from '../input';
|
|
3
3
|
import { NativeProps } from '../../utils/native-props';
|
|
4
4
|
export declare type SearchBarRef = InputRef;
|
|
5
|
-
export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'onClear'> & {
|
|
5
|
+
export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'onClear' | 'onCompositionStart' | 'onCompositionEnd'> & {
|
|
6
6
|
value?: string;
|
|
7
7
|
defaultValue?: string;
|
|
8
8
|
maxLength?: number;
|
|
@@ -17,7 +17,7 @@ export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'on
|
|
|
17
17
|
onChange?: (val: string) => void;
|
|
18
18
|
onCancel?: () => void;
|
|
19
19
|
} & NativeProps<'--background' | '--border-radius' | '--placeholder-color' | '--height' | '--padding-left'>;
|
|
20
|
-
export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps, "onFocus" | "onBlur" | "onClear"> & {
|
|
20
|
+
export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps, "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onClear"> & {
|
|
21
21
|
value?: string | undefined;
|
|
22
22
|
defaultValue?: string | undefined;
|
|
23
23
|
maxLength?: number | undefined;
|
|
@@ -119,11 +119,15 @@ const SearchBar = (0, _react.forwardRef)((p, ref) => {
|
|
|
119
119
|
}
|
|
120
120
|
},
|
|
121
121
|
"aria-label": locale.SearchBar.name,
|
|
122
|
-
onCompositionStart:
|
|
122
|
+
onCompositionStart: e => {
|
|
123
|
+
var _a;
|
|
123
124
|
composingRef.current = true;
|
|
125
|
+
(_a = props.onCompositionStart) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
124
126
|
},
|
|
125
|
-
onCompositionEnd:
|
|
127
|
+
onCompositionEnd: e => {
|
|
128
|
+
var _a;
|
|
126
129
|
composingRef.current = false;
|
|
130
|
+
(_a = props.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
127
131
|
}
|
|
128
132
|
})), renderCancelButton()));
|
|
129
133
|
});
|
|
@@ -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,11 +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
|
-
(0, _ahooks.useUpdateEffect)(() => {
|
|
87
|
-
var _a;
|
|
88
|
-
(_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, current);
|
|
89
|
-
}, [current]);
|
|
86
|
+
const [current, setCurrent, getCurrent] = (0, _ahooks.useGetState)(props.defaultIndex);
|
|
90
87
|
const [dragging, setDragging, draggingRef] = (0, _useRefState.useRefState)(false);
|
|
91
88
|
function boundIndex(current) {
|
|
92
89
|
let min = 0;
|
|
@@ -181,9 +178,13 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
181
178
|
}
|
|
182
179
|
});
|
|
183
180
|
function swipeTo(index, immediate = false) {
|
|
181
|
+
var _a;
|
|
184
182
|
const roundedIndex = Math.round(index);
|
|
185
183
|
const targetIndex = loop ? modulus(roundedIndex, count) : (0, _bound.bound)(roundedIndex, 0, count - 1);
|
|
186
184
|
setCurrent(targetIndex);
|
|
185
|
+
if (targetIndex !== getCurrent()) {
|
|
186
|
+
(_a = props.onIndexChange) === null || _a === void 0 ? void 0 : _a.call(props, targetIndex);
|
|
187
|
+
}
|
|
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() {
|
|
@@ -228,7 +230,9 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
228
230
|
className: `${classPrefix}-track-inner`
|
|
229
231
|
}, _react.default.Children.map(validChildren, (child, index) => {
|
|
230
232
|
return _react.default.createElement(_web.animated.div, {
|
|
231
|
-
className: `${classPrefix}-slide`,
|
|
233
|
+
className: (0, _classnames.default)(`${classPrefix}-slide`, {
|
|
234
|
+
[`${classPrefix}-slide-active`]: current === index
|
|
235
|
+
}),
|
|
232
236
|
style: {
|
|
233
237
|
[isVertical ? 'y' : 'x']: position.to(position => {
|
|
234
238
|
let finalPosition = -position + index * 100;
|
|
@@ -247,9 +251,11 @@ const Swiper = (0, _react.forwardRef)((0, _stagedComponents.staged)((p, ref) =>
|
|
|
247
251
|
style: {
|
|
248
252
|
[isVertical ? 'y' : 'x']: position.to(position => `${-position}%`)
|
|
249
253
|
}
|
|
250
|
-
}, _react.default.Children.map(validChildren, child => {
|
|
254
|
+
}, _react.default.Children.map(validChildren, (child, index) => {
|
|
251
255
|
return _react.default.createElement("div", {
|
|
252
|
-
className: `${classPrefix}-slide
|
|
256
|
+
className: (0, _classnames.default)(`${classPrefix}-slide`, {
|
|
257
|
+
[`${classPrefix}-slide-active`]: current === index
|
|
258
|
+
})
|
|
253
259
|
}, child);
|
|
254
260
|
}));
|
|
255
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;
|
|
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.TextArea = void 0;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _ahooks = require("ahooks");
|
|
9
|
+
var _runes = _interopRequireDefault(require("runes2"));
|
|
9
10
|
var _nativeProps = require("../../utils/native-props");
|
|
10
11
|
var _usePropsValue = require("../../utils/use-props-value");
|
|
11
12
|
var _withDefaultProps = require("../../utils/with-default-props");
|
|
12
13
|
var _devLog = require("../../utils/dev-log");
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
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); }
|
|
14
16
|
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; }
|
|
15
17
|
const classPrefix = 'adm-text-area';
|
|
@@ -76,7 +78,7 @@ const TextArea = (0, _react.forwardRef)((p, ref) => {
|
|
|
76
78
|
}, [value, autoSize]);
|
|
77
79
|
const compositingRef = (0, _react.useRef)(false);
|
|
78
80
|
let count;
|
|
79
|
-
const valueLength =
|
|
81
|
+
const valueLength = (0, _runes.default)(value).length;
|
|
80
82
|
if (typeof showCount === 'function') {
|
|
81
83
|
count = showCount(valueLength, maxLength);
|
|
82
84
|
} else if (showCount) {
|
|
@@ -95,7 +97,7 @@ const TextArea = (0, _react.forwardRef)((p, ref) => {
|
|
|
95
97
|
onChange: e => {
|
|
96
98
|
let v = e.target.value;
|
|
97
99
|
if (maxLength && !compositingRef.current) {
|
|
98
|
-
v =
|
|
100
|
+
v = (0, _runes.default)(v).slice(0, maxLength).join('');
|
|
99
101
|
}
|
|
100
102
|
setValue(v);
|
|
101
103
|
},
|
|
@@ -110,7 +112,7 @@ const TextArea = (0, _react.forwardRef)((p, ref) => {
|
|
|
110
112
|
compositingRef.current = false;
|
|
111
113
|
if (maxLength) {
|
|
112
114
|
const v = e.target.value;
|
|
113
|
-
setValue(
|
|
115
|
+
setValue((0, _runes.default)(v).slice(0, maxLength).join(''));
|
|
114
116
|
}
|
|
115
117
|
(_a = props.onCompositionEnd) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
116
118
|
},
|
|
@@ -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`,
|
|
@@ -60,7 +60,9 @@ const CollapsePanelContent = props => {
|
|
|
60
60
|
}
|
|
61
61
|
}, [visible]);
|
|
62
62
|
return React.createElement(animated.div, {
|
|
63
|
-
className: `${classPrefix}-panel-content`,
|
|
63
|
+
className: classNames(`${classPrefix}-panel-content`, {
|
|
64
|
+
[`${classPrefix}-panel-content-active`]: visible
|
|
65
|
+
}),
|
|
64
66
|
style: {
|
|
65
67
|
height: height.to(v => {
|
|
66
68
|
if (height.idle && visible) {
|
|
@@ -4,4 +4,4 @@ import { RenderLabel } from '../date-picker-view/date-picker-view';
|
|
|
4
4
|
export declare type DatePrecision = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';
|
|
5
5
|
export declare function generateDatePickerColumns(selected: string[], min: Date, max: Date, precision: DatePrecision, renderLabel: RenderLabel, filter: DatePickerFilter | undefined, tillNow?: boolean): PickerColumn[];
|
|
6
6
|
export declare function convertDateToStringArray(date: Date | undefined | null): string[];
|
|
7
|
-
export declare function convertStringArrayToDate
|
|
7
|
+
export declare function convertStringArrayToDate<T extends string | number | null | undefined>(value: T[]): Date;
|
|
@@ -6,5 +6,5 @@ export declare type DatePickerFilter = Partial<Record<Precision, (val: number, e
|
|
|
6
6
|
date: Date;
|
|
7
7
|
}) => boolean>>;
|
|
8
8
|
export declare const convertDateToStringArray: (date: Date | undefined | null, precision: Precision) => string[];
|
|
9
|
-
export declare const convertStringArrayToDate:
|
|
9
|
+
export declare const convertStringArrayToDate: <T extends string | number | null | undefined>(value: T[], precision: Precision) => Date;
|
|
10
10
|
export declare const generateDatePickerColumns: (selected: string[], min: Date, max: Date, precision: Precision, renderLabel: RenderLabel, filter: DatePickerFilter | undefined, tillNow?: boolean | undefined) => import("../picker-view").PickerColumn[];
|
|
@@ -4,4 +4,4 @@ import type { DatePickerFilter } from './date-picker-utils';
|
|
|
4
4
|
export declare type WeekPrecision = 'year' | 'week' | 'week-day';
|
|
5
5
|
export declare function generateDatePickerColumns(selected: string[], min: Date, max: Date, precision: WeekPrecision, renderLabel: (type: WeekPrecision, data: number) => ReactNode, filter: DatePickerFilter | undefined): PickerColumn[];
|
|
6
6
|
export declare function convertDateToStringArray(date: Date | undefined | null): string[];
|
|
7
|
-
export declare function convertStringArrayToDate
|
|
7
|
+
export declare function convertStringArrayToDate<T extends string | number | null | undefined>(value: T[]): Date;
|
|
@@ -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;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { PopupProps } from '../popup';
|
|
2
3
|
import { NativeProps } from '../../utils/native-props';
|
|
3
4
|
export declare type DropdownProps = {
|
|
4
5
|
activeKey?: string | null;
|
|
@@ -7,6 +8,7 @@ export declare type DropdownProps = {
|
|
|
7
8
|
closeOnClickAway?: boolean;
|
|
8
9
|
onChange?: (key: string | null) => void;
|
|
9
10
|
arrow?: React.ReactNode;
|
|
11
|
+
getContainer?: PopupProps['getContainer'];
|
|
10
12
|
} & NativeProps;
|
|
11
13
|
export declare type DropdownRef = {
|
|
12
14
|
close: () => void;
|
|
@@ -18,6 +20,7 @@ declare const Dropdown: React.ForwardRefExoticComponent<{
|
|
|
18
20
|
closeOnClickAway?: boolean | undefined;
|
|
19
21
|
onChange?: ((key: string | null) => void) | undefined;
|
|
20
22
|
arrow?: React.ReactNode;
|
|
23
|
+
getContainer?: PopupProps['getContainer'];
|
|
21
24
|
} & {
|
|
22
25
|
className?: string | undefined;
|
|
23
26
|
style?: (React.CSSProperties & Partial<Record<never, string>>) | undefined;
|
|
@@ -6,11 +6,13 @@ import { ItemChildrenWrap } from './item';
|
|
|
6
6
|
import { withNativeProps } from '../../utils/native-props';
|
|
7
7
|
import { mergeProps } from '../../utils/with-default-props';
|
|
8
8
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
9
|
+
import { defaultPopupBaseProps } from '../popup/popup-base-props';
|
|
9
10
|
const classPrefix = `adm-dropdown`;
|
|
10
11
|
const defaultProps = {
|
|
11
12
|
defaultActiveKey: null,
|
|
12
13
|
closeOnMaskClick: true,
|
|
13
|
-
closeOnClickAway: false
|
|
14
|
+
closeOnClickAway: false,
|
|
15
|
+
getContainer: defaultPopupBaseProps['getContainer']
|
|
14
16
|
};
|
|
15
17
|
const Dropdown = forwardRef((p, ref) => {
|
|
16
18
|
const props = mergeProps(defaultProps, p);
|
|
@@ -78,6 +80,7 @@ const Dropdown = forwardRef((p, ref) => {
|
|
|
78
80
|
}, navs), React.createElement(Popup, {
|
|
79
81
|
visible: !!value,
|
|
80
82
|
position: 'top',
|
|
83
|
+
getContainer: props.getContainer,
|
|
81
84
|
className: `${classPrefix}-popup`,
|
|
82
85
|
maskClassName: `${classPrefix}-popup-mask`,
|
|
83
86
|
bodyClassName: `${classPrefix}-popup-body`,
|
|
@@ -8,6 +8,7 @@ declare const _default: import("react").ForwardRefExoticComponent<{
|
|
|
8
8
|
closeOnClickAway?: boolean | undefined;
|
|
9
9
|
onChange?: ((key: string | null) => void) | undefined;
|
|
10
10
|
arrow?: import("react").ReactNode;
|
|
11
|
+
getContainer?: import("../../utils/render-to-container").GetContainer | undefined;
|
|
11
12
|
} & {
|
|
12
13
|
className?: string | undefined;
|
|
13
14
|
style?: (import("react").CSSProperties & Partial<Record<never, string>>) | 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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useMemo, useRef, useState } from 'react';
|
|
2
|
-
import runes from '
|
|
2
|
+
import runes from 'runes2';
|
|
3
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
4
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
5
5
|
import { useResizeEffect } from '../../utils/use-resize-effect';
|
|
@@ -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,
|
|
@@ -5,7 +5,10 @@ import { useIsomorphicUpdateLayoutEffect } from '../../utils/use-isomorphic-upda
|
|
|
5
5
|
export const FormSubscribe = props => {
|
|
6
6
|
const update = useUpdate();
|
|
7
7
|
const form = useContext(FieldContext);
|
|
8
|
-
|
|
8
|
+
const value = form.getFieldsValue(props.to);
|
|
9
|
+
// Memo to avoid useless render
|
|
10
|
+
const childNode = React.useMemo(() => props.children(value, form), [JSON.stringify(value)]);
|
|
11
|
+
return React.createElement(React.Fragment, null, childNode, props.to.map(namePath => React.createElement(Watcher, {
|
|
9
12
|
key: namePath.toString(),
|
|
10
13
|
form: form,
|
|
11
14
|
namePath: namePath,
|
|
@@ -4,7 +4,7 @@ export declare type FormLayout = 'vertical' | 'horizontal';
|
|
|
4
4
|
export type { FormProps, FormInstance } from './form';
|
|
5
5
|
export type { FormItemProps } from './form-item';
|
|
6
6
|
export type { FormSubscribeProps } from './form-subscribe';
|
|
7
|
-
export type { ValidateMessages, FieldData, NamePath, } from 'rc-field-form/es/interface';
|
|
7
|
+
export type { ValidateMessages, FieldData, NamePath, Rule, RuleObject, RuleRender, } from 'rc-field-form/es/interface';
|
|
8
8
|
export type { FormArrayField, FormArrayOperation, FormArrayProps, } from './form-array';
|
|
9
9
|
declare const _default: import("react").ForwardRefExoticComponent<Pick<import("rc-field-form").FormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & {
|
|
10
10
|
className?: string | undefined;
|
|
@@ -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>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { mergeProps } from '../../utils/with-default-props';
|
|
2
|
-
import React, { useState, useRef } from 'react';
|
|
2
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
3
3
|
import { withNativeProps } from '../../utils/native-props';
|
|
4
4
|
import { staged } from 'staged-components';
|
|
5
5
|
import { toCSSLength } from '../../utils/to-css-length';
|
|
@@ -24,6 +24,7 @@ export const Image = staged(p => {
|
|
|
24
24
|
const [loaded, setLoaded] = useState(false);
|
|
25
25
|
const [failed, setFailed] = useState(false);
|
|
26
26
|
const ref = useRef(null);
|
|
27
|
+
const imgRef = useRef(null);
|
|
27
28
|
let src = props.src;
|
|
28
29
|
let srcSet = props.srcSet;
|
|
29
30
|
const [initialized, setInitialized] = useState(!props.lazy);
|
|
@@ -33,11 +34,20 @@ export const Image = staged(p => {
|
|
|
33
34
|
setLoaded(false);
|
|
34
35
|
setFailed(false);
|
|
35
36
|
}, [src]);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
var _a;
|
|
39
|
+
// for nextjs ssr
|
|
40
|
+
if ((_a = imgRef.current) === null || _a === void 0 ? void 0 : _a.complete) {
|
|
41
|
+
setLoaded(true);
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
36
44
|
function renderInner() {
|
|
37
45
|
if (failed) {
|
|
38
46
|
return React.createElement(React.Fragment, null, props.fallback);
|
|
39
47
|
}
|
|
40
48
|
const img = React.createElement("img", {
|
|
49
|
+
ref: imgRef,
|
|
50
|
+
id: props.id,
|
|
41
51
|
className: `${classPrefix}-img`,
|
|
42
52
|
src: src,
|
|
43
53
|
alt: props.alt,
|