antd-mobile 5.2.2 → 5.4.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/cjs/components/avatar/avatar.js +1 -0
- package/2x/cjs/components/calendar/calendar.js +23 -20
- package/2x/cjs/components/date-picker/date-picker.js +3 -7
- package/2x/cjs/components/ellipsis/ellipsis.d.ts +2 -0
- package/2x/cjs/components/ellipsis/ellipsis.js +8 -5
- package/2x/cjs/components/floating-bubble/floating-bubble.d.ts +2 -0
- package/2x/cjs/components/floating-bubble/floating-bubble.js +47 -16
- package/2x/cjs/components/form/context.d.ts +2 -1
- package/2x/cjs/components/form/context.js +6 -5
- package/2x/cjs/components/form/form-item.css +27 -1
- package/2x/cjs/components/form/form-item.d.ts +1 -0
- package/2x/cjs/components/form/form-item.js +44 -13
- package/2x/cjs/components/form/form.js +19 -10
- package/2x/cjs/components/form/index.css +27 -1
- package/2x/cjs/components/infinite-scroll/infinite-scroll.js +23 -19
- package/2x/cjs/components/input/input.js +2 -2
- package/2x/cjs/components/modal/modal.js +0 -1
- package/2x/cjs/components/notice-bar/notice-bar.js +1 -1
- package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
- 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/locales/base.d.ts +51 -0
- package/2x/cjs/locales/base.js +52 -0
- package/2x/cjs/locales/en-US.d.ts +51 -0
- package/2x/cjs/locales/zh-CN.d.ts +51 -0
- package/2x/cjs/locales/zh-CN.js +52 -0
- package/2x/es/components/avatar/avatar.js +1 -0
- package/2x/es/components/calendar/calendar.js +23 -19
- package/2x/es/components/date-picker/date-picker.js +3 -7
- package/2x/es/components/ellipsis/ellipsis.d.ts +2 -0
- package/2x/es/components/ellipsis/ellipsis.js +7 -5
- package/2x/es/components/floating-bubble/floating-bubble.d.ts +2 -0
- package/2x/es/components/floating-bubble/floating-bubble.js +48 -17
- package/2x/es/components/form/context.d.ts +2 -1
- package/2x/es/components/form/context.js +4 -3
- package/2x/es/components/form/form-item.css +27 -1
- package/2x/es/components/form/form-item.d.ts +1 -0
- package/2x/es/components/form/form-item.js +43 -13
- package/2x/es/components/form/form.js +19 -12
- package/2x/es/components/form/index.css +27 -1
- package/2x/es/components/infinite-scroll/infinite-scroll.js +22 -19
- package/2x/es/components/input/input.js +2 -2
- package/2x/es/components/modal/modal.js +0 -1
- package/2x/es/components/notice-bar/notice-bar.js +1 -1
- package/2x/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
- 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/locales/base.d.ts +51 -0
- package/2x/es/locales/base.js +52 -0
- package/2x/es/locales/en-US.d.ts +51 -0
- package/2x/es/locales/zh-CN.d.ts +51 -0
- package/2x/es/locales/zh-CN.js +52 -0
- package/2x/package.json +4 -4
- package/cjs/components/avatar/avatar.js +1 -0
- package/cjs/components/calendar/calendar.js +23 -20
- package/cjs/components/date-picker/date-picker.js +3 -7
- package/cjs/components/ellipsis/ellipsis.d.ts +2 -0
- package/cjs/components/ellipsis/ellipsis.js +8 -5
- package/cjs/components/floating-bubble/floating-bubble.d.ts +2 -0
- package/cjs/components/floating-bubble/floating-bubble.js +47 -16
- package/cjs/components/form/context.d.ts +2 -1
- package/cjs/components/form/context.js +6 -5
- package/cjs/components/form/form-item.css +21 -1
- package/cjs/components/form/form-item.d.ts +1 -0
- package/cjs/components/form/form-item.js +44 -13
- package/cjs/components/form/form.js +19 -10
- package/cjs/components/form/index.css +21 -1
- package/cjs/components/infinite-scroll/infinite-scroll.js +23 -19
- package/cjs/components/input/input.js +2 -2
- package/cjs/components/modal/modal.js +0 -1
- package/cjs/components/notice-bar/notice-bar.js +1 -1
- package/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
- 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/locales/base.d.ts +51 -0
- package/cjs/locales/base.js +52 -0
- package/cjs/locales/en-US.d.ts +51 -0
- package/cjs/locales/zh-CN.d.ts +51 -0
- package/cjs/locales/zh-CN.js +52 -0
- package/es/components/avatar/avatar.js +1 -0
- package/es/components/calendar/calendar.js +23 -19
- package/es/components/date-picker/date-picker.js +3 -7
- package/es/components/ellipsis/ellipsis.d.ts +2 -0
- package/es/components/ellipsis/ellipsis.js +7 -5
- package/es/components/floating-bubble/floating-bubble.d.ts +2 -0
- package/es/components/floating-bubble/floating-bubble.js +48 -17
- package/es/components/form/context.d.ts +2 -1
- package/es/components/form/context.js +4 -3
- package/es/components/form/form-item.css +21 -1
- package/es/components/form/form-item.d.ts +1 -0
- package/es/components/form/form-item.js +43 -13
- package/es/components/form/form.js +19 -12
- package/es/components/form/index.css +21 -1
- package/es/components/infinite-scroll/infinite-scroll.js +22 -19
- package/es/components/input/input.js +2 -2
- package/es/components/modal/modal.js +0 -1
- package/es/components/notice-bar/notice-bar.js +1 -1
- package/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
- 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/locales/base.d.ts +51 -0
- package/es/locales/base.js +52 -0
- package/es/locales/en-US.d.ts +51 -0
- package/es/locales/zh-CN.d.ts +51 -0
- package/es/locales/zh-CN.js +52 -0
- package/package.json +4 -4
- package/umd/antd-mobile.js +1 -1
- package/umd/antd-mobile.js.LICENSE.txt +0 -24
|
@@ -50,7 +50,29 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
|
50
50
|
if (item) markItems.unshift(item);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const
|
|
53
|
+
const dateRange = (0, _react.useMemo)(() => {
|
|
54
|
+
var _a, _b, _c, _d;
|
|
55
|
+
|
|
56
|
+
if (props.selectionMode === 'single') {
|
|
57
|
+
const value = (_b = (_a = props.value) !== null && _a !== void 0 ? _a : props.defaultValue) !== null && _b !== void 0 ? _b : null;
|
|
58
|
+
return [value, value];
|
|
59
|
+
} else if (props.selectionMode === 'range') {
|
|
60
|
+
return (_d = (_c = props.value) !== null && _c !== void 0 ? _c : props.defaultValue) !== null && _d !== void 0 ? _d : [null, null];
|
|
61
|
+
} else {
|
|
62
|
+
return [null, null];
|
|
63
|
+
}
|
|
64
|
+
}, [props.selectionMode, props.value, props.defaultValue]);
|
|
65
|
+
const [begin, setBegin] = (0, _react.useState)(null);
|
|
66
|
+
const [end, setEnd] = (0, _react.useState)(null);
|
|
67
|
+
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
68
|
+
setBegin(dateRange[0] ? (0, _dayjs.default)(dateRange[0]) : null);
|
|
69
|
+
setEnd(dateRange[1] ? (0, _dayjs.default)(dateRange[1]) : null);
|
|
70
|
+
}, [dateRange[0], dateRange[1]]);
|
|
71
|
+
const [current, setCurrent] = (0, _react.useState)(() => {
|
|
72
|
+
var _a;
|
|
73
|
+
|
|
74
|
+
return (0, _dayjs.default)((_a = dateRange[0]) !== null && _a !== void 0 ? _a : today).date(1);
|
|
75
|
+
});
|
|
54
76
|
(0, _ahooks.useUpdateEffect)(() => {
|
|
55
77
|
var _a;
|
|
56
78
|
|
|
@@ -102,25 +124,6 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
|
|
|
102
124
|
}
|
|
103
125
|
}, _react.default.createElement(_arrowLeftDouble.ArrowLeftDouble, null)));
|
|
104
126
|
|
|
105
|
-
const dateRange = (0, _react.useMemo)(() => {
|
|
106
|
-
var _a, _b, _c, _d;
|
|
107
|
-
|
|
108
|
-
if (props.selectionMode === 'single') {
|
|
109
|
-
const value = (_b = (_a = props.value) !== null && _a !== void 0 ? _a : props.defaultValue) !== null && _b !== void 0 ? _b : null;
|
|
110
|
-
return [value, value];
|
|
111
|
-
} else if (props.selectionMode === 'range') {
|
|
112
|
-
return (_d = (_c = props.value) !== null && _c !== void 0 ? _c : props.defaultValue) !== null && _d !== void 0 ? _d : [null, null];
|
|
113
|
-
} else {
|
|
114
|
-
return [null, null];
|
|
115
|
-
}
|
|
116
|
-
}, [props.selectionMode, props.value, props.defaultValue]);
|
|
117
|
-
const [begin, setBegin] = (0, _react.useState)(null);
|
|
118
|
-
const [end, setEnd] = (0, _react.useState)(null);
|
|
119
|
-
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
120
|
-
setBegin(dateRange[0] ? (0, _dayjs.default)(dateRange[0]) : null);
|
|
121
|
-
setEnd(dateRange[1] ? (0, _dayjs.default)(dateRange[1]) : null);
|
|
122
|
-
}, [dateRange[0], dateRange[1]]);
|
|
123
|
-
|
|
124
127
|
function renderCells() {
|
|
125
128
|
var _a;
|
|
126
129
|
|
|
@@ -50,14 +50,10 @@ const DatePicker = p => {
|
|
|
50
50
|
});
|
|
51
51
|
const now = (0, _react.useMemo)(() => new Date(), []);
|
|
52
52
|
const pickerValue = (0, _react.useMemo)(() => {
|
|
53
|
-
let date = value;
|
|
54
|
-
|
|
55
|
-
if (date === null) {
|
|
56
|
-
date = new Date((0, _bound.bound)(now.getTime(), props.min.getTime(), props.max.getTime()));
|
|
57
|
-
}
|
|
58
|
-
|
|
53
|
+
let date = value !== null && value !== void 0 ? value : now;
|
|
54
|
+
date = new Date((0, _bound.bound)(date.getTime(), props.min.getTime(), props.max.getTime()));
|
|
59
55
|
return (0, _datePickerUtils.convertDateToStringArray)(date, props.precision);
|
|
60
|
-
}, [value, props.precision]);
|
|
56
|
+
}, [value, props.precision, props.min, props.max]);
|
|
61
57
|
const onConfirm = (0, _react.useCallback)(val => {
|
|
62
58
|
setValue((0, _datePickerUtils.convertStringArrayToDate)(val, props.precision));
|
|
63
59
|
}, [setValue, props.precision]);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
|
+
import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
3
4
|
export declare type EllipsisProps = {
|
|
4
5
|
content: string;
|
|
5
6
|
direction?: 'start' | 'end' | 'middle';
|
|
6
7
|
rows?: number;
|
|
7
8
|
expandText?: string;
|
|
8
9
|
collapseText?: string;
|
|
10
|
+
stopPropagationForActionButtons?: PropagationEvent[];
|
|
9
11
|
} & NativeProps;
|
|
10
12
|
export declare const Ellipsis: FC<EllipsisProps>;
|
|
@@ -15,6 +15,8 @@ var _useResizeEffect = require("../../utils/use-resize-effect");
|
|
|
15
15
|
|
|
16
16
|
var _ahooks = require("ahooks");
|
|
17
17
|
|
|
18
|
+
var _withStopPropagation = require("../../utils/with-stop-propagation");
|
|
19
|
+
|
|
18
20
|
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); }
|
|
19
21
|
|
|
20
22
|
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; }
|
|
@@ -24,7 +26,8 @@ const defaultProps = {
|
|
|
24
26
|
direction: 'end',
|
|
25
27
|
rows: 1,
|
|
26
28
|
expandText: '',
|
|
27
|
-
collapseText: ''
|
|
29
|
+
collapseText: '',
|
|
30
|
+
stopPropagationForActionButtons: []
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
const Ellipsis = p => {
|
|
@@ -134,16 +137,16 @@ const Ellipsis = p => {
|
|
|
134
137
|
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
135
138
|
calcEllipsised();
|
|
136
139
|
}, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
|
|
137
|
-
const expandActionElement = exceeded && props.expandText ? _react.default.createElement("a", {
|
|
140
|
+
const expandActionElement = exceeded && props.expandText ? (0, _withStopPropagation.withStopPropagation)(props.stopPropagationForActionButtons, _react.default.createElement("a", {
|
|
138
141
|
onClick: () => {
|
|
139
142
|
setExpanded(true);
|
|
140
143
|
}
|
|
141
|
-
}, props.expandText) : null;
|
|
142
|
-
const collapseActionElement = exceeded && props.expandText ? _react.default.createElement("a", {
|
|
144
|
+
}, props.expandText)) : null;
|
|
145
|
+
const collapseActionElement = exceeded && props.expandText ? (0, _withStopPropagation.withStopPropagation)(props.stopPropagationForActionButtons, _react.default.createElement("a", {
|
|
143
146
|
onClick: () => {
|
|
144
147
|
setExpanded(false);
|
|
145
148
|
}
|
|
146
|
-
}, props.collapseText) : null;
|
|
149
|
+
}, props.collapseText)) : null;
|
|
147
150
|
|
|
148
151
|
const renderContent = () => {
|
|
149
152
|
if (!exceeded) {
|
|
@@ -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,72 @@ 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) {
|
|
51
|
+
const boundary = boundaryRef.current;
|
|
52
|
+
const button = buttonRef.current;
|
|
53
|
+
if (!boundary || !button) return;
|
|
54
|
+
|
|
55
|
+
if (props.magnetic === 'x') {
|
|
56
|
+
const compensation = x.goal - x.get();
|
|
57
|
+
const boundaryRect = boundary.getBoundingClientRect();
|
|
58
|
+
const buttonRect = button.getBoundingClientRect();
|
|
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
|
+
}
|
|
68
|
+
}
|
|
47
69
|
|
|
48
|
-
|
|
49
|
-
|
|
70
|
+
api.start({
|
|
71
|
+
x: nextX,
|
|
72
|
+
y: nextY // immediate: !state.last,
|
|
73
|
+
|
|
74
|
+
}); // active status
|
|
75
|
+
|
|
76
|
+
api.start({
|
|
50
77
|
opacity: state.active ? 0.8 : 1
|
|
51
78
|
});
|
|
52
79
|
}, {
|
|
53
|
-
|
|
54
|
-
axis: 'y',
|
|
80
|
+
axis: props.axis === 'xy' ? undefined : props.axis,
|
|
55
81
|
pointer: {
|
|
56
82
|
touch: true
|
|
57
83
|
},
|
|
58
84
|
// the component won't trigger drag logic if the user just clicked on the component.
|
|
59
85
|
filterTaps: true,
|
|
60
86
|
// set constraints to the user gesture
|
|
61
|
-
bounds: boundaryRef
|
|
87
|
+
bounds: boundaryRef,
|
|
88
|
+
from: () => [x.get(), y.get()]
|
|
62
89
|
});
|
|
63
90
|
return (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
|
|
64
91
|
className: classPrefix
|
|
@@ -68,9 +95,13 @@ const FloatingBubble = p => {
|
|
|
68
95
|
className: `${classPrefix}-boundary`,
|
|
69
96
|
ref: boundaryRef
|
|
70
97
|
})), _react.default.createElement(_web.animated.div, Object.assign({}, bind(), {
|
|
71
|
-
style:
|
|
98
|
+
style: {
|
|
99
|
+
opacity,
|
|
100
|
+
transform: (0, _web.to)([x, y], (x, y) => `translate(${x}px, ${y}px)`)
|
|
101
|
+
},
|
|
72
102
|
onClick: props.onClick,
|
|
73
|
-
className: `${classPrefix}-button
|
|
103
|
+
className: `${classPrefix}-button`,
|
|
104
|
+
ref: buttonRef
|
|
74
105
|
}), props.children)));
|
|
75
106
|
};
|
|
76
107
|
|
|
@@ -4,8 +4,9 @@ import type { Meta, InternalNamePath } from 'rc-field-form/lib/interface';
|
|
|
4
4
|
export declare type FormContextType = {
|
|
5
5
|
hasFeedback: boolean;
|
|
6
6
|
layout: FormLayout;
|
|
7
|
+
requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional';
|
|
7
8
|
};
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const defaultFormContext: FormContextType;
|
|
9
10
|
export declare const FormContext: React.Context<FormContextType>;
|
|
10
11
|
export declare type OnSubMetaChange = (meta: Meta & {
|
|
11
12
|
destroy?: boolean;
|
|
@@ -3,19 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.defaultFormContext = exports.NoStyleItemContext = exports.FormContext = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const defaultFormContext = {
|
|
13
13
|
hasFeedback: true,
|
|
14
|
-
layout: 'vertical'
|
|
14
|
+
layout: 'vertical',
|
|
15
|
+
requiredMarkStyle: 'asterisk'
|
|
15
16
|
};
|
|
16
|
-
exports.
|
|
17
|
+
exports.defaultFormContext = defaultFormContext;
|
|
17
18
|
|
|
18
|
-
const FormContext = _react.default.createContext(
|
|
19
|
+
const FormContext = _react.default.createContext(defaultFormContext);
|
|
19
20
|
|
|
20
21
|
exports.FormContext = FormContext;
|
|
21
22
|
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
color: #666666;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
.adm-form-item-label-required {
|
|
14
|
+
.adm-form-item-label .adm-form-item-required-asterisk {
|
|
15
15
|
position: absolute;
|
|
16
16
|
left: -0.6em;
|
|
17
17
|
top: 0;
|
|
@@ -20,8 +20,34 @@
|
|
|
20
20
|
user-select: none;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
.adm-form-item-label .adm-form-item-required-text {
|
|
24
|
+
margin-left: 8px;
|
|
25
|
+
color: var(--adm-color-weak);
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
.adm-form-item-label-help {
|
|
24
29
|
margin-left: 8px;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.adm-form-item-child {
|
|
34
|
+
display: flex;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.adm-form-item-child-position-normal {
|
|
38
|
+
justify-content: normal;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.adm-form-item-child-position-normal > * {
|
|
42
|
+
flex: auto;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.adm-form-item-child-position-right {
|
|
46
|
+
justify-content: right;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.adm-form-item-child-position-right > * {
|
|
50
|
+
flex: none;
|
|
25
51
|
}
|
|
26
52
|
|
|
27
53
|
.adm-form-item-footer {
|
|
@@ -16,6 +16,7 @@ export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePr
|
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
hidden?: boolean;
|
|
18
18
|
layout?: FormLayout;
|
|
19
|
+
childElementPosition?: 'normal' | 'right';
|
|
19
20
|
children: ChildrenType;
|
|
20
21
|
} & NativeProps;
|
|
21
22
|
export declare const FormItem: FC<FormItemProps>;
|
|
@@ -27,6 +27,8 @@ var _popover = _interopRequireDefault(require("../popover"));
|
|
|
27
27
|
|
|
28
28
|
var _antdMobileIcons = require("antd-mobile-icons");
|
|
29
29
|
|
|
30
|
+
var _configProvider = require("../config-provider");
|
|
31
|
+
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
|
|
32
34
|
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); }
|
|
@@ -54,18 +56,47 @@ const FormItemLayout = props => {
|
|
|
54
56
|
hidden,
|
|
55
57
|
errors,
|
|
56
58
|
arrow,
|
|
57
|
-
description
|
|
59
|
+
description,
|
|
60
|
+
childElementPosition = 'normal'
|
|
58
61
|
} = props;
|
|
59
62
|
const context = (0, _react.useContext)(_context.FormContext);
|
|
63
|
+
const {
|
|
64
|
+
locale
|
|
65
|
+
} = (0, _configProvider.useConfig)();
|
|
60
66
|
const hasFeedback = props.hasFeedback !== undefined ? props.hasFeedback : context.hasFeedback;
|
|
61
67
|
const layout = props.layout || context.layout;
|
|
62
68
|
const feedback = hasFeedback && errors && errors.length > 0 ? errors[0] : null;
|
|
69
|
+
|
|
70
|
+
const requiredMark = (() => {
|
|
71
|
+
const {
|
|
72
|
+
requiredMarkStyle
|
|
73
|
+
} = context;
|
|
74
|
+
|
|
75
|
+
switch (requiredMarkStyle) {
|
|
76
|
+
case 'asterisk':
|
|
77
|
+
return required && _react.default.createElement("span", {
|
|
78
|
+
className: `${classPrefix}-required-asterisk`
|
|
79
|
+
}, "*");
|
|
80
|
+
|
|
81
|
+
case 'text-required':
|
|
82
|
+
return required && _react.default.createElement("span", {
|
|
83
|
+
className: `${classPrefix}-required-text`
|
|
84
|
+
}, "(", locale.Form.required, ")");
|
|
85
|
+
|
|
86
|
+
case 'text-optional':
|
|
87
|
+
return !required && _react.default.createElement("span", {
|
|
88
|
+
className: `${classPrefix}-required-text`
|
|
89
|
+
}, "(", locale.Form.optional, ")");
|
|
90
|
+
|
|
91
|
+
default:
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
})();
|
|
95
|
+
|
|
63
96
|
const labelElement = label ? _react.default.createElement("label", {
|
|
64
97
|
className: `${classPrefix}-label`,
|
|
65
98
|
htmlFor: htmlFor
|
|
66
|
-
}, label,
|
|
67
|
-
className: `${classPrefix}-label-required`
|
|
68
|
-
}, "*"), help && _react.default.createElement("span", {
|
|
99
|
+
}, label, requiredMark, help && _react.default.createElement("span", {
|
|
69
100
|
className: `${classPrefix}-label-help`
|
|
70
101
|
}, _react.default.createElement(_popover.default, {
|
|
71
102
|
content: help,
|
|
@@ -87,7 +118,11 @@ const FormItemLayout = props => {
|
|
|
87
118
|
disabled: disabled,
|
|
88
119
|
onClick: props.onClick,
|
|
89
120
|
arrow: arrow
|
|
90
|
-
},
|
|
121
|
+
}, _react.default.createElement("div", {
|
|
122
|
+
className: (0, _classnames.default)(`${classPrefix}-child`, `${classPrefix}-child-position-${childElementPosition}`)
|
|
123
|
+
}, _react.default.createElement("div", {
|
|
124
|
+
className: (0, _classnames.default)(`${classPrefix}-child-inner`)
|
|
125
|
+
}, children)));
|
|
91
126
|
};
|
|
92
127
|
|
|
93
128
|
const FormItem = props => {
|
|
@@ -105,6 +140,7 @@ const FormItem = props => {
|
|
|
105
140
|
noStyle,
|
|
106
141
|
hidden,
|
|
107
142
|
layout,
|
|
143
|
+
childElementPosition,
|
|
108
144
|
description,
|
|
109
145
|
// Field 相关
|
|
110
146
|
disabled,
|
|
@@ -118,7 +154,7 @@ const FormItem = props => {
|
|
|
118
154
|
dependencies,
|
|
119
155
|
arrow
|
|
120
156
|
} = props,
|
|
121
|
-
fieldProps = (0, _tslib.__rest)(props, ["className", "style", "label", "help", "extra", "hasFeedback", "name", "required", "noStyle", "hidden", "layout", "description", "disabled", "rules", "children", "messageVariables", "trigger", "validateTrigger", "onClick", "shouldUpdate", "dependencies", "arrow"]);
|
|
157
|
+
fieldProps = (0, _tslib.__rest)(props, ["className", "style", "label", "help", "extra", "hasFeedback", "name", "required", "noStyle", "hidden", "layout", "childElementPosition", "description", "disabled", "rules", "children", "messageVariables", "trigger", "validateTrigger", "onClick", "shouldUpdate", "dependencies", "arrow"]);
|
|
122
158
|
|
|
123
159
|
const {
|
|
124
160
|
validateTrigger: contextValidateTrigger
|
|
@@ -179,6 +215,7 @@ const FormItem = props => {
|
|
|
179
215
|
onClick: onClick,
|
|
180
216
|
hidden: hidden,
|
|
181
217
|
layout: layout,
|
|
218
|
+
childElementPosition: childElementPosition,
|
|
182
219
|
arrow: arrow
|
|
183
220
|
}, _react.default.createElement(_context.NoStyleItemContext.Provider, {
|
|
184
221
|
value: onSubMetaChange
|
|
@@ -221,13 +258,7 @@ const FormItem = props => {
|
|
|
221
258
|
messageVariables: Variables
|
|
222
259
|
}), (control, meta, context) => {
|
|
223
260
|
let childNode = null;
|
|
224
|
-
const isRequired = required !== undefined ? required :
|
|
225
|
-
if (rule && typeof rule === 'object' && rule.required) {
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return false;
|
|
230
|
-
}));
|
|
261
|
+
const isRequired = required !== undefined ? required : rules && rules.some(rule => !!(rule && typeof rule === 'object' && rule.required));
|
|
231
262
|
const fieldId = ((0, _utils.toArray)(name).length && meta ? meta.name : []).join('_');
|
|
232
263
|
|
|
233
264
|
if (shouldUpdate && dependencies) {
|
|
@@ -21,6 +21,10 @@ var _withDefaultProps = require("../../utils/with-default-props");
|
|
|
21
21
|
|
|
22
22
|
var _header = require("./header");
|
|
23
23
|
|
|
24
|
+
var _configProvider = require("../config-provider");
|
|
25
|
+
|
|
26
|
+
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
27
|
+
|
|
24
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
29
|
|
|
26
30
|
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); }
|
|
@@ -28,10 +32,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
28
32
|
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; }
|
|
29
33
|
|
|
30
34
|
const classPrefix = 'adm-form';
|
|
31
|
-
const defaultProps =
|
|
32
|
-
hasFeedback: true,
|
|
33
|
-
layout: 'vertical'
|
|
34
|
-
};
|
|
35
|
+
const defaultProps = _context.defaultFormContext;
|
|
35
36
|
const Form = (0, _react.forwardRef)((p, ref) => {
|
|
36
37
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
37
38
|
const {
|
|
@@ -41,9 +42,14 @@ const Form = (0, _react.forwardRef)((p, ref) => {
|
|
|
41
42
|
children,
|
|
42
43
|
layout,
|
|
43
44
|
footer,
|
|
44
|
-
mode
|
|
45
|
+
mode,
|
|
46
|
+
requiredMarkStyle
|
|
45
47
|
} = props,
|
|
46
|
-
formProps = (0, _tslib.__rest)(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode"]);
|
|
48
|
+
formProps = (0, _tslib.__rest)(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "requiredMarkStyle"]);
|
|
49
|
+
const {
|
|
50
|
+
locale
|
|
51
|
+
} = (0, _configProvider.useConfig)();
|
|
52
|
+
const validateMessages = (0, _react.useMemo)(() => (0, _merge.default)({}, locale.Form.defaultValidateMessages, formProps.validateMessages), [locale.Form.defaultValidateMessages, formProps.validateMessages]);
|
|
47
53
|
const lists = [];
|
|
48
54
|
let currentHeader = null;
|
|
49
55
|
let items = [];
|
|
@@ -60,7 +66,7 @@ const Form = (0, _react.forwardRef)((p, ref) => {
|
|
|
60
66
|
items = [];
|
|
61
67
|
}
|
|
62
68
|
|
|
63
|
-
_react.default.Children.forEach(props.children,
|
|
69
|
+
_react.default.Children.forEach(props.children, child => {
|
|
64
70
|
if (_react.default.isValidElement(child) && child.type === _header.Header) {
|
|
65
71
|
collect();
|
|
66
72
|
currentHeader = child.props.children;
|
|
@@ -74,10 +80,13 @@ const Form = (0, _react.forwardRef)((p, ref) => {
|
|
|
74
80
|
className: (0, _classnames.default)(classPrefix, className),
|
|
75
81
|
style: style,
|
|
76
82
|
ref: ref
|
|
77
|
-
}, formProps
|
|
83
|
+
}, formProps, {
|
|
84
|
+
validateMessages: validateMessages
|
|
85
|
+
}), _react.default.createElement(_context.FormContext.Provider, {
|
|
78
86
|
value: {
|
|
79
|
-
hasFeedback
|
|
80
|
-
layout
|
|
87
|
+
hasFeedback,
|
|
88
|
+
layout,
|
|
89
|
+
requiredMarkStyle
|
|
81
90
|
}
|
|
82
91
|
}, lists), footer && _react.default.createElement("div", {
|
|
83
92
|
className: `${classPrefix}-footer`
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
color: #666666;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
.adm-form-item-label-required {
|
|
35
|
+
.adm-form-item-label .adm-form-item-required-asterisk {
|
|
36
36
|
position: absolute;
|
|
37
37
|
left: -0.6em;
|
|
38
38
|
top: 0;
|
|
@@ -41,8 +41,34 @@
|
|
|
41
41
|
user-select: none;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
.adm-form-item-label .adm-form-item-required-text {
|
|
45
|
+
margin-left: 8px;
|
|
46
|
+
color: var(--adm-color-weak);
|
|
47
|
+
}
|
|
48
|
+
|
|
44
49
|
.adm-form-item-label-help {
|
|
45
50
|
margin-left: 8px;
|
|
51
|
+
cursor: pointer;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.adm-form-item-child {
|
|
55
|
+
display: flex;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.adm-form-item-child-position-normal {
|
|
59
|
+
justify-content: normal;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.adm-form-item-child-position-normal > * {
|
|
63
|
+
flex: auto;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.adm-form-item-child-position-right {
|
|
67
|
+
justify-content: right;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.adm-form-item-child-position-right > * {
|
|
71
|
+
flex: none;
|
|
46
72
|
}
|
|
47
73
|
|
|
48
74
|
.adm-form-item-footer {
|
|
@@ -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();
|
|
@@ -78,7 +78,7 @@ const Input = (0, _react.forwardRef)((p, ref) => {
|
|
|
78
78
|
let nextValue = value;
|
|
79
79
|
|
|
80
80
|
if (props.type === 'number') {
|
|
81
|
-
nextValue = (0, _bound.bound)(parseFloat(nextValue), props.min, props.max).toString();
|
|
81
|
+
nextValue = nextValue && (0, _bound.bound)(parseFloat(nextValue), props.min, props.max).toString();
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (nextValue !== value) {
|
|
@@ -126,7 +126,7 @@ const Input = (0, _react.forwardRef)((p, ref) => {
|
|
|
126
126
|
onKeyUp: props.onKeyUp,
|
|
127
127
|
onCompositionStart: props.onCompositionStart,
|
|
128
128
|
onCompositionEnd: props.onCompositionEnd
|
|
129
|
-
}), props.clearable && !!value && !props.readOnly && _react.default.createElement("div", {
|
|
129
|
+
}), props.clearable && !!value && !props.readOnly && hasFocus && _react.default.createElement("div", {
|
|
130
130
|
className: `${classPrefix}-clear`,
|
|
131
131
|
onMouseDown: e => {
|
|
132
132
|
e.preventDefault();
|
|
@@ -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)(() => {
|