• 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
17Describes 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    | Widget name.                                |
27| description | string               | Yes   | No    | Description of the widget.  |
28| descriptionId<sup>10+</sup>      | number               | Yes   | No    | ID of the widget description.              |
29| type        | [FormType](#formtype)             | Yes   | No    | Type of the widget. Currently, JS and ArkTS widgets are supported.|
30| jsComponentName      | string               | Yes   | No    | Name of the component used in the JS widget.              |
31| colorMode  | [ColorMode](#colormode) | Yes   | No    | Color mode of the widget.                                      |
32| isDefault    | boolean      | Yes   | No    | Whether the widget is the default one.                             |
33| updateEnabled  | boolean               | Yes   | No    | Whether the widget is updatable.                   |
34| formVisibleNotify  | boolean        | Yes   | No    | Whether to send a notification when the widget is visible.           |
35| scheduledUpdateTime        | string               | Yes   | No    | Time when the widget was updated.    |
36| 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.  |
37| updateDuration        | number       | Yes   | No    | Update period of the widget.|
38| defaultDimension  | number | Yes   | No    | Default dimension of the widget.                                      |
39| supportDimensions    | Array&lt;number&gt;      | Yes   | No    | Dimensions supported by the widget. For details, see [FormDimension](#formdimension).  |
40| customizeData    | {[key: string]: [value: string]}      | Yes   | No    | Custom data of the widget.        |
41| 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.              |
42
43## FormType
44
45Enumerates the widget types.
46
47**System capability**: SystemCapability.Ability.Form
48
49| Name       | Value  | Description        |
50| ----------- | ---- | ------------ |
51| JS      | 1    | JS widget.  |
52| eTS     | 2    | ArkTS widget.|
53
54## ColorMode
55
56Enumerates the color modes supported by the widget.
57
58**System capability**: SystemCapability.Ability.Form
59
60| Name       | Value  | Description        |
61| ----------- | ---- | ------------ |
62| MODE_AUTO   | -1    | Auto mode.  |
63| MODE_DARK    | 0   | Dark mode.  |
64| MODE_LIGHT     | 1   | Light mode.  |
65
66## FormStateInfo
67
68Describes the widget state information.
69
70**System capability**: SystemCapability.Ability.Form
71
72| Name       | Type                | Readable   | Writable   | Description                                                        |
73| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
74| formState  | [FormState](#formstate)               | Yes   | No    | Widget state.                         |
75| want  | [Want](js-apis-app-ability-want.md)         | Yes   | No    | Want text.   |
76
77##  FormState
78
79Enumerates the widget states.
80
81**System capability**: SystemCapability.Ability.Form
82
83| Name       | Value  | Description        |
84| ----------- | ---- | ------------ |
85| UNKNOWN    | -1    | Unknown state.  |
86| DEFAULT     | 0   | Default state.  |
87| READY      | 1   | Ready state.  |
88
89##  FormParam
90
91Enumerates the widget parameters.
92
93**System capability**: SystemCapability.Ability.Form
94
95| Name       | Value  | Description        |
96| ----------- | ---- | ------------ |
97| IDENTITY_KEY     | 'ohos.extra.param.key.form_identity'    | Widget ID.  |
98| DIMENSION_KEY      | 'ohos.extra.param.key.form_dimension'  | Widget dimension.  |
99| NAME_KEY       | 'ohos.extra.param.key.form_name'   | Widget name.  |
100| MODULE_NAME_KEY        | 'ohos.extra.param.key.module_name'   | Name of the module to which the widget belongs.  |
101| WIDTH_KEY        | 'ohos.extra.param.key.form_width'   | Widget width.  |
102| HEIGHT_KEY         | 'ohos.extra.param.key.form_height'   | Widget height.  |
103| TEMPORARY_KEY          | 'ohos.extra.param.key.form_temporary'   | Temporary widget.  |
104| ABILITY_NAME_KEY   | 'ohos.extra.param.key.ability_name'   | Ability name. |
105| 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. |
106| BUNDLE_NAME_KEY    | 'ohos.extra.param.key.bundle_name'   | Key that specifies the target bundle name.|
107| LAUNCH_REASON_KEY<sup>10+</sup>    | 'ohos.extra.param.key.form_launch_reason'   | Reason for creating the widget.  |
108| PARAM_FORM_CUSTOMIZE_KEY<sup>10+</sup>    | 'ohos.extra.param.key.form_customize'   | Custom data.  |
109
110##  FormDimension
111
112Enumerates the widget dimensions.
113
114**System capability**: SystemCapability.Ability.Form
115
116| Name       | Value  | Description        |
117| ----------- | ---- | ------------ |
118| Dimension_1_2      | 1   | 1 x 2.  |
119| Dimension_2_2      | 2   | 2 x 2.  |
120| Dimension_2_4      | 3   | 2 x 4.  |
121| Dimension_4_4      | 4   | 4 x 4.  |
122| Dimension_2_1      | 5   | 2 x 1.  |
123
124
125## FormInfoFilter
126
127Defines the widget information filter. Only the widget information that meets the filter is returned.
128
129**System capability**: SystemCapability.Ability.Form
130
131| Name       | Type  | Mandatory        |Description        |
132| ----------- | ---- | ------------ |------------ |
133| 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.  |
134
135## VisibilityType
136
137Enumerates the visibility types of the widget.
138
139**System capability**: SystemCapability.Ability.Form
140
141| Name       |  Value  | Description        |
142| ----------- | ---- | ------------ |
143| UNKNOWN<sup>10+</sup> | 0   | The visibility type of the widget is unknown.|
144| FORM_VISIBLE | 1   | The widget is visible.|
145| FORM_INVISIBLE   | 2   | The widget is invisible.|
146
147## RunningFormInfo<sup>10+</sup>
148
149Defines the information about the widget host.
150
151**System capability**: SystemCapability.Ability.Form
152
153**System API**: This is a system API and cannot be called by third-party applications.
154
155| Name       | Type                | Readable   | Writable   | Description                                                        |
156| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
157| formId  | string               | Yes   | No    | Widget ID.                  |
158| bundleName<sup>10+</sup>  | string               | Yes   | No    | Name of the bundle to which the widget provider belongs.                  |
159| hostBundleName  | string               | Yes   | No    | Name of the bundle to which the widget host belongs.                  |
160| visibilityType  | [VisibilityType](#visibilitytype)               | Yes   | No    | Visibility types of the widget.                  |
161| moduleName<sup>10+</sup>  | string               | Yes   | No    | Name of the module to which the widget belongs.                     |
162| abilityName<sup>10+</sup> | string               | Yes   | No    | Name of the ability to which the widget belongs.                      |
163| formName<sup>10+</sup>        | string               | Yes   | No    | Widget name.                                |
164| dimension | number               | Yes   | No    | Widget specifications.  |
165
166## formProviderFilter<sup>10+</sup>
167
168Defines the information about the widget provider.
169
170**System capability**: SystemCapability.Ability.Form
171
172**System API**: This is a system API and cannot be called by third-party applications.
173
174| Name       | Type                | Readable   | Writable   | Description                                                        |
175| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
176| bundleName  | string               | Yes   | No    | Name of the bundle to which the widget provider belongs.<br>**Model restriction**: This API can be used only in the stage model.<br> |
177| formName    | string               | Yes   | No    | Widget name.<br>**Model restriction**: This API can be used only in the stage model.<br>                    |
178| moduleName  | string               | Yes   | No    | Name of the module to which the widget belongs.<br>**Model restriction**: This API can be used only in the stage model.<br>       |
179| abilityName | string               | Yes   | No    | Name of the ability to which the widget belongs.<br>**Model restriction**: This API can be used only in the stage model.<br>       |
180
181## LaunchReason<sup>10+</sup>
182
183Enumerates the reasons for creating a widget.
184
185**System capability**: SystemCapability.Ability.Form
186
187| Name       |  Value  | Description        |
188| ----------- | ---- | ------------ |
189| FORM_DEFAULT | 1   | The widget is created by default.|
190| FORM_SHARE   | 2   | The widget is created for sharing.|
191