@canlooks/can-ui 0.0.28 → 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.
@@ -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(:last-of-type):not([data-disable-margin=true]) {
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
 
@@ -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(:last-of-type):not([data-disable-margin=true]) {
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 = Array.isArray(rules) ? rules : rules && [rules];
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;
@@ -69,7 +69,7 @@ export const gridItemStyle = defineCss(({ spacing, text }) => css `
69
69
  flex-direction: row-reverse;
70
70
  }
71
71
 
72
- &:not(:last-of-type):not([data-disable-margin=true]) {
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
 
@@ -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(:last-of-type):not([data-disable-margin=true]) {
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 = Array.isArray(rules) ? rules : rules && [rules];
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canlooks/can-ui",
3
- "version": "0.0.28",
3
+ "version": "0.0.29",
4
4
  "author": "C.CanLiang <canlooks@gmail.com>",
5
5
  "description": "My ui framework",
6
6
  "license": "MIT",