antd-mobile 5.10.4 → 5.11.2
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/button/button.d.ts +6 -4
- package/2x/cjs/components/button/button.js +31 -7
- package/2x/cjs/components/calendar/calendar.css +2 -2
- package/2x/cjs/components/calendar/calendar.d.ts +2 -0
- package/2x/cjs/components/calendar/calendar.js +6 -1
- package/2x/cjs/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/2x/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
- package/2x/cjs/components/cascade-picker/cascade-picker.js +2 -7
- package/2x/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
- package/2x/cjs/components/date-picker/date-picker.js +1 -0
- package/2x/cjs/components/dialog/dialog-action-button.js +3 -26
- package/2x/cjs/components/floating-panel/floating-panel.js +1 -1
- package/2x/cjs/components/form/context.d.ts +1 -0
- package/2x/cjs/components/form/context.js +2 -1
- package/2x/cjs/components/form/form-item.css +1 -1
- package/2x/cjs/components/form/form-item.js +3 -1
- package/2x/cjs/components/form/form.d.ts +0 -3
- package/2x/cjs/components/form/form.js +4 -2
- package/2x/cjs/components/form/index.css +1 -1
- package/2x/cjs/components/form/index.d.ts +2 -2
- package/2x/cjs/components/form/index.js +2 -1
- package/2x/cjs/components/image-uploader/image-uploader.js +9 -2
- package/2x/cjs/components/index-bar/panel.d.ts +1 -0
- package/2x/cjs/components/input/input.css +4 -0
- package/2x/cjs/components/input/input.d.ts +2 -0
- package/2x/cjs/components/input/input.js +13 -2
- package/2x/cjs/components/list/list-item.js +7 -5
- package/2x/cjs/components/modal/modal-action-button.js +3 -26
- package/2x/cjs/components/search-bar/search-bar.d.ts +2 -0
- package/2x/cjs/components/search-bar/search-bar.js +2 -0
- package/2x/cjs/components/text-area/text-area.js +1 -1
- package/2x/cjs/components/virtual-input/virtual-input.js +2 -1
- package/2x/cjs/global/index.js +2 -0
- package/2x/cjs/locales/base.d.ts +1 -0
- package/2x/cjs/locales/base.js +2 -1
- package/2x/cjs/locales/en-US.d.ts +1 -0
- package/2x/cjs/locales/es-ES.d.ts +1 -0
- package/2x/cjs/locales/fa-IR.d.ts +1 -0
- package/2x/cjs/locales/ko-KR.d.ts +1 -0
- package/2x/cjs/locales/zh-CN.d.ts +1 -0
- package/2x/cjs/locales/zh-CN.js +2 -1
- package/2x/cjs/locales/zh-HK.d.ts +1 -0
- package/2x/cjs/locales/zh-TW.d.ts +1 -0
- package/2x/cjs/utils/is-node-with-content.d.ts +4 -0
- package/2x/cjs/utils/is-node-with-content.js +10 -0
- package/2x/es/components/button/button.d.ts +6 -4
- package/2x/es/components/button/button.js +30 -8
- package/2x/es/components/calendar/calendar.css +2 -2
- package/2x/es/components/calendar/calendar.d.ts +2 -0
- package/2x/es/components/calendar/calendar.js +6 -2
- package/2x/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/2x/es/components/cascade-picker/cascade-picker-utils.js +35 -15
- package/2x/es/components/cascade-picker/cascade-picker.js +3 -7
- package/2x/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
- package/2x/es/components/date-picker/date-picker.js +1 -0
- package/2x/es/components/dialog/dialog-action-button.js +3 -21
- package/2x/es/components/floating-panel/floating-panel.js +1 -1
- package/2x/es/components/form/context.d.ts +1 -0
- package/2x/es/components/form/context.js +2 -1
- package/2x/es/components/form/form-item.css +1 -1
- package/2x/es/components/form/form-item.js +3 -1
- package/2x/es/components/form/form.d.ts +0 -3
- package/2x/es/components/form/form.js +4 -2
- package/2x/es/components/form/index.css +1 -1
- package/2x/es/components/form/index.d.ts +2 -2
- package/2x/es/components/form/index.js +3 -2
- package/2x/es/components/image-uploader/image-uploader.js +8 -2
- package/2x/es/components/index-bar/panel.d.ts +1 -0
- package/2x/es/components/input/input.css +4 -0
- package/2x/es/components/input/input.d.ts +2 -0
- package/2x/es/components/input/input.js +13 -2
- package/2x/es/components/list/list-item.js +6 -5
- package/2x/es/components/modal/modal-action-button.js +3 -21
- package/2x/es/components/search-bar/search-bar.d.ts +2 -0
- package/2x/es/components/search-bar/search-bar.js +2 -0
- package/2x/es/components/text-area/text-area.js +2 -2
- package/2x/es/components/virtual-input/virtual-input.js +2 -1
- package/2x/es/global/index.js +2 -0
- package/2x/es/locales/base.d.ts +1 -0
- package/2x/es/locales/base.js +2 -1
- package/2x/es/locales/en-US.d.ts +1 -0
- package/2x/es/locales/es-ES.d.ts +1 -0
- package/2x/es/locales/fa-IR.d.ts +1 -0
- package/2x/es/locales/ko-KR.d.ts +1 -0
- package/2x/es/locales/zh-CN.d.ts +1 -0
- package/2x/es/locales/zh-CN.js +2 -1
- package/2x/es/locales/zh-HK.d.ts +1 -0
- package/2x/es/locales/zh-TW.d.ts +1 -0
- package/2x/es/utils/is-node-with-content.d.ts +4 -0
- package/2x/es/utils/is-node-with-content.js +3 -0
- package/2x/package.json +2 -2
- package/bundle/antd-mobile.cjs.js +122 -106
- package/bundle/antd-mobile.es.js +124 -108
- package/bundle/style.css +6 -3
- package/cjs/components/button/button.d.ts +6 -4
- package/cjs/components/button/button.js +31 -7
- package/cjs/components/calendar/calendar.css +2 -2
- package/cjs/components/calendar/calendar.d.ts +2 -0
- package/cjs/components/calendar/calendar.js +6 -1
- package/cjs/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
- package/cjs/components/cascade-picker/cascade-picker.js +2 -7
- package/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
- package/cjs/components/date-picker/date-picker.js +1 -0
- package/cjs/components/dialog/dialog-action-button.js +3 -26
- package/cjs/components/floating-panel/floating-panel.js +1 -1
- package/cjs/components/form/context.d.ts +1 -0
- package/cjs/components/form/context.js +2 -1
- package/cjs/components/form/form-item.css +1 -1
- package/cjs/components/form/form-item.js +3 -1
- package/cjs/components/form/form.d.ts +0 -3
- package/cjs/components/form/form.js +4 -2
- package/cjs/components/form/index.css +1 -1
- package/cjs/components/form/index.d.ts +2 -2
- package/cjs/components/form/index.js +2 -1
- package/cjs/components/image-uploader/image-uploader.js +9 -2
- package/cjs/components/index-bar/panel.d.ts +1 -0
- package/cjs/components/input/input.css +3 -0
- package/cjs/components/input/input.d.ts +2 -0
- package/cjs/components/input/input.js +13 -2
- package/cjs/components/list/list-item.js +7 -5
- package/cjs/components/modal/modal-action-button.js +3 -26
- package/cjs/components/search-bar/search-bar.d.ts +2 -0
- package/cjs/components/search-bar/search-bar.js +2 -0
- package/cjs/components/text-area/text-area.js +1 -1
- package/cjs/components/virtual-input/virtual-input.js +2 -1
- package/cjs/global/index.js +2 -0
- package/cjs/locales/base.d.ts +1 -0
- package/cjs/locales/base.js +2 -1
- package/cjs/locales/en-US.d.ts +1 -0
- package/cjs/locales/es-ES.d.ts +1 -0
- package/cjs/locales/fa-IR.d.ts +1 -0
- package/cjs/locales/ko-KR.d.ts +1 -0
- package/cjs/locales/zh-CN.d.ts +1 -0
- package/cjs/locales/zh-CN.js +2 -1
- package/cjs/locales/zh-HK.d.ts +1 -0
- package/cjs/locales/zh-TW.d.ts +1 -0
- package/cjs/utils/is-node-with-content.d.ts +4 -0
- package/cjs/utils/is-node-with-content.js +10 -0
- package/es/components/button/button.d.ts +6 -4
- package/es/components/button/button.js +30 -8
- package/es/components/calendar/calendar.css +2 -2
- package/es/components/calendar/calendar.d.ts +2 -0
- package/es/components/calendar/calendar.js +6 -2
- package/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
- package/es/components/cascade-picker/cascade-picker-utils.js +35 -15
- package/es/components/cascade-picker/cascade-picker.js +3 -7
- package/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
- package/es/components/date-picker/date-picker.js +1 -0
- package/es/components/dialog/dialog-action-button.js +3 -21
- package/es/components/floating-panel/floating-panel.js +1 -1
- package/es/components/form/context.d.ts +1 -0
- package/es/components/form/context.js +2 -1
- package/es/components/form/form-item.css +1 -1
- package/es/components/form/form-item.js +3 -1
- package/es/components/form/form.d.ts +0 -3
- package/es/components/form/form.js +4 -2
- package/es/components/form/index.css +1 -1
- package/es/components/form/index.d.ts +2 -2
- package/es/components/form/index.js +3 -2
- package/es/components/image-uploader/image-uploader.js +8 -2
- package/es/components/index-bar/panel.d.ts +1 -0
- package/es/components/input/input.css +3 -0
- package/es/components/input/input.d.ts +2 -0
- package/es/components/input/input.js +13 -2
- package/es/components/list/list-item.js +6 -5
- package/es/components/modal/modal-action-button.js +3 -21
- package/es/components/search-bar/search-bar.d.ts +2 -0
- package/es/components/search-bar/search-bar.js +2 -0
- package/es/components/text-area/text-area.js +2 -2
- package/es/components/virtual-input/virtual-input.js +2 -1
- package/es/global/index.js +2 -0
- package/es/locales/base.d.ts +1 -0
- package/es/locales/base.js +2 -1
- package/es/locales/en-US.d.ts +1 -0
- package/es/locales/es-ES.d.ts +1 -0
- package/es/locales/fa-IR.d.ts +1 -0
- package/es/locales/ko-KR.d.ts +1 -0
- package/es/locales/zh-CN.d.ts +1 -0
- package/es/locales/zh-CN.js +2 -1
- package/es/locales/zh-HK.d.ts +1 -0
- package/es/locales/zh-TW.d.ts +1 -0
- package/es/utils/is-node-with-content.d.ts +4 -0
- package/es/utils/is-node-with-content.js +3 -0
- package/package.json +2 -2
- package/umd/antd-mobile.js +1 -1
- package/2x/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/2x/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
- package/2x/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/2x/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
- package/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
- package/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
- package/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
package/cjs/global/index.js
CHANGED
|
@@ -5,5 +5,7 @@ require("./global.css");
|
|
|
5
5
|
var _canUseDom = require("../utils/can-use-dom");
|
|
6
6
|
|
|
7
7
|
if (_canUseDom.canUseDom) {
|
|
8
|
+
// Make sure the `:active` CSS selector of `button` and `a` take effect
|
|
9
|
+
// See: https://stackoverflow.com/questions/3885018/active-pseudo-class-doesnt-work-in-mobile-safari
|
|
8
10
|
document.addEventListener('touchstart', () => {}, true);
|
|
9
11
|
}
|
package/cjs/locales/base.d.ts
CHANGED
package/cjs/locales/base.js
CHANGED
package/cjs/locales/en-US.d.ts
CHANGED
package/cjs/locales/es-ES.d.ts
CHANGED
package/cjs/locales/fa-IR.d.ts
CHANGED
package/cjs/locales/ko-KR.d.ts
CHANGED
package/cjs/locales/zh-CN.d.ts
CHANGED
package/cjs/locales/zh-CN.js
CHANGED
package/cjs/locales/zh-HK.d.ts
CHANGED
package/cjs/locales/zh-TW.d.ts
CHANGED
|
@@ -5,10 +5,11 @@ export declare type ButtonProps = {
|
|
|
5
5
|
fill?: 'solid' | 'outline' | 'none';
|
|
6
6
|
size?: 'mini' | 'small' | 'middle' | 'large';
|
|
7
7
|
block?: boolean;
|
|
8
|
-
loading?: boolean;
|
|
8
|
+
loading?: boolean | 'auto';
|
|
9
9
|
loadingText?: string;
|
|
10
|
+
loadingIcon?: React.ReactNode;
|
|
10
11
|
disabled?: boolean;
|
|
11
|
-
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void
|
|
12
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Promise<void>;
|
|
12
13
|
type?: 'submit' | 'reset' | 'button';
|
|
13
14
|
shape?: 'default' | 'rounded' | 'rectangular';
|
|
14
15
|
children?: React.ReactNode;
|
|
@@ -21,10 +22,11 @@ export declare const Button: React.ForwardRefExoticComponent<{
|
|
|
21
22
|
fill?: "none" | "solid" | "outline" | undefined;
|
|
22
23
|
size?: "small" | "large" | "middle" | "mini" | undefined;
|
|
23
24
|
block?: boolean | undefined;
|
|
24
|
-
loading?: boolean | undefined;
|
|
25
|
+
loading?: boolean | "auto" | undefined;
|
|
25
26
|
loadingText?: string | undefined;
|
|
27
|
+
loadingIcon?: React.ReactNode;
|
|
26
28
|
disabled?: boolean | undefined;
|
|
27
|
-
onClick?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
|
|
29
|
+
onClick?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void | Promise<void>) | undefined;
|
|
28
30
|
type?: "reset" | "submit" | "button" | undefined;
|
|
29
31
|
shape?: "default" | "rounded" | "rectangular" | undefined;
|
|
30
32
|
children?: React.ReactNode;
|
|
@@ -1,32 +1,56 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
import DotLoading from '../dot-loading';
|
|
4
5
|
import { mergeProps } from '../../utils/with-default-props';
|
|
5
6
|
import { withNativeProps } from '../../utils/native-props';
|
|
7
|
+
import { isPromise } from '../../utils/validate';
|
|
6
8
|
const classPrefix = `adm-button`;
|
|
7
9
|
const defaultProps = {
|
|
8
10
|
color: 'default',
|
|
9
11
|
fill: 'solid',
|
|
10
12
|
block: false,
|
|
11
13
|
loading: false,
|
|
14
|
+
loadingIcon: React.createElement(DotLoading, {
|
|
15
|
+
color: 'currentColor'
|
|
16
|
+
}),
|
|
12
17
|
type: 'button',
|
|
13
18
|
shape: 'default',
|
|
14
19
|
size: 'middle'
|
|
15
20
|
};
|
|
16
21
|
export const Button = forwardRef((p, ref) => {
|
|
17
22
|
const props = mergeProps(defaultProps, p);
|
|
18
|
-
const
|
|
23
|
+
const [innerLoading, setInnerLoading] = useState(false);
|
|
19
24
|
const nativeButtonRef = useRef(null);
|
|
25
|
+
const loading = props.loading === 'auto' ? innerLoading : props.loading;
|
|
26
|
+
const disabled = props.disabled || loading;
|
|
20
27
|
useImperativeHandle(ref, () => ({
|
|
21
28
|
get nativeElement() {
|
|
22
29
|
return nativeButtonRef.current;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
}));
|
|
33
|
+
|
|
34
|
+
const handleClick = e => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
if (!props.onClick) return;
|
|
36
|
+
const promise = props.onClick(e);
|
|
37
|
+
|
|
38
|
+
if (isPromise(promise)) {
|
|
39
|
+
try {
|
|
40
|
+
setInnerLoading(true);
|
|
41
|
+
yield promise;
|
|
42
|
+
setInnerLoading(false);
|
|
43
|
+
} catch (e) {
|
|
44
|
+
setInnerLoading(false);
|
|
45
|
+
throw e;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
26
50
|
return withNativeProps(props, React.createElement("button", {
|
|
27
51
|
ref: nativeButtonRef,
|
|
28
52
|
type: props.type,
|
|
29
|
-
onClick:
|
|
53
|
+
onClick: handleClick,
|
|
30
54
|
className: classNames(classPrefix, props.color ? `${classPrefix}-${props.color}` : null, {
|
|
31
55
|
[`${classPrefix}-block`]: props.block,
|
|
32
56
|
[`${classPrefix}-disabled`]: disabled,
|
|
@@ -35,12 +59,10 @@ export const Button = forwardRef((p, ref) => {
|
|
|
35
59
|
[`${classPrefix}-mini`]: props.size === 'mini',
|
|
36
60
|
[`${classPrefix}-small`]: props.size === 'small',
|
|
37
61
|
[`${classPrefix}-large`]: props.size === 'large',
|
|
38
|
-
[`${classPrefix}-loading`]:
|
|
62
|
+
[`${classPrefix}-loading`]: loading
|
|
39
63
|
}, `${classPrefix}-shape-${props.shape}`),
|
|
40
64
|
disabled: disabled
|
|
41
|
-
},
|
|
65
|
+
}, loading ? React.createElement("div", {
|
|
42
66
|
className: `${classPrefix}-loading-wrapper`
|
|
43
|
-
},
|
|
44
|
-
color: 'currentColor'
|
|
45
|
-
}), props.loadingText) : props.children));
|
|
67
|
+
}, props.loadingIcon, props.loadingText) : props.children));
|
|
46
68
|
});
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
.adm-calendar-cell.adm-calendar-cell-today {
|
|
51
51
|
color: var(--adm-color-primary);
|
|
52
52
|
}
|
|
53
|
-
.adm-calendar-cell.adm-calendar-cell-
|
|
53
|
+
.adm-calendar-cell.adm-calendar-cell-disabled {
|
|
54
54
|
color: var(--adm-color-light);
|
|
55
55
|
}
|
|
56
|
-
.adm-calendar-cell.adm-calendar-cell-
|
|
56
|
+
.adm-calendar-cell.adm-calendar-cell-disabled .adm-calendar-cell-bottom {
|
|
57
57
|
color: var(--adm-color-light);
|
|
58
58
|
}
|
|
59
59
|
.adm-calendar-cell.adm-calendar-cell-selected.adm-calendar-cell.adm-calendar-cell-selected {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { forwardRef, useState, useImperativeHandle } from 'react';
|
|
1
|
+
import React, { forwardRef, useState, useImperativeHandle, useMemo } from 'react';
|
|
2
2
|
import { withNativeProps } from '../../utils/native-props';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -94,6 +94,8 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
94
94
|
setCurrent(current.add(1, 'year'));
|
|
95
95
|
}
|
|
96
96
|
}, React.createElement(ArrowLeftDouble, null)));
|
|
97
|
+
const maxDay = useMemo(() => props.max && dayjs(props.max), [props.max]);
|
|
98
|
+
const minDay = useMemo(() => props.min && dayjs(props.min), [props.min]);
|
|
97
99
|
|
|
98
100
|
function renderCells() {
|
|
99
101
|
var _a;
|
|
@@ -119,9 +121,10 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
119
121
|
}
|
|
120
122
|
|
|
121
123
|
const inThisMonth = d.month() === current.month();
|
|
124
|
+
const disabled = !inThisMonth || maxDay && d.isAfter(maxDay, 'day') || minDay && d.isBefore(minDay, 'day');
|
|
122
125
|
cells.push(React.createElement("div", {
|
|
123
126
|
key: d.valueOf(),
|
|
124
|
-
className: classNames(`${classPrefix}-cell`,
|
|
127
|
+
className: classNames(`${classPrefix}-cell`, disabled && `${classPrefix}-cell-disabled`, inThisMonth && {
|
|
125
128
|
[`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
|
|
126
129
|
[`${classPrefix}-cell-selected`]: isSelect,
|
|
127
130
|
[`${classPrefix}-cell-selected-begin`]: isBegin,
|
|
@@ -129,6 +132,7 @@ export const Calendar = forwardRef((p, ref) => {
|
|
|
129
132
|
}),
|
|
130
133
|
onClick: () => {
|
|
131
134
|
if (!props.selectionMode) return;
|
|
135
|
+
if (disabled) return;
|
|
132
136
|
const date = d.toDate();
|
|
133
137
|
|
|
134
138
|
if (!inThisMonth) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PickerColumn } from '../picker-view';
|
|
1
|
+
import { PickerColumn, PickerValue } from '../picker-view';
|
|
2
2
|
import { CascadePickerOption } from './cascade-picker';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function useColumnsFn(options: CascadePickerOption[]): (selected: PickerValue[]) => PickerColumn[];
|
|
@@ -1,23 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: option.value
|
|
6
|
-
})));
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
export function useColumnsFn(options) {
|
|
3
|
+
const depth = useMemo(() => {
|
|
4
|
+
let depth = 0;
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
function traverse(options, currentDepth) {
|
|
7
|
+
if (currentDepth > depth) depth = currentDepth;
|
|
8
|
+
const nextDepth = currentDepth + 1;
|
|
9
|
+
options.forEach(option => {
|
|
10
|
+
if (option.children) {
|
|
11
|
+
traverse(option.children, nextDepth);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
traverse(options, 1);
|
|
17
|
+
return depth;
|
|
18
|
+
}, [options]);
|
|
19
|
+
return selected => {
|
|
20
|
+
const columns = [];
|
|
21
|
+
let currentOptions = options;
|
|
22
|
+
let i = 0;
|
|
23
|
+
|
|
24
|
+
while (true) {
|
|
25
|
+
columns.push(currentOptions.map(option => ({
|
|
16
26
|
label: option.label,
|
|
17
27
|
value: option.value
|
|
18
28
|
})));
|
|
29
|
+
const x = selected[i];
|
|
30
|
+
const targetOptions = currentOptions.find(option => option.value === x);
|
|
31
|
+
if (!targetOptions || !targetOptions.children) break;
|
|
32
|
+
currentOptions = targetOptions.children;
|
|
33
|
+
i++;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
while (i < depth - 1) {
|
|
37
|
+
columns.push([]);
|
|
38
|
+
i++;
|
|
19
39
|
}
|
|
20
|
-
}
|
|
21
40
|
|
|
22
|
-
|
|
41
|
+
return columns;
|
|
42
|
+
};
|
|
23
43
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import Picker from '../picker';
|
|
4
|
-
import {
|
|
5
|
-
import { generateCascadePickerColumns } from './cascade-picker-utils';
|
|
4
|
+
import { useColumnsFn } from './cascade-picker-utils';
|
|
6
5
|
export const CascadePicker = props => {
|
|
7
6
|
const {
|
|
8
7
|
options
|
|
9
8
|
} = props,
|
|
10
9
|
pickerProps = __rest(props, ["options"]);
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
depth,
|
|
14
|
-
subOptionsRecord
|
|
15
|
-
} = useCascadePickerOptions(options);
|
|
11
|
+
const columnsFn = useColumnsFn(options);
|
|
16
12
|
return React.createElement(Picker, Object.assign({}, pickerProps, {
|
|
17
|
-
columns:
|
|
13
|
+
columns: columnsFn
|
|
18
14
|
}));
|
|
19
15
|
};
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PickerView from '../picker-view';
|
|
4
|
-
import {
|
|
5
|
-
import { generateCascadePickerColumns } from '../cascade-picker/cascade-picker-utils';
|
|
4
|
+
import { useColumnsFn } from '../cascade-picker/cascade-picker-utils';
|
|
6
5
|
export const CascadePickerView = props => {
|
|
7
6
|
const {
|
|
8
7
|
options
|
|
9
8
|
} = props,
|
|
10
9
|
pickerProps = __rest(props, ["options"]);
|
|
11
10
|
|
|
12
|
-
const
|
|
13
|
-
depth,
|
|
14
|
-
subOptionsRecord
|
|
15
|
-
} = useCascadePickerOptions(options);
|
|
11
|
+
const columnsFn = useColumnsFn(options);
|
|
16
12
|
return React.createElement(PickerView, Object.assign({}, pickerProps, {
|
|
17
|
-
columns:
|
|
13
|
+
columns: columnsFn
|
|
18
14
|
}));
|
|
19
15
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import Button from '../button';
|
|
5
4
|
import { withNativeProps } from '../../utils/native-props';
|
|
@@ -7,26 +6,9 @@ export const DialogActionButton = props => {
|
|
|
7
6
|
const {
|
|
8
7
|
action
|
|
9
8
|
} = props;
|
|
10
|
-
const [loading, setLoading] = useState(false);
|
|
11
|
-
|
|
12
|
-
function handleClick() {
|
|
13
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
14
|
-
setLoading(true);
|
|
15
|
-
|
|
16
|
-
try {
|
|
17
|
-
const promise = props.onAction();
|
|
18
|
-
yield promise;
|
|
19
|
-
setLoading(false);
|
|
20
|
-
} catch (e) {
|
|
21
|
-
setLoading(false);
|
|
22
|
-
throw e;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
9
|
return withNativeProps(props.action, React.createElement(Button, {
|
|
28
10
|
key: action.key,
|
|
29
|
-
onClick:
|
|
11
|
+
onClick: props.onAction,
|
|
30
12
|
className: classNames('adm-dialog-button', {
|
|
31
13
|
'adm-dialog-button-bold': action.bold
|
|
32
14
|
}),
|
|
@@ -34,7 +16,7 @@ export const DialogActionButton = props => {
|
|
|
34
16
|
shape: 'rectangular',
|
|
35
17
|
block: true,
|
|
36
18
|
color: action.danger ? 'danger' : 'primary',
|
|
37
|
-
loading:
|
|
19
|
+
loading: 'auto',
|
|
38
20
|
disabled: action.disabled
|
|
39
21
|
}, action.text));
|
|
40
22
|
};
|
|
@@ -6,6 +6,7 @@ export declare type FormContextType = {
|
|
|
6
6
|
hasFeedback: boolean;
|
|
7
7
|
layout: FormLayout;
|
|
8
8
|
requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional';
|
|
9
|
+
disabled: boolean;
|
|
9
10
|
};
|
|
10
11
|
export declare const defaultFormContext: FormContextType;
|
|
11
12
|
export declare const FormContext: React.Context<FormContextType>;
|
|
@@ -3,7 +3,8 @@ export const defaultFormContext = {
|
|
|
3
3
|
name: undefined,
|
|
4
4
|
hasFeedback: true,
|
|
5
5
|
layout: 'vertical',
|
|
6
|
-
requiredMarkStyle: 'asterisk'
|
|
6
|
+
requiredMarkStyle: 'asterisk',
|
|
7
|
+
disabled: false
|
|
7
8
|
};
|
|
8
9
|
export const FormContext = React.createContext(defaultFormContext);
|
|
9
10
|
export const NoStyleItemContext = React.createContext(null);
|
|
@@ -18,6 +18,8 @@ const MemoInput = React.memo(({
|
|
|
18
18
|
}) => children, (prev, next) => prev.value === next.value && prev.update === next.update);
|
|
19
19
|
|
|
20
20
|
const FormItemLayout = props => {
|
|
21
|
+
var _a;
|
|
22
|
+
|
|
21
23
|
const {
|
|
22
24
|
className,
|
|
23
25
|
style,
|
|
@@ -25,7 +27,6 @@ const FormItemLayout = props => {
|
|
|
25
27
|
label,
|
|
26
28
|
help,
|
|
27
29
|
required,
|
|
28
|
-
disabled,
|
|
29
30
|
children,
|
|
30
31
|
htmlFor,
|
|
31
32
|
hidden,
|
|
@@ -38,6 +39,7 @@ const FormItemLayout = props => {
|
|
|
38
39
|
} = useConfig();
|
|
39
40
|
const hasFeedback = props.hasFeedback !== undefined ? props.hasFeedback : context.hasFeedback;
|
|
40
41
|
const layout = props.layout || context.layout;
|
|
42
|
+
const disabled = (_a = props.disabled) !== null && _a !== void 0 ? _a : context.disabled;
|
|
41
43
|
|
|
42
44
|
const requiredMark = (() => {
|
|
43
45
|
const {
|
|
@@ -3,15 +3,12 @@ import { NativeProps } from '../../utils/native-props';
|
|
|
3
3
|
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
|
-
import type { FormLayout } from '.';
|
|
7
6
|
export declare type FormInstance = Pick<RCFormInstance, 'getFieldValue' | 'getFieldsValue' | 'getFieldError' | 'getFieldsError' | 'isFieldTouched' | 'isFieldsTouched' | 'resetFields' | 'setFields' | 'setFieldsValue' | 'submit' | 'validateFields'>;
|
|
8
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> & {
|
|
9
8
|
footer?: ReactNode;
|
|
10
|
-
layout?: FormLayout;
|
|
11
9
|
mode?: ListProps['mode'];
|
|
12
10
|
};
|
|
13
11
|
export declare const Form: React.ForwardRefExoticComponent<Pick<RcFormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & NativeProps<"--border-inner" | "--border-top" | "--border-bottom"> & Partial<FormContextType> & {
|
|
14
12
|
footer?: ReactNode;
|
|
15
|
-
layout?: FormLayout | undefined;
|
|
16
13
|
mode?: ListProps['mode'];
|
|
17
14
|
} & React.RefAttributes<FormInstance>>;
|
|
@@ -23,9 +23,10 @@ export const Form = forwardRef((p, ref) => {
|
|
|
23
23
|
layout,
|
|
24
24
|
footer,
|
|
25
25
|
mode,
|
|
26
|
+
disabled,
|
|
26
27
|
requiredMarkStyle
|
|
27
28
|
} = props,
|
|
28
|
-
formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "requiredMarkStyle"]);
|
|
29
|
+
formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "disabled", "requiredMarkStyle"]);
|
|
29
30
|
|
|
30
31
|
const {
|
|
31
32
|
locale
|
|
@@ -76,7 +77,8 @@ export const Form = forwardRef((p, ref) => {
|
|
|
76
77
|
name: formProps.name,
|
|
77
78
|
hasFeedback,
|
|
78
79
|
layout,
|
|
79
|
-
requiredMarkStyle
|
|
80
|
+
requiredMarkStyle,
|
|
81
|
+
disabled: disabled
|
|
80
82
|
}
|
|
81
83
|
}, lists), footer && React.createElement("div", {
|
|
82
84
|
className: `${classPrefix}-footer`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './index.less';
|
|
3
|
-
import { useForm } from 'rc-field-form';
|
|
3
|
+
import { useWatch, useForm } from 'rc-field-form';
|
|
4
4
|
export declare type FormLayout = 'vertical' | 'horizontal';
|
|
5
5
|
export type { FormProps, FormInstance } from './form';
|
|
6
6
|
export type { FormItemProps } from './form-item';
|
|
@@ -9,7 +9,6 @@ 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"> & import("../../utils/native-props").NativeProps<"--border-inner" | "--border-top" | "--border-bottom"> & Partial<import("./context").FormContextType> & {
|
|
11
11
|
footer?: import("react").ReactNode;
|
|
12
|
-
layout?: FormLayout | undefined;
|
|
13
12
|
mode?: "default" | "card" | undefined;
|
|
14
13
|
} & import("react").RefAttributes<import("./form").FormInstance>> & {
|
|
15
14
|
Item: import("react").FC<import("./form-item").FormItemProps>;
|
|
@@ -19,5 +18,6 @@ declare const _default: import("react").ForwardRefExoticComponent<Pick<import("r
|
|
|
19
18
|
}>;
|
|
20
19
|
Array: import("react").FC<import("./form-array").FormArrayProps>;
|
|
21
20
|
useForm: typeof useForm;
|
|
21
|
+
useWatch: typeof useWatch;
|
|
22
22
|
};
|
|
23
23
|
export default _default;
|
|
@@ -3,7 +3,7 @@ import { Form } from './form';
|
|
|
3
3
|
import { attachPropertiesToComponent } from '../../utils/attach-properties-to-component';
|
|
4
4
|
import { FormItem } from './form-item';
|
|
5
5
|
import { Header } from './header';
|
|
6
|
-
import { useForm } from 'rc-field-form';
|
|
6
|
+
import { useWatch, useForm } from 'rc-field-form';
|
|
7
7
|
import { FormSubscribe } from './form-subscribe';
|
|
8
8
|
import { FormArray } from './form-array';
|
|
9
9
|
export default attachPropertiesToComponent(Form, {
|
|
@@ -11,5 +11,6 @@ export default attachPropertiesToComponent(Form, {
|
|
|
11
11
|
Subscribe: FormSubscribe,
|
|
12
12
|
Header,
|
|
13
13
|
Array: FormArray,
|
|
14
|
-
useForm
|
|
14
|
+
useForm,
|
|
15
|
+
useWatch
|
|
15
16
|
});
|
|
@@ -8,6 +8,7 @@ import { usePropsValue } from '../../utils/use-props-value';
|
|
|
8
8
|
import { useIsomorphicLayoutEffect, useMemoizedFn, useUnmount } from 'ahooks';
|
|
9
9
|
import Space from '../space';
|
|
10
10
|
import { withNativeProps } from '../../utils/native-props';
|
|
11
|
+
import { useConfig } from '../config-provider';
|
|
11
12
|
const classPrefix = `adm-image-uploader`;
|
|
12
13
|
const defaultProps = {
|
|
13
14
|
disableUpload: false,
|
|
@@ -22,6 +23,9 @@ const defaultProps = {
|
|
|
22
23
|
imageFit: 'cover'
|
|
23
24
|
};
|
|
24
25
|
export const ImageUploader = p => {
|
|
26
|
+
const {
|
|
27
|
+
locale
|
|
28
|
+
} = useConfig();
|
|
25
29
|
const props = mergeProps(defaultProps, p);
|
|
26
30
|
const [value, setValue] = usePropsValue(props);
|
|
27
31
|
const updateValue = useMemoizedFn(updater => {
|
|
@@ -194,7 +198,8 @@ export const ImageUploader = p => {
|
|
|
194
198
|
className: `${classPrefix}-upload-button-wrap`
|
|
195
199
|
}, props.children ? props.children : React.createElement("span", {
|
|
196
200
|
className: `${classPrefix}-cell ${classPrefix}-upload-button`,
|
|
197
|
-
role: 'button'
|
|
201
|
+
role: 'button',
|
|
202
|
+
"aria-label": locale.ImageUploader.upload
|
|
198
203
|
}, React.createElement("span", {
|
|
199
204
|
className: `${classPrefix}-upload-button-icon`
|
|
200
205
|
}, React.createElement(AddOutline, null))), !props.disableUpload && React.createElement("input", {
|
|
@@ -203,6 +208,7 @@ export const ImageUploader = p => {
|
|
|
203
208
|
multiple: props.multiple,
|
|
204
209
|
type: 'file',
|
|
205
210
|
className: `${classPrefix}-input`,
|
|
206
|
-
onChange: onChange
|
|
211
|
+
onChange: onChange,
|
|
212
|
+
"aria-hidden": true
|
|
207
213
|
})))));
|
|
208
214
|
};
|