ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
603 lines • 52.1 kB
JavaScript
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
import { Injectable } from '@angular/core';
import { BehaviorSubject, Subject } from 'rxjs';
import { arraysEqual } from '../core/util/array';
import { isShowSearchObject } from './nz-cascader-definitions';
import { isChildOption, isParentOption } from './nz-cascader-utils';
/**
* All data is stored and parsed in NzCascaderService.
*/
export class NzCascaderService {
constructor() {
/**
* Activated options in each column.
*/
this.activatedOptions = [];
/**
* An array to store cascader items arranged in different layers.
*/
this.columns = [[]];
/**
* If user has entered searching mode.
*/
this.inSearchingMode = false;
/**
* Selected options would be output to user.
*/
this.selectedOptions = [];
this.values = []; // tslint:disable-line:no-any
// tslint:disable-line:no-any
this.$loading = new BehaviorSubject(false);
/**
* Emit an event to notify cascader it needs to redraw because activated or
* selected options are changed.
*/
this.$redraw = new Subject();
/**
* Emit an event when an option gets selected.
* Emit true if a leaf options is selected.
*/
this.$optionSelected = new Subject();
/**
* Emit an event to notify cascader it needs to quit searching mode.
* Only emit when user do select a searching option.
*/
this.$quitSearching = new Subject();
/**
* To hold columns before entering searching mode.
*/
this.columnsSnapshot = [[]];
/**
* To hold activated options before entering searching mode.
*/
this.activatedOptionsSnapshot = [];
}
/**
* Return cascader options in the first layer.
* @return {?}
*/
get nzOptions() {
return this.columns[0];
}
/**
* @return {?}
*/
ngOnDestroy() {
this.$redraw.complete();
this.$quitSearching.complete();
this.$optionSelected.complete();
this.$loading.complete();
}
/**
* Make sure that value matches what is displayed in the dropdown.
* @param {?=} first
* @return {?}
*/
syncOptions(first = false) {
/** @type {?} */
const values = this.values;
/** @type {?} */
const hasValue = values && values.length;
/** @type {?} */
const lastColumnIndex = values.length - 1;
/** @type {?} */
const initColumnWithIndex = (/**
* @param {?} columnIndex
* @return {?}
*/
(columnIndex) => {
/** @type {?} */
const activatedOptionSetter = (/**
* @return {?}
*/
() => {
/** @type {?} */
const currentValue = values[columnIndex];
if (!currentValue) {
this.$redraw.next();
return;
}
/** @type {?} */
const option = this.findOptionWithValue(columnIndex, values[columnIndex]) ||
(typeof currentValue === 'object'
? currentValue
: {
[`${this.cascaderComponent.nzValueProperty}`]: currentValue,
[`${this.cascaderComponent.nzLabelProperty}`]: currentValue
});
this.setOptionActivated(option, columnIndex, false, false);
if (columnIndex < lastColumnIndex) {
initColumnWithIndex(columnIndex + 1);
}
else {
this.dropBehindColumns(columnIndex);
this.selectedOptions = [...this.activatedOptions];
this.$redraw.next();
}
});
if (this.isLoaded(columnIndex) || !this.cascaderComponent.nzLoadData) {
activatedOptionSetter();
}
else {
/** @type {?} */
const option = this.activatedOptions[columnIndex - 1] || {};
this.loadChildren(option, columnIndex - 1, activatedOptionSetter);
}
});
this.activatedOptions = [];
this.selectedOptions = [];
if (first && this.cascaderComponent.nzLoadData && !hasValue) {
return;
}
else {
initColumnWithIndex(0);
}
}
/**
* Bind cascader component so this service could use inputs.
* @param {?} cascaderComponent
* @return {?}
*/
withComponent(cascaderComponent) {
this.cascaderComponent = cascaderComponent;
}
/**
* Reset all options. Rebuild searching options if in searching mode.
* @param {?} options
* @return {?}
*/
withOptions(options) {
this.columnsSnapshot = this.columns = options && options.length ? [options] : [];
if (this.inSearchingMode) {
this.prepareSearchOptions(this.cascaderComponent.inputValue);
}
else if (this.columns.length) {
this.syncOptions();
}
}
/**
* Try to set a option as activated.
* @param {?} option Cascader option
* @param {?} columnIndex Of which column this option is in
* @param {?=} select Select
* @param {?=} loadingChildren Try to load children asynchronously.
* @return {?}
*/
setOptionActivated(option, columnIndex, select = false, loadingChildren = true) {
if (option.disabled) {
return;
}
this.activatedOptions[columnIndex] = option;
this.trackAncestorActivatedOptions(columnIndex);
this.dropBehindActivatedOptions(columnIndex);
/** @type {?} */
const isParent = isParentOption(option);
if (isParent) {
// Parent option that has children.
this.setColumnData((/** @type {?} */ (option.children)), columnIndex + 1, option);
}
else if (!option.isLeaf && loadingChildren) {
// Parent option that should try to load children asynchronously.
this.loadChildren(option, columnIndex);
}
else if (option.isLeaf) {
// Leaf option.
this.dropBehindColumns(columnIndex);
}
// Actually perform selection to make an options not only activated but also selected.
if (select) {
this.setOptionSelected(option, columnIndex);
}
this.$redraw.next();
}
/**
* Set a searching option as activated, finishing up things.
* @param {?} option
* @return {?}
*/
setSearchOptionSelected(option) {
this.activatedOptions = [option];
this.selectedOptions = [...option.path];
this.prepareEmitValue();
this.$redraw.next();
this.$optionSelected.next({ option, index: 0 });
setTimeout((/**
* @return {?}
*/
() => {
// Reset data and tell UI only to remove input and reset dropdown width style.
this.$quitSearching.next();
this.$redraw.next();
this.inSearchingMode = false;
this.columns = [...this.columnsSnapshot];
this.activatedOptions = [...this.selectedOptions];
}), 200);
}
/**
* Filter cascader options to reset `columns`.
* @param {?} searchValue The string user wants to search.
* @return {?}
*/
prepareSearchOptions(searchValue) {
/** @type {?} */
const results = [];
// Search results only have one layer.
/** @type {?} */
const path = [];
/** @type {?} */
const defaultFilter = (/**
* @param {?} i
* @param {?} p
* @return {?}
*/
(i, p) => {
return p.some((/**
* @param {?} o
* @return {?}
*/
o => {
/** @type {?} */
const label = this.getOptionLabel(o);
return !!label && label.indexOf(i) !== -1;
}));
});
/** @type {?} */
const showSearch = this.cascaderComponent.nzShowSearch;
/** @type {?} */
const filter = isShowSearchObject(showSearch) && showSearch.filter ? showSearch.filter : defaultFilter;
/** @type {?} */
const sorter = isShowSearchObject(showSearch) && showSearch.sorter ? showSearch.sorter : null;
/** @type {?} */
const loopChild = (/**
* @param {?} node
* @param {?=} forceDisabled
* @return {?}
*/
(node, forceDisabled = false) => {
path.push(node);
/** @type {?} */
const cPath = Array.from(path);
if (filter(searchValue, cPath)) {
/** @type {?} */
const disabled = forceDisabled || node.disabled;
/** @type {?} */
const option = {
disabled,
isLeaf: true,
path: cPath,
[this.cascaderComponent.nzLabelProperty]: cPath.map((/**
* @param {?} p
* @return {?}
*/
p => this.getOptionLabel(p))).join(' / ')
};
results.push(option);
}
path.pop();
});
/** @type {?} */
const loopParent = (/**
* @param {?} node
* @param {?=} forceDisabled
* @return {?}
*/
(node, forceDisabled = false) => {
/** @type {?} */
const disabled = forceDisabled || node.disabled;
path.push(node);
(/** @type {?} */ (node.children)).forEach((/**
* @param {?} sNode
* @return {?}
*/
sNode => {
if (!sNode.parent) {
sNode.parent = node;
}
if (!sNode.isLeaf) {
loopParent(sNode, disabled);
}
if (sNode.isLeaf || !sNode.children || !sNode.children.length) {
loopChild(sNode, disabled);
}
}));
path.pop();
});
if (!this.columnsSnapshot.length) {
this.columns = [[]];
return;
}
this.columnsSnapshot[0].forEach((/**
* @param {?} o
* @return {?}
*/
o => (isChildOption(o) ? loopChild(o) : loopParent(o))));
if (sorter) {
results.sort((/**
* @param {?} a
* @param {?} b
* @return {?}
*/
(a, b) => sorter(a.path, b.path, searchValue)));
}
this.columns = [results];
}
/**
* Toggle searching mode by UI. It deals with things not directly related to UI.
* @param {?} toSearching If this cascader is entering searching mode
* @return {?}
*/
toggleSearchingMode(toSearching) {
this.inSearchingMode = toSearching;
if (toSearching) {
this.activatedOptionsSnapshot = [...this.activatedOptions];
this.activatedOptions = [];
this.selectedOptions = [];
this.$redraw.next();
}
else {
// User quit searching mode without selecting an option.
this.activatedOptions = [...this.activatedOptionsSnapshot];
this.selectedOptions = [...this.activatedOptions];
this.columns = [...this.columnsSnapshot];
this.syncOptions();
this.$redraw.next();
}
}
/**
* @param {?} option
* @param {?} index
* @return {?}
*/
setOptionSelected(option, index) {
/** @type {?} */
const changeOn = this.cascaderComponent.nzChangeOn;
/** @type {?} */
const shouldPerformSelection = (/**
* @param {?} o
* @param {?} i
* @return {?}
*/
(o, i) => {
return typeof changeOn === 'function' ? changeOn(o, i) : false;
});
if (option.isLeaf || this.cascaderComponent.nzChangeOnSelect || shouldPerformSelection(option, index)) {
this.selectedOptions = [...this.activatedOptions];
this.prepareEmitValue();
this.$redraw.next();
this.$optionSelected.next({ option, index });
}
}
/**
* Clear selected options.
* @return {?}
*/
clear() {
this.values = [];
this.selectedOptions = [];
this.activatedOptions = [];
this.dropBehindColumns(0);
this.prepareEmitValue();
this.$redraw.next();
this.$optionSelected.next(null);
}
/**
* @param {?} o
* @return {?}
*/
getOptionLabel(o) {
return (/** @type {?} */ (o[this.cascaderComponent.nzLabelProperty || 'label']));
}
// tslint:disable-next-line:no-any
/**
* @param {?} o
* @return {?}
*/
getOptionValue(o) {
return o[this.cascaderComponent.nzValueProperty || 'value'];
}
/**
* Try to insert options into a column.
* @private
* @param {?} options Options to insert
* @param {?} columnIndex Position
* @param {?} parent
* @return {?}
*/
setColumnData(options, columnIndex, parent) {
/** @type {?} */
const existingOptions = this.columns[columnIndex];
if (!arraysEqual(existingOptions, options)) {
options.forEach((/**
* @param {?} o
* @return {?}
*/
o => (o.parent = parent)));
this.columns[columnIndex] = options;
this.dropBehindColumns(columnIndex);
}
}
/**
* Set all ancestor options as activated.
* @private
* @param {?} startIndex
* @return {?}
*/
trackAncestorActivatedOptions(startIndex) {
for (let i = startIndex - 1; i >= 0; i--) {
if (!this.activatedOptions[i]) {
this.activatedOptions[i] = (/** @type {?} */ (this.activatedOptions[i + 1].parent));
}
}
}
/**
* @private
* @param {?} lastReserveIndex
* @return {?}
*/
dropBehindActivatedOptions(lastReserveIndex) {
this.activatedOptions = this.activatedOptions.splice(0, lastReserveIndex + 1);
}
/**
* @private
* @param {?} lastReserveIndex
* @return {?}
*/
dropBehindColumns(lastReserveIndex) {
if (lastReserveIndex < this.columns.length - 1) {
this.columns = this.columns.slice(0, lastReserveIndex + 1);
}
}
/**
* Load children of an option asynchronously.
* @param {?} option
* @param {?} columnIndex
* @param {?=} success
* @param {?=} failure
* @return {?}
*/
loadChildren(option, // tslint:disable-line:no-any
columnIndex, success, failure) {
/** @type {?} */
const loadFn = this.cascaderComponent.nzLoadData;
if (loadFn) {
// If there isn't any option in columns.
this.$loading.next(columnIndex < 0);
if (typeof option === 'object') {
option.loading = true;
}
loadFn(option, columnIndex).then((/**
* @return {?}
*/
() => {
option.loading = false;
if (option.children) {
this.setColumnData(option.children, columnIndex + 1, option);
}
if (success) {
success();
}
this.$loading.next(false);
this.$redraw.next();
}), (/**
* @return {?}
*/
() => {
option.loading = false;
option.isLeaf = true;
if (failure) {
failure();
}
this.$redraw.next();
}));
}
}
/**
* @private
* @param {?} index
* @return {?}
*/
isLoaded(index) {
return this.columns[index] && this.columns[index].length > 0;
}
/**
* Find a option that has a given value in a given column.
* @private
* @param {?} columnIndex
* @param {?} value
* @return {?}
*/
findOptionWithValue(columnIndex, value // tslint:disable-line:no-any
) {
/** @type {?} */
const targetColumn = this.columns[columnIndex];
if (targetColumn) {
/** @type {?} */
const v = typeof value === 'object' ? this.getOptionValue(value) : value;
return (/** @type {?} */ (targetColumn.find((/**
* @param {?} o
* @return {?}
*/
o => v === this.getOptionValue(o)))));
}
return null;
}
/**
* @private
* @return {?}
*/
prepareEmitValue() {
this.values = this.selectedOptions.map((/**
* @param {?} o
* @return {?}
*/
o => this.getOptionValue(o)));
}
}
NzCascaderService.decorators = [
{ type: Injectable }
];
if (false) {
/**
* Activated options in each column.
* @type {?}
*/
NzCascaderService.prototype.activatedOptions;
/**
* An array to store cascader items arranged in different layers.
* @type {?}
*/
NzCascaderService.prototype.columns;
/**
* If user has entered searching mode.
* @type {?}
*/
NzCascaderService.prototype.inSearchingMode;
/**
* Selected options would be output to user.
* @type {?}
*/
NzCascaderService.prototype.selectedOptions;
/** @type {?} */
NzCascaderService.prototype.values;
/** @type {?} */
NzCascaderService.prototype.$loading;
/**
* Emit an event to notify cascader it needs to redraw because activated or
* selected options are changed.
* @type {?}
*/
NzCascaderService.prototype.$redraw;
/**
* Emit an event when an option gets selected.
* Emit true if a leaf options is selected.
* @type {?}
*/
NzCascaderService.prototype.$optionSelected;
/**
* Emit an event to notify cascader it needs to quit searching mode.
* Only emit when user do select a searching option.
* @type {?}
*/
NzCascaderService.prototype.$quitSearching;
/**
* To hold columns before entering searching mode.
* @type {?}
* @private
*/
NzCascaderService.prototype.columnsSnapshot;
/**
* To hold activated options before entering searching mode.
* @type {?}
* @private
*/
NzCascaderService.prototype.activatedOptionsSnapshot;
/**
* @type {?}
* @private
*/
NzCascaderService.prototype.cascaderComponent;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnotY2FzY2FkZXIuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL25nLXpvcnJvLWFudGQteWovIiwic291cmNlcyI6WyJjYXNjYWRlci9uei1jYXNjYWRlci5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFhLE1BQU0sZUFBZSxDQUFDO0FBQ3RELE9BQU8sRUFBRSxlQUFlLEVBQUUsT0FBTyxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBQ2hELE9BQU8sRUFBRSxXQUFXLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVqRCxPQUFPLEVBQ0wsa0JBQWtCLEVBS25CLE1BQU0sMkJBQTJCLENBQUM7QUFDbkMsT0FBTyxFQUFFLGFBQWEsRUFBRSxjQUFjLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQzs7OztBQU1wRSxNQUFNLE9BQU8saUJBQWlCO0lBRDlCOzs7O1FBR0UscUJBQWdCLEdBQXFCLEVBQUUsQ0FBQzs7OztRQUd4QyxZQUFPLEdBQXVCLENBQUMsRUFBRSxDQUFDLENBQUM7Ozs7UUFHbkMsb0JBQWUsR0FBRyxLQUFLLENBQUM7Ozs7UUFHeEIsb0JBQWUsR0FBcUIsRUFBRSxDQUFDO1FBRXZDLFdBQU0sR0FBVSxFQUFFLENBQUMsQ0FBQyw2QkFBNkI7O1FBRXhDLGFBQVEsR0FBRyxJQUFJLGVBQWUsQ0FBVSxLQUFLLENBQUMsQ0FBQzs7Ozs7UUFNL0MsWUFBTyxHQ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