{"version":3,"file":"sort.js","sources":["../../packages/material/sort/sort-errors.js","../../packages/material/sort/sort.js","../../packages/material/sort/sort-header-intl.js","../../packages/material/sort/sort-header.js","../../packages/material/sort/sort-module.js","../../packages/material/sort/index.js"],"sourcesContent":["/**\n * \\@docs-private\n * @param {?} id\n * @return {?}\n */\nexport function getSortDuplicateSortableIdError(id) {\n return Error(`Cannot have two MatSortables with the same id (${id}).`);\n}\n/**\n * \\@docs-private\n * @return {?}\n */\nexport function getSortHeaderNotContainedWithinSortError() {\n return Error(`MatSortHeader must be placed within a parent element with the MatSort directive.`);\n}\n/**\n * \\@docs-private\n * @return {?}\n */\nexport function getSortHeaderMissingIdError() {\n return Error(`MatSortHeader must be provided with a unique id.`);\n}\n/**\n * \\@docs-private\n * @param {?} direction\n * @return {?}\n */\nexport function getSortInvalidDirectionError(direction) {\n return Error(`${direction} is not a valid sort direction ('asc' or 'desc').`);\n}\n//# sourceMappingURL=sort-errors.js.map","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport { Directive, EventEmitter, Input, isDevMode, Output } from '@angular/core';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { getSortInvalidDirectionError, getSortDuplicateSortableIdError, getSortHeaderMissingIdError } from './sort-errors';\n/**\n * Container for MatSortables to manage the sort state and provide default sort parameters.\n */\nexport class MatSort {\n constructor() {\n /**\n * Collection of all registered sortables that this directive manages.\n */\n this.sortables = new Map();\n /**\n * The direction to set when an MatSortable is initially sorted.\n * May be overriden by the MatSortable's sort start.\n */\n this.start = 'asc';\n this._direction = '';\n /**\n * Event emitted when the user changes either the active sort or sort direction.\n */\n this.sortChange = new EventEmitter();\n }\n /**\n * The sort direction of the currently active MatSortable.\n * @param {?} direction\n * @return {?}\n */\n set direction(direction) {\n if (isDevMode() && direction && direction !== 'asc' && direction !== 'desc') {\n throw getSortInvalidDirectionError(direction);\n }\n this._direction = direction;\n }\n /**\n * @return {?}\n */\n get direction() { return this._direction; }\n /**\n * Whether to disable the user from clearing the sort by finishing the sort direction cycle.\n * May be overriden by the MatSortable's disable clear input.\n * @return {?}\n */\n get disableClear() { return this._disableClear; }\n /**\n * @param {?} v\n * @return {?}\n */\n set disableClear(v) { this._disableClear = coerceBooleanProperty(v); }\n /**\n * Register function to be used by the contained MatSortables. Adds the MatSortable to the\n * collection of MatSortables.\n * @param {?} sortable\n * @return {?}\n */\n register(sortable) {\n if (!sortable.id) {\n throw getSortHeaderMissingIdError();\n }\n if (this.sortables.has(sortable.id)) {\n throw getSortDuplicateSortableIdError(sortable.id);\n }\n this.sortables.set(sortable.id, sortable);\n }\n /**\n * Unregister function to be used by the contained MatSortables. Removes the MatSortable from the\n * collection of contained MatSortables.\n * @param {?} sortable\n * @return {?}\n */\n deregister(sortable) {\n this.sortables.delete(sortable.id);\n }\n /**\n * Sets the active sort id and determines the new sort direction.\n * @param {?} sortable\n * @return {?}\n */\n sort(sortable) {\n if (this.active != sortable.id) {\n this.active = sortable.id;\n this.direction = sortable.start ? sortable.start : this.start;\n }\n else {\n this.direction = this.getNextSortDirection(sortable);\n }\n this.sortChange.next({ active: this.active, direction: this.direction });\n }\n /**\n * Returns the next sort direction of the active sortable, checking for potential overrides.\n * @param {?} sortable\n * @return {?}\n */\n getNextSortDirection(sortable) {\n if (!sortable) {\n return '';\n }\n // Get the sort direction cycle with the potential sortable overrides.\n const /** @type {?} */ disableClear = sortable.disableClear != null ? sortable.disableClear : this.disableClear;\n let /** @type {?} */ sortDirectionCycle = getSortDirectionCycle(sortable.start || this.start, disableClear);\n // Get and return the next direction in the cycle\n let /** @type {?} */ nextDirectionIndex = sortDirectionCycle.indexOf(this.direction) + 1;\n if (nextDirectionIndex >= sortDirectionCycle.length) {\n nextDirectionIndex = 0;\n }\n return sortDirectionCycle[nextDirectionIndex];\n }\n}\nMatSort.decorators = [\n { type: Directive, args: [{\n selector: '[matSort]',\n },] },\n];\n/**\n * @nocollapse\n */\nMatSort.ctorParameters = () => [];\nMatSort.propDecorators = {\n 'active': [{ type: Input, args: ['matSortActive',] },],\n 'start': [{ type: Input, args: ['matSortStart',] },],\n 'direction': [{ type: Input, args: ['matSortDirection',] },],\n 'disableClear': [{ type: Input, args: ['matSortDisableClear',] },],\n 'sortChange': [{ type: Output, args: ['matSortChange',] },],\n};\nfunction MatSort_tsickle_Closure_declarations() {\n /** @type {?} */\n MatSort.decorators;\n /**\n * @nocollapse\n * @type {?}\n */\n MatSort.ctorParameters;\n /** @type {?} */\n MatSort.propDecorators;\n /**\n * Collection of all registered sortables that this directive manages.\n * @type {?}\n */\n MatSort.prototype.sortables;\n /**\n * The id of the most recently sorted MatSortable.\n * @type {?}\n */\n MatSort.prototype.active;\n /**\n * The direction to set when an MatSortable is initially sorted.\n * May be overriden by the MatSortable's sort start.\n * @type {?}\n */\n MatSort.prototype.start;\n /** @type {?} */\n MatSort.prototype._direction;\n /** @type {?} */\n MatSort.prototype._disableClear;\n /**\n * Event emitted when the user changes either the active sort or sort direction.\n * @type {?}\n */\n MatSort.prototype.sortChange;\n}\n/**\n * Returns the sort direction cycle to use given the provided parameters of order and clear.\n * @param {?} start\n * @param {?} disableClear\n * @return {?}\n */\nfunction getSortDirectionCycle(start, disableClear) {\n let /** @type {?} */ sortOrder = ['asc', 'desc'];\n if (start == 'desc') {\n sortOrder.reverse();\n }\n if (!disableClear) {\n sortOrder.push('');\n }\n return sortOrder;\n}\n//# sourceMappingURL=sort.js.map","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs/Subject';\n/**\n * To modify the labels and text displayed, create a new instance of MatSortHeaderIntl and\n * include it in a custom provider.\n */\nexport class MatSortHeaderIntl {\n constructor() {\n /**\n * Stream that emits whenever the labels here are changed. Use this to notify\n * components if the labels have changed after initialization.\n */\n this.changes = new Subject();\n /**\n * ARIA label for the sorting button.\n */\n this.sortButtonLabel = (id) => {\n return `Change sorting for ${id}`;\n };\n /**\n * A label to describe the current sort (visible only to screenreaders).\n */\n this.sortDescriptionLabel = (id, direction) => {\n return `Sorted by ${id} ${direction == 'asc' ? 'ascending' : 'descending'}`;\n };\n }\n}\nMatSortHeaderIntl.decorators = [\n { type: Injectable },\n];\n/**\n * @nocollapse\n */\nMatSortHeaderIntl.ctorParameters = () => [];\nfunction MatSortHeaderIntl_tsickle_Closure_declarations() {\n /** @type {?} */\n MatSortHeaderIntl.decorators;\n /**\n * @nocollapse\n * @type {?}\n */\n MatSortHeaderIntl.ctorParameters;\n /**\n * Stream that emits whenever the labels here are changed. Use this to notify\n * components if the labels have changed after initialization.\n * @type {?}\n */\n MatSortHeaderIntl.prototype.changes;\n /**\n * ARIA label for the sorting button.\n * @type {?}\n */\n MatSortHeaderIntl.prototype.sortButtonLabel;\n /**\n * A label to describe the current sort (visible only to screenreaders).\n * @type {?}\n */\n MatSortHeaderIntl.prototype.sortDescriptionLabel;\n}\n//# sourceMappingURL=sort-header-intl.js.map","/**\n * @license\n * Copyright Google Inc. All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\nimport { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, Optional, ViewEncapsulation } from '@angular/core';\nimport { coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { trigger, state, style, animate, transition, keyframes, } from '@angular/animations';\nimport { CdkColumnDef } from '@angular/cdk/table';\nimport { merge } from 'rxjs/observable/merge';\nimport { MatSort } from './sort';\nimport { MatSortHeaderIntl } from './sort-header-intl';\nimport { getSortHeaderNotContainedWithinSortError } from './sort-errors';\nimport { AnimationCurves, AnimationDurations } from '@angular/material/core';\nconst /** @type {?} */ SORT_ANIMATION_TRANSITION = AnimationDurations.ENTERING + ' ' + AnimationCurves.STANDARD_CURVE;\n/**\n * Applies sorting behavior (click to change sort) and styles to an element, including an\n * arrow to display the current sort direction.\n *\n * Must be provided with an id and contained within a parent MatSort directive.\n *\n * If used on header cells in a CdkTable, it will automatically default its id from its containing\n * column definition.\n */\nexport class MatSortHeader {\n /**\n * @param {?} _intl\n * @param {?} changeDetectorRef\n * @param {?} _sort\n * @param {?} _cdkColumnDef\n */\n constructor(_intl, changeDetectorRef, _sort, _cdkColumnDef) {\n this._intl = _intl;\n this._sort = _sort;\n this._cdkColumnDef = _cdkColumnDef;\n /**\n * Sets the position of the arrow that displays when sorted.\n */\n this.arrowPosition = 'after';\n if (!_sort) {\n throw getSortHeaderNotContainedWithinSortError();\n }\n this._rerenderSubscription = merge(_sort.sortChange, _intl.changes).subscribe(() => {\n changeDetectorRef.markForCheck();\n });\n }\n /**\n * Overrides the disable clear value of the containing MatSort for this MatSortable.\n * @return {?}\n */\n get disableClear() { return this._disableClear; }\n /**\n * @param {?} v\n * @return {?}\n */\n set disableClear(v) { this._disableClear = coerceBooleanProperty(v); }\n /**\n * @return {?}\n */\n ngOnInit() {\n if (!this.id && this._cdkColumnDef) {\n this.id = this._cdkColumnDef.name;\n }\n this._sort.register(this);\n }\n /**\n * @return {?}\n */\n ngOnDestroy() {\n this._sort.deregister(this);\n this._rerenderSubscription.unsubscribe();\n }\n /**\n * Whether this MatSortHeader is currently sorted in either ascending or descending order.\n * @return {?}\n */\n _isSorted() {\n return this._sort.active == this.id &&\n (this._sort.direction === 'asc' || this._sort.direction === 'desc');\n }\n}\nMatSortHeader.decorators = [\n { type: Component, args: [{selector: '[mat-sort-header]',\n template: \"