@ray-js/components 1.7.78 → 1.7.80

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,78 +1,52 @@
1
+ import * as React from 'react';
1
2
  import { BaseProps } from '../types';
3
+ /**
4
+ * 多端按钮基础组件,可用于进行强交互的操作。
5
+ *
6
+ * @public
7
+ * @alias Button
8
+ * @since @ray-js/ray 0.5.10
9
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
10
+ * @example 按钮类型 ./demos/type/index.tsx sandbox ide e2e
11
+ * @example 按钮尺寸 ./demos/size/index.tsx sandbox ide e2e
12
+ * @example 按钮状态 ./demos/status/index.tsx sandbox ide e2e
13
+ * @example Hover 点击态与表单 ./demos/hover-form/index.tsx sandbox ide e2e
14
+ */
2
15
  export interface ButtonProps extends BaseProps {
3
- /**
4
- * @description.en disabled
5
- * @description.zh 是否禁用
6
- * @default undefined
7
- */
8
- disabled?: boolean;
9
- /**
10
- * @description.en loading
11
- * @description.zh 是否加载中
12
- * @default undefined
13
- */
14
- loading?: boolean;
15
- /**
16
- * @description.en Button size
17
- * @description.zh 按钮的大小
18
- * @default default
19
- */
16
+ /** 按钮的大小 */
20
17
  size?: 'default' | 'mini';
21
- /**
22
- * @description.en The style type of the button
23
- * @description.zh 按钮的样式类型
24
- * @default default
25
- */
18
+ /** 按钮的样式类型 */
26
19
  type?: 'default' | 'primary' | 'warn';
27
- /**
28
- * @description.en Whether the button hollow, transparent background color
29
- * @description.zh 按钮是否镂空,背景色透明
30
- * @default undefined
31
- */
20
+ /** 按钮是否镂空,背景色透明 */
32
21
  plain?: boolean;
33
- /**
34
- * @description.en Press down on the style
35
- * @description.zh 按下去的样式
36
- * @default undefined
22
+ /** 是否禁用 */
23
+ disabled?: boolean;
24
+ /** 名称前是否带 loading 图标 */
25
+ loading?: boolean;
26
+ /** 用于 form 组件,点击分别会触发 form 组件的 submit/reset 事件 */
27
+ formType?: 'submit' | 'reset';
28
+ /** 按下去的样式
29
+ * @internal
37
30
  */
38
- hoverStyle?: any;
31
+ hoverStyle?: string | React.CSSProperties;
39
32
  /**
40
- * @description.en Press down class on the style
41
- * @description.zh 按下去的样式class
42
- * @default undefined
33
+ * 指定按钮按下去的样式类
34
+ * @internal
43
35
  */
44
36
  hoverClassName?: string;
45
- /**
46
- * @description.en How long does it take for the click state to appear after holding, in milliseconds
47
- * @description.zh 按住后多久出现点击态,单位毫秒
48
- * @default undefined
49
- */
37
+ /** 按住后多久出现点击态,单位毫秒 */
50
38
  hoverStartTime?: number;
51
- /**
52
- * @description.en Click retention time after finger release, in milliseconds
53
- * @description.zh 手指松开后点击态保留时间,单位毫秒
54
- * @default undefined
55
- */
39
+ /** 手指松开后点击态保留时间,单位毫秒 */
56
40
  hoverStayTime?: number;
57
- /**
58
- * @description.en onClick
59
- * @description.zh 点击回调
60
- * @default undefined
61
- */
62
- onClick?: (params: {
63
- /**
64
- * @description.en type
65
- * @description.zh 类型
66
- * @default undefined
67
- */
68
- type: 'click';
69
- }) => void;
41
+ /** 子节点 */
70
42
  children?: React.ReactNode;
71
- /**
72
- * @description.en For the Form component, clicking on each of the Form component's Submit /reset events triggers it
73
- * @description.zh 用于 form 组件,点击分别会触发 form 组件的 submit/reset 事件
74
- * @default undefined
75
- */
76
- formType?: 'submit' | 'reset';
43
+ /** 点击按钮时触发 */
44
+ onClick?: BaseProps['onClick'];
77
45
  }
46
+ /**
47
+ * Button 组件默认值
48
+ *
49
+ * @belong Button
50
+ * @defaults
51
+ */
78
52
  export declare const defaultButtonProps: ButtonProps;
@@ -1,10 +1,31 @@
1
+ /**
2
+ * 多端按钮基础组件,可用于进行强交互的操作。
3
+ *
4
+ * @public
5
+ * @alias Button
6
+ * @since @ray-js/ray 0.5.10
7
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
8
+ * @example 按钮类型 ./demos/type/index.tsx sandbox ide e2e
9
+ * @example 按钮尺寸 ./demos/size/index.tsx sandbox ide e2e
10
+ * @example 按钮状态 ./demos/status/index.tsx sandbox ide e2e
11
+ * @example Hover 点击态与表单 ./demos/hover-form/index.tsx sandbox ide e2e
12
+ */
13
+
14
+ /**
15
+ * Button 组件默认值
16
+ *
17
+ * @belong Button
18
+ * @defaults
19
+ */
1
20
  export const defaultButtonProps = {
2
21
  size: 'default',
3
22
  type: 'default',
23
+ plain: false,
24
+ loading: false,
25
+ disabled: false,
4
26
  hoverStyle: {
5
27
  opacity: 0.8
6
28
  },
7
29
  hoverStartTime: 20,
8
- hoverStayTime: 70,
9
- disabled: false
30
+ hoverStayTime: 70
10
31
  };
@@ -1,27 +1,32 @@
1
1
  import { BaseProps } from '../types';
2
+ /**
3
+ * 多选框,用于在选项列表中开启或关闭单项选择。
4
+ *
5
+ * @public
6
+ * @alias Checkbox
7
+ * @since @ray-js/ray 0.5.10
8
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
9
+ *
10
+ * @example 不同状态 ./demos/states/index.tsx sandbox ide e2e
11
+ */
2
12
  export interface CheckboxProps extends BaseProps {
3
- /**
4
- * @description.en If this parameter is selected, the change event of the checkbox-group is triggered and the value of the checkbox is carried
5
- * @description.zh checkbox标识,选中时触发checkbox-group的 change 事件,并携带 checkbox 的 value
6
- * @default undefined
7
- */
13
+ /** 选中时触发所属 checkbox-group 的 change 事件,并携带该 value */
8
14
  value?: string;
9
- /**
10
- * @description.en Whether it is currently selected can be set to default
11
- * @description.zh 当前是否选中,可用来设置默认选中
12
- * @default undefined
13
- */
15
+ /** 当前是否选中,可作默认选中 */
14
16
  checked?: boolean;
15
- /**
16
- * @description.en is disabled
17
- * @description.zh 是否禁用
18
- * @default undefined
19
- */
17
+ /** 是否禁用 */
20
18
  disabled?: boolean;
21
- /**
22
- * @description.en color
23
- * @description.zh 颜色
24
- * @default undefined
25
- */
19
+ /** 多选框颜色,同 CSS color */
26
20
  color?: string;
27
21
  }
22
+ /**
23
+ * Checkbox 组件文档用默认值(与运行时 defaultProps 分离)
24
+ *
25
+ * @belong Checkbox
26
+ * @defaults
27
+ */
28
+ export declare const checkboxDefaultProps: {
29
+ disabled: boolean;
30
+ checked: boolean;
31
+ color: string;
32
+ };
@@ -1 +1,22 @@
1
- export {};
1
+ /**
2
+ * 多选框,用于在选项列表中开启或关闭单项选择。
3
+ *
4
+ * @public
5
+ * @alias Checkbox
6
+ * @since @ray-js/ray 0.5.10
7
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
8
+ *
9
+ * @example 不同状态 ./demos/states/index.tsx sandbox ide e2e
10
+ */
11
+
12
+ /**
13
+ * Checkbox 组件文档用默认值(与运行时 defaultProps 分离)
14
+ *
15
+ * @belong Checkbox
16
+ * @defaults
17
+ */
18
+ export const checkboxDefaultProps = {
19
+ disabled: false,
20
+ checked: false,
21
+ color: '#007AFF'
22
+ };
@@ -1,41 +1,69 @@
1
+ import * as React from 'react';
1
2
  import { BaseProps } from '../types';
2
3
  import { CheckboxProps } from '../Checkbox/props';
3
- import { GenericEvent } from '@ray-js/adapter';
4
+ import { BaseEvent } from '@ray-js/adapter';
5
+ /** checkbox-group change 事件数据 */
6
+ export interface CheckboxGroupChangeDetail {
7
+ /** 选中项的值列表 */
8
+ value: string[];
9
+ }
10
+ /** checkbox-group change 事件对象 */
11
+ export interface CheckboxGroupChangeEvent extends BaseEvent {
12
+ /** 事件类型 */
13
+ type: 'change';
14
+ /** 事件数据 */
15
+ detail: CheckboxGroupChangeDetail;
16
+ }
17
+ /**
18
+ * CheckboxGroup 选项数据。
19
+ * 继承 `CheckboxProps` 的全部属性(如 `value`、`checked`、`disabled`、`color` 等),并额外要求 `label` 作为展示文本。
20
+ */
4
21
  export type CheckboxGroupOption = CheckboxProps & {
22
+ /** 选项标签文本 */
5
23
  label: string;
6
24
  };
25
+ /** 以 `options` 数据驱动的 CheckboxGroup(与 children 二选一) */
7
26
  export interface ICheckboxGroupWithOptions {
27
+ /** 选项列表 */
8
28
  options: CheckboxGroupOption[];
9
29
  children?: undefined;
10
30
  }
31
+ /** 以 children(`Checkbox` 子节点)渲染的 CheckboxGroup(与 options 二选一) */
11
32
  export interface ICheckboxGroupWithChildren {
12
33
  options?: undefined;
34
+ /** 子节点,通常为多个 `Checkbox` */
13
35
  children: React.ReactNode | React.ReactNode[] | string;
14
36
  }
15
- export type CheckboxGroupProps = (ICheckboxGroupWithOptions & BaseCheckboxGroupProps) | (ICheckboxGroupWithChildren & BaseCheckboxGroupProps);
37
+ /** CheckboxGroup 公共属性 */
16
38
  export interface BaseCheckboxGroupProps extends Omit<BaseProps, 'children'> {
17
- /**
18
- * @description.en name
19
- * @description.zh 姓名
20
- * @default undefined
21
- */
39
+ /** 表单控件名称,提交表单时作为键名 */
22
40
  name?: string;
23
- /**
24
- * @description.en disabled
25
- * @description.zh 是否禁用
26
- * @default null
27
- */
41
+ /** 是否禁用 */
28
42
  disabled?: boolean;
29
- /**
30
- * @description.en Triggered when the selected item is changed
31
- * @description.zh 选中项发生改变时触发 change 事件
32
- * @default null
33
- */
34
- onChange?: (event: GenericEvent<{
35
- value: any;
36
- } & {
37
- type: string;
38
- value: string[];
39
- origin: any;
40
- }>) => void;
43
+ /** 选中项发生改变时触发 */
44
+ onChange?: (event: CheckboxGroupChangeEvent) => void;
41
45
  }
46
+ /**
47
+ * 多项选择器组,由多个 Checkbox 组成。`options` 与 children 二选一。
48
+ *
49
+ * @public
50
+ * @alias CheckboxGroup
51
+ * @since @ray-js/ray 0.5.10
52
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
53
+ * @example options 数据驱动 ./demos/options-data/index.tsx sandbox ide e2e
54
+ */
55
+ export interface CheckboxGroupProps extends BaseCheckboxGroupProps {
56
+ /** 选项列表,与 children 二选一 */
57
+ options?: CheckboxGroupOption[];
58
+ /** 子节点,通常为多个 `Checkbox`,与 options 二选一 */
59
+ children?: React.ReactNode | React.ReactNode[] | string;
60
+ }
61
+ /**
62
+ * CheckboxGroup 组件默认值
63
+ *
64
+ * @belong CheckboxGroup
65
+ * @defaults
66
+ */
67
+ export declare const checkboxGroupDefaultProps: {
68
+ disabled: boolean;
69
+ };
@@ -1 +1,34 @@
1
- export {};
1
+ /** checkbox-group change 事件数据 */
2
+
3
+ /** checkbox-group change 事件对象 */
4
+
5
+ /**
6
+ * CheckboxGroup 选项数据。
7
+ * 继承 `CheckboxProps` 的全部属性(如 `value`、`checked`、`disabled`、`color` 等),并额外要求 `label` 作为展示文本。
8
+ */
9
+
10
+ /** 以 `options` 数据驱动的 CheckboxGroup(与 children 二选一) */
11
+
12
+ /** 以 children(`Checkbox` 子节点)渲染的 CheckboxGroup(与 options 二选一) */
13
+
14
+ /** CheckboxGroup 公共属性 */
15
+
16
+ /**
17
+ * 多项选择器组,由多个 Checkbox 组成。`options` 与 children 二选一。
18
+ *
19
+ * @public
20
+ * @alias CheckboxGroup
21
+ * @since @ray-js/ray 0.5.10
22
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
23
+ * @example options 数据驱动 ./demos/options-data/index.tsx sandbox ide e2e
24
+ */
25
+
26
+ /**
27
+ * CheckboxGroup 组件默认值
28
+ *
29
+ * @belong CheckboxGroup
30
+ * @defaults
31
+ */
32
+ export const checkboxGroupDefaultProps = {
33
+ disabled: false
34
+ };
@@ -1,5 +1,7 @@
1
+ import * as React from 'react';
1
2
  import { BaseProps } from '../types';
2
3
  export type CoverViewProps = BaseProps & {
3
- children?: any;
4
+ /** 子节点 */
5
+ children?: React.ReactNode;
4
6
  };
5
7
  export declare const defaultCoverViewProps: Partial<CoverViewProps>;
@@ -1,23 +1,40 @@
1
1
  import { BaseProps } from '../types';
2
- export type FormProps = BaseProps & {
3
- /**
4
- * @description.en Trigger the Submit event with the data in the form
5
- * @description.zh 携带 form 中的数据触发 submit 事件
6
- * @default null
7
- */
8
- onSubmit?(event: {
9
- type: 'form';
10
- origin: any;
11
- value: any;
12
- }): void;
13
- /**
14
- * @description.en Triggered when the form is reset
15
- * @description.zh 表单重置时会触发
16
- * @default null
17
- */
18
- onReset?(event: {
19
- type: 'form';
20
- origin: any;
21
- value: any;
22
- }): void;
23
- };
2
+ import { BaseEvent } from '@ray-js/adapter';
3
+ /** 表单提交事件数据 */
4
+ export interface FormSubmitDetail {
5
+ /** 表单数据,key 为各表单控件的 name */
6
+ value: Record<string, unknown>;
7
+ }
8
+ /** 表单提交事件对象 */
9
+ export interface FormSubmitEvent extends BaseEvent {
10
+ /** 事件类型 */
11
+ type: 'submit';
12
+ /** 事件数据,通过 detail.value 获取表单数据 */
13
+ detail: FormSubmitDetail;
14
+ }
15
+ /** 表单重置事件对象 */
16
+ export interface FormResetEvent extends BaseEvent {
17
+ /** 事件类型 */
18
+ type: 'reset';
19
+ }
20
+ /**
21
+ * 表单容器,用于收集并提交其内部控件的输入值。
22
+ *
23
+ * @public
24
+ * @alias Form
25
+ * @since @ray-js/ray 0.5.10
26
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
27
+ */
28
+ export interface FormProps extends BaseProps {
29
+ /** 携带 form 中的数据,提交时触发 */
30
+ onSubmit?: (event: FormSubmitEvent) => void;
31
+ /** 表单重置时触发 */
32
+ onReset?: (event: FormResetEvent) => void;
33
+ }
34
+ /**
35
+ * Form 组件默认值
36
+ *
37
+ * @belong Form
38
+ * @defaults
39
+ */
40
+ export declare const formDefaultProps: Partial<FormProps>;
package/lib/Form/props.js CHANGED
@@ -1 +1,22 @@
1
- export {};
1
+ /** 表单提交事件数据 */
2
+
3
+ /** 表单提交事件对象 */
4
+
5
+ /** 表单重置事件对象 */
6
+
7
+ /**
8
+ * 表单容器,用于收集并提交其内部控件的输入值。
9
+ *
10
+ * @public
11
+ * @alias Form
12
+ * @since @ray-js/ray 0.5.10
13
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
14
+ */
15
+
16
+ /**
17
+ * Form 组件默认值
18
+ *
19
+ * @belong Form
20
+ * @defaults
21
+ */
22
+ export const formDefaultProps = {};
@@ -1 +1,98 @@
1
- export type { ImageProps } from '@ray-js/adapter';
1
+ import { BaseProps } from '../types';
2
+ import { BaseEvent } from '@ray-js/adapter';
3
+ /** 图片裁剪、缩放模式 */
4
+ export type ImageMode =
5
+ /** 缩放模式,不保持纵横比缩放图片,使图片的宽高完全拉伸至填满 image 元素 */
6
+ 'scaleToFill'
7
+ /** 缩放模式,保持纵横比缩放图片,使图片的长边能完全显示出来 */
8
+ | 'aspectFit'
9
+ /** 缩放模式,保持纵横比缩放图片,只保证图片的短边能完全显示出来 */
10
+ | 'aspectFill'
11
+ /** 缩放模式,宽度不变,高度自动变化,保持原图宽高比不变 */
12
+ | 'widthFix'
13
+ /** 缩放模式,高度不变,宽度自动变化,保持原图宽高比不变 */
14
+ | 'heightFix'
15
+ /** 裁剪模式,不缩放图片,只显示图片的顶部区域 */
16
+ | 'top'
17
+ /** 裁剪模式,不缩放图片,只显示图片的底部区域 */
18
+ | 'bottom'
19
+ /** 裁剪模式,不缩放图片,只显示图片的中间区域 */
20
+ | 'center'
21
+ /** 裁剪模式,不缩放图片,只显示图片的左边区域 */
22
+ | 'left'
23
+ /** 裁剪模式,不缩放图片,只显示图片的右边区域 */
24
+ | 'right'
25
+ /** 裁剪模式,不缩放图片,只显示图片的左上边区域 */
26
+ | 'top left'
27
+ /** 裁剪模式,不缩放图片,只显示图片的右上边区域 */
28
+ | 'top right'
29
+ /** 裁剪模式,不缩放图片,只显示图片的左下边区域 */
30
+ | 'bottom left'
31
+ /** 裁剪模式,不缩放图片,只显示图片的右下边区域 */
32
+ | 'bottom right';
33
+ /** 图片加载成功事件数据 */
34
+ export interface ImageLoadDetail {
35
+ /** 图片宽度,单位 px */
36
+ width: number;
37
+ /** 图片高度,单位 px */
38
+ height: number;
39
+ }
40
+ /** 图片加载成功事件对象 */
41
+ export interface ImageLoadEvent extends BaseEvent {
42
+ /** 事件类型 */
43
+ type: 'load';
44
+ /** 事件数据 */
45
+ detail: ImageLoadDetail;
46
+ }
47
+ /** 图片加载失败事件数据 */
48
+ export interface ImageErrorDetail {
49
+ /** 错误信息 */
50
+ errMsg: string;
51
+ }
52
+ /** 图片加载失败事件对象 */
53
+ export interface ImageErrorEvent extends BaseEvent {
54
+ /** 事件类型 */
55
+ type: 'error';
56
+ /** 事件数据 */
57
+ detail: ImageErrorDetail;
58
+ }
59
+ /**
60
+ * 图片组件,支持多种裁剪和缩放模式。
61
+ *
62
+ * @public
63
+ * @alias Image
64
+ * @since @ray-js/ray 0.5.10
65
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
66
+ * @example 缩放模式 ./demos/mode/index.tsx sandbox ide e2e
67
+ * @example 懒加载与渐显 ./demos/lazy-fade/index.tsx sandbox ide e2e
68
+ */
69
+ export interface ImageProps extends BaseProps {
70
+ /** 图片资源地址 */
71
+ src?: string;
72
+ /** 图片裁剪、缩放的模式 */
73
+ mode?: ImageMode;
74
+ /**
75
+ * 默认不解析 WebP,仅部分端支持;仅网络资源
76
+ * @internal
77
+ */
78
+ webp?: boolean;
79
+ /** 懒加载,进入一定范围后再加载 */
80
+ lazyLoad?: boolean;
81
+ /** 加载过程中渐显时长,单位 ms */
82
+ fadeDuration?: number;
83
+ /** 加载失败时触发 */
84
+ onError?: (event: ImageErrorEvent) => void;
85
+ /** 载入完毕时触发 */
86
+ onLoad?: (event: ImageLoadEvent) => void;
87
+ }
88
+ /**
89
+ * Image 组件文档用默认值(与运行时 defaultProps 分离)
90
+ *
91
+ * @belong Image
92
+ * @defaults
93
+ */
94
+ export declare const imageDefaultProps: {
95
+ mode: string;
96
+ lazyLoad: boolean;
97
+ fadeDuration: number;
98
+ };
@@ -1 +1,32 @@
1
- export {};
1
+ /** 图片裁剪、缩放模式 */
2
+
3
+ /** 图片加载成功事件数据 */
4
+
5
+ /** 图片加载成功事件对象 */
6
+
7
+ /** 图片加载失败事件数据 */
8
+
9
+ /** 图片加载失败事件对象 */
10
+
11
+ /**
12
+ * 图片组件,支持多种裁剪和缩放模式。
13
+ *
14
+ * @public
15
+ * @alias Image
16
+ * @since @ray-js/ray 0.5.10
17
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
18
+ * @example 缩放模式 ./demos/mode/index.tsx sandbox ide e2e
19
+ * @example 懒加载与渐显 ./demos/lazy-fade/index.tsx sandbox ide e2e
20
+ */
21
+
22
+ /**
23
+ * Image 组件文档用默认值(与运行时 defaultProps 分离)
24
+ *
25
+ * @belong Image
26
+ * @defaults
27
+ */
28
+ export const imageDefaultProps = {
29
+ mode: 'scaleToFill',
30
+ lazyLoad: false,
31
+ fadeDuration: 0
32
+ };
@@ -7,6 +7,7 @@ import * as React from 'react';
7
7
  import clsx from 'clsx';
8
8
  import { useEventListener } from 'ahooks';
9
9
  import { inlineStyle, useStylesheet } from '@ray-js/framework-shared';
10
+ import s2o from 'style-to-object';
10
11
  import { defaultInputProps } from './props';
11
12
  import styles from './index.module.less';
12
13
  import handleProps from '../utils/handleProps';
@@ -20,7 +21,8 @@ const Input = /*#__PURE__*/React.forwardRef((props, ref) => {
20
21
  onConfirm
21
22
  } = props,
22
23
  restProps = _objectWithoutProperties(props, _excluded);
23
- const [placeholderStyleClassName] = useStylesheet(inlineStyle(placeholderStyle));
24
+ const placeholderStyleForSheet = placeholderStyle == null ? undefined : typeof placeholderStyle === 'string' ? s2o(placeholderStyle) : placeholderStyle;
25
+ const [placeholderStyleClassName] = useStylesheet(inlineStyle(placeholderStyleForSheet));
24
26
  const currentNode = ref || React.useRef(null);
25
27
  useEventListener('focus', e => {
26
28
  onFocus === null || onFocus === void 0 || onFocus(_objectSpread(_objectSpread({}, e), {}, {