antd-mobile 5.22.0 → 5.24.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/bundle/antd-mobile.cjs.development.js +953 -709
- package/2x/bundle/antd-mobile.cjs.js +8 -8
- package/2x/bundle/antd-mobile.compatible.umd.js +6991 -6789
- package/2x/bundle/antd-mobile.es.development.js +953 -709
- package/2x/bundle/antd-mobile.es.js +5666 -5497
- package/2x/bundle/antd-mobile.umd.development.js +953 -709
- package/2x/bundle/antd-mobile.umd.js +8 -8
- package/2x/bundle/style.css +137 -41
- package/2x/cjs/components/avatar/avatar.js +2 -2
- package/2x/cjs/components/calendar/calendar.d.ts +3 -5
- package/2x/cjs/components/calendar/calendar.js +27 -5
- package/2x/cjs/components/calendar/convert.d.ts +6 -0
- package/2x/cjs/components/calendar/convert.js +9 -0
- package/2x/cjs/components/dialog/dialog-action-button.d.ts +2 -2
- package/2x/cjs/components/ellipsis/ellipsis.js +16 -7
- package/2x/cjs/components/empty/empty.d.ts +1 -0
- package/2x/cjs/components/empty/empty.js +1 -0
- package/2x/cjs/components/footer/footer.css +60 -0
- package/2x/cjs/components/footer/footer.d.ts +19 -0
- package/2x/cjs/components/footer/footer.js +83 -0
- package/2x/cjs/components/footer/index.d.ts +4 -0
- package/2x/cjs/components/footer/index.js +13 -0
- package/2x/cjs/components/form/form-item.css +0 -1
- package/2x/cjs/components/form/form.css +9 -3
- package/2x/cjs/components/form/form.d.ts +2 -2
- package/2x/cjs/components/form/index.css +9 -4
- package/2x/cjs/components/form/index.d.ts +1 -1
- package/2x/cjs/components/image-uploader/image-uploader.d.ts +11 -1
- package/2x/cjs/components/image-uploader/image-uploader.js +42 -25
- package/2x/cjs/components/image-uploader/index.d.ts +1 -1
- package/2x/cjs/components/image-uploader/preview-item.js +5 -0
- package/2x/cjs/components/image-viewer/slides.js +2 -2
- package/2x/cjs/components/page-indicator/page-indicator.css +1 -0
- package/2x/cjs/components/picker/index.d.ts +2 -2
- package/2x/cjs/components/picker/picker.d.ts +1 -1
- package/2x/cjs/components/picker-view/picker-view.css +9 -0
- package/2x/cjs/components/picker-view/wheel.js +8 -4
- package/2x/cjs/components/popover/popover.js +2 -2
- package/2x/cjs/components/rate/rate.css +6 -1
- package/2x/cjs/components/rate/rate.js +3 -1
- package/2x/cjs/components/slider/slider.css +15 -1
- package/2x/cjs/components/slider/slider.d.ts +1 -0
- package/2x/cjs/components/slider/slider.js +13 -2
- package/2x/cjs/components/slider/thumb.d.ts +1 -0
- package/2x/cjs/components/slider/thumb.js +4 -3
- package/2x/cjs/components/stepper/stepper.js +2 -1
- package/2x/cjs/components/swiper/swiper.js +9 -0
- package/2x/cjs/components/toast/toast.css +4 -3
- package/2x/cjs/index.d.ts +1 -0
- package/2x/cjs/index.js +8 -0
- package/2x/cjs/locales/zh-CN.js +1 -1
- package/2x/cjs/utils/measure-css-length.js +1 -1
- package/2x/es/components/avatar/avatar.js +1 -1
- package/2x/es/components/calendar/calendar.d.ts +3 -5
- package/2x/es/components/calendar/calendar.js +29 -6
- package/2x/es/components/calendar/convert.d.ts +6 -0
- package/2x/es/components/calendar/convert.js +4 -0
- package/2x/es/components/dialog/dialog-action-button.d.ts +2 -2
- package/2x/es/components/ellipsis/ellipsis.js +14 -8
- package/2x/es/components/empty/empty.d.ts +1 -0
- package/2x/es/components/empty/empty.js +2 -0
- package/2x/es/components/footer/footer.css +60 -0
- package/2x/es/components/footer/footer.d.ts +19 -0
- package/2x/es/components/footer/footer.js +66 -0
- package/2x/es/components/footer/index.d.ts +4 -0
- package/2x/es/components/footer/index.js +3 -0
- package/2x/es/components/form/form-item.css +0 -1
- package/2x/es/components/form/form.css +9 -3
- package/2x/es/components/form/form.d.ts +2 -2
- package/2x/es/components/form/index.css +9 -4
- package/2x/es/components/form/index.d.ts +1 -1
- package/2x/es/components/image-uploader/image-uploader.d.ts +11 -1
- package/2x/es/components/image-uploader/image-uploader.js +41 -25
- package/2x/es/components/image-uploader/index.d.ts +1 -1
- package/2x/es/components/image-uploader/preview-item.js +6 -1
- package/2x/es/components/image-viewer/slides.js +2 -2
- package/2x/es/components/page-indicator/page-indicator.css +1 -0
- package/2x/es/components/picker/index.d.ts +2 -2
- package/2x/es/components/picker/picker.d.ts +1 -1
- package/2x/es/components/picker-view/picker-view.css +9 -0
- package/2x/es/components/picker-view/wheel.js +8 -4
- package/2x/es/components/popover/popover.js +2 -2
- package/2x/es/components/rate/rate.css +6 -1
- package/2x/es/components/rate/rate.js +3 -1
- package/2x/es/components/slider/slider.css +15 -1
- package/2x/es/components/slider/slider.d.ts +1 -0
- package/2x/es/components/slider/slider.js +12 -2
- package/2x/es/components/slider/thumb.d.ts +1 -0
- package/2x/es/components/slider/thumb.js +4 -3
- package/2x/es/components/stepper/stepper.js +2 -1
- package/2x/es/components/swiper/swiper.js +9 -0
- package/2x/es/components/toast/toast.css +4 -3
- package/2x/es/index.d.ts +1 -0
- package/2x/es/index.js +1 -0
- package/2x/es/locales/zh-CN.js +1 -1
- package/2x/es/utils/measure-css-length.js +1 -1
- package/2x/package.json +2 -1
- package/2x/umd/antd-mobile.js +6991 -6789
- package/bundle/antd-mobile.cjs.development.js +953 -709
- package/bundle/antd-mobile.cjs.js +8 -8
- package/bundle/antd-mobile.compatible.umd.js +6991 -6789
- package/bundle/antd-mobile.es.development.js +953 -709
- package/bundle/antd-mobile.es.js +5666 -5497
- package/bundle/antd-mobile.umd.development.js +953 -709
- package/bundle/antd-mobile.umd.js +8 -8
- package/bundle/style.css +1 -1
- package/cjs/components/avatar/avatar.js +2 -2
- package/cjs/components/calendar/calendar.d.ts +3 -5
- package/cjs/components/calendar/calendar.js +27 -5
- package/cjs/components/calendar/convert.d.ts +6 -0
- package/cjs/components/calendar/convert.js +9 -0
- package/cjs/components/dialog/dialog-action-button.d.ts +2 -2
- package/cjs/components/ellipsis/ellipsis.js +16 -7
- package/cjs/components/empty/empty.d.ts +1 -0
- package/cjs/components/empty/empty.js +1 -0
- package/cjs/components/footer/footer.css +51 -0
- package/cjs/components/footer/footer.d.ts +19 -0
- package/cjs/components/footer/footer.js +83 -0
- package/cjs/components/footer/index.d.ts +4 -0
- package/cjs/components/footer/index.js +13 -0
- package/cjs/components/form/form-item.css +0 -1
- package/cjs/components/form/form.css +8 -3
- package/cjs/components/form/form.d.ts +2 -2
- package/cjs/components/form/index.css +8 -4
- package/cjs/components/form/index.d.ts +1 -1
- package/cjs/components/image-uploader/image-uploader.d.ts +11 -1
- package/cjs/components/image-uploader/image-uploader.js +42 -25
- package/cjs/components/image-uploader/index.d.ts +1 -1
- package/cjs/components/image-uploader/preview-item.js +5 -0
- package/cjs/components/image-viewer/slides.js +2 -2
- package/cjs/components/page-indicator/page-indicator.css +1 -0
- package/cjs/components/picker/index.d.ts +2 -2
- package/cjs/components/picker/picker.d.ts +1 -1
- package/cjs/components/picker-view/picker-view.css +8 -0
- package/cjs/components/picker-view/wheel.js +8 -4
- package/cjs/components/popover/popover.js +2 -2
- package/cjs/components/rate/rate.css +5 -1
- package/cjs/components/rate/rate.js +3 -1
- package/cjs/components/slider/slider.css +14 -1
- package/cjs/components/slider/slider.d.ts +1 -0
- package/cjs/components/slider/slider.js +13 -2
- package/cjs/components/slider/thumb.d.ts +1 -0
- package/cjs/components/slider/thumb.js +4 -3
- package/cjs/components/stepper/stepper.js +2 -1
- package/cjs/components/swiper/swiper.js +9 -0
- package/cjs/components/toast/toast.css +4 -3
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +8 -0
- package/cjs/locales/zh-CN.js +1 -1
- package/cjs/utils/measure-css-length.js +1 -1
- package/es/components/avatar/avatar.js +1 -1
- package/es/components/calendar/calendar.d.ts +3 -5
- package/es/components/calendar/calendar.js +29 -6
- package/es/components/calendar/convert.d.ts +6 -0
- package/es/components/calendar/convert.js +4 -0
- package/es/components/dialog/dialog-action-button.d.ts +2 -2
- package/es/components/ellipsis/ellipsis.js +14 -8
- package/es/components/empty/empty.d.ts +1 -0
- package/es/components/empty/empty.js +2 -0
- package/es/components/footer/footer.css +51 -0
- package/es/components/footer/footer.d.ts +19 -0
- package/es/components/footer/footer.js +66 -0
- package/es/components/footer/index.d.ts +4 -0
- package/es/components/footer/index.js +3 -0
- package/es/components/form/form-item.css +0 -1
- package/es/components/form/form.css +8 -3
- package/es/components/form/form.d.ts +2 -2
- package/es/components/form/index.css +8 -4
- package/es/components/form/index.d.ts +1 -1
- package/es/components/image-uploader/image-uploader.d.ts +11 -1
- package/es/components/image-uploader/image-uploader.js +41 -25
- package/es/components/image-uploader/index.d.ts +1 -1
- package/es/components/image-uploader/preview-item.js +6 -1
- package/es/components/image-viewer/slides.js +2 -2
- package/es/components/page-indicator/page-indicator.css +1 -0
- package/es/components/picker/index.d.ts +2 -2
- package/es/components/picker/picker.d.ts +1 -1
- package/es/components/picker-view/picker-view.css +8 -0
- package/es/components/picker-view/wheel.js +8 -4
- package/es/components/popover/popover.js +2 -2
- package/es/components/rate/rate.css +5 -1
- package/es/components/rate/rate.js +3 -1
- package/es/components/slider/slider.css +14 -1
- package/es/components/slider/slider.d.ts +1 -0
- package/es/components/slider/slider.js +12 -2
- package/es/components/slider/thumb.d.ts +1 -0
- package/es/components/slider/thumb.js +4 -3
- package/es/components/stepper/stepper.js +2 -1
- package/es/components/swiper/swiper.js +9 -0
- package/es/components/toast/toast.css +4 -3
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/locales/zh-CN.js +1 -1
- package/es/utils/measure-css-length.js +1 -1
- package/package.json +2 -1
- package/umd/antd-mobile.js +1 -1
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
|
-
|
|
4
|
-
month: number;
|
|
5
|
-
year: number;
|
|
6
|
-
};
|
|
3
|
+
import { Page } from './convert';
|
|
7
4
|
export declare type CalendarRef = {
|
|
8
5
|
jumpTo: (page: Page | ((page: Page) => Page)) => void;
|
|
9
6
|
jumpToToday: () => void;
|
|
@@ -20,6 +17,8 @@ export declare type CalendarProps = {
|
|
|
20
17
|
max?: Date;
|
|
21
18
|
min?: Date;
|
|
22
19
|
shouldDisableDate?: (date: Date) => boolean;
|
|
20
|
+
minPage?: Page;
|
|
21
|
+
maxPage?: Page;
|
|
23
22
|
} & ({
|
|
24
23
|
selectionMode?: undefined;
|
|
25
24
|
value?: undefined;
|
|
@@ -37,4 +36,3 @@ export declare type CalendarProps = {
|
|
|
37
36
|
onChange?: (val: [Date, Date] | null) => void;
|
|
38
37
|
}) & NativeProps;
|
|
39
38
|
export declare const Calendar: React.ForwardRefExoticComponent<CalendarProps & React.RefAttributes<CalendarRef>>;
|
|
40
|
-
export {};
|
|
@@ -9,7 +9,7 @@ import { useConfig } from '../config-provider';
|
|
|
9
9
|
import isoWeek from 'dayjs/plugin/isoWeek';
|
|
10
10
|
import { useUpdateEffect } from 'ahooks';
|
|
11
11
|
import { usePropsValue } from '../../utils/use-props-value';
|
|
12
|
-
import { convertValueToRange } from './convert';
|
|
12
|
+
import { convertValueToRange, convertPageToDayjs } from './convert';
|
|
13
13
|
dayjs.extend(isoWeek);
|
|
14
14
|
const classPrefix = 'adm-calendar';
|
|
15
15
|
const defaultProps = {
|
|
@@ -67,35 +67,58 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
67
67
|
page = pageOrPageGenerator;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
setCurrent(
|
|
70
|
+
setCurrent(convertPageToDayjs(page));
|
|
71
71
|
},
|
|
72
72
|
jumpToToday: () => {
|
|
73
73
|
setCurrent(dayjs().date(1));
|
|
74
74
|
}
|
|
75
75
|
}));
|
|
76
|
+
|
|
77
|
+
const handlePageChange = (action, num, type) => {
|
|
78
|
+
const nxtCurrent = current[action](num, type);
|
|
79
|
+
|
|
80
|
+
if (action === 'subtract' && props.minPage) {
|
|
81
|
+
const minPage = convertPageToDayjs(props.minPage);
|
|
82
|
+
|
|
83
|
+
if (nxtCurrent.isBefore(minPage, type)) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (action === 'add' && props.maxPage) {
|
|
89
|
+
const maxPage = convertPageToDayjs(props.maxPage);
|
|
90
|
+
|
|
91
|
+
if (nxtCurrent.isAfter(maxPage, type)) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
setCurrent(current[action](num, type));
|
|
97
|
+
};
|
|
98
|
+
|
|
76
99
|
const header = React.createElement("div", {
|
|
77
100
|
className: `${classPrefix}-header`
|
|
78
101
|
}, React.createElement("a", {
|
|
79
102
|
className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-year`,
|
|
80
103
|
onClick: () => {
|
|
81
|
-
|
|
104
|
+
handlePageChange('subtract', 1, 'year');
|
|
82
105
|
}
|
|
83
106
|
}, props.prevYearButton), React.createElement("a", {
|
|
84
107
|
className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-month`,
|
|
85
108
|
onClick: () => {
|
|
86
|
-
|
|
109
|
+
handlePageChange('subtract', 1, 'month');
|
|
87
110
|
}
|
|
88
111
|
}, props.prevMonthButton), React.createElement("div", {
|
|
89
112
|
className: `${classPrefix}-title`
|
|
90
113
|
}, locale.Calendar.renderYearAndMonth(current.year(), current.month() + 1)), React.createElement("a", {
|
|
91
114
|
className: classNames(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-month`),
|
|
92
115
|
onClick: () => {
|
|
93
|
-
|
|
116
|
+
handlePageChange('add', 1, 'month');
|
|
94
117
|
}
|
|
95
118
|
}, props.nextMonthButton), React.createElement("a", {
|
|
96
119
|
className: classNames(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-year`),
|
|
97
120
|
onClick: () => {
|
|
98
|
-
|
|
121
|
+
handlePageChange('add', 1, 'year');
|
|
99
122
|
}
|
|
100
123
|
}, props.nextYearButton));
|
|
101
124
|
const maxDay = useMemo(() => props.max && dayjs(props.max), [props.max]);
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
1
2
|
export declare type DateRange = [Date, Date] | null;
|
|
3
|
+
export declare type Page = {
|
|
4
|
+
month: number;
|
|
5
|
+
year: number;
|
|
6
|
+
};
|
|
2
7
|
export declare function convertValueToRange(selectionMode: 'single' | 'range' | undefined, value: Date | [Date, Date] | null): DateRange;
|
|
8
|
+
export declare function convertPageToDayjs(page: Page): dayjs.Dayjs;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
1
2
|
export function convertValueToRange(selectionMode, value) {
|
|
2
3
|
if (selectionMode === undefined) {
|
|
3
4
|
return null;
|
|
@@ -12,4 +13,7 @@ export function convertValueToRange(selectionMode, value) {
|
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
return [value, value];
|
|
16
|
+
}
|
|
17
|
+
export function convertPageToDayjs(page) {
|
|
18
|
+
return dayjs().year(page.year).month(page.month - 1).date(1);
|
|
15
19
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
export declare type Action = {
|
|
4
4
|
key: string | number;
|
|
5
|
-
text:
|
|
5
|
+
text: ReactNode;
|
|
6
6
|
disabled?: boolean;
|
|
7
7
|
danger?: boolean;
|
|
8
8
|
bold?: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import React, { useRef, useState } from 'react';
|
|
1
|
+
import React, { useMemo, useRef, useState } from 'react';
|
|
2
|
+
import runes from 'runes';
|
|
2
3
|
import { mergeProps } from '../../utils/with-default-props';
|
|
3
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
4
5
|
import { useResizeEffect } from '../../utils/use-resize-effect';
|
|
@@ -19,6 +20,11 @@ export const Ellipsis = p => {
|
|
|
19
20
|
const [ellipsised, setEllipsised] = useState({});
|
|
20
21
|
const [expanded, setExpanded] = useState(false);
|
|
21
22
|
const [exceeded, setExceeded] = useState(false);
|
|
23
|
+
const chars = useMemo(() => runes(props.content), [props.content]);
|
|
24
|
+
|
|
25
|
+
function getSubString(start, end) {
|
|
26
|
+
return chars.slice(start, end).join('');
|
|
27
|
+
}
|
|
22
28
|
|
|
23
29
|
function calcEllipsised() {
|
|
24
30
|
const root = rootRef.current;
|
|
@@ -57,11 +63,11 @@ export const Ellipsis = p => {
|
|
|
57
63
|
if (right - left <= 1) {
|
|
58
64
|
if (props.direction === 'end') {
|
|
59
65
|
return {
|
|
60
|
-
leading:
|
|
66
|
+
leading: getSubString(0, left) + '...'
|
|
61
67
|
};
|
|
62
68
|
} else {
|
|
63
69
|
return {
|
|
64
|
-
tailing: '...' +
|
|
70
|
+
tailing: '...' + getSubString(right, end)
|
|
65
71
|
};
|
|
66
72
|
}
|
|
67
73
|
}
|
|
@@ -69,9 +75,9 @@ export const Ellipsis = p => {
|
|
|
69
75
|
const middle = Math.round((left + right) / 2);
|
|
70
76
|
|
|
71
77
|
if (props.direction === 'end') {
|
|
72
|
-
container.innerText =
|
|
78
|
+
container.innerText = getSubString(0, middle) + '...' + actionText;
|
|
73
79
|
} else {
|
|
74
|
-
container.innerText = actionText + '...' +
|
|
80
|
+
container.innerText = actionText + '...' + getSubString(middle, end);
|
|
75
81
|
}
|
|
76
82
|
|
|
77
83
|
if (container.offsetHeight <= maxHeight) {
|
|
@@ -92,14 +98,14 @@ export const Ellipsis = p => {
|
|
|
92
98
|
function checkMiddle(leftPart, rightPart) {
|
|
93
99
|
if (leftPart[1] - leftPart[0] <= 1 && rightPart[1] - rightPart[0] <= 1) {
|
|
94
100
|
return {
|
|
95
|
-
leading:
|
|
96
|
-
tailing: '...' +
|
|
101
|
+
leading: getSubString(0, leftPart[0]) + '...',
|
|
102
|
+
tailing: '...' + getSubString(rightPart[1], end)
|
|
97
103
|
};
|
|
98
104
|
}
|
|
99
105
|
|
|
100
106
|
const leftPartMiddle = Math.floor((leftPart[0] + leftPart[1]) / 2);
|
|
101
107
|
const rightPartMiddle = Math.ceil((rightPart[0] + rightPart[1]) / 2);
|
|
102
|
-
container.innerText =
|
|
108
|
+
container.innerText = getSubString(0, leftPartMiddle) + '...' + actionText + '...' + getSubString(rightPartMiddle, end);
|
|
103
109
|
|
|
104
110
|
if (container.offsetHeight <= maxHeight) {
|
|
105
111
|
return checkMiddle([leftPartMiddle, leftPart[1]], [rightPart[0], rightPartMiddle]);
|
|
@@ -3,6 +3,8 @@ import classNames from 'classnames';
|
|
|
3
3
|
import { withNativeProps } from '../../utils/native-props';
|
|
4
4
|
import { EmptyIcon } from './empty-icon';
|
|
5
5
|
const classPrefix = `adm-empty`;
|
|
6
|
+
/** @deprecated Empty has been deprecated and will be removed in the next major version. */
|
|
7
|
+
|
|
6
8
|
export const Empty = props => {
|
|
7
9
|
function renderImageNode() {
|
|
8
10
|
const {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
.adm-footer {
|
|
2
|
+
--background-color: var(--adm-color-background);
|
|
3
|
+
color: var(--adm-color-text);
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
align-items: center;
|
|
7
|
+
background-color: var(--background-color);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.adm-footer-label {
|
|
11
|
+
width: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.adm-footer-label .adm-divider.adm-divider {
|
|
15
|
+
color: var(--adm-color-light);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.adm-footer-links {
|
|
19
|
+
margin: 16px 0;
|
|
20
|
+
color: var(--adm-color-primary);
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.adm-footer-links a {
|
|
25
|
+
text-decoration: none;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.adm-footer-content {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
margin: 16px 0;
|
|
32
|
+
color: var(--adm-color-light);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.adm-footer-chips {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
white-space: nowrap;
|
|
39
|
+
margin: 16px 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.adm-footer-chip {
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
margin-right: 40px;
|
|
45
|
+
font-size: 24px;
|
|
46
|
+
background-color: var(--adm-color-box);
|
|
47
|
+
color: var(--adm-color-weak);
|
|
48
|
+
padding: 8px 24px;
|
|
49
|
+
border-radius: 200px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.adm-footer-chip-link {
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
background-color: #e7f1ff;
|
|
55
|
+
color: var(--adm-color-primary);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.adm-footer-chip:last-child {
|
|
59
|
+
margin-right: 0;
|
|
60
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { NativeProps } from '../../utils/native-props';
|
|
3
|
+
export declare type LinkItem = {
|
|
4
|
+
text: string;
|
|
5
|
+
href: string;
|
|
6
|
+
};
|
|
7
|
+
export declare type ChipItem = {
|
|
8
|
+
text: ReactNode;
|
|
9
|
+
type?: 'plain' | 'link';
|
|
10
|
+
};
|
|
11
|
+
export declare type FooterProps = {
|
|
12
|
+
label?: ReactNode;
|
|
13
|
+
links?: LinkItem[];
|
|
14
|
+
content?: ReactNode;
|
|
15
|
+
chips?: ChipItem[];
|
|
16
|
+
onChipClick?: (item: ChipItem, index: number) => void;
|
|
17
|
+
onLinkClick?: (item: LinkItem, index: number) => void;
|
|
18
|
+
} & NativeProps<'--background-color'>;
|
|
19
|
+
export declare const Footer: FC<FooterProps>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { withNativeProps } from '../../utils/native-props';
|
|
4
|
+
import { mergeProps } from '../../utils/with-default-props';
|
|
5
|
+
import { Divider } from '../divider/divider';
|
|
6
|
+
const classPrefix = `adm-footer`;
|
|
7
|
+
const defaultProps = {
|
|
8
|
+
label: '',
|
|
9
|
+
links: [],
|
|
10
|
+
content: '',
|
|
11
|
+
chips: []
|
|
12
|
+
};
|
|
13
|
+
export const Footer = p => {
|
|
14
|
+
const props = mergeProps(defaultProps, p);
|
|
15
|
+
const {
|
|
16
|
+
label,
|
|
17
|
+
links,
|
|
18
|
+
content,
|
|
19
|
+
chips,
|
|
20
|
+
onChipClick,
|
|
21
|
+
onLinkClick
|
|
22
|
+
} = props;
|
|
23
|
+
|
|
24
|
+
const clickChipItem = (item, index) => {
|
|
25
|
+
if ((chips === null || chips === void 0 ? void 0 : chips.length) && item.type === 'link') {
|
|
26
|
+
onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(item, index);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const clickLinkItem = (item, index, e) => {
|
|
31
|
+
if (onLinkClick) {
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
onLinkClick(item, index);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return withNativeProps(props, React.createElement("div", {
|
|
38
|
+
className: classNames(classPrefix)
|
|
39
|
+
}, label && React.createElement("div", {
|
|
40
|
+
className: `${classPrefix}-label`
|
|
41
|
+
}, React.createElement(Divider, null, label)), links && links.length > 0 && React.createElement("div", {
|
|
42
|
+
className: `${classPrefix}-links`
|
|
43
|
+
}, links.map((link, index) => {
|
|
44
|
+
return React.createElement(React.Fragment, {
|
|
45
|
+
key: index
|
|
46
|
+
}, React.createElement("a", {
|
|
47
|
+
href: link.href,
|
|
48
|
+
rel: 'noopener noreferrer',
|
|
49
|
+
onClick: event => clickLinkItem(link, index, event)
|
|
50
|
+
}, link.text), index !== links.length - 1 && React.createElement(Divider, {
|
|
51
|
+
direction: 'vertical'
|
|
52
|
+
}));
|
|
53
|
+
})), content && React.createElement("div", {
|
|
54
|
+
className: `${classPrefix}-content`
|
|
55
|
+
}, content), chips && chips.length > 0 && React.createElement("div", {
|
|
56
|
+
className: `${classPrefix}-chips`
|
|
57
|
+
}, chips.map((chip, index) => {
|
|
58
|
+
return React.createElement("div", {
|
|
59
|
+
key: index,
|
|
60
|
+
onClick: () => clickChipItem(chip, index),
|
|
61
|
+
className: classNames(`${classPrefix}-chip`, {
|
|
62
|
+
[`${classPrefix}-chip-link`]: chip.type === 'link'
|
|
63
|
+
})
|
|
64
|
+
}, chip.text);
|
|
65
|
+
}))));
|
|
66
|
+
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
.adm-form {
|
|
2
|
-
--border-inner: solid 2px var(--adm-color
|
|
3
|
-
--border-top: solid 2px var(--adm-color
|
|
4
|
-
--border-bottom: solid 2px var(--adm-color
|
|
2
|
+
--border-inner: solid 2px var(--adm-border-color);
|
|
3
|
+
--border-top: solid 2px var(--adm-border-color);
|
|
4
|
+
--border-bottom: solid 2px var(--adm-border-color);
|
|
5
|
+
--prefix-width: 6.8em;
|
|
5
6
|
---border-inner: var(--border-inner);
|
|
6
7
|
---border-top: var(--border-top);
|
|
7
8
|
---border-bottom: var(--border-bottom);
|
|
9
|
+
---prefix-width: var(--prefix-width);
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
.adm-form .adm-list.adm-list {
|
|
@@ -19,6 +21,10 @@
|
|
|
19
21
|
padding: 40px 24px;
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
.adm-form .adm-form-item-horizontal.adm-list-item {
|
|
25
|
+
--prefix-width: var(---prefix-width);
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
.adm-form-list-operation {
|
|
23
29
|
text-align: center;
|
|
24
30
|
color: #1677ff;
|
|
@@ -4,13 +4,13 @@ import { ListProps } from '../list';
|
|
|
4
4
|
import type { FormProps as RcFormProps, FormInstance as RCFormInstance } from 'rc-field-form';
|
|
5
5
|
import { FormContextType } from './context';
|
|
6
6
|
export declare type FormInstance = Pick<RCFormInstance, 'getFieldValue' | 'getFieldsValue' | 'getFieldError' | 'getFieldsError' | 'isFieldTouched' | 'isFieldsTouched' | 'resetFields' | 'setFields' | 'setFieldsValue' | 'submit' | 'validateFields'>;
|
|
7
|
-
export declare type FormProps = Pick<RcFormProps, 'form' | 'initialValues' | 'name' | 'preserve' | 'validateMessages' | 'validateTrigger' | 'onFieldsChange' | 'onFinish' | 'onFinishFailed' | 'onValuesChange' | 'children'> & NativeProps<'--border-inner' | '--border-top' | '--border-bottom'> & Partial<FormContextType> & {
|
|
7
|
+
export declare type FormProps = Pick<RcFormProps, 'form' | 'initialValues' | 'name' | 'preserve' | 'validateMessages' | 'validateTrigger' | 'onFieldsChange' | 'onFinish' | 'onFinishFailed' | 'onValuesChange' | 'children'> & NativeProps<'--border-inner' | '--border-top' | '--border-bottom' | '--prefix-width'> & Partial<FormContextType> & {
|
|
8
8
|
footer?: ReactNode;
|
|
9
9
|
mode?: ListProps['mode'];
|
|
10
10
|
};
|
|
11
11
|
export declare const Form: React.ForwardRefExoticComponent<Pick<RcFormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & {
|
|
12
12
|
className?: string | undefined;
|
|
13
|
-
style?: (React.CSSProperties & Partial<Record<"--border-bottom" | "--border-inner" | "--border-top", string>>) | undefined;
|
|
13
|
+
style?: (React.CSSProperties & Partial<Record<"--border-bottom" | "--border-inner" | "--border-top" | "--prefix-width", string>>) | undefined;
|
|
14
14
|
tabIndex?: number | undefined;
|
|
15
15
|
} & React.AriaAttributes & Partial<FormContextType> & {
|
|
16
16
|
footer?: ReactNode;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
.adm-form {
|
|
2
|
-
--border-inner: solid 2px var(--adm-color
|
|
3
|
-
--border-top: solid 2px var(--adm-color
|
|
4
|
-
--border-bottom: solid 2px var(--adm-color
|
|
2
|
+
--border-inner: solid 2px var(--adm-border-color);
|
|
3
|
+
--border-top: solid 2px var(--adm-border-color);
|
|
4
|
+
--border-bottom: solid 2px var(--adm-border-color);
|
|
5
|
+
--prefix-width: 6.8em;
|
|
5
6
|
---border-inner: var(--border-inner);
|
|
6
7
|
---border-top: var(--border-top);
|
|
7
8
|
---border-bottom: var(--border-bottom);
|
|
9
|
+
---prefix-width: var(--prefix-width);
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
.adm-form .adm-list.adm-list {
|
|
@@ -19,6 +21,10 @@
|
|
|
19
21
|
padding: 40px 24px;
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
.adm-form .adm-form-item-horizontal.adm-list-item {
|
|
25
|
+
--prefix-width: var(---prefix-width);
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
.adm-form-list-operation {
|
|
23
29
|
text-align: center;
|
|
24
30
|
color: #1677ff;
|
|
@@ -93,7 +99,6 @@
|
|
|
93
99
|
|
|
94
100
|
.adm-form-item.adm-form-item-horizontal.adm-list-item {
|
|
95
101
|
--align-items: stretch;
|
|
96
|
-
--prefix-width: 6.8em;
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
.adm-form-item.adm-form-item-horizontal .adm-list-item-content-prefix {
|
|
@@ -9,7 +9,7 @@ export type { ValidateMessages, FieldData, NamePath, } from 'rc-field-form/es/in
|
|
|
9
9
|
export type { FormArrayField, FormArrayOperation, FormArrayProps, } from './form-array';
|
|
10
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"> & {
|
|
11
11
|
className?: string | undefined;
|
|
12
|
-
style?: (import("react").CSSProperties & Partial<Record<"--border-bottom" | "--border-inner" | "--border-top", string>>) | undefined;
|
|
12
|
+
style?: (import("react").CSSProperties & Partial<Record<"--border-bottom" | "--border-inner" | "--border-top" | "--prefix-width", string>>) | undefined;
|
|
13
13
|
tabIndex?: number | undefined;
|
|
14
14
|
} & import("react").AriaAttributes & Partial<import("./context").FormContextType> & {
|
|
15
15
|
footer?: import("react").ReactNode;
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import React, { FC, InputHTMLAttributes } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
3
|
import type { ImageProps } from '../image';
|
|
4
|
-
export declare type TaskStatus = 'pending' | 'fail';
|
|
4
|
+
export declare type TaskStatus = 'pending' | 'fail' | 'success';
|
|
5
5
|
export interface ImageUploadItem {
|
|
6
6
|
key?: string | number;
|
|
7
7
|
url: string;
|
|
8
8
|
thumbnailUrl?: string;
|
|
9
9
|
extra?: any;
|
|
10
10
|
}
|
|
11
|
+
declare type Task = {
|
|
12
|
+
id: number;
|
|
13
|
+
url?: string;
|
|
14
|
+
file: File;
|
|
15
|
+
status: TaskStatus;
|
|
16
|
+
};
|
|
17
|
+
export declare type UploadTask = Pick<Task, 'id' | 'status'>;
|
|
11
18
|
export declare type ImageUploaderProps = {
|
|
12
19
|
defaultValue?: ImageUploadItem[];
|
|
13
20
|
value?: ImageUploadItem[];
|
|
14
21
|
onChange?: (items: ImageUploadItem[]) => void;
|
|
22
|
+
onUploadQueueChange?: (tasks: UploadTask[]) => void;
|
|
15
23
|
accept?: string;
|
|
16
24
|
multiple?: boolean;
|
|
17
25
|
maxCount?: number;
|
|
@@ -28,5 +36,7 @@ export declare type ImageUploaderProps = {
|
|
|
28
36
|
showFailed?: boolean;
|
|
29
37
|
imageFit?: ImageProps['fit'];
|
|
30
38
|
children?: React.ReactNode;
|
|
39
|
+
renderItem?: (originNode: React.ReactElement, file: ImageUploadItem, fileList: ImageUploadItem[]) => React.ReactNode;
|
|
31
40
|
} & NativeProps<'--cell-size'>;
|
|
32
41
|
export declare const ImageUploader: FC<ImageUploaderProps>;
|
|
42
|
+
export {};
|
|
@@ -35,10 +35,19 @@ export const ImageUploader = p => {
|
|
|
35
35
|
return !value.some(fileItem => fileItem.url === task.url);
|
|
36
36
|
}));
|
|
37
37
|
}, [value]);
|
|
38
|
+
useIsomorphicLayoutEffect(() => {
|
|
39
|
+
var _a;
|
|
40
|
+
|
|
41
|
+
(_a = props.onUploadQueueChange) === null || _a === void 0 ? void 0 : _a.call(props, tasks.map(item => ({
|
|
42
|
+
id: item.id,
|
|
43
|
+
status: item.status
|
|
44
|
+
})));
|
|
45
|
+
}, [tasks]);
|
|
38
46
|
const idCountRef = useRef(0);
|
|
39
47
|
const {
|
|
40
48
|
maxCount,
|
|
41
|
-
onPreview
|
|
49
|
+
onPreview,
|
|
50
|
+
renderItem
|
|
42
51
|
} = props;
|
|
43
52
|
|
|
44
53
|
function processFile(file, fileList) {
|
|
@@ -99,6 +108,7 @@ export const ImageUploader = p => {
|
|
|
99
108
|
return prev.map(task => {
|
|
100
109
|
if (task.id === currentTask.id) {
|
|
101
110
|
return Object.assign(Object.assign({}, task), {
|
|
111
|
+
status: 'success',
|
|
102
112
|
url: result.url
|
|
103
113
|
});
|
|
104
114
|
}
|
|
@@ -146,36 +156,42 @@ export const ImageUploader = p => {
|
|
|
146
156
|
(_a = imageViewerHandlerRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
147
157
|
});
|
|
148
158
|
const showUpload = props.showUpload && (maxCount === 0 || value.length + tasks.length < maxCount);
|
|
159
|
+
|
|
160
|
+
const renderImages = () => {
|
|
161
|
+
return value.map((fileItem, index) => {
|
|
162
|
+
var _a, _b;
|
|
163
|
+
|
|
164
|
+
const originNode = React.createElement(PreviewItem, {
|
|
165
|
+
key: (_a = fileItem.key) !== null && _a !== void 0 ? _a : index,
|
|
166
|
+
url: (_b = fileItem.thumbnailUrl) !== null && _b !== void 0 ? _b : fileItem.url,
|
|
167
|
+
deletable: props.deletable,
|
|
168
|
+
imageFit: props.imageFit,
|
|
169
|
+
onClick: () => {
|
|
170
|
+
if (props.preview) {
|
|
171
|
+
previewImage(index);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
onPreview && onPreview(index, fileItem);
|
|
175
|
+
},
|
|
176
|
+
onDelete: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
|
+
var _c;
|
|
178
|
+
|
|
179
|
+
const canDelete = yield (_c = props.onDelete) === null || _c === void 0 ? void 0 : _c.call(props, fileItem);
|
|
180
|
+
if (canDelete === false) return;
|
|
181
|
+
setValue(value.filter((x, i) => i !== index));
|
|
182
|
+
})
|
|
183
|
+
});
|
|
184
|
+
return renderItem ? renderItem(originNode, fileItem, value) : originNode;
|
|
185
|
+
});
|
|
186
|
+
};
|
|
187
|
+
|
|
149
188
|
return withNativeProps(props, React.createElement("div", {
|
|
150
189
|
className: classPrefix
|
|
151
190
|
}, React.createElement(Space, {
|
|
152
191
|
className: `${classPrefix}-space`,
|
|
153
192
|
wrap: true,
|
|
154
193
|
block: true
|
|
155
|
-
},
|
|
156
|
-
var _a, _b;
|
|
157
|
-
|
|
158
|
-
return React.createElement(PreviewItem, {
|
|
159
|
-
key: (_a = fileItem.key) !== null && _a !== void 0 ? _a : index,
|
|
160
|
-
url: (_b = fileItem.thumbnailUrl) !== null && _b !== void 0 ? _b : fileItem.url,
|
|
161
|
-
deletable: props.deletable,
|
|
162
|
-
imageFit: props.imageFit,
|
|
163
|
-
onClick: () => {
|
|
164
|
-
if (props.preview) {
|
|
165
|
-
previewImage(index);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
onPreview && onPreview(index, fileItem);
|
|
169
|
-
},
|
|
170
|
-
onDelete: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
171
|
-
var _c;
|
|
172
|
-
|
|
173
|
-
const canDelete = yield (_c = props.onDelete) === null || _c === void 0 ? void 0 : _c.call(props, fileItem);
|
|
174
|
-
if (canDelete === false) return;
|
|
175
|
-
setValue(value.filter((x, i) => i !== index));
|
|
176
|
-
})
|
|
177
|
-
});
|
|
178
|
-
}), tasks.map(task => {
|
|
194
|
+
}, renderImages(), tasks.map(task => {
|
|
179
195
|
if (!props.showFailed && task.status === 'fail') {
|
|
180
196
|
return null;
|
|
181
197
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ImageUploader } from './image-uploader';
|
|
2
2
|
import './image-uploader.less';
|
|
3
|
-
export type { ImageUploadItem, ImageUploaderProps } from './image-uploader';
|
|
3
|
+
export type { ImageUploadItem, ImageUploaderProps, UploadTask, } from './image-uploader';
|
|
4
4
|
export default ImageUploader;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useLayoutEffect, useMemo } from 'react';
|
|
2
2
|
import { CloseOutline } from 'antd-mobile-icons';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import Image from '../image';
|
|
@@ -28,6 +28,11 @@ const PreviewItem = props => {
|
|
|
28
28
|
|
|
29
29
|
return '';
|
|
30
30
|
}, [url, file]);
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
return () => {
|
|
33
|
+
URL.revokeObjectURL(src);
|
|
34
|
+
};
|
|
35
|
+
}, [src]);
|
|
31
36
|
|
|
32
37
|
function renderLoading() {
|
|
33
38
|
return props.status === 'pending' && React.createElement("div", {
|
|
@@ -75,8 +75,8 @@ export const Slides = forwardRef((props, ref) => {
|
|
|
75
75
|
style: {
|
|
76
76
|
x: x.to(x => -x)
|
|
77
77
|
}
|
|
78
|
-
}, props.images.map(image => React.createElement(Slide, {
|
|
79
|
-
key:
|
|
78
|
+
}, props.images.map((image, index) => React.createElement(Slide, {
|
|
79
|
+
key: index,
|
|
80
80
|
image: image,
|
|
81
81
|
onTap: props.onTap,
|
|
82
82
|
maxZoom: props.maxZoom,
|