@canlooks/can-ui 0.0.33 → 0.0.34

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.
@@ -31,7 +31,7 @@ function InnerApp({ component: Component = 'div', theme, children, fill = true,
31
31
  dialog: exports.App.dialog = new appDialog_1.AppDialogMethods(),
32
32
  message: exports.App.message = new appMessage_1.AppMessageMethods(),
33
33
  notification: exports.App.notification = new appNotification_1.AppNotificationMethods(),
34
- actionSheet: exports.App.actionSheet = new appActionSheet_1.AppActionSheetMethods(),
34
+ actionSheet: exports.App.actionSheet = new appActionSheet_1.AppActionSheetMethods()
35
35
  }), []);
36
36
  return ((0, jsx_runtime_1.jsxs)(AppContext, { value: appValue, children: [Component
37
37
  ? (0, jsx_runtime_1.jsx)(Component, { ...props, css: [
@@ -6,11 +6,16 @@ const react_1 = require("react");
6
6
  const dialog_1 = require("../dialog");
7
7
  const status_1 = require("../status");
8
8
  class AppDialogMethods {
9
- async info(props, ...args) { }
10
- async success(props, ...args) { }
11
- async warning(props, ...args) { }
12
- async error(props, ...args) { }
13
- async confirm(props, ...args) { }
9
+ async info(props, ...args) {
10
+ }
11
+ async success(props, ...args) {
12
+ }
13
+ async warning(props, ...args) {
14
+ }
15
+ async error(props, ...args) {
16
+ }
17
+ async confirm(props, ...args) {
18
+ }
14
19
  }
15
20
  exports.AppDialogMethods = AppDialogMethods;
16
21
  exports.AppDialog = (0, react_1.memo)(({ methods }) => {
@@ -12,21 +12,6 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
12
12
  const { formValue, setFieldValue, itemsContainer, formRef, ...context } = (0, form_1.useFormContext)();
13
13
  requiredMark ??= context.requiredMark ?? '*';
14
14
  variant ??= context.variant ?? 'grid';
15
- /**
16
- * --------------------------------------------------------------------
17
- * 重置与初始化
18
- */
19
- const shouldValidate = (0, react_1.useRef)(false);
20
- const isTouched = (0, react_1.useRef)(false);
21
- // formRef的resetForm()方法会传入新的initialValue
22
- const reset = (value = formValue) => {
23
- shouldValidate.current = isTouched.current = false;
24
- if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
25
- (0, utils_1.queryDeep)(value, field, () => initialValue);
26
- }
27
- innerError.current && setInnerError(false);
28
- };
29
- (0, react_1.useMemo)(reset, []);
30
15
  /**
31
16
  * --------------------------------------------------------------------
32
17
  * 字段值
@@ -83,13 +68,29 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
83
68
  * --------------------------------------------------------------------
84
69
  * 依赖更新自动校验
85
70
  */
71
+ const shouldValidate = (0, react_1.useRef)(false);
86
72
  const dependencyValues = (0, react_1.useMemo)(() => {
87
73
  return formValue && dependencies?.map(d => (0, utils_1.queryDeep)(formValue, d));
88
74
  }, [formValue, ...dependencies || []]);
89
75
  (0, react_1.useMemo)(() => {
76
+ // 跳过首次渲染
90
77
  shouldValidate.current && validate().then();
91
78
  shouldValidate.current = true;
92
79
  }, [fieldValue, ...dependencyValues || []]);
80
+ /**
81
+ * --------------------------------------------------------------------
82
+ * 重置与初始化
83
+ */
84
+ const isTouched = (0, react_1.useRef)(false);
85
+ // formRef的resetForm()方法会传入新的initialValue,否则使用`formValue`
86
+ const reset = (value = formValue) => {
87
+ shouldValidate.current = isTouched.current = false;
88
+ if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
89
+ (0, utils_1.queryDeep)(value, field, () => initialValue);
90
+ }
91
+ innerError.current && setInnerError(false);
92
+ };
93
+ (0, react_1.useMemo)(reset, []);
93
94
  /**
94
95
  * --------------------------------------------------------------------
95
96
  * 挂载formItemRef
@@ -26,7 +26,7 @@ export function InnerApp({ component: Component = 'div', theme, children, fill =
26
26
  dialog: App.dialog = new AppDialogMethods(),
27
27
  message: App.message = new AppMessageMethods(),
28
28
  notification: App.notification = new AppNotificationMethods(),
29
- actionSheet: App.actionSheet = new AppActionSheetMethods(),
29
+ actionSheet: App.actionSheet = new AppActionSheetMethods()
30
30
  }), []);
31
31
  return (_jsxs(AppContext, { value: appValue, children: [Component
32
32
  ? _jsx(Component, { ...props, css: [
@@ -3,11 +3,16 @@ import { memo, useState } from 'react';
3
3
  import { Dialog } from '../dialog';
4
4
  import { StatusIcon } from '../status';
5
5
  export class AppDialogMethods {
6
- async info(props, ...args) { }
7
- async success(props, ...args) { }
8
- async warning(props, ...args) { }
9
- async error(props, ...args) { }
10
- async confirm(props, ...args) { }
6
+ async info(props, ...args) {
7
+ }
8
+ async success(props, ...args) {
9
+ }
10
+ async warning(props, ...args) {
11
+ }
12
+ async error(props, ...args) {
13
+ }
14
+ async confirm(props, ...args) {
15
+ }
11
16
  }
12
17
  export const AppDialog = memo(({ methods }) => {
13
18
  const [stacks, setStacks] = useState([]);
@@ -9,21 +9,6 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
9
9
  const { formValue, setFieldValue, itemsContainer, formRef, ...context } = useFormContext();
10
10
  requiredMark ??= context.requiredMark ?? '*';
11
11
  variant ??= context.variant ?? 'grid';
12
- /**
13
- * --------------------------------------------------------------------
14
- * 重置与初始化
15
- */
16
- const shouldValidate = useRef(false);
17
- const isTouched = useRef(false);
18
- // formRef的resetForm()方法会传入新的initialValue
19
- const reset = (value = formValue) => {
20
- shouldValidate.current = isTouched.current = false;
21
- if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
22
- queryDeep(value, field, () => initialValue);
23
- }
24
- innerError.current && setInnerError(false);
25
- };
26
- useMemo(reset, []);
27
12
  /**
28
13
  * --------------------------------------------------------------------
29
14
  * 字段值
@@ -80,13 +65,29 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
80
65
  * --------------------------------------------------------------------
81
66
  * 依赖更新自动校验
82
67
  */
68
+ const shouldValidate = useRef(false);
83
69
  const dependencyValues = useMemo(() => {
84
70
  return formValue && dependencies?.map(d => queryDeep(formValue, d));
85
71
  }, [formValue, ...dependencies || []]);
86
72
  useMemo(() => {
73
+ // 跳过首次渲染
87
74
  shouldValidate.current && validate().then();
88
75
  shouldValidate.current = true;
89
76
  }, [fieldValue, ...dependencyValues || []]);
77
+ /**
78
+ * --------------------------------------------------------------------
79
+ * 重置与初始化
80
+ */
81
+ const isTouched = useRef(false);
82
+ // formRef的resetForm()方法会传入新的initialValue,否则使用`formValue`
83
+ const reset = (value = formValue) => {
84
+ shouldValidate.current = isTouched.current = false;
85
+ if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
86
+ queryDeep(value, field, () => initialValue);
87
+ }
88
+ innerError.current && setInnerError(false);
89
+ };
90
+ useMemo(reset, []);
90
91
  /**
91
92
  * --------------------------------------------------------------------
92
93
  * 挂载formItemRef