1/* 2* Copyright (C) 2023-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 * @file 18 * @kit ArkUI 19 */ 20 21/// <reference path="../component/units.d.ts" /> 22 23import { ResourceStr } from 'GlobalResource'; 24 25/** 26 * Control style of operation element 27 * @enum { TreeListenType } 28 * @syscap SystemCapability.ArkUI.ArkUI.Full 29 * @since 10 30 */ 31 32 33/** 34 * Control style of operation element 35 * @enum { TreeListenType } 36 * @syscap SystemCapability.ArkUI.ArkUI.Full 37 * @atomicservice 38 * @since 11 39 */ 40export declare enum TreeListenType { 41 /** 42 * register listener after a node is clicked. 43 * @syscap SystemCapability.ArkUI.ArkUI.Full 44 * @since 10 45 */ 46 /** 47 * register listener after a node is clicked. 48 * @syscap SystemCapability.ArkUI.ArkUI.Full 49 * @atomicservice 50 * @since 11 51 */ 52 NODE_CLICK = "NodeClick", 53 /** 54 * register listener after a node is add. 55 * @syscap SystemCapability.ArkUI.ArkUI.Full 56 * @since 10 57 */ 58 /** 59 * register listener after a node is add. 60 * @syscap SystemCapability.ArkUI.ArkUI.Full 61 * @atomicservice 62 * @since 11 63 */ 64 NODE_ADD = "NodeAdd", 65 /** 66 * register listener after a node is delected. 67 * @syscap SystemCapability.ArkUI.ArkUI.Full 68 * @since 10 69 */ 70 /** 71 * register listener after a node is delected. 72 * @syscap SystemCapability.ArkUI.ArkUI.Full 73 * @atomicservice 74 * @since 11 75 */ 76 NODE_DELETE = "NodeDelete", 77 /** 78 * register listener after a node is modified. 79 * @syscap SystemCapability.ArkUI.ArkUI.Full 80 * @since 10 81 */ 82 /** 83 * register listener after a node is modified. 84 * @syscap SystemCapability.ArkUI.ArkUI.Full 85 * @atomicservice 86 * @since 11 87 */ 88 NODE_MODIFY = "NodeModify", 89 /** 90 * register listener after a node is moved. 91 * @syscap SystemCapability.ArkUI.ArkUI.Full 92 * @since 10 93 */ 94 /** 95 * register listener after a node is moved. 96 * @syscap SystemCapability.ArkUI.ArkUI.Full 97 * @atomicservice 98 * @since 11 99 */ 100 NODE_MOVE = "NodeMove", 101} 102 103/** 104 * Declare class TreeListener 105 * @syscap SystemCapability.ArkUI.ArkUI.Full 106 * @since 10 107 */ 108/** 109 * Declare class TreeListener 110 * @syscap SystemCapability.ArkUI.ArkUI.Full 111 * @atomicservice 112 * @since 11 113 */ 114export declare class TreeListener { 115 /** 116 * Event registration and processing. 117 * The event will not be destroyed after being processed. 118 * 119 * @param { type } event Registered Events. 120 * @param { callback }. 121 * @syscap SystemCapability.ArkUI.ArkUI.Full 122 * @since 10 123 */ 124 /** 125 * Event registration and processing. 126 * The event will not be destroyed after being processed. 127 * 128 * @param { type } event Registered Events. 129 * @param { callback }. 130 * @syscap SystemCapability.ArkUI.ArkUI.Full 131 * @atomicservice 132 * @since 11 133 */ 134 on(type: TreeListenType, callback: (callbackParam: CallbackParam) => void): void; 135 136 /** 137 * Event registration and processing. 138 * After the event is processed once, it will be destroyed. 139 * 140 * @param { type } event Registered Events. 141 * @param { callback }. 142 * @syscap SystemCapability.ArkUI.ArkUI.Full 143 * @since 10 144 */ 145 /** 146 * Event registration and processing. 147 * After the event is processed once, it will be destroyed. 148 * 149 * @param { type } event Registered Events. 150 * @param { callback }. 151 * @syscap SystemCapability.ArkUI.ArkUI.Full 152 * @atomicservice 153 * @since 11 154 */ 155 once(type: TreeListenType, callback: (callbackParam: CallbackParam) => void): void; 156 157 /** 158 * Destroy event. 159 * 160 * @param { type } event Registered Events. 161 * @param { callback }. 162 * @syscap SystemCapability.ArkUI.ArkUI.Full 163 * @since 10 164 */ 165 /** 166 * Destroy event. 167 * 168 * @param { type } event Registered Events. 169 * @param { callback }. 170 * @syscap SystemCapability.ArkUI.ArkUI.Full 171 * @atomicservice 172 * @since 11 173 */ 174 off(type: TreeListenType, callback?: (callbackParam: CallbackParam) => void): void; 175} 176 177/** 178 * Declare class TreeListenerManager 179 * @syscap SystemCapability.ArkUI.ArkUI.Full 180 * @since 10 181 */ 182/** 183 * Declare class TreeListenerManager 184 * @syscap SystemCapability.ArkUI.ArkUI.Full 185 * @atomicservice 186 * @since 11 187 */ 188export declare class TreeListenerManager { 189 /** 190 * Get instance of treeListenerManager. 191 * @return treeListenerManager instance 192 * @static 193 * @syscap SystemCapability.ArkUI.ArkUI.Full 194 * @since 10 195 */ 196 /** 197 * Get instance of treeListenerManager. 198 * @return treeListenerManager instance 199 * @static 200 * @syscap SystemCapability.ArkUI.ArkUI.Full 201 * @atomicservice 202 * @since 11 203 */ 204 static getInstance(): TreeListenerManager; 205 206 /** 207 * Get treeListener. 208 * @return treeListener object 209 * @syscap SystemCapability.ArkUI.ArkUI.Full 210 * @since 10 211 */ 212 /** 213 * Get treeListener. 214 * @return treeListener object 215 * @syscap SystemCapability.ArkUI.ArkUI.Full 216 * @atomicservice 217 * @since 11 218 */ 219 getTreeListener(): TreeListener; 220} 221 222/** 223 * Declare TreeView Component 224 * @syscap SystemCapability.ArkUI.ArkUI.Full 225 * @since 10 226 */ 227/** 228 * Declare TreeView Component 229 * @syscap SystemCapability.ArkUI.ArkUI.Full 230 * @atomicservice 231 * @since 12 232 */ 233@Component 234export declare struct TreeView { 235 /** 236 * Node data source of TreeView. 237 * @type TreeController 238 * @syscap SystemCapability.ArkUI.ArkUI.Full 239 * @since 10 240 */ 241 /** 242 * Node data source of TreeView. 243 * @type TreeController 244 * @syscap SystemCapability.ArkUI.ArkUI.Full 245 * @atomicservice 246 * @since 11 247 */ 248 treeController: TreeController; 249} 250 251/** 252 * Declare CallbackParam 253 * @typedef CallbackParam 254 * @syscap SystemCapability.ArkUI.ArkUI.Full 255 * @since 10 256 */ 257/** 258 * Declare CallbackParam 259 * @typedef CallbackParam 260 * @syscap SystemCapability.ArkUI.ArkUI.Full 261 * @atomicservice 262 * @since 11 263 */ 264export interface CallbackParam { 265 /** 266 * Get the currentNodeId. 267 * @type { number } 268 * @syscap SystemCapability.ArkUI.ArkUI.Full 269 * @since 10 270 */ 271 /** 272 * Get the currentNodeId. 273 * @type { number } 274 * @syscap SystemCapability.ArkUI.ArkUI.Full 275 * @atomicservice 276 * @since 11 277 */ 278 currentNodeId: number, 279 280 /** 281 * Get the parentNodeId. 282 * @type { number } 283 * @syscap SystemCapability.ArkUI.ArkUI.Full 284 * @since 10 285 */ 286 /** 287 * Get the parentNodeId. 288 * @type { number } 289 * @syscap SystemCapability.ArkUI.ArkUI.Full 290 * @atomicservice 291 * @since 11 292 */ 293 parentNodeId?: number, 294 295 /** 296 * Get the childIndex. 297 * @type { number } 298 * @syscap SystemCapability.ArkUI.ArkUI.Full 299 * @since 10 300 */ 301 /** 302 * Get the childIndex. 303 * @type { number } 304 * @syscap SystemCapability.ArkUI.ArkUI.Full 305 * @atomicservice 306 * @since 11 307 */ 308 childIndex?: number 309} 310 311/** 312 * Declare NodeParam 313 * @typedef NodeParam 314 * @syscap SystemCapability.ArkUI.ArkUI.Full 315 * @since 10 316 */ 317/** 318 * Declare NodeParam 319 * @typedef NodeParam 320 * @syscap SystemCapability.ArkUI.ArkUI.Full 321 * @atomicservice 322 * @since 11 323 */ 324export interface NodeParam { 325 /** 326 * Set the parentNodeId. 327 * @type { number } 328 * @syscap SystemCapability.ArkUI.ArkUI.Full 329 * @since 10 330 */ 331 /** 332 * Set the parentNodeId. 333 * @type { number } 334 * @syscap SystemCapability.ArkUI.ArkUI.Full 335 * @atomicservice 336 * @since 11 337 */ 338 parentNodeId?: number, 339 340 /** 341 * Set currentNodeId. 342 * @type { number } 343 * @syscap SystemCapability.ArkUI.ArkUI.Full 344 * @since 10 345 */ 346 /** 347 * Set currentNodeId. 348 * @type { number } 349 * @syscap SystemCapability.ArkUI.ArkUI.Full 350 * @atomicservice 351 * @since 11 352 */ 353 currentNodeId?: number, 354 355 /** 356 * Set catalog whether is floder. 357 * @type { boolean } 358 * @syscap SystemCapability.ArkUI.ArkUI.Full 359 * @since 10 360 */ 361 /** 362 * Set catalog whether is floder. 363 * @type { boolean } 364 * @syscap SystemCapability.ArkUI.ArkUI.Full 365 * @atomicservice 366 * @since 11 367 */ 368 isFolder?: boolean; 369 370 /** 371 * Set the icon resource. 372 * @type { Resource } 373 * @syscap SystemCapability.ArkUI.ArkUI.Full 374 * @since 10 375 */ 376 /** 377 * Set the icon resource. 378 * @type { Resource } 379 * @syscap SystemCapability.ArkUI.ArkUI.Full 380 * @atomicservice 381 * @since 11 382 */ 383 icon?: ResourceStr; 384 385 /** 386 * Set selected icon resource. 387 * @type { Resource } 388 * @syscap SystemCapability.ArkUI.ArkUI.Full 389 * @since 10 390 */ 391 /** 392 * Set selected icon resource. 393 * @type { Resource } 394 * @syscap SystemCapability.ArkUI.ArkUI.Full 395 * @atomicservice 396 * @since 11 397 */ 398 selectedIcon?: ResourceStr; 399 400 /** 401 * Set edit icon resource. 402 * @type { Resource } 403 * @syscap SystemCapability.ArkUI.ArkUI.Full 404 * @since 10 405 */ 406 /** 407 * Set edit icon resource. 408 * @type { Resource } 409 * @syscap SystemCapability.ArkUI.ArkUI.Full 410 * @atomicservice 411 * @since 11 412 */ 413 editIcon?: ResourceStr; 414 415 /** 416 * Set primary title content. 417 * @type { ResourceStr } 418 * @syscap SystemCapability.ArkUI.ArkUI.Full 419 * @since 10 420 */ 421 /** 422 * Set primary title content. 423 * @type { ResourceStr } 424 * @syscap SystemCapability.ArkUI.ArkUI.Full 425 * @atomicservice 426 * @since 11 427 */ 428 primaryTitle?: ResourceStr; 429 430 /** 431 * Set secondary title content. 432 * @type { ResourceStr } 433 * @syscap SystemCapability.ArkUI.ArkUI.Full 434 * @since 10 435 */ 436 /** 437 * Set secondary title content. 438 * @type { ResourceStr } 439 * @syscap SystemCapability.ArkUI.ArkUI.Full 440 * @atomicservice 441 * @since 11 442 */ 443 secondaryTitle?: ResourceStr; 444 445 /** 446 * set subcomponent binded on tree item. 447 * @type { () => void } 448 * @syscap SystemCapability.ArkUI.ArkUI.Full 449 * @since 10 450 */ 451 /** 452 * set subcomponent binded on tree item. 453 * @type { () => void } 454 * @syscap SystemCapability.ArkUI.ArkUI.Full 455 * @atomicservice 456 * @since 11 457 */ 458 container?: () => void; 459} 460 461/** 462 * Declare TreeController 463 * @syscap SystemCapability.ArkUI.ArkUI.Full 464 * @since 10 465 */ 466/** 467 * Declare TreeController 468 * @syscap SystemCapability.ArkUI.ArkUI.Full 469 * @atomicservice 470 * @since 11 471 */ 472export declare class TreeController { 473 /** 474 * Delete a node. 475 * Register an ON_ITEM_DELETE callback through the ListTreeListener mechanism to obtain the IDs of all deleted nodes. 476 * @syscap SystemCapability.ArkUI.ArkUI.Full 477 * @since 10 478 */ 479 /** 480 * Delete a node. 481 * Register an ON_ITEM_DELETE callback through the ListTreeListener mechanism to obtain the IDs of all deleted nodes. 482 * @syscap SystemCapability.ArkUI.ArkUI.Full 483 * @atomicservice 484 * @since 11 485 */ 486 removeNode(): void; 487 488 /** 489 * Modify the node name. 490 * Register an ON_ITEM_MODIFY callback to obtain the ID, parent node ID, and node name of the modified node. 491 * @syscap SystemCapability.ArkUI.ArkUI.Full 492 * @since 10 493 */ 494 /** 495 * Modify the node name. 496 * Register an ON_ITEM_MODIFY callback to obtain the ID, parent node ID, and node name of the modified node. 497 * @syscap SystemCapability.ArkUI.ArkUI.Full 498 * @atomicservice 499 * @since 11 500 */ 501 modifyNode(): void; 502 503 /** 504 * Initialize the interface of the tree view. This interface is used to generate ListNodeDataSource data. 505 * addNode is only designed for initialization. It can only be invoked during initialization. 506 * 507 * A maximum of 50 directory levels can be added. 508 * 509 * @param nodeParam Configuration information of the newly added node. 510 * 511 * For details, see the comment description of NodeParam. 512 * @return ListTreeNode Tree view component proxy class. 513 * @syscap SystemCapability.ArkUI.ArkUI.Full 514 * @since 10 515 */ 516 /** 517 * Initialize the interface of the tree view. This interface is used to generate ListNodeDataSource data. 518 * addNode is only designed for initialization. It can only be invoked during initialization. 519 * 520 * A maximum of 50 directory levels can be added. 521 * 522 * @param nodeParam Configuration information of the newly added node. 523 * 524 * For details, see the comment description of NodeParam. 525 * @return ListTreeNode Tree view component proxy class. 526 * @syscap SystemCapability.ArkUI.ArkUI.Full 527 * @atomicservice 528 * @since 11 529 */ 530 addNode(nodeParam?: NodeParam): TreeController; 531 532 /** 533 * This interface is called when a secondaryTitle needs to be updated 534 * 535 * @param parentId ID of the parent node. 536 * @param parentSubTitle secondaryTitle of parent node. 537 * @param currentSubtitle secondaryTitle of current node. 538 * 539 * @syscap SystemCapability.ArkUI.ArkUI.Full 540 * @since 10 541 */ 542 /** 543 * This interface is called when a secondaryTitle needs to be updated 544 * 545 * @param parentId ID of the parent node. 546 * @param parentSubTitle secondaryTitle of parent node. 547 * @param currentSubtitle secondaryTitle of current node. 548 * 549 * @syscap SystemCapability.ArkUI.ArkUI.Full 550 * @atomicservice 551 * @since 11 552 */ 553 refreshNode(parentId: number, parentSubTitle: ResourceStr, currentSubtitle: ResourceStr): void; 554 555 /** 556 * After the initialization is complete by calling the addNode interface, 557 * call this interface to complete initialization. 558 * 559 * This interface must be called when you finish initializing the ListTreeView by addNode. 560 * @syscap SystemCapability.ArkUI.ArkUI.Full 561 * @since 10 562 */ 563 /** 564 * After the initialization is complete by calling the addNode interface, 565 * call this interface to complete initialization. 566 * 567 * This interface must be called when you finish initializing the ListTreeView by addNode. 568 * @syscap SystemCapability.ArkUI.ArkUI.Full 569 * @atomicservice 570 * @since 11 571 */ 572 buildDone(): void; 573}