@ray-js/components 1.7.79 → 1.7.81

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,95 +1,103 @@
1
- import { GenericEvent } from '@ray-js/adapter';
2
- import { BaseProps } from '../types';
3
1
  import * as React from 'react';
2
+ import { BaseProps } from '../types';
3
+ import { BaseEvent } from '@ray-js/adapter';
4
4
  export type InputType = 'text' | 'number' | 'digit' | 'idcard';
5
+ /** input 输入事件数据 */
6
+ export interface InputInputDetail {
7
+ /** 输入框内容 */
8
+ value: string;
9
+ /** 光标位置 */
10
+ cursor: number;
11
+ /** 键值 */
12
+ keyCode: number;
13
+ }
14
+ /** input 通用文本事件数据 */
15
+ export interface InputValueDetail {
16
+ /** 输入框内容 */
17
+ value: string;
18
+ }
19
+ /** input 输入事件对象 */
20
+ export interface InputInputEvent extends BaseEvent {
21
+ /** 事件类型 */
22
+ type: 'input';
23
+ /** 事件数据 */
24
+ detail: InputInputDetail;
25
+ /** 输入框当前值 */
26
+ value: string;
27
+ }
28
+ /** input 确认事件对象 */
29
+ export interface InputConfirmEvent extends BaseEvent {
30
+ /** 事件类型 */
31
+ type: 'confirm';
32
+ /** 事件数据 */
33
+ detail: InputValueDetail;
34
+ }
35
+ /** input 聚焦事件对象 */
36
+ export interface InputFocusEvent extends BaseEvent {
37
+ /** 事件类型 */
38
+ type: 'focus';
39
+ /** 事件数据 */
40
+ detail: InputValueDetail;
41
+ }
42
+ /** input 失焦事件对象 */
43
+ export interface InputBlurEvent extends BaseEvent {
44
+ /** 事件类型 */
45
+ type: 'blur';
46
+ /** 事件数据 */
47
+ detail: InputValueDetail;
48
+ }
49
+ /**
50
+ * 输入框组件,支持多种输入类型和键盘配置。
51
+ *
52
+ * @public
53
+ * @alias Input
54
+ * @since @ray-js/ray 0.5.10
55
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
56
+ * @example 不同类型 ./demos/types/index.tsx sandbox ide e2e
57
+ * @example 输入限制与禁用 ./demos/limit-disabled/index.tsx sandbox ide e2e
58
+ */
5
59
  export interface InputProps extends BaseProps {
6
- /**
7
- * @description.en content
8
- * @description.zh 内容
9
- * @default undefined
10
- */
60
+ /** 输入框的内容 */
11
61
  value?: string;
12
- /**
13
- * @description.en type
14
- * @description.zh 类型
15
- * @default text
16
- */
62
+ /** 输入类型 */
17
63
  type?: InputType;
18
- /**
19
- * @description.en is password
20
- * @description.zh 是否为密码
21
- * @default false
22
- */
64
+ /** 表单控件名称,提交表单时作为键名 */
65
+ name?: string;
66
+ /** 是否为密码输入框 */
23
67
  password?: boolean;
24
- /**
25
- * @description.en placeholder
26
- * @description.zh 占位内容
27
- * @default undefined
28
- */
68
+ /** 输入框为空时占位符 */
29
69
  placeholder?: string;
30
- /**
31
- * @description.en placeholder
32
- * @description.zh 占位符的样式
33
- * @default undefined
34
- */
70
+ /** 占位符的样式 */
35
71
  placeholderStyle?: React.CSSProperties | string;
36
- /**
37
- * @description.en disabled
38
- * @description.zh 是否禁用
39
- * @default false
40
- */
72
+ /** 是否禁用 */
41
73
  disabled?: boolean;
42
- /**
43
- * @description.en Maximum input length. When the value is set to -1, the maximum input length is not limited
44
- * @description.zh 最大输入长度,设置为 -1 的时候不限制最大长度
45
- * @default undefined
46
- */
74
+ /** 最大输入长度,设置为 -1 的时候不限制最大长度 */
47
75
  maxLength?: number;
48
- /**
49
- * @description.en Set the text of the button in the lower right corner of the keyboard, effective only when type='text'
50
- * @description.zh 设置键盘右下角按钮的文字,仅在type='text'时生效
51
- * @default done
52
- */
76
+ /** 设置键盘右下角按钮的文字,仅在 type='text' 时生效 */
53
77
  confirmType?: 'send' | 'search' | 'next' | 'go' | 'done';
54
78
  /**
55
- * @description 输入框内容左侧内容缩进,仅在涂鸦小程序有效
79
+ * 输入框内容左侧内容缩进,仅在涂鸦小程序有效
80
+ * @internal
56
81
  */
57
82
  indentStart?: string | number;
58
83
  /**
59
- * @description 输入框内容右侧内容缩进,仅在涂鸦小程序有效
84
+ * 输入框内容右侧内容缩进,仅在涂鸦小程序有效
85
+ * @internal
60
86
  */
61
87
  indentEnd?: string | number;
62
- /**
63
- * @description.en Input events
64
- * @description.zh 输入事件
65
- * @default undefined
66
- */
67
- onInput?: (event: GenericEvent<{
68
- value: any;
69
- }>) => void;
70
- /**
71
- * @description.en onConfirm
72
- * @description.zh 确认事件
73
- * @default undefined
74
- */
75
- onConfirm?: (event: GenericEvent<{
76
- value: any;
77
- }>) => void;
78
- /**
79
- * @description.en onFocus
80
- * @description.zh 焦点事件
81
- * @default undefined
82
- */
83
- onFocus?: (event: GenericEvent<{
84
- value: any;
85
- }>) => void;
86
- /**
87
- * @description.en onBlur
88
- * @description.zh 丢焦事件
89
- * @default undefined
90
- */
91
- onBlur?: (event: GenericEvent<{
92
- value: any;
93
- }>) => void;
88
+ /** 键盘输入时触发 */
89
+ onInput?: (event: InputInputEvent) => void;
90
+ /** 点击完成按钮时触发 */
91
+ onConfirm?: (event: InputConfirmEvent) => void;
92
+ /** 输入框聚焦时触发 */
93
+ onFocus?: (event: InputFocusEvent) => void;
94
+ /** 输入框失去焦点时触发 */
95
+ onBlur?: (event: InputBlurEvent) => void;
94
96
  }
97
+ /**
98
+ * Input 组件默认值
99
+ *
100
+ * @belong Input
101
+ * @defaults
102
+ */
95
103
  export declare const defaultInputProps: Partial<InputProps>;
@@ -1,3 +1,32 @@
1
+ /** input 输入事件数据 */
2
+
3
+ /** input 通用文本事件数据 */
4
+
5
+ /** input 输入事件对象 */
6
+
7
+ /** input 确认事件对象 */
8
+
9
+ /** input 聚焦事件对象 */
10
+
11
+ /** input 失焦事件对象 */
12
+
13
+ /**
14
+ * 输入框组件,支持多种输入类型和键盘配置。
15
+ *
16
+ * @public
17
+ * @alias Input
18
+ * @since @ray-js/ray 0.5.10
19
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
20
+ * @example 不同类型 ./demos/types/index.tsx sandbox ide e2e
21
+ * @example 输入限制与禁用 ./demos/limit-disabled/index.tsx sandbox ide e2e
22
+ */
23
+
24
+ /**
25
+ * Input 组件默认值
26
+ *
27
+ * @belong Input
28
+ * @defaults
29
+ */
1
30
  export const defaultInputProps = {
2
31
  type: 'text',
3
32
  maxLength: 140,
@@ -1,9 +1,24 @@
1
1
  import { BaseProps } from '../types';
2
+ /**
3
+ * 标签,用于提升表单可用性:可通过 htmlFor 关联控件,或包裹控件扩大点击区域。
4
+ *
5
+ * @public
6
+ * @alias Label
7
+ * @since @ray-js/ray 0.5.10
8
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
9
+ *
10
+ * @example htmlFor 绑定 ./demos/html-for/index.tsx sandbox ide e2e
11
+ */
2
12
  export interface LabelProps extends BaseProps {
3
13
  /**
4
- * @description.en htmlFor
5
- * @description.zh htmlfor
6
- * @default undefined
14
+ * 绑定控件的 id
7
15
  */
8
16
  htmlFor?: string;
9
17
  }
18
+ /**
19
+ * Label 组件文档用默认值(与运行时 defaultProps 分离)
20
+ *
21
+ * @belong Label
22
+ * @defaults
23
+ */
24
+ export declare const labelDefaultProps: Partial<LabelProps>;
@@ -1 +1,18 @@
1
- export {};
1
+ /**
2
+ * 标签,用于提升表单可用性:可通过 htmlFor 关联控件,或包裹控件扩大点击区域。
3
+ *
4
+ * @public
5
+ * @alias Label
6
+ * @since @ray-js/ray 0.5.10
7
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
8
+ *
9
+ * @example htmlFor 绑定 ./demos/html-for/index.tsx sandbox ide e2e
10
+ */
11
+
12
+ /**
13
+ * Label 组件文档用默认值(与运行时 defaultProps 分离)
14
+ *
15
+ * @belong Label
16
+ * @defaults
17
+ */
18
+ export const labelDefaultProps = {};
@@ -1,26 +1,57 @@
1
- import { BaseProps } from '../types';
2
1
  import * as React from 'react';
3
- import { GenericEvent } from '@ray-js/adapter';
4
- export type PageContainerEventType = GenericEvent<{
5
- value: any;
6
- }>;
7
- export type PageContainerProps = BaseProps & {
8
- /** 文本是否可选 */
2
+ import { BaseProps } from '../types';
3
+ import { BaseEvent } from '@ray-js/adapter';
4
+ /**
5
+ * 页面容器,用于从屏幕边缘或底部弹出半屏/全屏内容,支持遮罩、圆角、进入离开动画及生命周期回调。
6
+ *
7
+ * @public
8
+ * @alias PageContainer
9
+ * @since @ray-js/ray 0.5.10
10
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
11
+ * @example 从底部弹出带遮罩 ./demos/bottom-overlay/index.tsx sandbox ide e2e
12
+ * @example 自定义样式与生命周期 ./demos/custom-style-lifecycle/index.tsx sandbox ide e2e
13
+ */
14
+ export interface PageContainerProps extends BaseProps {
15
+ /** 是否显示容器组件 */
9
16
  show?: boolean;
17
+ /** 动画时长,单位毫秒 */
10
18
  duration?: number;
19
+ /** z-index 层级 */
11
20
  zIndex?: number;
21
+ /** 是否显示遮罩层 */
12
22
  overlay?: boolean;
23
+ /** 弹出位置 */
13
24
  position?: 'top' | 'bottom' | 'right' | 'center';
25
+ /** 是否显示圆角 */
14
26
  round?: boolean;
27
+ /** 自定义遮罩层样式 */
15
28
  overlayStyle?: string | React.CSSProperties;
29
+ /** 自定义弹出层样式 */
16
30
  customStyle?: string | React.CSSProperties;
17
- onBeforeEnter?: (event: PageContainerEventType) => void;
18
- onEnter?: (event: PageContainerEventType) => void;
19
- onAfterEnter?: (event: PageContainerEventType) => void;
20
- onBeforeLeave?: (event: PageContainerEventType) => void;
21
- onLeave?: (event: PageContainerEventType) => void;
22
- onAfterLeave?: (event: PageContainerEventType) => void;
23
- onClickOverlay?: (event: PageContainerEventType) => void;
24
- children?: React.ReactNode | string;
25
- };
31
+ /** 进入前触发 */
32
+ onBeforeEnter?: (event: BaseEvent) => void;
33
+ /** 进入中触发 */
34
+ onEnter?: (event: BaseEvent) => void;
35
+ /** 进入后触发 */
36
+ onAfterEnter?: (event: BaseEvent) => void;
37
+ /** 离开前触发 */
38
+ onBeforeLeave?: (event: BaseEvent) => void;
39
+ /** 离开中触发 */
40
+ onLeave?: (event: BaseEvent) => void;
41
+ /** 离开后触发 */
42
+ onAfterLeave?: (event: BaseEvent) => void;
43
+ /** 点击遮罩层时触发 */
44
+ onClickOverlay?: (event: BaseEvent) => void;
45
+ }
46
+ /**
47
+ * PageContainer 组件默认值
48
+ *
49
+ * @belong PageContainer
50
+ * @defaults
51
+ */
26
52
  export declare const defaultPageContainerProps: Partial<PageContainerProps>;
53
+ /**
54
+ * @internal
55
+ * @deprecated 使用 BaseEvent 替代
56
+ */
57
+ export type PageContainerEventType = BaseEvent;
@@ -1,3 +1,20 @@
1
+ /**
2
+ * 页面容器,用于从屏幕边缘或底部弹出半屏/全屏内容,支持遮罩、圆角、进入离开动画及生命周期回调。
3
+ *
4
+ * @public
5
+ * @alias PageContainer
6
+ * @since @ray-js/ray 0.5.10
7
+ * @example 基础用法 ./demos/basic/index.tsx sandbox ide e2e
8
+ * @example 从底部弹出带遮罩 ./demos/bottom-overlay/index.tsx sandbox ide e2e
9
+ * @example 自定义样式与生命周期 ./demos/custom-style-lifecycle/index.tsx sandbox ide e2e
10
+ */
11
+
12
+ /**
13
+ * PageContainer 组件默认值
14
+ *
15
+ * @belong PageContainer
16
+ * @defaults
17
+ */
1
18
  export const defaultPageContainerProps = {
2
19
  show: false,
3
20
  duration: 300,
@@ -6,4 +23,9 @@ export const defaultPageContainerProps = {
6
23
  position: 'bottom',
7
24
  round: false
8
25
  // closeOnSlideDown: false,
9
- };
26
+ };
27
+
28
+ /**
29
+ * @internal
30
+ * @deprecated 使用 BaseEvent 替代
31
+ */
@@ -1,27 +1,32 @@
1
1
  import { BaseProps } from '../types';
2
+ /**
3
+ * 单选框,用于在一组互斥选项中选中其中一项。
4
+ *
5
+ * @public
6
+ * @alias Radio
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 RadioProps extends BaseProps {
3
- /**
4
- * @description.en Radio id. When the radio is selected, the radio.group change event carries the value of the radio
5
- * @description.zh radio 标识。当该 radio 选中时,Radio.Group 的 change 事件会携带 radio 的 value
6
- * @default undefined
7
- */
13
+ /** radio 标识;该 radio 选中时,radio-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 false
13
- */
15
+ /** 当前是否选中,可作默认选中 */
14
16
  checked?: boolean;
15
- /**
16
- * @description.en disabled
17
- * @description.zh 是否禁用
18
- * @default false
19
- */
17
+ /** 是否禁用 */
20
18
  disabled?: boolean;
21
- /**
22
- * @description.en color
23
- * @description.zh 颜色
24
- * @default '#007AFF'
25
- */
19
+ /** radio 的颜色,同 CSS 的 color */
26
20
  color?: string;
27
21
  }
22
+ /**
23
+ * Radio 组件文档用默认值(与运行时 defaultProps 分离)
24
+ *
25
+ * @belong Radio
26
+ * @defaults
27
+ */
28
+ export declare const radioDefaultProps: {
29
+ checked: boolean;
30
+ disabled: boolean;
31
+ color: string;
32
+ };
@@ -1 +1,22 @@
1
- export {};
1
+ /**
2
+ * 单选框,用于在一组互斥选项中选中其中一项。
3
+ *
4
+ * @public
5
+ * @alias Radio
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
+ * Radio 组件文档用默认值(与运行时 defaultProps 分离)
14
+ *
15
+ * @belong Radio
16
+ * @defaults
17
+ */
18
+ export const radioDefaultProps = {
19
+ checked: false,
20
+ disabled: false,
21
+ color: '#007AFF'
22
+ };
@@ -1,37 +1,69 @@
1
+ import * as React from 'react';
1
2
  import { BaseProps } from '../types';
2
3
  import { RadioProps } from '../Radio/props';
3
- import { GenericEvent } from '@ray-js/adapter';
4
+ import { BaseEvent } from '@ray-js/adapter';
5
+ /** radio-group change 事件数据 */
6
+ export interface RadioGroupChangeDetail {
7
+ /** 选中项的值 */
8
+ value: string;
9
+ }
10
+ /** radio-group change 事件对象 */
11
+ export interface RadioGroupChangeEvent extends BaseEvent {
12
+ /** 事件类型 */
13
+ type: 'change';
14
+ /** 事件数据 */
15
+ detail: RadioGroupChangeDetail;
16
+ }
17
+ /**
18
+ * RadioGroup 选项数据。
19
+ * 继承 `RadioProps` 的全部属性(如 `value`、`checked`、`disabled`、`color` 等),并额外要求 `label` 作为展示文本。
20
+ */
4
21
  export type RadioGroupOption = RadioProps & {
22
+ /** 选项标签文本 */
5
23
  label: string;
6
24
  };
25
+ /** 以 `options` 数据驱动的 RadioGroup(与 children 二选一) */
7
26
  export interface IRadioGroupWithOptions {
27
+ /** 选项列表 */
8
28
  options: RadioGroupOption[];
9
29
  children?: undefined;
10
30
  }
31
+ /** 以 children(`Radio` 子节点)渲染的 RadioGroup(与 options 二选一) */
11
32
  export interface IRadioGroupWithChildren {
12
33
  options?: undefined;
34
+ /** 子节点,通常为多个 `Radio` */
13
35
  children: React.ReactNode | React.ReactNode[] | string;
14
36
  }
15
- export type RadioGroupProps = (IRadioGroupWithOptions & BaseRadioGroupProps) | (IRadioGroupWithChildren & BaseRadioGroupProps);
37
+ /** RadioGroup 公共属性 */
16
38
  export interface BaseRadioGroupProps 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 false
27
- */
41
+ /** 是否禁用 */
28
42
  disabled?: boolean;
29
- /**
30
- * @description.en onChange
31
- * @description.zh 选中项发生改变时触发 change 事件
32
- * @default undefined
33
- */
34
- onChange?: (event: GenericEvent<{
35
- value: any;
36
- }>) => void;
43
+ /** 选中项发生改变时触发 */
44
+ onChange?: (event: RadioGroupChangeEvent) => void;
37
45
  }
46
+ /**
47
+ * 单选选择器组,由多个 Radio 组成。`options` 与 children 二选一。
48
+ *
49
+ * @public
50
+ * @alias RadioGroup
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 RadioGroupProps extends BaseRadioGroupProps {
56
+ /** 选项列表,与 children 二选一 */
57
+ options?: RadioGroupOption[];
58
+ /** 子节点,通常为多个 `Radio`,与 options 二选一 */
59
+ children?: React.ReactNode | React.ReactNode[] | string;
60
+ }
61
+ /**
62
+ * RadioGroup 组件默认值
63
+ *
64
+ * @belong RadioGroup
65
+ * @defaults
66
+ */
67
+ export declare const radioGroupDefaultProps: {
68
+ disabled: boolean;
69
+ };
@@ -1 +1,34 @@
1
- export {};
1
+ /** radio-group change 事件数据 */
2
+
3
+ /** radio-group change 事件对象 */
4
+
5
+ /**
6
+ * RadioGroup 选项数据。
7
+ * 继承 `RadioProps` 的全部属性(如 `value`、`checked`、`disabled`、`color` 等),并额外要求 `label` 作为展示文本。
8
+ */
9
+
10
+ /** 以 `options` 数据驱动的 RadioGroup(与 children 二选一) */
11
+
12
+ /** 以 children(`Radio` 子节点)渲染的 RadioGroup(与 options 二选一) */
13
+
14
+ /** RadioGroup 公共属性 */
15
+
16
+ /**
17
+ * 单选选择器组,由多个 Radio 组成。`options` 与 children 二选一。
18
+ *
19
+ * @public
20
+ * @alias RadioGroup
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
+ * RadioGroup 组件默认值
28
+ *
29
+ * @belong RadioGroup
30
+ * @defaults
31
+ */
32
+ export const radioGroupDefaultProps = {
33
+ disabled: false
34
+ };