@canlooks/can-ui 0.0.60 → 0.0.62

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.
@@ -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, columnCount = 3, ...props }) => {
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), columnCount: columnCount, variant: "plain", onChange: changeHandler, children: !!items?.length &&
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) &&
@@ -17,10 +17,11 @@ variant, size, color, disabled, readOnly, autoFocus, ...props }) => {
17
17
  variant, size, color, disabled, readOnly
18
18
  };
19
19
  const showTimer = /[Hms]/.test(format);
20
+ console.log(innerValue.current?.[1].date());
20
21
  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
22
  startPickerProps?.onOpenChange?.(open);
22
23
  setInnerOpen(open ? 'start' : 'closed');
23
- }, onChange: startValue => {
24
+ }, value: innerValue.current?.[0], onChange: startValue => {
24
25
  startPickerProps?.onChange?.(startValue);
25
26
  setInnerValue(o => [startValue, o?.[1] || null]);
26
27
  if (startValue && !showTimer) {
@@ -30,7 +31,7 @@ variant, size, color, disabled, readOnly, autoFocus, ...props }) => {
30
31
  } }), 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
32
  startPickerProps?.onOpenChange?.(open);
32
33
  setInnerOpen(open ? 'end' : 'closed');
33
- }, onChange: endValue => {
34
+ }, value: innerValue.current?.[1], onChange: endValue => {
34
35
  endPickerProps?.onChange?.(endValue);
35
36
  setInnerValue(o => [o?.[0] || null, endValue]);
36
37
  }, 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
@@ -161,7 +161,7 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
161
161
  });
162
162
  }
163
163
  return children;
164
- }, [children, innerError.current, field, size, randomKey.current]);
164
+ }, [children, innerError.current, field, size, randomKey.current, fieldValue]);
165
165
  if (noStyle || variant === 'plain') {
166
166
  return renderedChildren;
167
167
  }
@@ -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, columnCount = 3, ...props }) => {
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), columnCount: columnCount, variant: "plain", onChange: changeHandler, children: !!items?.length &&
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) &&
@@ -14,10 +14,11 @@ variant, size, color, disabled, readOnly, autoFocus, ...props }) => {
14
14
  variant, size, color, disabled, readOnly
15
15
  };
16
16
  const showTimer = /[Hms]/.test(format);
17
+ console.log(innerValue.current?.[1].date());
17
18
  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
19
  startPickerProps?.onOpenChange?.(open);
19
20
  setInnerOpen(open ? 'start' : 'closed');
20
- }, onChange: startValue => {
21
+ }, value: innerValue.current?.[0], onChange: startValue => {
21
22
  startPickerProps?.onChange?.(startValue);
22
23
  setInnerValue(o => [startValue, o?.[1] || null]);
23
24
  if (startValue && !showTimer) {
@@ -27,7 +28,7 @@ variant, size, color, disabled, readOnly, autoFocus, ...props }) => {
27
28
  } }), 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
29
  startPickerProps?.onOpenChange?.(open);
29
30
  setInnerOpen(open ? 'end' : 'closed');
30
- }, onChange: endValue => {
31
+ }, value: innerValue.current?.[1], onChange: endValue => {
31
32
  endPickerProps?.onChange?.(endValue);
32
33
  setInnerValue(o => [o?.[0] || null, endValue]);
33
34
  }, 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
@@ -158,7 +158,7 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
158
158
  });
159
159
  }
160
160
  return children;
161
- }, [children, innerError.current, field, size, randomKey.current]);
161
+ }, [children, innerError.current, field, size, randomKey.current, fieldValue]);
162
162
  if (noStyle || variant === 'plain') {
163
163
  return renderedChildren;
164
164
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.60",
3
+ "version": "0.0.62",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",