1 | (function (global, factory) {
|
---|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/cdk/a11y'), require('@angular/cdk/coercion'), require('@angular/cdk/keycodes'), require('@angular/material/core'), require('rxjs'), require('@angular/animations'), require('@angular/common')) :
|
---|
3 | typeof define === 'function' && define.amd ? define('@angular/material/sort', ['exports', '@angular/core', '@angular/cdk/a11y', '@angular/cdk/coercion', '@angular/cdk/keycodes', '@angular/material/core', 'rxjs', '@angular/animations', '@angular/common'], factory) :
|
---|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.sort = {}), global.ng.core, global.ng.cdk.a11y, global.ng.cdk.coercion, global.ng.cdk.keycodes, global.ng.material.core, global.rxjs, global.ng.animations, global.ng.common));
|
---|
5 | }(this, (function (exports, i0, a11y, coercion, keycodes, core, rxjs, animations, common) { 'use strict';
|
---|
6 |
|
---|
7 | function _interopNamespace(e) {
|
---|
8 | if (e && e.__esModule) return e;
|
---|
9 | var n = Object.create(null);
|
---|
10 | if (e) {
|
---|
11 | Object.keys(e).forEach(function (k) {
|
---|
12 | if (k !== 'default') {
|
---|
13 | var d = Object.getOwnPropertyDescriptor(e, k);
|
---|
14 | Object.defineProperty(n, k, d.get ? d : {
|
---|
15 | enumerable: true,
|
---|
16 | get: function () {
|
---|
17 | return e[k];
|
---|
18 | }
|
---|
19 | });
|
---|
20 | }
|
---|
21 | });
|
---|
22 | }
|
---|
23 | n['default'] = e;
|
---|
24 | return Object.freeze(n);
|
---|
25 | }
|
---|
26 |
|
---|
27 | var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
---|
28 |
|
---|
29 | /*! *****************************************************************************
|
---|
30 | Copyright (c) Microsoft Corporation.
|
---|
31 |
|
---|
32 | Permission to use, copy, modify, and/or distribute this software for any
|
---|
33 | purpose with or without fee is hereby granted.
|
---|
34 |
|
---|
35 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
---|
36 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
37 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
---|
38 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
---|
39 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
---|
40 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
---|
41 | PERFORMANCE OF THIS SOFTWARE.
|
---|
42 | ***************************************************************************** */
|
---|
43 | /* global Reflect, Promise */
|
---|
44 | var extendStatics = function (d, b) {
|
---|
45 | extendStatics = Object.setPrototypeOf ||
|
---|
46 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
---|
47 | function (d, b) { for (var p in b)
|
---|
48 | if (Object.prototype.hasOwnProperty.call(b, p))
|
---|
49 | d[p] = b[p]; };
|
---|
50 | return extendStatics(d, b);
|
---|
51 | };
|
---|
52 | function __extends(d, b) {
|
---|
53 | if (typeof b !== "function" && b !== null)
|
---|
54 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
---|
55 | extendStatics(d, b);
|
---|
56 | function __() { this.constructor = d; }
|
---|
57 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
---|
58 | }
|
---|
59 | var __assign = function () {
|
---|
60 | __assign = Object.assign || function __assign(t) {
|
---|
61 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
---|
62 | s = arguments[i];
|
---|
63 | for (var p in s)
|
---|
64 | if (Object.prototype.hasOwnProperty.call(s, p))
|
---|
65 | t[p] = s[p];
|
---|
66 | }
|
---|
67 | return t;
|
---|
68 | };
|
---|
69 | return __assign.apply(this, arguments);
|
---|
70 | };
|
---|
71 | function __rest(s, e) {
|
---|
72 | var t = {};
|
---|
73 | for (var p in s)
|
---|
74 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
---|
75 | t[p] = s[p];
|
---|
76 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
---|
77 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
---|
78 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
---|
79 | t[p[i]] = s[p[i]];
|
---|
80 | }
|
---|
81 | return t;
|
---|
82 | }
|
---|
83 | function __decorate(decorators, target, key, desc) {
|
---|
84 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
---|
85 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
---|
86 | r = Reflect.decorate(decorators, target, key, desc);
|
---|
87 | else
|
---|
88 | for (var i = decorators.length - 1; i >= 0; i--)
|
---|
89 | if (d = decorators[i])
|
---|
90 | r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
---|
91 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
---|
92 | }
|
---|
93 | function __param(paramIndex, decorator) {
|
---|
94 | return function (target, key) { decorator(target, key, paramIndex); };
|
---|
95 | }
|
---|
96 | function __metadata(metadataKey, metadataValue) {
|
---|
97 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
---|
98 | return Reflect.metadata(metadataKey, metadataValue);
|
---|
99 | }
|
---|
100 | function __awaiter(thisArg, _arguments, P, generator) {
|
---|
101 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
---|
102 | return new (P || (P = Promise))(function (resolve, reject) {
|
---|
103 | function fulfilled(value) { try {
|
---|
104 | step(generator.next(value));
|
---|
105 | }
|
---|
106 | catch (e) {
|
---|
107 | reject(e);
|
---|
108 | } }
|
---|
109 | function rejected(value) { try {
|
---|
110 | step(generator["throw"](value));
|
---|
111 | }
|
---|
112 | catch (e) {
|
---|
113 | reject(e);
|
---|
114 | } }
|
---|
115 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
---|
116 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
---|
117 | });
|
---|
118 | }
|
---|
119 | function __generator(thisArg, body) {
|
---|
120 | var _ = { label: 0, sent: function () { if (t[0] & 1)
|
---|
121 | throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
---|
122 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
---|
123 | function verb(n) { return function (v) { return step([n, v]); }; }
|
---|
124 | function step(op) {
|
---|
125 | if (f)
|
---|
126 | throw new TypeError("Generator is already executing.");
|
---|
127 | while (_)
|
---|
128 | try {
|
---|
129 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
---|
130 | return t;
|
---|
131 | if (y = 0, t)
|
---|
132 | op = [op[0] & 2, t.value];
|
---|
133 | switch (op[0]) {
|
---|
134 | case 0:
|
---|
135 | case 1:
|
---|
136 | t = op;
|
---|
137 | break;
|
---|
138 | case 4:
|
---|
139 | _.label++;
|
---|
140 | return { value: op[1], done: false };
|
---|
141 | case 5:
|
---|
142 | _.label++;
|
---|
143 | y = op[1];
|
---|
144 | op = [0];
|
---|
145 | continue;
|
---|
146 | case 7:
|
---|
147 | op = _.ops.pop();
|
---|
148 | _.trys.pop();
|
---|
149 | continue;
|
---|
150 | default:
|
---|
151 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
---|
152 | _ = 0;
|
---|
153 | continue;
|
---|
154 | }
|
---|
155 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
---|
156 | _.label = op[1];
|
---|
157 | break;
|
---|
158 | }
|
---|
159 | if (op[0] === 6 && _.label < t[1]) {
|
---|
160 | _.label = t[1];
|
---|
161 | t = op;
|
---|
162 | break;
|
---|
163 | }
|
---|
164 | if (t && _.label < t[2]) {
|
---|
165 | _.label = t[2];
|
---|
166 | _.ops.push(op);
|
---|
167 | break;
|
---|
168 | }
|
---|
169 | if (t[2])
|
---|
170 | _.ops.pop();
|
---|
171 | _.trys.pop();
|
---|
172 | continue;
|
---|
173 | }
|
---|
174 | op = body.call(thisArg, _);
|
---|
175 | }
|
---|
176 | catch (e) {
|
---|
177 | op = [6, e];
|
---|
178 | y = 0;
|
---|
179 | }
|
---|
180 | finally {
|
---|
181 | f = t = 0;
|
---|
182 | }
|
---|
183 | if (op[0] & 5)
|
---|
184 | throw op[1];
|
---|
185 | return { value: op[0] ? op[1] : void 0, done: true };
|
---|
186 | }
|
---|
187 | }
|
---|
188 | var __createBinding = Object.create ? (function (o, m, k, k2) {
|
---|
189 | if (k2 === undefined)
|
---|
190 | k2 = k;
|
---|
191 | Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
---|
192 | }) : (function (o, m, k, k2) {
|
---|
193 | if (k2 === undefined)
|
---|
194 | k2 = k;
|
---|
195 | o[k2] = m[k];
|
---|
196 | });
|
---|
197 | function __exportStar(m, o) {
|
---|
198 | for (var p in m)
|
---|
199 | if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
---|
200 | __createBinding(o, m, p);
|
---|
201 | }
|
---|
202 | function __values(o) {
|
---|
203 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
---|
204 | if (m)
|
---|
205 | return m.call(o);
|
---|
206 | if (o && typeof o.length === "number")
|
---|
207 | return {
|
---|
208 | next: function () {
|
---|
209 | if (o && i >= o.length)
|
---|
210 | o = void 0;
|
---|
211 | return { value: o && o[i++], done: !o };
|
---|
212 | }
|
---|
213 | };
|
---|
214 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
---|
215 | }
|
---|
216 | function __read(o, n) {
|
---|
217 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
---|
218 | if (!m)
|
---|
219 | return o;
|
---|
220 | var i = m.call(o), r, ar = [], e;
|
---|
221 | try {
|
---|
222 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
---|
223 | ar.push(r.value);
|
---|
224 | }
|
---|
225 | catch (error) {
|
---|
226 | e = { error: error };
|
---|
227 | }
|
---|
228 | finally {
|
---|
229 | try {
|
---|
230 | if (r && !r.done && (m = i["return"]))
|
---|
231 | m.call(i);
|
---|
232 | }
|
---|
233 | finally {
|
---|
234 | if (e)
|
---|
235 | throw e.error;
|
---|
236 | }
|
---|
237 | }
|
---|
238 | return ar;
|
---|
239 | }
|
---|
240 | /** @deprecated */
|
---|
241 | function __spread() {
|
---|
242 | for (var ar = [], i = 0; i < arguments.length; i++)
|
---|
243 | ar = ar.concat(__read(arguments[i]));
|
---|
244 | return ar;
|
---|
245 | }
|
---|
246 | /** @deprecated */
|
---|
247 | function __spreadArrays() {
|
---|
248 | for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
---|
249 | s += arguments[i].length;
|
---|
250 | for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
---|
251 | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
---|
252 | r[k] = a[j];
|
---|
253 | return r;
|
---|
254 | }
|
---|
255 | function __spreadArray(to, from, pack) {
|
---|
256 | if (pack || arguments.length === 2)
|
---|
257 | for (var i = 0, l = from.length, ar; i < l; i++) {
|
---|
258 | if (ar || !(i in from)) {
|
---|
259 | if (!ar)
|
---|
260 | ar = Array.prototype.slice.call(from, 0, i);
|
---|
261 | ar[i] = from[i];
|
---|
262 | }
|
---|
263 | }
|
---|
264 | return to.concat(ar || from);
|
---|
265 | }
|
---|
266 | function __await(v) {
|
---|
267 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
---|
268 | }
|
---|
269 | function __asyncGenerator(thisArg, _arguments, generator) {
|
---|
270 | if (!Symbol.asyncIterator)
|
---|
271 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
272 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
---|
273 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
---|
274 | function verb(n) { if (g[n])
|
---|
275 | i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
---|
276 | function resume(n, v) { try {
|
---|
277 | step(g[n](v));
|
---|
278 | }
|
---|
279 | catch (e) {
|
---|
280 | settle(q[0][3], e);
|
---|
281 | } }
|
---|
282 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
---|
283 | function fulfill(value) { resume("next", value); }
|
---|
284 | function reject(value) { resume("throw", value); }
|
---|
285 | function settle(f, v) { if (f(v), q.shift(), q.length)
|
---|
286 | resume(q[0][0], q[0][1]); }
|
---|
287 | }
|
---|
288 | function __asyncDelegator(o) {
|
---|
289 | var i, p;
|
---|
290 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
---|
291 | function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
---|
292 | }
|
---|
293 | function __asyncValues(o) {
|
---|
294 | if (!Symbol.asyncIterator)
|
---|
295 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
296 | var m = o[Symbol.asyncIterator], i;
|
---|
297 | return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
---|
298 | function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
---|
299 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
---|
300 | }
|
---|
301 | function __makeTemplateObject(cooked, raw) {
|
---|
302 | if (Object.defineProperty) {
|
---|
303 | Object.defineProperty(cooked, "raw", { value: raw });
|
---|
304 | }
|
---|
305 | else {
|
---|
306 | cooked.raw = raw;
|
---|
307 | }
|
---|
308 | return cooked;
|
---|
309 | }
|
---|
310 | ;
|
---|
311 | var __setModuleDefault = Object.create ? (function (o, v) {
|
---|
312 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
---|
313 | }) : function (o, v) {
|
---|
314 | o["default"] = v;
|
---|
315 | };
|
---|
316 | function __importStar(mod) {
|
---|
317 | if (mod && mod.__esModule)
|
---|
318 | return mod;
|
---|
319 | var result = {};
|
---|
320 | if (mod != null)
|
---|
321 | for (var k in mod)
|
---|
322 | if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
---|
323 | __createBinding(result, mod, k);
|
---|
324 | __setModuleDefault(result, mod);
|
---|
325 | return result;
|
---|
326 | }
|
---|
327 | function __importDefault(mod) {
|
---|
328 | return (mod && mod.__esModule) ? mod : { default: mod };
|
---|
329 | }
|
---|
330 | function __classPrivateFieldGet(receiver, state, kind, f) {
|
---|
331 | if (kind === "a" && !f)
|
---|
332 | throw new TypeError("Private accessor was defined without a getter");
|
---|
333 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
334 | throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
---|
335 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
---|
336 | }
|
---|
337 | function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
---|
338 | if (kind === "m")
|
---|
339 | throw new TypeError("Private method is not writable");
|
---|
340 | if (kind === "a" && !f)
|
---|
341 | throw new TypeError("Private accessor was defined without a setter");
|
---|
342 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
343 | throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
---|
344 | return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
---|
345 | }
|
---|
346 |
|
---|
347 | /**
|
---|
348 | * @license
|
---|
349 | * Copyright Google LLC All Rights Reserved.
|
---|
350 | *
|
---|
351 | * Use of this source code is governed by an MIT-style license that can be
|
---|
352 | * found in the LICENSE file at https://angular.io/license
|
---|
353 | */
|
---|
354 | /** @docs-private */
|
---|
355 | function getSortDuplicateSortableIdError(id) {
|
---|
356 | return Error("Cannot have two MatSortables with the same id (" + id + ").");
|
---|
357 | }
|
---|
358 | /** @docs-private */
|
---|
359 | function getSortHeaderNotContainedWithinSortError() {
|
---|
360 | return Error("MatSortHeader must be placed within a parent element with the MatSort directive.");
|
---|
361 | }
|
---|
362 | /** @docs-private */
|
---|
363 | function getSortHeaderMissingIdError() {
|
---|
364 | return Error("MatSortHeader must be provided with a unique id.");
|
---|
365 | }
|
---|
366 | /** @docs-private */
|
---|
367 | function getSortInvalidDirectionError(direction) {
|
---|
368 | return Error(direction + " is not a valid sort direction ('asc' or 'desc').");
|
---|
369 | }
|
---|
370 |
|
---|
371 | /** Injection token to be used to override the default options for `mat-sort`. */
|
---|
372 | var MAT_SORT_DEFAULT_OPTIONS = new i0.InjectionToken('MAT_SORT_DEFAULT_OPTIONS');
|
---|
373 | // Boilerplate for applying mixins to MatSort.
|
---|
374 | /** @docs-private */
|
---|
375 | var _MatSortBase = core.mixinInitialized(core.mixinDisabled(/** @class */ (function () {
|
---|
376 | function class_1() {
|
---|
377 | }
|
---|
378 | return class_1;
|
---|
379 | }())));
|
---|
380 | /** Container for MatSortables to manage the sort state and provide default sort parameters. */
|
---|
381 | var MatSort = /** @class */ (function (_super) {
|
---|
382 | __extends(MatSort, _super);
|
---|
383 | function MatSort(_defaultOptions) {
|
---|
384 | var _this = _super.call(this) || this;
|
---|
385 | _this._defaultOptions = _defaultOptions;
|
---|
386 | /** Collection of all registered sortables that this directive manages. */
|
---|
387 | _this.sortables = new Map();
|
---|
388 | /** Used to notify any child components listening to state changes. */
|
---|
389 | _this._stateChanges = new rxjs.Subject();
|
---|
390 | /**
|
---|
391 | * The direction to set when an MatSortable is initially sorted.
|
---|
392 | * May be overriden by the MatSortable's sort start.
|
---|
393 | */
|
---|
394 | _this.start = 'asc';
|
---|
395 | _this._direction = '';
|
---|
396 | /** Event emitted when the user changes either the active sort or sort direction. */
|
---|
397 | _this.sortChange = new i0.EventEmitter();
|
---|
398 | return _this;
|
---|
399 | }
|
---|
400 | Object.defineProperty(MatSort.prototype, "direction", {
|
---|
401 | /** The sort direction of the currently active MatSortable. */
|
---|
402 | get: function () { return this._direction; },
|
---|
403 | set: function (direction) {
|
---|
404 | if (direction && direction !== 'asc' && direction !== 'desc' &&
|
---|
405 | (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
406 | throw getSortInvalidDirectionError(direction);
|
---|
407 | }
|
---|
408 | this._direction = direction;
|
---|
409 | },
|
---|
410 | enumerable: false,
|
---|
411 | configurable: true
|
---|
412 | });
|
---|
413 | Object.defineProperty(MatSort.prototype, "disableClear", {
|
---|
414 | /**
|
---|
415 | * Whether to disable the user from clearing the sort by finishing the sort direction cycle.
|
---|
416 | * May be overriden by the MatSortable's disable clear input.
|
---|
417 | */
|
---|
418 | get: function () { return this._disableClear; },
|
---|
419 | set: function (v) { this._disableClear = coercion.coerceBooleanProperty(v); },
|
---|
420 | enumerable: false,
|
---|
421 | configurable: true
|
---|
422 | });
|
---|
423 | /**
|
---|
424 | * Register function to be used by the contained MatSortables. Adds the MatSortable to the
|
---|
425 | * collection of MatSortables.
|
---|
426 | */
|
---|
427 | MatSort.prototype.register = function (sortable) {
|
---|
428 | if (typeof ngDevMode === 'undefined' || ngDevMode) {
|
---|
429 | if (!sortable.id) {
|
---|
430 | throw getSortHeaderMissingIdError();
|
---|
431 | }
|
---|
432 | if (this.sortables.has(sortable.id)) {
|
---|
433 | throw getSortDuplicateSortableIdError(sortable.id);
|
---|
434 | }
|
---|
435 | }
|
---|
436 | this.sortables.set(sortable.id, sortable);
|
---|
437 | };
|
---|
438 | /**
|
---|
439 | * Unregister function to be used by the contained MatSortables. Removes the MatSortable from the
|
---|
440 | * collection of contained MatSortables.
|
---|
441 | */
|
---|
442 | MatSort.prototype.deregister = function (sortable) {
|
---|
443 | this.sortables.delete(sortable.id);
|
---|
444 | };
|
---|
445 | /** Sets the active sort id and determines the new sort direction. */
|
---|
446 | MatSort.prototype.sort = function (sortable) {
|
---|
447 | if (this.active != sortable.id) {
|
---|
448 | this.active = sortable.id;
|
---|
449 | this.direction = sortable.start ? sortable.start : this.start;
|
---|
450 | }
|
---|
451 | else {
|
---|
452 | this.direction = this.getNextSortDirection(sortable);
|
---|
453 | }
|
---|
454 | this.sortChange.emit({ active: this.active, direction: this.direction });
|
---|
455 | };
|
---|
456 | /** Returns the next sort direction of the active sortable, checking for potential overrides. */
|
---|
457 | MatSort.prototype.getNextSortDirection = function (sortable) {
|
---|
458 | var _a, _b, _c;
|
---|
459 | if (!sortable) {
|
---|
460 | return '';
|
---|
461 | }
|
---|
462 | // Get the sort direction cycle with the potential sortable overrides.
|
---|
463 | var disableClear = (_b = (_a = sortable === null || sortable === void 0 ? void 0 : sortable.disableClear) !== null && _a !== void 0 ? _a : this.disableClear) !== null && _b !== void 0 ? _b : !!((_c = this._defaultOptions) === null || _c === void 0 ? void 0 : _c.disableClear);
|
---|
464 | var sortDirectionCycle = getSortDirectionCycle(sortable.start || this.start, disableClear);
|
---|
465 | // Get and return the next direction in the cycle
|
---|
466 | var nextDirectionIndex = sortDirectionCycle.indexOf(this.direction) + 1;
|
---|
467 | if (nextDirectionIndex >= sortDirectionCycle.length) {
|
---|
468 | nextDirectionIndex = 0;
|
---|
469 | }
|
---|
470 | return sortDirectionCycle[nextDirectionIndex];
|
---|
471 | };
|
---|
472 | MatSort.prototype.ngOnInit = function () {
|
---|
473 | this._markInitialized();
|
---|
474 | };
|
---|
475 | MatSort.prototype.ngOnChanges = function () {
|
---|
476 | this._stateChanges.next();
|
---|
477 | };
|
---|
478 | MatSort.prototype.ngOnDestroy = function () {
|
---|
479 | this._stateChanges.complete();
|
---|
480 | };
|
---|
481 | return MatSort;
|
---|
482 | }(_MatSortBase));
|
---|
483 | MatSort.decorators = [
|
---|
484 | { type: i0.Directive, args: [{
|
---|
485 | selector: '[matSort]',
|
---|
486 | exportAs: 'matSort',
|
---|
487 | host: { 'class': 'mat-sort' },
|
---|
488 | inputs: ['disabled: matSortDisabled']
|
---|
489 | },] }
|
---|
490 | ];
|
---|
491 | MatSort.ctorParameters = function () { return [
|
---|
492 | { type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [MAT_SORT_DEFAULT_OPTIONS,] }] }
|
---|
493 | ]; };
|
---|
494 | MatSort.propDecorators = {
|
---|
495 | active: [{ type: i0.Input, args: ['matSortActive',] }],
|
---|
496 | start: [{ type: i0.Input, args: ['matSortStart',] }],
|
---|
497 | direction: [{ type: i0.Input, args: ['matSortDirection',] }],
|
---|
498 | disableClear: [{ type: i0.Input, args: ['matSortDisableClear',] }],
|
---|
499 | sortChange: [{ type: i0.Output, args: ['matSortChange',] }]
|
---|
500 | };
|
---|
501 | /** Returns the sort direction cycle to use given the provided parameters of order and clear. */
|
---|
502 | function getSortDirectionCycle(start, disableClear) {
|
---|
503 | var sortOrder = ['asc', 'desc'];
|
---|
504 | if (start == 'desc') {
|
---|
505 | sortOrder.reverse();
|
---|
506 | }
|
---|
507 | if (!disableClear) {
|
---|
508 | sortOrder.push('');
|
---|
509 | }
|
---|
510 | return sortOrder;
|
---|
511 | }
|
---|
512 |
|
---|
513 | /**
|
---|
514 | * @license
|
---|
515 | * Copyright Google LLC All Rights Reserved.
|
---|
516 | *
|
---|
517 | * Use of this source code is governed by an MIT-style license that can be
|
---|
518 | * found in the LICENSE file at https://angular.io/license
|
---|
519 | */
|
---|
520 | var SORT_ANIMATION_TRANSITION = core.AnimationDurations.ENTERING + ' ' +
|
---|
521 | core.AnimationCurves.STANDARD_CURVE;
|
---|
522 | /**
|
---|
523 | * Animations used by MatSort.
|
---|
524 | * @docs-private
|
---|
525 | */
|
---|
526 | var matSortAnimations = {
|
---|
527 | /** Animation that moves the sort indicator. */
|
---|
528 | indicator: animations.trigger('indicator', [
|
---|
529 | animations.state('active-asc, asc', animations.style({ transform: 'translateY(0px)' })),
|
---|
530 | // 10px is the height of the sort indicator, minus the width of the pointers
|
---|
531 | animations.state('active-desc, desc', animations.style({ transform: 'translateY(10px)' })),
|
---|
532 | animations.transition('active-asc <=> active-desc', animations.animate(SORT_ANIMATION_TRANSITION))
|
---|
533 | ]),
|
---|
534 | /** Animation that rotates the left pointer of the indicator based on the sorting direction. */
|
---|
535 | leftPointer: animations.trigger('leftPointer', [
|
---|
536 | animations.state('active-asc, asc', animations.style({ transform: 'rotate(-45deg)' })),
|
---|
537 | animations.state('active-desc, desc', animations.style({ transform: 'rotate(45deg)' })),
|
---|
538 | animations.transition('active-asc <=> active-desc', animations.animate(SORT_ANIMATION_TRANSITION))
|
---|
539 | ]),
|
---|
540 | /** Animation that rotates the right pointer of the indicator based on the sorting direction. */
|
---|
541 | rightPointer: animations.trigger('rightPointer', [
|
---|
542 | animations.state('active-asc, asc', animations.style({ transform: 'rotate(45deg)' })),
|
---|
543 | animations.state('active-desc, desc', animations.style({ transform: 'rotate(-45deg)' })),
|
---|
544 | animations.transition('active-asc <=> active-desc', animations.animate(SORT_ANIMATION_TRANSITION))
|
---|
545 | ]),
|
---|
546 | /** Animation that controls the arrow opacity. */
|
---|
547 | arrowOpacity: animations.trigger('arrowOpacity', [
|
---|
548 | animations.state('desc-to-active, asc-to-active, active', animations.style({ opacity: 1 })),
|
---|
549 | animations.state('desc-to-hint, asc-to-hint, hint', animations.style({ opacity: .54 })),
|
---|
550 | animations.state('hint-to-desc, active-to-desc, desc, hint-to-asc, active-to-asc, asc, void', animations.style({ opacity: 0 })),
|
---|
551 | // Transition between all states except for immediate transitions
|
---|
552 | animations.transition('* => asc, * => desc, * => active, * => hint, * => void', animations.animate('0ms')),
|
---|
553 | animations.transition('* <=> *', animations.animate(SORT_ANIMATION_TRANSITION)),
|
---|
554 | ]),
|
---|
555 | /**
|
---|
556 | * Animation for the translation of the arrow as a whole. States are separated into two
|
---|
557 | * groups: ones with animations and others that are immediate. Immediate states are asc, desc,
|
---|
558 | * peek, and active. The other states define a specific animation (source-to-destination)
|
---|
559 | * and are determined as a function of their prev user-perceived state and what the next state
|
---|
560 | * should be.
|
---|
561 | */
|
---|
562 | arrowPosition: animations.trigger('arrowPosition', [
|
---|
563 | // Hidden Above => Hint Center
|
---|
564 | animations.transition('* => desc-to-hint, * => desc-to-active', animations.animate(SORT_ANIMATION_TRANSITION, animations.keyframes([
|
---|
565 | animations.style({ transform: 'translateY(-25%)' }),
|
---|
566 | animations.style({ transform: 'translateY(0)' })
|
---|
567 | ]))),
|
---|
568 | // Hint Center => Hidden Below
|
---|
569 | animations.transition('* => hint-to-desc, * => active-to-desc', animations.animate(SORT_ANIMATION_TRANSITION, animations.keyframes([
|
---|
570 | animations.style({ transform: 'translateY(0)' }),
|
---|
571 | animations.style({ transform: 'translateY(25%)' })
|
---|
572 | ]))),
|
---|
573 | // Hidden Below => Hint Center
|
---|
574 | animations.transition('* => asc-to-hint, * => asc-to-active', animations.animate(SORT_ANIMATION_TRANSITION, animations.keyframes([
|
---|
575 | animations.style({ transform: 'translateY(25%)' }),
|
---|
576 | animations.style({ transform: 'translateY(0)' })
|
---|
577 | ]))),
|
---|
578 | // Hint Center => Hidden Above
|
---|
579 | animations.transition('* => hint-to-asc, * => active-to-asc', animations.animate(SORT_ANIMATION_TRANSITION, animations.keyframes([
|
---|
580 | animations.style({ transform: 'translateY(0)' }),
|
---|
581 | animations.style({ transform: 'translateY(-25%)' })
|
---|
582 | ]))),
|
---|
583 | animations.state('desc-to-hint, asc-to-hint, hint, desc-to-active, asc-to-active, active', animations.style({ transform: 'translateY(0)' })),
|
---|
584 | animations.state('hint-to-desc, active-to-desc, desc', animations.style({ transform: 'translateY(-25%)' })),
|
---|
585 | animations.state('hint-to-asc, active-to-asc, asc', animations.style({ transform: 'translateY(25%)' })),
|
---|
586 | ]),
|
---|
587 | /** Necessary trigger that calls animate on children animations. */
|
---|
588 | allowChildren: animations.trigger('allowChildren', [
|
---|
589 | animations.transition('* <=> *', [
|
---|
590 | animations.query('@*', animations.animateChild(), { optional: true })
|
---|
591 | ])
|
---|
592 | ]),
|
---|
593 | };
|
---|
594 |
|
---|
595 | /**
|
---|
596 | * @license
|
---|
597 | * Copyright Google LLC All Rights Reserved.
|
---|
598 | *
|
---|
599 | * Use of this source code is governed by an MIT-style license that can be
|
---|
600 | * found in the LICENSE file at https://angular.io/license
|
---|
601 | */
|
---|
602 | /**
|
---|
603 | * To modify the labels and text displayed, create a new instance of MatSortHeaderIntl and
|
---|
604 | * include it in a custom provider.
|
---|
605 | */
|
---|
606 | var MatSortHeaderIntl = /** @class */ (function () {
|
---|
607 | function MatSortHeaderIntl() {
|
---|
608 | /**
|
---|
609 | * Stream that emits whenever the labels here are changed. Use this to notify
|
---|
610 | * components if the labels have changed after initialization.
|
---|
611 | */
|
---|
612 | this.changes = new rxjs.Subject();
|
---|
613 | }
|
---|
614 | return MatSortHeaderIntl;
|
---|
615 | }());
|
---|
616 | MatSortHeaderIntl.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function MatSortHeaderIntl_Factory() { return new MatSortHeaderIntl(); }, token: MatSortHeaderIntl, providedIn: "root" });
|
---|
617 | MatSortHeaderIntl.decorators = [
|
---|
618 | { type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
---|
619 | ];
|
---|
620 | /** @docs-private */
|
---|
621 | function MAT_SORT_HEADER_INTL_PROVIDER_FACTORY(parentIntl) {
|
---|
622 | return parentIntl || new MatSortHeaderIntl();
|
---|
623 | }
|
---|
624 | /** @docs-private */
|
---|
625 | var MAT_SORT_HEADER_INTL_PROVIDER = {
|
---|
626 | // If there is already an MatSortHeaderIntl available, use that. Otherwise, provide a new one.
|
---|
627 | provide: MatSortHeaderIntl,
|
---|
628 | deps: [[new i0.Optional(), new i0.SkipSelf(), MatSortHeaderIntl]],
|
---|
629 | useFactory: MAT_SORT_HEADER_INTL_PROVIDER_FACTORY
|
---|
630 | };
|
---|
631 |
|
---|
632 | // Boilerplate for applying mixins to the sort header.
|
---|
633 | /** @docs-private */
|
---|
634 | var _MatSortHeaderBase = core.mixinDisabled(/** @class */ (function () {
|
---|
635 | function class_1() {
|
---|
636 | }
|
---|
637 | return class_1;
|
---|
638 | }()));
|
---|
639 | /**
|
---|
640 | * Applies sorting behavior (click to change sort) and styles to an element, including an
|
---|
641 | * arrow to display the current sort direction.
|
---|
642 | *
|
---|
643 | * Must be provided with an id and contained within a parent MatSort directive.
|
---|
644 | *
|
---|
645 | * If used on header cells in a CdkTable, it will automatically default its id from its containing
|
---|
646 | * column definition.
|
---|
647 | */
|
---|
648 | var MatSortHeader = /** @class */ (function (_super) {
|
---|
649 | __extends(MatSortHeader, _super);
|
---|
650 | function MatSortHeader(
|
---|
651 | /**
|
---|
652 | * @deprecated `_intl` parameter isn't being used anymore and it'll be removed.
|
---|
653 | * @breaking-change 13.0.0
|
---|
654 | */
|
---|
655 | _intl, _changeDetectorRef,
|
---|
656 | // `MatSort` is not optionally injected, but just asserted manually w/ better error.
|
---|
657 | // tslint:disable-next-line: lightweight-tokens
|
---|
658 | _sort, _columnDef, _focusMonitor, _elementRef,
|
---|
659 | /** @breaking-change 14.0.0 _ariaDescriber will be required. */
|
---|
660 | _ariaDescriber) {
|
---|
661 | var _this =
|
---|
662 | // Note that we use a string token for the `_columnDef`, because the value is provided both by
|
---|
663 | // `material/table` and `cdk/table` and we can't have the CDK depending on Material,
|
---|
664 | // and we want to avoid having the sort header depending on the CDK table because
|
---|
665 | // of this single reference.
|
---|
666 | _super.call(this) || this;
|
---|
667 | _this._intl = _intl;
|
---|
668 | _this._changeDetectorRef = _changeDetectorRef;
|
---|
669 | _this._sort = _sort;
|
---|
670 | _this._columnDef = _columnDef;
|
---|
671 | _this._focusMonitor = _focusMonitor;
|
---|
672 | _this._elementRef = _elementRef;
|
---|
673 | _this._ariaDescriber = _ariaDescriber;
|
---|
674 | /**
|
---|
675 | * Flag set to true when the indicator should be displayed while the sort is not active. Used to
|
---|
676 | * provide an affordance that the header is sortable by showing on focus and hover.
|
---|
677 | */
|
---|
678 | _this._showIndicatorHint = false;
|
---|
679 | /**
|
---|
680 | * The view transition state of the arrow (translation/ opacity) - indicates its `from` and `to`
|
---|
681 | * position through the animation. If animations are currently disabled, the fromState is removed
|
---|
682 | * so that there is no animation displayed.
|
---|
683 | */
|
---|
684 | _this._viewState = {};
|
---|
685 | /** The direction the arrow should be facing according to the current state. */
|
---|
686 | _this._arrowDirection = '';
|
---|
687 | /**
|
---|
688 | * Whether the view state animation should show the transition between the `from` and `to` states.
|
---|
689 | */
|
---|
690 | _this._disableViewStateAnimation = false;
|
---|
691 | /** Sets the position of the arrow that displays when sorted. */
|
---|
692 | _this.arrowPosition = 'after';
|
---|
693 | // Default the action description to "Sort" because it's better than nothing.
|
---|
694 | // Without a description, the button's label comes from the sort header text content,
|
---|
695 | // which doesn't give any indication that it performs a sorting operation.
|
---|
696 | _this._sortActionDescription = 'Sort';
|
---|
697 | if (!_sort && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
698 | throw getSortHeaderNotContainedWithinSortError();
|
---|
699 | }
|
---|
700 | _this._handleStateChanges();
|
---|
701 | return _this;
|
---|
702 | }
|
---|
703 | Object.defineProperty(MatSortHeader.prototype, "sortActionDescription", {
|
---|
704 | /**
|
---|
705 | * Description applied to MatSortHeader's button element with aria-describedby. This text should
|
---|
706 | * describe the action that will occur when the user clicks the sort header.
|
---|
707 | */
|
---|
708 | get: function () {
|
---|
709 | return this._sortActionDescription;
|
---|
710 | },
|
---|
711 | set: function (value) {
|
---|
712 | this._updateSortActionDescription(value);
|
---|
713 | },
|
---|
714 | enumerable: false,
|
---|
715 | configurable: true
|
---|
716 | });
|
---|
717 | Object.defineProperty(MatSortHeader.prototype, "disableClear", {
|
---|
718 | /** Overrides the disable clear value of the containing MatSort for this MatSortable. */
|
---|
719 | get: function () { return this._disableClear; },
|
---|
720 | set: function (v) { this._disableClear = coercion.coerceBooleanProperty(v); },
|
---|
721 | enumerable: false,
|
---|
722 | configurable: true
|
---|
723 | });
|
---|
724 | MatSortHeader.prototype.ngOnInit = function () {
|
---|
725 | if (!this.id && this._columnDef) {
|
---|
726 | this.id = this._columnDef.name;
|
---|
727 | }
|
---|
728 | // Initialize the direction of the arrow and set the view state to be immediately that state.
|
---|
729 | this._updateArrowDirection();
|
---|
730 | this._setAnimationTransitionState({ toState: this._isSorted() ? 'active' : this._arrowDirection });
|
---|
731 | this._sort.register(this);
|
---|
732 | this._sortButton = this._elementRef.nativeElement.querySelector('[role="button"]');
|
---|
733 | this._updateSortActionDescription(this._sortActionDescription);
|
---|
734 | };
|
---|
735 | MatSortHeader.prototype.ngAfterViewInit = function () {
|
---|
736 | var _this = this;
|
---|
737 | // We use the focus monitor because we also want to style
|
---|
738 | // things differently based on the focus origin.
|
---|
739 | this._focusMonitor.monitor(this._elementRef, true).subscribe(function (origin) {
|
---|
740 | var newState = !!origin;
|
---|
741 | if (newState !== _this._showIndicatorHint) {
|
---|
742 | _this._setIndicatorHintVisible(newState);
|
---|
743 | _this._changeDetectorRef.markForCheck();
|
---|
744 | }
|
---|
745 | });
|
---|
746 | };
|
---|
747 | MatSortHeader.prototype.ngOnDestroy = function () {
|
---|
748 | this._focusMonitor.stopMonitoring(this._elementRef);
|
---|
749 | this._sort.deregister(this);
|
---|
750 | this._rerenderSubscription.unsubscribe();
|
---|
751 | };
|
---|
752 | /**
|
---|
753 | * Sets the "hint" state such that the arrow will be semi-transparently displayed as a hint to the
|
---|
754 | * user showing what the active sort will become. If set to false, the arrow will fade away.
|
---|
755 | */
|
---|
756 | MatSortHeader.prototype._setIndicatorHintVisible = function (visible) {
|
---|
757 | // No-op if the sort header is disabled - should not make the hint visible.
|
---|
758 | if (this._isDisabled() && visible) {
|
---|
759 | return;
|
---|
760 | }
|
---|
761 | this._showIndicatorHint = visible;
|
---|
762 | if (!this._isSorted()) {
|
---|
763 | this._updateArrowDirection();
|
---|
764 | if (this._showIndicatorHint) {
|
---|
765 | this._setAnimationTransitionState({ fromState: this._arrowDirection, toState: 'hint' });
|
---|
766 | }
|
---|
767 | else {
|
---|
768 | this._setAnimationTransitionState({ fromState: 'hint', toState: this._arrowDirection });
|
---|
769 | }
|
---|
770 | }
|
---|
771 | };
|
---|
772 | /**
|
---|
773 | * Sets the animation transition view state for the arrow's position and opacity. If the
|
---|
774 | * `disableViewStateAnimation` flag is set to true, the `fromState` will be ignored so that
|
---|
775 | * no animation appears.
|
---|
776 | */
|
---|
777 | MatSortHeader.prototype._setAnimationTransitionState = function (viewState) {
|
---|
778 | this._viewState = viewState || {};
|
---|
779 | // If the animation for arrow position state (opacity/translation) should be disabled,
|
---|
780 | // remove the fromState so that it jumps right to the toState.
|
---|
781 | if (this._disableViewStateAnimation) {
|
---|
782 | this._viewState = { toState: viewState.toState };
|
---|
783 | }
|
---|
784 | };
|
---|
785 | /** Triggers the sort on this sort header and removes the indicator hint. */
|
---|
786 | MatSortHeader.prototype._toggleOnInteraction = function () {
|
---|
787 | this._sort.sort(this);
|
---|
788 | // Do not show the animation if the header was already shown in the right position.
|
---|
789 | if (this._viewState.toState === 'hint' || this._viewState.toState === 'active') {
|
---|
790 | this._disableViewStateAnimation = true;
|
---|
791 | }
|
---|
792 | };
|
---|
793 | MatSortHeader.prototype._handleClick = function () {
|
---|
794 | if (!this._isDisabled()) {
|
---|
795 | this._sort.sort(this);
|
---|
796 | }
|
---|
797 | };
|
---|
798 | MatSortHeader.prototype._handleKeydown = function (event) {
|
---|
799 | if (!this._isDisabled() && (event.keyCode === keycodes.SPACE || event.keyCode === keycodes.ENTER)) {
|
---|
800 | event.preventDefault();
|
---|
801 | this._toggleOnInteraction();
|
---|
802 | }
|
---|
803 | };
|
---|
804 | /** Whether this MatSortHeader is currently sorted in either ascending or descending order. */
|
---|
805 | MatSortHeader.prototype._isSorted = function () {
|
---|
806 | return this._sort.active == this.id &&
|
---|
807 | (this._sort.direction === 'asc' || this._sort.direction === 'desc');
|
---|
808 | };
|
---|
809 | /** Returns the animation state for the arrow direction (indicator and pointers). */
|
---|
810 | MatSortHeader.prototype._getArrowDirectionState = function () {
|
---|
811 | return "" + (this._isSorted() ? 'active-' : '') + this._arrowDirection;
|
---|
812 | };
|
---|
813 | /** Returns the arrow position state (opacity, translation). */
|
---|
814 | MatSortHeader.prototype._getArrowViewState = function () {
|
---|
815 | var fromState = this._viewState.fromState;
|
---|
816 | return (fromState ? fromState + "-to-" : '') + this._viewState.toState;
|
---|
817 | };
|
---|
818 | /**
|
---|
819 | * Updates the direction the arrow should be pointing. If it is not sorted, the arrow should be
|
---|
820 | * facing the start direction. Otherwise if it is sorted, the arrow should point in the currently
|
---|
821 | * active sorted direction. The reason this is updated through a function is because the direction
|
---|
822 | * should only be changed at specific times - when deactivated but the hint is displayed and when
|
---|
823 | * the sort is active and the direction changes. Otherwise the arrow's direction should linger
|
---|
824 | * in cases such as the sort becoming deactivated but we want to animate the arrow away while
|
---|
825 | * preserving its direction, even though the next sort direction is actually different and should
|
---|
826 | * only be changed once the arrow displays again (hint or activation).
|
---|
827 | */
|
---|
828 | MatSortHeader.prototype._updateArrowDirection = function () {
|
---|
829 | this._arrowDirection = this._isSorted() ?
|
---|
830 | this._sort.direction :
|
---|
831 | (this.start || this._sort.start);
|
---|
832 | };
|
---|
833 | MatSortHeader.prototype._isDisabled = function () {
|
---|
834 | return this._sort.disabled || this.disabled;
|
---|
835 | };
|
---|
836 | /**
|
---|
837 | * Gets the aria-sort attribute that should be applied to this sort header. If this header
|
---|
838 | * is not sorted, returns null so that the attribute is removed from the host element. Aria spec
|
---|
839 | * says that the aria-sort property should only be present on one header at a time, so removing
|
---|
840 | * ensures this is true.
|
---|
841 | */
|
---|
842 | MatSortHeader.prototype._getAriaSortAttribute = function () {
|
---|
843 | if (!this._isSorted()) {
|
---|
844 | return 'none';
|
---|
845 | }
|
---|
846 | return this._sort.direction == 'asc' ? 'ascending' : 'descending';
|
---|
847 | };
|
---|
848 | /** Whether the arrow inside the sort header should be rendered. */
|
---|
849 | MatSortHeader.prototype._renderArrow = function () {
|
---|
850 | return !this._isDisabled() || this._isSorted();
|
---|
851 | };
|
---|
852 | MatSortHeader.prototype._updateSortActionDescription = function (newDescription) {
|
---|
853 | // We use AriaDescriber for the sort button instead of setting an `aria-label` because some
|
---|
854 | // screen readers (notably VoiceOver) will read both the column header *and* the button's label
|
---|
855 | // for every *cell* in the table, creating a lot of unnecessary noise.
|
---|
856 | var _a, _b;
|
---|
857 | // If _sortButton is undefined, the component hasn't been initialized yet so there's
|
---|
858 | // nothing to update in the DOM.
|
---|
859 | if (this._sortButton) {
|
---|
860 | // removeDescription will no-op if there is no existing message.
|
---|
861 | // TODO(jelbourn): remove optional chaining when AriaDescriber is required.
|
---|
862 | (_a = this._ariaDescriber) === null || _a === void 0 ? void 0 : _a.removeDescription(this._sortButton, this._sortActionDescription);
|
---|
863 | (_b = this._ariaDescriber) === null || _b === void 0 ? void 0 : _b.describe(this._sortButton, newDescription);
|
---|
864 | }
|
---|
865 | this._sortActionDescription = newDescription;
|
---|
866 | };
|
---|
867 | /** Handles changes in the sorting state. */
|
---|
868 | MatSortHeader.prototype._handleStateChanges = function () {
|
---|
869 | var _this = this;
|
---|
870 | this._rerenderSubscription =
|
---|
871 | rxjs.merge(this._sort.sortChange, this._sort._stateChanges, this._intl.changes).subscribe(function () {
|
---|
872 | if (_this._isSorted()) {
|
---|
873 | _this._updateArrowDirection();
|
---|
874 | // Do not show the animation if the header was already shown in the right position.
|
---|
875 | if (_this._viewState.toState === 'hint' || _this._viewState.toState === 'active') {
|
---|
876 | _this._disableViewStateAnimation = true;
|
---|
877 | }
|
---|
878 | _this._setAnimationTransitionState({ fromState: _this._arrowDirection, toState: 'active' });
|
---|
879 | _this._showIndicatorHint = false;
|
---|
880 | }
|
---|
881 | // If this header was recently active and now no longer sorted, animate away the arrow.
|
---|
882 | if (!_this._isSorted() && _this._viewState && _this._viewState.toState === 'active') {
|
---|
883 | _this._disableViewStateAnimation = false;
|
---|
884 | _this._setAnimationTransitionState({ fromState: 'active', toState: _this._arrowDirection });
|
---|
885 | }
|
---|
886 | _this._changeDetectorRef.markForCheck();
|
---|
887 | });
|
---|
888 | };
|
---|
889 | return MatSortHeader;
|
---|
890 | }(_MatSortHeaderBase));
|
---|
891 | MatSortHeader.decorators = [
|
---|
892 | { type: i0.Component, args: [{
|
---|
893 | selector: '[mat-sort-header]',
|
---|
894 | exportAs: 'matSortHeader',
|
---|
895 | template: "<!--\n We set the `tabindex` on an element inside the table header, rather than the header itself,\n because of a bug in NVDA where having a `tabindex` on a `th` breaks keyboard navigation in the\n table (see https://github.com/nvaccess/nvda/issues/7718). This allows for the header to both\n be focusable, and have screen readers read out its `aria-sort` state. We prefer this approach\n over having a button with an `aria-label` inside the header, because the button's `aria-label`\n will be read out as the user is navigating the table's cell (see #13012).\n\n The approach is based off of: https://dequeuniversity.com/library/aria/tables/sf-sortable-grid\n-->\n<div class=\"mat-sort-header-container mat-focus-indicator\"\n [class.mat-sort-header-sorted]=\"_isSorted()\"\n [class.mat-sort-header-position-before]=\"arrowPosition == 'before'\"\n [attr.tabindex]=\"_isDisabled() ? null : 0\"\n role=\"button\">\n\n <!--\n TODO(crisbeto): this div isn't strictly necessary, but we have to keep it due to a large\n number of screenshot diff failures. It should be removed eventually. Note that the difference\n isn't visible with a shorter header, but once it breaks up into multiple lines, this element\n causes it to be center-aligned, whereas removing it will keep the text to the left.\n -->\n <div class=\"mat-sort-header-content\">\n <ng-content></ng-content>\n </div>\n\n <!-- Disable animations while a current animation is running -->\n <div class=\"mat-sort-header-arrow\"\n *ngIf=\"_renderArrow()\"\n [@arrowOpacity]=\"_getArrowViewState()\"\n [@arrowPosition]=\"_getArrowViewState()\"\n [@allowChildren]=\"_getArrowDirectionState()\"\n (@arrowPosition.start)=\"_disableViewStateAnimation = true\"\n (@arrowPosition.done)=\"_disableViewStateAnimation = false\">\n <div class=\"mat-sort-header-stem\"></div>\n <div class=\"mat-sort-header-indicator\" [@indicator]=\"_getArrowDirectionState()\">\n <div class=\"mat-sort-header-pointer-left\" [@leftPointer]=\"_getArrowDirectionState()\"></div>\n <div class=\"mat-sort-header-pointer-right\" [@rightPointer]=\"_getArrowDirectionState()\"></div>\n <div class=\"mat-sort-header-pointer-middle\"></div>\n </div>\n </div>\n</div>\n",
|
---|
896 | host: {
|
---|
897 | 'class': 'mat-sort-header',
|
---|
898 | '(click)': '_handleClick()',
|
---|
899 | '(keydown)': '_handleKeydown($event)',
|
---|
900 | '(mouseenter)': '_setIndicatorHintVisible(true)',
|
---|
901 | '(mouseleave)': '_setIndicatorHintVisible(false)',
|
---|
902 | '[attr.aria-sort]': '_getAriaSortAttribute()',
|
---|
903 | '[class.mat-sort-header-disabled]': '_isDisabled()',
|
---|
904 | },
|
---|
905 | encapsulation: i0.ViewEncapsulation.None,
|
---|
906 | changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
---|
907 | inputs: ['disabled'],
|
---|
908 | animations: [
|
---|
909 | matSortAnimations.indicator,
|
---|
910 | matSortAnimations.leftPointer,
|
---|
911 | matSortAnimations.rightPointer,
|
---|
912 | matSortAnimations.arrowOpacity,
|
---|
913 | matSortAnimations.arrowPosition,
|
---|
914 | matSortAnimations.allowChildren,
|
---|
915 | ],
|
---|
916 | styles: [".mat-sort-header-container{display:flex;cursor:pointer;align-items:center;letter-spacing:normal;outline:0}[mat-sort-header].cdk-keyboard-focused .mat-sort-header-container,[mat-sort-header].cdk-program-focused .mat-sort-header-container{border-bottom:solid 1px currentColor}.mat-sort-header-disabled .mat-sort-header-container{cursor:default}.mat-sort-header-content{text-align:center;display:flex;align-items:center}.mat-sort-header-position-before{flex-direction:row-reverse}.mat-sort-header-arrow{height:12px;width:12px;min-width:12px;position:relative;display:flex;opacity:0}.mat-sort-header-arrow,[dir=rtl] .mat-sort-header-position-before .mat-sort-header-arrow{margin:0 0 0 6px}.mat-sort-header-position-before .mat-sort-header-arrow,[dir=rtl] .mat-sort-header-arrow{margin:0 6px 0 0}.mat-sort-header-stem{background:currentColor;height:10px;width:2px;margin:auto;display:flex;align-items:center}.cdk-high-contrast-active .mat-sort-header-stem{width:0;border-left:solid 2px}.mat-sort-header-indicator{width:100%;height:2px;display:flex;align-items:center;position:absolute;top:0;left:0}.mat-sort-header-pointer-middle{margin:auto;height:2px;width:2px;background:currentColor;transform:rotate(45deg)}.cdk-high-contrast-active .mat-sort-header-pointer-middle{width:0;height:0;border-top:solid 2px;border-left:solid 2px}.mat-sort-header-pointer-left,.mat-sort-header-pointer-right{background:currentColor;width:6px;height:2px;position:absolute;top:0}.cdk-high-contrast-active .mat-sort-header-pointer-left,.cdk-high-contrast-active .mat-sort-header-pointer-right{width:0;height:0;border-left:solid 6px;border-top:solid 2px}.mat-sort-header-pointer-left{transform-origin:right;left:0}.mat-sort-header-pointer-right{transform-origin:left;right:0}\n"]
|
---|
917 | },] }
|
---|
918 | ];
|
---|
919 | MatSortHeader.ctorParameters = function () { return [
|
---|
920 | { type: MatSortHeaderIntl },
|
---|
921 | { type: i0.ChangeDetectorRef },
|
---|
922 | { type: MatSort, decorators: [{ type: i0.Optional }] },
|
---|
923 | { type: undefined, decorators: [{ type: i0.Inject, args: ['MAT_SORT_HEADER_COLUMN_DEF',] }, { type: i0.Optional }] },
|
---|
924 | { type: a11y.FocusMonitor },
|
---|
925 | { type: i0.ElementRef },
|
---|
926 | { type: a11y.AriaDescriber, decorators: [{ type: i0.Inject, args: [a11y.AriaDescriber,] }, { type: i0.Optional }] }
|
---|
927 | ]; };
|
---|
928 | MatSortHeader.propDecorators = {
|
---|
929 | id: [{ type: i0.Input, args: ['mat-sort-header',] }],
|
---|
930 | arrowPosition: [{ type: i0.Input }],
|
---|
931 | start: [{ type: i0.Input }],
|
---|
932 | sortActionDescription: [{ type: i0.Input }],
|
---|
933 | disableClear: [{ type: i0.Input }]
|
---|
934 | };
|
---|
935 |
|
---|
936 | /**
|
---|
937 | * @license
|
---|
938 | * Copyright Google LLC All Rights Reserved.
|
---|
939 | *
|
---|
940 | * Use of this source code is governed by an MIT-style license that can be
|
---|
941 | * found in the LICENSE file at https://angular.io/license
|
---|
942 | */
|
---|
943 | var MatSortModule = /** @class */ (function () {
|
---|
944 | function MatSortModule() {
|
---|
945 | }
|
---|
946 | return MatSortModule;
|
---|
947 | }());
|
---|
948 | MatSortModule.decorators = [
|
---|
949 | { type: i0.NgModule, args: [{
|
---|
950 | imports: [common.CommonModule, core.MatCommonModule],
|
---|
951 | exports: [MatSort, MatSortHeader],
|
---|
952 | declarations: [MatSort, MatSortHeader],
|
---|
953 | providers: [MAT_SORT_HEADER_INTL_PROVIDER]
|
---|
954 | },] }
|
---|
955 | ];
|
---|
956 |
|
---|
957 | /**
|
---|
958 | * @license
|
---|
959 | * Copyright Google LLC All Rights Reserved.
|
---|
960 | *
|
---|
961 | * Use of this source code is governed by an MIT-style license that can be
|
---|
962 | * found in the LICENSE file at https://angular.io/license
|
---|
963 | */
|
---|
964 |
|
---|
965 | /**
|
---|
966 | * Generated bundle index. Do not edit.
|
---|
967 | */
|
---|
968 |
|
---|
969 | exports.MAT_SORT_DEFAULT_OPTIONS = MAT_SORT_DEFAULT_OPTIONS;
|
---|
970 | exports.MAT_SORT_HEADER_INTL_PROVIDER = MAT_SORT_HEADER_INTL_PROVIDER;
|
---|
971 | exports.MAT_SORT_HEADER_INTL_PROVIDER_FACTORY = MAT_SORT_HEADER_INTL_PROVIDER_FACTORY;
|
---|
972 | exports.MatSort = MatSort;
|
---|
973 | exports.MatSortHeader = MatSortHeader;
|
---|
974 | exports.MatSortHeaderIntl = MatSortHeaderIntl;
|
---|
975 | exports.MatSortModule = MatSortModule;
|
---|
976 | exports.matSortAnimations = matSortAnimations;
|
---|
977 |
|
---|
978 | Object.defineProperty(exports, '__esModule', { value: true });
|
---|
979 |
|
---|
980 | })));
|
---|
981 | //# sourceMappingURL=material-sort.umd.js.map
|
---|