@canlooks/can-ui 0.0.61 → 0.0.63
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/curd/curdFilter.js +2 -2
- package/dist/cjs/components/dataGrid/dataGrid.style.js +6 -0
- package/dist/cjs/components/dateTimeRangePicker/dateTimeRangePicker.js +2 -2
- package/dist/cjs/components/form/formItem.js +16 -16
- package/dist/esm/components/curd/curdFilter.js +2 -2
- package/dist/esm/components/dataGrid/dataGrid.style.js +6 -0
- package/dist/esm/components/dateTimeRangePicker/dateTimeRangePicker.js +2 -2
- package/dist/esm/components/form/formItem.js +16 -16
- package/package.json +1 -1
|
@@ -14,7 +14,7 @@ const theme_1 = require("../theme");
|
|
|
14
14
|
const __1 = require("../..");
|
|
15
15
|
const faChevronDown_1 = require("@fortawesome/free-solid-svg-icons/faChevronDown");
|
|
16
16
|
const faFilter_1 = require("@fortawesome/free-solid-svg-icons/faFilter");
|
|
17
|
-
exports.CurdFilter = (0, react_2.memo)(({ ref, columns, expandable, showButton, renderConditions, buttonProps, onFilter,
|
|
17
|
+
exports.CurdFilter = (0, react_2.memo)(({ ref, columns, expandable, showButton, renderConditions, buttonProps, onFilter, ...props }) => {
|
|
18
18
|
const { spacing } = (0, theme_1.useTheme)();
|
|
19
19
|
const items = (0, react_2.useMemo)(() => {
|
|
20
20
|
return (0, utils_1.columnsToFilterItem)(columns);
|
|
@@ -51,7 +51,7 @@ exports.CurdFilter = (0, react_2.memo)(({ ref, columns, expandable, showButton,
|
|
|
51
51
|
* 已生效的筛选条件
|
|
52
52
|
*/
|
|
53
53
|
const [filteredConditions, setFilteredConditions] = (0, react_2.useState)({});
|
|
54
|
-
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),
|
|
54
|
+
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), variant: "plain", onChange: changeHandler, children: !!items?.length &&
|
|
55
55
|
(0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [expandable
|
|
56
56
|
? (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 })
|
|
57
57
|
: renderedGrid, (expandable || showButton) &&
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.style = exports.classes = void 0;
|
|
4
4
|
const react_1 = require("@emotion/react");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
|
+
const loading_style_1 = require("../loading/loading.style");
|
|
6
7
|
exports.classes = (0, utils_1.defineInnerClasses)('data-grid', [
|
|
7
8
|
'container',
|
|
8
9
|
'title',
|
|
@@ -20,6 +21,11 @@ exports.classes = (0, utils_1.defineInnerClasses)('data-grid', [
|
|
|
20
21
|
exports.style = (0, utils_1.defineCss)(({ spacing, mode, gray, text, colors, easing }) => (0, react_1.css) `
|
|
21
22
|
max-height: 100%;
|
|
22
23
|
min-height: 0;
|
|
24
|
+
|
|
25
|
+
.${loading_style_1.classes.container} {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
}
|
|
23
29
|
|
|
24
30
|
.${exports.classes.container} {
|
|
25
31
|
flex: 1;
|
|
@@ -20,7 +20,7 @@ variant, size, color, disabled, readOnly, autoFocus, ...props }) => {
|
|
|
20
20
|
return ((0, jsx_runtime_1.jsxs)("div", { ...props, css: dateTimeRangePicker_style_1.style, className: (0, utils_1.clsx)(dateTimeRangePicker_style_1.classes.root, props.className), children: [(0, jsx_runtime_1.jsx)(dateTimePicker_1.DateTimePicker, { ...commonProps, autoFocus: autoFocus, autoClose: false, placeholder: showTimer ? '开始时间' : '开始日期', max: innerValue.current?.[1] || void 0, open: innerOpen.current === 'start', ...startPickerProps, onOpenChange: open => {
|
|
21
21
|
startPickerProps?.onOpenChange?.(open);
|
|
22
22
|
setInnerOpen(open ? 'start' : 'closed');
|
|
23
|
-
}, onChange: startValue => {
|
|
23
|
+
}, value: innerValue.current?.[0], onChange: startValue => {
|
|
24
24
|
startPickerProps?.onChange?.(startValue);
|
|
25
25
|
setInnerValue(o => [startValue, o?.[1] || null]);
|
|
26
26
|
if (startValue && !showTimer) {
|
|
@@ -30,7 +30,7 @@ variant, size, color, disabled, readOnly, autoFocus, ...props }) => {
|
|
|
30
30
|
} }), separator ?? (0, jsx_runtime_1.jsx)("span", { children: "-" }), (0, jsx_runtime_1.jsx)(dateTimePicker_1.DateTimePicker, { ...commonProps, autoClose: autoClose, placeholder: showTimer ? '结束时间' : '结束日期', min: innerValue.current?.[0] || void 0, open: innerOpen.current === 'end', ...endPickerProps, inputProps: { ref: endPickerInputRef }, onOpenChange: open => {
|
|
31
31
|
startPickerProps?.onOpenChange?.(open);
|
|
32
32
|
setInnerOpen(open ? 'end' : 'closed');
|
|
33
|
-
}, onChange: endValue => {
|
|
33
|
+
}, value: innerValue.current?.[1], onChange: endValue => {
|
|
34
34
|
endPickerProps?.onChange?.(endValue);
|
|
35
35
|
setInnerValue(o => [o?.[0] || null, endValue]);
|
|
36
36
|
}, popperProps: {
|
|
@@ -13,6 +13,22 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
|
|
|
13
13
|
requiredMark ??= context.requiredMark ?? '*';
|
|
14
14
|
variant ??= context.variant ?? 'grid';
|
|
15
15
|
size ??= context.size;
|
|
16
|
+
const shouldValidate = (0, react_1.useRef)(false);
|
|
17
|
+
const [innerError, setInnerError] = (0, utils_1.useDerivedState)(error);
|
|
18
|
+
/**
|
|
19
|
+
* --------------------------------------------------------------------
|
|
20
|
+
* 重置与初始化
|
|
21
|
+
*/
|
|
22
|
+
const isTouched = (0, react_1.useRef)(false);
|
|
23
|
+
// formRef的resetForm()方法会传入新的initialValue,否则使用`formValue`
|
|
24
|
+
const reset = (value = formValue) => {
|
|
25
|
+
shouldValidate.current = isTouched.current = false;
|
|
26
|
+
if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
|
|
27
|
+
(0, utils_1.queryDeep)(value, field, () => initialValue);
|
|
28
|
+
}
|
|
29
|
+
innerError.current && setInnerError(false);
|
|
30
|
+
};
|
|
31
|
+
(0, react_1.useMemo)(reset, []);
|
|
16
32
|
/**
|
|
17
33
|
* --------------------------------------------------------------------
|
|
18
34
|
* 字段值
|
|
@@ -31,7 +47,6 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
|
|
|
31
47
|
* 校验
|
|
32
48
|
*/
|
|
33
49
|
const rulesArr = (0, utils_1.toArray)(rules);
|
|
34
|
-
const [innerError, setInnerError] = (0, utils_1.useDerivedState)(error);
|
|
35
50
|
const [innerHelperText, setInnerHelperText] = (0, utils_1.useDerivedState)(helperText);
|
|
36
51
|
const validate = async () => {
|
|
37
52
|
if (error) {
|
|
@@ -73,7 +88,6 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
|
|
|
73
88
|
* --------------------------------------------------------------------
|
|
74
89
|
* 依赖更新自动校验
|
|
75
90
|
*/
|
|
76
|
-
const shouldValidate = (0, react_1.useRef)(false);
|
|
77
91
|
const dependencyValues = (0, react_1.useMemo)(() => {
|
|
78
92
|
return formValue && dependencies?.map(d => (0, utils_1.queryDeep)(formValue, d));
|
|
79
93
|
}, [formValue, ...dependencies || []]);
|
|
@@ -82,20 +96,6 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
|
|
|
82
96
|
shouldValidate.current && validate().then();
|
|
83
97
|
shouldValidate.current = true;
|
|
84
98
|
}, [fieldValue, ...dependencyValues || []]);
|
|
85
|
-
/**
|
|
86
|
-
* --------------------------------------------------------------------
|
|
87
|
-
* 重置与初始化
|
|
88
|
-
*/
|
|
89
|
-
const isTouched = (0, react_1.useRef)(false);
|
|
90
|
-
// formRef的resetForm()方法会传入新的initialValue,否则使用`formValue`
|
|
91
|
-
const reset = (value = formValue) => {
|
|
92
|
-
shouldValidate.current = isTouched.current = false;
|
|
93
|
-
if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
|
|
94
|
-
(0, utils_1.queryDeep)(value, field, () => initialValue);
|
|
95
|
-
}
|
|
96
|
-
innerError.current && setInnerError(false);
|
|
97
|
-
};
|
|
98
|
-
(0, react_1.useMemo)(reset, []);
|
|
99
99
|
/**
|
|
100
100
|
* --------------------------------------------------------------------
|
|
101
101
|
* 挂载formItemRef
|
|
@@ -11,7 +11,7 @@ import { useTheme } from '../theme';
|
|
|
11
11
|
import { Icon } from '../..';
|
|
12
12
|
import { faChevronDown } from '@fortawesome/free-solid-svg-icons/faChevronDown';
|
|
13
13
|
import { faFilter } from '@fortawesome/free-solid-svg-icons/faFilter';
|
|
14
|
-
export const CurdFilter = memo(({ ref, columns, expandable, showButton, renderConditions, buttonProps, onFilter,
|
|
14
|
+
export const CurdFilter = memo(({ ref, columns, expandable, showButton, renderConditions, buttonProps, onFilter, ...props }) => {
|
|
15
15
|
const { spacing } = useTheme();
|
|
16
16
|
const items = useMemo(() => {
|
|
17
17
|
return columnsToFilterItem(columns);
|
|
@@ -48,7 +48,7 @@ export const CurdFilter = memo(({ ref, columns, expandable, showButton, renderCo
|
|
|
48
48
|
* 已生效的筛选条件
|
|
49
49
|
*/
|
|
50
50
|
const [filteredConditions, setFilteredConditions] = useState({});
|
|
51
|
-
return (_jsxs(_Fragment, { children: [_jsx(Form, { ...props, ref: cloneRef(ref, formRef), className: clsx(classes.filter, props.className),
|
|
51
|
+
return (_jsxs(_Fragment, { children: [_jsx(Form, { ...props, ref: cloneRef(ref, formRef), className: clsx(classes.filter, props.className), variant: "plain", onChange: changeHandler, children: !!items?.length &&
|
|
52
52
|
_jsxs(_Fragment, { children: [expandable
|
|
53
53
|
? _jsx(Collapse, { className: classes.filterGridContainer, in: expanded, collapsedSize: () => firstItemRef.current?.offsetHeight || 56, appear: false, children: renderedGrid })
|
|
54
54
|
: renderedGrid, (expandable || showButton) &&
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
import { defineInnerClasses, defineCss } from '../../utils';
|
|
3
|
+
import { classes as loadingClasses } from '../loading/loading.style';
|
|
3
4
|
export const classes = defineInnerClasses('data-grid', [
|
|
4
5
|
'container',
|
|
5
6
|
'title',
|
|
@@ -17,6 +18,11 @@ export const classes = defineInnerClasses('data-grid', [
|
|
|
17
18
|
export const style = defineCss(({ spacing, mode, gray, text, colors, easing }) => css `
|
|
18
19
|
max-height: 100%;
|
|
19
20
|
min-height: 0;
|
|
21
|
+
|
|
22
|
+
.${loadingClasses.container} {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
}
|
|
20
26
|
|
|
21
27
|
.${classes.container} {
|
|
22
28
|
flex: 1;
|
|
@@ -17,7 +17,7 @@ variant, size, color, disabled, readOnly, autoFocus, ...props }) => {
|
|
|
17
17
|
return (_jsxs("div", { ...props, css: style, className: clsx(classes.root, props.className), children: [_jsx(DateTimePicker, { ...commonProps, autoFocus: autoFocus, autoClose: false, placeholder: showTimer ? '开始时间' : '开始日期', max: innerValue.current?.[1] || void 0, open: innerOpen.current === 'start', ...startPickerProps, onOpenChange: open => {
|
|
18
18
|
startPickerProps?.onOpenChange?.(open);
|
|
19
19
|
setInnerOpen(open ? 'start' : 'closed');
|
|
20
|
-
}, onChange: startValue => {
|
|
20
|
+
}, value: innerValue.current?.[0], onChange: startValue => {
|
|
21
21
|
startPickerProps?.onChange?.(startValue);
|
|
22
22
|
setInnerValue(o => [startValue, o?.[1] || null]);
|
|
23
23
|
if (startValue && !showTimer) {
|
|
@@ -27,7 +27,7 @@ variant, size, color, disabled, readOnly, autoFocus, ...props }) => {
|
|
|
27
27
|
} }), separator ?? _jsx("span", { children: "-" }), _jsx(DateTimePicker, { ...commonProps, autoClose: autoClose, placeholder: showTimer ? '结束时间' : '结束日期', min: innerValue.current?.[0] || void 0, open: innerOpen.current === 'end', ...endPickerProps, inputProps: { ref: endPickerInputRef }, onOpenChange: open => {
|
|
28
28
|
startPickerProps?.onOpenChange?.(open);
|
|
29
29
|
setInnerOpen(open ? 'end' : 'closed');
|
|
30
|
-
}, onChange: endValue => {
|
|
30
|
+
}, value: innerValue.current?.[1], onChange: endValue => {
|
|
31
31
|
endPickerProps?.onChange?.(endValue);
|
|
32
32
|
setInnerValue(o => [o?.[0] || null, endValue]);
|
|
33
33
|
}, popperProps: {
|
|
@@ -10,6 +10,22 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
|
|
|
10
10
|
requiredMark ??= context.requiredMark ?? '*';
|
|
11
11
|
variant ??= context.variant ?? 'grid';
|
|
12
12
|
size ??= context.size;
|
|
13
|
+
const shouldValidate = useRef(false);
|
|
14
|
+
const [innerError, setInnerError] = useDerivedState(error);
|
|
15
|
+
/**
|
|
16
|
+
* --------------------------------------------------------------------
|
|
17
|
+
* 重置与初始化
|
|
18
|
+
*/
|
|
19
|
+
const isTouched = useRef(false);
|
|
20
|
+
// formRef的resetForm()方法会传入新的initialValue,否则使用`formValue`
|
|
21
|
+
const reset = (value = formValue) => {
|
|
22
|
+
shouldValidate.current = isTouched.current = false;
|
|
23
|
+
if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
|
|
24
|
+
queryDeep(value, field, () => initialValue);
|
|
25
|
+
}
|
|
26
|
+
innerError.current && setInnerError(false);
|
|
27
|
+
};
|
|
28
|
+
useMemo(reset, []);
|
|
13
29
|
/**
|
|
14
30
|
* --------------------------------------------------------------------
|
|
15
31
|
* 字段值
|
|
@@ -28,7 +44,6 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
|
|
|
28
44
|
* 校验
|
|
29
45
|
*/
|
|
30
46
|
const rulesArr = toArray(rules);
|
|
31
|
-
const [innerError, setInnerError] = useDerivedState(error);
|
|
32
47
|
const [innerHelperText, setInnerHelperText] = useDerivedState(helperText);
|
|
33
48
|
const validate = async () => {
|
|
34
49
|
if (error) {
|
|
@@ -70,7 +85,6 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
|
|
|
70
85
|
* --------------------------------------------------------------------
|
|
71
86
|
* 依赖更新自动校验
|
|
72
87
|
*/
|
|
73
|
-
const shouldValidate = useRef(false);
|
|
74
88
|
const dependencyValues = useMemo(() => {
|
|
75
89
|
return formValue && dependencies?.map(d => queryDeep(formValue, d));
|
|
76
90
|
}, [formValue, ...dependencies || []]);
|
|
@@ -79,20 +93,6 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
|
|
|
79
93
|
shouldValidate.current && validate().then();
|
|
80
94
|
shouldValidate.current = true;
|
|
81
95
|
}, [fieldValue, ...dependencyValues || []]);
|
|
82
|
-
/**
|
|
83
|
-
* --------------------------------------------------------------------
|
|
84
|
-
* 重置与初始化
|
|
85
|
-
*/
|
|
86
|
-
const isTouched = useRef(false);
|
|
87
|
-
// formRef的resetForm()方法会传入新的initialValue,否则使用`formValue`
|
|
88
|
-
const reset = (value = formValue) => {
|
|
89
|
-
shouldValidate.current = isTouched.current = false;
|
|
90
|
-
if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
|
|
91
|
-
queryDeep(value, field, () => initialValue);
|
|
92
|
-
}
|
|
93
|
-
innerError.current && setInnerError(false);
|
|
94
|
-
};
|
|
95
|
-
useMemo(reset, []);
|
|
96
96
|
/**
|
|
97
97
|
* --------------------------------------------------------------------
|
|
98
98
|
* 挂载formItemRef
|