• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.app.form.formInfo (formInfo)
2
3The **formInfo** module provides types and enums related to the widget information and state.
4
5> **NOTE**
6>
7> The initial APIs of this module are supported since API version 9. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8
9## Modules to Import
10
11```ts
12import formInfo from '@ohos.app.form.formInfo';
13```
14
15## FormInfo
16
17Defines the widget information.
18
19**System capability**: SystemCapability.Ability.Form
20
21| Name       | Type                | Readable   | Writable   | Description                                                        |
22| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
23| bundleName  | string               | Yes   | No    | Name of the bundle to which the widget belongs.                  |
24| moduleName  | string               | Yes   | No    | Name of the module to which the widget belongs.                     |
25| abilityName | string               | Yes   | No    | Name of the ability to which the widget belongs.                      |
26| name        | string               | Yes   | No    | Name of an application or ability.                                |
27| displayName<sup>11+</sup> | string               | Yes   | No    | Widget name.                                |
28| description | string               | Yes   | No    | Description of the widget.  |
29| descriptionId<sup>10+</sup>      | number               | Yes   | No    | ID of the widget description.              |
30| type        | [FormType](#formtype)             | Yes   | No    | Type of the widget. Currently, JS and ArkTS widgets are supported.|
31| jsComponentName      | string               | Yes   | No    | Name of the component used in the JS widget.              |
32| colorMode  | [ColorMode](#colormode) | Yes   | No    | Color mode of the widget.                                      |
33| isDefault    | boolean      | Yes   | No    | Whether the widget is the default one.                             |
34| updateEnabled  | boolean               | Yes   | No    | Whether the widget is updatable.                   |
35| formVisibleNotify  | boolean        | Yes   | No    | Whether to send a notification when the widget is visible.           |
36| scheduledUpdateTime        | string               | Yes   | No    | Time when the widget was updated.    |
37| formConfigAbility | string               | Yes   | No    | Configuration ability of the widget, that is, the ability corresponding to the option in the selection box displayed when the widget is long pressed.  |
38| updateDuration        | number       | Yes   | No    | Update period of the widget.|
39| defaultDimension  | number | Yes   | No    | Default dimension of the widget.                                      |
40| supportDimensions    | Array&lt;number&gt;      | Yes   | No    | Dimensions supported by the widget. For details, see [FormDimension](#formdimension).  |
41| customizeData    | Record\<string, string>      | Yes   | No    | Custom data of the widget.        |
42| isDynamic<sup>10+</sup>      | boolean               | Yes   | No    | Whether the widget is a dynamic widget.<br>ArkTS widgets are classified into dynamic and static widgets. JS widgets are all dynamic widgets.              |
43| transparencyEnabled<sup>11+</sup>      | boolean               | Yes   | No    | Whether the widget supports the setting of the background transparency.<br>For ArkTS widgets, the support for the background transparency setting depends on user configurations. For JS widgets, the background transparency setting is not supported.              |
44
45## FormType
46
47Enumerates the widget types.
48
49**System capability**: SystemCapability.Ability.Form
50
51| Name       | Value  | Description        |
52| ----------- | ---- | ------------ |
53| JS      | 1    | JS widget.  |
54| eTS     | 2    | ArkTS widget.|
55
56## ColorMode
57
58Enumerates the color modes supported by the widget.
59
60**System capability**: SystemCapability.Ability.Form
61
62| Name       | Value  | Description        |
63| ----------- | ---- | ------------ |
64| MODE_AUTO   | -1    | Auto mode.  |
65| MODE_DARK    | 0   | Dark mode.  |
66| MODE_LIGHT     | 1   | Light mode.  |
67
68## FormStateInfo
69
70Describes the widget state information.
71
72**System capability**: SystemCapability.Ability.Form
73
74| Name       | Type                | Readable   | Writable   | Description                                                        |
75| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
76| formState  | [FormState](#formstate)               | Yes   | No    | Widget state.                         |
77| want  | [Want](js-apis-app-ability-want.md)         | Yes   | No    | Want text.   |
78
79##  FormState
80
81Enumerates the widget states.
82
83**System capability**: SystemCapability.Ability.Form
84
85| Name       | Value  | Description        |
86| ----------- | ---- | ------------ |
87| UNKNOWN    | -1    | Unknown state.  |
88| DEFAULT     | 0   | Default state.  |
89| READY      | 1   | Ready state.  |
90
91##  FormParam
92
93Enumerates the widget parameters.
94
95**System capability**: SystemCapability.Ability.Form
96
97| Name       | Value  | Description        |
98| ----------- | ---- | ------------ |
99| IDENTITY_KEY     | 'ohos.extra.param.key.form_identity'    | Widget ID.  |
100| DIMENSION_KEY      | 'ohos.extra.param.key.form_dimension'  | Widget dimension.  |
101| NAME_KEY       | 'ohos.extra.param.key.form_name'   | Widget name.  |
102| MODULE_NAME_KEY        | 'ohos.extra.param.key.module_name'   | Name of the module to which the widget belongs.  |
103| WIDTH_KEY        | 'ohos.extra.param.key.form_width'   | Widget width.  |
104| HEIGHT_KEY         | 'ohos.extra.param.key.form_height'   | Widget height.  |
105| TEMPORARY_KEY          | 'ohos.extra.param.key.form_temporary'   | Temporary widget.  |
106| ABILITY_NAME_KEY   | 'ohos.extra.param.key.ability_name'   | Ability name. |
107| DEVICE_ID_KEY    | 'ohos.extra.param.key.device_id'   | Device ID.<br>**System API**: This is a system API and cannot be called by third-party applications. |
108| BUNDLE_NAME_KEY    | 'ohos.extra.param.key.bundle_name'   | Key that specifies the target bundle name.|
109| LAUNCH_REASON_KEY<sup>10+</sup>    | 'ohos.extra.param.key.form_launch_reason'   | Reason for creating the widget.  |
110| PARAM_FORM_CUSTOMIZE_KEY<sup>10+</sup>    | 'ohos.extra.param.key.form_customize'   | Custom data.  |
111| FORM_RENDERING_MODE_KEY<sup>11+</sup>    | 'ohos.extra.param.key.form_rendering_mode'   | Widget rendering mode. |
112
113##  FormDimension
114
115Enumerates the widget dimensions.
116
117**System capability**: SystemCapability.Ability.Form
118
119| Name       | Value  | Description        |
120| ----------- | ---- | ------------ |
121| Dimension_1_2      | 1   | 1 x 2.  |
122| Dimension_2_2      | 2   | 2 x 2.  |
123| Dimension_2_4      | 3   | 2 x 4.  |
124| Dimension_4_4      | 4   | 4 x 4.  |
125| Dimension_2_1      | 5   | 2 x 1.  |
126| DIMENSION_1_1      | 6   | 1 x 1.  |
127
128
129## FormInfoFilter
130
131Defines the widget information filter. Only the widget information that meets the filter is returned.
132
133**System capability**: SystemCapability.Ability.Form
134
135| Name       | Type  | Mandatory        |Description        |
136| ----------- | ---- | ------------ |------------ |
137| moduleName    | string    |No   | Optional. Only the information about the widget whose **moduleName** is the same as the provided value is returned.<br>If this parameter is not set, **moduleName** is not used for filtering.  |
138
139## VisibilityType
140
141Enumerates the visibility types of the widget.
142
143**System capability**: SystemCapability.Ability.Form
144
145| Name       |  Value  | Description        |
146| ----------- | ---- | ------------ |
147| UNKNOWN<sup>10+</sup> | 0   | The visibility type of the widget is unknown.|
148| FORM_VISIBLE | 1   | The widget is visible.|
149| FORM_INVISIBLE   | 2   | The widget is invisible.|
150
151## FormUsageState
152
153Enumerates the usage statuses of widgets.
154
155**System capability**: SystemCapability.Ability.Form
156
157**System API**: This is a system API and cannot be called by third-party applications.
158
159| Name       |  Value  | Description        |
160| ----------- | ---- | ------------ |
161| USED<sup>11+</sup> | 0   | The widget is in use.|
162| UNUSED<sup>11+</sup> | 1   | The widget is not in use.|
163
164## RunningFormInfo<sup>10+</sup>
165
166Defines the information about an added widget, which can be either in use or not.
167
168**System capability**: SystemCapability.Ability.Form
169
170**System API**: This is a system API and cannot be called by third-party applications.
171
172| Name       | Type                | Readable   | Writable   | Description                                                        |
173| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
174| formId  | string               | Yes   | No    | Widget ID.                  |
175| bundleName<sup>10+</sup>  | string               | Yes   | No    | Name of the bundle to which the widget provider belongs.                  |
176| hostBundleName  | string               | Yes   | No    | Name of the bundle to which the widget host belongs.                  |
177| visibilityType  | [VisibilityType](#visibilitytype)               | Yes   | No    | Visibility types of the widget.                  |
178| moduleName<sup>10+</sup>  | string               | Yes   | No    | Name of the module to which the widget belongs.                     |
179| abilityName<sup>10+</sup> | string               | Yes   | No    | Name of the ability to which the widget belongs.                      |
180| formName<sup>10+</sup>        | string               | Yes   | No    | Widget name.                                |
181| dimension | number               | Yes   | No    | Widget specifications.  |
182| formUsageState<sup>11+</sup> | [FormUsageState](#formusagestate)         | Yes   | No    | Usage status of the widget.  |
183| formDescription<sup>11+</sup> | string         | Yes   | No    | Description in the widget configuration file of the provider.  |
184
185## formProviderFilter<sup>10+</sup>
186
187Defines the information about the widget provider.
188
189**Model restriction**: This API can be used only in the stage model.
190
191**System capability**: SystemCapability.Ability.Form
192
193**System API**: This is a system API and cannot be called by third-party applications.
194
195| Name       | Type                | Readable   | Writable   | Description                                                        |
196| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
197| bundleName  | string               | Yes   | No    | Name of the bundle to which the widget provider belongs. |
198| formName    | string               | Yes   | No    | Widget name.                    |
199| moduleName  | string               | Yes   | No    | Name of the module to which the widget belongs.       |
200| abilityName | string               | Yes   | No    | Name of the ability to which the widget belongs.       |
201| isUnusedIncluded<sup>11+</sup> | boolean               | Yes   | No    | Whether an unused widget is included.       |
202
203## LaunchReason<sup>10+</sup>
204
205Enumerates the reasons for creating a widget.
206
207**System capability**: SystemCapability.Ability.Form
208
209| Name       |  Value  | Description        |
210| ----------- | ---- | ------------ |
211| FORM_DEFAULT | 1   | The widget is created by default.|
212| FORM_SHARE   | 2   | The widget is created for sharing.|
213