161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"),
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit FormKit
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ciimport formBindingData from './@ohos.app.form.formBindingData';
2261847f8eSopenharmony_ciimport formInfo from './@ohos.app.form.formInfo';
2361847f8eSopenharmony_ciimport FormExtensionContext from './application/FormExtensionContext';
2461847f8eSopenharmony_ciimport Want from './@ohos.app.ability.Want';
2561847f8eSopenharmony_ciimport { Configuration } from './@ohos.app.ability.Configuration';
2661847f8eSopenharmony_ci
2761847f8eSopenharmony_ci/**
2861847f8eSopenharmony_ci * class of form extension.
2961847f8eSopenharmony_ci *
3061847f8eSopenharmony_ci * @syscap SystemCapability.Ability.Form
3161847f8eSopenharmony_ci * @stagemodelonly
3261847f8eSopenharmony_ci * @since 9
3361847f8eSopenharmony_ci */
3461847f8eSopenharmony_ci/**
3561847f8eSopenharmony_ci * class of form extension.
3661847f8eSopenharmony_ci *
3761847f8eSopenharmony_ci * @syscap SystemCapability.Ability.Form
3861847f8eSopenharmony_ci * @stagemodelonly
3961847f8eSopenharmony_ci * @atomicservice
4061847f8eSopenharmony_ci * @since 11
4161847f8eSopenharmony_ci */
4261847f8eSopenharmony_ciexport default class FormExtensionAbility {
4361847f8eSopenharmony_ci  /**
4461847f8eSopenharmony_ci   * Indicates form extension context.
4561847f8eSopenharmony_ci   *
4661847f8eSopenharmony_ci   * @type { FormExtensionContext }
4761847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
4861847f8eSopenharmony_ci   * @stagemodelonly
4961847f8eSopenharmony_ci   * @since 9
5061847f8eSopenharmony_ci   */
5161847f8eSopenharmony_ci  /**
5261847f8eSopenharmony_ci   * Indicates form extension context.
5361847f8eSopenharmony_ci   *
5461847f8eSopenharmony_ci   * @type { FormExtensionContext }
5561847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
5661847f8eSopenharmony_ci   * @stagemodelonly
5761847f8eSopenharmony_ci   * @atomicservice
5861847f8eSopenharmony_ci   * @since 11
5961847f8eSopenharmony_ci   */
6061847f8eSopenharmony_ci  context: FormExtensionContext;
6161847f8eSopenharmony_ci
6261847f8eSopenharmony_ci  /**
6361847f8eSopenharmony_ci   * Called to return a {@link formBindingData#FormBindingData} object.
6461847f8eSopenharmony_ci   *
6561847f8eSopenharmony_ci   * @param { Want } want - Indicates the detailed information for creating a {@link formBindingData#FormBindingData}.
6661847f8eSopenharmony_ci   *                        The {@code Want} object must include the form ID, form name, and grid style of the form.
6761847f8eSopenharmony_ci   *                        Such form information must be managed as persistent data for further form
6861847f8eSopenharmony_ci   *                        acquisition, update, and deletion.
6961847f8eSopenharmony_ci   * @returns { formBindingData.FormBindingData } Returns the created {@link formBindingData#FormBindingData} object.
7061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
7161847f8eSopenharmony_ci   * @stagemodelonly
7261847f8eSopenharmony_ci   * @since 9
7361847f8eSopenharmony_ci   */
7461847f8eSopenharmony_ci  /**
7561847f8eSopenharmony_ci   * Called to return a {@link formBindingData#FormBindingData} object.
7661847f8eSopenharmony_ci   *
7761847f8eSopenharmony_ci   * @param { Want } want - Indicates the detailed information for creating a {@link formBindingData#FormBindingData}.
7861847f8eSopenharmony_ci   *                        The {@code Want} object must include the form ID, form name, and grid style of the form.
7961847f8eSopenharmony_ci   *                        Such form information must be managed as persistent data for further form
8061847f8eSopenharmony_ci   *                        acquisition, update, and deletion.
8161847f8eSopenharmony_ci   * @returns { formBindingData.FormBindingData } Returns the created {@link formBindingData#FormBindingData} object.
8261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
8361847f8eSopenharmony_ci   * @stagemodelonly
8461847f8eSopenharmony_ci   * @atomicservice
8561847f8eSopenharmony_ci   * @since 11
8661847f8eSopenharmony_ci   */
8761847f8eSopenharmony_ci  onAddForm(want: Want): formBindingData.FormBindingData;
8861847f8eSopenharmony_ci
8961847f8eSopenharmony_ci  /**
9061847f8eSopenharmony_ci   * Called when the form provider is notified that a temporary form is successfully converted to a normal form.
9161847f8eSopenharmony_ci   *
9261847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form.
9361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
9461847f8eSopenharmony_ci   * @stagemodelonly
9561847f8eSopenharmony_ci   * @since 9
9661847f8eSopenharmony_ci   */
9761847f8eSopenharmony_ci  /**
9861847f8eSopenharmony_ci   * Called when the form provider is notified that a temporary form is successfully converted to a normal form.
9961847f8eSopenharmony_ci   *
10061847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form.
10161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
10261847f8eSopenharmony_ci   * @stagemodelonly
10361847f8eSopenharmony_ci   * @atomicservice
10461847f8eSopenharmony_ci   * @since 11
10561847f8eSopenharmony_ci   */
10661847f8eSopenharmony_ci  onCastToNormalForm(formId: string): void;
10761847f8eSopenharmony_ci
10861847f8eSopenharmony_ci  /**
10961847f8eSopenharmony_ci   * Called to notify the form provider to update a specified form.
11061847f8eSopenharmony_ci   *
11161847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form to update.
11261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
11361847f8eSopenharmony_ci   * @stagemodelonly
11461847f8eSopenharmony_ci   * @since 9
11561847f8eSopenharmony_ci   */
11661847f8eSopenharmony_ci  /**
11761847f8eSopenharmony_ci   * Called to notify the form provider to update a specified form.
11861847f8eSopenharmony_ci   *
11961847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form to update.
12061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
12161847f8eSopenharmony_ci   * @stagemodelonly
12261847f8eSopenharmony_ci   * @atomicservice
12361847f8eSopenharmony_ci   * @since 11
12461847f8eSopenharmony_ci   */
12561847f8eSopenharmony_ci  /**
12661847f8eSopenharmony_ci   * Called to notify the form provider to update a specified form.
12761847f8eSopenharmony_ci   *
12861847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form to update.
12961847f8eSopenharmony_ci   * @param { Record<string, Object> } [wantParams] - Indicates the detailed information for updating the form.
13061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
13161847f8eSopenharmony_ci   * @stagemodelonly
13261847f8eSopenharmony_ci   * @atomicservice
13361847f8eSopenharmony_ci   * @since 12
13461847f8eSopenharmony_ci   */
13561847f8eSopenharmony_ci  onUpdateForm(formId: string, wantParams?: Record<string, Object>): void;
13661847f8eSopenharmony_ci
13761847f8eSopenharmony_ci  /**
13861847f8eSopenharmony_ci   * Called when the form provider receives form events from the system.
13961847f8eSopenharmony_ci   *
14061847f8eSopenharmony_ci   * @param { object } newStatus - Indicates the form events occurred. The key in the {@code Map}
14161847f8eSopenharmony_ci   *                               object indicates the form ID, and the value indicates the event
14261847f8eSopenharmony_ci   *                               type, which can be either
14361847f8eSopenharmony_ci   *                               {@link formInfo#VisibilityType#FORM_VISIBLE} or
14461847f8eSopenharmony_ci   *                               {@link formInfo#VisibilityType#FORM_INVISIBLE}.
14561847f8eSopenharmony_ci   *                               {@link formInfo#VisibilityType#FORM_VISIBLE} means that the form becomes visible,
14661847f8eSopenharmony_ci   *                               {@link formInfo#VisibilityType#FORM_INVISIBLE} means that the form becomes
14761847f8eSopenharmony_ci   *                               invisible.
14861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
14961847f8eSopenharmony_ci   * @stagemodelonly
15061847f8eSopenharmony_ci   * @since 9
15161847f8eSopenharmony_ci   */
15261847f8eSopenharmony_ci  /**
15361847f8eSopenharmony_ci   * Called when the form provider receives form events from the system.
15461847f8eSopenharmony_ci   *
15561847f8eSopenharmony_ci   * @param { Record<string, number> } newStatus - Indicates the form events occurred. The key in the {@code Map}
15661847f8eSopenharmony_ci   *                                               object indicates the form ID, and the value indicates the event
15761847f8eSopenharmony_ci   *                                               type, which can be either
15861847f8eSopenharmony_ci   *                                               {@link formInfo#VisibilityType#FORM_VISIBLE} or
15961847f8eSopenharmony_ci   *                                               {@link formInfo#VisibilityType#FORM_INVISIBLE}.
16061847f8eSopenharmony_ci   *                                               {@link formInfo#VisibilityType#FORM_VISIBLE}
16161847f8eSopenharmony_ci   *                                               means that the form becomes visible,
16261847f8eSopenharmony_ci   *                                               {@link formInfo#VisibilityType#FORM_INVISIBLE} means that the form
16361847f8eSopenharmony_ci   *                                               becomes invisible.
16461847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
16561847f8eSopenharmony_ci   * @stagemodelonly
16661847f8eSopenharmony_ci   * @since 11
16761847f8eSopenharmony_ci   */
16861847f8eSopenharmony_ci  onChangeFormVisibility(newStatus: Record<string, number>): void;
16961847f8eSopenharmony_ci
17061847f8eSopenharmony_ci  /**
17161847f8eSopenharmony_ci   * Called when a specified message event defined by the form provider is triggered. This method is valid only for
17261847f8eSopenharmony_ci   * JS forms.
17361847f8eSopenharmony_ci   *
17461847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form on which the message event is triggered, which is
17561847f8eSopenharmony_ci   *                            provided by the client to the form provider.
17661847f8eSopenharmony_ci   * @param { string } message - Indicates the value of the {@code params} field of the message event. This parameter
17761847f8eSopenharmony_ci   *                             is used to identify the specific component on which the event is triggered.
17861847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
17961847f8eSopenharmony_ci   * @stagemodelonly
18061847f8eSopenharmony_ci   * @since 9
18161847f8eSopenharmony_ci   */
18261847f8eSopenharmony_ci  /**
18361847f8eSopenharmony_ci   * Called when a specified message event defined by the form provider is triggered. This method is valid only for
18461847f8eSopenharmony_ci   * JS forms.
18561847f8eSopenharmony_ci   *
18661847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form on which the message event is triggered, which is
18761847f8eSopenharmony_ci   *                            provided by the client to the form provider.
18861847f8eSopenharmony_ci   * @param { string } message - Indicates the value of the {@code params} field of the message event. This parameter
18961847f8eSopenharmony_ci   *                             is used to identify the specific component on which the event is triggered.
19061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
19161847f8eSopenharmony_ci   * @stagemodelonly
19261847f8eSopenharmony_ci   * @atomicservice
19361847f8eSopenharmony_ci   * @since 11
19461847f8eSopenharmony_ci   */
19561847f8eSopenharmony_ci  onFormEvent(formId: string, message: string): void;
19661847f8eSopenharmony_ci
19761847f8eSopenharmony_ci  /**
19861847f8eSopenharmony_ci   * Called to notify the form provider that a specified form has been destroyed. Override this method if
19961847f8eSopenharmony_ci   * you want your application, as the form provider, to be notified of form deletion.
20061847f8eSopenharmony_ci   *
20161847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the destroyed form.
20261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
20361847f8eSopenharmony_ci   * @stagemodelonly
20461847f8eSopenharmony_ci   * @since 9
20561847f8eSopenharmony_ci   */
20661847f8eSopenharmony_ci  /**
20761847f8eSopenharmony_ci   * Called to notify the form provider that a specified form has been destroyed. Override this method if
20861847f8eSopenharmony_ci   * you want your application, as the form provider, to be notified of form deletion.
20961847f8eSopenharmony_ci   *
21061847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the destroyed form.
21161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
21261847f8eSopenharmony_ci   * @stagemodelonly
21361847f8eSopenharmony_ci   * @atomicservice
21461847f8eSopenharmony_ci   * @since 11
21561847f8eSopenharmony_ci   */
21661847f8eSopenharmony_ci  onRemoveForm(formId: string): void;
21761847f8eSopenharmony_ci
21861847f8eSopenharmony_ci  /**
21961847f8eSopenharmony_ci   * Called when the system configuration is updated.
22061847f8eSopenharmony_ci   *
22161847f8eSopenharmony_ci   * @param { Configuration } newConfig - Indicates the system configuration, such as language and color mode.
22261847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
22361847f8eSopenharmony_ci   * @stagemodelonly
22461847f8eSopenharmony_ci   * @since 9
22561847f8eSopenharmony_ci   */
22661847f8eSopenharmony_ci  /**
22761847f8eSopenharmony_ci   * Called when the system configuration is updated.
22861847f8eSopenharmony_ci   *
22961847f8eSopenharmony_ci   * @param { Configuration } newConfig - Indicates the system configuration, such as language and color mode.
23061847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
23161847f8eSopenharmony_ci   * @stagemodelonly
23261847f8eSopenharmony_ci   * @atomicservice
23361847f8eSopenharmony_ci   * @since 11
23461847f8eSopenharmony_ci   */
23561847f8eSopenharmony_ci  onConfigurationUpdate(newConfig: Configuration): void;
23661847f8eSopenharmony_ci
23761847f8eSopenharmony_ci  /**
23861847f8eSopenharmony_ci   * Called to return a {@link FormState} object.
23961847f8eSopenharmony_ci   * <p>You must override this callback if you want this ability to return the actual form state. Otherwise,
24061847f8eSopenharmony_ci   * this method returns {@link FormState#DEFAULT} by default.</p>
24161847f8eSopenharmony_ci   *
24261847f8eSopenharmony_ci   * @param { Want } want - Indicates the description of the form for which the {@link formInfo#FormState}
24361847f8eSopenharmony_ci   *                        is obtained. The description covers the bundle name, ability name, module name,
24461847f8eSopenharmony_ci   *                        form name, and form dimensions.
24561847f8eSopenharmony_ci   * @returns { formInfo.FormState } Returns the {@link formInfo#FormState} object.
24661847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
24761847f8eSopenharmony_ci   * @stagemodelonly
24861847f8eSopenharmony_ci   * @since 9
24961847f8eSopenharmony_ci   */
25061847f8eSopenharmony_ci  /**
25161847f8eSopenharmony_ci   * Called to return a {@link FormState} object.
25261847f8eSopenharmony_ci   * <p>You must override this callback if you want this ability to return the actual form state. Otherwise,
25361847f8eSopenharmony_ci   * this method returns {@link FormState#DEFAULT} by default.</p>
25461847f8eSopenharmony_ci   *
25561847f8eSopenharmony_ci   * @param { Want } want - Indicates the description of the form for which the {@link formInfo#FormState}
25661847f8eSopenharmony_ci   *                        is obtained. The description covers the bundle name, ability name, module name,
25761847f8eSopenharmony_ci   *                        form name, and form dimensions.
25861847f8eSopenharmony_ci   * @returns { formInfo.FormState } Returns the {@link formInfo#FormState} object.
25961847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
26061847f8eSopenharmony_ci   * @stagemodelonly
26161847f8eSopenharmony_ci   * @atomicservice
26261847f8eSopenharmony_ci   * @since 11
26361847f8eSopenharmony_ci   */
26461847f8eSopenharmony_ci  onAcquireFormState?(want: Want): formInfo.FormState;
26561847f8eSopenharmony_ci
26661847f8eSopenharmony_ci  /**
26761847f8eSopenharmony_ci   * Called when the system shares the form.
26861847f8eSopenharmony_ci   *
26961847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form.
27061847f8eSopenharmony_ci   * @returns { object } Returns the wantParams object.
27161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
27261847f8eSopenharmony_ci   * @systemapi
27361847f8eSopenharmony_ci   * @stagemodelonly
27461847f8eSopenharmony_ci   * @since 9
27561847f8eSopenharmony_ci   */
27661847f8eSopenharmony_ci  /**
27761847f8eSopenharmony_ci   * Called when the system shares the form.
27861847f8eSopenharmony_ci   *
27961847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form.
28061847f8eSopenharmony_ci   * @returns { Record<string, Object> } Returns the wantParams object.
28161847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
28261847f8eSopenharmony_ci   * @systemapi
28361847f8eSopenharmony_ci   * @stagemodelonly
28461847f8eSopenharmony_ci   * @since 11
28561847f8eSopenharmony_ci   */
28661847f8eSopenharmony_ci  onShareForm?(formId: string): Record<string, Object>;
28761847f8eSopenharmony_ci
28861847f8eSopenharmony_ci  /**
28961847f8eSopenharmony_ci   * Called when the system acquire the form data.
29061847f8eSopenharmony_ci   *
29161847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form.
29261847f8eSopenharmony_ci   * @returns { object } Returns the wantParams object.
29361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
29461847f8eSopenharmony_ci   * @systemapi
29561847f8eSopenharmony_ci   * @stagemodelonly
29661847f8eSopenharmony_ci   * @since 10
29761847f8eSopenharmony_ci   */
29861847f8eSopenharmony_ci  /**
29961847f8eSopenharmony_ci   * Called when the system acquire the form data.
30061847f8eSopenharmony_ci   *
30161847f8eSopenharmony_ci   * @param { string } formId - Indicates the ID of the form.
30261847f8eSopenharmony_ci   * @returns { Record<string, Object> } Returns the wantParams object.
30361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
30461847f8eSopenharmony_ci   * @systemapi
30561847f8eSopenharmony_ci   * @stagemodelonly
30661847f8eSopenharmony_ci   * @since 11
30761847f8eSopenharmony_ci   */
30861847f8eSopenharmony_ci  onAcquireFormData?(formId: string): Record<string, Object>;
30961847f8eSopenharmony_ci
31061847f8eSopenharmony_ci  /**
31161847f8eSopenharmony_ci   * Called when this ability breaks the last link, notifying the provider that the provider process is about to stop.
31261847f8eSopenharmony_ci   *
31361847f8eSopenharmony_ci   * @syscap SystemCapability.Ability.Form
31461847f8eSopenharmony_ci   * @stagemodelonly
31561847f8eSopenharmony_ci   * @atomicservice
31661847f8eSopenharmony_ci   * @since 12
31761847f8eSopenharmony_ci   */
31861847f8eSopenharmony_ci  onStop?(): void;
31961847f8eSopenharmony_ci}
320