ng-zorro-antd-cascader.mjs 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031
  1. import { __esDecorate, __runInitializers } from 'tslib';
  2. import { DOWN_ARROW, UP_ARROW, LEFT_ARROW, RIGHT_ARROW, ENTER, BACKSPACE, ESCAPE } from '@angular/cdk/keycodes';
  3. import * as i6 from '@angular/cdk/overlay';
  4. import { OverlayModule, CdkConnectedOverlay } from '@angular/cdk/overlay';
  5. import { _getEventTarget } from '@angular/cdk/platform';
  6. import { NgTemplateOutlet, SlicePipe } from '@angular/common';
  7. import * as i0 from '@angular/core';
  8. import { EventEmitter, inject, ElementRef, booleanAttribute, numberAttribute, Output, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, Injectable, computed, signal, forwardRef, HostListener, ViewChildren, ViewChild, NgModule } from '@angular/core';
  9. import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
  10. import { BehaviorSubject, Subject, from, of, merge } from 'rxjs';
  11. import { finalize, distinctUntilChanged, withLatestFrom, map, takeUntil, startWith, switchMap } from 'rxjs/operators';
  12. import { slideMotion } from 'ng-zorro-antd/core/animation';
  13. import { WithConfig, NzConfigService } from 'ng-zorro-antd/core/config';
  14. import { NzFormStatusService, NzFormNoStatusService, NzFormItemFeedbackIconComponent } from 'ng-zorro-antd/core/form';
  15. import { NzNoAnimationDirective } from 'ng-zorro-antd/core/no-animation';
  16. import * as i9 from 'ng-zorro-antd/core/overlay';
  17. import { DEFAULT_CASCADER_POSITIONS, POSITION_MAP, getPlacementName, NzOverlayModule } from 'ng-zorro-antd/core/overlay';
  18. import * as i3$1 from 'ng-zorro-antd/core/services';
  19. import { NzDestroyService } from 'ng-zorro-antd/core/services';
  20. import { NzTreeBaseService, NzTreeNode, NzTreeBase } from 'ng-zorro-antd/core/tree';
  21. import { arraysEqual, isNotNil, toArray, getStatusClassNames, fromEventOutsideAngular } from 'ng-zorro-antd/core/util';
  22. import * as i8 from 'ng-zorro-antd/empty';
  23. import { NzEmptyModule } from 'ng-zorro-antd/empty';
  24. import * as i2 from 'ng-zorro-antd/icon';
  25. import { NzIconModule } from 'ng-zorro-antd/icon';
  26. import { NzSelectClearComponent, NzSelectItemComponent, NzSelectPlaceholderComponent, NzSelectSearchComponent } from 'ng-zorro-antd/select';
  27. import * as i5 from 'ng-zorro-antd/space';
  28. import { NZ_SPACE_COMPACT_SIZE, NZ_SPACE_COMPACT_ITEM_TYPE, NzSpaceCompactItemDirective } from 'ng-zorro-antd/space';
  29. import * as i1 from 'ng-zorro-antd/core/highlight';
  30. import { NzHighlightModule } from 'ng-zorro-antd/core/highlight';
  31. import * as i3 from 'ng-zorro-antd/core/outlet';
  32. import { NzOutletModule } from 'ng-zorro-antd/core/outlet';
  33. import * as i2$1 from 'ng-zorro-antd/i18n';
  34. import * as i4 from '@angular/cdk/bidi';
  35. /**
  36. * Use of this source code is governed by an MIT-style license that can be
  37. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  38. */
  39. function isShowSearchObject(options) {
  40. return typeof options !== 'boolean';
  41. }
  42. /**
  43. * Use of this source code is governed by an MIT-style license that can be
  44. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  45. */
  46. function isChildNode(node) {
  47. return node.isLeaf || !node.children || !node.children.length;
  48. }
  49. function isParentNode(node) {
  50. return !!node.children && !!node.children.length && !node.isLeaf;
  51. }
  52. class NzCascaderOptionComponent {
  53. cdr;
  54. optionTemplate = null;
  55. node;
  56. activated = false;
  57. highlightText;
  58. nzLabelProperty = 'label';
  59. columnIndex;
  60. expandIcon = '';
  61. dir = 'ltr';
  62. checkable = false;
  63. check = new EventEmitter();
  64. nativeElement = inject(ElementRef).nativeElement;
  65. constructor(cdr) {
  66. this.cdr = cdr;
  67. }
  68. ngOnInit() {
  69. if (this.expandIcon === '' && this.dir === 'rtl') {
  70. this.expandIcon = 'left';
  71. }
  72. else if (this.expandIcon === '') {
  73. this.expandIcon = 'right';
  74. }
  75. }
  76. get checked() {
  77. return this.node.isChecked;
  78. }
  79. get halfChecked() {
  80. return this.node.isHalfChecked;
  81. }
  82. get disabled() {
  83. return this.node.isDisabled || this.node.isDisableCheckbox;
  84. }
  85. markForCheck() {
  86. this.cdr.markForCheck();
  87. }
  88. onCheckboxClick(event) {
  89. event.preventDefault();
  90. event.stopPropagation();
  91. if (!this.checkable) {
  92. return;
  93. }
  94. this.check.emit();
  95. }
  96. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderOptionComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
  97. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzCascaderOptionComponent, isStandalone: true, selector: "[nz-cascader-option]", inputs: { optionTemplate: "optionTemplate", node: "node", activated: "activated", highlightText: "highlightText", nzLabelProperty: "nzLabelProperty", columnIndex: ["columnIndex", "columnIndex", numberAttribute], expandIcon: "expandIcon", dir: "dir", checkable: ["checkable", "checkable", booleanAttribute] }, outputs: { check: "check" }, host: { properties: { "attr.title": "node.title", "class.ant-cascader-menu-item-active": "activated", "class.ant-cascader-menu-item-expand": "!node.isLeaf", "class.ant-cascader-menu-item-disabled": "node.isDisabled" }, classAttribute: "ant-cascader-menu-item ant-cascader-menu-item-expanded" }, exportAs: ["nzCascaderOption"], ngImport: i0, template: `
  98. @if (checkable) {
  99. <span
  100. class="ant-cascader-checkbox"
  101. [class.ant-cascader-checkbox-checked]="checked"
  102. [class.ant-cascader-checkbox-indeterminate]="halfChecked"
  103. [class.ant-cascader-checkbox-disabled]="disabled"
  104. (click)="onCheckboxClick($event)"
  105. >
  106. <span class="ant-cascader-checkbox-inner"></span>
  107. </span>
  108. }
  109. @if (optionTemplate) {
  110. <ng-template
  111. [ngTemplateOutlet]="optionTemplate"
  112. [ngTemplateOutletContext]="{ $implicit: node.origin, index: columnIndex }"
  113. />
  114. } @else {
  115. <div
  116. class="ant-cascader-menu-item-content"
  117. [innerHTML]="node.title | nzHighlight: highlightText : 'g' : 'ant-cascader-menu-item-keyword'"
  118. ></div>
  119. }
  120. @if (!node.isLeaf || node.children?.length || node.isLoading) {
  121. <div class="ant-cascader-menu-item-expand-icon">
  122. @if (node.isLoading) {
  123. <nz-icon nzType="loading" />
  124. } @else {
  125. <ng-container *nzStringTemplateOutlet="expandIcon">
  126. <nz-icon [nzType]="$any(expandIcon)" />
  127. </ng-container>
  128. }
  129. </div>
  130. }
  131. `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: NzHighlightModule }, { kind: "pipe", type: i1.NzHighlightPipe, name: "nzHighlight" }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzOutletModule }, { kind: "directive", type: i3.NzStringTemplateOutletDirective, selector: "[nzStringTemplateOutlet]", inputs: ["nzStringTemplateOutletContext", "nzStringTemplateOutlet"], exportAs: ["nzStringTemplateOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
  132. }
  133. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderOptionComponent, decorators: [{
  134. type: Component,
  135. args: [{
  136. selector: '[nz-cascader-option]',
  137. exportAs: 'nzCascaderOption',
  138. imports: [NgTemplateOutlet, NzHighlightModule, NzIconModule, NzOutletModule],
  139. template: `
  140. @if (checkable) {
  141. <span
  142. class="ant-cascader-checkbox"
  143. [class.ant-cascader-checkbox-checked]="checked"
  144. [class.ant-cascader-checkbox-indeterminate]="halfChecked"
  145. [class.ant-cascader-checkbox-disabled]="disabled"
  146. (click)="onCheckboxClick($event)"
  147. >
  148. <span class="ant-cascader-checkbox-inner"></span>
  149. </span>
  150. }
  151. @if (optionTemplate) {
  152. <ng-template
  153. [ngTemplateOutlet]="optionTemplate"
  154. [ngTemplateOutletContext]="{ $implicit: node.origin, index: columnIndex }"
  155. />
  156. } @else {
  157. <div
  158. class="ant-cascader-menu-item-content"
  159. [innerHTML]="node.title | nzHighlight: highlightText : 'g' : 'ant-cascader-menu-item-keyword'"
  160. ></div>
  161. }
  162. @if (!node.isLeaf || node.children?.length || node.isLoading) {
  163. <div class="ant-cascader-menu-item-expand-icon">
  164. @if (node.isLoading) {
  165. <nz-icon nzType="loading" />
  166. } @else {
  167. <ng-container *nzStringTemplateOutlet="expandIcon">
  168. <nz-icon [nzType]="$any(expandIcon)" />
  169. </ng-container>
  170. }
  171. </div>
  172. }
  173. `,
  174. host: {
  175. class: 'ant-cascader-menu-item ant-cascader-menu-item-expanded',
  176. '[attr.title]': 'node.title',
  177. '[class.ant-cascader-menu-item-active]': 'activated',
  178. '[class.ant-cascader-menu-item-expand]': '!node.isLeaf',
  179. '[class.ant-cascader-menu-item-disabled]': 'node.isDisabled'
  180. },
  181. changeDetection: ChangeDetectionStrategy.OnPush,
  182. encapsulation: ViewEncapsulation.None
  183. }]
  184. }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { optionTemplate: [{
  185. type: Input
  186. }], node: [{
  187. type: Input
  188. }], activated: [{
  189. type: Input
  190. }], highlightText: [{
  191. type: Input
  192. }], nzLabelProperty: [{
  193. type: Input
  194. }], columnIndex: [{
  195. type: Input,
  196. args: [{ transform: numberAttribute }]
  197. }], expandIcon: [{
  198. type: Input
  199. }], dir: [{
  200. type: Input
  201. }], checkable: [{
  202. type: Input,
  203. args: [{ transform: booleanAttribute }]
  204. }], check: [{
  205. type: Output
  206. }] } });
  207. /**
  208. * Use of this source code is governed by an MIT-style license that can be
  209. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  210. */
  211. class NzCascaderTreeService extends NzTreeBaseService {
  212. fieldNames = {
  213. label: 'label',
  214. value: 'value'
  215. };
  216. missingNodeList = [];
  217. treeNodePostProcessor = (node) => {
  218. node.key = this.getOptionValue(node);
  219. node.title = this.getOptionLabel(node);
  220. };
  221. getOptionValue(node) {
  222. return node.origin[this.fieldNames.value || 'value'];
  223. }
  224. getOptionLabel(node) {
  225. return node.origin[this.fieldNames.label || 'label'];
  226. }
  227. get children() {
  228. return this.rootNodes;
  229. }
  230. set children(value) {
  231. this.rootNodes = value.map(v => (v instanceof NzTreeNode ? v : new NzTreeNode(v, null)));
  232. }
  233. constructor() {
  234. super();
  235. }
  236. /**
  237. * Map list of nodes to list of option
  238. */
  239. toOptions(nodes) {
  240. return nodes.map(node => node.origin);
  241. }
  242. getAncestorNodeList(node) {
  243. if (!node) {
  244. return [];
  245. }
  246. if (node.parentNode) {
  247. return [...this.getAncestorNodeList(node.parentNode), node];
  248. }
  249. return [node];
  250. }
  251. /**
  252. * Render by nzCheckedKeys
  253. * When keys equals null, just render with checkStrictly
  254. *
  255. * @param paths
  256. * @param checkStrictly
  257. */
  258. conductCheckPaths(paths, checkStrictly) {
  259. this.checkedNodeList = [];
  260. this.halfCheckedNodeList = [];
  261. this.missingNodeList = [];
  262. const existsPathList = [];
  263. const calc = (nodes) => {
  264. nodes.forEach(node => {
  265. if (paths === null) {
  266. // render tree if no default checked keys found
  267. node.isChecked = !!node.origin.checked;
  268. }
  269. else {
  270. // if node is in checked path
  271. const nodePath = this.getAncestorNodeList(node).map(n => this.getOptionValue(n));
  272. if (paths.some(keys => arraysEqual(nodePath, keys))) {
  273. node.isChecked = true;
  274. node.isHalfChecked = false;
  275. existsPathList.push(nodePath);
  276. }
  277. else {
  278. node.isChecked = false;
  279. node.isHalfChecked = false;
  280. }
  281. }
  282. if (node.children.length > 0) {
  283. calc(node.children);
  284. }
  285. });
  286. };
  287. calc(this.rootNodes);
  288. this.refreshCheckState(checkStrictly);
  289. this.missingNodeList = this.getMissingNodeList(paths, existsPathList);
  290. }
  291. conductSelectedPaths(paths, isMulti) {
  292. this.selectedNodeList.forEach(node => (node.isSelected = false));
  293. this.selectedNodeList = [];
  294. this.missingNodeList = [];
  295. const existsPathList = [];
  296. const calc = (nodes) => nodes.every(node => {
  297. // if node is in selected path
  298. const nodePath = this.getAncestorNodeList(node).map(n => this.getOptionValue(n));
  299. if (paths.some(keys => arraysEqual(nodePath, keys))) {
  300. node.isSelected = true;
  301. this.setSelectedNodeList(node);
  302. existsPathList.push(nodePath);
  303. if (!isMulti) {
  304. // if not support multi select
  305. return false;
  306. }
  307. }
  308. else {
  309. node.isSelected = false;
  310. }
  311. if (node.children.length > 0) {
  312. // Recursion
  313. return calc(node.children);
  314. }
  315. return true;
  316. });
  317. calc(this.rootNodes);
  318. this.missingNodeList = this.getMissingNodeList(paths, existsPathList);
  319. }
  320. getMissingNodeList(paths, existsPathList) {
  321. if (!paths) {
  322. return [];
  323. }
  324. return paths
  325. .filter(path => !existsPathList.some(keys => arraysEqual(path, keys)))
  326. .map(path => this.createMissingNode(path))
  327. .filter(isNotNil);
  328. }
  329. createMissingNode(path) {
  330. if (!path?.length) {
  331. return null;
  332. }
  333. const createOption = (key) => {
  334. return {
  335. [this.fieldNames.value || 'value']: key,
  336. [this.fieldNames.label || 'label']: key
  337. };
  338. };
  339. let node = new NzTreeNode(createOption(path[0]), null, this);
  340. for (let i = 1; i < path.length; i++) {
  341. const childNode = new NzTreeNode(createOption(path[i]));
  342. node.addChildren([childNode]);
  343. node = childNode;
  344. }
  345. return node;
  346. }
  347. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderTreeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
  348. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderTreeService });
  349. }
  350. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderTreeService, decorators: [{
  351. type: Injectable
  352. }], ctorParameters: () => [] });
  353. /**
  354. * Use of this source code is governed by an MIT-style license that can be
  355. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  356. */
  357. /**
  358. * All data is stored and parsed in NzCascaderService.
  359. */
  360. class NzCascaderService {
  361. /** Activated options in each column. */
  362. activatedNodes = [];
  363. /** An array to store cascader items arranged in different layers. */
  364. columns = [];
  365. /** If user has entered searching mode. */
  366. inSearchingMode = false;
  367. values = [];
  368. /**
  369. * Emit an event when loading state changes.
  370. * Emit true if nzOptions is loading by `nzLoadData`.
  371. */
  372. $loading = new BehaviorSubject(false);
  373. /**
  374. * Emit an event to notify cascader it needs to redraw because activated or
  375. * selected options are changed.
  376. */
  377. $redraw = new Subject();
  378. /**
  379. * Emit an event when an option gets selected.
  380. * Emit true if a leaf options is selected.
  381. */
  382. $nodeSelected = new Subject();
  383. /**
  384. * Emit an event to notify cascader it needs to quit searching mode.
  385. * Only emit when user do select a searching option.
  386. */
  387. $quitSearching = new Subject();
  388. /** To hold columns before entering searching mode. */
  389. columnSnapshot = [[]];
  390. cascaderComponent;
  391. searchOptionPathMap = new Map();
  392. /** Return cascader options in the first layer. */
  393. get nzOptions() {
  394. return this.cascaderComponent.treeService.toOptions(this.columns[0] || []);
  395. }
  396. ngOnDestroy() {
  397. this.$redraw.complete();
  398. this.$quitSearching.complete();
  399. this.$nodeSelected.complete();
  400. this.$loading.complete();
  401. this.searchOptionPathMap.clear();
  402. }
  403. /**
  404. * Bind cascader component so this service could use inputs.
  405. */
  406. withComponent(cascaderComponent) {
  407. this.cascaderComponent = cascaderComponent;
  408. }
  409. /**
  410. * Try to set an option as activated.
  411. *
  412. * @param node Cascader option node
  413. * @param columnIndex Of which column this option is in
  414. * @param performSelect Select
  415. * @param multiple Multiple mode
  416. * @param loadingChildren Try to load children asynchronously.
  417. */
  418. setNodeActivated(node, columnIndex, performSelect = false, multiple = false, loadingChildren = true) {
  419. if (node.isDisabled) {
  420. return;
  421. }
  422. this.activatedNodes[columnIndex] = node;
  423. this.trackAncestorActivatedNodes(columnIndex);
  424. this.dropBehindActivatedNodes(columnIndex);
  425. if (isParentNode(node)) {
  426. // Parent option that has children.
  427. this.setColumnData(node.children, columnIndex + 1);
  428. }
  429. else if (!node.isLeaf && loadingChildren) {
  430. // Parent option that should try to load children asynchronously.
  431. this.loadChildren(node, columnIndex);
  432. }
  433. else if (node.isLeaf) {
  434. // Leaf option.
  435. this.dropBehindColumns(columnIndex);
  436. }
  437. // Actually perform selection to make an options not only activated but also selected.
  438. if (performSelect && node.isSelectable) {
  439. this.setNodeSelected(node, columnIndex, multiple);
  440. }
  441. this.$redraw.next();
  442. }
  443. /**
  444. * Set an option as selected.
  445. * @param node
  446. * @param index
  447. * @param multiple
  448. */
  449. setNodeSelected(node, index, multiple = false) {
  450. const changeOn = this.cascaderComponent.nzChangeOn;
  451. const shouldPerformSelection = (o, i) => typeof changeOn === 'function' ? changeOn(o, i) : false;
  452. if (multiple ||
  453. node.isLeaf ||
  454. this.cascaderComponent.nzChangeOnSelect ||
  455. shouldPerformSelection(node.origin, index)) {
  456. node.isSelected = true;
  457. this.cascaderComponent.treeService.setSelectedNodeList(node, multiple);
  458. this.cascaderComponent.updateSelectedNodes();
  459. this.$redraw.next();
  460. this.$nodeSelected.next(node);
  461. }
  462. }
  463. setNodeDeactivatedSinceColumn(column) {
  464. this.dropBehindActivatedNodes(column - 1);
  465. this.dropBehindColumns(column);
  466. this.$redraw.next();
  467. }
  468. /**
  469. * Set a searching option as selected, finishing up things.
  470. *
  471. * @param node
  472. * @param multiple
  473. */
  474. setSearchOptionSelected(node, multiple = false) {
  475. this.setNodeSelected(node, node.level, multiple);
  476. setTimeout(() => {
  477. // Reset data and tell UI only to remove input and reset dropdown width style.
  478. this.$quitSearching.next();
  479. this.$redraw.next();
  480. }, 200);
  481. }
  482. /**
  483. * Reset node's `title` and `disabled` status and clear `searchOptionPathMap`.
  484. */
  485. clearSearchOptions() {
  486. for (const node of this.searchOptionPathMap.keys()) {
  487. node.isDisabled = node.origin.disabled || false;
  488. node.title = this.getOptionLabel(node.origin);
  489. }
  490. this.searchOptionPathMap.clear();
  491. }
  492. /**
  493. * Filter cascader options to reset `columns`.
  494. *
  495. * @param searchValue The string user wants to search.
  496. */
  497. prepareSearchOptions(searchValue) {
  498. const results = []; // Search results only have one layer.
  499. const path = [];
  500. const defaultFilter = (i, p) => p.some(o => {
  501. const label = this.getOptionLabel(o);
  502. return !!label && label.indexOf(i) !== -1;
  503. });
  504. const showSearch = this.cascaderComponent.nzShowSearch;
  505. const filter = isShowSearchObject(showSearch) && showSearch.filter ? showSearch.filter : defaultFilter;
  506. const sorter = isShowSearchObject(showSearch) && showSearch.sorter ? showSearch.sorter : null;
  507. const loopChild = (node, forceDisabled = false) => {
  508. path.push(node);
  509. const cPath = this.cascaderComponent.treeService.toOptions(path);
  510. if (filter(searchValue, cPath)) {
  511. this.searchOptionPathMap.set(node, cPath);
  512. node.isDisabled = forceDisabled || node.isDisabled;
  513. node.title = cPath.map(p => this.getOptionLabel(p)).join(' / ');
  514. results.push(node);
  515. }
  516. path.pop();
  517. };
  518. const loopParent = (node, forceDisabled = false) => {
  519. const disabled = forceDisabled || node.isDisabled;
  520. path.push(node);
  521. node.children.forEach(sNode => {
  522. if (!sNode.isLeaf) {
  523. loopParent(sNode, disabled);
  524. }
  525. if (sNode.isLeaf || !sNode.children || !sNode.children.length) {
  526. loopChild(sNode, disabled);
  527. }
  528. });
  529. path.pop();
  530. };
  531. if (!this.columnSnapshot.length) {
  532. this.columns = [[]];
  533. return;
  534. }
  535. this.columnSnapshot[0].forEach(o => (isChildNode(o) ? loopChild(o) : loopParent(o)));
  536. if (sorter) {
  537. results.sort((a, b) => sorter(this.searchOptionPathMap.get(a), this.searchOptionPathMap.get(b), searchValue));
  538. }
  539. this.columns = [results];
  540. this.$redraw.next(); // Search results may be empty, so should redraw.
  541. }
  542. /**
  543. * Set searching mode by UI. It deals with things not directly related to UI.
  544. *
  545. * @param toSearching If this cascader is entering searching mode
  546. */
  547. setSearchingMode(toSearching) {
  548. this.inSearchingMode = toSearching;
  549. if (toSearching) {
  550. this.clearSearchOptions(); // if reset nzOptions when searching, should clear searchOptionPathMap
  551. this.columnSnapshot = [...this.columns];
  552. this.activatedNodes = [];
  553. }
  554. else {
  555. // User quit searching mode without selecting an option.
  556. this.clearSearchOptions();
  557. this.activatedNodes = [];
  558. setTimeout(() => {
  559. this.columns = [...this.columnSnapshot];
  560. if (this.cascaderComponent.selectedNodes.length) {
  561. const activatedNode = this.cascaderComponent.selectedNodes[0];
  562. const columnIndex = activatedNode.level;
  563. this.activatedNodes[columnIndex] = activatedNode;
  564. this.trackAncestorActivatedNodes(columnIndex);
  565. this.trackAncestorColumnData(columnIndex);
  566. }
  567. this.$redraw.next();
  568. });
  569. }
  570. this.$redraw.next();
  571. }
  572. /**
  573. * Clear selected options.
  574. */
  575. clear() {
  576. this.values = [];
  577. this.activatedNodes = [];
  578. this.dropBehindColumns(0);
  579. this.$redraw.next();
  580. this.$nodeSelected.next(null);
  581. }
  582. getOptionLabel(o) {
  583. return o[this.cascaderComponent.nzLabelProperty || 'label'];
  584. }
  585. getOptionValue(o) {
  586. return o[this.cascaderComponent.nzValueProperty || 'value'];
  587. }
  588. /**
  589. * Try to insert options into a column.
  590. *
  591. * @param nodes Options to insert
  592. * @param columnIndex Position
  593. */
  594. setColumnData(nodes, columnIndex) {
  595. this.columns[columnIndex] = nodes;
  596. this.dropBehindColumns(columnIndex);
  597. }
  598. /**
  599. * Set all columns data according to activate option's path
  600. */
  601. trackAncestorColumnData(startIndex) {
  602. const node = this.activatedNodes[startIndex];
  603. if (!node) {
  604. return;
  605. }
  606. this.dropBehindColumns(startIndex);
  607. for (let i = 0; i < startIndex; i++) {
  608. this.columns[i + 1] = this.activatedNodes[i].children;
  609. }
  610. }
  611. /**
  612. * Set all ancestor options as activated.
  613. */
  614. trackAncestorActivatedNodes(startIndex) {
  615. for (let i = startIndex - 1; i >= 0; i--) {
  616. if (!this.activatedNodes[i]) {
  617. this.activatedNodes[i] = this.activatedNodes[i + 1].parentNode;
  618. }
  619. }
  620. }
  621. dropBehindActivatedNodes(lastReserveIndex) {
  622. this.activatedNodes = this.activatedNodes.splice(0, lastReserveIndex + 1);
  623. }
  624. dropBehindColumns(lastReserveIndex) {
  625. if (lastReserveIndex < this.columns.length - 1) {
  626. this.columns = this.columns.slice(0, lastReserveIndex + 1);
  627. }
  628. }
  629. /**
  630. * Load children of an option asynchronously.
  631. */
  632. loadChildren(node, columnIndex, onLoaded) {
  633. const isRoot = columnIndex < 0 || !isNotNil(node);
  634. const option = node?.origin || {};
  635. const loadFn = this.cascaderComponent.nzLoadData;
  636. if (loadFn) {
  637. // If there isn't any option in columns.
  638. this.$loading.next(isRoot);
  639. if (node) {
  640. node.isLoading = true;
  641. }
  642. from(loadFn(option, columnIndex))
  643. .pipe(finalize(() => {
  644. node && (node.isLoading = false);
  645. this.$loading.next(false);
  646. this.$redraw.next();
  647. }))
  648. .subscribe({
  649. next: () => {
  650. if (option.children) {
  651. if (!isRoot) {
  652. const nodes = option.children.map(o => new NzTreeNode(o, node));
  653. node.children = nodes;
  654. this.setColumnData(nodes, columnIndex + 1);
  655. }
  656. else {
  657. // If it's root node, we should initialize the tree.
  658. const nodes = this.cascaderComponent.coerceTreeNodes(option.children);
  659. this.cascaderComponent.treeService.initTree(nodes);
  660. this.setColumnData(nodes, 0);
  661. }
  662. onLoaded?.(option.children);
  663. }
  664. },
  665. error: () => {
  666. node && (node.isLeaf = true);
  667. }
  668. });
  669. }
  670. }
  671. isLoaded(index) {
  672. return !!this.columns[index] && this.columns[index].length > 0;
  673. }
  674. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
  675. static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderService });
  676. }
  677. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderService, decorators: [{
  678. type: Injectable
  679. }] });
  680. const NZ_CONFIG_MODULE_NAME = 'cascader';
  681. const defaultDisplayRender = (labels) => labels.join(' / ');
  682. let NzCascaderComponent = (() => {
  683. let _classSuper = NzTreeBase;
  684. let _nzSize_decorators;
  685. let _nzSize_initializers = [];
  686. let _nzSize_extraInitializers = [];
  687. let _nzBackdrop_decorators;
  688. let _nzBackdrop_initializers = [];
  689. let _nzBackdrop_extraInitializers = [];
  690. return class NzCascaderComponent extends _classSuper {
  691. static {
  692. const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
  693. _nzSize_decorators = [WithConfig()];
  694. _nzBackdrop_decorators = [WithConfig()];
  695. __esDecorate(null, null, _nzSize_decorators, { kind: "field", name: "nzSize", static: false, private: false, access: { has: obj => "nzSize" in obj, get: obj => obj.nzSize, set: (obj, value) => { obj.nzSize = value; } }, metadata: _metadata }, _nzSize_initializers, _nzSize_extraInitializers);
  696. __esDecorate(null, null, _nzBackdrop_decorators, { kind: "field", name: "nzBackdrop", static: false, private: false, access: { has: obj => "nzBackdrop" in obj, get: obj => obj.nzBackdrop, set: (obj, value) => { obj.nzBackdrop = value; } }, metadata: _metadata }, _nzBackdrop_initializers, _nzBackdrop_extraInitializers);
  697. if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
  698. }
  699. ngZone;
  700. cdr;
  701. i18nService;
  702. destroy$;
  703. elementRef;
  704. renderer;
  705. directionality;
  706. _nzModuleName = NZ_CONFIG_MODULE_NAME;
  707. selectContainer;
  708. set input(inputComponent) {
  709. this.input$.next(inputComponent?.inputElement);
  710. }
  711. get input() {
  712. return this.input$.getValue();
  713. }
  714. /** Used to store the native `<input type="search" />` element since it might be set asynchronously. */
  715. input$ = new BehaviorSubject(undefined);
  716. menu;
  717. overlay;
  718. cascaderItems;
  719. nzOptionRender = null;
  720. nzShowInput = true;
  721. nzShowArrow = true;
  722. nzAllowClear = true;
  723. nzAutoFocus = false;
  724. nzChangeOnSelect = false;
  725. nzDisabled = false;
  726. nzColumnClassName;
  727. nzExpandTrigger = 'click';
  728. nzValueProperty = 'value';
  729. nzLabelProperty = 'label';
  730. nzLabelRender = null;
  731. nzNotFoundContent;
  732. nzSize = __runInitializers(this, _nzSize_initializers, 'default');
  733. nzBackdrop = (__runInitializers(this, _nzSize_extraInitializers), __runInitializers(this, _nzBackdrop_initializers, false));
  734. nzShowSearch = (__runInitializers(this, _nzBackdrop_extraInitializers), false);
  735. nzPlaceHolder = '';
  736. nzMenuClassName;
  737. nzMenuStyle = null;
  738. /**
  739. * Duration in milliseconds before opening the menu when the mouse enters the trigger.
  740. * @default 150
  741. */
  742. nzMouseLeaveDelay = 150;
  743. /**
  744. * Duration in milliseconds before closing the menu when the mouse leaves the trigger.
  745. * @default 150
  746. */
  747. nzMouseEnterDelay = 150;
  748. nzStatus = '';
  749. nzMultiple = false;
  750. nzMaxTagCount = Infinity;
  751. nzPlacement = 'bottomLeft';
  752. nzTriggerAction = ['click'];
  753. nzChangeOn;
  754. nzLoadData;
  755. nzDisplayWith = (nodes) => {
  756. return defaultDisplayRender(nodes.map(n => this.cascaderService.getOptionLabel(n)));
  757. };
  758. // TODO: RTL
  759. nzSuffixIcon = 'down';
  760. nzExpandIcon = '';
  761. get nzOptions() {
  762. return this.cascaderService.nzOptions;
  763. }
  764. set nzOptions(options) {
  765. const nodes = this.coerceTreeNodes(options || []);
  766. this.treeService.initTree(nodes);
  767. this.cascaderService.columns = [nodes];
  768. this.updateSelectedNodes(true);
  769. if (this.inSearchingMode) {
  770. this.cascaderService.setSearchingMode(this.inSearchingMode);
  771. this.cascaderService.prepareSearchOptions(this.inputValue);
  772. }
  773. }
  774. get treeService() {
  775. return this.nzTreeService;
  776. }
  777. nzVisibleChange = new EventEmitter();
  778. nzSelectionChange = new EventEmitter();
  779. nzRemoved = new EventEmitter();
  780. nzClear = new EventEmitter();
  781. prefixCls = 'ant-select';
  782. statusCls = {};
  783. status = '';
  784. hasFeedback = false;
  785. /**
  786. * If the dropdown should show the empty content.
  787. * `true` if there's no options.
  788. */
  789. shouldShowEmpty = false;
  790. el;
  791. menuVisible = false;
  792. isLoading = false;
  793. labelRenderText;
  794. labelRenderContext = {};
  795. onChange = Function.prototype;
  796. onTouched = Function.prototype;
  797. positions = [...DEFAULT_CASCADER_POSITIONS];
  798. /**
  799. * Dropdown width in pixel.
  800. */
  801. dropdownWidthStyle;
  802. dropdownHeightStyle = '';
  803. dropdownPosition = 'bottomLeft';
  804. isFocused = false;
  805. locale;
  806. dir = 'ltr';
  807. isComposing = false;
  808. get overlayOrigin() {
  809. return this.elementRef;
  810. }
  811. finalSize = computed(() => {
  812. if (this.compactSize) {
  813. return this.compactSize();
  814. }
  815. return this.size();
  816. });
  817. size = signal(this.nzSize);
  818. compactSize = inject(NZ_SPACE_COMPACT_SIZE, { optional: true });
  819. inputString = '';
  820. isOpening = false;
  821. delayMenuTimer;
  822. delaySelectTimer;
  823. isNzDisableFirstChange = true;
  824. selectedNodes = [];
  825. get inSearchingMode() {
  826. return this.cascaderService.inSearchingMode;
  827. }
  828. set inputValue(inputValue) {
  829. this.inputString = inputValue;
  830. this.toggleSearchingMode(!!inputValue);
  831. }
  832. get inputValue() {
  833. return this.inputString;
  834. }
  835. get hasInput() {
  836. return !!this.inputValue;
  837. }
  838. get hasValue() {
  839. return this.cascaderService.values && this.cascaderService.values.length > 0;
  840. }
  841. get showLabelRender() {
  842. return !this.hasInput && !this.nzMultiple && !!this.selectedNodes.length;
  843. }
  844. get showPlaceholder() {
  845. return !(this.hasInput || this.hasValue);
  846. }
  847. get clearIconVisible() {
  848. return this.nzAllowClear && !this.nzDisabled && (this.hasValue || this.hasInput);
  849. }
  850. get isLabelRenderTemplate() {
  851. return !!this.nzLabelRender;
  852. }
  853. noAnimation = inject(NzNoAnimationDirective, { host: true, optional: true });
  854. nzFormStatusService = inject(NzFormStatusService, { optional: true });
  855. nzFormNoStatusService = inject(NzFormNoStatusService, { optional: true });
  856. nzConfigService = inject(NzConfigService);
  857. cascaderService = inject(NzCascaderService);
  858. constructor(treeService, ngZone, cdr, i18nService, destroy$, elementRef, renderer, directionality) {
  859. super(treeService);
  860. this.ngZone = ngZone;
  861. this.cdr = cdr;
  862. this.i18nService = i18nService;
  863. this.destroy$ = destroy$;
  864. this.elementRef = elementRef;
  865. this.renderer = renderer;
  866. this.directionality = directionality;
  867. this.el = elementRef.nativeElement;
  868. this.cascaderService.withComponent(this);
  869. this.renderer.addClass(this.elementRef.nativeElement, 'ant-select');
  870. this.renderer.addClass(this.elementRef.nativeElement, 'ant-cascader');
  871. }
  872. ngOnInit() {
  873. this.nzFormStatusService?.formStatusChanges
  874. .pipe(distinctUntilChanged((pre, cur) => pre.status === cur.status && pre.hasFeedback === cur.hasFeedback), withLatestFrom(this.nzFormNoStatusService ? this.nzFormNoStatusService.noFormStatus : of(false)), map(([{ status, hasFeedback }, noStatus]) => ({ status: noStatus ? '' : status, hasFeedback })), takeUntil(this.destroy$))
  875. .subscribe(({ status, hasFeedback }) => {
  876. this.setStatusStyles(status, hasFeedback);
  877. });
  878. const srv = this.cascaderService;
  879. srv.$redraw.pipe(takeUntil(this.destroy$)).subscribe(() => {
  880. // These operations would not mutate data.
  881. this.checkChildren();
  882. this.setDisplayLabel();
  883. this.cdr.detectChanges();
  884. this.reposition();
  885. this.setDropdownStyles();
  886. });
  887. srv.$loading.pipe(takeUntil(this.destroy$)).subscribe(loading => {
  888. this.isLoading = loading;
  889. });
  890. srv.$nodeSelected.pipe(takeUntil(this.destroy$)).subscribe(node => {
  891. if (!node) {
  892. this.emitValue([]);
  893. this.nzSelectionChange.emit([]);
  894. }
  895. else {
  896. const shouldClose =
  897. // keep menu opened if multiple mode
  898. !this.nzMultiple && (node.isLeaf || (this.nzChangeOnSelect && this.nzExpandTrigger === 'hover'));
  899. if (shouldClose) {
  900. this.delaySetMenuVisible(false);
  901. }
  902. this.nzSelectionChange.emit(this.getAncestorOptionList(node));
  903. this.cdr.markForCheck();
  904. }
  905. });
  906. srv.$quitSearching.pipe(takeUntil(this.destroy$)).subscribe(() => {
  907. this.inputValue = '';
  908. this.dropdownWidthStyle = '';
  909. });
  910. this.i18nService.localeChange.pipe(startWith(), takeUntil(this.destroy$)).subscribe(() => {
  911. this.setLocale();
  912. });
  913. this.size.set(this.nzSize);
  914. this.nzConfigService
  915. .getConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME)
  916. .pipe(takeUntil(this.destroy$))
  917. .subscribe(() => {
  918. this.size.set(this.nzSize);
  919. this.cdr.markForCheck();
  920. });
  921. this.dir = this.directionality.value;
  922. this.directionality.change.pipe(takeUntil(this.destroy$)).subscribe(() => {
  923. this.dir = this.directionality.value;
  924. srv.$redraw.next();
  925. });
  926. this.setupSelectionChangeListener();
  927. this.setupChangeListener();
  928. this.setupKeydownListener();
  929. this.setupFocusListener();
  930. }
  931. ngOnChanges(changes) {
  932. const { nzStatus, nzSize, nzPlacement } = changes;
  933. if (nzStatus) {
  934. this.setStatusStyles(this.nzStatus, this.hasFeedback);
  935. }
  936. if (nzSize) {
  937. this.size.set(nzSize.currentValue);
  938. }
  939. if (nzPlacement) {
  940. const { currentValue } = nzPlacement;
  941. this.dropdownPosition = currentValue;
  942. const listOfPlacement = ['bottomLeft', 'topLeft', 'bottomRight', 'topRight'];
  943. if (currentValue && listOfPlacement.includes(currentValue)) {
  944. this.positions = [POSITION_MAP[currentValue]];
  945. }
  946. else {
  947. this.positions = listOfPlacement.map(e => POSITION_MAP[e]);
  948. }
  949. }
  950. }
  951. ngOnDestroy() {
  952. this.clearDelayMenuTimer();
  953. this.clearDelaySelectTimer();
  954. }
  955. registerOnChange(fn) {
  956. this.onChange = fn;
  957. }
  958. registerOnTouched(fn) {
  959. this.onTouched = fn;
  960. }
  961. writeValue(value) {
  962. if (isNotNil(value)) {
  963. if (this.nzMultiple) {
  964. this.cascaderService.values = toArray(value);
  965. }
  966. else {
  967. this.cascaderService.values = [toArray(value)];
  968. }
  969. // need clear selected nodes when user set value before updating
  970. this.clearSelectedNodes();
  971. this.updateSelectedNodes(true, false);
  972. }
  973. else {
  974. this.cascaderService.values = [];
  975. this.clearSelectedNodes();
  976. this.selectedNodes = [];
  977. this.cascaderService.$redraw.next();
  978. }
  979. }
  980. setupSelectionChangeListener() {
  981. merge(this.nzSelectionChange, this.nzRemoved, this.nzClear)
  982. .pipe(takeUntil(this.destroy$))
  983. .subscribe(() => {
  984. this.updateSelectedNodes();
  985. this.emitValue(this.cascaderService.values);
  986. this.cascaderService.$redraw.next();
  987. });
  988. }
  989. delaySetMenuVisible(visible, delay = 100, setOpening = false) {
  990. this.clearDelayMenuTimer();
  991. if (delay) {
  992. if (visible && setOpening) {
  993. this.isOpening = true;
  994. }
  995. this.delayMenuTimer = setTimeout(() => {
  996. this.setMenuVisible(visible);
  997. this.cdr.detectChanges();
  998. this.clearDelayMenuTimer();
  999. if (visible) {
  1000. setTimeout(() => {
  1001. this.isOpening = false;
  1002. }, 100);
  1003. }
  1004. }, delay);
  1005. }
  1006. else {
  1007. this.setMenuVisible(visible);
  1008. }
  1009. }
  1010. setMenuVisible(visible) {
  1011. if (this.nzDisabled || this.menuVisible === visible) {
  1012. return;
  1013. }
  1014. if (visible) {
  1015. this.cascaderService.$redraw.next();
  1016. this.updateSelectedNodes(!!this.nzLoadData);
  1017. this.scrollToActivatedOptions();
  1018. }
  1019. else {
  1020. this.inputValue = '';
  1021. }
  1022. this.menuVisible = visible;
  1023. this.nzVisibleChange.emit(visible);
  1024. this.cdr.detectChanges();
  1025. }
  1026. clearDelayMenuTimer() {
  1027. if (this.delayMenuTimer) {
  1028. clearTimeout(this.delayMenuTimer);
  1029. this.delayMenuTimer = undefined;
  1030. }
  1031. }
  1032. clearSelection(event) {
  1033. if (event) {
  1034. event.preventDefault();
  1035. event.stopPropagation();
  1036. }
  1037. this.clearSelectedNodes();
  1038. this.labelRenderText = '';
  1039. this.labelRenderContext = {};
  1040. this.inputValue = '';
  1041. this.setMenuVisible(false);
  1042. this.cascaderService.clear();
  1043. this.nzClear.emit();
  1044. }
  1045. clearSelectedNodes() {
  1046. this.selectedNodes.forEach(node => {
  1047. this.removeSelected(node, false);
  1048. });
  1049. }
  1050. emitValue(values) {
  1051. if (this.nzMultiple) {
  1052. this.onChange(values);
  1053. }
  1054. else {
  1055. this.onChange(values?.length ? values[0] : []);
  1056. }
  1057. }
  1058. /**
  1059. * @internal
  1060. */
  1061. getSubmitValue() {
  1062. if (this.nzMultiple) {
  1063. return this.cascaderService.values;
  1064. }
  1065. else {
  1066. return this.cascaderService.values?.length ? this.cascaderService.values[0] : [];
  1067. }
  1068. }
  1069. focus() {
  1070. if (!this.isFocused) {
  1071. (this.input?.nativeElement || this.el).focus();
  1072. this.isFocused = true;
  1073. }
  1074. }
  1075. blur() {
  1076. if (this.isFocused) {
  1077. (this.input?.nativeElement || this.el).blur();
  1078. this.isFocused = false;
  1079. }
  1080. }
  1081. handleInputBlur() {
  1082. this.menuVisible ? this.focus() : this.blur();
  1083. }
  1084. handleInputFocus() {
  1085. this.focus();
  1086. }
  1087. isComposingChange(isComposing) {
  1088. this.isComposing = isComposing;
  1089. }
  1090. onTriggerClick() {
  1091. if (this.nzDisabled) {
  1092. return;
  1093. }
  1094. if (this.nzShowSearch) {
  1095. this.focus();
  1096. }
  1097. if (this.isActionTrigger('click')) {
  1098. this.delaySetMenuVisible(!this.menuVisible, 100);
  1099. }
  1100. this.onTouched();
  1101. }
  1102. onTriggerMouseEnter() {
  1103. if (this.nzDisabled || !this.isActionTrigger('hover')) {
  1104. return;
  1105. }
  1106. this.delaySetMenuVisible(true, this.nzMouseEnterDelay, true);
  1107. }
  1108. onTriggerMouseLeave(event) {
  1109. if (this.nzDisabled || !this.menuVisible || this.isOpening || !this.isActionTrigger('hover')) {
  1110. event.preventDefault();
  1111. return;
  1112. }
  1113. const mouseTarget = event.relatedTarget;
  1114. const hostEl = this.el;
  1115. const menuEl = this.menu && this.menu.nativeElement;
  1116. if (hostEl.contains(mouseTarget) || (menuEl && menuEl.contains(mouseTarget))) {
  1117. return;
  1118. }
  1119. this.delaySetMenuVisible(false, this.nzMouseLeaveDelay);
  1120. }
  1121. onOptionMouseEnter(node, columnIndex, event) {
  1122. event.preventDefault();
  1123. if (this.nzExpandTrigger === 'hover') {
  1124. if (!node.isLeaf) {
  1125. this.delaySetOptionActivated(node, columnIndex, false);
  1126. }
  1127. else {
  1128. this.cascaderService.setNodeDeactivatedSinceColumn(columnIndex);
  1129. }
  1130. }
  1131. }
  1132. onOptionMouseLeave(node, _columnIndex, event) {
  1133. event.preventDefault();
  1134. if (this.nzExpandTrigger === 'hover' && !node.isLeaf) {
  1135. this.clearDelaySelectTimer();
  1136. }
  1137. }
  1138. /**
  1139. * Get ancestor options of a node
  1140. */
  1141. getAncestorOptionList(node) {
  1142. const ancestors = this.treeService.getAncestorNodeList(node);
  1143. return this.treeService.toOptions(ancestors);
  1144. }
  1145. updateSelectedNodes(init = false, updateValue = true) {
  1146. const value = this.cascaderService.values;
  1147. const multiple = this.nzMultiple;
  1148. /**
  1149. * Update selected nodes and emit value
  1150. * @param shouldUpdateValue if false, only update selected nodes
  1151. */
  1152. const updateNodesAndValue = (shouldUpdateValue) => {
  1153. this.selectedNodes = [
  1154. ...this.treeService.missingNodeList,
  1155. ...(this.nzMultiple ? this.getCheckedNodeList() : this.getSelectedNodeList())
  1156. ].sort((a, b) => {
  1157. const indexA = value.indexOf(a.key);
  1158. const indexB = value.indexOf(b.key);
  1159. if (indexA !== -1 && indexB !== -1) {
  1160. return indexA - indexB;
  1161. }
  1162. if (indexA !== -1) {
  1163. return -1;
  1164. }
  1165. if (indexB !== -1) {
  1166. return 1;
  1167. }
  1168. return 0;
  1169. });
  1170. if (shouldUpdateValue) {
  1171. this.cascaderService.values = this.selectedNodes.map(node => this.getAncestorOptionList(node).map(o => this.cascaderService.getOptionValue(o)));
  1172. }
  1173. this.cascaderService.$redraw.next();
  1174. };
  1175. if (init) {
  1176. const defaultValue = value[0];
  1177. const lastColumnIndex = defaultValue?.length ? defaultValue.length - 1 : 0;
  1178. this.treeService.fieldNames = {
  1179. value: this.nzValueProperty,
  1180. label: this.nzLabelProperty
  1181. };
  1182. this.treeService.isMultiple = multiple;
  1183. this.treeService.isCheckStrictly = false;
  1184. /**
  1185. * check whether the node is checked or selected according to the value
  1186. */
  1187. const checkNodeStates = () => {
  1188. if (multiple) {
  1189. this.treeService.conductCheckPaths(value, this.treeService.isCheckStrictly);
  1190. }
  1191. else {
  1192. this.treeService.conductSelectedPaths(value, multiple);
  1193. }
  1194. };
  1195. const initColumnWithIndex = (columnIndex = 0) => {
  1196. const activatedOptionSetter = () => {
  1197. const currentValue = defaultValue?.[columnIndex];
  1198. if (!isNotNil(currentValue)) {
  1199. this.cascaderService.$redraw.next();
  1200. return;
  1201. }
  1202. const node = this.cascaderService.columns[columnIndex].find(n => this.cascaderService.getOptionValue(n.origin) === currentValue) || null;
  1203. if (isNotNil(node)) {
  1204. this.cascaderService.setNodeActivated(node, columnIndex, false, multiple, false);
  1205. // Load next level options till leaf node
  1206. if (columnIndex < lastColumnIndex) {
  1207. initColumnWithIndex(columnIndex + 1);
  1208. }
  1209. }
  1210. checkNodeStates();
  1211. updateNodesAndValue(false);
  1212. };
  1213. if (this.cascaderService.isLoaded(columnIndex) || !this.nzLoadData) {
  1214. activatedOptionSetter();
  1215. }
  1216. else {
  1217. const node = this.cascaderService.activatedNodes[columnIndex - 1];
  1218. this.cascaderService.loadChildren(node, columnIndex - 1, activatedOptionSetter);
  1219. }
  1220. };
  1221. // if nzLoadData set, load first level data asynchronously
  1222. if (this.nzLoadData) {
  1223. initColumnWithIndex();
  1224. }
  1225. else {
  1226. const nodes = this.coerceTreeNodes(this.nzOptions || []);
  1227. this.treeService.initTree(nodes);
  1228. this.cascaderService.setColumnData(nodes, 0);
  1229. initColumnWithIndex();
  1230. }
  1231. }
  1232. updateNodesAndValue(updateValue);
  1233. }
  1234. onOptionClick(node, columnIndex, event) {
  1235. if (event) {
  1236. event.preventDefault();
  1237. }
  1238. if (node && node.isDisabled) {
  1239. return;
  1240. }
  1241. this.el.focus();
  1242. // for multiple mode, click the leaf node can be seen as check action
  1243. if (this.nzMultiple && node.isLeaf) {
  1244. this.onOptionCheck(node, columnIndex, true);
  1245. }
  1246. else {
  1247. this.inSearchingMode
  1248. ? this.cascaderService.setSearchOptionSelected(node, this.nzMultiple)
  1249. : this.cascaderService.setNodeActivated(node, columnIndex, !this.nzMultiple);
  1250. }
  1251. }
  1252. onOptionCheck(node, columnIndex, performActivate = false) {
  1253. if (!this.nzMultiple || node.isDisabled || node.isDisableCheckbox) {
  1254. return;
  1255. }
  1256. node.isChecked = !node.isChecked;
  1257. node.isHalfChecked = false;
  1258. this.treeService.setCheckedNodeList(node);
  1259. this.treeService.conduct(node, this.treeService.isCheckStrictly);
  1260. if (this.inSearchingMode) {
  1261. this.cascaderService.setSearchOptionSelected(node, true);
  1262. }
  1263. else if (performActivate) {
  1264. this.cascaderService.setNodeActivated(node, columnIndex, true, true);
  1265. }
  1266. else {
  1267. // only update selected nodes and not set node activated by default
  1268. this.cascaderService.setNodeSelected(node, columnIndex, true);
  1269. }
  1270. }
  1271. removeSelected(node, emitEvent = true) {
  1272. node.isSelected = false;
  1273. node.isChecked = false;
  1274. if (this.nzMultiple) {
  1275. this.treeService.conduct(node, this.treeService.isCheckStrictly);
  1276. }
  1277. this.treeService.setSelectedNodeList(node, this.nzMultiple);
  1278. if (emitEvent) {
  1279. this.nzRemoved.emit(node.origin);
  1280. }
  1281. }
  1282. onClickOutside(event) {
  1283. const target = _getEventTarget(event);
  1284. if (!this.el.contains(target)) {
  1285. this.closeMenu();
  1286. }
  1287. }
  1288. onPositionChange(position) {
  1289. const placement = getPlacementName(position);
  1290. this.dropdownPosition = placement;
  1291. }
  1292. isActionTrigger(action) {
  1293. return typeof this.nzTriggerAction === 'string'
  1294. ? this.nzTriggerAction === action
  1295. : this.nzTriggerAction.indexOf(action) !== -1;
  1296. }
  1297. onEnter() {
  1298. const columnIndex = Math.max(this.cascaderService.activatedNodes.length - 1, 0);
  1299. const node = this.cascaderService.activatedNodes[columnIndex];
  1300. if (node && !node.isDisabled) {
  1301. this.inSearchingMode
  1302. ? this.cascaderService.setSearchOptionSelected(node)
  1303. : this.cascaderService.setNodeActivated(node, columnIndex, true);
  1304. }
  1305. }
  1306. moveUpOrDown(isUp) {
  1307. const columnIndex = Math.max(this.cascaderService.activatedNodes.length - 1, 0);
  1308. const activatedNode = this.cascaderService.activatedNodes[columnIndex];
  1309. const options = this.cascaderService.columns[columnIndex] || [];
  1310. const length = options.length;
  1311. let nextIndex = -1;
  1312. if (!activatedNode) {
  1313. // Not selected options in this column
  1314. nextIndex = isUp ? length : -1;
  1315. }
  1316. else {
  1317. nextIndex = options.indexOf(activatedNode);
  1318. }
  1319. while (true) {
  1320. nextIndex = isUp ? nextIndex - 1 : nextIndex + 1;
  1321. if (nextIndex < 0 || nextIndex >= length) {
  1322. break;
  1323. }
  1324. const nextOption = options[nextIndex];
  1325. if (!nextOption || nextOption.isDisabled) {
  1326. continue;
  1327. }
  1328. this.cascaderService.setNodeActivated(nextOption, columnIndex);
  1329. break;
  1330. }
  1331. }
  1332. moveLeft() {
  1333. const options = this.cascaderService.activatedNodes;
  1334. if (options.length) {
  1335. options.pop(); // Remove the last one
  1336. this.cascaderService.setNodeDeactivatedSinceColumn(options.length); // collapse menu
  1337. }
  1338. }
  1339. moveRight() {
  1340. const length = this.cascaderService.activatedNodes.length;
  1341. const options = this.cascaderService.columns[length];
  1342. if (options && options.length) {
  1343. const nextOpt = options.find(o => !o.isDisabled);
  1344. if (nextOpt) {
  1345. this.cascaderService.setNodeActivated(nextOpt, length);
  1346. }
  1347. }
  1348. }
  1349. clearDelaySelectTimer() {
  1350. if (this.delaySelectTimer) {
  1351. clearTimeout(this.delaySelectTimer);
  1352. this.delaySelectTimer = undefined;
  1353. }
  1354. }
  1355. delaySetOptionActivated(node, columnIndex, performSelect) {
  1356. this.clearDelaySelectTimer();
  1357. this.delaySelectTimer = setTimeout(() => {
  1358. this.cascaderService.setNodeActivated(node, columnIndex, performSelect, this.nzMultiple);
  1359. this.delaySelectTimer = undefined;
  1360. }, 150);
  1361. }
  1362. toggleSearchingMode(toSearching) {
  1363. if (this.inSearchingMode !== toSearching) {
  1364. this.cascaderService.setSearchingMode(toSearching);
  1365. }
  1366. if (this.inSearchingMode) {
  1367. this.cascaderService.prepareSearchOptions(this.inputValue);
  1368. }
  1369. }
  1370. isOptionActivated(node, index) {
  1371. return this.cascaderService.activatedNodes[index] === node;
  1372. }
  1373. setDisabledState(isDisabled) {
  1374. this.nzDisabled = (this.isNzDisableFirstChange && this.nzDisabled) || isDisabled;
  1375. this.isNzDisableFirstChange = false;
  1376. if (this.nzDisabled) {
  1377. this.closeMenu();
  1378. }
  1379. }
  1380. closeMenu() {
  1381. this.blur();
  1382. this.clearDelayMenuTimer();
  1383. this.setMenuVisible(false);
  1384. // if select none, clear previous state
  1385. if (!this.hasValue && this.cascaderService.columns.length) {
  1386. this.cascaderService.dropBehindColumns(0);
  1387. }
  1388. }
  1389. /**
  1390. * Reposition the cascader panel. When a menu opens, the cascader expands
  1391. * and may exceed the boundary of browser's window.
  1392. */
  1393. reposition() {
  1394. if (this.overlay && this.overlay.overlayRef && this.menuVisible) {
  1395. Promise.resolve().then(() => {
  1396. this.overlay.overlayRef.updatePosition();
  1397. this.cdr.markForCheck();
  1398. });
  1399. }
  1400. }
  1401. /**
  1402. * When a cascader options is changed, a child needs to know that it should re-render.
  1403. */
  1404. checkChildren() {
  1405. if (this.cascaderItems) {
  1406. this.cascaderItems.forEach(item => item.markForCheck());
  1407. }
  1408. }
  1409. setDisplayLabel() {
  1410. if (this.nzMultiple) {
  1411. return;
  1412. }
  1413. const node = this.selectedNodes.length ? this.selectedNodes[0] : null;
  1414. const selectedOptions = this.getAncestorOptionList(node);
  1415. const labels = selectedOptions.map(o => this.cascaderService.getOptionLabel(o));
  1416. if (this.isLabelRenderTemplate) {
  1417. this.labelRenderContext = { labels, selectedOptions };
  1418. }
  1419. this.labelRenderText = defaultDisplayRender.call(this, labels);
  1420. }
  1421. setDropdownStyles() {
  1422. const firstColumn = this.cascaderService.columns[0];
  1423. this.shouldShowEmpty =
  1424. (this.inSearchingMode && (!firstColumn || !firstColumn.length)) || // Should show empty when there's no searching result
  1425. (!(this.nzOptions && this.nzOptions.length) && !this.nzLoadData); // Should show when there's no options and developer does not use nzLoadData
  1426. this.dropdownHeightStyle = this.shouldShowEmpty ? 'auto' : '';
  1427. if (this.input) {
  1428. this.dropdownWidthStyle =
  1429. this.inSearchingMode || this.shouldShowEmpty ? `${this.selectContainer.nativeElement.offsetWidth}px` : '';
  1430. }
  1431. }
  1432. setStatusStyles(status, hasFeedback) {
  1433. // set inner status
  1434. this.status = status;
  1435. this.hasFeedback = hasFeedback;
  1436. this.cdr.markForCheck();
  1437. // render status if nzStatus is set
  1438. this.statusCls = getStatusClassNames(this.prefixCls, status, hasFeedback);
  1439. Object.keys(this.statusCls).forEach(status => {
  1440. if (this.statusCls[status]) {
  1441. this.renderer.addClass(this.elementRef.nativeElement, status);
  1442. }
  1443. else {
  1444. this.renderer.removeClass(this.elementRef.nativeElement, status);
  1445. }
  1446. });
  1447. }
  1448. setLocale() {
  1449. this.locale = this.i18nService.getLocaleData('global');
  1450. this.cdr.markForCheck();
  1451. }
  1452. scrollToActivatedOptions() {
  1453. // The `scrollIntoView` is a native DOM API, which doesn't require Angular to run
  1454. // a change detection when a promise microtask is resolved.
  1455. this.ngZone.runOutsideAngular(() => {
  1456. Promise.resolve().then(() => {
  1457. // scroll only until option menu view is ready
  1458. this.cascaderItems
  1459. .toArray()
  1460. .filter(e => e.activated)
  1461. .forEach(e => {
  1462. e.nativeElement.scrollIntoView({ block: 'start', inline: 'nearest' });
  1463. });
  1464. });
  1465. });
  1466. }
  1467. setupChangeListener() {
  1468. this.input$
  1469. .pipe(switchMap(input => fromEventOutsideAngular(input?.nativeElement, 'change')), takeUntil(this.destroy$))
  1470. .subscribe(event => event.stopPropagation());
  1471. }
  1472. setupFocusListener() {
  1473. this.input$
  1474. .pipe(switchMap(input => fromEventOutsideAngular(input?.nativeElement, 'focus')), takeUntil(this.destroy$))
  1475. .subscribe(() => this.handleInputFocus());
  1476. this.input$
  1477. .pipe(switchMap(input => fromEventOutsideAngular(input?.nativeElement, 'blur')), takeUntil(this.destroy$))
  1478. .subscribe(() => this.handleInputBlur());
  1479. }
  1480. setupKeydownListener() {
  1481. fromEventOutsideAngular(this.el, 'keydown')
  1482. .pipe(takeUntil(this.destroy$))
  1483. .subscribe(event => {
  1484. const keyCode = event.keyCode;
  1485. if (keyCode !== DOWN_ARROW &&
  1486. keyCode !== UP_ARROW &&
  1487. keyCode !== LEFT_ARROW &&
  1488. keyCode !== RIGHT_ARROW &&
  1489. keyCode !== ENTER &&
  1490. keyCode !== BACKSPACE &&
  1491. keyCode !== ESCAPE) {
  1492. return;
  1493. }
  1494. // Press any keys above to reopen menu.
  1495. if (!this.menuVisible && keyCode !== BACKSPACE && keyCode !== ESCAPE) {
  1496. // The `setMenuVisible` runs `detectChanges()`, so we don't need to run `markForCheck()` additionally.
  1497. return this.ngZone.run(() => this.setMenuVisible(true));
  1498. }
  1499. // Make these keys work as default in searching mode.
  1500. if (this.inSearchingMode && (keyCode === BACKSPACE || keyCode === LEFT_ARROW || keyCode === RIGHT_ARROW)) {
  1501. return;
  1502. }
  1503. if (!this.menuVisible) {
  1504. return;
  1505. }
  1506. event.preventDefault();
  1507. this.ngZone.run(() => {
  1508. // Interact with the component.
  1509. if (keyCode === DOWN_ARROW) {
  1510. this.moveUpOrDown(false);
  1511. }
  1512. else if (keyCode === UP_ARROW) {
  1513. this.moveUpOrDown(true);
  1514. }
  1515. else if (keyCode === LEFT_ARROW) {
  1516. this.moveLeft();
  1517. }
  1518. else if (keyCode === RIGHT_ARROW) {
  1519. this.moveRight();
  1520. }
  1521. else if (keyCode === ENTER) {
  1522. this.onEnter();
  1523. }
  1524. // `@HostListener`s run `markForCheck()` internally before calling the actual handler so
  1525. // we call `markForCheck()` to be backwards-compatible.
  1526. this.cdr.markForCheck();
  1527. });
  1528. });
  1529. }
  1530. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderComponent, deps: [{ token: NzCascaderTreeService }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }, { token: i2$1.NzI18nService }, { token: i3$1.NzDestroyService }, { token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i4.Directionality }], target: i0.ɵɵFactoryTarget.Component });
  1531. static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.2", type: NzCascaderComponent, isStandalone: true, selector: "nz-cascader, [nz-cascader]", inputs: { nzOptionRender: "nzOptionRender", nzShowInput: ["nzShowInput", "nzShowInput", booleanAttribute], nzShowArrow: ["nzShowArrow", "nzShowArrow", booleanAttribute], nzAllowClear: ["nzAllowClear", "nzAllowClear", booleanAttribute], nzAutoFocus: ["nzAutoFocus", "nzAutoFocus", booleanAttribute], nzChangeOnSelect: ["nzChangeOnSelect", "nzChangeOnSelect", booleanAttribute], nzDisabled: ["nzDisabled", "nzDisabled", booleanAttribute], nzColumnClassName: "nzColumnClassName", nzExpandTrigger: "nzExpandTrigger", nzValueProperty: "nzValueProperty", nzLabelProperty: "nzLabelProperty", nzLabelRender: "nzLabelRender", nzNotFoundContent: "nzNotFoundContent", nzSize: "nzSize", nzBackdrop: "nzBackdrop", nzShowSearch: "nzShowSearch", nzPlaceHolder: "nzPlaceHolder", nzMenuClassName: "nzMenuClassName", nzMenuStyle: "nzMenuStyle", nzMouseLeaveDelay: ["nzMouseLeaveDelay", "nzMouseLeaveDelay", numberAttribute], nzMouseEnterDelay: ["nzMouseEnterDelay", "nzMouseEnterDelay", numberAttribute], nzStatus: "nzStatus", nzMultiple: ["nzMultiple", "nzMultiple", booleanAttribute], nzMaxTagCount: "nzMaxTagCount", nzPlacement: "nzPlacement", nzTriggerAction: "nzTriggerAction", nzChangeOn: "nzChangeOn", nzLoadData: "nzLoadData", nzDisplayWith: "nzDisplayWith", nzSuffixIcon: "nzSuffixIcon", nzExpandIcon: "nzExpandIcon", nzOptions: "nzOptions" }, outputs: { nzVisibleChange: "nzVisibleChange", nzSelectionChange: "nzSelectionChange", nzRemoved: "nzRemoved", nzClear: "nzClear" }, host: { listeners: { "click": "onTriggerClick()", "mouseenter": "onTriggerMouseEnter()", "mouseleave": "onTriggerMouseLeave($event)" }, properties: { "attr.tabIndex": "\"0\"", "class.ant-select-in-form-item": "!!nzFormStatusService", "class.ant-select-lg": "finalSize() === \"large\"", "class.ant-select-sm": "finalSize() === \"small\"", "class.ant-select-allow-clear": "nzAllowClear", "class.ant-select-show-arrow": "nzShowArrow", "class.ant-select-show-search": "!!nzShowSearch", "class.ant-select-disabled": "nzDisabled", "class.ant-select-open": "menuVisible", "class.ant-select-focused": "isFocused", "class.ant-select-multiple": "nzMultiple", "class.ant-select-single": "!nzMultiple", "class.ant-select-rtl": "dir === 'rtl'" } }, providers: [
  1532. {
  1533. provide: NG_VALUE_ACCESSOR,
  1534. useExisting: forwardRef(() => NzCascaderComponent),
  1535. multi: true
  1536. },
  1537. { provide: NZ_SPACE_COMPACT_ITEM_TYPE, useValue: 'select' },
  1538. NzCascaderService,
  1539. NzDestroyService,
  1540. NzCascaderTreeService
  1541. ], viewQueries: [{ propertyName: "selectContainer", first: true, predicate: ["selectContainer"], descendants: true }, { propertyName: "input", first: true, predicate: NzSelectSearchComponent, descendants: true }, { propertyName: "menu", first: true, predicate: ["menu"], descendants: true }, { propertyName: "overlay", first: true, predicate: CdkConnectedOverlay, descendants: true }, { propertyName: "cascaderItems", predicate: NzCascaderOptionComponent, descendants: true }], exportAs: ["nzCascader"], usesInheritance: true, usesOnChanges: true, hostDirectives: [{ directive: i5.NzSpaceCompactItemDirective }], ngImport: i0, template: `
  1542. @if (nzShowInput) {
  1543. <div #selectContainer class="ant-select-selector">
  1544. @if (nzMultiple) {
  1545. @for (node of selectedNodes | slice: 0 : nzMaxTagCount; track node) {
  1546. <nz-select-item
  1547. [deletable]="true"
  1548. [disabled]="nzDisabled"
  1549. [label]="nzDisplayWith(getAncestorOptionList(node))"
  1550. (delete)="removeSelected(node)"
  1551. ></nz-select-item>
  1552. }
  1553. @if (selectedNodes.length > nzMaxTagCount) {
  1554. <nz-select-item
  1555. [deletable]="false"
  1556. [disabled]="false"
  1557. [label]="'+ ' + (selectedNodes.length - nzMaxTagCount) + ' ...'"
  1558. ></nz-select-item>
  1559. }
  1560. }
  1561. <nz-select-search
  1562. [showInput]="!!nzShowSearch"
  1563. (isComposingChange)="isComposingChange($event)"
  1564. [value]="inputValue"
  1565. (valueChange)="inputValue = $event"
  1566. [mirrorSync]="nzMultiple"
  1567. [disabled]="nzDisabled"
  1568. [autofocus]="nzAutoFocus"
  1569. [focusTrigger]="menuVisible"
  1570. ></nz-select-search>
  1571. @if (showPlaceholder) {
  1572. <nz-select-placeholder
  1573. [placeholder]="nzPlaceHolder || locale?.placeholder!"
  1574. [style.display]="inputValue || isComposing ? 'none' : 'block'"
  1575. ></nz-select-placeholder>
  1576. }
  1577. @if (showLabelRender) {
  1578. <nz-select-item
  1579. [deletable]="false"
  1580. [disabled]="nzDisabled"
  1581. [label]="labelRenderText"
  1582. [contentTemplateOutlet]="isLabelRenderTemplate ? nzLabelRender : null"
  1583. [contentTemplateOutletContext]="labelRenderContext"
  1584. ></nz-select-item>
  1585. }
  1586. </div>
  1587. @if (nzShowArrow) {
  1588. <span class="ant-select-arrow" [class.ant-select-arrow-loading]="isLoading">
  1589. @if (!isLoading) {
  1590. <nz-icon [nzType]="$any(nzSuffixIcon)" [class.ant-cascader-picker-arrow-expand]="menuVisible" />
  1591. } @else {
  1592. <nz-icon nzType="loading" />
  1593. }
  1594. @if (hasFeedback && !!status) {
  1595. <nz-form-item-feedback-icon [status]="status" />
  1596. }
  1597. </span>
  1598. }
  1599. @if (clearIconVisible) {
  1600. <nz-select-clear (clear)="clearSelection($event)"></nz-select-clear>
  1601. }
  1602. }
  1603. <ng-content></ng-content>
  1604. <ng-template
  1605. cdkConnectedOverlay
  1606. nzConnectedOverlay
  1607. [cdkConnectedOverlayHasBackdrop]="nzBackdrop"
  1608. [cdkConnectedOverlayOrigin]="overlayOrigin"
  1609. [cdkConnectedOverlayPositions]="positions"
  1610. [cdkConnectedOverlayTransformOriginOn]="'.ant-cascader-dropdown'"
  1611. [cdkConnectedOverlayOpen]="menuVisible"
  1612. (overlayOutsideClick)="onClickOutside($event)"
  1613. (detach)="closeMenu()"
  1614. (positionChange)="onPositionChange($event)"
  1615. >
  1616. <div
  1617. class="ant-select-dropdown ant-cascader-dropdown"
  1618. [class.ant-select-dropdown-placement-bottomLeft]="dropdownPosition === 'bottomLeft'"
  1619. [class.ant-select-dropdown-placement-bottomRight]="dropdownPosition === 'bottomRight'"
  1620. [class.ant-select-dropdown-placement-topLeft]="dropdownPosition === 'topLeft'"
  1621. [class.ant-select-dropdown-placement-topRight]="dropdownPosition === 'topRight'"
  1622. [class.ant-cascader-dropdown-rtl]="dir === 'rtl'"
  1623. [@slideMotion]="'enter'"
  1624. [@.disabled]="!!noAnimation?.nzNoAnimation"
  1625. [nzNoAnimation]="noAnimation?.nzNoAnimation"
  1626. (mouseenter)="onTriggerMouseEnter()"
  1627. (mouseleave)="onTriggerMouseLeave($event)"
  1628. >
  1629. <div
  1630. #menu
  1631. class="ant-cascader-menus"
  1632. [class.ant-cascader-rtl]="dir === 'rtl'"
  1633. [class.ant-cascader-menus-hidden]="!menuVisible"
  1634. [class.ant-cascader-menu-empty]="shouldShowEmpty"
  1635. [class]="nzMenuClassName"
  1636. [style]="nzMenuStyle"
  1637. >
  1638. @if (shouldShowEmpty) {
  1639. <ul class="ant-cascader-menu" [style.width]="dropdownWidthStyle" [style.height]="dropdownHeightStyle">
  1640. <li class="ant-cascader-menu-item ant-cascader-menu-item-disabled">
  1641. <nz-embed-empty
  1642. class="ant-cascader-menu-item-content"
  1643. [nzComponentName]="'cascader'"
  1644. [specificContent]="nzNotFoundContent"
  1645. />
  1646. </li>
  1647. </ul>
  1648. } @else {
  1649. @for (options of cascaderService.columns; track options; let i = $index) {
  1650. <ul
  1651. class="ant-cascader-menu"
  1652. role="menuitemcheckbox"
  1653. [class]="nzColumnClassName"
  1654. [style.height]="dropdownHeightStyle"
  1655. >
  1656. @for (option of options; track option) {
  1657. <li
  1658. nz-cascader-option
  1659. [expandIcon]="nzExpandIcon"
  1660. [columnIndex]="i"
  1661. [nzLabelProperty]="nzLabelProperty"
  1662. [optionTemplate]="nzOptionRender"
  1663. [activated]="isOptionActivated(option, i)"
  1664. [highlightText]="inSearchingMode ? inputValue : ''"
  1665. [node]="option"
  1666. [dir]="dir"
  1667. [checkable]="nzMultiple"
  1668. (mouseenter)="onOptionMouseEnter(option, i, $event)"
  1669. (mouseleave)="onOptionMouseLeave(option, i, $event)"
  1670. (click)="onOptionClick(option, i, $event)"
  1671. (check)="onOptionCheck(option, i)"
  1672. ></li>
  1673. }
  1674. </ul>
  1675. }
  1676. }
  1677. </div>
  1678. </div>
  1679. </ng-template>
  1680. `, isInline: true, dependencies: [{ kind: "pipe", type: SlicePipe, name: "slice" }, { kind: "ngmodule", type: OverlayModule }, { kind: "directive", type: i6.CdkConnectedOverlay, selector: "[cdk-connected-overlay], [connected-overlay], [cdkConnectedOverlay]", inputs: ["cdkConnectedOverlayOrigin", "cdkConnectedOverlayPositions", "cdkConnectedOverlayPositionStrategy", "cdkConnectedOverlayOffsetX", "cdkConnectedOverlayOffsetY", "cdkConnectedOverlayWidth", "cdkConnectedOverlayHeight", "cdkConnectedOverlayMinWidth", "cdkConnectedOverlayMinHeight", "cdkConnectedOverlayBackdropClass", "cdkConnectedOverlayPanelClass", "cdkConnectedOverlayViewportMargin", "cdkConnectedOverlayScrollStrategy", "cdkConnectedOverlayOpen", "cdkConnectedOverlayDisableClose", "cdkConnectedOverlayTransformOriginOn", "cdkConnectedOverlayHasBackdrop", "cdkConnectedOverlayLockPosition", "cdkConnectedOverlayFlexibleDimensions", "cdkConnectedOverlayGrowAfterOpen", "cdkConnectedOverlayPush", "cdkConnectedOverlayDisposeOnNavigation"], outputs: ["backdropClick", "positionChange", "attach", "detach", "overlayKeydown", "overlayOutsideClick"], exportAs: ["cdkConnectedOverlay"] }, { kind: "directive", type: i4.Dir, selector: "[dir]", inputs: ["dir"], outputs: ["dirChange"], exportAs: ["dir"] }, { kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: NzIconModule }, { kind: "directive", type: i2.NzIconDirective, selector: "nz-icon,[nz-icon]", inputs: ["nzSpin", "nzRotate", "nzType", "nzTheme", "nzTwotoneColor", "nzIconfont"], exportAs: ["nzIcon"] }, { kind: "ngmodule", type: NzEmptyModule }, { kind: "component", type: i8.NzEmbedEmptyComponent, selector: "nz-embed-empty", inputs: ["nzComponentName", "specificContent"], exportAs: ["nzEmbedEmpty"] }, { kind: "component", type: NzFormItemFeedbackIconComponent, selector: "nz-form-item-feedback-icon", inputs: ["status"], exportAs: ["nzFormFeedbackIcon"] }, { kind: "ngmodule", type: NzOverlayModule }, { kind: "directive", type: i9.NzConnectedOverlayDirective, selector: "[cdkConnectedOverlay][nzConnectedOverlay]", inputs: ["nzArrowPointAtCenter"], exportAs: ["nzConnectedOverlay"] }, { kind: "directive", type: NzNoAnimationDirective, selector: "[nzNoAnimation]", inputs: ["nzNoAnimation"], exportAs: ["nzNoAnimation"] }, { kind: "component", type: NzSelectClearComponent, selector: "nz-select-clear", inputs: ["clearIcon"], outputs: ["clear"] }, { kind: "component", type: NzSelectItemComponent, selector: "nz-select-item", inputs: ["disabled", "label", "deletable", "removeIcon", "contentTemplateOutletContext", "contentTemplateOutlet"], outputs: ["delete"] }, { kind: "component", type: NzSelectPlaceholderComponent, selector: "nz-select-placeholder", inputs: ["placeholder"] }, { kind: "component", type: NzSelectSearchComponent, selector: "nz-select-search", inputs: ["nzId", "disabled", "mirrorSync", "showInput", "focusTrigger", "value", "autofocus"], outputs: ["valueChange", "isComposingChange"] }, { kind: "component", type: NzCascaderOptionComponent, selector: "[nz-cascader-option]", inputs: ["optionTemplate", "node", "activated", "highlightText", "nzLabelProperty", "columnIndex", "expandIcon", "dir", "checkable"], outputs: ["check"], exportAs: ["nzCascaderOption"] }], animations: [slideMotion], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
  1681. };
  1682. })();
  1683. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderComponent, decorators: [{
  1684. type: Component,
  1685. args: [{
  1686. changeDetection: ChangeDetectionStrategy.OnPush,
  1687. encapsulation: ViewEncapsulation.None,
  1688. selector: 'nz-cascader, [nz-cascader]',
  1689. exportAs: 'nzCascader',
  1690. preserveWhitespaces: false,
  1691. template: `
  1692. @if (nzShowInput) {
  1693. <div #selectContainer class="ant-select-selector">
  1694. @if (nzMultiple) {
  1695. @for (node of selectedNodes | slice: 0 : nzMaxTagCount; track node) {
  1696. <nz-select-item
  1697. [deletable]="true"
  1698. [disabled]="nzDisabled"
  1699. [label]="nzDisplayWith(getAncestorOptionList(node))"
  1700. (delete)="removeSelected(node)"
  1701. ></nz-select-item>
  1702. }
  1703. @if (selectedNodes.length > nzMaxTagCount) {
  1704. <nz-select-item
  1705. [deletable]="false"
  1706. [disabled]="false"
  1707. [label]="'+ ' + (selectedNodes.length - nzMaxTagCount) + ' ...'"
  1708. ></nz-select-item>
  1709. }
  1710. }
  1711. <nz-select-search
  1712. [showInput]="!!nzShowSearch"
  1713. (isComposingChange)="isComposingChange($event)"
  1714. [value]="inputValue"
  1715. (valueChange)="inputValue = $event"
  1716. [mirrorSync]="nzMultiple"
  1717. [disabled]="nzDisabled"
  1718. [autofocus]="nzAutoFocus"
  1719. [focusTrigger]="menuVisible"
  1720. ></nz-select-search>
  1721. @if (showPlaceholder) {
  1722. <nz-select-placeholder
  1723. [placeholder]="nzPlaceHolder || locale?.placeholder!"
  1724. [style.display]="inputValue || isComposing ? 'none' : 'block'"
  1725. ></nz-select-placeholder>
  1726. }
  1727. @if (showLabelRender) {
  1728. <nz-select-item
  1729. [deletable]="false"
  1730. [disabled]="nzDisabled"
  1731. [label]="labelRenderText"
  1732. [contentTemplateOutlet]="isLabelRenderTemplate ? nzLabelRender : null"
  1733. [contentTemplateOutletContext]="labelRenderContext"
  1734. ></nz-select-item>
  1735. }
  1736. </div>
  1737. @if (nzShowArrow) {
  1738. <span class="ant-select-arrow" [class.ant-select-arrow-loading]="isLoading">
  1739. @if (!isLoading) {
  1740. <nz-icon [nzType]="$any(nzSuffixIcon)" [class.ant-cascader-picker-arrow-expand]="menuVisible" />
  1741. } @else {
  1742. <nz-icon nzType="loading" />
  1743. }
  1744. @if (hasFeedback && !!status) {
  1745. <nz-form-item-feedback-icon [status]="status" />
  1746. }
  1747. </span>
  1748. }
  1749. @if (clearIconVisible) {
  1750. <nz-select-clear (clear)="clearSelection($event)"></nz-select-clear>
  1751. }
  1752. }
  1753. <ng-content></ng-content>
  1754. <ng-template
  1755. cdkConnectedOverlay
  1756. nzConnectedOverlay
  1757. [cdkConnectedOverlayHasBackdrop]="nzBackdrop"
  1758. [cdkConnectedOverlayOrigin]="overlayOrigin"
  1759. [cdkConnectedOverlayPositions]="positions"
  1760. [cdkConnectedOverlayTransformOriginOn]="'.ant-cascader-dropdown'"
  1761. [cdkConnectedOverlayOpen]="menuVisible"
  1762. (overlayOutsideClick)="onClickOutside($event)"
  1763. (detach)="closeMenu()"
  1764. (positionChange)="onPositionChange($event)"
  1765. >
  1766. <div
  1767. class="ant-select-dropdown ant-cascader-dropdown"
  1768. [class.ant-select-dropdown-placement-bottomLeft]="dropdownPosition === 'bottomLeft'"
  1769. [class.ant-select-dropdown-placement-bottomRight]="dropdownPosition === 'bottomRight'"
  1770. [class.ant-select-dropdown-placement-topLeft]="dropdownPosition === 'topLeft'"
  1771. [class.ant-select-dropdown-placement-topRight]="dropdownPosition === 'topRight'"
  1772. [class.ant-cascader-dropdown-rtl]="dir === 'rtl'"
  1773. [@slideMotion]="'enter'"
  1774. [@.disabled]="!!noAnimation?.nzNoAnimation"
  1775. [nzNoAnimation]="noAnimation?.nzNoAnimation"
  1776. (mouseenter)="onTriggerMouseEnter()"
  1777. (mouseleave)="onTriggerMouseLeave($event)"
  1778. >
  1779. <div
  1780. #menu
  1781. class="ant-cascader-menus"
  1782. [class.ant-cascader-rtl]="dir === 'rtl'"
  1783. [class.ant-cascader-menus-hidden]="!menuVisible"
  1784. [class.ant-cascader-menu-empty]="shouldShowEmpty"
  1785. [class]="nzMenuClassName"
  1786. [style]="nzMenuStyle"
  1787. >
  1788. @if (shouldShowEmpty) {
  1789. <ul class="ant-cascader-menu" [style.width]="dropdownWidthStyle" [style.height]="dropdownHeightStyle">
  1790. <li class="ant-cascader-menu-item ant-cascader-menu-item-disabled">
  1791. <nz-embed-empty
  1792. class="ant-cascader-menu-item-content"
  1793. [nzComponentName]="'cascader'"
  1794. [specificContent]="nzNotFoundContent"
  1795. />
  1796. </li>
  1797. </ul>
  1798. } @else {
  1799. @for (options of cascaderService.columns; track options; let i = $index) {
  1800. <ul
  1801. class="ant-cascader-menu"
  1802. role="menuitemcheckbox"
  1803. [class]="nzColumnClassName"
  1804. [style.height]="dropdownHeightStyle"
  1805. >
  1806. @for (option of options; track option) {
  1807. <li
  1808. nz-cascader-option
  1809. [expandIcon]="nzExpandIcon"
  1810. [columnIndex]="i"
  1811. [nzLabelProperty]="nzLabelProperty"
  1812. [optionTemplate]="nzOptionRender"
  1813. [activated]="isOptionActivated(option, i)"
  1814. [highlightText]="inSearchingMode ? inputValue : ''"
  1815. [node]="option"
  1816. [dir]="dir"
  1817. [checkable]="nzMultiple"
  1818. (mouseenter)="onOptionMouseEnter(option, i, $event)"
  1819. (mouseleave)="onOptionMouseLeave(option, i, $event)"
  1820. (click)="onOptionClick(option, i, $event)"
  1821. (check)="onOptionCheck(option, i)"
  1822. ></li>
  1823. }
  1824. </ul>
  1825. }
  1826. }
  1827. </div>
  1828. </div>
  1829. </ng-template>
  1830. `,
  1831. animations: [slideMotion],
  1832. providers: [
  1833. {
  1834. provide: NG_VALUE_ACCESSOR,
  1835. useExisting: forwardRef(() => NzCascaderComponent),
  1836. multi: true
  1837. },
  1838. { provide: NZ_SPACE_COMPACT_ITEM_TYPE, useValue: 'select' },
  1839. NzCascaderService,
  1840. NzDestroyService,
  1841. NzCascaderTreeService
  1842. ],
  1843. host: {
  1844. '[attr.tabIndex]': '"0"',
  1845. '[class.ant-select-in-form-item]': '!!nzFormStatusService',
  1846. '[class.ant-select-lg]': 'finalSize() === "large"',
  1847. '[class.ant-select-sm]': 'finalSize() === "small"',
  1848. '[class.ant-select-allow-clear]': 'nzAllowClear',
  1849. '[class.ant-select-show-arrow]': 'nzShowArrow',
  1850. '[class.ant-select-show-search]': '!!nzShowSearch',
  1851. '[class.ant-select-disabled]': 'nzDisabled',
  1852. '[class.ant-select-open]': 'menuVisible',
  1853. '[class.ant-select-focused]': 'isFocused',
  1854. '[class.ant-select-multiple]': 'nzMultiple',
  1855. '[class.ant-select-single]': '!nzMultiple',
  1856. '[class.ant-select-rtl]': `dir === 'rtl'`
  1857. },
  1858. hostDirectives: [NzSpaceCompactItemDirective],
  1859. imports: [
  1860. SlicePipe,
  1861. OverlayModule,
  1862. FormsModule,
  1863. NzIconModule,
  1864. NzEmptyModule,
  1865. NzFormItemFeedbackIconComponent,
  1866. NzOverlayModule,
  1867. NzNoAnimationDirective,
  1868. NzSelectClearComponent,
  1869. NzSelectItemComponent,
  1870. NzSelectPlaceholderComponent,
  1871. NzSelectSearchComponent,
  1872. NzCascaderOptionComponent
  1873. ]
  1874. }]
  1875. }], ctorParameters: () => [{ type: NzCascaderTreeService }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i2$1.NzI18nService }, { type: i3$1.NzDestroyService }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i4.Directionality }], propDecorators: { selectContainer: [{
  1876. type: ViewChild,
  1877. args: ['selectContainer', { static: false }]
  1878. }], input: [{
  1879. type: ViewChild,
  1880. args: [NzSelectSearchComponent]
  1881. }], menu: [{
  1882. type: ViewChild,
  1883. args: ['menu', { static: false }]
  1884. }], overlay: [{
  1885. type: ViewChild,
  1886. args: [CdkConnectedOverlay, { static: false }]
  1887. }], cascaderItems: [{
  1888. type: ViewChildren,
  1889. args: [NzCascaderOptionComponent]
  1890. }], nzOptionRender: [{
  1891. type: Input
  1892. }], nzShowInput: [{
  1893. type: Input,
  1894. args: [{ transform: booleanAttribute }]
  1895. }], nzShowArrow: [{
  1896. type: Input,
  1897. args: [{ transform: booleanAttribute }]
  1898. }], nzAllowClear: [{
  1899. type: Input,
  1900. args: [{ transform: booleanAttribute }]
  1901. }], nzAutoFocus: [{
  1902. type: Input,
  1903. args: [{ transform: booleanAttribute }]
  1904. }], nzChangeOnSelect: [{
  1905. type: Input,
  1906. args: [{ transform: booleanAttribute }]
  1907. }], nzDisabled: [{
  1908. type: Input,
  1909. args: [{ transform: booleanAttribute }]
  1910. }], nzColumnClassName: [{
  1911. type: Input
  1912. }], nzExpandTrigger: [{
  1913. type: Input
  1914. }], nzValueProperty: [{
  1915. type: Input
  1916. }], nzLabelProperty: [{
  1917. type: Input
  1918. }], nzLabelRender: [{
  1919. type: Input
  1920. }], nzNotFoundContent: [{
  1921. type: Input
  1922. }], nzSize: [{
  1923. type: Input
  1924. }], nzBackdrop: [{
  1925. type: Input
  1926. }], nzShowSearch: [{
  1927. type: Input
  1928. }], nzPlaceHolder: [{
  1929. type: Input
  1930. }], nzMenuClassName: [{
  1931. type: Input
  1932. }], nzMenuStyle: [{
  1933. type: Input
  1934. }], nzMouseLeaveDelay: [{
  1935. type: Input,
  1936. args: [{ transform: numberAttribute }]
  1937. }], nzMouseEnterDelay: [{
  1938. type: Input,
  1939. args: [{ transform: numberAttribute }]
  1940. }], nzStatus: [{
  1941. type: Input
  1942. }], nzMultiple: [{
  1943. type: Input,
  1944. args: [{ transform: booleanAttribute }]
  1945. }], nzMaxTagCount: [{
  1946. type: Input
  1947. }], nzPlacement: [{
  1948. type: Input
  1949. }], nzTriggerAction: [{
  1950. type: Input
  1951. }], nzChangeOn: [{
  1952. type: Input
  1953. }], nzLoadData: [{
  1954. type: Input
  1955. }], nzDisplayWith: [{
  1956. type: Input
  1957. }], nzSuffixIcon: [{
  1958. type: Input
  1959. }], nzExpandIcon: [{
  1960. type: Input
  1961. }], nzOptions: [{
  1962. type: Input
  1963. }], nzVisibleChange: [{
  1964. type: Output
  1965. }], nzSelectionChange: [{
  1966. type: Output
  1967. }], nzRemoved: [{
  1968. type: Output
  1969. }], nzClear: [{
  1970. type: Output
  1971. }], onTriggerClick: [{
  1972. type: HostListener,
  1973. args: ['click']
  1974. }], onTriggerMouseEnter: [{
  1975. type: HostListener,
  1976. args: ['mouseenter']
  1977. }], onTriggerMouseLeave: [{
  1978. type: HostListener,
  1979. args: ['mouseleave', ['$event']]
  1980. }] } });
  1981. /**
  1982. * Use of this source code is governed by an MIT-style license that can be
  1983. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  1984. */
  1985. class NzCascaderModule {
  1986. static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
  1987. static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderModule, imports: [NzCascaderComponent], exports: [NzCascaderComponent] });
  1988. static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderModule, imports: [NzCascaderComponent] });
  1989. }
  1990. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.2", ngImport: i0, type: NzCascaderModule, decorators: [{
  1991. type: NgModule,
  1992. args: [{
  1993. imports: [NzCascaderComponent],
  1994. exports: [NzCascaderComponent]
  1995. }]
  1996. }] });
  1997. /**
  1998. * Use of this source code is governed by an MIT-style license that can be
  1999. * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
  2000. */
  2001. /**
  2002. * Generated bundle index. Do not edit.
  2003. */
  2004. export { NzCascaderComponent, NzCascaderModule, NzCascaderOptionComponent, NzCascaderService, isChildNode, isParentNode, isShowSearchObject };
  2005. //# sourceMappingURL=ng-zorro-antd-cascader.mjs.map