[6a3a178] | 1 | (function (global, factory) {
|
---|
| 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('@angular/core')) :
|
---|
| 3 | typeof define === 'function' && define.amd ? define('@angular/cdk/collections', ['exports', 'rxjs', '@angular/core'], factory) :
|
---|
| 4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.collections = {}), global.rxjs, global.ng.core));
|
---|
| 5 | }(this, (function (exports, rxjs, i0) { '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 | var DataSource = /** @class */ (function () {
|
---|
| 355 | function DataSource() {
|
---|
| 356 | }
|
---|
| 357 | return DataSource;
|
---|
| 358 | }());
|
---|
| 359 | /** Checks whether an object is a data source. */
|
---|
| 360 | function isDataSource(value) {
|
---|
| 361 | // Check if the value is a DataSource by observing if it has a connect function. Cannot
|
---|
| 362 | // be checked as an `instanceof DataSource` since people could create their own sources
|
---|
| 363 | // that match the interface, but don't extend DataSource.
|
---|
| 364 | return value && typeof value.connect === 'function';
|
---|
| 365 | }
|
---|
| 366 |
|
---|
| 367 | /** DataSource wrapper for a native array. */
|
---|
| 368 | var ArrayDataSource = /** @class */ (function (_super) {
|
---|
| 369 | __extends(ArrayDataSource, _super);
|
---|
| 370 | function ArrayDataSource(_data) {
|
---|
| 371 | var _this = _super.call(this) || this;
|
---|
| 372 | _this._data = _data;
|
---|
| 373 | return _this;
|
---|
| 374 | }
|
---|
| 375 | ArrayDataSource.prototype.connect = function () {
|
---|
| 376 | return rxjs.isObservable(this._data) ? this._data : rxjs.of(this._data);
|
---|
| 377 | };
|
---|
| 378 | ArrayDataSource.prototype.disconnect = function () { };
|
---|
| 379 | return ArrayDataSource;
|
---|
| 380 | }(DataSource));
|
---|
| 381 |
|
---|
| 382 | /**
|
---|
| 383 | * @license
|
---|
| 384 | * Copyright Google LLC All Rights Reserved.
|
---|
| 385 | *
|
---|
| 386 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 387 | * found in the LICENSE file at https://angular.io/license
|
---|
| 388 | */
|
---|
| 389 | /**
|
---|
| 390 | * A repeater that destroys views when they are removed from a
|
---|
| 391 | * {@link ViewContainerRef}. When new items are inserted into the container,
|
---|
| 392 | * the repeater will always construct a new embedded view for each item.
|
---|
| 393 | *
|
---|
| 394 | * @template T The type for the embedded view's $implicit property.
|
---|
| 395 | * @template R The type for the item in each IterableDiffer change record.
|
---|
| 396 | * @template C The type for the context passed to each embedded view.
|
---|
| 397 | */
|
---|
| 398 | var _DisposeViewRepeaterStrategy = /** @class */ (function () {
|
---|
| 399 | function _DisposeViewRepeaterStrategy() {
|
---|
| 400 | }
|
---|
| 401 | _DisposeViewRepeaterStrategy.prototype.applyChanges = function (changes, viewContainerRef, itemContextFactory, itemValueResolver, itemViewChanged) {
|
---|
| 402 | changes.forEachOperation(function (record, adjustedPreviousIndex, currentIndex) {
|
---|
| 403 | var view;
|
---|
| 404 | var operation;
|
---|
| 405 | if (record.previousIndex == null) {
|
---|
| 406 | var insertContext = itemContextFactory(record, adjustedPreviousIndex, currentIndex);
|
---|
| 407 | view = viewContainerRef.createEmbeddedView(insertContext.templateRef, insertContext.context, insertContext.index);
|
---|
| 408 | operation = 1 /* INSERTED */;
|
---|
| 409 | }
|
---|
| 410 | else if (currentIndex == null) {
|
---|
| 411 | viewContainerRef.remove(adjustedPreviousIndex);
|
---|
| 412 | operation = 3 /* REMOVED */;
|
---|
| 413 | }
|
---|
| 414 | else {
|
---|
| 415 | view = viewContainerRef.get(adjustedPreviousIndex);
|
---|
| 416 | viewContainerRef.move(view, currentIndex);
|
---|
| 417 | operation = 2 /* MOVED */;
|
---|
| 418 | }
|
---|
| 419 | if (itemViewChanged) {
|
---|
| 420 | itemViewChanged({
|
---|
| 421 | context: view === null || view === void 0 ? void 0 : view.context,
|
---|
| 422 | operation: operation,
|
---|
| 423 | record: record,
|
---|
| 424 | });
|
---|
| 425 | }
|
---|
| 426 | });
|
---|
| 427 | };
|
---|
| 428 | _DisposeViewRepeaterStrategy.prototype.detach = function () {
|
---|
| 429 | };
|
---|
| 430 | return _DisposeViewRepeaterStrategy;
|
---|
| 431 | }());
|
---|
| 432 |
|
---|
| 433 | /**
|
---|
| 434 | * @license
|
---|
| 435 | * Copyright Google LLC All Rights Reserved.
|
---|
| 436 | *
|
---|
| 437 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 438 | * found in the LICENSE file at https://angular.io/license
|
---|
| 439 | */
|
---|
| 440 | /**
|
---|
| 441 | * A repeater that caches views when they are removed from a
|
---|
| 442 | * {@link ViewContainerRef}. When new items are inserted into the container,
|
---|
| 443 | * the repeater will reuse one of the cached views instead of creating a new
|
---|
| 444 | * embedded view. Recycling cached views reduces the quantity of expensive DOM
|
---|
| 445 | * inserts.
|
---|
| 446 | *
|
---|
| 447 | * @template T The type for the embedded view's $implicit property.
|
---|
| 448 | * @template R The type for the item in each IterableDiffer change record.
|
---|
| 449 | * @template C The type for the context passed to each embedded view.
|
---|
| 450 | */
|
---|
| 451 | var _RecycleViewRepeaterStrategy = /** @class */ (function () {
|
---|
| 452 | function _RecycleViewRepeaterStrategy() {
|
---|
| 453 | /**
|
---|
| 454 | * The size of the cache used to store unused views.
|
---|
| 455 | * Setting the cache size to `0` will disable caching. Defaults to 20 views.
|
---|
| 456 | */
|
---|
| 457 | this.viewCacheSize = 20;
|
---|
| 458 | /**
|
---|
| 459 | * View cache that stores embedded view instances that have been previously stamped out,
|
---|
| 460 | * but don't are not currently rendered. The view repeater will reuse these views rather than
|
---|
| 461 | * creating brand new ones.
|
---|
| 462 | *
|
---|
| 463 | * TODO(michaeljamesparsons) Investigate whether using a linked list would improve performance.
|
---|
| 464 | */
|
---|
| 465 | this._viewCache = [];
|
---|
| 466 | }
|
---|
| 467 | /** Apply changes to the DOM. */
|
---|
| 468 | _RecycleViewRepeaterStrategy.prototype.applyChanges = function (changes, viewContainerRef, itemContextFactory, itemValueResolver, itemViewChanged) {
|
---|
| 469 | var _this = this;
|
---|
| 470 | // Rearrange the views to put them in the right location.
|
---|
| 471 | changes.forEachOperation(function (record, adjustedPreviousIndex, currentIndex) {
|
---|
| 472 | var view;
|
---|
| 473 | var operation;
|
---|
| 474 | if (record.previousIndex == null) { // Item added.
|
---|
| 475 | var viewArgsFactory = function () { return itemContextFactory(record, adjustedPreviousIndex, currentIndex); };
|
---|
| 476 | view = _this._insertView(viewArgsFactory, currentIndex, viewContainerRef, itemValueResolver(record));
|
---|
| 477 | operation = view ? 1 /* INSERTED */ : 0 /* REPLACED */;
|
---|
| 478 | }
|
---|
| 479 | else if (currentIndex == null) { // Item removed.
|
---|
| 480 | _this._detachAndCacheView(adjustedPreviousIndex, viewContainerRef);
|
---|
| 481 | operation = 3 /* REMOVED */;
|
---|
| 482 | }
|
---|
| 483 | else { // Item moved.
|
---|
| 484 | view = _this._moveView(adjustedPreviousIndex, currentIndex, viewContainerRef, itemValueResolver(record));
|
---|
| 485 | operation = 2 /* MOVED */;
|
---|
| 486 | }
|
---|
| 487 | if (itemViewChanged) {
|
---|
| 488 | itemViewChanged({
|
---|
| 489 | context: view === null || view === void 0 ? void 0 : view.context,
|
---|
| 490 | operation: operation,
|
---|
| 491 | record: record,
|
---|
| 492 | });
|
---|
| 493 | }
|
---|
| 494 | });
|
---|
| 495 | };
|
---|
| 496 | _RecycleViewRepeaterStrategy.prototype.detach = function () {
|
---|
| 497 | var e_1, _a;
|
---|
| 498 | try {
|
---|
| 499 | for (var _b = __values(this._viewCache), _c = _b.next(); !_c.done; _c = _b.next()) {
|
---|
| 500 | var view = _c.value;
|
---|
| 501 | view.destroy();
|
---|
| 502 | }
|
---|
| 503 | }
|
---|
| 504 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
---|
| 505 | finally {
|
---|
| 506 | try {
|
---|
| 507 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
---|
| 508 | }
|
---|
| 509 | finally { if (e_1) throw e_1.error; }
|
---|
| 510 | }
|
---|
| 511 | this._viewCache = [];
|
---|
| 512 | };
|
---|
| 513 | /**
|
---|
| 514 | * Inserts a view for a new item, either from the cache or by creating a new
|
---|
| 515 | * one. Returns `undefined` if the item was inserted into a cached view.
|
---|
| 516 | */
|
---|
| 517 | _RecycleViewRepeaterStrategy.prototype._insertView = function (viewArgsFactory, currentIndex, viewContainerRef, value) {
|
---|
| 518 | var cachedView = this._insertViewFromCache(currentIndex, viewContainerRef);
|
---|
| 519 | if (cachedView) {
|
---|
| 520 | cachedView.context.$implicit = value;
|
---|
| 521 | return undefined;
|
---|
| 522 | }
|
---|
| 523 | var viewArgs = viewArgsFactory();
|
---|
| 524 | return viewContainerRef.createEmbeddedView(viewArgs.templateRef, viewArgs.context, viewArgs.index);
|
---|
| 525 | };
|
---|
| 526 | /** Detaches the view at the given index and inserts into the view cache. */
|
---|
| 527 | _RecycleViewRepeaterStrategy.prototype._detachAndCacheView = function (index, viewContainerRef) {
|
---|
| 528 | var detachedView = viewContainerRef.detach(index);
|
---|
| 529 | this._maybeCacheView(detachedView, viewContainerRef);
|
---|
| 530 | };
|
---|
| 531 | /** Moves view at the previous index to the current index. */
|
---|
| 532 | _RecycleViewRepeaterStrategy.prototype._moveView = function (adjustedPreviousIndex, currentIndex, viewContainerRef, value) {
|
---|
| 533 | var view = viewContainerRef.get(adjustedPreviousIndex);
|
---|
| 534 | viewContainerRef.move(view, currentIndex);
|
---|
| 535 | view.context.$implicit = value;
|
---|
| 536 | return view;
|
---|
| 537 | };
|
---|
| 538 | /**
|
---|
| 539 | * Cache the given detached view. If the cache is full, the view will be
|
---|
| 540 | * destroyed.
|
---|
| 541 | */
|
---|
| 542 | _RecycleViewRepeaterStrategy.prototype._maybeCacheView = function (view, viewContainerRef) {
|
---|
| 543 | if (this._viewCache.length < this.viewCacheSize) {
|
---|
| 544 | this._viewCache.push(view);
|
---|
| 545 | }
|
---|
| 546 | else {
|
---|
| 547 | var index = viewContainerRef.indexOf(view);
|
---|
| 548 | // The host component could remove views from the container outside of
|
---|
| 549 | // the view repeater. It's unlikely this will occur, but just in case,
|
---|
| 550 | // destroy the view on its own, otherwise destroy it through the
|
---|
| 551 | // container to ensure that all the references are removed.
|
---|
| 552 | if (index === -1) {
|
---|
| 553 | view.destroy();
|
---|
| 554 | }
|
---|
| 555 | else {
|
---|
| 556 | viewContainerRef.remove(index);
|
---|
| 557 | }
|
---|
| 558 | }
|
---|
| 559 | };
|
---|
| 560 | /** Inserts a recycled view from the cache at the given index. */
|
---|
| 561 | _RecycleViewRepeaterStrategy.prototype._insertViewFromCache = function (index, viewContainerRef) {
|
---|
| 562 | var cachedView = this._viewCache.pop();
|
---|
| 563 | if (cachedView) {
|
---|
| 564 | viewContainerRef.insert(cachedView, index);
|
---|
| 565 | }
|
---|
| 566 | return cachedView || null;
|
---|
| 567 | };
|
---|
| 568 | return _RecycleViewRepeaterStrategy;
|
---|
| 569 | }());
|
---|
| 570 |
|
---|
| 571 | /**
|
---|
| 572 | * @license
|
---|
| 573 | * Copyright Google LLC All Rights Reserved.
|
---|
| 574 | *
|
---|
| 575 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 576 | * found in the LICENSE file at https://angular.io/license
|
---|
| 577 | */
|
---|
| 578 | /**
|
---|
| 579 | * Class to be used to power selecting one or more options from a list.
|
---|
| 580 | */
|
---|
| 581 | var SelectionModel = /** @class */ (function () {
|
---|
| 582 | function SelectionModel(_multiple, initiallySelectedValues, _emitChanges) {
|
---|
| 583 | var _this = this;
|
---|
| 584 | if (_multiple === void 0) { _multiple = false; }
|
---|
| 585 | if (_emitChanges === void 0) { _emitChanges = true; }
|
---|
| 586 | this._multiple = _multiple;
|
---|
| 587 | this._emitChanges = _emitChanges;
|
---|
| 588 | /** Currently-selected values. */
|
---|
| 589 | this._selection = new Set();
|
---|
| 590 | /** Keeps track of the deselected options that haven't been emitted by the change event. */
|
---|
| 591 | this._deselectedToEmit = [];
|
---|
| 592 | /** Keeps track of the selected options that haven't been emitted by the change event. */
|
---|
| 593 | this._selectedToEmit = [];
|
---|
| 594 | /** Event emitted when the value has changed. */
|
---|
| 595 | this.changed = new rxjs.Subject();
|
---|
| 596 | if (initiallySelectedValues && initiallySelectedValues.length) {
|
---|
| 597 | if (_multiple) {
|
---|
| 598 | initiallySelectedValues.forEach(function (value) { return _this._markSelected(value); });
|
---|
| 599 | }
|
---|
| 600 | else {
|
---|
| 601 | this._markSelected(initiallySelectedValues[0]);
|
---|
| 602 | }
|
---|
| 603 | // Clear the array in order to avoid firing the change event for preselected values.
|
---|
| 604 | this._selectedToEmit.length = 0;
|
---|
| 605 | }
|
---|
| 606 | }
|
---|
| 607 | Object.defineProperty(SelectionModel.prototype, "selected", {
|
---|
| 608 | /** Selected values. */
|
---|
| 609 | get: function () {
|
---|
| 610 | if (!this._selected) {
|
---|
| 611 | this._selected = Array.from(this._selection.values());
|
---|
| 612 | }
|
---|
| 613 | return this._selected;
|
---|
| 614 | },
|
---|
| 615 | enumerable: false,
|
---|
| 616 | configurable: true
|
---|
| 617 | });
|
---|
| 618 | /**
|
---|
| 619 | * Selects a value or an array of values.
|
---|
| 620 | */
|
---|
| 621 | SelectionModel.prototype.select = function () {
|
---|
| 622 | var _this = this;
|
---|
| 623 | var values = [];
|
---|
| 624 | for (var _i = 0; _i < arguments.length; _i++) {
|
---|
| 625 | values[_i] = arguments[_i];
|
---|
| 626 | }
|
---|
| 627 | this._verifyValueAssignment(values);
|
---|
| 628 | values.forEach(function (value) { return _this._markSelected(value); });
|
---|
| 629 | this._emitChangeEvent();
|
---|
| 630 | };
|
---|
| 631 | /**
|
---|
| 632 | * Deselects a value or an array of values.
|
---|
| 633 | */
|
---|
| 634 | SelectionModel.prototype.deselect = function () {
|
---|
| 635 | var _this = this;
|
---|
| 636 | var values = [];
|
---|
| 637 | for (var _i = 0; _i < arguments.length; _i++) {
|
---|
| 638 | values[_i] = arguments[_i];
|
---|
| 639 | }
|
---|
| 640 | this._verifyValueAssignment(values);
|
---|
| 641 | values.forEach(function (value) { return _this._unmarkSelected(value); });
|
---|
| 642 | this._emitChangeEvent();
|
---|
| 643 | };
|
---|
| 644 | /**
|
---|
| 645 | * Toggles a value between selected and deselected.
|
---|
| 646 | */
|
---|
| 647 | SelectionModel.prototype.toggle = function (value) {
|
---|
| 648 | this.isSelected(value) ? this.deselect(value) : this.select(value);
|
---|
| 649 | };
|
---|
| 650 | /**
|
---|
| 651 | * Clears all of the selected values.
|
---|
| 652 | */
|
---|
| 653 | SelectionModel.prototype.clear = function () {
|
---|
| 654 | this._unmarkAll();
|
---|
| 655 | this._emitChangeEvent();
|
---|
| 656 | };
|
---|
| 657 | /**
|
---|
| 658 | * Determines whether a value is selected.
|
---|
| 659 | */
|
---|
| 660 | SelectionModel.prototype.isSelected = function (value) {
|
---|
| 661 | return this._selection.has(value);
|
---|
| 662 | };
|
---|
| 663 | /**
|
---|
| 664 | * Determines whether the model does not have a value.
|
---|
| 665 | */
|
---|
| 666 | SelectionModel.prototype.isEmpty = function () {
|
---|
| 667 | return this._selection.size === 0;
|
---|
| 668 | };
|
---|
| 669 | /**
|
---|
| 670 | * Determines whether the model has a value.
|
---|
| 671 | */
|
---|
| 672 | SelectionModel.prototype.hasValue = function () {
|
---|
| 673 | return !this.isEmpty();
|
---|
| 674 | };
|
---|
| 675 | /**
|
---|
| 676 | * Sorts the selected values based on a predicate function.
|
---|
| 677 | */
|
---|
| 678 | SelectionModel.prototype.sort = function (predicate) {
|
---|
| 679 | if (this._multiple && this.selected) {
|
---|
| 680 | this._selected.sort(predicate);
|
---|
| 681 | }
|
---|
| 682 | };
|
---|
| 683 | /**
|
---|
| 684 | * Gets whether multiple values can be selected.
|
---|
| 685 | */
|
---|
| 686 | SelectionModel.prototype.isMultipleSelection = function () {
|
---|
| 687 | return this._multiple;
|
---|
| 688 | };
|
---|
| 689 | /** Emits a change event and clears the records of selected and deselected values. */
|
---|
| 690 | SelectionModel.prototype._emitChangeEvent = function () {
|
---|
| 691 | // Clear the selected values so they can be re-cached.
|
---|
| 692 | this._selected = null;
|
---|
| 693 | if (this._selectedToEmit.length || this._deselectedToEmit.length) {
|
---|
| 694 | this.changed.next({
|
---|
| 695 | source: this,
|
---|
| 696 | added: this._selectedToEmit,
|
---|
| 697 | removed: this._deselectedToEmit
|
---|
| 698 | });
|
---|
| 699 | this._deselectedToEmit = [];
|
---|
| 700 | this._selectedToEmit = [];
|
---|
| 701 | }
|
---|
| 702 | };
|
---|
| 703 | /** Selects a value. */
|
---|
| 704 | SelectionModel.prototype._markSelected = function (value) {
|
---|
| 705 | if (!this.isSelected(value)) {
|
---|
| 706 | if (!this._multiple) {
|
---|
| 707 | this._unmarkAll();
|
---|
| 708 | }
|
---|
| 709 | this._selection.add(value);
|
---|
| 710 | if (this._emitChanges) {
|
---|
| 711 | this._selectedToEmit.push(value);
|
---|
| 712 | }
|
---|
| 713 | }
|
---|
| 714 | };
|
---|
| 715 | /** Deselects a value. */
|
---|
| 716 | SelectionModel.prototype._unmarkSelected = function (value) {
|
---|
| 717 | if (this.isSelected(value)) {
|
---|
| 718 | this._selection.delete(value);
|
---|
| 719 | if (this._emitChanges) {
|
---|
| 720 | this._deselectedToEmit.push(value);
|
---|
| 721 | }
|
---|
| 722 | }
|
---|
| 723 | };
|
---|
| 724 | /** Clears out the selected values. */
|
---|
| 725 | SelectionModel.prototype._unmarkAll = function () {
|
---|
| 726 | var _this = this;
|
---|
| 727 | if (!this.isEmpty()) {
|
---|
| 728 | this._selection.forEach(function (value) { return _this._unmarkSelected(value); });
|
---|
| 729 | }
|
---|
| 730 | };
|
---|
| 731 | /**
|
---|
| 732 | * Verifies the value assignment and throws an error if the specified value array is
|
---|
| 733 | * including multiple values while the selection model is not supporting multiple values.
|
---|
| 734 | */
|
---|
| 735 | SelectionModel.prototype._verifyValueAssignment = function (values) {
|
---|
| 736 | if (values.length > 1 && !this._multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
---|
| 737 | throw getMultipleValuesInSingleSelectionError();
|
---|
| 738 | }
|
---|
| 739 | };
|
---|
| 740 | return SelectionModel;
|
---|
| 741 | }());
|
---|
| 742 | /**
|
---|
| 743 | * Returns an error that reports that multiple values are passed into a selection model
|
---|
| 744 | * with a single value.
|
---|
| 745 | * @docs-private
|
---|
| 746 | */
|
---|
| 747 | function getMultipleValuesInSingleSelectionError() {
|
---|
| 748 | return Error('Cannot pass multiple values into SelectionModel with single-value mode.');
|
---|
| 749 | }
|
---|
| 750 |
|
---|
| 751 | /**
|
---|
| 752 | * Class to coordinate unique selection based on name.
|
---|
| 753 | * Intended to be consumed as an Angular service.
|
---|
| 754 | * This service is needed because native radio change events are only fired on the item currently
|
---|
| 755 | * being selected, and we still need to uncheck the previous selection.
|
---|
| 756 | *
|
---|
| 757 | * This service does not *store* any IDs and names because they may change at any time, so it is
|
---|
| 758 | * less error-prone if they are simply passed through when the events occur.
|
---|
| 759 | */
|
---|
| 760 | var UniqueSelectionDispatcher = /** @class */ (function () {
|
---|
| 761 | function UniqueSelectionDispatcher() {
|
---|
| 762 | this._listeners = [];
|
---|
| 763 | }
|
---|
| 764 | /**
|
---|
| 765 | * Notify other items that selection for the given name has been set.
|
---|
| 766 | * @param id ID of the item.
|
---|
| 767 | * @param name Name of the item.
|
---|
| 768 | */
|
---|
| 769 | UniqueSelectionDispatcher.prototype.notify = function (id, name) {
|
---|
| 770 | var e_1, _a;
|
---|
| 771 | try {
|
---|
| 772 | for (var _b = __values(this._listeners), _c = _b.next(); !_c.done; _c = _b.next()) {
|
---|
| 773 | var listener = _c.value;
|
---|
| 774 | listener(id, name);
|
---|
| 775 | }
|
---|
| 776 | }
|
---|
| 777 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
---|
| 778 | finally {
|
---|
| 779 | try {
|
---|
| 780 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
---|
| 781 | }
|
---|
| 782 | finally { if (e_1) throw e_1.error; }
|
---|
| 783 | }
|
---|
| 784 | };
|
---|
| 785 | /**
|
---|
| 786 | * Listen for future changes to item selection.
|
---|
| 787 | * @return Function used to deregister listener
|
---|
| 788 | */
|
---|
| 789 | UniqueSelectionDispatcher.prototype.listen = function (listener) {
|
---|
| 790 | var _this = this;
|
---|
| 791 | this._listeners.push(listener);
|
---|
| 792 | return function () {
|
---|
| 793 | _this._listeners = _this._listeners.filter(function (registered) {
|
---|
| 794 | return listener !== registered;
|
---|
| 795 | });
|
---|
| 796 | };
|
---|
| 797 | };
|
---|
| 798 | UniqueSelectionDispatcher.prototype.ngOnDestroy = function () {
|
---|
| 799 | this._listeners = [];
|
---|
| 800 | };
|
---|
| 801 | return UniqueSelectionDispatcher;
|
---|
| 802 | }());
|
---|
| 803 | UniqueSelectionDispatcher.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function UniqueSelectionDispatcher_Factory() { return new UniqueSelectionDispatcher(); }, token: UniqueSelectionDispatcher, providedIn: "root" });
|
---|
| 804 | UniqueSelectionDispatcher.decorators = [
|
---|
| 805 | { type: i0.Injectable, args: [{ providedIn: 'root' },] }
|
---|
| 806 | ];
|
---|
| 807 |
|
---|
| 808 | /**
|
---|
| 809 | * @license
|
---|
| 810 | * Copyright Google LLC All Rights Reserved.
|
---|
| 811 | *
|
---|
| 812 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 813 | * found in the LICENSE file at https://angular.io/license
|
---|
| 814 | */
|
---|
| 815 | /**
|
---|
| 816 | * Injection token for {@link _ViewRepeater}. This token is for use by Angular Material only.
|
---|
| 817 | * @docs-private
|
---|
| 818 | */
|
---|
| 819 | var _VIEW_REPEATER_STRATEGY = new i0.InjectionToken('_ViewRepeater');
|
---|
| 820 |
|
---|
| 821 | /**
|
---|
| 822 | * @license
|
---|
| 823 | * Copyright Google LLC All Rights Reserved.
|
---|
| 824 | *
|
---|
| 825 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 826 | * found in the LICENSE file at https://angular.io/license
|
---|
| 827 | */
|
---|
| 828 |
|
---|
| 829 | /**
|
---|
| 830 | * Generated bundle index. Do not edit.
|
---|
| 831 | */
|
---|
| 832 |
|
---|
| 833 | exports.ArrayDataSource = ArrayDataSource;
|
---|
| 834 | exports.DataSource = DataSource;
|
---|
| 835 | exports.SelectionModel = SelectionModel;
|
---|
| 836 | exports.UniqueSelectionDispatcher = UniqueSelectionDispatcher;
|
---|
| 837 | exports._DisposeViewRepeaterStrategy = _DisposeViewRepeaterStrategy;
|
---|
| 838 | exports._RecycleViewRepeaterStrategy = _RecycleViewRepeaterStrategy;
|
---|
| 839 | exports._VIEW_REPEATER_STRATEGY = _VIEW_REPEATER_STRATEGY;
|
---|
| 840 | exports.getMultipleValuesInSingleSelectionError = getMultipleValuesInSingleSelectionError;
|
---|
| 841 | exports.isDataSource = isDataSource;
|
---|
| 842 |
|
---|
| 843 | Object.defineProperty(exports, '__esModule', { value: true });
|
---|
| 844 |
|
---|
| 845 | })));
|
---|
| 846 | //# sourceMappingURL=cdk-collections.umd.js.map
|
---|