antd-mobile 5.3.1 → 5.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2x/cjs/components/cascader-view/cascader-view.d.ts +1 -0
- package/2x/cjs/components/cascader-view/use-cascader-value-extend.js +23 -0
- package/2x/cjs/components/check-list/check-list-item.js +1 -1
- package/2x/cjs/components/checkbox/checkbox.js +16 -4
- package/2x/cjs/components/floating-bubble/floating-bubble.d.ts +2 -0
- package/2x/cjs/components/floating-bubble/floating-bubble.js +56 -16
- package/2x/cjs/components/form/form-array.d.ts +19 -0
- package/2x/cjs/components/form/form-array.js +52 -0
- package/2x/cjs/components/form/form-item.css +6 -1
- package/2x/cjs/components/form/form-item.js +24 -8
- package/2x/cjs/components/form/form.css +5 -0
- package/2x/cjs/components/form/form.js +17 -6
- package/2x/cjs/components/form/index.css +11 -1
- package/2x/cjs/components/form/index.d.ts +2 -0
- package/2x/cjs/components/form/index.js +3 -0
- package/2x/cjs/components/image-uploader/image-uploader.d.ts +1 -1
- package/2x/cjs/components/image-uploader/image-uploader.js +17 -1
- package/2x/cjs/components/infinite-scroll/infinite-scroll.js +23 -19
- package/2x/cjs/components/modal/modal.js +0 -1
- package/2x/cjs/components/notice-bar/notice-bar.js +1 -1
- package/2x/cjs/components/popover/index.d.ts +7 -2
- package/2x/cjs/components/popover/normalize-placement.d.ts +2 -0
- package/2x/cjs/components/popover/normalize-placement.js +22 -0
- package/2x/cjs/components/popover/popover.css +0 -104
- package/2x/cjs/components/popover/popover.d.ts +11 -5
- package/2x/cjs/components/popover/popover.js +126 -22
- package/2x/cjs/components/popover/temp-floating-ui.min.d.ts +1 -0
- package/2x/cjs/components/popover/temp-floating-ui.min.js +430 -0
- package/2x/cjs/components/popover/wrapper.d.ts +7 -0
- package/2x/cjs/components/popover/wrapper.js +41 -0
- package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +24 -9
- package/2x/cjs/components/radio/radio.js +16 -4
- package/2x/cjs/components/search-bar/search-bar.js +0 -1
- package/2x/cjs/components/swiper/swiper.js +1 -1
- package/2x/cjs/components/text-area/text-area.css +4 -1
- package/2x/cjs/components/text-area/text-area.d.ts +2 -2
- package/2x/cjs/utils/use-props-value.d.ts +2 -1
- package/2x/cjs/utils/use-props-value.js +4 -2
- package/2x/es/components/cascader-view/cascader-view.d.ts +1 -0
- package/2x/es/components/cascader-view/use-cascader-value-extend.js +23 -0
- package/2x/es/components/check-list/check-list-item.js +1 -1
- package/2x/es/components/checkbox/checkbox.js +17 -5
- package/2x/es/components/floating-bubble/floating-bubble.d.ts +2 -0
- package/2x/es/components/floating-bubble/floating-bubble.js +57 -17
- package/2x/es/components/form/form-array.d.ts +19 -0
- package/2x/es/components/form/form-array.js +38 -0
- package/2x/es/components/form/form-item.css +6 -1
- package/2x/es/components/form/form-item.js +22 -8
- package/2x/es/components/form/form.css +5 -0
- package/2x/es/components/form/form.js +16 -6
- package/2x/es/components/form/index.css +11 -1
- package/2x/es/components/form/index.d.ts +2 -0
- package/2x/es/components/form/index.js +2 -0
- package/2x/es/components/image-uploader/image-uploader.d.ts +1 -1
- package/2x/es/components/image-uploader/image-uploader.js +17 -1
- package/2x/es/components/infinite-scroll/infinite-scroll.js +22 -19
- package/2x/es/components/modal/modal.js +0 -1
- package/2x/es/components/notice-bar/notice-bar.js +1 -1
- package/2x/es/components/popover/index.d.ts +7 -2
- package/2x/es/components/popover/normalize-placement.d.ts +2 -0
- package/2x/es/components/popover/normalize-placement.js +15 -0
- package/2x/es/components/popover/popover.css +0 -104
- package/2x/es/components/popover/popover.d.ts +11 -5
- package/2x/es/components/popover/popover.js +118 -22
- package/2x/es/components/popover/temp-floating-ui.min.d.ts +1 -0
- package/2x/es/components/popover/temp-floating-ui.min.js +430 -0
- package/2x/es/components/popover/wrapper.d.ts +7 -0
- package/2x/es/components/popover/wrapper.js +28 -0
- package/2x/es/components/pull-to-refresh/pull-to-refresh.js +24 -9
- package/2x/es/components/radio/radio.js +17 -5
- package/2x/es/components/search-bar/search-bar.js +0 -1
- package/2x/es/components/swiper/swiper.js +1 -1
- package/2x/es/components/text-area/text-area.css +4 -1
- package/2x/es/components/text-area/text-area.d.ts +2 -2
- package/2x/es/utils/use-props-value.d.ts +2 -1
- package/2x/es/utils/use-props-value.js +4 -2
- package/2x/package.json +2 -2
- package/cjs/components/cascader-view/cascader-view.d.ts +1 -0
- package/cjs/components/cascader-view/use-cascader-value-extend.js +23 -0
- package/cjs/components/check-list/check-list-item.js +1 -1
- package/cjs/components/checkbox/checkbox.js +16 -4
- package/cjs/components/floating-bubble/floating-bubble.d.ts +2 -0
- package/cjs/components/floating-bubble/floating-bubble.js +56 -16
- package/cjs/components/form/form-array.d.ts +19 -0
- package/cjs/components/form/form-array.js +52 -0
- package/cjs/components/form/form-item.css +5 -1
- package/cjs/components/form/form-item.js +24 -8
- package/cjs/components/form/form.css +4 -0
- package/cjs/components/form/form.js +17 -6
- package/cjs/components/form/index.css +9 -1
- package/cjs/components/form/index.d.ts +2 -0
- package/cjs/components/form/index.js +3 -0
- package/cjs/components/image-uploader/image-uploader.d.ts +1 -1
- package/cjs/components/image-uploader/image-uploader.js +17 -1
- package/cjs/components/infinite-scroll/infinite-scroll.js +23 -19
- package/cjs/components/modal/modal.js +0 -1
- package/cjs/components/notice-bar/notice-bar.js +1 -1
- package/cjs/components/popover/index.d.ts +7 -2
- package/cjs/components/popover/normalize-placement.d.ts +2 -0
- package/cjs/components/popover/normalize-placement.js +22 -0
- package/cjs/components/popover/popover.css +0 -84
- package/cjs/components/popover/popover.d.ts +11 -5
- package/cjs/components/popover/popover.js +126 -22
- package/cjs/components/popover/temp-floating-ui.min.d.ts +1 -0
- package/cjs/components/popover/temp-floating-ui.min.js +430 -0
- package/cjs/components/popover/wrapper.d.ts +7 -0
- package/cjs/components/popover/wrapper.js +41 -0
- package/cjs/components/pull-to-refresh/pull-to-refresh.js +24 -9
- package/cjs/components/radio/radio.js +16 -4
- package/cjs/components/search-bar/search-bar.js +0 -1
- package/cjs/components/swiper/swiper.js +1 -1
- package/cjs/components/text-area/text-area.css +4 -1
- package/cjs/components/text-area/text-area.d.ts +2 -2
- package/cjs/utils/use-props-value.d.ts +2 -1
- package/cjs/utils/use-props-value.js +4 -2
- package/es/components/cascader-view/cascader-view.d.ts +1 -0
- package/es/components/cascader-view/use-cascader-value-extend.js +23 -0
- package/es/components/check-list/check-list-item.js +1 -1
- package/es/components/checkbox/checkbox.js +17 -5
- package/es/components/floating-bubble/floating-bubble.d.ts +2 -0
- package/es/components/floating-bubble/floating-bubble.js +57 -17
- package/es/components/form/form-array.d.ts +19 -0
- package/es/components/form/form-array.js +38 -0
- package/es/components/form/form-item.css +5 -1
- package/es/components/form/form-item.js +22 -8
- package/es/components/form/form.css +4 -0
- package/es/components/form/form.js +16 -6
- package/es/components/form/index.css +9 -1
- package/es/components/form/index.d.ts +2 -0
- package/es/components/form/index.js +2 -0
- package/es/components/image-uploader/image-uploader.d.ts +1 -1
- package/es/components/image-uploader/image-uploader.js +17 -1
- package/es/components/infinite-scroll/infinite-scroll.js +22 -19
- package/es/components/modal/modal.js +0 -1
- package/es/components/notice-bar/notice-bar.js +1 -1
- package/es/components/popover/index.d.ts +7 -2
- package/es/components/popover/normalize-placement.d.ts +2 -0
- package/es/components/popover/normalize-placement.js +15 -0
- package/es/components/popover/popover.css +0 -84
- package/es/components/popover/popover.d.ts +11 -5
- package/es/components/popover/popover.js +118 -22
- package/es/components/popover/temp-floating-ui.min.d.ts +1 -0
- package/es/components/popover/temp-floating-ui.min.js +430 -0
- package/es/components/popover/wrapper.d.ts +7 -0
- package/es/components/popover/wrapper.js +28 -0
- package/es/components/pull-to-refresh/pull-to-refresh.js +24 -9
- package/es/components/radio/radio.js +17 -5
- package/es/components/search-bar/search-bar.js +0 -1
- package/es/components/swiper/swiper.js +1 -1
- package/es/components/text-area/text-area.css +4 -1
- package/es/components/text-area/text-area.d.ts +2 -2
- package/es/utils/use-props-value.d.ts +2 -1
- package/es/utils/use-props-value.js +4 -2
- package/package.json +2 -2
- package/umd/antd-mobile.js +1 -1
|
@@ -32,11 +32,34 @@ function useCascaderValueExtend(options) {
|
|
|
32
32
|
return ret;
|
|
33
33
|
}, val => JSON.stringify(val));
|
|
34
34
|
}, [options]);
|
|
35
|
+
const generateIsLeaf = (0, _react.useMemo)(() => {
|
|
36
|
+
return (0, _memoize.default)(val => {
|
|
37
|
+
var _a;
|
|
38
|
+
|
|
39
|
+
let isLeaf = false;
|
|
40
|
+
|
|
41
|
+
for (const v of val) {
|
|
42
|
+
const target = options.find(option => option.value === v);
|
|
43
|
+
|
|
44
|
+
if (!target) {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
isLeaf = ((_a = target.children) === null || _a === void 0 ? void 0 : _a.length) === val.length;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return isLeaf;
|
|
52
|
+
}, val => JSON.stringify(val));
|
|
53
|
+
}, [options]);
|
|
35
54
|
|
|
36
55
|
function generateValueExtend(val) {
|
|
37
56
|
return {
|
|
38
57
|
get items() {
|
|
39
58
|
return generateItems(val);
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
get isLeaf() {
|
|
62
|
+
return generateIsLeaf(val);
|
|
40
63
|
}
|
|
41
64
|
|
|
42
65
|
};
|
|
@@ -42,7 +42,7 @@ const CheckListItem = props => {
|
|
|
42
42
|
|
|
43
43
|
return (0, _nativeProps.withNativeProps)(props, _react.default.createElement(_list.default.Item, {
|
|
44
44
|
title: props.title,
|
|
45
|
-
className: (0, _classnames.default)(classPrefix, readOnly && `${classPrefix}-readonly`),
|
|
45
|
+
className: (0, _classnames.default)(classPrefix, readOnly && `${classPrefix}-readonly`, active && `${classPrefix}-active`),
|
|
46
46
|
description: props.description,
|
|
47
47
|
prefix: props.prefix,
|
|
48
48
|
onClick: e => {
|
|
@@ -90,7 +90,22 @@ const Checkbox = p => {
|
|
|
90
90
|
}, props.indeterminate ? _react.default.createElement(_indeterminateIcon.IndeterminateIcon, null) : checked && _react.default.createElement(_checkIcon.CheckIcon, null));
|
|
91
91
|
};
|
|
92
92
|
|
|
93
|
+
const inputRef = (0, _react.useRef)(null);
|
|
94
|
+
const labelRef = (0, _react.useRef)(null);
|
|
95
|
+
(0, _react.useEffect)(() => {
|
|
96
|
+
var _a;
|
|
97
|
+
|
|
98
|
+
(_a = labelRef.current) === null || _a === void 0 ? void 0 : _a.addEventListener('click', e => {
|
|
99
|
+
if (e.target !== inputRef.current) {
|
|
100
|
+
e.stopPropagation();
|
|
101
|
+
e.stopImmediatePropagation();
|
|
102
|
+
}
|
|
103
|
+
}, {
|
|
104
|
+
capture: false
|
|
105
|
+
});
|
|
106
|
+
}, []);
|
|
93
107
|
return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("label", {
|
|
108
|
+
ref: labelRef,
|
|
94
109
|
className: (0, _classnames.default)(classPrefix, {
|
|
95
110
|
[`${classPrefix}-checked`]: checked && !props.indeterminate,
|
|
96
111
|
[`${classPrefix}-indeterminate`]: props.indeterminate,
|
|
@@ -98,15 +113,12 @@ const Checkbox = p => {
|
|
|
98
113
|
[`${classPrefix}-block`]: props.block
|
|
99
114
|
})
|
|
100
115
|
}, _react.default.createElement("input", {
|
|
116
|
+
ref: inputRef,
|
|
101
117
|
type: 'checkbox',
|
|
102
118
|
checked: checked,
|
|
103
119
|
onChange: e => {
|
|
104
120
|
setChecked(e.target.checked);
|
|
105
121
|
},
|
|
106
|
-
onClick: e => {
|
|
107
|
-
e.stopPropagation();
|
|
108
|
-
e.nativeEvent.stopImmediatePropagation();
|
|
109
|
-
},
|
|
110
122
|
disabled: disabled,
|
|
111
123
|
id: props.id
|
|
112
124
|
}), renderIcon(), props.children && _react.default.createElement("div", {
|
|
@@ -2,5 +2,7 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
export declare type FloatingBubbleProps = {
|
|
4
4
|
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
|
|
5
|
+
axis?: 'x' | 'y' | 'xy' | 'lock';
|
|
6
|
+
magnetic?: 'x' | 'y';
|
|
5
7
|
} & NativeProps<'--initial-position-left' | '--initial-position-right' | '--initial-position-top' | '--initial-position-bottom' | '--z-index' | '--edge-distance' | '--size' | '--border-radius'>;
|
|
6
8
|
export declare const FloatingBubble: FC<FloatingBubbleProps>;
|
|
@@ -20,45 +20,81 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
20
20
|
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; }
|
|
21
21
|
|
|
22
22
|
const classPrefix = `adm-floating-bubble`;
|
|
23
|
-
const defaultProps = {
|
|
23
|
+
const defaultProps = {
|
|
24
|
+
axis: 'y'
|
|
25
|
+
};
|
|
24
26
|
|
|
25
27
|
const FloatingBubble = p => {
|
|
26
28
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
27
29
|
const boundaryRef = (0, _react.useRef)(null);
|
|
30
|
+
const buttonRef = (0, _react.useRef)(null);
|
|
28
31
|
/**
|
|
29
32
|
* memoize the `to` function
|
|
30
33
|
* inside a component that renders frequently
|
|
31
34
|
* to prevent an unintended restart
|
|
32
35
|
*/
|
|
33
36
|
|
|
34
|
-
const [
|
|
37
|
+
const [{
|
|
38
|
+
x,
|
|
39
|
+
y,
|
|
40
|
+
opacity
|
|
41
|
+
}, api] = (0, _web.useSpring)(() => ({
|
|
42
|
+
x: 0,
|
|
35
43
|
y: 0,
|
|
36
|
-
scale: 1,
|
|
37
44
|
opacity: 1
|
|
38
45
|
}));
|
|
39
46
|
const bind = (0, _react2.useDrag)(state => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
47
|
+
let nextX = state.offset[0];
|
|
48
|
+
let nextY = state.offset[1];
|
|
49
|
+
|
|
50
|
+
if (state.last && props.magnetic) {
|
|
51
|
+
const boundary = boundaryRef.current;
|
|
52
|
+
const button = buttonRef.current;
|
|
53
|
+
if (!boundary || !button) return;
|
|
54
|
+
const boundaryRect = boundary.getBoundingClientRect();
|
|
55
|
+
const buttonRect = button.getBoundingClientRect();
|
|
56
|
+
|
|
57
|
+
if (props.magnetic === 'x') {
|
|
58
|
+
const compensation = x.goal - x.get();
|
|
59
|
+
const leftDistance = buttonRect.left + compensation - boundaryRect.left;
|
|
60
|
+
const rightDistance = boundaryRect.right - (buttonRect.right + compensation);
|
|
46
61
|
|
|
62
|
+
if (rightDistance <= leftDistance) {
|
|
63
|
+
nextX += rightDistance;
|
|
64
|
+
} else {
|
|
65
|
+
nextX -= leftDistance;
|
|
66
|
+
}
|
|
67
|
+
} else if (props.magnetic === 'y') {
|
|
68
|
+
const compensation = y.goal - y.get();
|
|
69
|
+
const topDistance = buttonRect.top + compensation - boundaryRect.top;
|
|
70
|
+
const bottomDistance = boundaryRect.bottom - (buttonRect.bottom + compensation);
|
|
47
71
|
|
|
48
|
-
|
|
49
|
-
|
|
72
|
+
if (bottomDistance <= topDistance) {
|
|
73
|
+
nextY += bottomDistance;
|
|
74
|
+
} else {
|
|
75
|
+
nextY -= topDistance;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
api.start({
|
|
81
|
+
x: nextX,
|
|
82
|
+
y: nextY
|
|
83
|
+
}); // active status
|
|
84
|
+
|
|
85
|
+
api.start({
|
|
50
86
|
opacity: state.active ? 0.8 : 1
|
|
51
87
|
});
|
|
52
88
|
}, {
|
|
53
|
-
|
|
54
|
-
axis: 'y',
|
|
89
|
+
axis: props.axis === 'xy' ? undefined : props.axis,
|
|
55
90
|
pointer: {
|
|
56
91
|
touch: true
|
|
57
92
|
},
|
|
58
93
|
// the component won't trigger drag logic if the user just clicked on the component.
|
|
59
94
|
filterTaps: true,
|
|
60
95
|
// set constraints to the user gesture
|
|
61
|
-
bounds: boundaryRef
|
|
96
|
+
bounds: boundaryRef,
|
|
97
|
+
from: () => [x.get(), y.get()]
|
|
62
98
|
});
|
|
63
99
|
return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
|
|
64
100
|
className: classPrefix
|
|
@@ -68,9 +104,13 @@ const FloatingBubble = p => {
|
|
|
68
104
|
className: `${classPrefix}-boundary`,
|
|
69
105
|
ref: boundaryRef
|
|
70
106
|
})), _react.default.createElement(_web.animated.div, Object.assign({}, bind(), {
|
|
71
|
-
style:
|
|
107
|
+
style: {
|
|
108
|
+
opacity,
|
|
109
|
+
transform: (0, _web.to)([x, y], (x, y) => `translate(${x}px, ${y}px)`)
|
|
110
|
+
},
|
|
72
111
|
onClick: props.onClick,
|
|
73
|
-
className: `${classPrefix}-button
|
|
112
|
+
className: `${classPrefix}-button`,
|
|
113
|
+
ref: buttonRef
|
|
74
114
|
}), props.children)));
|
|
75
115
|
};
|
|
76
116
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { StoreValue } from 'rc-field-form/es/interface';
|
|
3
|
+
export interface FormArrayField {
|
|
4
|
+
index: number;
|
|
5
|
+
key: number;
|
|
6
|
+
}
|
|
7
|
+
export interface FormArrayOperation {
|
|
8
|
+
add: (defaultValue?: StoreValue, insertIndex?: number) => void;
|
|
9
|
+
remove: (index: number | number[]) => void;
|
|
10
|
+
move: (from: number, to: number) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface FormArrayProps {
|
|
13
|
+
name: string | number | (string | number)[];
|
|
14
|
+
initialValue?: any[];
|
|
15
|
+
renderHeader?: (field: FormArrayField, operation: FormArrayOperation) => ReactNode;
|
|
16
|
+
renderAdd?: () => ReactNode;
|
|
17
|
+
children: (fields: FormArrayField[], operation: FormArrayOperation) => ReactElement[];
|
|
18
|
+
}
|
|
19
|
+
export declare const FormArray: React.FC<FormArrayProps>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FormArray = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _rcFieldForm = require("rc-field-form");
|
|
11
|
+
|
|
12
|
+
var _list = _interopRequireDefault(require("../list"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const FormArray = props => {
|
|
17
|
+
return _react.default.createElement(_rcFieldForm.List, {
|
|
18
|
+
name: props.name,
|
|
19
|
+
initialValue: props.initialValue
|
|
20
|
+
}, (rcFields, operation) => {
|
|
21
|
+
const fields = rcFields.map(field => ({
|
|
22
|
+
index: field.name,
|
|
23
|
+
key: field.key
|
|
24
|
+
}));
|
|
25
|
+
const children = props.children(fields, operation).map((child, index) => {
|
|
26
|
+
var _a;
|
|
27
|
+
|
|
28
|
+
return _react.default.createElement(_list.default, {
|
|
29
|
+
key: fields[index].key,
|
|
30
|
+
mode: 'card',
|
|
31
|
+
header: (_a = props.renderHeader) === null || _a === void 0 ? void 0 : _a.call(props, fields[index], operation)
|
|
32
|
+
}, child);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (props.renderAdd) {
|
|
36
|
+
children.push(_react.default.createElement(_list.default, {
|
|
37
|
+
key: 'add',
|
|
38
|
+
mode: 'card'
|
|
39
|
+
}, _react.default.createElement(_list.default.Item, {
|
|
40
|
+
className: 'adm-form-list-operation',
|
|
41
|
+
onClick: () => {
|
|
42
|
+
operation.add();
|
|
43
|
+
},
|
|
44
|
+
arrow: false
|
|
45
|
+
}, props.renderAdd())));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return _react.default.createElement(_react.default.Fragment, null, children);
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.FormArray = FormArray;
|
|
@@ -40,10 +40,14 @@
|
|
|
40
40
|
.adm-form-item-child-position-right > * {
|
|
41
41
|
flex: none;
|
|
42
42
|
}
|
|
43
|
-
.adm-form-item-
|
|
43
|
+
.adm-form-item-feedback-error {
|
|
44
44
|
color: var(--adm-color-danger);
|
|
45
45
|
margin-top: 4px;
|
|
46
46
|
}
|
|
47
|
+
.adm-form-item-feedback-warning {
|
|
48
|
+
color: var(--adm-color-warning);
|
|
49
|
+
margin-top: 4px;
|
|
50
|
+
}
|
|
47
51
|
.adm-form-item.adm-form-item-hidden {
|
|
48
52
|
display: none;
|
|
49
53
|
}
|
|
@@ -54,9 +54,7 @@ const FormItemLayout = props => {
|
|
|
54
54
|
children,
|
|
55
55
|
htmlFor,
|
|
56
56
|
hidden,
|
|
57
|
-
errors,
|
|
58
57
|
arrow,
|
|
59
|
-
description,
|
|
60
58
|
childElementPosition = 'normal'
|
|
61
59
|
} = props;
|
|
62
60
|
const context = (0, _react.useContext)(_context.FormContext);
|
|
@@ -65,7 +63,6 @@ const FormItemLayout = props => {
|
|
|
65
63
|
} = (0, _configProvider.useConfig)();
|
|
66
64
|
const hasFeedback = props.hasFeedback !== undefined ? props.hasFeedback : context.hasFeedback;
|
|
67
65
|
const layout = props.layout || context.layout;
|
|
68
|
-
const feedback = hasFeedback && errors && errors.length > 0 ? errors[0] : null;
|
|
69
66
|
|
|
70
67
|
const requiredMark = (() => {
|
|
71
68
|
const {
|
|
@@ -103,15 +100,21 @@ const FormItemLayout = props => {
|
|
|
103
100
|
mode: 'dark',
|
|
104
101
|
trigger: 'click'
|
|
105
102
|
}, _react.default.createElement(_antdMobileIcons.QuestionCircleOutline, null)))) : null;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
|
|
104
|
+
const description = _react.default.createElement(_react.default.Fragment, null, props.description, hasFeedback && _react.default.createElement(_react.default.Fragment, null, props.errors.map((error, index) => _react.default.createElement("div", {
|
|
105
|
+
key: `error-${index}`,
|
|
106
|
+
className: `${classPrefix}-feedback-error`
|
|
107
|
+
}, error)), props.warnings.map((warning, index) => _react.default.createElement("div", {
|
|
108
|
+
key: `warning-${index}`,
|
|
109
|
+
className: `${classPrefix}-feedback-warning`
|
|
110
|
+
}, warning))));
|
|
111
|
+
|
|
109
112
|
return _react.default.createElement(_list.default.Item, {
|
|
110
113
|
style: style,
|
|
111
114
|
title: layout === 'vertical' && labelElement,
|
|
112
115
|
prefix: layout === 'horizontal' && labelElement,
|
|
113
116
|
extra: extra,
|
|
114
|
-
description:
|
|
117
|
+
description: description,
|
|
115
118
|
className: (0, _classnames.default)(classPrefix, className, `${classPrefix}-${layout}`, {
|
|
116
119
|
[`${classPrefix}-hidden`]: hidden
|
|
117
120
|
}),
|
|
@@ -182,7 +185,7 @@ const FormItem = props => {
|
|
|
182
185
|
}, [setSubMetas]);
|
|
183
186
|
|
|
184
187
|
function renderLayout(baseChildren, fieldId, meta, isRequired) {
|
|
185
|
-
var _a;
|
|
188
|
+
var _a, _b;
|
|
186
189
|
|
|
187
190
|
if (noStyle && !hidden) {
|
|
188
191
|
return baseChildren;
|
|
@@ -200,6 +203,18 @@ const FormItem = props => {
|
|
|
200
203
|
|
|
201
204
|
return subErrors;
|
|
202
205
|
}, curErrors);
|
|
206
|
+
const curWarnings = (_b = meta === null || meta === void 0 ? void 0 : meta.warnings) !== null && _b !== void 0 ? _b : [];
|
|
207
|
+
const warnings = Object.keys(subMetas).reduce((subWarnings, key) => {
|
|
208
|
+
var _a, _b;
|
|
209
|
+
|
|
210
|
+
const warnings = (_b = (_a = subMetas[key]) === null || _a === void 0 ? void 0 : _a.warnings) !== null && _b !== void 0 ? _b : [];
|
|
211
|
+
|
|
212
|
+
if (warnings.length) {
|
|
213
|
+
subWarnings = [...subWarnings, ...warnings];
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return subWarnings;
|
|
217
|
+
}, curWarnings);
|
|
203
218
|
return _react.default.createElement(FormItemLayout, {
|
|
204
219
|
className: className,
|
|
205
220
|
style: style,
|
|
@@ -212,6 +227,7 @@ const FormItem = props => {
|
|
|
212
227
|
hasFeedback: hasFeedback,
|
|
213
228
|
htmlFor: fieldId,
|
|
214
229
|
errors: errors,
|
|
230
|
+
warnings: warnings,
|
|
215
231
|
onClick: onClick,
|
|
216
232
|
hidden: hidden,
|
|
217
233
|
layout: layout,
|
|
@@ -25,6 +25,8 @@ var _configProvider = require("../config-provider");
|
|
|
25
25
|
|
|
26
26
|
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
27
27
|
|
|
28
|
+
var _formArray = require("./form-array");
|
|
29
|
+
|
|
28
30
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
31
|
|
|
30
32
|
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); }
|
|
@@ -66,13 +68,22 @@ const Form = (0, _react.forwardRef)((p, ref) => {
|
|
|
66
68
|
items = [];
|
|
67
69
|
}
|
|
68
70
|
|
|
69
|
-
_react.default.Children.forEach(props.children,
|
|
70
|
-
if (_react.default.isValidElement(child)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
_react.default.Children.forEach(props.children, child => {
|
|
72
|
+
if (_react.default.isValidElement(child)) {
|
|
73
|
+
if (child.type === _header.Header) {
|
|
74
|
+
collect();
|
|
75
|
+
currentHeader = child.props.children;
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (child.type === _formArray.FormArray) {
|
|
80
|
+
collect();
|
|
81
|
+
lists.push(child);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
75
84
|
}
|
|
85
|
+
|
|
86
|
+
items.push(child);
|
|
76
87
|
});
|
|
77
88
|
|
|
78
89
|
collect();
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
.adm-form .adm-form-footer {
|
|
17
17
|
padding: 20px 12px;
|
|
18
18
|
}
|
|
19
|
+
.adm-form-list-operation {
|
|
20
|
+
text-align: center;
|
|
21
|
+
color: #1677ff;
|
|
22
|
+
}
|
|
19
23
|
.adm-form-item + .adm-form-item {
|
|
20
24
|
border-top: none;
|
|
21
25
|
}
|
|
@@ -58,10 +62,14 @@
|
|
|
58
62
|
.adm-form-item-child-position-right > * {
|
|
59
63
|
flex: none;
|
|
60
64
|
}
|
|
61
|
-
.adm-form-item-
|
|
65
|
+
.adm-form-item-feedback-error {
|
|
62
66
|
color: var(--adm-color-danger);
|
|
63
67
|
margin-top: 4px;
|
|
64
68
|
}
|
|
69
|
+
.adm-form-item-feedback-warning {
|
|
70
|
+
color: var(--adm-color-warning);
|
|
71
|
+
margin-top: 4px;
|
|
72
|
+
}
|
|
65
73
|
.adm-form-item.adm-form-item-hidden {
|
|
66
74
|
display: none;
|
|
67
75
|
}
|
|
@@ -6,6 +6,7 @@ export type { FormProps, FormInstance } from './form';
|
|
|
6
6
|
export type { FormItemProps } from './form-item';
|
|
7
7
|
export type { FormSubscribeProps } from './form-subscribe';
|
|
8
8
|
export type { ValidateMessages, FieldData, NamePath, } from 'rc-field-form/es/interface';
|
|
9
|
+
export type { FormArrayField, FormArrayOperation, FormArrayProps, } from './form-array';
|
|
9
10
|
declare const _default: import("react").ForwardRefExoticComponent<Pick<import("rc-field-form").FormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & import("../../utils/native-props").NativeProps<"--border-inner" | "--border-top" | "--border-bottom"> & Partial<import("./context").FormContextType> & {
|
|
10
11
|
footer?: import("react").ReactNode;
|
|
11
12
|
layout?: FormLayout | undefined;
|
|
@@ -14,6 +15,7 @@ declare const _default: import("react").ForwardRefExoticComponent<Pick<import("r
|
|
|
14
15
|
Item: import("react").FC<import("./form-item").FormItemProps>;
|
|
15
16
|
Subscribe: import("react").VFC<import("./form-subscribe").FormSubscribeProps>;
|
|
16
17
|
Header: import("react").FC<{}>;
|
|
18
|
+
Array: import("react").FC<import("./form-array").FormArrayProps>;
|
|
17
19
|
useForm: typeof useForm;
|
|
18
20
|
};
|
|
19
21
|
export default _default;
|
|
@@ -19,10 +19,13 @@ var _rcFieldForm = require("rc-field-form");
|
|
|
19
19
|
|
|
20
20
|
var _formSubscribe = require("./form-subscribe");
|
|
21
21
|
|
|
22
|
+
var _formArray = require("./form-array");
|
|
23
|
+
|
|
22
24
|
var _default = (0, _attachPropertiesToComponent.attachPropertiesToComponent)(_form.Form, {
|
|
23
25
|
Item: _formItem.FormItem,
|
|
24
26
|
Subscribe: _formSubscribe.FormSubscribe,
|
|
25
27
|
Header: _header.Header,
|
|
28
|
+
Array: _formArray.FormArray,
|
|
26
29
|
useForm: _rcFieldForm.useForm
|
|
27
30
|
});
|
|
28
31
|
|
|
@@ -20,7 +20,7 @@ export declare type ImageUploaderProps = {
|
|
|
20
20
|
deletable?: boolean;
|
|
21
21
|
capture?: InputHTMLAttributes<unknown>['capture'];
|
|
22
22
|
onPreview?: (index: number, item: ImageUploadItem) => void;
|
|
23
|
-
beforeUpload?: (file: File[]) => Promise<File
|
|
23
|
+
beforeUpload?: (file: File, files: File[]) => Promise<File | null> | File | null;
|
|
24
24
|
upload: (file: File) => Promise<ImageUploadItem>;
|
|
25
25
|
onDelete?: (item: ImageUploadItem) => boolean | Promise<boolean> | void;
|
|
26
26
|
preview?: boolean;
|
|
@@ -63,6 +63,17 @@ const ImageUploader = p => {
|
|
|
63
63
|
onPreview
|
|
64
64
|
} = props;
|
|
65
65
|
|
|
66
|
+
function processFile(file, fileList) {
|
|
67
|
+
return (0, _tslib.__awaiter)(this, void 0, void 0, function* () {
|
|
68
|
+
const {
|
|
69
|
+
beforeUpload
|
|
70
|
+
} = props;
|
|
71
|
+
let transformedFile = file;
|
|
72
|
+
transformedFile = yield beforeUpload === null || beforeUpload === void 0 ? void 0 : beforeUpload(file, fileList);
|
|
73
|
+
return transformedFile;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
66
77
|
function onChange(e) {
|
|
67
78
|
var _a;
|
|
68
79
|
|
|
@@ -75,7 +86,12 @@ const ImageUploader = p => {
|
|
|
75
86
|
let files = [].slice.call(rawFiles);
|
|
76
87
|
|
|
77
88
|
if (props.beforeUpload) {
|
|
78
|
-
|
|
89
|
+
const postFiles = files.map(file => {
|
|
90
|
+
return processFile(file, files);
|
|
91
|
+
});
|
|
92
|
+
yield Promise.all(postFiles).then(filesList => {
|
|
93
|
+
files = filesList.filter(Boolean);
|
|
94
|
+
});
|
|
79
95
|
}
|
|
80
96
|
|
|
81
97
|
if (files.length === 0) {
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.InfiniteScroll = void 0;
|
|
7
7
|
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
|
+
|
|
8
10
|
var _withDefaultProps = require("../../utils/with-default-props");
|
|
9
11
|
|
|
10
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
@@ -41,25 +43,27 @@ const InfiniteScroll = p => {
|
|
|
41
43
|
}, p);
|
|
42
44
|
const doLoadMore = (0, _ahooks.useLockFn)(() => props.loadMore());
|
|
43
45
|
const elementRef = (0, _react.useRef)(null);
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
46
|
+
const [flag, setFlag] = (0, _react.useState)({});
|
|
47
|
+
const nextFlagRef = (0, _react.useRef)(flag);
|
|
48
|
+
const check = (0, _ahooks.useMemoizedFn)(() => (0, _tslib.__awaiter)(void 0, void 0, void 0, function* () {
|
|
49
|
+
if (nextFlagRef.current !== flag) return;
|
|
50
|
+
if (!props.hasMore) return;
|
|
51
|
+
const element = elementRef.current;
|
|
52
|
+
if (!element) return;
|
|
53
|
+
if (!element.offsetParent) return;
|
|
54
|
+
const parent = (0, _getScrollParent.getScrollParent)(element);
|
|
55
|
+
if (!parent) return;
|
|
56
|
+
const rect = element.getBoundingClientRect();
|
|
57
|
+
const elementTop = rect.top;
|
|
58
|
+
const current = isWindow(parent) ? window.innerHeight : parent.getBoundingClientRect().bottom;
|
|
59
|
+
|
|
60
|
+
if (current >= elementTop - props.threshold) {
|
|
61
|
+
const nextFlag = {};
|
|
62
|
+
nextFlagRef.current = nextFlag;
|
|
63
|
+
yield doLoadMore();
|
|
64
|
+
setFlag(nextFlag);
|
|
65
|
+
}
|
|
66
|
+
})); // 确保在内容不足时会自动触发加载事件
|
|
63
67
|
|
|
64
68
|
(0, _react.useEffect)(() => {
|
|
65
69
|
check();
|
|
@@ -41,7 +41,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
41
41
|
|
|
42
42
|
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; }
|
|
43
43
|
|
|
44
|
-
const classPrefix = `adm-modal`;
|
|
45
44
|
const defaultProps = {
|
|
46
45
|
visible: false,
|
|
47
46
|
actions: [],
|
|
@@ -76,7 +76,7 @@ const NoticeBar = (0, _react.memo)(p => {
|
|
|
76
76
|
delayLockRef.current = false;
|
|
77
77
|
start();
|
|
78
78
|
}, props.delay);
|
|
79
|
-
(0, _useResizeEffect.useResizeEffect)(
|
|
79
|
+
(0, _useResizeEffect.useResizeEffect)(() => {
|
|
80
80
|
start();
|
|
81
81
|
}, containerRef);
|
|
82
82
|
(0, _useMutationEffect.useMutationEffect)(() => {
|
|
@@ -3,16 +3,21 @@ import './popover.less';
|
|
|
3
3
|
import './popover-menu.less';
|
|
4
4
|
export type { PopoverProps, PopoverRef } from './popover';
|
|
5
5
|
export type { PopoverMenuProps, Action } from './popover-menu';
|
|
6
|
+
export declare type Placement = 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
7
|
+
export declare type DeprecatedPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom';
|
|
6
8
|
declare const _default: import("react").ForwardRefExoticComponent<{
|
|
9
|
+
defaultVisible?: boolean | undefined;
|
|
10
|
+
visible?: boolean | undefined;
|
|
11
|
+
onVisibleChange?: ((visible: boolean) => void) | undefined;
|
|
7
12
|
getContainer?: import("../../utils/render-to-container").GetContainer | undefined;
|
|
8
13
|
destroyOnHide?: boolean | undefined;
|
|
9
14
|
children: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
10
15
|
mode?: "dark" | "light" | undefined;
|
|
11
16
|
trigger?: "click" | undefined;
|
|
12
|
-
placement?:
|
|
17
|
+
placement?: DeprecatedPlacement | Placement | undefined;
|
|
13
18
|
stopPropagation?: "click"[] | undefined;
|
|
14
19
|
content: import("react").ReactNode;
|
|
15
|
-
} &
|
|
20
|
+
} & import("../../utils/native-props").NativeProps<"--z-index"> & import("react").RefAttributes<import("./popover").PopoverRef>> & {
|
|
16
21
|
Menu: import("react").ForwardRefExoticComponent<Omit<import("./popover").PopoverProps, "content"> & {
|
|
17
22
|
actions: import("./popover-menu").Action[];
|
|
18
23
|
onAction?: ((item: import("./popover-menu").Action) => void) | undefined;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.normalizePlacement = normalizePlacement;
|
|
7
|
+
const record = {
|
|
8
|
+
'topLeft': 'top-start',
|
|
9
|
+
'topRight': 'top-end',
|
|
10
|
+
'bottomLeft': 'bottom-start',
|
|
11
|
+
'bottomRight': 'bottom-end',
|
|
12
|
+
'leftTop': 'left-start',
|
|
13
|
+
'leftBottom': 'left-end',
|
|
14
|
+
'rightTop': 'right-start',
|
|
15
|
+
'rightBottom': 'right-end'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
function normalizePlacement(placement) {
|
|
19
|
+
var _a;
|
|
20
|
+
|
|
21
|
+
return (_a = record[placement]) !== null && _a !== void 0 ? _a : placement;
|
|
22
|
+
}
|