1/* 2 * Copyright (c) 2024 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/** 17 * @file Defines a modifier which can update attributes to native side. 18 * @kit ArkUI 19 */ 20 21import { AttributeModifier } from './component/common' 22 23/** 24 * function that returns a default param of AttributeUpdater. 25 * 26 * @typedef { function } Initializer<T> 27 * @returns { T } 28 * @syscap SystemCapability.ArkUI.ArkUI.Full 29 * @crossplatform 30 * @atomicservice 31 * @since 12 32 */ 33export type Initializer<T> = () => T; 34 35/** 36 * Defines a modifier which can update attributes to native side. 37 * 38 * @implements AttributeModifier 39 * @syscap SystemCapability.ArkUI.ArkUI.Full 40 * @crossplatform 41 * @atomicservice 42 * @since 12 43 */ 44export declare class AttributeUpdater<T, C = Initializer<T>> implements AttributeModifier<T> { 45 46 /** 47 * Defines the normal update attribute function. 48 * 49 * @param { T } instance 50 * @syscap SystemCapability.ArkUI.ArkUI.Full 51 * @crossplatform 52 * @atomicservice 53 * @since 12 54 */ 55 applyNormalAttribute: undefined | ((instance: T) => void); 56 applyPressedAttribute: undefined | ((instance: T) => void); 57 applyFocusedAttribute: undefined | ((instance: T) => void); 58 applyDisabledAttribute: undefined | ((instance: T) => void); 59 applySelectedAttribute: undefined | ((instance: T) => void); 60 61 /** 62 * Defines a function for initialization. 63 * 64 * @param { T } instance 65 * @syscap SystemCapability.ArkUI.ArkUI.Full 66 * @crossplatform 67 * @atomicservice 68 * @since 12 69 */ 70 initializeModifier(instance: T): void; 71 72 /** 73 * Get attribute of the modifier. 74 * 75 * @returns { T | undefined } The attribute of the modifier. 76 * @syscap SystemCapability.ArkUI.ArkUI.Full 77 * @crossplatform 78 * @atomicservice 79 * @since 12 80 */ 81 get attribute(): T | undefined; 82 83 /** 84 * Used to update constructor params. 85 * 86 * @type { C } 87 * @syscap SystemCapability.ArkUI.ArkUI.Full 88 * @crossplatform 89 * @atomicservice 90 * @since 12 91 */ 92 updateConstructorParams: C; 93 94 /** 95 * Defines a function executed when component changed. 96 * 97 * @param { T } component 98 * @syscap SystemCapability.ArkUI.ArkUI.Full 99 * @crossplatform 100 * @atomicservice 101 * @since 12 102 */ 103 onComponentChanged(component: T): void; 104} 105