@lynx-js/types 3.4.3 → 3.5.9

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.
@@ -3,82 +3,239 @@
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
5
  import { BaseMethod, Callback } from '../events';
6
- import { AutoScrollMethod, ScrollToPositionMethod } from './list';
7
- import { ScrollToMethod } from './scroll-view';
6
+ import { AutoScrollMethod, ListUIMethods } from './list';
7
+ import { ScrollViewUIMethods } from './scroll-view';
8
8
 
9
- export type ListParams = ScrollToPositionMethod;
9
+ export type ListParams = ListUIMethods;
10
10
 
11
- export type ScrollViewParams = ScrollToMethod | AutoScrollMethod;
11
+ export type ScrollViewParams = ScrollViewUIMethods | AutoScrollMethod;
12
12
 
13
+ /**
14
+ * Call this method to get the width, height, and position information of the target element.
15
+ * @Android
16
+ * @iOS
17
+ * @Harmony
18
+ * @PC
19
+ */
13
20
  interface BoundingClientRectMethod extends BaseMethod {
14
21
  method: 'boundingClientRect';
22
+ params: {
23
+ /**
24
+ * The element to which the coordinates are relative. If not specified, the coordinates are relative to the viewport. If the value is `screen`, the coordinates are relative to the screen. If the value is a element's `id`, the coordinates are relative to the element with the specified ID. Else, the coordinates are relative to the viewport of LynxView.
25
+ * @defaultValue null
26
+ * @iOS
27
+ * @Harmony
28
+ * @Android
29
+ */
30
+ relativeTo?: 'screen' | string | null;
31
+ /**
32
+ * Whether to enable transform props on Android, it is recommended to set it to `true` when the element has transform props.
33
+ * @defaultValue false
34
+ * @Android
35
+ */
36
+ androidEnableTransformProps?: boolean;
37
+ };
15
38
  success?: Callback<{
16
39
  /**
17
- * Node ID.
40
+ * The id of the element
41
+ * @Android
42
+ * @iOS
43
+ * @Harmony
44
+ * @PC
18
45
  */
19
46
  id: string;
20
47
 
21
48
  /**
22
- * Dataset of nodes.
49
+ * Dataset of the element.
50
+ * @Android
51
+ * @iOS
52
+ * @Harmony
53
+ * @PC
23
54
  */
24
55
  dataset: object;
25
56
 
26
57
  /**
27
- * Left boundary coordinate of the node (in pixels)
58
+ * Left boundary coordinate of the element (in pixels)
59
+ * @Android
60
+ * @iOS
61
+ * @Harmony
62
+ * @PC
28
63
  */
29
64
  left: number;
30
65
 
31
66
  /**
32
- * The right boundary coordinates of the node.
67
+ * The right boundary coordinates of the element.
68
+ * @Android
69
+ * @iOS
70
+ * @Harmony
71
+ * @PC
33
72
  */
34
73
  right: number;
35
74
 
36
75
  /**
37
- * Upper boundary coordinate of the node.
76
+ * Upper boundary coordinate of the element.
77
+ * @Android
78
+ * @iOS
79
+ * @Harmony
80
+ * @PC
38
81
  */
39
82
  top: number;
40
83
 
41
84
  /**
42
- * The lower boundary coordinates of the node
85
+ * The lower boundary coordinates of the element.
86
+ * @Android
87
+ * @iOS
88
+ * @Harmony
89
+ * @PC
43
90
  */
44
91
  bottom: number;
45
92
 
46
93
  /**
47
- * Width of the node.
94
+ * Width of the element.
95
+ * @Android
96
+ * @iOS
97
+ * @Harmony
98
+ * @PC
48
99
  */
49
100
  width: number;
50
101
 
51
102
  /**
52
- * height of the node.
103
+ * height of the element.
104
+ * @Android
105
+ * @iOS
106
+ * @Harmony
107
+ * @PC
53
108
  */
54
109
  height: number;
55
110
  }>;
56
111
  }
57
112
 
113
+ /**
114
+ * Call this method to take a screenshot of the element.
115
+ * @Android
116
+ * @iOS
117
+ * @Harmony
118
+ * @PC
119
+ */
120
+ interface TakeScreenShotMethod extends BaseMethod {
121
+ method: 'takeScreenshot';
122
+ params: {
123
+ /**
124
+ * Specify the image format.
125
+ * @defaultValue 'jpeg'
126
+ * @Android
127
+ * @iOS
128
+ * @Harmony
129
+ * @PC
130
+ */
131
+ format: 'jpeg' | 'png';
132
+ /**
133
+ * Specify the image quality, within [0, 1], the smaller the value, the blurrier and smaller the size.
134
+ * @defaultValue 1
135
+ * @Android
136
+ * @iOS
137
+ * @Harmony
138
+ * @PC
139
+ */
140
+ scale?: number;
141
+ };
142
+ success?: Callback<{
143
+ /**
144
+ * The base64-encoded string of the screenshot image.
145
+ * @Android
146
+ * @iOS
147
+ * @Harmony
148
+ * @PC
149
+ */
150
+ data: string;
151
+ }>;
152
+ }
153
+
154
+ /**
155
+ * Set the element to require focus
156
+ * @PC
157
+ */
58
158
  interface SetFocusMethod extends BaseMethod {
59
159
  method: 'setFocus';
60
160
  params: {
61
- /** Set whether the element gains focus, `false` means the element loses focus.*/
161
+ /**
162
+ * Set whether the element gains focus, `false` means the element loses focus.
163
+ * @PC
164
+ */
62
165
  focus: boolean;
63
- /** Whether to scroll the element into the visible area at the same time, default is `true`.*/
166
+ /**
167
+ * Whether to scroll the element into the visible area at the same time, default is `true`.
168
+ * @PC
169
+ */
64
170
  scroll?: boolean;
65
171
  };
66
172
  }
67
173
 
174
+ /**
175
+ * Call this method to request accessibility focus for the element.
176
+ * @Android
177
+ * @iOS
178
+ */
179
+ interface RequestAccessibilityFocusMethod extends BaseMethod {
180
+ method: 'requestAccessibilityFocus';
181
+ }
182
+
183
+ /**
184
+ * Call this method to check if the element is currently animating.
185
+ * @deprecated Legacy API
186
+ */
68
187
  interface IsAnimatingMethod extends BaseMethod {
69
188
  method: 'isAnimating';
70
189
  success?: Callback<{ data: boolean }>;
71
190
  }
72
191
 
192
+ /**
193
+ * Call this method to scroll the element into the visible area.
194
+ * @Android
195
+ * @iOS
196
+ * @Harmony
197
+ * @PC
198
+ */
73
199
  interface ScrollIntoViewMethod extends BaseMethod {
74
200
  method: 'scrollIntoView';
75
201
  params: {
202
+ /**
203
+ * Specify the scroll options.
204
+ * @Android
205
+ * @iOS
206
+ * @Harmony
207
+ * @PC
208
+ */
76
209
  scrollIntoViewOptions: {
77
- block: 'start' | 'center' | 'end';
78
- inline: 'start' | 'center' | 'end';
79
- behavior?: 'smooth';
210
+ /**
211
+ * Vertical alignment options: "start" aligns top | "center" centers | "end" aligns bottom
212
+ * @defaultValue 'center'
213
+ * @Android
214
+ * @iOS
215
+ * @Harmony
216
+ * @PC
217
+ */
218
+ block?: 'start' | 'center' | 'end';
219
+ /**
220
+ * Horizontal alignment options: "start" aligns left | "center" centers | "end" aligns right
221
+ * @defaultValue 'start'
222
+ * @Android
223
+ * @iOS
224
+ * @Harmony
225
+ * @PC
226
+ */
227
+ inline?: 'start' | 'center' | 'end';
228
+ /**
229
+ * Specify the scroll behavior.
230
+ * @defaultValue 'smooth'
231
+ * @Android
232
+ * @iOS
233
+ * @Harmony
234
+ * @PC
235
+ */
236
+ behavior?: 'smooth' | 'none';
80
237
  };
81
238
  };
82
239
  }
83
240
 
84
- export type InvokeParams = ListParams | ScrollViewParams | BoundingClientRectMethod | SetFocusMethod | IsAnimatingMethod | ScrollIntoViewMethod;
241
+ export type InvokeParams = ListParams | ScrollViewParams | BoundingClientRectMethod | SetFocusMethod | IsAnimatingMethod | ScrollIntoViewMethod | TakeScreenShotMethod | RequestAccessibilityFocusMethod;
@@ -4,7 +4,6 @@
4
4
 
5
5
  import { BaseEvent, BaseMethod, EventHandler } from '../events';
6
6
  import { StandardProps } from '../props';
7
- import { AutoScrollMethod } from './list';
8
7
  import {
9
8
  ContentSizeChangedEvent,
10
9
  ScrollEndEvent,
@@ -18,172 +17,101 @@ import {
18
17
  } from './common';
19
18
 
20
19
  export interface ScrollViewProps extends StandardProps {
21
- /**
22
- * Scroll horizontaly.
23
- * @defaultValue false
24
- * @since 1.4
25
- * @iOS
26
- * @Android
27
- * @H
28
- */
29
- 'scroll-x'?: boolean;
30
-
31
- /**
32
- * Scroll vertically
33
- * @defaultValue false
34
- * @since 1.4
35
- * @iOS
36
- * @Android
37
- * @H
38
- */
39
- 'scroll-y'?: boolean;
40
-
41
20
  /**
42
21
  * Replacement of scroll-x and scroll-y
22
+ * @defaultValue 'vertical'
43
23
  * @since 3.0
44
24
  * @iOS
45
25
  * @Android
46
- * @H
26
+ * @Harmony
27
+ * @PC
47
28
  */
48
29
  'scroll-orientation'?: 'vertical' | 'horizontal';
49
30
 
50
31
  /**
51
32
  * Enable bounce effect
52
- * @defaultValue false
33
+ * @defaultValue true
53
34
  * @since 1.4
54
35
  * @iOS
55
- * @Android
56
- * @H
36
+ * @Harmony
37
+ * @PC
57
38
  */
58
39
  bounces?: boolean;
59
40
 
60
41
  /**
61
42
  * Enable dragging
62
- * @defaultValue false
43
+ * @defaultValue true
63
44
  * @since 1.4
64
45
  * @iOS
65
46
  * @Android 2.2
66
- * @H
47
+ * @Harmony
48
+ * @PC
67
49
  */
68
50
  'enable-scroll'?: boolean;
69
51
 
70
52
  /**
71
53
  * Enable scrollbar
72
- * @defaultValue false
54
+ * @defaultValue true
73
55
  * @since 1.4
74
56
  * @iOS
75
- * @Android
76
- * @H
57
+ * @Harmony
58
+ * @PC
77
59
  */
78
60
  'scroll-bar-enable'?: boolean;
79
61
 
80
62
  /**
81
- * Not recommended to use. Please use upper-threshold-item-count instead. Set upper threshold to bindscrolltoupper event.
63
+ * Set upper threshold to bindscrolltoupper event.
82
64
  * @defaultValue 0
83
65
  * @since 1.4
84
66
  * @iOS
85
67
  * @Android
86
- * @H
68
+ * @Harmony
69
+ * @PC
87
70
  */
88
71
  'upper-threshold'?: number;
89
72
 
90
73
  /**
91
- * Not recommended to use. Please use lower-threshold-item-count instead. Set upper threshold to bindscrolltoupper event.
74
+ * Set upper threshold to bindscrolltoupper event.
92
75
  * @defaultValue 0
93
76
  * @since 1.4
94
77
  * @iOS
95
78
  * @Android
96
- * @H
79
+ * @Harmony
80
+ * @PC
97
81
  */
98
82
  'lower-threshold'?: number;
99
83
 
100
84
  /**
101
- * Please use initial-scroll-offset or ScrollTo method. Set the content offset from the top.
102
- * @defaultValue 0
103
- * @since 1.4
104
- * @deprecated 2.17
105
- * @iOS
106
- * @Android
107
- * @H
108
- */
109
- 'scroll-top'?: number;
110
-
111
- /**
112
- * Please use initial-scroll-offset or ScrollTo method. Set the content offset from the left.
113
- * @defaultValue 0
114
- * @since 1.4
115
- * @deprecated 2.17
116
- * @iOS
117
- * @Android
118
- * @H
119
- */
120
- 'scroll-left'?: number;
121
-
122
- /**
123
- * Initial scroll position, only effective once
85
+ * Initial scroll position, only effective once, in PX
124
86
  * @defaultValue 0
125
87
  * @since 2.17
126
88
  * @iOS
127
89
  * @Android
128
- * @H
90
+ * @Harmony
91
+ * @PC
129
92
  */
130
93
  'initial-scroll-offset'?: number;
131
94
 
132
- /**
133
- * Please use initial-scroll-index or ScrollTo method。Set the first item at the first screen
134
- * @defaultValue 0
135
- * @since 2.1
136
- * @deprecated 2.17
137
- * @iOS
138
- * @Android
139
- */
140
- 'scroll-to-index'?: number;
141
-
142
95
  /**
143
96
  * Scroll to specified child node on first screen, only effective once. All direct child nodes must be flatten=false.
144
97
  * @defaultValue 0
145
98
  * @since 2.17
146
99
  * @iOS
147
100
  * @Android
148
- * @H
101
+ * @Harmony
102
+ * @PC
149
103
  */
150
104
  'initial-scroll-to-index'?: number;
151
105
 
152
- /**
153
- * On iOS, force-can-scroll should be used with ios-block-gesture-class and ios-recognized-view-tag. Can be used alone on Android.
154
- * @defaultValue false
155
- * @since 2.10.1
156
- * @iOS
157
- * @Android
158
- * @H
159
- */
160
- 'force-can-scroll'?: boolean;
161
-
162
- /**
163
- * Force-can-scroll should be used with ios-block-gesture-class、ios-recognized-view-tag. Specify the class name of scrollable container that should be blocked by force-can-scroll. Given by container's developer.
164
- * @defaultValue none
165
- * @since 2.10.1
166
- * @iOS
167
- */
168
- 'ios-block-gesture-class'?: string;
169
-
170
- /**
171
- * force-can-scroll should be used with ios-block-gesture-class、ios-recognized-view-tag. Specify scrollable container's tag, the UIView's tag. Set and given by container's developer.
172
- * @defaultValue none
173
- * @since 2.10.1
174
- * @iOS
175
- */
176
- 'ios-recognized-view-tag'?: number;
177
-
178
106
  /**
179
107
  * This event is triggered when the upper/left edge of the scrolling area intersects with the visible area defined by the upperThreshold.
180
108
  * @defaultValue none
181
109
  * @since 1.4
182
110
  * @iOS
183
111
  * @Android
184
- * @H
112
+ * @Harmony
185
113
  */
186
- bindscrolltoupper?: EventHandler<ScrollToUpperEvent>;
114
+ bindscrolltoupper?: (e: ScrollToUpperEvent) => void;
187
115
 
188
116
  /**
189
117
  * This event is triggered when the lower/right edge of the scrolling area intersects with the visible area defined by the lowerThreshold.
@@ -191,9 +119,9 @@ export interface ScrollViewProps extends StandardProps {
191
119
  * @since 1.4
192
120
  * @iOS
193
121
  * @Android
194
- * @H
122
+ * @Harmony
195
123
  */
196
- bindscrolltolower?: EventHandler<ScrollToLowerEvent>;
124
+ bindscrolltolower?: (e: ScrollToLowerEvent) => void;
197
125
 
198
126
  /**
199
127
  * This event is triggered when the scrollview is scrolling.
@@ -201,9 +129,10 @@ export interface ScrollViewProps extends StandardProps {
201
129
  * @since 1.4
202
130
  * @iOS
203
131
  * @Android
204
- * @H
132
+ * @Harmony
133
+ * @PC
205
134
  */
206
- bindscroll?: EventHandler<ScrollEvent>;
135
+ bindscroll?: (e: ScrollEvent) => void;
207
136
 
208
137
  /**
209
138
  * This event is triggered when the scrollview's scroll ended.
@@ -211,9 +140,10 @@ export interface ScrollViewProps extends StandardProps {
211
140
  * @since 1.6
212
141
  * @iOS
213
142
  * @Android
214
- * @H
143
+ * @Harmony
144
+ * @PC
215
145
  */
216
- bindscrollend?: EventHandler<ScrollEndEvent>;
146
+ bindscrollend?: (e: ScrollEndEvent) => void;
217
147
 
218
148
  /**
219
149
  * This event is triggered when the scrollview's content size changed.
@@ -221,42 +151,19 @@ export interface ScrollViewProps extends StandardProps {
221
151
  * @since 1.6
222
152
  * @iOS
223
153
  * @Android
224
- * @H
225
- */
226
- bindcontentsizechanged?: EventHandler<ContentSizeChangedEvent>;
227
-
228
- /**
229
- * scrollview scrolls to upper edge
230
- * @defaultValue none
231
- * @since 3.0
232
- * @iOS
233
- * @Android
234
- * @H
154
+ * @Harmony
235
155
  */
236
- bindscrolltoupperedge?: EventHandler<ScrollToUpperEdgeEvent>;
237
-
238
- /**
239
- * scrollview scrolls to lower edge
240
- * @defaultValue none
241
- * @since 3.0
242
- * @iOS
243
- * @Android
244
- * @H
245
- */
246
- bindscrolltoloweredge?: EventHandler<ScrollToLowerEdgeEvent>;
247
-
248
- /**
249
- * scrollview scrolls to normal position. Not at upper or lower edge
250
- * @defaultValue none
251
- * @since 3.0
252
- * @iOS
253
- * @Android
254
- * @H
255
- */
256
- bindscrolltonormalstate?: EventHandler<ScrollToNormalStateEvent>;
156
+ bindcontentsizechanged?: (e: ContentSizeChangedEvent) => void;
257
157
  }
258
158
 
259
- export interface ScrollToMethod extends BaseMethod {
159
+ /**
160
+ * Scroll to specified position
161
+ * @Android
162
+ * @iOS
163
+ * @Harmony
164
+ * @PC
165
+ */
166
+ export interface ScrollViewScrollToMethod extends BaseMethod {
260
167
  method: 'scrollTo';
261
168
  params: {
262
169
  /**
@@ -277,4 +184,52 @@ export interface ScrollToMethod extends BaseMethod {
277
184
  };
278
185
  }
279
186
 
280
- export type ScrollViewUIMethods = ScrollToMethod | AutoScrollMethod;
187
+ /**
188
+ * Scroll by specified offset
189
+ * @Android
190
+ * @iOS
191
+ * @Harmony
192
+ * @PC
193
+ */
194
+ export interface ScrollViewScrollByMethod extends BaseMethod {
195
+ method: 'scrollBy';
196
+ params: {
197
+ /**
198
+ * Offset to scroll
199
+ */
200
+ offset?: number;
201
+ };
202
+ }
203
+
204
+
205
+
206
+ /**
207
+ * Automatic scrolling
208
+ * @Android
209
+ * @iOS
210
+ * @Harmony
211
+ * @PC
212
+ */
213
+ export interface ScrollViewAutoScrollMethod extends BaseMethod {
214
+ method: 'autoScroll';
215
+ params: {
216
+ /**
217
+ * The distance of each second's scrolling, which supports positive and negative values. The unit of distance can be "px", "rpx", "ppx", or null (for iOS, the value must be greater than 1/screen.scale px).
218
+ * @Android
219
+ * @iOS
220
+ * @Harmony
221
+ * @PC
222
+ */
223
+ rate: number;
224
+ /**
225
+ * Start/stop automatic scrolling.
226
+ * @Android
227
+ * @iOS
228
+ * @Harmony
229
+ * @PC
230
+ */
231
+ start: boolean;
232
+ };
233
+ }
234
+
235
+ export type ScrollViewUIMethods = ScrollViewScrollToMethod | ScrollViewScrollByMethod | ScrollViewAutoScrollMethod;
@@ -11,14 +11,16 @@ import { StandardProps } from '../props';
11
11
  export interface TextProps extends StandardProps {
12
12
  /**
13
13
  * Maximum number of lines for text display
14
- * @defaultValue "-1"
14
+ * @Android
15
+ * @iOS
16
+ * @Harmony
17
+ * @PC
15
18
  * @since 1.0
16
19
  */
17
20
  'text-maxline'?: string;
18
21
 
19
22
  /**
20
23
  * Maximum number of characters for text display
21
- * @defaultValue ""
22
24
  * @since 1.0
23
25
  * @deprecated Suggest preprocessing the text content length.
24
26
  */
@@ -27,6 +29,7 @@ export interface TextProps extends StandardProps {
27
29
  /**
28
30
  * Whether font-size is affected by system font scaling
29
31
  * @defaultValue false
32
+ * @deprecated
30
33
  * @since 1.6
31
34
  */
32
35
  'enable-font-scaling'?: boolean;
@@ -42,15 +45,18 @@ export interface TextProps extends StandardProps {
42
45
  /**
43
46
  * By default, if text truncation occurs, the color of the inserted ... will be specified by the style on the nearest inline-text. If this attribute is enabled, the color of ... will be specified by the style on the outermost text tag.
44
47
  * @defaultValue false
48
+ * @Android
49
+ * @iOS
45
50
  * @since 2.0
46
51
  */
47
52
  'tail-color-convert'?: boolean;
48
53
 
49
54
  /**
50
55
  * Set single-line plain text to be centered and aligned within the line. Inline text settings are not supported. Recommended only when the default font doesn't meet center alignment needs, as it increases text measurement time.
51
- * @defaultValue normal
56
+ * @defaultValue 'normal'
52
57
  * @iOS
53
58
  * @Android
59
+ * @PC
54
60
  * @since 2.12
55
61
  */
56
62
  'text-single-line-vertical-align'?: 'normal' | 'bottom' | 'center' | 'top';
@@ -110,11 +116,17 @@ export interface TextProps extends StandardProps {
110
116
  /**
111
117
  * Text layout event
112
118
  * @since 2.7
119
+ * @Android
120
+ * @iOS
121
+ * @Harmony
122
+ * @PC
113
123
  */
114
124
  bindlayout?: (e: LayoutEvent) => void;
115
125
 
116
126
  /**
117
127
  * Text selection change event
128
+ * @Android
129
+ * @iOS
118
130
  * @since 2.18
119
131
  */
120
132
  bindselectionchange?: (e: SelectionChangeEvent) => void;
@@ -205,6 +217,7 @@ interface SetTextSelectionMethod extends BaseMethod {
205
217
  * Gets the bounding rectangle of the text.
206
218
  * @Android
207
219
  * @iOS
220
+ * @PC
208
221
  * @since 2.18
209
222
  */
210
223
  interface GetTextBoundingRectMethod extends BaseMethod {
@@ -152,7 +152,7 @@ export interface TextAreaProps extends Omit<StandardProps, 'bindfocus' | 'bindbl
152
152
  */
153
153
  'line-spacing'?: number | `${number}px` | `${number}rpx`;
154
154
  /**
155
- * Interaction enabled
155
+ * Readonly
156
156
  * @defaultValue false
157
157
  * @Android
158
158
  * @iOS
@@ -162,6 +162,16 @@ export interface TextAreaProps extends Omit<StandardProps, 'bindfocus' | 'bindbl
162
162
  */
163
163
  readonly?: boolean;
164
164
 
165
+ /**
166
+ * Interaction enabled
167
+ * @defaultValue false
168
+ * @Android
169
+ * @iOS
170
+ * @Harmony
171
+ * @since 3.5
172
+ */
173
+ disabled?: boolean;
174
+
165
175
  /**
166
176
  * Show soft input keyboard while focused
167
177
  * @defaultValue true