cascader.service.d.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * Use of this source code is governed by an MIT-style license that can be
  3. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  4. */
  5. import { OnDestroy } from '@angular/core';
  6. import { BehaviorSubject, Subject } from 'rxjs';
  7. import { NzTreeNode } from 'ng-zorro-antd/core/tree';
  8. import { NzSafeAny } from 'ng-zorro-antd/core/types';
  9. import { NzCascaderComponentAsSource, NzCascaderOption } from './typings';
  10. import * as i0 from "@angular/core";
  11. /**
  12. * All data is stored and parsed in NzCascaderService.
  13. */
  14. export declare class NzCascaderService implements OnDestroy {
  15. /** Activated options in each column. */
  16. activatedNodes: NzTreeNode[];
  17. /** An array to store cascader items arranged in different layers. */
  18. columns: NzTreeNode[][];
  19. /** If user has entered searching mode. */
  20. inSearchingMode: boolean;
  21. values: NzSafeAny[];
  22. /**
  23. * Emit an event when loading state changes.
  24. * Emit true if nzOptions is loading by `nzLoadData`.
  25. */
  26. readonly $loading: BehaviorSubject<boolean>;
  27. /**
  28. * Emit an event to notify cascader it needs to redraw because activated or
  29. * selected options are changed.
  30. */
  31. readonly $redraw: Subject<void>;
  32. /**
  33. * Emit an event when an option gets selected.
  34. * Emit true if a leaf options is selected.
  35. */
  36. readonly $nodeSelected: Subject<NzTreeNode | null>;
  37. /**
  38. * Emit an event to notify cascader it needs to quit searching mode.
  39. * Only emit when user do select a searching option.
  40. */
  41. readonly $quitSearching: Subject<void>;
  42. /** To hold columns before entering searching mode. */
  43. private columnSnapshot;
  44. private cascaderComponent;
  45. private searchOptionPathMap;
  46. /** Return cascader options in the first layer. */
  47. get nzOptions(): NzCascaderOption[];
  48. ngOnDestroy(): void;
  49. /**
  50. * Bind cascader component so this service could use inputs.
  51. */
  52. withComponent(cascaderComponent: NzCascaderComponentAsSource): void;
  53. /**
  54. * Try to set an option as activated.
  55. *
  56. * @param node Cascader option node
  57. * @param columnIndex Of which column this option is in
  58. * @param performSelect Select
  59. * @param multiple Multiple mode
  60. * @param loadingChildren Try to load children asynchronously.
  61. */
  62. setNodeActivated(node: NzTreeNode, columnIndex: number, performSelect?: boolean, multiple?: boolean, loadingChildren?: boolean): void;
  63. /**
  64. * Set an option as selected.
  65. * @param node
  66. * @param index
  67. * @param multiple
  68. */
  69. setNodeSelected(node: NzTreeNode, index: number, multiple?: boolean): void;
  70. setNodeDeactivatedSinceColumn(column: number): void;
  71. /**
  72. * Set a searching option as selected, finishing up things.
  73. *
  74. * @param node
  75. * @param multiple
  76. */
  77. setSearchOptionSelected(node: NzTreeNode, multiple?: boolean): void;
  78. /**
  79. * Reset node's `title` and `disabled` status and clear `searchOptionPathMap`.
  80. */
  81. private clearSearchOptions;
  82. /**
  83. * Filter cascader options to reset `columns`.
  84. *
  85. * @param searchValue The string user wants to search.
  86. */
  87. prepareSearchOptions(searchValue: string): void;
  88. /**
  89. * Set searching mode by UI. It deals with things not directly related to UI.
  90. *
  91. * @param toSearching If this cascader is entering searching mode
  92. */
  93. setSearchingMode(toSearching: boolean): void;
  94. /**
  95. * Clear selected options.
  96. */
  97. clear(): void;
  98. getOptionLabel(o: NzCascaderOption): string;
  99. getOptionValue(o: NzCascaderOption): NzSafeAny;
  100. /**
  101. * Try to insert options into a column.
  102. *
  103. * @param nodes Options to insert
  104. * @param columnIndex Position
  105. */
  106. setColumnData(nodes: NzTreeNode[], columnIndex: number): void;
  107. /**
  108. * Set all columns data according to activate option's path
  109. */
  110. private trackAncestorColumnData;
  111. /**
  112. * Set all ancestor options as activated.
  113. */
  114. private trackAncestorActivatedNodes;
  115. private dropBehindActivatedNodes;
  116. dropBehindColumns(lastReserveIndex: number): void;
  117. /**
  118. * Load children of an option asynchronously.
  119. */
  120. loadChildren(node: NzTreeNode | null, columnIndex: number, onLoaded?: (options: NzCascaderOption[]) => void): void;
  121. isLoaded(index: number): boolean;
  122. static ɵfac: i0.ɵɵFactoryDeclaration<NzCascaderService, never>;
  123. static ɵprov: i0.ɵɵInjectableDeclaration<NzCascaderService>;
  124. }