@canlooks/can-ui 0.0.26 → 0.0.27

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.
@@ -1,5 +1,5 @@
1
- import { ReactElement, ReactNode, ElementType } from 'react';
2
- import { MergeProps, Obj, OverridableProps, ResponsiveProp, Size } from '../../types';
1
+ import { ReactElement, ReactNode, ElementType, ComponentPropsWithRef } from 'react';
2
+ import { Obj, ResponsiveProp, Size } from '../../types';
3
3
  import { GridProps } from '../grid';
4
4
  import { DescriptionItem, DescriptionItemProps } from './descriptionItem';
5
5
  export type DescriptionsSharedProps = {
@@ -14,7 +14,7 @@ export type DescriptionsSharedProps = {
14
14
  /** 是否禁用padding,{@link DescriptionsProps.variant}为table有效 */
15
15
  disablePadding?: boolean;
16
16
  };
17
- export interface DescriptionsBaseProps extends DescriptionsSharedProps {
17
+ interface DescriptionsBaseProps extends DescriptionsSharedProps {
18
18
  items?: (DescriptionItemProps & Obj)[];
19
19
  /**
20
20
  * @private 用于渲染item的组件,通常为内部使用
@@ -22,21 +22,21 @@ export interface DescriptionsBaseProps extends DescriptionsSharedProps {
22
22
  */
23
23
  itemComponent?: ElementType;
24
24
  }
25
- export interface DescriptionsGridOwnProps extends DescriptionsBaseProps {
25
+ interface DescriptionsGridProps extends DescriptionsBaseProps, GridProps {
26
26
  variant?: 'grid';
27
27
  }
28
- export interface DescriptionsTableProps extends DescriptionsBaseProps {
28
+ interface DescriptionsTableProps extends DescriptionsBaseProps, ComponentPropsWithRef<'table'> {
29
29
  variant: 'table';
30
30
  columnCount?: ResponsiveProp;
31
31
  }
32
- export type DescriptionsProps<C extends ElementType = 'div' | 'table'> = MergeProps<DescriptionsGridOwnProps, GridProps<C>> | OverridableProps<DescriptionsTableProps, C>;
32
+ export type DescriptionsProps = DescriptionsGridProps | DescriptionsTableProps;
33
33
  interface DescriptionsContext extends DescriptionsSharedProps {
34
34
  variant?: 'grid' | 'table';
35
35
  }
36
36
  export declare function useDescriptionsContext(): DescriptionsContext;
37
37
  declare const DescriptionsContext: import("react").Context<DescriptionsContext>;
38
38
  export declare const Descriptions: {
39
- <C extends ElementType = "div">(props: DescriptionsProps<C>): ReactElement;
39
+ (props: DescriptionsProps): ReactElement;
40
40
  Item: typeof DescriptionItem;
41
41
  };
42
42
  export {};
@@ -1,16 +1,18 @@
1
1
  import React, { Dispatch, ReactElement, ReactNode, Ref, RefObject, SetStateAction, ElementType } from 'react';
2
- import { MergeProps, Obj } from '../../types';
2
+ import { Obj, OverridableProps } from '../../types';
3
3
  import { FieldPath } from '../../utils';
4
4
  import { FieldError, FormItem, FormItemProps, FormItemRef } from './formItem';
5
5
  import { FormRelatable } from './formRelatable';
6
- import { DescriptionsProps } from '../descriptions';
6
+ import { DescriptionsProps, DescriptionsSharedProps } from '../descriptions';
7
+ import { GridOwnProps } from '../grid';
7
8
  export type FormValue = Obj;
8
9
  export type FormSharedProps = {
10
+ /** 必填字段的标记,默认为`*` */
9
11
  requiredMark?: ReactNode;
10
12
  /** variant为"grid"或"table"时会渲染Descriptions组件,并传递variant属性,默认为`grid` */
11
13
  variant?: 'plain' | 'grid' | 'table';
12
14
  };
13
- export interface FormOwnProps<V extends FormValue = FormValue> extends FormSharedProps {
15
+ interface FormOwnProps<V extends FormValue = FormValue> extends FormSharedProps, DescriptionsSharedProps, GridOwnProps {
14
16
  ref?: Ref<FormRef<V> | null>;
15
17
  /** 最外层元素的ref,默认{@link ref}属性已经被{@link FormRef}取代 */
16
18
  wrapperRef?: Ref<HTMLFormElement>;
@@ -20,9 +22,8 @@ export interface FormOwnProps<V extends FormValue = FormValue> extends FormShare
20
22
  items?: (FormItemProps & Obj)[];
21
23
  descriptionsProps?: DescriptionsProps;
22
24
  }
23
- export type FormProps<V extends FormValue = FormValue, C extends ElementType = 'form'> = MergeProps<FormOwnProps<V>, DescriptionsProps<C>>;
25
+ export type FormProps<V extends FormValue = FormValue, C extends ElementType = 'form'> = OverridableProps<FormOwnProps<V>, C>;
24
26
  interface FormContext<V extends FormValue> extends FormSharedProps {
25
- requiredMark?: ReactNode;
26
27
  formValue?: V;
27
28
  setFieldValue?(field: FieldPath, value: any, silent?: boolean): void;
28
29
  itemsContainer?: Map<string, FormItemRef>;
@@ -13,11 +13,11 @@ const FormContext = (0, react_1.createContext)({});
13
13
  function useFormContext() {
14
14
  return (0, react_1.useContext)(FormContext);
15
15
  }
16
- exports.Form = (({ ref, component: Component = 'form', wrapperRef, initialValue, onChange, onFinish, requiredMark = '*', columnCount = 1, descriptionsProps,
17
- // 以下属性从DescriptionsBaseProps继承
18
- items, variant = 'grid',
16
+ exports.Form = (({ component: Component = 'form', ref, wrapperRef, initialValue, onChange, onFinish, items, descriptionsProps, requiredMark = '*', variant = 'grid',
19
17
  // 以下属性从DescriptionsSharedProps继承
20
- labelWidth, labelPlacement = 'left', colon = ':', size, disableMargin, disablePadding, ...props }) => {
18
+ labelWidth, labelPlacement = 'left', colon = ':', size, disableMargin, disablePadding,
19
+ // 以下属性从GridOwnProps继承
20
+ inline, columnCount = 1, gap, columnGap, rowGap, ...props }) => {
21
21
  /**
22
22
  * ------------------------------------------------------------------------
23
23
  * 表单值
@@ -97,7 +97,7 @@ labelWidth, labelPlacement = 'left', colon = ':', size, disableMargin, disablePa
97
97
  itemsContainer: itemsContainer.current, formRef
98
98
  }), [requiredMark, variant, formValue.current]), children: variant === 'plain'
99
99
  ? props.children
100
- : (0, jsx_runtime_1.jsx)(descriptions_1.Descriptions, { ...descriptionsProps, size: size, labelWidth: labelWidth, colon: colon, labelPlacement: labelPlacement, disableMargin: disableMargin, disablePadding: disablePadding, columnCount: columnCount, items: items, variant: variant, itemComponent: formItem_1.FormItem, children: props.children }) }) }));
100
+ : (0, jsx_runtime_1.jsx)(descriptions_1.Descriptions, { ...descriptionsProps, size: size, labelWidth: labelWidth, colon: colon, labelPlacement: labelPlacement, disableMargin: disableMargin, disablePadding: disablePadding, items: items, variant: variant, itemComponent: formItem_1.FormItem, inline: inline, columnCount: columnCount, gap: gap, columnGap: columnGap, rowGap: rowGap, children: props.children }) }) }));
101
101
  });
102
102
  exports.Form.Item = formItem_1.FormItem;
103
103
  exports.Form.Relatable = formRelatable_1.FormRelatable;
@@ -1,5 +1,5 @@
1
- import { ReactElement, ReactNode, ElementType } from 'react';
2
- import { MergeProps, Obj, OverridableProps, ResponsiveProp, Size } from '../../types';
1
+ import { ReactElement, ReactNode, ElementType, ComponentPropsWithRef } from 'react';
2
+ import { Obj, ResponsiveProp, Size } from '../../types';
3
3
  import { GridProps } from '../grid';
4
4
  import { DescriptionItem, DescriptionItemProps } from './descriptionItem';
5
5
  export type DescriptionsSharedProps = {
@@ -14,7 +14,7 @@ export type DescriptionsSharedProps = {
14
14
  /** 是否禁用padding,{@link DescriptionsProps.variant}为table有效 */
15
15
  disablePadding?: boolean;
16
16
  };
17
- export interface DescriptionsBaseProps extends DescriptionsSharedProps {
17
+ interface DescriptionsBaseProps extends DescriptionsSharedProps {
18
18
  items?: (DescriptionItemProps & Obj)[];
19
19
  /**
20
20
  * @private 用于渲染item的组件,通常为内部使用
@@ -22,21 +22,21 @@ export interface DescriptionsBaseProps extends DescriptionsSharedProps {
22
22
  */
23
23
  itemComponent?: ElementType;
24
24
  }
25
- export interface DescriptionsGridOwnProps extends DescriptionsBaseProps {
25
+ interface DescriptionsGridProps extends DescriptionsBaseProps, GridProps {
26
26
  variant?: 'grid';
27
27
  }
28
- export interface DescriptionsTableProps extends DescriptionsBaseProps {
28
+ interface DescriptionsTableProps extends DescriptionsBaseProps, ComponentPropsWithRef<'table'> {
29
29
  variant: 'table';
30
30
  columnCount?: ResponsiveProp;
31
31
  }
32
- export type DescriptionsProps<C extends ElementType = 'div' | 'table'> = MergeProps<DescriptionsGridOwnProps, GridProps<C>> | OverridableProps<DescriptionsTableProps, C>;
32
+ export type DescriptionsProps = DescriptionsGridProps | DescriptionsTableProps;
33
33
  interface DescriptionsContext extends DescriptionsSharedProps {
34
34
  variant?: 'grid' | 'table';
35
35
  }
36
36
  export declare function useDescriptionsContext(): DescriptionsContext;
37
37
  declare const DescriptionsContext: import("react").Context<DescriptionsContext>;
38
38
  export declare const Descriptions: {
39
- <C extends ElementType = "div">(props: DescriptionsProps<C>): ReactElement;
39
+ (props: DescriptionsProps): ReactElement;
40
40
  Item: typeof DescriptionItem;
41
41
  };
42
42
  export {};
@@ -1,16 +1,18 @@
1
1
  import React, { Dispatch, ReactElement, ReactNode, Ref, RefObject, SetStateAction, ElementType } from 'react';
2
- import { MergeProps, Obj } from '../../types';
2
+ import { Obj, OverridableProps } from '../../types';
3
3
  import { FieldPath } from '../../utils';
4
4
  import { FieldError, FormItem, FormItemProps, FormItemRef } from './formItem';
5
5
  import { FormRelatable } from './formRelatable';
6
- import { DescriptionsProps } from '../descriptions';
6
+ import { DescriptionsProps, DescriptionsSharedProps } from '../descriptions';
7
+ import { GridOwnProps } from '../grid';
7
8
  export type FormValue = Obj;
8
9
  export type FormSharedProps = {
10
+ /** 必填字段的标记,默认为`*` */
9
11
  requiredMark?: ReactNode;
10
12
  /** variant为"grid"或"table"时会渲染Descriptions组件,并传递variant属性,默认为`grid` */
11
13
  variant?: 'plain' | 'grid' | 'table';
12
14
  };
13
- export interface FormOwnProps<V extends FormValue = FormValue> extends FormSharedProps {
15
+ interface FormOwnProps<V extends FormValue = FormValue> extends FormSharedProps, DescriptionsSharedProps, GridOwnProps {
14
16
  ref?: Ref<FormRef<V> | null>;
15
17
  /** 最外层元素的ref,默认{@link ref}属性已经被{@link FormRef}取代 */
16
18
  wrapperRef?: Ref<HTMLFormElement>;
@@ -20,9 +22,8 @@ export interface FormOwnProps<V extends FormValue = FormValue> extends FormShare
20
22
  items?: (FormItemProps & Obj)[];
21
23
  descriptionsProps?: DescriptionsProps;
22
24
  }
23
- export type FormProps<V extends FormValue = FormValue, C extends ElementType = 'form'> = MergeProps<FormOwnProps<V>, DescriptionsProps<C>>;
25
+ export type FormProps<V extends FormValue = FormValue, C extends ElementType = 'form'> = OverridableProps<FormOwnProps<V>, C>;
24
26
  interface FormContext<V extends FormValue> extends FormSharedProps {
25
- requiredMark?: ReactNode;
26
27
  formValue?: V;
27
28
  setFieldValue?(field: FieldPath, value: any, silent?: boolean): void;
28
29
  itemsContainer?: Map<string, FormItemRef>;
@@ -9,11 +9,11 @@ const FormContext = createContext({});
9
9
  export function useFormContext() {
10
10
  return useContext(FormContext);
11
11
  }
12
- export const Form = (({ ref, component: Component = 'form', wrapperRef, initialValue, onChange, onFinish, requiredMark = '*', columnCount = 1, descriptionsProps,
13
- // 以下属性从DescriptionsBaseProps继承
14
- items, variant = 'grid',
12
+ export const Form = (({ component: Component = 'form', ref, wrapperRef, initialValue, onChange, onFinish, items, descriptionsProps, requiredMark = '*', variant = 'grid',
15
13
  // 以下属性从DescriptionsSharedProps继承
16
- labelWidth, labelPlacement = 'left', colon = ':', size, disableMargin, disablePadding, ...props }) => {
14
+ labelWidth, labelPlacement = 'left', colon = ':', size, disableMargin, disablePadding,
15
+ // 以下属性从GridOwnProps继承
16
+ inline, columnCount = 1, gap, columnGap, rowGap, ...props }) => {
17
17
  /**
18
18
  * ------------------------------------------------------------------------
19
19
  * 表单值
@@ -93,7 +93,7 @@ labelWidth, labelPlacement = 'left', colon = ':', size, disableMargin, disablePa
93
93
  itemsContainer: itemsContainer.current, formRef
94
94
  }), [requiredMark, variant, formValue.current]), children: variant === 'plain'
95
95
  ? props.children
96
- : _jsx(Descriptions, { ...descriptionsProps, size: size, labelWidth: labelWidth, colon: colon, labelPlacement: labelPlacement, disableMargin: disableMargin, disablePadding: disablePadding, columnCount: columnCount, items: items, variant: variant, itemComponent: FormItem, children: props.children }) }) }));
96
+ : _jsx(Descriptions, { ...descriptionsProps, size: size, labelWidth: labelWidth, colon: colon, labelPlacement: labelPlacement, disableMargin: disableMargin, disablePadding: disablePadding, items: items, variant: variant, itemComponent: FormItem, inline: inline, columnCount: columnCount, gap: gap, columnGap: columnGap, rowGap: rowGap, children: props.children }) }) }));
97
97
  });
98
98
  Form.Item = FormItem;
99
99
  Form.Relatable = FormRelatable;