antd-mobile 5.10.3 → 5.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/2x/cjs/components/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 +2 -2
- package/2x/cjs/components/form/form-item.js +5 -2
- 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 +2 -2
- package/2x/cjs/components/form/index.d.ts +2 -2
- package/2x/cjs/components/form/index.js +2 -1
- 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/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/global/index.js +2 -0
- package/2x/cjs/utils/get-scroll-parent.js +7 -4
- 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 +2 -2
- package/2x/es/components/form/form-item.js +5 -2
- 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 +2 -2
- package/2x/es/components/form/index.d.ts +2 -2
- package/2x/es/components/form/index.js +3 -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/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/global/index.js +2 -0
- package/2x/es/utils/get-scroll-parent.js +7 -4
- package/2x/package.json +2 -2
- package/bundle/antd-mobile.cjs.js +107 -98
- package/bundle/antd-mobile.es.js +108 -99
- package/bundle/style.css +7 -4
- 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 +2 -2
- package/cjs/components/form/form-item.js +5 -2
- package/cjs/components/form/form.d.ts +0 -3
- package/cjs/components/form/form.js +4 -2
- package/cjs/components/form/index.css +2 -2
- package/cjs/components/form/index.d.ts +2 -2
- package/cjs/components/form/index.js +2 -1
- 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/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/global/index.js +2 -0
- package/cjs/utils/get-scroll-parent.js +7 -4
- 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 +2 -2
- package/es/components/form/form-item.js +5 -2
- package/es/components/form/form.d.ts +0 -3
- package/es/components/form/form.js +4 -2
- package/es/components/form/index.css +2 -2
- package/es/components/form/index.d.ts +2 -2
- package/es/components/form/index.js +3 -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/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/global/index.js +2 -0
- package/es/utils/get-scroll-parent.js +7 -4
- 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
|
@@ -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);
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
flex: auto;
|
|
36
36
|
}
|
|
37
37
|
.adm-form-item-child-position-right {
|
|
38
|
-
justify-content:
|
|
38
|
+
justify-content: flex-end;
|
|
39
39
|
}
|
|
40
40
|
.adm-form-item-child-position-right > * {
|
|
41
41
|
flex: none;
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
.adm-form-item.adm-form-item-horizontal.adm-list-item {
|
|
55
55
|
--align-items: stretch;
|
|
56
|
-
--prefix-width:
|
|
56
|
+
--prefix-width: 6.8em;
|
|
57
57
|
}
|
|
58
58
|
.adm-form-item.adm-form-item-horizontal .adm-list-item-content-prefix {
|
|
59
59
|
padding-top: 12px;
|
|
@@ -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 {
|
|
@@ -92,7 +94,8 @@ const FormItemLayout = props => {
|
|
|
92
94
|
extra: extra,
|
|
93
95
|
description: description,
|
|
94
96
|
className: classNames(classPrefix, className, `${classPrefix}-${layout}`, {
|
|
95
|
-
[`${classPrefix}-hidden`]: hidden
|
|
97
|
+
[`${classPrefix}-hidden`]: hidden,
|
|
98
|
+
[`${classPrefix}-has-error`]: props.errors.length
|
|
96
99
|
}),
|
|
97
100
|
disabled: disabled,
|
|
98
101
|
onClick: props.onClick,
|
|
@@ -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`
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
flex: auto;
|
|
58
58
|
}
|
|
59
59
|
.adm-form-item-child-position-right {
|
|
60
|
-
justify-content:
|
|
60
|
+
justify-content: flex-end;
|
|
61
61
|
}
|
|
62
62
|
.adm-form-item-child-position-right > * {
|
|
63
63
|
flex: none;
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
}
|
|
76
76
|
.adm-form-item.adm-form-item-horizontal.adm-list-item {
|
|
77
77
|
--align-items: stretch;
|
|
78
|
-
--prefix-width:
|
|
78
|
+
--prefix-width: 6.8em;
|
|
79
79
|
}
|
|
80
80
|
.adm-form-item.adm-form-item-horizontal .adm-list-item-content-prefix {
|
|
81
81
|
padding-top: 12px;
|
|
@@ -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
|
});
|
|
@@ -9,6 +9,7 @@ export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength
|
|
|
9
9
|
disabled?: boolean;
|
|
10
10
|
readOnly?: boolean;
|
|
11
11
|
clearable?: boolean;
|
|
12
|
+
onlyShowClearWhenFocus?: boolean;
|
|
12
13
|
onClear?: () => void;
|
|
13
14
|
id?: string;
|
|
14
15
|
onEnterPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
@@ -30,6 +31,7 @@ export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProp
|
|
|
30
31
|
disabled?: boolean | undefined;
|
|
31
32
|
readOnly?: boolean | undefined;
|
|
32
33
|
clearable?: boolean | undefined;
|
|
34
|
+
onlyShowClearWhenFocus?: boolean | undefined;
|
|
33
35
|
onClear?: (() => void) | undefined;
|
|
34
36
|
id?: string | undefined;
|
|
35
37
|
onEnterPress?: ((e: React.KeyboardEvent<HTMLInputElement>) => void) | undefined;
|
|
@@ -8,7 +8,8 @@ import { useIsomorphicLayoutEffect } from 'ahooks';
|
|
|
8
8
|
import { bound } from '../../utils/bound';
|
|
9
9
|
const classPrefix = `adm-input`;
|
|
10
10
|
const defaultProps = {
|
|
11
|
-
defaultValue: ''
|
|
11
|
+
defaultValue: '',
|
|
12
|
+
onlyShowClearWhenFocus: true
|
|
12
13
|
};
|
|
13
14
|
export const Input = forwardRef((p, ref) => {
|
|
14
15
|
const props = mergeProps(defaultProps, p);
|
|
@@ -70,6 +71,16 @@ export const Input = forwardRef((p, ref) => {
|
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
|
|
74
|
+
const shouldShowClear = (() => {
|
|
75
|
+
if (!props.clearable || !value || props.readOnly) return false;
|
|
76
|
+
|
|
77
|
+
if (props.onlyShowClearWhenFocus) {
|
|
78
|
+
return hasFocus;
|
|
79
|
+
} else {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
})();
|
|
83
|
+
|
|
73
84
|
return withNativeProps(props, React.createElement("div", {
|
|
74
85
|
className: classNames(`${classPrefix}`, props.disabled && `${classPrefix}-disabled`)
|
|
75
86
|
}, React.createElement("input", {
|
|
@@ -112,7 +123,7 @@ export const Input = forwardRef((p, ref) => {
|
|
|
112
123
|
onCompositionStart: props.onCompositionStart,
|
|
113
124
|
onCompositionEnd: props.onCompositionEnd,
|
|
114
125
|
onClick: props.onClick
|
|
115
|
-
}),
|
|
126
|
+
}), shouldShowClear && React.createElement("div", {
|
|
116
127
|
className: `${classPrefix}-clear`,
|
|
117
128
|
onMouseDown: e => {
|
|
118
129
|
e.preventDefault();
|
|
@@ -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 ModalActionButton = 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-modal-button', {
|
|
31
13
|
'adm-modal-button-primary': props.action.primary
|
|
32
14
|
}),
|
|
@@ -34,7 +16,7 @@ export const ModalActionButton = props => {
|
|
|
34
16
|
size: props.action.primary ? 'large' : 'middle',
|
|
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
|
};
|
|
@@ -8,6 +8,7 @@ export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'on
|
|
|
8
8
|
maxLength?: number;
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
clearable?: boolean;
|
|
11
|
+
onlyShowClearWhenFocus?: boolean;
|
|
11
12
|
showCancelButton?: boolean | ((focus: boolean, value: string) => boolean);
|
|
12
13
|
cancelText?: string;
|
|
13
14
|
icon?: ReactNode;
|
|
@@ -22,6 +23,7 @@ export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps,
|
|
|
22
23
|
maxLength?: number | undefined;
|
|
23
24
|
placeholder?: string | undefined;
|
|
24
25
|
clearable?: boolean | undefined;
|
|
26
|
+
onlyShowClearWhenFocus?: boolean | undefined;
|
|
25
27
|
showCancelButton?: boolean | ((focus: boolean, value: string) => boolean) | undefined;
|
|
26
28
|
cancelText?: string | undefined;
|
|
27
29
|
icon?: ReactNode;
|
|
@@ -10,6 +10,7 @@ import { useConfig } from '../config-provider';
|
|
|
10
10
|
const classPrefix = `adm-search-bar`;
|
|
11
11
|
const defaultProps = {
|
|
12
12
|
clearable: true,
|
|
13
|
+
onlyShowClearWhenFocus: false,
|
|
13
14
|
showCancelButton: false,
|
|
14
15
|
defaultValue: '',
|
|
15
16
|
clearOnCancel: true,
|
|
@@ -101,6 +102,7 @@ export const SearchBar = forwardRef((p, ref) => {
|
|
|
101
102
|
maxLength: props.maxLength,
|
|
102
103
|
placeholder: props.placeholder,
|
|
103
104
|
clearable: props.clearable,
|
|
105
|
+
onlyShowClearWhenFocus: props.onlyShowClearWhenFocus,
|
|
104
106
|
onFocus: e => {
|
|
105
107
|
var _a;
|
|
106
108
|
|
package/es/global/index.js
CHANGED
|
@@ -2,5 +2,7 @@ import "./global.css";
|
|
|
2
2
|
import { canUseDom } from '../utils/can-use-dom';
|
|
3
3
|
|
|
4
4
|
if (canUseDom) {
|
|
5
|
+
// Make sure the `:active` CSS selector of `button` and `a` take effect
|
|
6
|
+
// See: https://stackoverflow.com/questions/3885018/active-pseudo-class-doesnt-work-in-mobile-safari
|
|
5
7
|
document.addEventListener('touchstart', () => {}, true);
|
|
6
8
|
}
|