@canlooks/can-ui 0.0.56 → 0.0.58

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.
@@ -81,6 +81,7 @@ inline, columnCount = 1, gap, columnGap, rowGap, ...props }) => {
81
81
  for (const [, item] of itemsContainer.current) {
82
82
  item.reset(newValue);
83
83
  }
84
+ console.log('after', newValue);
84
85
  setFormValue(newValue);
85
86
  },
86
87
  resetField: field => {
@@ -10,7 +10,6 @@ export type FormItemRules<I = any> = {
10
10
  validator?(fieldValue: I | undefined, formValue: any, formRef: FormRef | null): any;
11
11
  };
12
12
  export type FieldProps<I = any> = {
13
- key?: string;
14
13
  checked?: boolean;
15
14
  value?: I;
16
15
  onChange?(e: any): void;
@@ -29,7 +28,11 @@ export interface FormItemOwnProps<I = any> extends FormSharedProps {
29
28
  error?: boolean;
30
29
  helperText?: ReactNode;
31
30
  dependencies?: FieldPath[];
32
- children?: ReactNode | ((fieldProps: FieldProps<I>, styleProps: StyleProps) => ReactNode);
31
+ /**
32
+ * 若`children`为`function`类型时,第三个参数`key`主要用于强制重渲染,
33
+ * 在没有{@link initialValue}时非常有用
34
+ */
35
+ children?: ReactNode | ((fieldProps: FieldProps<I>, styleProps: StyleProps, key?: string) => ReactNode);
33
36
  noStyle?: boolean;
34
37
  }
35
38
  export type FormItemProps<I = any, C extends ElementType = 'div'> = MergeProps<FormItemOwnProps<I>, DescriptionItemProps<C>>;
@@ -89,7 +89,7 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
89
89
  // formRef的resetForm()方法会传入新的initialValue,否则使用`formValue`
90
90
  const reset = (value = formValue) => {
91
91
  shouldValidate.current = isTouched.current = false;
92
- if (typeof field !== 'undefined' && value) {
92
+ if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
93
93
  (0, utils_1.queryDeep)(value, field, () => initialValue);
94
94
  }
95
95
  innerError.current && setInnerError(false);
@@ -128,7 +128,6 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
128
128
  if (typeof children === 'function') {
129
129
  return children(typeof field !== 'undefined'
130
130
  ? {
131
- key: randomKey.current,
132
131
  ...typeof fieldValue === 'boolean'
133
132
  ? { checked: fieldValue }
134
133
  : { value: fieldValue },
@@ -140,7 +139,7 @@ const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rules, req
140
139
  : {}, {
141
140
  ...props.size && { size: props.size },
142
141
  ...innerError.current ? { color: 'error' } : {}
143
- });
142
+ }, randomKey.current);
144
143
  }
145
144
  if ((0, react_1.isValidElement)(children)) {
146
145
  const { props: childProps } = children;
@@ -46,6 +46,7 @@ export * from './components/input';
46
46
  export * from './components/inputBase';
47
47
  export * from './components/loading';
48
48
  export * from './components/loadingIndicator';
49
+ export * from './components/loadingMask';
49
50
  export * from './components/menu';
50
51
  export * from './components/menuItem';
51
52
  export * from './components/modal';
package/dist/cjs/index.js CHANGED
@@ -49,6 +49,7 @@ tslib_1.__exportStar(require("./components/input"), exports);
49
49
  tslib_1.__exportStar(require("./components/inputBase"), exports);
50
50
  tslib_1.__exportStar(require("./components/loading"), exports);
51
51
  tslib_1.__exportStar(require("./components/loadingIndicator"), exports);
52
+ tslib_1.__exportStar(require("./components/loadingMask"), exports);
52
53
  tslib_1.__exportStar(require("./components/menu"), exports);
53
54
  tslib_1.__exportStar(require("./components/menuItem"), exports);
54
55
  tslib_1.__exportStar(require("./components/modal"), exports);
@@ -77,6 +77,7 @@ inline, columnCount = 1, gap, columnGap, rowGap, ...props }) => {
77
77
  for (const [, item] of itemsContainer.current) {
78
78
  item.reset(newValue);
79
79
  }
80
+ console.log('after', newValue);
80
81
  setFormValue(newValue);
81
82
  },
82
83
  resetField: field => {
@@ -10,7 +10,6 @@ export type FormItemRules<I = any> = {
10
10
  validator?(fieldValue: I | undefined, formValue: any, formRef: FormRef | null): any;
11
11
  };
12
12
  export type FieldProps<I = any> = {
13
- key?: string;
14
13
  checked?: boolean;
15
14
  value?: I;
16
15
  onChange?(e: any): void;
@@ -29,7 +28,11 @@ export interface FormItemOwnProps<I = any> extends FormSharedProps {
29
28
  error?: boolean;
30
29
  helperText?: ReactNode;
31
30
  dependencies?: FieldPath[];
32
- children?: ReactNode | ((fieldProps: FieldProps<I>, styleProps: StyleProps) => ReactNode);
31
+ /**
32
+ * 若`children`为`function`类型时,第三个参数`key`主要用于强制重渲染,
33
+ * 在没有{@link initialValue}时非常有用
34
+ */
35
+ children?: ReactNode | ((fieldProps: FieldProps<I>, styleProps: StyleProps, key?: string) => ReactNode);
33
36
  noStyle?: boolean;
34
37
  }
35
38
  export type FormItemProps<I = any, C extends ElementType = 'div'> = MergeProps<FormItemOwnProps<I>, DescriptionItemProps<C>>;
@@ -86,7 +86,7 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
86
86
  // formRef的resetForm()方法会传入新的initialValue,否则使用`formValue`
87
87
  const reset = (value = formValue) => {
88
88
  shouldValidate.current = isTouched.current = false;
89
- if (typeof field !== 'undefined' && value) {
89
+ if (typeof field !== 'undefined' && value && typeof initialValue !== 'undefined') {
90
90
  queryDeep(value, field, () => initialValue);
91
91
  }
92
92
  innerError.current && setInnerError(false);
@@ -125,7 +125,6 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
125
125
  if (typeof children === 'function') {
126
126
  return children(typeof field !== 'undefined'
127
127
  ? {
128
- key: randomKey.current,
129
128
  ...typeof fieldValue === 'boolean'
130
129
  ? { checked: fieldValue }
131
130
  : { value: fieldValue },
@@ -137,7 +136,7 @@ export const FormItem = ({ ref, wrapperRef, field, initialValue, label = '', rul
137
136
  : {}, {
138
137
  ...props.size && { size: props.size },
139
138
  ...innerError.current ? { color: 'error' } : {}
140
- });
139
+ }, randomKey.current);
141
140
  }
142
141
  if (isValidElement(children)) {
143
142
  const { props: childProps } = children;
@@ -46,6 +46,7 @@ export * from './components/input';
46
46
  export * from './components/inputBase';
47
47
  export * from './components/loading';
48
48
  export * from './components/loadingIndicator';
49
+ export * from './components/loadingMask';
49
50
  export * from './components/menu';
50
51
  export * from './components/menuItem';
51
52
  export * from './components/modal';
package/dist/esm/index.js CHANGED
@@ -46,6 +46,7 @@ export * from './components/input';
46
46
  export * from './components/inputBase';
47
47
  export * from './components/loading';
48
48
  export * from './components/loadingIndicator';
49
+ export * from './components/loadingMask';
49
50
  export * from './components/menu';
50
51
  export * from './components/menuItem';
51
52
  export * from './components/modal';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.56",
3
+ "version": "0.0.58",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",