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 16/** 17 * Defines the option of MenuItem. 18 * 19 * @interface MenuItemOptions 20 * @syscap SystemCapability.ArkUI.ArkUI.Full 21 * @since 9 22 */ 23/** 24 * Defines the option of MenuItem. 25 * 26 * @interface MenuItemOptions 27 * @syscap SystemCapability.ArkUI.ArkUI.Full 28 * @crossplatform 29 * @since 10 30 */ 31declare interface MenuItemOptions { 32 /** 33 * Defines the start display image info. 34 * 35 * @type { ?ResourceStr } 36 * @syscap SystemCapability.ArkUI.ArkUI.Full 37 * @since 9 38 */ 39 /** 40 * Defines the start display image info. 41 * 42 * @type { ?ResourceStr } 43 * @syscap SystemCapability.ArkUI.ArkUI.Full 44 * @crossplatform 45 * @since 10 46 */ 47 startIcon?: ResourceStr; 48 49 /** 50 * Defines the content string display info. 51 * 52 * @type { ?ResourceStr } 53 * @syscap SystemCapability.ArkUI.ArkUI.Full 54 * @since 9 55 */ 56 /** 57 * Defines the content string display info. 58 * 59 * @type { ?ResourceStr } 60 * @syscap SystemCapability.ArkUI.ArkUI.Full 61 * @crossplatform 62 * @since 10 63 */ 64 content?: ResourceStr; 65 66 /** 67 * Defines the end display image info. 68 * 69 * @type { ?ResourceStr } 70 * @syscap SystemCapability.ArkUI.ArkUI.Full 71 * @since 9 72 */ 73 /** 74 * Defines the end display image info. 75 * 76 * @type { ?ResourceStr } 77 * @syscap SystemCapability.ArkUI.ArkUI.Full 78 * @crossplatform 79 * @since 10 80 */ 81 endIcon?: ResourceStr; 82 83 /** 84 * Defines the end label info like shortcut. 85 * 86 * @type { ?ResourceStr } 87 * @syscap SystemCapability.ArkUI.ArkUI.Full 88 * @since 9 89 */ 90 /** 91 * Defines the end label info like shortcut. 92 * 93 * @type { ?ResourceStr } 94 * @syscap SystemCapability.ArkUI.ArkUI.Full 95 * @crossplatform 96 * @since 10 97 */ 98 labelInfo?: ResourceStr; 99 100 /** 101 * Create the submenu. 102 * 103 * @type { ?CustomBuilder } 104 * @syscap SystemCapability.ArkUI.ArkUI.Full 105 * @since 9 106 */ 107 /** 108 * Create the submenu. 109 * 110 * @type { ?CustomBuilder } 111 * @syscap SystemCapability.ArkUI.ArkUI.Full 112 * @crossplatform 113 * @since 10 114 */ 115 builder?: CustomBuilder; 116} 117 118/** 119 * Defines the MenuItem Component. 120 * 121 * @interface MenuItemInterface 122 * @syscap SystemCapability.ArkUI.ArkUI.Full 123 * @since 9 124 */ 125/** 126 * Defines the MenuItem Component. 127 * 128 * @interface MenuItemInterface 129 * @syscap SystemCapability.ArkUI.ArkUI.Full 130 * @crossplatform 131 * @since 10 132 */ 133interface MenuItemInterface { 134 /** 135 * Creates the MenuItem component. 136 * 137 * @param { MenuItemOptions | CustomBuilder } value 138 * @returns { MenuItemAttribute } 139 * @syscap SystemCapability.ArkUI.ArkUI.Full 140 * @since 9 141 */ 142 /** 143 * Creates the MenuItem component. 144 * 145 * @param { MenuItemOptions | CustomBuilder } value 146 * @returns { MenuItemAttribute } 147 * @syscap SystemCapability.ArkUI.ArkUI.Full 148 * @crossplatform 149 * @since 10 150 */ 151 (value?: MenuItemOptions | CustomBuilder): MenuItemAttribute; 152} 153 154/** 155 * Defines the MenuItem component attribute functions. 156 * 157 * @extends CommonMethod 158 * @syscap SystemCapability.ArkUI.ArkUI.Full 159 * @since 9 160 */ 161/** 162 * Defines the MenuItem component attribute functions. 163 * 164 * @extends CommonMethod 165 * @syscap SystemCapability.ArkUI.ArkUI.Full 166 * @crossplatform 167 * @since 10 168 */ 169declare class MenuItemAttribute extends CommonMethod<MenuItemAttribute> { 170 /** 171 * Setting whether menuItem is selected. 172 * 173 * @param { boolean } value 174 * @returns { MenuItemAttribute } 175 * @syscap SystemCapability.ArkUI.ArkUI.Full 176 * @since 9 177 */ 178 /** 179 * Setting whether menuItem is selected. 180 * 181 * @param { boolean } value 182 * @returns { MenuItemAttribute } 183 * @syscap SystemCapability.ArkUI.ArkUI.Full 184 * @crossplatform 185 * @since 10 186 */ 187 selected(value: boolean): MenuItemAttribute; 188 189 /** 190 * Whether the relevant check icon is displayed when a menu item is selected. 191 * 192 * @param { boolean | ResourceStr } value - Indicates whether to display the check icon when selected. 193 * @returns { MenuItemAttribute } 194 * @syscap SystemCapability.ArkUI.ArkUI.Full 195 * @since 9 196 */ 197 /** 198 * Whether the relevant check icon is displayed when a menu item is selected. 199 * Use type ResourceStr to specify icon instead of the default check mark. 200 * 201 * @param { boolean | ResourceStr } value - Indicates whether to display icon when selected. 202 * true: displays the default check mark when selected. 203 * false: does not displays icon when selected. 204 * ResourceStr: displays the specified icon when selected. 205 * @returns { MenuItemAttribute } 206 * @syscap SystemCapability.ArkUI.ArkUI.Full 207 * @crossplatform 208 * @since 10 209 */ 210 selectIcon(value: boolean | ResourceStr): MenuItemAttribute; 211 212 /** 213 * Triggers a callback when a menu item is selected or unchecked. 214 * 215 * @param { function } callback 216 * @returns { MenuItemAttribute } 217 * @syscap SystemCapability.ArkUI.ArkUI.Full 218 * @since 9 219 */ 220 /** 221 * Triggers a callback when a menu item is selected or unchecked. 222 * 223 * @param { function } callback 224 * @returns { MenuItemAttribute } 225 * @syscap SystemCapability.ArkUI.ArkUI.Full 226 * @crossplatform 227 * @since 10 228 */ 229 onChange(callback: (selected: boolean) => void): MenuItemAttribute; 230 231 /** 232 * Sets the content font style. 233 * Family and style are not supported currently and will be fixed in future. 234 * 235 * @param { Font } value - Indicates the font style of content text. 236 * @returns { MenuItemAttribute } 237 * @syscap SystemCapability.ArkUI.ArkUI.Full 238 * @crossplatform 239 * @since 10 240 */ 241 contentFont(value: Font): MenuItemAttribute; 242 243 /** 244 * Sets the font color of content text. 245 * 246 * @param { ResourceColor } value - Indicates the font color of content text. 247 * @returns { MenuItemAttribute } 248 * @syscap SystemCapability.ArkUI.ArkUI.Full 249 * @crossplatform 250 * @since 10 251 */ 252 contentFontColor(value: ResourceColor): MenuItemAttribute; 253 254 /** 255 * Sets the label info font style. 256 * Family and style are not supported currently and will be fixed in future. 257 * 258 * @param { Font } value - Indicates the font style of label info text. 259 * @returns { MenuItemAttribute } 260 * @syscap SystemCapability.ArkUI.ArkUI.Full 261 * @crossplatform 262 * @since 10 263 */ 264 labelFont(value: Font): MenuItemAttribute; 265 266 /** 267 * Sets the font color of label info text. 268 * 269 * @param { ResourceColor } value - Indicates the font color of label info text. 270 * @returns { MenuItemAttribute } 271 * @syscap SystemCapability.ArkUI.ArkUI.Full 272 * @crossplatform 273 * @since 10 274 */ 275 labelFontColor(value: ResourceColor): MenuItemAttribute; 276} 277 278/** 279 * Defines MenuItem Component. 280 * 281 * @syscap SystemCapability.ArkUI.ArkUI.Full 282 * @since 9 283 */ 284/** 285 * Defines MenuItem Component. 286 * 287 * @syscap SystemCapability.ArkUI.ArkUI.Full 288 * @crossplatform 289 * @since 10 290 */ 291declare const MenuItem: MenuItemInterface; 292 293/** 294 * Defines MenuItem Component instance. 295 * 296 * @syscap SystemCapability.ArkUI.ArkUI.Full 297 * @since 9 298 */ 299/** 300 * Defines MenuItem Component instance. 301 * 302 * @syscap SystemCapability.ArkUI.ArkUI.Full 303 * @crossplatform 304 * @since 10 305 */ 306declare const MenuItemInstance: MenuItemAttribute; 307