• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import Want from './@ohos.app.ability.Want';
17
18/**
19 * interface of formInfo.
20 *
21 * @namespace formInfo
22 * @syscap SystemCapability.Ability.Form
23 * @since 9
24 */
25declare namespace formInfo {
26  /**
27   * Provides information about a form.
28   *
29   * @typedef FormInfo
30   * @syscap SystemCapability.Ability.Form
31   * @since 9
32   */
33  interface FormInfo {
34    /**
35     * Obtains the bundle name of the application to which this form belongs.
36     *
37     * @type { string }
38     * @syscap SystemCapability.Ability.Form
39     * @since 9
40     */
41    bundleName: string;
42
43    /**
44     * Obtains the name of the application module to which this form belongs.
45     *
46     * @type { string }
47     * @syscap SystemCapability.Ability.Form
48     * @since 9
49     */
50    moduleName: string;
51
52    /**
53     * Obtains the class name of the ability to which this form belongs.
54     *
55     * @type { string }
56     * @syscap SystemCapability.Ability.Form
57     * @since 9
58     */
59    abilityName: string;
60
61    /**
62     * Obtains the name of this form.
63     *
64     * @type { string }
65     * @syscap SystemCapability.Ability.Form
66     * @since 9
67     */
68    name: string;
69
70    /**
71     * Obtains the description of this form.
72     *
73     * @type { string }
74     * @syscap SystemCapability.Ability.Form
75     * @since 9
76     */
77    description: string;
78
79    /**
80     * Obtains the description id of this form.
81     *
82     * @type { number }
83     * @syscap SystemCapability.Ability.Form
84     * @since 10
85     */
86    descriptionId: number;
87
88    /**
89     * Obtains the type of this form. Currently, JS forms are supported.
90     *
91     * @type { FormType }
92     * @syscap SystemCapability.Ability.Form
93     * @since 9
94     */
95    type: FormType;
96
97    /**
98     * Obtains the JS component name of this JS form.
99     *
100     * @type { string }
101     * @syscap SystemCapability.Ability.Form
102     * @since 9
103     */
104    jsComponentName: string;
105
106    /**
107     * Obtains the color mode of this form.
108     *
109     * @type { ColorMode }
110     * @syscap SystemCapability.Ability.Form
111     * @since 9
112     */
113    colorMode: ColorMode;
114
115    /**
116     * Checks whether this form is a default form.
117     *
118     * @type { boolean }
119     * @syscap SystemCapability.Ability.Form
120     * @since 9
121     */
122    isDefault: boolean;
123
124    /**
125     * Obtains the updateEnabled.
126     *
127     * @type { boolean }
128     * @syscap SystemCapability.Ability.Form
129     * @since 9
130     */
131    updateEnabled: boolean;
132
133    /**
134     * Obtains whether notify visible of this form.
135     *
136     * @type { boolean }
137     * @syscap SystemCapability.Ability.Form
138     * @since 9
139     */
140    formVisibleNotify: boolean;
141
142    /**
143     * Obtains the scheduledUpdateTime.
144     *
145     * @type { string }
146     * @syscap SystemCapability.Ability.Form
147     * @since 9
148     */
149    scheduledUpdateTime: string;
150
151    /**
152     * Obtains the form config ability about this form.
153     *
154     * @type { string }
155     * @syscap SystemCapability.Ability.Form
156     * @since 9
157     */
158    formConfigAbility: string;
159
160    /**
161     * Obtains the updateDuration.
162     *
163     * @type { number }
164     * @syscap SystemCapability.Ability.Form
165     * @since 9
166     */
167    updateDuration: number;
168
169    /**
170     * Obtains the default grid style of this form.
171     *
172     * @type { number }
173     * @syscap SystemCapability.Ability.Form
174     * @since 9
175     */
176    defaultDimension: number;
177
178    /**
179     * Obtains the grid styles supported by this form.
180     *
181     * @type { Array<number> }
182     * @syscap SystemCapability.Ability.Form
183     * @since 9
184     */
185    supportDimensions: Array<number>;
186
187    /**
188     * Obtains the custom data defined in this form.
189     *
190     * @type { object }
191     * @syscap SystemCapability.Ability.Form
192     * @since 9
193     */
194    customizeData: { [key: string]: [value: string] };
195
196    /**
197     * Obtains whether this form is a dynamic form.
198     *
199     * @type { boolean }
200     * @syscap SystemCapability.Ability.Form
201     * @since 10
202     */
203    isDynamic: boolean;
204  }
205
206  /**
207   * Type of form.
208   *
209   * @enum { number }
210   * @syscap SystemCapability.Ability.Form
211   * @since 9
212   */
213  enum FormType {
214    /**
215     * JS form.
216     *
217     * @syscap SystemCapability.Ability.Form
218     * @since 9
219     */
220    JS = 1,
221
222    /**
223     * eTS form.
224     *
225     * @syscap SystemCapability.Ability.Form
226     * @since 9
227     */
228    eTS = 2
229  }
230
231  /**
232   * Color mode.
233   *
234   * @enum { number }
235   * @syscap SystemCapability.Ability.Form
236   * @since 9
237   */
238  enum ColorMode {
239    /**
240     * Automatic mode.
241     *
242     * @syscap SystemCapability.Ability.Form
243     * @since 9
244     */
245    MODE_AUTO = -1,
246
247    /**
248     * Dark mode.
249     *
250     * @syscap SystemCapability.Ability.Form
251     * @since 9
252     */
253    MODE_DARK = 0,
254
255    /**
256     * Light mode.
257     *
258     * @syscap SystemCapability.Ability.Form
259     * @since 9
260     */
261    MODE_LIGHT = 1
262  }
263
264  /**
265   * Provides state information about a form.
266   *
267   * @typedef FormStateInfo
268   * @syscap SystemCapability.Ability.Form
269   * @since 9
270   */
271  interface FormStateInfo {
272    /**
273     * Obtains the form state.
274     *
275     * @type { FormState }
276     * @syscap SystemCapability.Ability.Form
277     * @since 9
278     */
279    formState: FormState;
280
281    /**
282     * Obtains the want form .
283     *
284     * @type { Want }
285     * @syscap SystemCapability.Ability.Form
286     * @since 9
287     */
288    want: Want;
289  }
290
291  /**
292   * Provides state about a form.
293   *
294   * @enum { number }
295   * @syscap SystemCapability.Ability.Form
296   * @since 9
297   */
298  enum FormState {
299    /**
300     * Indicates that the form status is unknown due to an internal error.
301     *
302     * @syscap SystemCapability.Ability.Form
303     * @since 9
304     */
305    UNKNOWN = -1,
306
307    /**
308     * Indicates that the form is in the default state.
309     *
310     * @syscap SystemCapability.Ability.Form
311     * @since 9
312     */
313    DEFAULT = 0,
314
315    /**
316     * Indicates that the form is ready.
317     *
318     * @syscap SystemCapability.Ability.Form
319     * @since 9
320     */
321    READY = 1
322  }
323
324  /**
325   * Parameter of form.
326   *
327   * @enum { string }
328   * @syscap SystemCapability.Ability.Form
329   * @since 9
330   */
331  enum FormParam {
332    /**
333     * Indicates the key specifying the ID of the form to be obtained, which is represented as
334     * want: {
335     *   "parameters": {
336     *       IDENTITY_KEY: "119476135"
337     *    }
338     * }.
339     *
340     * @syscap SystemCapability.Ability.Form
341     * @since 9
342     */
343    IDENTITY_KEY = 'ohos.extra.param.key.form_identity',
344
345    /**
346     * Indicates the key specifying the grid style of the form to be obtained, which is represented as
347     * want: {
348     *   "parameters": {
349     *       DIMENSION_KEY: FormDimension.Dimension_1_2
350     *    }
351     * }.
352     *
353     * @syscap SystemCapability.Ability.Form
354     * @since 9
355     */
356    DIMENSION_KEY = 'ohos.extra.param.key.form_dimension',
357
358    /**
359     * Indicates the key specifying the name of the form to be obtained, which is represented as
360     * want: {
361     *   "parameters": {
362     *       NAME_KEY: "formName"
363     *    }
364     * }.
365     *
366     * @syscap SystemCapability.Ability.Form
367     * @since 9
368     */
369    NAME_KEY = 'ohos.extra.param.key.form_name',
370
371    /**
372     * Indicates the key specifying the name of the module to which the form to be obtained belongs, which is
373     * represented as
374     * want: {
375     *   "parameters": {
376     *       MODULE_NAME_KEY: "formEntry"
377     *    }
378     * }
379     * This constant is mandatory.
380     *
381     * @syscap SystemCapability.Ability.Form
382     * @since 9
383     */
384    MODULE_NAME_KEY = 'ohos.extra.param.key.module_name',
385
386    /**
387     * Indicates the key specifying the width of the form to be obtained, which is represented as
388     * want: {
389     *   "parameters": {
390     *       WIDTH_KEY: 800
391     *    }
392     * }
393     *
394     * @syscap SystemCapability.Ability.Form
395     * @since 9
396     */
397    WIDTH_KEY = 'ohos.extra.param.key.form_width',
398
399    /**
400     * Indicates the key specifying the height of the form to be obtained, which is represented as
401     * want: {
402     *   "parameters": {
403     *       HEIGHT_KEY: 400
404     *    }
405     * }
406     *
407     * @syscap SystemCapability.Ability.Form
408     * @since 9
409     */
410    HEIGHT_KEY = 'ohos.extra.param.key.form_height',
411
412    /**
413     * Indicates the key specifying whether a form is temporary, which is represented as
414     * want: {
415     *   "parameters": {
416     *       TEMPORARY_KEY: true
417     *    }
418     * }
419     *
420     * @syscap SystemCapability.Ability.Form
421     * @since 9
422     */
423    TEMPORARY_KEY = 'ohos.extra.param.key.form_temporary',
424
425    /**
426     * Indicates the key specifying the name of the bundle to be obtained, which is represented as
427     * want: {
428     *   "parameters": {
429     *       BUNDLE_NAME_KEY: "bundleName"
430     *    }
431     * }
432     *
433     * @syscap SystemCapability.Ability.Form
434     * @since 9
435     */
436    BUNDLE_NAME_KEY = 'ohos.extra.param.key.bundle_name',
437
438    /**
439     * Indicates the key specifying the name of the ability to be obtained, which is represented as
440     * want: {
441     *   "parameters": {
442     *       ABILITY_NAME_KEY: "abilityName"
443     *    }
444     * }
445     *
446     * @syscap SystemCapability.Ability.Form
447     * @since 9
448     */
449    ABILITY_NAME_KEY = 'ohos.extra.param.key.ability_name',
450
451    /**
452     * Indicates the key specifying the the device ID, which is represented as
453     * want: {
454     *   "parameters": {
455     *       DEVICE_ID_KEY : "EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2"
456     *    }
457     * }
458     *
459     * @syscap SystemCapability.Ability.Form
460     * @systemapi
461     * @since 9
462     */
463    DEVICE_ID_KEY = 'ohos.extra.param.key.device_id',
464
465    /**
466     * Indicates the key specifying the launch reason of the form to be obtained, which is represented as
467     * want: {
468     *   "parameters": {
469     *       LAUNCH_REASON_KEY: LaunchReason.FORM_DEFAULT
470     *    }
471     * }
472     *
473     * @syscap SystemCapability.Ability.Form
474     * @since 10
475     */
476    LAUNCH_REASON_KEY = 'ohos.extra.param.key.form_launch_reason',
477
478    /**
479     * Indicates the key specifying the custom data of the form to be obtained, which is represented as
480     * want: {
481     *   "parameters": {
482     *       PARAM_FORM_CUSTOMIZE_KEY: {
483     *          "key": "userData"
484     *       }
485     *    }
486     * }
487     *
488     * @syscap SystemCapability.Ability.Form
489     * @since 10
490     */
491    PARAM_FORM_CUSTOMIZE_KEY = 'ohos.extra.param.key.form_customize'
492  }
493
494  /**
495   * The optional options used as filters to ask
496   * getFormsInfo to return formInfos from only forms that match the options.
497   *
498   * @typedef FormInfoFilter
499   * @syscap SystemCapability.Ability.Form
500   * @since 9
501   */
502  interface FormInfoFilter {
503    /**
504     * optional moduleName that used to ask getFormsInfo to return
505     * form infos with the same moduleName.
506     *
507     * @type { ?string }
508     * @syscap SystemCapability.Ability.Form
509     * @since 9
510     */
511    moduleName?: string;
512  }
513
514  /**
515   * Defines the FormDimension enum.
516   *
517   * @enum { number }
518   * @syscap SystemCapability.Ability.Form
519   * @since 9
520   */
521  enum FormDimension {
522    /**
523     * 1 x 2 form
524     *
525     * @syscap SystemCapability.Ability.Form
526     * @since 9
527     */
528    Dimension_1_2 = 1,
529
530    /**
531     * 2 x 2 form
532     *
533     * @syscap SystemCapability.Ability.Form
534     * @since 9
535     */
536    Dimension_2_2,
537
538    /**
539     * 2 x 4 form
540     *
541     * @syscap SystemCapability.Ability.Form
542     * @since 9
543     */
544    Dimension_2_4,
545
546    /**
547     * 4 x 4 form
548     *
549     * @syscap SystemCapability.Ability.Form
550     * @since 9
551     */
552    Dimension_4_4,
553
554    /**
555     * 2 x 1 form
556     *
557     * @syscap SystemCapability.Ability.Form
558     * @since 9
559     */
560    Dimension_2_1
561  }
562  /**
563   * The visibility of a form.
564   *
565   * @enum { number }
566   * @syscap SystemCapability.Ability.Form
567   * @since 9
568   */
569  enum VisibilityType {
570    /**
571     * Indicates the type of the form type is unknown.
572     * Often used as a condition variable in function OnVisibilityChange to specify actions only on forms that are
573     * changing to unknown.
574     *
575     * @syscap SystemCapability.Ability.Form
576     * @since 10
577     */
578    UNKNOWN = 0,
579    /**
580     * Indicates the type of the form is visible.
581     * Often used as a condition variable in function OnVisibilityChange to specify actions only on forms that are
582     * changing to visible.
583     *
584     * @syscap SystemCapability.Ability.Form
585     * @since 9
586     */
587    FORM_VISIBLE = 1,
588    /**
589     * Indicates the type of the form is invisible.
590     * Often used as a condition variable in function OnVisibilityChange to specify actions only on forms that are
591     * changing to invisible.
592     *
593     * @syscap SystemCapability.Ability.Form
594     * @since 9
595     */
596    FORM_INVISIBLE
597  }
598
599  /**
600   * Indicates the launch reason of a form.
601   *
602   * @enum { number }
603   * @syscap SystemCapability.Ability.Form
604   * @since 10
605   */
606  enum LaunchReason {
607    /**
608     * Indicates the launch reason of a form is default.
609     *
610     * @syscap SystemCapability.Ability.Form
611     * @since 10
612     */
613    FORM_DEFAULT = 1,
614    /**
615     * Indicates the launch reason of a form is share.
616     *
617     * @syscap SystemCapability.Ability.Form
618     * @since 10
619     */
620    FORM_SHARE
621  }
622
623  /**
624   * Information about a running form.
625   *
626   * @typedef FormProviderFilter
627   * @syscap SystemCapability.Ability.Form
628   * @systemapi
629   * @stagemodelonly
630   * @since 10
631   */
632  interface FormProviderFilter {
633    /**
634     * Obtains the bundle name of the provider application.
635     *
636     * @type { string }
637     * @syscap SystemCapability.Ability.Form
638     * @systemapi
639     * @stagemodelonly
640     * @since 10
641     */
642    bundleName: string;
643
644    /**
645     * Obtains the form name of the provider application form.
646     *
647     * @type { ?string }
648     * @syscap SystemCapability.Ability.Form
649     * @systemapi
650     * @stagemodelonly
651     * @since 10
652     */
653    formName?: string;
654
655    /**
656     * Obtains the module name of the provider application module.
657     *
658     * @type { ?string }
659     * @syscap SystemCapability.Ability.Form
660     * @systemapi
661     * @stagemodelonly
662     * @since 10
663     */
664    moduleName?: string;
665
666    /**
667     * Obtains the ability name of the provider application module.
668     *
669     * @type { ?string }
670     * @syscap SystemCapability.Ability.Form
671     * @systemapi
672     * @stagemodelonly
673     * @since 10
674     */
675    abilityName?: string;
676  }
677
678  /**
679   * The class of a running form information.
680   *
681   * @typedef RunningFormInfo
682   * @syscap SystemCapability.Ability.Form
683   * @systemapi hide this for inner system use
684   * @since 10
685   */
686  interface RunningFormInfo {
687    /**
688     * Obtains the id of the this form.
689     *
690     * @type { string }
691     * @default -
692     * @syscap SystemCapability.Ability.Form
693     * @systemapi
694     * @since 10
695     */
696    readonly formId: string;
697
698    /**
699     * Obtains the bundle name of the application to which this form belongs.
700     *
701     * @type { string }
702     * @default -
703     * @syscap SystemCapability.Ability.Form
704     * @systemapi
705     * @since 10
706     */
707    readonly bundleName: string;
708
709    /**
710     * Obtains the bundle name of the form host application.
711     *
712     * @type { string }
713     * @default -
714     * @syscap SystemCapability.Ability.Form
715     * @systemapi
716     * @since 10
717     */
718    readonly hostBundleName: string;
719
720    /**
721     * Obtains the visibility of this form.
722     *
723     * @type { VisibilityType }
724     * @default -
725     * @syscap SystemCapability.Ability.Form
726     * @systemapi
727     * @since 10
728     */
729    readonly visibilityType: VisibilityType;
730
731    /**
732     * Obtains the name of the application module to which this form belongs.
733     *
734     * @type { string }
735     * @default -
736     * @syscap SystemCapability.Ability.Form
737     * @systemapi
738     * @since 10
739     */
740    readonly moduleName: string;
741
742    /**
743     * Obtains the class name of the ability to which this form belongs.
744     *
745     * @type { string }
746     * @default -
747     * @syscap SystemCapability.Ability.Form
748     * @systemapi
749     * @since 10
750     */
751    readonly abilityName: string;
752
753    /**
754     * Obtains the name of this form.
755     *
756     * @type { string }
757     * @default -
758     * @syscap SystemCapability.Ability.Form
759     * @systemapi
760     * @since 10
761     */
762    readonly formName: string;
763
764    /**
765     * Obtains the grid style of this form.
766     *
767     * @type { number }
768     * @default -
769     * @syscap SystemCapability.Ability.Form
770     * @systemapi
771     * @since 10
772     */
773    readonly dimension: number;
774  }
775}
776export default formInfo;
777