1/* 2 * Copyright (C) 2025 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/** 16 * @file 17 * @kit ArkUI 18 * @arkts 1.2 19 */ 20 21import { UIContext } from '@ohos.arkui.UIContext' 22import { Builder } from './builder' 23 24/** 25 * Defining interface of LifeCycle for custom component and custom dialog 26 * 27 * @syscap SystemCapability.ArkUI.ArkUI.Full 28 * @crossplatform 29 * @atomicservice 30 * @since 20 31 */ 32export interface LifeCycle { 33 /** 34 * aboutToAppear Method. 35 * 36 * The aboutToAppear function is executed after a new instance of the custom component is created, 37 * before its build() function is executed. 38 * 39 * @syscap SystemCapability.ArkUI.ArkUI.Full 40 * @crossplatform 41 * @atomicservice 42 * @since 20 43 */ 44 aboutToAppear(): void {} 45 46 /** 47 * aboutToDisappear Method. 48 * 49 * The aboutToDisappear function executes before a custom component is destroyed. 50 * 51 * @syscap SystemCapability.ArkUI.ArkUI.Full 52 * @crossplatform 53 * @atomicservice 54 * @since 20 55 */ 56 aboutToDisappear(): void {} 57 58 /** 59 * The callback method after the custom component is built. 60 * 61 * Triggered when the custom component has been built. 62 * 63 * @syscap SystemCapability.ArkUI.ArkUI.Full 64 * @crossplatform 65 * @atomicservice 66 * @since 20 67 */ 68 onDidBuild(): void {} 69 70 /** 71 * Customize the build process of the custom component. 72 * 73 * @syscap SystemCapability.ArkUI.ArkUI.Full 74 * @crossplatform 75 * @atomicservice 76 * @since 20 77 */ 78 @Builder 79 build(): void 80} 81 82/** 83 * Definition of extendable component, which is base class of custom component and custom dialog. 84 * 85 * @implements LifeCycle 86 * @syscap SystemCapability.ArkUI.ArkUI.Full 87 * @crossplatform 88 * @atomicservice 89 * @since 20 90 */ 91export declare abstract class ExtendableComponent implements LifeCycle { 92 /** 93 * Get current UIContext. 94 * 95 * @returns { UIContext } The UIContext that the custom component belongs to. 96 * @syscap SystemCapability.ArkUI.ArkUI.Full 97 * @crossplatform 98 * @atomicservice 99 * @since 20 100 */ 101 getUIContext(): UIContext 102 103 /** 104 * Get uniqueId of the custom component. 105 * 106 * @returns { int } - The uniqueId of the custom component. 107 * @syscap SystemCapability.ArkUI.ArkUI.Full 108 * @crossplatform 109 * @atomicservice 110 * @since 20 111 */ 112 getUniqueId(): int 113}