@canlooks/can-ui 0.0.27 → 0.0.29
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/dist/cjs/components/actionSheet/actionSheet.js +5 -4
- package/dist/cjs/components/curd/curdFilter.js +10 -9
- package/dist/cjs/components/descriptions/descriptions.js +14 -9
- package/dist/cjs/components/descriptions/descriptions.style.js +2 -1
- package/dist/cjs/components/form/form.d.ts +1 -0
- package/dist/cjs/components/form/form.style.js +1 -1
- package/dist/cjs/components/form/formItem.js +2 -2
- package/dist/cjs/components/slider/slider.js +3 -2
- package/dist/esm/components/actionSheet/actionSheet.js +3 -2
- package/dist/esm/components/curd/curdFilter.js +2 -1
- package/dist/esm/components/descriptions/descriptions.js +8 -3
- package/dist/esm/components/descriptions/descriptions.style.js +2 -1
- package/dist/esm/components/form/form.d.ts +1 -0
- package/dist/esm/components/form/form.style.js +1 -1
- package/dist/esm/components/form/formItem.js +3 -3
- package/dist/esm/components/slider/slider.js +3 -2
- package/documentation/dist/assets/{index-GGSqC5H1.js → index-DGYeA9_D.js} +235 -234
- package/documentation/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActionSheet = void 0;
|
|
4
|
+
const react_1 = require("@emotion/react");
|
|
4
5
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const
|
|
6
|
+
const react_2 = require("react");
|
|
6
7
|
const actionSheet_style_1 = require("./actionSheet.style");
|
|
7
8
|
const utils_1 = require("../../utils");
|
|
8
9
|
const overlayBase_1 = require("../overlayBase");
|
|
@@ -12,7 +13,7 @@ const placementToDirection = {
|
|
|
12
13
|
top: 'down',
|
|
13
14
|
bottom: 'up'
|
|
14
15
|
};
|
|
15
|
-
exports.ActionSheet = (0,
|
|
16
|
+
exports.ActionSheet = (0, react_2.memo)(({ ref, title, actions, placement = 'bottom', maskClosable, escapeClosable = true, onAction, onConfirm, onCancel, defaultOpen = false, open, onClose, showConfirm, confirmText = '确 定', confirmProps, showCancel = true, cancelText = '取 消', cancelProps, slideProps, ...props }) => {
|
|
16
17
|
const [innerOpen, setInnerOpen] = (0, utils_1.useControlled)(defaultOpen, open);
|
|
17
18
|
const close = (reason) => {
|
|
18
19
|
onClose?.(reason);
|
|
@@ -34,10 +35,10 @@ exports.ActionSheet = (0, react_1.memo)(({ ref, title, actions, placement = 'bot
|
|
|
34
35
|
confirmProps?.onClick?.(e);
|
|
35
36
|
onConfirm?.(e);
|
|
36
37
|
close('confirmed');
|
|
37
|
-
} }), actions?.map((menuItemProps, i) => (0,
|
|
38
|
+
} }), actions?.map((menuItemProps, i) => (0, react_1.createElement)(menuItem_1.MenuItem, { className: (0, utils_1.clsx)(actionSheet_style_1.classes.action, menuItemProps.className), size: "large", ...menuItemProps, key: menuItemProps.key ?? i, onClick: e => {
|
|
38
39
|
menuItemProps.onClick?.(e);
|
|
39
40
|
onAction?.(menuItemProps);
|
|
40
41
|
close('action');
|
|
41
|
-
} }
|
|
42
|
+
} }))] }), showCancel &&
|
|
42
43
|
(0, jsx_runtime_1.jsx)("div", { className: actionSheet_style_1.classes.card, children: (0, jsx_runtime_1.jsx)(menuItem_1.MenuItem, { color: "error", emphasized: true, size: "large", label: cancelText, ...cancelProps, onClick: cancelHandler }) })] }) }));
|
|
43
44
|
});
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CurdFilter = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
5
|
+
const react_1 = require("@emotion/react");
|
|
6
|
+
const react_2 = require("react");
|
|
6
7
|
const form_1 = require("../form");
|
|
7
8
|
const curd_style_1 = require("./curd.style");
|
|
8
9
|
const utils_1 = require("../../utils");
|
|
@@ -13,25 +14,25 @@ const theme_1 = require("../theme");
|
|
|
13
14
|
const __1 = require("../..");
|
|
14
15
|
const faChevronDown_1 = require("@fortawesome/free-solid-svg-icons/faChevronDown");
|
|
15
16
|
const faFilter_1 = require("@fortawesome/free-solid-svg-icons/faFilter");
|
|
16
|
-
exports.CurdFilter = (0,
|
|
17
|
+
exports.CurdFilter = (0, react_2.memo)(({ ref, columns, expandable, showButton, renderConditions, buttonProps, onFilter, columnCount = 3, ...props }) => {
|
|
17
18
|
const { spacing } = (0, theme_1.useTheme)();
|
|
18
|
-
const items = (0,
|
|
19
|
+
const items = (0, react_2.useMemo)(() => {
|
|
19
20
|
return (0, utils_1.columnsToFilterItem)(columns);
|
|
20
21
|
}, [columns]);
|
|
21
22
|
/**
|
|
22
23
|
* --------------------------------------------------------------
|
|
23
24
|
* 收起与展开
|
|
24
25
|
*/
|
|
25
|
-
const firstItemRef = (0,
|
|
26
|
-
const [expanded, setExpanded] = (0,
|
|
27
|
-
const renderedGrid = ((0, jsx_runtime_1.jsx)(grid_1.Grid, { className: curd_style_1.classes.filterGrid, columnGap: spacing[8], children: items?.map((item, i) => (0,
|
|
26
|
+
const firstItemRef = (0, react_2.useRef)(null);
|
|
27
|
+
const [expanded, setExpanded] = (0, react_2.useState)(false);
|
|
28
|
+
const renderedGrid = ((0, jsx_runtime_1.jsx)(grid_1.Grid, { className: curd_style_1.classes.filterGrid, columnGap: spacing[8], children: items?.map((item, i) => (0, react_2.isValidElement)(item)
|
|
28
29
|
? item
|
|
29
|
-
: (0,
|
|
30
|
+
: (0, react_1.createElement)(form_1.FormItem, { span: { xs: 12, md: 6, lg: 4 }, ...item, key: item.key ?? i, wrapperRef: !i ? firstItemRef : void 0 })) }));
|
|
30
31
|
/**
|
|
31
32
|
* --------------------------------------------------------------
|
|
32
33
|
* 触发筛选
|
|
33
34
|
*/
|
|
34
|
-
const formRef = (0,
|
|
35
|
+
const formRef = (0, react_2.useRef)(null);
|
|
35
36
|
const clickHandler = (e) => {
|
|
36
37
|
buttonProps?.onClick?.(e);
|
|
37
38
|
const filterValue = formRef.current.getFormValue();
|
|
@@ -47,7 +48,7 @@ exports.CurdFilter = (0, react_1.memo)(({ ref, columns, expandable, showButton,
|
|
|
47
48
|
* --------------------------------------------------------------
|
|
48
49
|
* 已生效的筛选条件
|
|
49
50
|
*/
|
|
50
|
-
const [filteredConditions, setFilteredConditions] = (0,
|
|
51
|
+
const [filteredConditions, setFilteredConditions] = (0, react_2.useState)({});
|
|
51
52
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(form_1.Form, { ...props, ref: (0, utils_1.cloneRef)(ref, formRef), className: (0, utils_1.clsx)(curd_style_1.classes.filter, props.className), columnCount: columnCount, variant: "plain", onChange: changeHandler, children: !!items?.length &&
|
|
52
53
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [expandable
|
|
53
54
|
? (0, jsx_runtime_1.jsx)(transitionBase_1.Collapse, { className: curd_style_1.classes.filterGridContainer, in: expanded, collapsedSize: () => firstItemRef.current?.offsetHeight || 56, appear: false, children: renderedGrid })
|
|
@@ -3,36 +3,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Descriptions = void 0;
|
|
4
4
|
exports.useDescriptionsContext = useDescriptionsContext;
|
|
5
5
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
6
|
-
const react_1 = require("react");
|
|
6
|
+
const react_1 = require("@emotion/react");
|
|
7
|
+
const react_2 = require("react");
|
|
7
8
|
const grid_1 = require("../grid");
|
|
8
9
|
const descriptionItem_1 = require("./descriptionItem");
|
|
9
10
|
const utils_1 = require("../../utils");
|
|
10
11
|
const descriptions_style_1 = require("./descriptions.style");
|
|
11
12
|
const theme_1 = require("../theme");
|
|
12
13
|
function useDescriptionsContext() {
|
|
13
|
-
return (0,
|
|
14
|
+
return (0, react_2.useContext)(DescriptionsContext);
|
|
14
15
|
}
|
|
15
|
-
const DescriptionsContext = (0,
|
|
16
|
-
exports.Descriptions = (0,
|
|
17
|
-
const contextValue = (0,
|
|
16
|
+
const DescriptionsContext = (0, react_2.createContext)({});
|
|
17
|
+
exports.Descriptions = (0, react_2.memo)(({ size, labelWidth, colon = ':', labelPlacement = 'left', disableMargin, disablePadding, items, itemComponent: ItemComponent = descriptionItem_1.DescriptionItem, variant = 'grid', columnCount = 3, ...props }) => {
|
|
18
|
+
const contextValue = (0, react_2.useMemo)(() => ({
|
|
18
19
|
size, labelWidth, colon, labelPlacement, disableMargin, disablePadding, variant
|
|
19
20
|
}), [
|
|
20
21
|
size, labelWidth, colon, labelPlacement, disableMargin, disablePadding, variant
|
|
21
22
|
]);
|
|
22
23
|
const renderGridItems = () => {
|
|
23
|
-
return items?.map((itemProps, i) => (0,
|
|
24
|
+
return items?.map((itemProps, i) => (0, react_1.createElement)(ItemComponent
|
|
25
|
+
// 最后一项沾满剩余行空间
|
|
26
|
+
, {
|
|
24
27
|
// 最后一项沾满剩余行空间
|
|
25
|
-
flex: i === items.length - 1 ? 1 : void 0, ...itemProps
|
|
28
|
+
flex: i === items.length - 1 ? 1 : void 0, ...itemProps, key: itemProps.key ?? i })) || props.children;
|
|
26
29
|
};
|
|
27
30
|
const columnCountNum = (0, utils_1.useResponsiveValue)(columnCount);
|
|
28
31
|
const renderTableItems = () => {
|
|
29
|
-
const actualItems = items ||
|
|
32
|
+
const actualItems = items || react_2.Children.map(props.children, c => (0, react_2.isValidElement)(c) ? c.props : c);
|
|
30
33
|
if (actualItems?.length) {
|
|
31
34
|
const rows = [];
|
|
32
35
|
for (let i = 0, { length } = actualItems; i < length; i++) {
|
|
33
36
|
const cols = rows[Math.floor(i / columnCountNum)] ||= [];
|
|
34
37
|
const itemProps = actualItems[i];
|
|
35
|
-
cols.push((0,
|
|
38
|
+
cols.push((0, react_1.createElement)(ItemComponent
|
|
39
|
+
// 最后一项沾满剩余行空间
|
|
40
|
+
, { ...itemProps, key: itemProps.key ?? i, span: i === actualItems.length - 1 ? columnCountNum - i % columnCountNum : itemProps.span, className: (0, utils_1.clsx)(descriptions_style_1.classes.col, itemProps) }));
|
|
36
41
|
}
|
|
37
42
|
return rows.map((r, i) => (0, jsx_runtime_1.jsx)("tr", { children: r }, i));
|
|
38
43
|
}
|
|
@@ -72,7 +72,7 @@ exports.gridItemStyle = (0, utils_1.defineCss)(({ spacing, text }) => (0, react_
|
|
|
72
72
|
flex-direction: row-reverse;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
&:not(
|
|
75
|
+
&:not([data-disable-margin=true]) {
|
|
76
76
|
&[data-label-placement=left], &[data-label-placement=right] {
|
|
77
77
|
margin-bottom: ${spacing[4]}px;
|
|
78
78
|
|
|
@@ -134,6 +134,7 @@ exports.gridItemStyle = (0, utils_1.defineCss)(({ spacing, text }) => (0, react_
|
|
|
134
134
|
|
|
135
135
|
&[data-label-placement=left] {
|
|
136
136
|
.${exports.classes.label} {
|
|
137
|
+
text-align: right;
|
|
137
138
|
justify-content: flex-end;
|
|
138
139
|
}
|
|
139
140
|
|
|
@@ -32,6 +32,7 @@ interface FormContext<V extends FormValue> extends FormSharedProps {
|
|
|
32
32
|
declare const FormContext: React.Context<FormContext<any>>;
|
|
33
33
|
export declare function useFormContext<V extends FormValue>(): FormContext<V>;
|
|
34
34
|
export type FormRef<V extends FormValue = FormValue> = {
|
|
35
|
+
/** 存在校验不通过的字段时会得到`null` */
|
|
35
36
|
submit(): Promise<V | null>;
|
|
36
37
|
getFieldValue<T = any>(field: FieldPath): T;
|
|
37
38
|
getFormValue(): V;
|
|
@@ -20,7 +20,7 @@ exports.style = (0, utils_1.defineCss)(({ colors, spacing }) => (0, react_1.css)
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
.${exports.classes.item} {
|
|
23
|
-
&:not(
|
|
23
|
+
&:not([data-disable-margin=true]) {
|
|
24
24
|
&[data-label-placement=left], &[data-label-placement=right] {
|
|
25
25
|
margin-bottom: ${spacing[6]}px;
|
|
26
26
|
|
|
@@ -49,7 +49,7 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
|
|
|
49
49
|
* --------------------------------------------------------------------
|
|
50
50
|
* 校验
|
|
51
51
|
*/
|
|
52
|
-
const rulesArr =
|
|
52
|
+
const rulesArr = (0, utils_1.toArray)(rules);
|
|
53
53
|
const [innerError, setInnerError] = (0, utils_1.useDerivedState)(error);
|
|
54
54
|
const [innerHelperText, setInnerHelperText] = (0, utils_1.useDerivedState)(helperText);
|
|
55
55
|
const validate = async () => {
|
|
@@ -167,7 +167,7 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
|
|
|
167
167
|
if (noStyle || variant === 'plain') {
|
|
168
168
|
return renderedChildren;
|
|
169
169
|
}
|
|
170
|
-
return ((0, jsx_runtime_1.jsxs)(descriptions_1.DescriptionItem, { ...props, ref: wrapperRef, className: (0, utils_1.clsx)(form_style_1.classes.item, props.className), label: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRequired && !!requiredMark &&
|
|
170
|
+
return ((0, jsx_runtime_1.jsxs)(descriptions_1.DescriptionItem, { flex: void 0, ...props, ref: wrapperRef, className: (0, utils_1.clsx)(form_style_1.classes.item, props.className), label: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [isRequired && !!requiredMark &&
|
|
171
171
|
(0, jsx_runtime_1.jsx)("span", { className: form_style_1.classes.requiredMark, children: requiredMark }), label] }), children: [renderedChildren, (0, jsx_runtime_1.jsx)(transitionBase_1.Collapse, { in: innerError.current || !!helperText, children: (0, jsx_runtime_1.jsx)("div", { className: form_style_1.classes.helperText, children: innerHelperText.current }) })] }));
|
|
172
172
|
};
|
|
173
173
|
exports.FormItem = FormItem;
|
|
@@ -192,14 +192,15 @@ exports.Slider = (0, react_2.memo)(({ color = 'primary', orientation = 'horizont
|
|
|
192
192
|
};
|
|
193
193
|
return renderHandle
|
|
194
194
|
? renderHandle(value, _handleProps)
|
|
195
|
-
: (0,
|
|
195
|
+
: (0, react_1.createElement)(tooltip_1.Tooltip, { popperRef: r => {
|
|
196
196
|
if (r) {
|
|
197
197
|
tooltipRefs.current[index] = r;
|
|
198
198
|
}
|
|
199
199
|
else {
|
|
200
200
|
delete tooltipRefs.current[index];
|
|
201
201
|
}
|
|
202
|
-
}, title: valueIsArray ? innerValue.current[index] : innerValue.current, trigger: ['hover', 'focus'], placement: orientation === 'horizontal' ? 'top' : 'left', ...tooltipProps,
|
|
202
|
+
}, title: valueIsArray ? innerValue.current[index] : innerValue.current, trigger: ['hover', 'focus'], placement: orientation === 'horizontal' ? 'top' : 'left', ...tooltipProps, key: index },
|
|
203
|
+
(0, react_1.createElement)("button", { ..._handleProps, key: index }));
|
|
203
204
|
};
|
|
204
205
|
return valueIsArray
|
|
205
206
|
? innerValue.current.map(fn)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createElement as _createElement } from "@emotion/react";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
3
|
import { memo } from 'react';
|
|
3
4
|
import { classes, style } from './actionSheet.style';
|
|
@@ -31,10 +32,10 @@ export const ActionSheet = memo(({ ref, title, actions, placement = 'bottom', ma
|
|
|
31
32
|
confirmProps?.onClick?.(e);
|
|
32
33
|
onConfirm?.(e);
|
|
33
34
|
close('confirmed');
|
|
34
|
-
} }), actions?.map((menuItemProps, i) =>
|
|
35
|
+
} }), actions?.map((menuItemProps, i) => _createElement(MenuItem, { className: clsx(classes.action, menuItemProps.className), size: "large", ...menuItemProps, key: menuItemProps.key ?? i, onClick: e => {
|
|
35
36
|
menuItemProps.onClick?.(e);
|
|
36
37
|
onAction?.(menuItemProps);
|
|
37
38
|
close('action');
|
|
38
|
-
} }
|
|
39
|
+
} }))] }), showCancel &&
|
|
39
40
|
_jsx("div", { className: classes.card, children: _jsx(MenuItem, { color: "error", emphasized: true, size: "large", label: cancelText, ...cancelProps, onClick: cancelHandler }) })] }) }));
|
|
40
41
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "@emotion/react";
|
|
2
3
|
import { isValidElement, memo, useMemo, useRef, useState } from 'react';
|
|
3
4
|
import { Form, FormItem } from '../form';
|
|
4
5
|
import { classes } from './curd.style';
|
|
@@ -23,7 +24,7 @@ export const CurdFilter = memo(({ ref, columns, expandable, showButton, renderCo
|
|
|
23
24
|
const [expanded, setExpanded] = useState(false);
|
|
24
25
|
const renderedGrid = (_jsx(Grid, { className: classes.filterGrid, columnGap: spacing[8], children: items?.map((item, i) => isValidElement(item)
|
|
25
26
|
? item
|
|
26
|
-
:
|
|
27
|
+
: _createElement(FormItem, { span: { xs: 12, md: 6, lg: 4 }, ...item, key: item.key ?? i, wrapperRef: !i ? firstItemRef : void 0 })) }));
|
|
27
28
|
/**
|
|
28
29
|
* --------------------------------------------------------------
|
|
29
30
|
* 触发筛选
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { createElement as _createElement } from "@emotion/react";
|
|
2
3
|
import { Children, createContext, isValidElement, memo, useContext, useMemo } from 'react';
|
|
3
4
|
import { Grid } from '../grid';
|
|
4
5
|
import { DescriptionItem } from './descriptionItem';
|
|
@@ -16,9 +17,11 @@ export const Descriptions = memo(({ size, labelWidth, colon = ':', labelPlacemen
|
|
|
16
17
|
size, labelWidth, colon, labelPlacement, disableMargin, disablePadding, variant
|
|
17
18
|
]);
|
|
18
19
|
const renderGridItems = () => {
|
|
19
|
-
return items?.map((itemProps, i) =>
|
|
20
|
+
return items?.map((itemProps, i) => _createElement(ItemComponent
|
|
21
|
+
// 最后一项沾满剩余行空间
|
|
22
|
+
, {
|
|
20
23
|
// 最后一项沾满剩余行空间
|
|
21
|
-
flex: i === items.length - 1 ? 1 : void 0, ...itemProps
|
|
24
|
+
flex: i === items.length - 1 ? 1 : void 0, ...itemProps, key: itemProps.key ?? i })) || props.children;
|
|
22
25
|
};
|
|
23
26
|
const columnCountNum = useResponsiveValue(columnCount);
|
|
24
27
|
const renderTableItems = () => {
|
|
@@ -28,7 +31,9 @@ export const Descriptions = memo(({ size, labelWidth, colon = ':', labelPlacemen
|
|
|
28
31
|
for (let i = 0, { length } = actualItems; i < length; i++) {
|
|
29
32
|
const cols = rows[Math.floor(i / columnCountNum)] ||= [];
|
|
30
33
|
const itemProps = actualItems[i];
|
|
31
|
-
cols.push(
|
|
34
|
+
cols.push(_createElement(ItemComponent
|
|
35
|
+
// 最后一项沾满剩余行空间
|
|
36
|
+
, { ...itemProps, key: itemProps.key ?? i, span: i === actualItems.length - 1 ? columnCountNum - i % columnCountNum : itemProps.span, className: clsx(classes.col, itemProps) }));
|
|
32
37
|
}
|
|
33
38
|
return rows.map((r, i) => _jsx("tr", { children: r }, i));
|
|
34
39
|
}
|
|
@@ -69,7 +69,7 @@ export const gridItemStyle = defineCss(({ spacing, text }) => css `
|
|
|
69
69
|
flex-direction: row-reverse;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
&:not(
|
|
72
|
+
&:not([data-disable-margin=true]) {
|
|
73
73
|
&[data-label-placement=left], &[data-label-placement=right] {
|
|
74
74
|
margin-bottom: ${spacing[4]}px;
|
|
75
75
|
|
|
@@ -131,6 +131,7 @@ export const gridItemStyle = defineCss(({ spacing, text }) => css `
|
|
|
131
131
|
|
|
132
132
|
&[data-label-placement=left] {
|
|
133
133
|
.${classes.label} {
|
|
134
|
+
text-align: right;
|
|
134
135
|
justify-content: flex-end;
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -32,6 +32,7 @@ interface FormContext<V extends FormValue> extends FormSharedProps {
|
|
|
32
32
|
declare const FormContext: React.Context<FormContext<any>>;
|
|
33
33
|
export declare function useFormContext<V extends FormValue>(): FormContext<V>;
|
|
34
34
|
export type FormRef<V extends FormValue = FormValue> = {
|
|
35
|
+
/** 存在校验不通过的字段时会得到`null` */
|
|
35
36
|
submit(): Promise<V | null>;
|
|
36
37
|
getFieldValue<T = any>(field: FieldPath): T;
|
|
37
38
|
getFormValue(): V;
|
|
@@ -17,7 +17,7 @@ export const style = defineCss(({ colors, spacing }) => css `
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
.${classes.item} {
|
|
20
|
-
&:not(
|
|
20
|
+
&:not([data-disable-margin=true]) {
|
|
21
21
|
&[data-label-placement=left], &[data-label-placement=right] {
|
|
22
22
|
margin-bottom: ${spacing[6]}px;
|
|
23
23
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
import { cloneElement, isValidElement, useDeferredValue, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
3
3
|
import { useFormContext } from './form';
|
|
4
|
-
import { clsx, getValueOnChange, queryDeep, stringifyField, useDerivedState } from '../../utils';
|
|
4
|
+
import { clsx, getValueOnChange, queryDeep, stringifyField, useDerivedState, toArray } from '../../utils';
|
|
5
5
|
import { DescriptionItem } from '../descriptions';
|
|
6
6
|
import { classes } from './form.style';
|
|
7
7
|
import { Collapse } from '../transitionBase';
|
|
@@ -46,7 +46,7 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
|
|
|
46
46
|
* --------------------------------------------------------------------
|
|
47
47
|
* 校验
|
|
48
48
|
*/
|
|
49
|
-
const rulesArr =
|
|
49
|
+
const rulesArr = toArray(rules);
|
|
50
50
|
const [innerError, setInnerError] = useDerivedState(error);
|
|
51
51
|
const [innerHelperText, setInnerHelperText] = useDerivedState(helperText);
|
|
52
52
|
const validate = async () => {
|
|
@@ -164,6 +164,6 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
|
|
|
164
164
|
if (noStyle || variant === 'plain') {
|
|
165
165
|
return renderedChildren;
|
|
166
166
|
}
|
|
167
|
-
return (_jsxs(DescriptionItem, { ...props, ref: wrapperRef, className: clsx(classes.item, props.className), label: _jsxs(_Fragment, { children: [isRequired && !!requiredMark &&
|
|
167
|
+
return (_jsxs(DescriptionItem, { flex: void 0, ...props, ref: wrapperRef, className: clsx(classes.item, props.className), label: _jsxs(_Fragment, { children: [isRequired && !!requiredMark &&
|
|
168
168
|
_jsx("span", { className: classes.requiredMark, children: requiredMark }), label] }), children: [renderedChildren, _jsx(Collapse, { in: innerError.current || !!helperText, children: _jsx("div", { className: classes.helperText, children: innerHelperText.current }) })] }));
|
|
169
169
|
};
|
|
@@ -189,14 +189,15 @@ export const Slider = memo(({ color = 'primary', orientation = 'horizontal', var
|
|
|
189
189
|
};
|
|
190
190
|
return renderHandle
|
|
191
191
|
? renderHandle(value, _handleProps)
|
|
192
|
-
:
|
|
192
|
+
: _createElement(Tooltip, { popperRef: r => {
|
|
193
193
|
if (r) {
|
|
194
194
|
tooltipRefs.current[index] = r;
|
|
195
195
|
}
|
|
196
196
|
else {
|
|
197
197
|
delete tooltipRefs.current[index];
|
|
198
198
|
}
|
|
199
|
-
}, title: valueIsArray ? innerValue.current[index] : innerValue.current, trigger: ['hover', 'focus'], placement: orientation === 'horizontal' ? 'top' : 'left', ...tooltipProps,
|
|
199
|
+
}, title: valueIsArray ? innerValue.current[index] : innerValue.current, trigger: ['hover', 'focus'], placement: orientation === 'horizontal' ? 'top' : 'left', ...tooltipProps, key: index },
|
|
200
|
+
_createElement("button", { ..._handleProps, key: index }));
|
|
200
201
|
};
|
|
201
202
|
return valueIsArray
|
|
202
203
|
? innerValue.current.map(fn)
|