@arco-design/mobile-react 2.20.0 → 2.21.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/CHANGELOG.md +30 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/avatar/index.d.ts +1 -1
- package/cjs/avatar/index.js +1 -1
- package/cjs/badge/index.d.ts +1 -1
- package/cjs/badge/index.js +1 -1
- package/cjs/carousel/index.d.ts +1 -1
- package/cjs/carousel/index.js +1 -1
- package/cjs/cell/index.d.ts +1 -1
- package/cjs/cell/index.js +1 -1
- package/cjs/checkbox/index.d.ts +1 -1
- package/cjs/checkbox/index.js +1 -1
- package/cjs/collapse/index.d.ts +1 -1
- package/cjs/collapse/index.js +1 -1
- package/cjs/count-down/index.d.ts +1 -1
- package/cjs/count-down/index.js +1 -1
- package/cjs/date-picker/index.d.ts +1 -1
- package/cjs/date-picker/index.js +1 -1
- package/cjs/dropdown/dropdown.js +36 -20
- package/cjs/dropdown/style/css/index.css +3 -0
- package/cjs/dropdown/style/index.less +2 -0
- package/cjs/ellipsis/index.d.ts +1 -1
- package/cjs/ellipsis/index.js +1 -1
- package/cjs/image/index.d.ts +1 -1
- package/cjs/image/index.js +1 -1
- package/cjs/image-picker/index.d.ts +4 -175
- package/cjs/image-picker/index.js +41 -18
- package/cjs/image-picker/type.d.ts +174 -0
- package/cjs/image-picker/type.js +3 -0
- package/cjs/image-preview/index.d.ts +1 -1
- package/cjs/image-preview/index.js +1 -1
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +9 -1
- package/cjs/input/hooks.js +49 -8
- package/cjs/input/index.d.ts +1 -1
- package/cjs/input/index.js +1 -1
- package/cjs/input/props.d.ts +8 -2
- package/cjs/notice-bar/index.d.ts +1 -1
- package/cjs/notice-bar/index.js +1 -1
- package/cjs/picker/index.d.ts +1 -1
- package/cjs/picker/index.js +1 -1
- package/cjs/picker-view/index.d.ts +1 -1
- package/cjs/picker-view/index.js +1 -1
- package/cjs/popover/index.d.ts +1 -1
- package/cjs/popover/index.js +1 -1
- package/cjs/popup-swiper/index.js +3 -2
- package/cjs/radio/index.d.ts +1 -1
- package/cjs/radio/index.js +1 -1
- package/cjs/rate/index.d.ts +1 -1
- package/cjs/rate/index.js +1 -1
- package/cjs/search-bar/association.d.ts +3 -0
- package/cjs/search-bar/association.js +92 -0
- package/cjs/search-bar/cancel-button.d.ts +10 -0
- package/cjs/search-bar/cancel-button.js +41 -0
- package/cjs/search-bar/demo/style/css/mobile.css +5 -0
- package/cjs/search-bar/demo/style/mobile.less +9 -0
- package/cjs/search-bar/highlight.d.ts +12 -0
- package/cjs/search-bar/highlight.js +77 -0
- package/cjs/search-bar/index.d.ts +13 -0
- package/cjs/search-bar/index.js +239 -0
- package/cjs/search-bar/style/css/index.css +148 -0
- package/cjs/search-bar/style/css/index.d.ts +2 -0
- package/cjs/search-bar/style/css/index.js +5 -0
- package/cjs/search-bar/style/index.d.ts +2 -0
- package/cjs/search-bar/style/index.js +5 -0
- package/cjs/search-bar/style/index.less +111 -0
- package/cjs/search-bar/type.d.ts +163 -0
- package/cjs/search-bar/type.js +3 -0
- package/cjs/slider/index.d.ts +1 -1
- package/cjs/slider/index.js +1 -1
- package/cjs/steps/index.d.ts +1 -1
- package/cjs/steps/index.js +1 -1
- package/cjs/sticky/index.d.ts +1 -1
- package/cjs/style.d.ts +2 -0
- package/cjs/style.js +4 -0
- package/cjs/swipe-action/demo/style/css/mobile.css +5 -0
- package/cjs/swipe-action/demo/style/mobile.less +9 -0
- package/cjs/swipe-action/index.d.ts +12 -0
- package/cjs/swipe-action/index.js +339 -0
- package/cjs/swipe-action/item.d.ts +11 -0
- package/cjs/swipe-action/item.js +52 -0
- package/cjs/swipe-action/style/css/index.css +88 -0
- package/cjs/swipe-action/style/css/index.d.ts +2 -0
- package/cjs/swipe-action/style/css/index.js +5 -0
- package/cjs/swipe-action/style/index.d.ts +2 -0
- package/cjs/swipe-action/style/index.js +5 -0
- package/cjs/swipe-action/style/index.less +89 -0
- package/cjs/swipe-action/type.d.ts +123 -0
- package/cjs/swipe-action/type.js +3 -0
- package/cjs/switch/index.d.ts +1 -1
- package/cjs/switch/index.js +1 -1
- package/cjs/tabs/tab-pane.js +5 -1
- package/cjs/tag/index.d.ts +1 -1
- package/cjs/tag/index.js +1 -1
- package/cjs/textarea/index.d.ts +1 -1
- package/cjs/textarea/index.js +1 -1
- package/dist/index.js +7450 -6611
- package/dist/index.min.js +6 -6
- package/dist/style.css +203 -0
- package/dist/style.min.css +1 -1
- package/esm/avatar/index.d.ts +1 -1
- package/esm/avatar/index.js +1 -1
- package/esm/badge/index.d.ts +1 -1
- package/esm/badge/index.js +1 -1
- package/esm/carousel/index.d.ts +1 -1
- package/esm/carousel/index.js +1 -1
- package/esm/cell/index.d.ts +1 -1
- package/esm/cell/index.js +1 -1
- package/esm/checkbox/index.d.ts +1 -1
- package/esm/checkbox/index.js +1 -1
- package/esm/collapse/index.d.ts +1 -1
- package/esm/collapse/index.js +1 -1
- package/esm/count-down/index.d.ts +1 -1
- package/esm/count-down/index.js +1 -1
- package/esm/date-picker/index.d.ts +1 -1
- package/esm/date-picker/index.js +1 -1
- package/esm/dropdown/dropdown.js +36 -20
- package/esm/dropdown/style/css/index.css +3 -0
- package/esm/dropdown/style/index.less +2 -0
- package/esm/ellipsis/index.d.ts +1 -1
- package/esm/ellipsis/index.js +1 -1
- package/esm/image/index.d.ts +1 -1
- package/esm/image/index.js +1 -1
- package/esm/image-picker/index.d.ts +4 -175
- package/esm/image-picker/index.js +30 -17
- package/esm/image-picker/type.d.ts +174 -0
- package/esm/image-picker/type.js +1 -0
- package/esm/image-preview/index.d.ts +1 -1
- package/esm/image-preview/index.js +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -0
- package/esm/input/hooks.js +49 -8
- package/esm/input/index.d.ts +1 -1
- package/esm/input/index.js +1 -1
- package/esm/input/props.d.ts +8 -2
- package/esm/notice-bar/index.d.ts +1 -1
- package/esm/notice-bar/index.js +1 -1
- package/esm/picker/index.d.ts +1 -1
- package/esm/picker/index.js +1 -1
- package/esm/picker-view/index.d.ts +1 -1
- package/esm/picker-view/index.js +1 -1
- package/esm/popover/index.d.ts +1 -1
- package/esm/popover/index.js +1 -1
- package/esm/popup-swiper/index.js +3 -2
- package/esm/radio/index.d.ts +1 -1
- package/esm/radio/index.js +1 -1
- package/esm/rate/index.d.ts +1 -1
- package/esm/rate/index.js +1 -1
- package/esm/search-bar/association.d.ts +3 -0
- package/esm/search-bar/association.js +82 -0
- package/esm/search-bar/cancel-button.d.ts +10 -0
- package/esm/search-bar/cancel-button.js +30 -0
- package/esm/search-bar/demo/style/css/mobile.css +5 -0
- package/esm/search-bar/demo/style/mobile.less +9 -0
- package/esm/search-bar/highlight.d.ts +12 -0
- package/esm/search-bar/highlight.js +66 -0
- package/esm/search-bar/index.d.ts +13 -0
- package/esm/search-bar/index.js +213 -0
- package/esm/search-bar/style/css/index.css +148 -0
- package/esm/search-bar/style/css/index.d.ts +2 -0
- package/esm/search-bar/style/css/index.js +2 -0
- package/esm/search-bar/style/index.d.ts +2 -0
- package/esm/search-bar/style/index.js +2 -0
- package/esm/search-bar/style/index.less +111 -0
- package/esm/search-bar/type.d.ts +163 -0
- package/esm/search-bar/type.js +1 -0
- package/esm/slider/index.d.ts +1 -1
- package/esm/slider/index.js +1 -1
- package/esm/steps/index.d.ts +1 -1
- package/esm/steps/index.js +1 -1
- package/esm/sticky/index.d.ts +1 -1
- package/esm/style.d.ts +2 -0
- package/esm/style.js +2 -0
- package/esm/swipe-action/demo/style/css/mobile.css +5 -0
- package/esm/swipe-action/demo/style/mobile.less +9 -0
- package/esm/swipe-action/index.d.ts +12 -0
- package/esm/swipe-action/index.js +321 -0
- package/esm/swipe-action/item.d.ts +11 -0
- package/esm/swipe-action/item.js +42 -0
- package/esm/swipe-action/style/css/index.css +88 -0
- package/esm/swipe-action/style/css/index.d.ts +2 -0
- package/esm/swipe-action/style/css/index.js +2 -0
- package/esm/swipe-action/style/index.d.ts +2 -0
- package/esm/swipe-action/style/index.js +2 -0
- package/esm/swipe-action/style/index.less +89 -0
- package/esm/swipe-action/type.d.ts +123 -0
- package/esm/swipe-action/type.js +1 -0
- package/esm/switch/index.d.ts +1 -1
- package/esm/switch/index.js +1 -1
- package/esm/tabs/tab-pane.js +5 -1
- package/esm/tag/index.d.ts +1 -1
- package/esm/tag/index.js +1 -1
- package/esm/textarea/index.d.ts +1 -1
- package/esm/textarea/index.js +1 -1
- package/package.json +3 -3
- package/tokens/app/arcodesign/default/css-variables.less +34 -0
- package/tokens/app/arcodesign/default/index.d.ts +34 -0
- package/tokens/app/arcodesign/default/index.js +34 -0
- package/tokens/app/arcodesign/default/index.json +398 -0
- package/tokens/app/arcodesign/default/index.less +34 -0
- package/umd/avatar/index.d.ts +1 -1
- package/umd/avatar/index.js +1 -1
- package/umd/badge/index.d.ts +1 -1
- package/umd/badge/index.js +1 -1
- package/umd/carousel/index.d.ts +1 -1
- package/umd/carousel/index.js +1 -1
- package/umd/cell/index.d.ts +1 -1
- package/umd/cell/index.js +1 -1
- package/umd/checkbox/index.d.ts +1 -1
- package/umd/checkbox/index.js +1 -1
- package/umd/collapse/index.d.ts +1 -1
- package/umd/collapse/index.js +1 -1
- package/umd/count-down/index.d.ts +1 -1
- package/umd/count-down/index.js +1 -1
- package/umd/date-picker/index.d.ts +1 -1
- package/umd/date-picker/index.js +1 -1
- package/umd/dropdown/dropdown.js +36 -20
- package/umd/dropdown/style/css/index.css +3 -0
- package/umd/dropdown/style/index.less +2 -0
- package/umd/ellipsis/index.d.ts +1 -1
- package/umd/ellipsis/index.js +1 -1
- package/umd/image/index.d.ts +1 -1
- package/umd/image/index.js +1 -1
- package/umd/image-picker/index.d.ts +4 -175
- package/umd/image-picker/index.js +40 -22
- package/umd/image-picker/type.d.ts +174 -0
- package/umd/image-picker/type.js +17 -0
- package/umd/image-preview/index.d.ts +1 -1
- package/umd/image-preview/index.js +1 -1
- package/umd/index.d.ts +2 -0
- package/umd/index.js +9 -5
- package/umd/input/hooks.js +48 -7
- package/umd/input/index.d.ts +1 -1
- package/umd/input/index.js +1 -1
- package/umd/input/props.d.ts +8 -2
- package/umd/notice-bar/index.d.ts +1 -1
- package/umd/notice-bar/index.js +1 -1
- package/umd/picker/index.d.ts +1 -1
- package/umd/picker/index.js +1 -1
- package/umd/picker-view/index.d.ts +1 -1
- package/umd/picker-view/index.js +1 -1
- package/umd/popover/index.d.ts +1 -1
- package/umd/popover/index.js +1 -1
- package/umd/popup-swiper/index.js +3 -2
- package/umd/radio/index.d.ts +1 -1
- package/umd/radio/index.js +1 -1
- package/umd/rate/index.d.ts +1 -1
- package/umd/rate/index.js +1 -1
- package/umd/search-bar/association.d.ts +3 -0
- package/umd/search-bar/association.js +101 -0
- package/umd/search-bar/cancel-button.d.ts +10 -0
- package/umd/search-bar/cancel-button.js +52 -0
- package/umd/search-bar/demo/style/css/mobile.css +5 -0
- package/umd/search-bar/demo/style/mobile.less +9 -0
- package/umd/search-bar/highlight.d.ts +12 -0
- package/umd/search-bar/highlight.js +87 -0
- package/umd/search-bar/index.d.ts +13 -0
- package/umd/search-bar/index.js +235 -0
- package/umd/search-bar/style/css/index.css +148 -0
- package/umd/search-bar/style/css/index.d.ts +2 -0
- package/umd/search-bar/style/css/index.js +15 -0
- package/umd/search-bar/style/index.d.ts +2 -0
- package/umd/search-bar/style/index.js +15 -0
- package/umd/search-bar/style/index.less +111 -0
- package/umd/search-bar/type.d.ts +163 -0
- package/umd/search-bar/type.js +17 -0
- package/umd/slider/index.d.ts +1 -1
- package/umd/slider/index.js +1 -1
- package/umd/steps/index.d.ts +1 -1
- package/umd/steps/index.js +1 -1
- package/umd/sticky/index.d.ts +1 -1
- package/umd/style.d.ts +2 -0
- package/umd/style.js +4 -4
- package/umd/swipe-action/demo/style/css/mobile.css +5 -0
- package/umd/swipe-action/demo/style/mobile.less +9 -0
- package/umd/swipe-action/index.d.ts +12 -0
- package/umd/swipe-action/index.js +342 -0
- package/umd/swipe-action/item.d.ts +11 -0
- package/umd/swipe-action/item.js +62 -0
- package/umd/swipe-action/style/css/index.css +88 -0
- package/umd/swipe-action/style/css/index.d.ts +2 -0
- package/umd/swipe-action/style/css/index.js +15 -0
- package/umd/swipe-action/style/index.d.ts +2 -0
- package/umd/swipe-action/style/index.js +15 -0
- package/umd/swipe-action/style/index.less +89 -0
- package/umd/swipe-action/type.d.ts +123 -0
- package/umd/swipe-action/type.js +17 -0
- package/umd/switch/index.d.ts +1 -1
- package/umd/switch/index.js +1 -1
- package/umd/tabs/tab-pane.js +5 -1
- package/umd/tag/index.d.ts +1 -1
- package/umd/tag/index.js +1 -1
- package/umd/textarea/index.d.ts +1 -1
- package/umd/textarea/index.js +1 -1
@@ -12,7 +12,7 @@ export interface DatePickerRef {
|
|
12
12
|
/**
|
13
13
|
* 日期时间选择器,基于`Picker`组件扩展,支持指定范围,单位可精确到秒。
|
14
14
|
* @en Date picker, based on the `Picker` component, supports the specified range, the unit can be accurate to seconds.
|
15
|
-
* @type
|
15
|
+
* @type 数据录入
|
16
16
|
* @type_en Data Entry
|
17
17
|
* @name 日期时间选择器
|
18
18
|
* @name_en DatePicker
|
package/esm/date-picker/index.js
CHANGED
@@ -21,7 +21,7 @@ var initDate = Date.now();
|
|
21
21
|
/**
|
22
22
|
* 日期时间选择器,基于`Picker`组件扩展,支持指定范围,单位可精确到秒。
|
23
23
|
* @en Date picker, based on the `Picker` component, supports the specified range, the unit can be accurate to seconds.
|
24
|
-
* @type
|
24
|
+
* @type 数据录入
|
25
25
|
* @type_en Data Entry
|
26
26
|
* @name 日期时间选择器
|
27
27
|
* @name_en DatePicker
|
package/esm/dropdown/dropdown.js
CHANGED
@@ -78,7 +78,7 @@ export function componentGenerator(Comp) {
|
|
78
78
|
// @en down=0 is to expand upwards, 1 is to expand downwards
|
79
79
|
|
80
80
|
|
81
|
-
var _useState3 = useState(
|
81
|
+
var _useState3 = useState(null),
|
82
82
|
down = _useState3[0],
|
83
83
|
setDown = _useState3[1];
|
84
84
|
|
@@ -117,12 +117,15 @@ export function componentGenerator(Comp) {
|
|
117
117
|
|
118
118
|
usePopupScroll(showDropdown, domRef.current, getScrollContainer);
|
119
119
|
usePreventBodyScroll(showDropdown, preventBodyScroll, initialBodyOverflow);
|
120
|
-
|
120
|
+
var updateDown = useCallback(function (wrapperHeight) {
|
121
121
|
var _dropdownContainer$cu2;
|
122
122
|
|
123
123
|
// 为0的时候不改变
|
124
124
|
// @en Does not change when it is 0
|
125
|
-
if (
|
125
|
+
if (wrapperHeight === 0) {
|
126
|
+
return;
|
127
|
+
}
|
128
|
+
|
126
129
|
var tempEl = getAnchorElement ? getAnchorElement() : (_dropdownContainer$cu2 = dropdownContainer.current) == null ? void 0 : _dropdownContainer$cu2.parentElement;
|
127
130
|
|
128
131
|
var _ref = (tempEl == null ? void 0 : tempEl.getBoundingClientRect()) || {
|
@@ -137,7 +140,7 @@ export function componentGenerator(Comp) {
|
|
137
140
|
var tempMaskHeight = windowHeight - tempTop; // 没有指定方向,且空间足够时,或向上展开的空间不够,向下展开
|
138
141
|
// @en If there is no specified direction and there is enough space, or there is not enough space to expand upward, expand downward
|
139
142
|
|
140
|
-
var tempDown = direction !== 'up' &&
|
143
|
+
var tempDown = direction !== 'up' && wrapperHeight < tempMaskHeight || wrapperHeight > tempTop;
|
141
144
|
|
142
145
|
if (tempDown) {
|
143
146
|
maskHeight.current = tempMaskHeight;
|
@@ -154,7 +157,7 @@ export function componentGenerator(Comp) {
|
|
154
157
|
}
|
155
158
|
|
156
159
|
setDown(tempDown);
|
157
|
-
}, [
|
160
|
+
}, [props.top, props.bottom, Boolean(getAnchorElement), direction, windowHeight]);
|
158
161
|
/**
|
159
162
|
* 取消选择
|
160
163
|
* @en Cancel selection
|
@@ -195,19 +198,27 @@ export function componentGenerator(Comp) {
|
|
195
198
|
};
|
196
199
|
}, [showDropdown, clickOtherToClose, handleCancel]);
|
197
200
|
useEffect(function () {
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
201
|
+
var wrapperHeight = 0;
|
202
|
+
|
203
|
+
if (height !== void 0) {
|
204
|
+
// 受控模式下,完全交由外层控制
|
205
|
+
// @en In controlled mode, it is completely controlled by the outer layer
|
206
|
+
wrapperHeight = height;
|
207
|
+
} else {
|
208
|
+
if (!optionsContainer.current) return;
|
209
|
+
|
210
|
+
if (!showDropdown) {
|
211
|
+
wrapperHeight = 0;
|
203
212
|
} else {
|
204
|
-
|
205
|
-
if (!showDropdown) setOptionsWrapperHeight(0);else {
|
206
|
-
setOptionsWrapperHeight(optionsContainer.current.getBoundingClientRect().height);
|
207
|
-
}
|
213
|
+
wrapperHeight = optionsContainer.current.getBoundingClientRect().height;
|
208
214
|
}
|
215
|
+
}
|
216
|
+
|
217
|
+
updateDown(wrapperHeight);
|
218
|
+
nextTick(function () {
|
219
|
+
setOptionsWrapperHeight(wrapperHeight);
|
209
220
|
});
|
210
|
-
}, [showDropdown, options.length, height]);
|
221
|
+
}, [showDropdown, options.length, height, updateDown]);
|
211
222
|
useImperativeHandle(ref, function () {
|
212
223
|
return {
|
213
224
|
dom: domRef.current
|
@@ -216,13 +227,17 @@ export function componentGenerator(Comp) {
|
|
216
227
|
|
217
228
|
function getOptionsStyle() {
|
218
229
|
var trans = down ? 'translateY(-100%)' : 'translateY(100%)';
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
230
|
+
var transStyle = down === null ? {
|
231
|
+
opacity: 0
|
232
|
+
} : {
|
233
|
+
opacity: 1,
|
234
|
+
transform: optionsWrapperHeight ? 'translateY(0)' : trans,
|
235
|
+
transition: "all " + dropdownAnimationTimeout + "ms " + dropdownAnimationFunction
|
236
|
+
};
|
237
|
+
return getStyleWithVendor(_extends({}, transStyle, {
|
223
238
|
overflow: optionsWrapperHeight > maxHeight || height ? 'auto' : 'hidden',
|
224
239
|
maxHeight: maxHeight + "px"
|
225
|
-
});
|
240
|
+
}));
|
226
241
|
}
|
227
242
|
|
228
243
|
function renderInnerOptions() {
|
@@ -256,6 +271,7 @@ export function componentGenerator(Comp) {
|
|
256
271
|
},
|
257
272
|
onExited: function onExited(el) {
|
258
273
|
el.style.visibility = 'hidden';
|
274
|
+
setDown(null);
|
259
275
|
},
|
260
276
|
mountOnEnter: mountOnEnter,
|
261
277
|
unmountOnExit: unmountOnExit
|
package/esm/ellipsis/index.d.ts
CHANGED
@@ -4,7 +4,7 @@ export * from './type';
|
|
4
4
|
/**
|
5
5
|
* 文本缩略组件,支持多行缩略、富文本、自定义缩略符、尾字符过滤等。
|
6
6
|
* @en Text ellipsis component supports multi-line abbreviations, rich text, custom abbreviations, tail character filtering, etc.
|
7
|
-
* @type
|
7
|
+
* @type 信息展示
|
8
8
|
* @type_en Data Display
|
9
9
|
* @name 文本缩略
|
10
10
|
* @name_en Ellipsis
|
package/esm/ellipsis/index.js
CHANGED
@@ -8,7 +8,7 @@ export * from './type';
|
|
8
8
|
/**
|
9
9
|
* 文本缩略组件,支持多行缩略、富文本、自定义缩略符、尾字符过滤等。
|
10
10
|
* @en Text ellipsis component supports multi-line abbreviations, rich text, custom abbreviations, tail character filtering, etc.
|
11
|
-
* @type
|
11
|
+
* @type 信息展示
|
12
12
|
* @type_en Data Display
|
13
13
|
* @name 文本缩略
|
14
14
|
* @name_en Ellipsis
|
package/esm/image/index.d.ts
CHANGED
@@ -177,7 +177,7 @@ export interface ImageRef {
|
|
177
177
|
/**
|
178
178
|
* 增强版的 img 标签,提供多种图片填充模式,支持图片加载中提示、加载失败提示。
|
179
179
|
* @en Enhanced img tag, provides a variety of image filling modes, and supports image loading prompts and loading failure prompts.
|
180
|
-
* @type
|
180
|
+
* @type 信息展示
|
181
181
|
* @type_en Data Display
|
182
182
|
* @name 图片
|
183
183
|
* @name_en Image
|
package/esm/image/index.js
CHANGED
@@ -8,7 +8,7 @@ import { useSystem, useWindowSize, getStyleWithVendor, useMountedState } from '.
|
|
8
8
|
/**
|
9
9
|
* 增强版的 img 标签,提供多种图片填充模式,支持图片加载中提示、加载失败提示。
|
10
10
|
* @en Enhanced img tag, provides a variety of image filling modes, and supports image loading prompts and loading failure prompts.
|
11
|
-
* @type
|
11
|
+
* @type 信息展示
|
12
12
|
* @type_en Data Display
|
13
13
|
* @name 图片
|
14
14
|
* @name_en Image
|
@@ -1,181 +1,10 @@
|
|
1
|
-
import React
|
2
|
-
import {
|
3
|
-
export
|
4
|
-
/**
|
5
|
-
* 图片地址
|
6
|
-
* @en Image Url
|
7
|
-
*/
|
8
|
-
url: string;
|
9
|
-
/**
|
10
|
-
* 图片文件
|
11
|
-
* @en Image File
|
12
|
-
*/
|
13
|
-
file?: File;
|
14
|
-
/**
|
15
|
-
* 图片状态
|
16
|
-
* @en Image Status
|
17
|
-
* @default 以图片自身加载状态而定
|
18
|
-
* @default_en According to inner status of the image
|
19
|
-
*/
|
20
|
-
status?: 'loaded' | 'loading' | 'error';
|
21
|
-
}
|
22
|
-
export interface AdapterFile {
|
23
|
-
url?: string;
|
24
|
-
size: number;
|
25
|
-
name: string;
|
26
|
-
}
|
27
|
-
export interface SelectCallback {
|
28
|
-
files: AdapterFile[];
|
29
|
-
}
|
30
|
-
export interface ImagePickerProps {
|
31
|
-
/**
|
32
|
-
* 自定义类名
|
33
|
-
* @en Custom className
|
34
|
-
*/
|
35
|
-
className?: string;
|
36
|
-
/**
|
37
|
-
* 自定义样式
|
38
|
-
* @en Custom stylesheet
|
39
|
-
*/
|
40
|
-
style?: React.CSSProperties;
|
41
|
-
/**
|
42
|
-
* 已选择图片列表
|
43
|
-
* @en selected images list
|
44
|
-
*/
|
45
|
-
images: ImagePickItem[];
|
46
|
-
/**
|
47
|
-
* 可以选择的文件类型
|
48
|
-
* @en Available File Types
|
49
|
-
* @default 'image/*'
|
50
|
-
*/
|
51
|
-
accept?: string;
|
52
|
-
/**
|
53
|
-
* 是否支持多选
|
54
|
-
* @en Whether To Support Multiple Selection
|
55
|
-
*/
|
56
|
-
multiple?: boolean;
|
57
|
-
/**
|
58
|
-
* 图片选取模式 Image selection mode [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
59
|
-
* @en Whether To Support Multiple Selection [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
60
|
-
*/
|
61
|
-
capture?: InputHTMLAttributes<unknown>['capture'];
|
62
|
-
/**
|
63
|
-
* 一行展示图片张数
|
64
|
-
* @en The Number Of Pictures Displayed In A Row
|
65
|
-
* @default 3
|
66
|
-
*/
|
67
|
-
columns?: number;
|
68
|
-
/**
|
69
|
-
* 格子间的间距
|
70
|
-
* @en spacing between grids
|
71
|
-
* @default 8
|
72
|
-
*/
|
73
|
-
gutter?: number;
|
74
|
-
/**
|
75
|
-
* 最多选择图片张数,超出数量自动隐藏上传按钮,0表示不做限制
|
76
|
-
* @en max Pictures Can Choose
|
77
|
-
*/
|
78
|
-
limit?: number;
|
79
|
-
/**
|
80
|
-
* 文件大小限制,单位为K
|
81
|
-
* @en File size limit, in K
|
82
|
-
*/
|
83
|
-
maxSize?: number;
|
84
|
-
/**
|
85
|
-
* 是否隐藏删除Icon
|
86
|
-
* @en Whether to hide delete Icon
|
87
|
-
* @default false
|
88
|
-
*/
|
89
|
-
hideDelete?: boolean;
|
90
|
-
/**
|
91
|
-
* 是否隐藏选择Icon
|
92
|
-
* @en Whether to hide Select Icon
|
93
|
-
* @default false
|
94
|
-
*/
|
95
|
-
hideSelect?: boolean;
|
96
|
-
/**
|
97
|
-
* 是否总是展示选择Icon,默认情况下当图片数量超出limit值时会自动隐藏选择Icon
|
98
|
-
* @en Whether to always show Select Icon
|
99
|
-
* @default false
|
100
|
-
*/
|
101
|
-
alwaysShowSelect?: boolean;
|
102
|
-
/**
|
103
|
-
* 禁用选择和删除图片
|
104
|
-
* @en Disable Select & Delete Image
|
105
|
-
*/
|
106
|
-
disabled?: boolean;
|
107
|
-
/**
|
108
|
-
* 自定义删除图标
|
109
|
-
* @en Defined Delete Icon
|
110
|
-
*/
|
111
|
-
deleteIcon?: React.ReactNode;
|
112
|
-
/**
|
113
|
-
* 自定义选择图标
|
114
|
-
* @en Defined Select Icon
|
115
|
-
*/
|
116
|
-
selectIcon?: React.ReactNode;
|
117
|
-
/**
|
118
|
-
* 透传给图片的属性
|
119
|
-
* @en Attributes passed through to the image
|
120
|
-
*/
|
121
|
-
imageProps?: Partial<ImageProps>;
|
122
|
-
/**
|
123
|
-
* 自定义上传失败展示
|
124
|
-
* @en Defined upload failed display
|
125
|
-
*/
|
126
|
-
renderError?: (index?: number) => React.ReactNode | React.ReactNode;
|
127
|
-
/**
|
128
|
-
* 自定义上传中展示
|
129
|
-
* @en Defined uploading display
|
130
|
-
*/
|
131
|
-
renderLoading?: (index?: number) => React.ReactNode | React.ReactNode;
|
132
|
-
/**
|
133
|
-
* 上传方法
|
134
|
-
* @en upload function
|
135
|
-
*/
|
136
|
-
upload?: (file: ImagePickItem) => Promise<ImagePickItem | null>;
|
137
|
-
/**
|
138
|
-
* 已选图片列表发生变化
|
139
|
-
* @en The list of selected images changes
|
140
|
-
*/
|
141
|
-
onChange?: (fileList: ImagePickItem[]) => void;
|
142
|
-
/**
|
143
|
-
* 图片超过限制大小
|
144
|
-
* @en Image exceeds size limit
|
145
|
-
*/
|
146
|
-
onMaxSizeExceed?: (file: File) => void;
|
147
|
-
/**
|
148
|
-
* 选择张数超过限制
|
149
|
-
* @en The number of pictures exceeds the limit
|
150
|
-
*/
|
151
|
-
onLimitExceed?: (files: File[]) => void;
|
152
|
-
/**
|
153
|
-
* 图片点击
|
154
|
-
* @en click event
|
155
|
-
*/
|
156
|
-
onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, image: ImagePickItem, index: number) => void;
|
157
|
-
/**
|
158
|
-
* 图片长按事件
|
159
|
-
* @en long press event
|
160
|
-
*/
|
161
|
-
onLongPress?: (e: React.TouchEvent<HTMLElement>, image: ImagePickItem, index: number) => void;
|
162
|
-
/**
|
163
|
-
* 图片选择适配器
|
164
|
-
* @en Select Adaptor
|
165
|
-
*/
|
166
|
-
selectAdapter?: () => Promise<SelectCallback>;
|
167
|
-
}
|
168
|
-
export interface ImagePickerRef {
|
169
|
-
/**
|
170
|
-
* 最外层 DOM 元素
|
171
|
-
* @en The outer DOM element of the component
|
172
|
-
*/
|
173
|
-
dom: HTMLDivElement | null;
|
174
|
-
}
|
1
|
+
import React from 'react';
|
2
|
+
import { ImagePickerProps, ImagePickerRef } from './type';
|
3
|
+
export * from './type';
|
175
4
|
/**
|
176
5
|
* 图片选择器组件
|
177
6
|
* @en ImagePicker Component
|
178
|
-
* @type
|
7
|
+
* @type 数据录入
|
179
8
|
* @type_en Data Entry
|
180
9
|
* @name 图片选择器
|
181
10
|
* @name_en ImagePicker
|
@@ -1,20 +1,22 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import React, { useRef, forwardRef, useImperativeHandle } from 'react';
|
3
|
+
import { Promise } from 'es6-promise';
|
3
4
|
import { cls, defaultLocale } from '@arco-design/mobile-utils';
|
4
5
|
import { ContextLayout } from '../context-provider';
|
5
6
|
import { IconClose } from '../icon';
|
6
7
|
import Image from '../image';
|
7
8
|
import Grid from '../grid';
|
8
9
|
import AddIcon from './add-icon';
|
9
|
-
|
10
|
+
export * from './type';
|
10
11
|
/**
|
11
12
|
* 图片选择器组件
|
12
13
|
* @en ImagePicker Component
|
13
|
-
* @type
|
14
|
+
* @type 数据录入
|
14
15
|
* @type_en Data Entry
|
15
16
|
* @name 图片选择器
|
16
17
|
* @name_en ImagePicker
|
17
18
|
*/
|
19
|
+
|
18
20
|
var ImagePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
19
21
|
var _props$className = props.className,
|
20
22
|
className = _props$className === void 0 ? '' : _props$className,
|
@@ -57,6 +59,7 @@ var ImagePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
57
59
|
selectAdapter = props.selectAdapter;
|
58
60
|
var domRef = useRef(null);
|
59
61
|
var fileRef = useRef(null);
|
62
|
+
var cacheRef = useRef([]);
|
60
63
|
useImperativeHandle(ref, function () {
|
61
64
|
return {
|
62
65
|
dom: domRef.current
|
@@ -92,7 +95,7 @@ var ImagePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
92
95
|
};
|
93
96
|
|
94
97
|
var handleChange = function handleChange(event, fromAdapter) {
|
95
|
-
var files =
|
98
|
+
var files = Array.prototype.filter.call(event.target.files || [], function (file) {
|
96
99
|
// 过滤maxSize
|
97
100
|
if (maxSize && file.size > maxSize * 1024) {
|
98
101
|
onMaxSizeExceed && onMaxSizeExceed(file);
|
@@ -123,20 +126,30 @@ var ImagePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
123
126
|
file: files[index]
|
124
127
|
};
|
125
128
|
});
|
126
|
-
|
127
|
-
onChange(
|
129
|
+
cacheRef.current = [].concat(images, res);
|
130
|
+
onChange([].concat(cacheRef.current)); // 执行upload
|
128
131
|
|
129
132
|
if (typeof upload === 'function') {
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
133
|
+
files.forEach(function (_file) {
|
134
|
+
upload(cacheRef.current.find(function (_ref) {
|
135
|
+
var file = _ref.file;
|
136
|
+
return file === _file;
|
137
|
+
})).then(function (data) {
|
138
|
+
var index = cacheRef.current.findIndex(function (_ref2) {
|
139
|
+
var file = _ref2.file;
|
140
|
+
return file === _file;
|
141
|
+
});
|
142
|
+
cacheRef.current[index] = _extends({}, cacheRef.current[index], data, {
|
134
143
|
status: undefined
|
135
144
|
});
|
136
145
|
}).catch(function () {
|
137
|
-
|
146
|
+
var index = cacheRef.current.findIndex(function (_ref3) {
|
147
|
+
var file = _ref3.file;
|
148
|
+
return file === _file;
|
149
|
+
});
|
150
|
+
cacheRef.current[index].status = 'error';
|
138
151
|
}).finally(function () {
|
139
|
-
onChange([].concat(
|
152
|
+
onChange([].concat(cacheRef.current));
|
140
153
|
});
|
141
154
|
});
|
142
155
|
}
|
@@ -171,8 +184,8 @@ var ImagePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
171
184
|
var handleSelect = function handleSelect() {
|
172
185
|
var _fileRef$current;
|
173
186
|
|
174
|
-
selectAdapter ? selectAdapter().then(function (
|
175
|
-
var files =
|
187
|
+
selectAdapter ? selectAdapter().then(function (_ref4) {
|
188
|
+
var files = _ref4.files;
|
176
189
|
return handleChange({
|
177
190
|
target: {
|
178
191
|
files: files
|
@@ -267,12 +280,12 @@ var ImagePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
267
280
|
return data;
|
268
281
|
};
|
269
282
|
|
270
|
-
return /*#__PURE__*/React.createElement(ContextLayout, null, function (
|
283
|
+
return /*#__PURE__*/React.createElement(ContextLayout, null, function (_ref5) {
|
271
284
|
var _cls2;
|
272
285
|
|
273
|
-
var prefixCls =
|
274
|
-
|
275
|
-
locale =
|
286
|
+
var prefixCls = _ref5.prefixCls,
|
287
|
+
_ref5$locale = _ref5.locale,
|
288
|
+
locale = _ref5$locale === void 0 ? defaultLocale : _ref5$locale;
|
276
289
|
return /*#__PURE__*/React.createElement("div", {
|
277
290
|
className: cls(prefixCls + "-image-picker", className, (_cls2 = {}, _cls2[prefixCls + "-image-picker-disabled"] = disabled, _cls2)),
|
278
291
|
style: style,
|
@@ -0,0 +1,174 @@
|
|
1
|
+
import { InputHTMLAttributes } from 'react';
|
2
|
+
import { ImageProps } from '../image';
|
3
|
+
export interface ImagePickItem {
|
4
|
+
/**
|
5
|
+
* 图片地址
|
6
|
+
* @en Image Url
|
7
|
+
*/
|
8
|
+
url: string;
|
9
|
+
/**
|
10
|
+
* 图片文件
|
11
|
+
* @en Image File
|
12
|
+
*/
|
13
|
+
file?: File;
|
14
|
+
/**
|
15
|
+
* 图片状态
|
16
|
+
* @en Image Status
|
17
|
+
* @default 以图片自身加载状态而定
|
18
|
+
* @default_en According to inner status of the image
|
19
|
+
*/
|
20
|
+
status?: 'loaded' | 'loading' | 'error';
|
21
|
+
}
|
22
|
+
export interface AdapterFile {
|
23
|
+
url?: string;
|
24
|
+
size: number;
|
25
|
+
name: string;
|
26
|
+
}
|
27
|
+
export interface SelectCallback {
|
28
|
+
files: AdapterFile[];
|
29
|
+
}
|
30
|
+
export interface ImagePickerProps {
|
31
|
+
/**
|
32
|
+
* 自定义类名
|
33
|
+
* @en Custom className
|
34
|
+
*/
|
35
|
+
className?: string;
|
36
|
+
/**
|
37
|
+
* 自定义样式
|
38
|
+
* @en Custom stylesheet
|
39
|
+
*/
|
40
|
+
style?: React.CSSProperties;
|
41
|
+
/**
|
42
|
+
* 已选择图片列表
|
43
|
+
* @en selected images list
|
44
|
+
*/
|
45
|
+
images: ImagePickItem[];
|
46
|
+
/**
|
47
|
+
* 可以选择的文件类型
|
48
|
+
* @en Available File Types
|
49
|
+
* @default 'image/*'
|
50
|
+
*/
|
51
|
+
accept?: string;
|
52
|
+
/**
|
53
|
+
* 是否支持多选
|
54
|
+
* @en Whether To Support Multiple Selection
|
55
|
+
*/
|
56
|
+
multiple?: boolean;
|
57
|
+
/**
|
58
|
+
* 图片选取模式 Image selection mode [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
59
|
+
* @en Whether To Support Multiple Selection [capture MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/capture)
|
60
|
+
*/
|
61
|
+
capture?: InputHTMLAttributes<unknown>['capture'];
|
62
|
+
/**
|
63
|
+
* 一行展示图片张数
|
64
|
+
* @en The Number Of Pictures Displayed In A Row
|
65
|
+
* @default 3
|
66
|
+
*/
|
67
|
+
columns?: number;
|
68
|
+
/**
|
69
|
+
* 格子间的间距
|
70
|
+
* @en spacing between grids
|
71
|
+
* @default 8
|
72
|
+
*/
|
73
|
+
gutter?: number;
|
74
|
+
/**
|
75
|
+
* 最多选择图片张数,超出数量自动隐藏上传按钮,0表示不做限制
|
76
|
+
* @en max Pictures Can Choose
|
77
|
+
*/
|
78
|
+
limit?: number;
|
79
|
+
/**
|
80
|
+
* 文件大小限制,单位为K
|
81
|
+
* @en File size limit, in K
|
82
|
+
*/
|
83
|
+
maxSize?: number;
|
84
|
+
/**
|
85
|
+
* 是否隐藏删除Icon
|
86
|
+
* @en Whether to hide delete Icon
|
87
|
+
* @default false
|
88
|
+
*/
|
89
|
+
hideDelete?: boolean;
|
90
|
+
/**
|
91
|
+
* 是否隐藏选择Icon
|
92
|
+
* @en Whether to hide Select Icon
|
93
|
+
* @default false
|
94
|
+
*/
|
95
|
+
hideSelect?: boolean;
|
96
|
+
/**
|
97
|
+
* 是否总是展示选择Icon,默认情况下当图片数量超出limit值时会自动隐藏选择Icon
|
98
|
+
* @en Whether to always show Select Icon
|
99
|
+
* @default false
|
100
|
+
*/
|
101
|
+
alwaysShowSelect?: boolean;
|
102
|
+
/**
|
103
|
+
* 禁用选择和删除图片
|
104
|
+
* @en Disable Select & Delete Image
|
105
|
+
*/
|
106
|
+
disabled?: boolean;
|
107
|
+
/**
|
108
|
+
* 自定义删除图标
|
109
|
+
* @en Defined Delete Icon
|
110
|
+
*/
|
111
|
+
deleteIcon?: React.ReactNode;
|
112
|
+
/**
|
113
|
+
* 自定义选择图标
|
114
|
+
* @en Defined Select Icon
|
115
|
+
*/
|
116
|
+
selectIcon?: React.ReactNode;
|
117
|
+
/**
|
118
|
+
* 透传给图片的属性
|
119
|
+
* @en Attributes passed through to the image
|
120
|
+
*/
|
121
|
+
imageProps?: Partial<ImageProps>;
|
122
|
+
/**
|
123
|
+
* 自定义上传失败展示
|
124
|
+
* @en Defined upload failed display
|
125
|
+
*/
|
126
|
+
renderError?: (index?: number) => React.ReactNode | React.ReactNode;
|
127
|
+
/**
|
128
|
+
* 自定义上传中展示
|
129
|
+
* @en Defined uploading display
|
130
|
+
*/
|
131
|
+
renderLoading?: (index?: number) => React.ReactNode | React.ReactNode;
|
132
|
+
/**
|
133
|
+
* 上传方法
|
134
|
+
* @en upload function
|
135
|
+
*/
|
136
|
+
upload?: (file: ImagePickItem) => Promise<ImagePickItem | null>;
|
137
|
+
/**
|
138
|
+
* 已选图片列表发生变化
|
139
|
+
* @en The list of selected images changes
|
140
|
+
*/
|
141
|
+
onChange?: (fileList: ImagePickItem[]) => void;
|
142
|
+
/**
|
143
|
+
* 图片超过限制大小
|
144
|
+
* @en Image exceeds size limit
|
145
|
+
*/
|
146
|
+
onMaxSizeExceed?: (file: File) => void;
|
147
|
+
/**
|
148
|
+
* 选择张数超过限制
|
149
|
+
* @en The number of pictures exceeds the limit
|
150
|
+
*/
|
151
|
+
onLimitExceed?: (files: File[]) => void;
|
152
|
+
/**
|
153
|
+
* 图片点击
|
154
|
+
* @en click event
|
155
|
+
*/
|
156
|
+
onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, image: ImagePickItem, index: number) => void;
|
157
|
+
/**
|
158
|
+
* 图片长按事件
|
159
|
+
* @en long press event
|
160
|
+
*/
|
161
|
+
onLongPress?: (e: React.TouchEvent<HTMLElement>, image: ImagePickItem, index: number) => void;
|
162
|
+
/**
|
163
|
+
* 图片选择适配器
|
164
|
+
* @en Select Adaptor
|
165
|
+
*/
|
166
|
+
selectAdapter?: () => Promise<SelectCallback>;
|
167
|
+
}
|
168
|
+
export interface ImagePickerRef {
|
169
|
+
/**
|
170
|
+
* 最外层 DOM 元素
|
171
|
+
* @en The outer DOM element of the component
|
172
|
+
*/
|
173
|
+
dom: HTMLDivElement | null;
|
174
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -280,7 +280,7 @@ declare const _default: React.ForwardRefExoticComponent<ImagePreviewProps & Reac
|
|
280
280
|
/**
|
281
281
|
* 图片预览组件,支持循环轮播、双指/双击缩放、缩略图放大效果。
|
282
282
|
* @en The image preview, supports circular rotation, two-finger/double-tap zoom, and thumbnail zoom effects.
|
283
|
-
* @type
|
283
|
+
* @type 信息展示
|
284
284
|
* @type_en Data Display
|
285
285
|
* @name 图片预览
|
286
286
|
* @name_en ImagePreview
|
@@ -983,7 +983,7 @@ export function methodsGenerator(Comp) {
|
|
983
983
|
/**
|
984
984
|
* 图片预览组件,支持循环轮播、双指/双击缩放、缩略图放大效果。
|
985
985
|
* @en The image preview, supports circular rotation, two-finger/double-tap zoom, and thumbnail zoom effects.
|
986
|
-
* @type
|
986
|
+
* @type 信息展示
|
987
987
|
* @type_en Data Display
|
988
988
|
* @name 图片预览
|
989
989
|
* @name_en ImagePreview
|