[6a3a178] | 1 | (function (global, factory) {
|
---|
| 2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/keycodes'), require('@angular/core'), require('@angular/material/core'), require('@angular/cdk/coercion'), require('@angular/cdk/platform'), require('@angular/common'), require('@angular/platform-browser/animations'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/a11y'), require('@angular/cdk/bidi'), require('@angular/cdk/collections'), require('@angular/forms'), require('@angular/material/form-field')) :
|
---|
| 3 | typeof define === 'function' && define.amd ? define('@angular/material/chips', ['exports', '@angular/cdk/keycodes', '@angular/core', '@angular/material/core', '@angular/cdk/coercion', '@angular/cdk/platform', '@angular/common', '@angular/platform-browser/animations', 'rxjs', 'rxjs/operators', '@angular/cdk/a11y', '@angular/cdk/bidi', '@angular/cdk/collections', '@angular/forms', '@angular/material/form-field'], factory) :
|
---|
| 4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.chips = {}), global.ng.cdk.keycodes, global.ng.core, global.ng.material.core, global.ng.cdk.coercion, global.ng.cdk.platform, global.ng.common, global.ng.platformBrowser.animations, global.rxjs, global.rxjs.operators, global.ng.cdk.a11y, global.ng.cdk.bidi, global.ng.cdk.collections, global.ng.forms, global.ng.material.formField));
|
---|
| 5 | }(this, (function (exports, keycodes, core, core$1, coercion, platform, common, animations, rxjs, operators, a11y, bidi, collections, forms, formField) { 'use strict';
|
---|
| 6 |
|
---|
| 7 | /*! *****************************************************************************
|
---|
| 8 | Copyright (c) Microsoft Corporation.
|
---|
| 9 |
|
---|
| 10 | Permission to use, copy, modify, and/or distribute this software for any
|
---|
| 11 | purpose with or without fee is hereby granted.
|
---|
| 12 |
|
---|
| 13 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
---|
| 14 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
---|
| 15 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
---|
| 16 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
---|
| 17 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
---|
| 18 | OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
---|
| 19 | PERFORMANCE OF THIS SOFTWARE.
|
---|
| 20 | ***************************************************************************** */
|
---|
| 21 | /* global Reflect, Promise */
|
---|
| 22 | var extendStatics = function (d, b) {
|
---|
| 23 | extendStatics = Object.setPrototypeOf ||
|
---|
| 24 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
---|
| 25 | function (d, b) { for (var p in b)
|
---|
| 26 | if (Object.prototype.hasOwnProperty.call(b, p))
|
---|
| 27 | d[p] = b[p]; };
|
---|
| 28 | return extendStatics(d, b);
|
---|
| 29 | };
|
---|
| 30 | function __extends(d, b) {
|
---|
| 31 | if (typeof b !== "function" && b !== null)
|
---|
| 32 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
---|
| 33 | extendStatics(d, b);
|
---|
| 34 | function __() { this.constructor = d; }
|
---|
| 35 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
---|
| 36 | }
|
---|
| 37 | var __assign = function () {
|
---|
| 38 | __assign = Object.assign || function __assign(t) {
|
---|
| 39 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
---|
| 40 | s = arguments[i];
|
---|
| 41 | for (var p in s)
|
---|
| 42 | if (Object.prototype.hasOwnProperty.call(s, p))
|
---|
| 43 | t[p] = s[p];
|
---|
| 44 | }
|
---|
| 45 | return t;
|
---|
| 46 | };
|
---|
| 47 | return __assign.apply(this, arguments);
|
---|
| 48 | };
|
---|
| 49 | function __rest(s, e) {
|
---|
| 50 | var t = {};
|
---|
| 51 | for (var p in s)
|
---|
| 52 | if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
---|
| 53 | t[p] = s[p];
|
---|
| 54 | if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
---|
| 55 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
---|
| 56 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
---|
| 57 | t[p[i]] = s[p[i]];
|
---|
| 58 | }
|
---|
| 59 | return t;
|
---|
| 60 | }
|
---|
| 61 | function __decorate(decorators, target, key, desc) {
|
---|
| 62 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
---|
| 63 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
---|
| 64 | r = Reflect.decorate(decorators, target, key, desc);
|
---|
| 65 | else
|
---|
| 66 | for (var i = decorators.length - 1; i >= 0; i--)
|
---|
| 67 | if (d = decorators[i])
|
---|
| 68 | r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
---|
| 69 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
---|
| 70 | }
|
---|
| 71 | function __param(paramIndex, decorator) {
|
---|
| 72 | return function (target, key) { decorator(target, key, paramIndex); };
|
---|
| 73 | }
|
---|
| 74 | function __metadata(metadataKey, metadataValue) {
|
---|
| 75 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
---|
| 76 | return Reflect.metadata(metadataKey, metadataValue);
|
---|
| 77 | }
|
---|
| 78 | function __awaiter(thisArg, _arguments, P, generator) {
|
---|
| 79 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
---|
| 80 | return new (P || (P = Promise))(function (resolve, reject) {
|
---|
| 81 | function fulfilled(value) { try {
|
---|
| 82 | step(generator.next(value));
|
---|
| 83 | }
|
---|
| 84 | catch (e) {
|
---|
| 85 | reject(e);
|
---|
| 86 | } }
|
---|
| 87 | function rejected(value) { try {
|
---|
| 88 | step(generator["throw"](value));
|
---|
| 89 | }
|
---|
| 90 | catch (e) {
|
---|
| 91 | reject(e);
|
---|
| 92 | } }
|
---|
| 93 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
---|
| 94 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
---|
| 95 | });
|
---|
| 96 | }
|
---|
| 97 | function __generator(thisArg, body) {
|
---|
| 98 | var _ = { label: 0, sent: function () { if (t[0] & 1)
|
---|
| 99 | throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
---|
| 100 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
|
---|
| 101 | function verb(n) { return function (v) { return step([n, v]); }; }
|
---|
| 102 | function step(op) {
|
---|
| 103 | if (f)
|
---|
| 104 | throw new TypeError("Generator is already executing.");
|
---|
| 105 | while (_)
|
---|
| 106 | try {
|
---|
| 107 | 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)
|
---|
| 108 | return t;
|
---|
| 109 | if (y = 0, t)
|
---|
| 110 | op = [op[0] & 2, t.value];
|
---|
| 111 | switch (op[0]) {
|
---|
| 112 | case 0:
|
---|
| 113 | case 1:
|
---|
| 114 | t = op;
|
---|
| 115 | break;
|
---|
| 116 | case 4:
|
---|
| 117 | _.label++;
|
---|
| 118 | return { value: op[1], done: false };
|
---|
| 119 | case 5:
|
---|
| 120 | _.label++;
|
---|
| 121 | y = op[1];
|
---|
| 122 | op = [0];
|
---|
| 123 | continue;
|
---|
| 124 | case 7:
|
---|
| 125 | op = _.ops.pop();
|
---|
| 126 | _.trys.pop();
|
---|
| 127 | continue;
|
---|
| 128 | default:
|
---|
| 129 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
---|
| 130 | _ = 0;
|
---|
| 131 | continue;
|
---|
| 132 | }
|
---|
| 133 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
---|
| 134 | _.label = op[1];
|
---|
| 135 | break;
|
---|
| 136 | }
|
---|
| 137 | if (op[0] === 6 && _.label < t[1]) {
|
---|
| 138 | _.label = t[1];
|
---|
| 139 | t = op;
|
---|
| 140 | break;
|
---|
| 141 | }
|
---|
| 142 | if (t && _.label < t[2]) {
|
---|
| 143 | _.label = t[2];
|
---|
| 144 | _.ops.push(op);
|
---|
| 145 | break;
|
---|
| 146 | }
|
---|
| 147 | if (t[2])
|
---|
| 148 | _.ops.pop();
|
---|
| 149 | _.trys.pop();
|
---|
| 150 | continue;
|
---|
| 151 | }
|
---|
| 152 | op = body.call(thisArg, _);
|
---|
| 153 | }
|
---|
| 154 | catch (e) {
|
---|
| 155 | op = [6, e];
|
---|
| 156 | y = 0;
|
---|
| 157 | }
|
---|
| 158 | finally {
|
---|
| 159 | f = t = 0;
|
---|
| 160 | }
|
---|
| 161 | if (op[0] & 5)
|
---|
| 162 | throw op[1];
|
---|
| 163 | return { value: op[0] ? op[1] : void 0, done: true };
|
---|
| 164 | }
|
---|
| 165 | }
|
---|
| 166 | var __createBinding = Object.create ? (function (o, m, k, k2) {
|
---|
| 167 | if (k2 === undefined)
|
---|
| 168 | k2 = k;
|
---|
| 169 | Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
|
---|
| 170 | }) : (function (o, m, k, k2) {
|
---|
| 171 | if (k2 === undefined)
|
---|
| 172 | k2 = k;
|
---|
| 173 | o[k2] = m[k];
|
---|
| 174 | });
|
---|
| 175 | function __exportStar(m, o) {
|
---|
| 176 | for (var p in m)
|
---|
| 177 | if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
|
---|
| 178 | __createBinding(o, m, p);
|
---|
| 179 | }
|
---|
| 180 | function __values(o) {
|
---|
| 181 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
---|
| 182 | if (m)
|
---|
| 183 | return m.call(o);
|
---|
| 184 | if (o && typeof o.length === "number")
|
---|
| 185 | return {
|
---|
| 186 | next: function () {
|
---|
| 187 | if (o && i >= o.length)
|
---|
| 188 | o = void 0;
|
---|
| 189 | return { value: o && o[i++], done: !o };
|
---|
| 190 | }
|
---|
| 191 | };
|
---|
| 192 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
---|
| 193 | }
|
---|
| 194 | function __read(o, n) {
|
---|
| 195 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
---|
| 196 | if (!m)
|
---|
| 197 | return o;
|
---|
| 198 | var i = m.call(o), r, ar = [], e;
|
---|
| 199 | try {
|
---|
| 200 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
---|
| 201 | ar.push(r.value);
|
---|
| 202 | }
|
---|
| 203 | catch (error) {
|
---|
| 204 | e = { error: error };
|
---|
| 205 | }
|
---|
| 206 | finally {
|
---|
| 207 | try {
|
---|
| 208 | if (r && !r.done && (m = i["return"]))
|
---|
| 209 | m.call(i);
|
---|
| 210 | }
|
---|
| 211 | finally {
|
---|
| 212 | if (e)
|
---|
| 213 | throw e.error;
|
---|
| 214 | }
|
---|
| 215 | }
|
---|
| 216 | return ar;
|
---|
| 217 | }
|
---|
| 218 | /** @deprecated */
|
---|
| 219 | function __spread() {
|
---|
| 220 | for (var ar = [], i = 0; i < arguments.length; i++)
|
---|
| 221 | ar = ar.concat(__read(arguments[i]));
|
---|
| 222 | return ar;
|
---|
| 223 | }
|
---|
| 224 | /** @deprecated */
|
---|
| 225 | function __spreadArrays() {
|
---|
| 226 | for (var s = 0, i = 0, il = arguments.length; i < il; i++)
|
---|
| 227 | s += arguments[i].length;
|
---|
| 228 | for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
---|
| 229 | for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
---|
| 230 | r[k] = a[j];
|
---|
| 231 | return r;
|
---|
| 232 | }
|
---|
| 233 | function __spreadArray(to, from, pack) {
|
---|
| 234 | if (pack || arguments.length === 2)
|
---|
| 235 | for (var i = 0, l = from.length, ar; i < l; i++) {
|
---|
| 236 | if (ar || !(i in from)) {
|
---|
| 237 | if (!ar)
|
---|
| 238 | ar = Array.prototype.slice.call(from, 0, i);
|
---|
| 239 | ar[i] = from[i];
|
---|
| 240 | }
|
---|
| 241 | }
|
---|
| 242 | return to.concat(ar || from);
|
---|
| 243 | }
|
---|
| 244 | function __await(v) {
|
---|
| 245 | return this instanceof __await ? (this.v = v, this) : new __await(v);
|
---|
| 246 | }
|
---|
| 247 | function __asyncGenerator(thisArg, _arguments, generator) {
|
---|
| 248 | if (!Symbol.asyncIterator)
|
---|
| 249 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
| 250 | var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
---|
| 251 | return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
---|
| 252 | function verb(n) { if (g[n])
|
---|
| 253 | i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
---|
| 254 | function resume(n, v) { try {
|
---|
| 255 | step(g[n](v));
|
---|
| 256 | }
|
---|
| 257 | catch (e) {
|
---|
| 258 | settle(q[0][3], e);
|
---|
| 259 | } }
|
---|
| 260 | function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
---|
| 261 | function fulfill(value) { resume("next", value); }
|
---|
| 262 | function reject(value) { resume("throw", value); }
|
---|
| 263 | function settle(f, v) { if (f(v), q.shift(), q.length)
|
---|
| 264 | resume(q[0][0], q[0][1]); }
|
---|
| 265 | }
|
---|
| 266 | function __asyncDelegator(o) {
|
---|
| 267 | var i, p;
|
---|
| 268 | return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
---|
| 269 | 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; }
|
---|
| 270 | }
|
---|
| 271 | function __asyncValues(o) {
|
---|
| 272 | if (!Symbol.asyncIterator)
|
---|
| 273 | throw new TypeError("Symbol.asyncIterator is not defined.");
|
---|
| 274 | var m = o[Symbol.asyncIterator], i;
|
---|
| 275 | 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);
|
---|
| 276 | 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); }); }; }
|
---|
| 277 | function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
|
---|
| 278 | }
|
---|
| 279 | function __makeTemplateObject(cooked, raw) {
|
---|
| 280 | if (Object.defineProperty) {
|
---|
| 281 | Object.defineProperty(cooked, "raw", { value: raw });
|
---|
| 282 | }
|
---|
| 283 | else {
|
---|
| 284 | cooked.raw = raw;
|
---|
| 285 | }
|
---|
| 286 | return cooked;
|
---|
| 287 | }
|
---|
| 288 | ;
|
---|
| 289 | var __setModuleDefault = Object.create ? (function (o, v) {
|
---|
| 290 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
---|
| 291 | }) : function (o, v) {
|
---|
| 292 | o["default"] = v;
|
---|
| 293 | };
|
---|
| 294 | function __importStar(mod) {
|
---|
| 295 | if (mod && mod.__esModule)
|
---|
| 296 | return mod;
|
---|
| 297 | var result = {};
|
---|
| 298 | if (mod != null)
|
---|
| 299 | for (var k in mod)
|
---|
| 300 | if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
|
---|
| 301 | __createBinding(result, mod, k);
|
---|
| 302 | __setModuleDefault(result, mod);
|
---|
| 303 | return result;
|
---|
| 304 | }
|
---|
| 305 | function __importDefault(mod) {
|
---|
| 306 | return (mod && mod.__esModule) ? mod : { default: mod };
|
---|
| 307 | }
|
---|
| 308 | function __classPrivateFieldGet(receiver, state, kind, f) {
|
---|
| 309 | if (kind === "a" && !f)
|
---|
| 310 | throw new TypeError("Private accessor was defined without a getter");
|
---|
| 311 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
| 312 | throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
---|
| 313 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
---|
| 314 | }
|
---|
| 315 | function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
---|
| 316 | if (kind === "m")
|
---|
| 317 | throw new TypeError("Private method is not writable");
|
---|
| 318 | if (kind === "a" && !f)
|
---|
| 319 | throw new TypeError("Private accessor was defined without a setter");
|
---|
| 320 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
---|
| 321 | throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
---|
| 322 | return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | /** Event object emitted by MatChip when selected or deselected. */
|
---|
| 326 | var MatChipSelectionChange = /** @class */ (function () {
|
---|
| 327 | function MatChipSelectionChange(
|
---|
| 328 | /** Reference to the chip that emitted the event. */
|
---|
| 329 | source,
|
---|
| 330 | /** Whether the chip that emitted the event is selected. */
|
---|
| 331 | selected,
|
---|
| 332 | /** Whether the selection change was a result of a user interaction. */
|
---|
| 333 | isUserInput) {
|
---|
| 334 | if (isUserInput === void 0) { isUserInput = false; }
|
---|
| 335 | this.source = source;
|
---|
| 336 | this.selected = selected;
|
---|
| 337 | this.isUserInput = isUserInput;
|
---|
| 338 | }
|
---|
| 339 | return MatChipSelectionChange;
|
---|
| 340 | }());
|
---|
| 341 | /**
|
---|
| 342 | * Injection token that can be used to reference instances of `MatChipRemove`. It serves as
|
---|
| 343 | * alternative token to the actual `MatChipRemove` class which could cause unnecessary
|
---|
| 344 | * retention of the class and its directive metadata.
|
---|
| 345 | */
|
---|
| 346 | var MAT_CHIP_REMOVE = new core.InjectionToken('MatChipRemove');
|
---|
| 347 | /**
|
---|
| 348 | * Injection token that can be used to reference instances of `MatChipAvatar`. It serves as
|
---|
| 349 | * alternative token to the actual `MatChipAvatar` class which could cause unnecessary
|
---|
| 350 | * retention of the class and its directive metadata.
|
---|
| 351 | */
|
---|
| 352 | var MAT_CHIP_AVATAR = new core.InjectionToken('MatChipAvatar');
|
---|
| 353 | /**
|
---|
| 354 | * Injection token that can be used to reference instances of `MatChipTrailingIcon`. It serves as
|
---|
| 355 | * alternative token to the actual `MatChipTrailingIcon` class which could cause unnecessary
|
---|
| 356 | * retention of the class and its directive metadata.
|
---|
| 357 | */
|
---|
| 358 | var MAT_CHIP_TRAILING_ICON = new core.InjectionToken('MatChipTrailingIcon');
|
---|
| 359 | // Boilerplate for applying mixins to MatChip.
|
---|
| 360 | /** @docs-private */
|
---|
| 361 | var MatChipBase = /** @class */ (function () {
|
---|
| 362 | function MatChipBase(_elementRef) {
|
---|
| 363 | this._elementRef = _elementRef;
|
---|
| 364 | }
|
---|
| 365 | return MatChipBase;
|
---|
| 366 | }());
|
---|
| 367 | var _MatChipMixinBase = core$1.mixinTabIndex(core$1.mixinColor(core$1.mixinDisableRipple(MatChipBase), 'primary'), -1);
|
---|
| 368 | /**
|
---|
| 369 | * Dummy directive to add CSS class to chip avatar.
|
---|
| 370 | * @docs-private
|
---|
| 371 | */
|
---|
| 372 | var MatChipAvatar = /** @class */ (function () {
|
---|
| 373 | function MatChipAvatar() {
|
---|
| 374 | }
|
---|
| 375 | return MatChipAvatar;
|
---|
| 376 | }());
|
---|
| 377 | MatChipAvatar.decorators = [
|
---|
| 378 | { type: core.Directive, args: [{
|
---|
| 379 | selector: 'mat-chip-avatar, [matChipAvatar]',
|
---|
| 380 | host: { 'class': 'mat-chip-avatar' },
|
---|
| 381 | providers: [{ provide: MAT_CHIP_AVATAR, useExisting: MatChipAvatar }]
|
---|
| 382 | },] }
|
---|
| 383 | ];
|
---|
| 384 | /**
|
---|
| 385 | * Dummy directive to add CSS class to chip trailing icon.
|
---|
| 386 | * @docs-private
|
---|
| 387 | */
|
---|
| 388 | var MatChipTrailingIcon = /** @class */ (function () {
|
---|
| 389 | function MatChipTrailingIcon() {
|
---|
| 390 | }
|
---|
| 391 | return MatChipTrailingIcon;
|
---|
| 392 | }());
|
---|
| 393 | MatChipTrailingIcon.decorators = [
|
---|
| 394 | { type: core.Directive, args: [{
|
---|
| 395 | selector: 'mat-chip-trailing-icon, [matChipTrailingIcon]',
|
---|
| 396 | host: { 'class': 'mat-chip-trailing-icon' },
|
---|
| 397 | providers: [{ provide: MAT_CHIP_TRAILING_ICON, useExisting: MatChipTrailingIcon }],
|
---|
| 398 | },] }
|
---|
| 399 | ];
|
---|
| 400 | /**
|
---|
| 401 | * Material design styled Chip component. Used inside the MatChipList component.
|
---|
| 402 | */
|
---|
| 403 | var MatChip = /** @class */ (function (_super) {
|
---|
| 404 | __extends(MatChip, _super);
|
---|
| 405 | function MatChip(elementRef, _ngZone, platform, globalRippleOptions, _changeDetectorRef, _document, animationMode, tabIndex) {
|
---|
| 406 | var _this = _super.call(this, elementRef) || this;
|
---|
| 407 | _this._ngZone = _ngZone;
|
---|
| 408 | _this._changeDetectorRef = _changeDetectorRef;
|
---|
| 409 | /** Whether the chip has focus. */
|
---|
| 410 | _this._hasFocus = false;
|
---|
| 411 | /** Whether the chip list is selectable */
|
---|
| 412 | _this.chipListSelectable = true;
|
---|
| 413 | /** Whether the chip list is in multi-selection mode. */
|
---|
| 414 | _this._chipListMultiple = false;
|
---|
| 415 | /** Whether the chip list as a whole is disabled. */
|
---|
| 416 | _this._chipListDisabled = false;
|
---|
| 417 | _this._selected = false;
|
---|
| 418 | _this._selectable = true;
|
---|
| 419 | _this._disabled = false;
|
---|
| 420 | _this._removable = true;
|
---|
| 421 | /** Emits when the chip is focused. */
|
---|
| 422 | _this._onFocus = new rxjs.Subject();
|
---|
| 423 | /** Emits when the chip is blured. */
|
---|
| 424 | _this._onBlur = new rxjs.Subject();
|
---|
| 425 | /** Emitted when the chip is selected or deselected. */
|
---|
| 426 | _this.selectionChange = new core.EventEmitter();
|
---|
| 427 | /** Emitted when the chip is destroyed. */
|
---|
| 428 | _this.destroyed = new core.EventEmitter();
|
---|
| 429 | /** Emitted when a chip is to be removed. */
|
---|
| 430 | _this.removed = new core.EventEmitter();
|
---|
| 431 | _this._addHostClassName();
|
---|
| 432 | // Dynamically create the ripple target, append it within the chip, and use it as the
|
---|
| 433 | // chip's ripple target. Adding the class '.mat-chip-ripple' ensures that it will have
|
---|
| 434 | // the proper styles.
|
---|
| 435 | _this._chipRippleTarget = _document.createElement('div');
|
---|
| 436 | _this._chipRippleTarget.classList.add('mat-chip-ripple');
|
---|
| 437 | _this._elementRef.nativeElement.appendChild(_this._chipRippleTarget);
|
---|
| 438 | _this._chipRipple = new core$1.RippleRenderer(_this, _ngZone, _this._chipRippleTarget, platform);
|
---|
| 439 | _this._chipRipple.setupTriggerEvents(elementRef);
|
---|
| 440 | _this.rippleConfig = globalRippleOptions || {};
|
---|
| 441 | _this._animationsDisabled = animationMode === 'NoopAnimations';
|
---|
| 442 | _this.tabIndex = tabIndex != null ? (parseInt(tabIndex) || -1) : -1;
|
---|
| 443 | return _this;
|
---|
| 444 | }
|
---|
| 445 | Object.defineProperty(MatChip.prototype, "rippleDisabled", {
|
---|
| 446 | /**
|
---|
| 447 | * Whether ripples are disabled on interaction
|
---|
| 448 | * @docs-private
|
---|
| 449 | */
|
---|
| 450 | get: function () {
|
---|
| 451 | return this.disabled || this.disableRipple || this._animationsDisabled ||
|
---|
| 452 | !!this.rippleConfig.disabled;
|
---|
| 453 | },
|
---|
| 454 | enumerable: false,
|
---|
| 455 | configurable: true
|
---|
| 456 | });
|
---|
| 457 | Object.defineProperty(MatChip.prototype, "selected", {
|
---|
| 458 | /** Whether the chip is selected. */
|
---|
| 459 | get: function () { return this._selected; },
|
---|
| 460 | set: function (value) {
|
---|
| 461 | var coercedValue = coercion.coerceBooleanProperty(value);
|
---|
| 462 | if (coercedValue !== this._selected) {
|
---|
| 463 | this._selected = coercedValue;
|
---|
| 464 | this._dispatchSelectionChange();
|
---|
| 465 | }
|
---|
| 466 | },
|
---|
| 467 | enumerable: false,
|
---|
| 468 | configurable: true
|
---|
| 469 | });
|
---|
| 470 | Object.defineProperty(MatChip.prototype, "value", {
|
---|
| 471 | /** The value of the chip. Defaults to the content inside `<mat-chip>` tags. */
|
---|
| 472 | get: function () {
|
---|
| 473 | return this._value !== undefined
|
---|
| 474 | ? this._value
|
---|
| 475 | : this._elementRef.nativeElement.textContent;
|
---|
| 476 | },
|
---|
| 477 | set: function (value) { this._value = value; },
|
---|
| 478 | enumerable: false,
|
---|
| 479 | configurable: true
|
---|
| 480 | });
|
---|
| 481 | Object.defineProperty(MatChip.prototype, "selectable", {
|
---|
| 482 | /**
|
---|
| 483 | * Whether or not the chip is selectable. When a chip is not selectable,
|
---|
| 484 | * changes to its selected state are always ignored. By default a chip is
|
---|
| 485 | * selectable, and it becomes non-selectable if its parent chip list is
|
---|
| 486 | * not selectable.
|
---|
| 487 | */
|
---|
| 488 | get: function () { return this._selectable && this.chipListSelectable; },
|
---|
| 489 | set: function (value) {
|
---|
| 490 | this._selectable = coercion.coerceBooleanProperty(value);
|
---|
| 491 | },
|
---|
| 492 | enumerable: false,
|
---|
| 493 | configurable: true
|
---|
| 494 | });
|
---|
| 495 | Object.defineProperty(MatChip.prototype, "disabled", {
|
---|
| 496 | /** Whether the chip is disabled. */
|
---|
| 497 | get: function () { return this._chipListDisabled || this._disabled; },
|
---|
| 498 | set: function (value) {
|
---|
| 499 | this._disabled = coercion.coerceBooleanProperty(value);
|
---|
| 500 | },
|
---|
| 501 | enumerable: false,
|
---|
| 502 | configurable: true
|
---|
| 503 | });
|
---|
| 504 | Object.defineProperty(MatChip.prototype, "removable", {
|
---|
| 505 | /**
|
---|
| 506 | * Determines whether or not the chip displays the remove styling and emits (removed) events.
|
---|
| 507 | */
|
---|
| 508 | get: function () { return this._removable; },
|
---|
| 509 | set: function (value) {
|
---|
| 510 | this._removable = coercion.coerceBooleanProperty(value);
|
---|
| 511 | },
|
---|
| 512 | enumerable: false,
|
---|
| 513 | configurable: true
|
---|
| 514 | });
|
---|
| 515 | Object.defineProperty(MatChip.prototype, "ariaSelected", {
|
---|
| 516 | /** The ARIA selected applied to the chip. */
|
---|
| 517 | get: function () {
|
---|
| 518 | // Remove the `aria-selected` when the chip is deselected in single-selection mode, because
|
---|
| 519 | // it adds noise to NVDA users where "not selected" will be read out for each chip.
|
---|
| 520 | return this.selectable && (this._chipListMultiple || this.selected) ?
|
---|
| 521 | this.selected.toString() : null;
|
---|
| 522 | },
|
---|
| 523 | enumerable: false,
|
---|
| 524 | configurable: true
|
---|
| 525 | });
|
---|
| 526 | MatChip.prototype._addHostClassName = function () {
|
---|
| 527 | var basicChipAttrName = 'mat-basic-chip';
|
---|
| 528 | var element = this._elementRef.nativeElement;
|
---|
| 529 | if (element.hasAttribute(basicChipAttrName) ||
|
---|
| 530 | element.tagName.toLowerCase() === basicChipAttrName) {
|
---|
| 531 | element.classList.add(basicChipAttrName);
|
---|
| 532 | return;
|
---|
| 533 | }
|
---|
| 534 | else {
|
---|
| 535 | element.classList.add('mat-standard-chip');
|
---|
| 536 | }
|
---|
| 537 | };
|
---|
| 538 | MatChip.prototype.ngOnDestroy = function () {
|
---|
| 539 | this.destroyed.emit({ chip: this });
|
---|
| 540 | this._chipRipple._removeTriggerEvents();
|
---|
| 541 | };
|
---|
| 542 | /** Selects the chip. */
|
---|
| 543 | MatChip.prototype.select = function () {
|
---|
| 544 | if (!this._selected) {
|
---|
| 545 | this._selected = true;
|
---|
| 546 | this._dispatchSelectionChange();
|
---|
| 547 | this._changeDetectorRef.markForCheck();
|
---|
| 548 | }
|
---|
| 549 | };
|
---|
| 550 | /** Deselects the chip. */
|
---|
| 551 | MatChip.prototype.deselect = function () {
|
---|
| 552 | if (this._selected) {
|
---|
| 553 | this._selected = false;
|
---|
| 554 | this._dispatchSelectionChange();
|
---|
| 555 | this._changeDetectorRef.markForCheck();
|
---|
| 556 | }
|
---|
| 557 | };
|
---|
| 558 | /** Select this chip and emit selected event */
|
---|
| 559 | MatChip.prototype.selectViaInteraction = function () {
|
---|
| 560 | if (!this._selected) {
|
---|
| 561 | this._selected = true;
|
---|
| 562 | this._dispatchSelectionChange(true);
|
---|
| 563 | this._changeDetectorRef.markForCheck();
|
---|
| 564 | }
|
---|
| 565 | };
|
---|
| 566 | /** Toggles the current selected state of this chip. */
|
---|
| 567 | MatChip.prototype.toggleSelected = function (isUserInput) {
|
---|
| 568 | if (isUserInput === void 0) { isUserInput = false; }
|
---|
| 569 | this._selected = !this.selected;
|
---|
| 570 | this._dispatchSelectionChange(isUserInput);
|
---|
| 571 | this._changeDetectorRef.markForCheck();
|
---|
| 572 | return this.selected;
|
---|
| 573 | };
|
---|
| 574 | /** Allows for programmatic focusing of the chip. */
|
---|
| 575 | MatChip.prototype.focus = function () {
|
---|
| 576 | if (!this._hasFocus) {
|
---|
| 577 | this._elementRef.nativeElement.focus();
|
---|
| 578 | this._onFocus.next({ chip: this });
|
---|
| 579 | }
|
---|
| 580 | this._hasFocus = true;
|
---|
| 581 | };
|
---|
| 582 | /**
|
---|
| 583 | * Allows for programmatic removal of the chip. Called by the MatChipList when the DELETE or
|
---|
| 584 | * BACKSPACE keys are pressed.
|
---|
| 585 | *
|
---|
| 586 | * Informs any listeners of the removal request. Does not remove the chip from the DOM.
|
---|
| 587 | */
|
---|
| 588 | MatChip.prototype.remove = function () {
|
---|
| 589 | if (this.removable) {
|
---|
| 590 | this.removed.emit({ chip: this });
|
---|
| 591 | }
|
---|
| 592 | };
|
---|
| 593 | /** Handles click events on the chip. */
|
---|
| 594 | MatChip.prototype._handleClick = function (event) {
|
---|
| 595 | if (this.disabled) {
|
---|
| 596 | event.preventDefault();
|
---|
| 597 | }
|
---|
| 598 | else {
|
---|
| 599 | event.stopPropagation();
|
---|
| 600 | }
|
---|
| 601 | };
|
---|
| 602 | /** Handle custom key presses. */
|
---|
| 603 | MatChip.prototype._handleKeydown = function (event) {
|
---|
| 604 | if (this.disabled) {
|
---|
| 605 | return;
|
---|
| 606 | }
|
---|
| 607 | switch (event.keyCode) {
|
---|
| 608 | case keycodes.DELETE:
|
---|
| 609 | case keycodes.BACKSPACE:
|
---|
| 610 | // If we are removable, remove the focused chip
|
---|
| 611 | this.remove();
|
---|
| 612 | // Always prevent so page navigation does not occur
|
---|
| 613 | event.preventDefault();
|
---|
| 614 | break;
|
---|
| 615 | case keycodes.SPACE:
|
---|
| 616 | // If we are selectable, toggle the focused chip
|
---|
| 617 | if (this.selectable) {
|
---|
| 618 | this.toggleSelected(true);
|
---|
| 619 | }
|
---|
| 620 | // Always prevent space from scrolling the page since the list has focus
|
---|
| 621 | event.preventDefault();
|
---|
| 622 | break;
|
---|
| 623 | }
|
---|
| 624 | };
|
---|
| 625 | MatChip.prototype._blur = function () {
|
---|
| 626 | var _this = this;
|
---|
| 627 | // When animations are enabled, Angular may end up removing the chip from the DOM a little
|
---|
| 628 | // earlier than usual, causing it to be blurred and throwing off the logic in the chip list
|
---|
| 629 | // that moves focus not the next item. To work around the issue, we defer marking the chip
|
---|
| 630 | // as not focused until the next time the zone stabilizes.
|
---|
| 631 | this._ngZone.onStable
|
---|
| 632 | .pipe(operators.take(1))
|
---|
| 633 | .subscribe(function () {
|
---|
| 634 | _this._ngZone.run(function () {
|
---|
| 635 | _this._hasFocus = false;
|
---|
| 636 | _this._onBlur.next({ chip: _this });
|
---|
| 637 | });
|
---|
| 638 | });
|
---|
| 639 | };
|
---|
| 640 | MatChip.prototype._dispatchSelectionChange = function (isUserInput) {
|
---|
| 641 | if (isUserInput === void 0) { isUserInput = false; }
|
---|
| 642 | this.selectionChange.emit({
|
---|
| 643 | source: this,
|
---|
| 644 | isUserInput: isUserInput,
|
---|
| 645 | selected: this._selected
|
---|
| 646 | });
|
---|
| 647 | };
|
---|
| 648 | return MatChip;
|
---|
| 649 | }(_MatChipMixinBase));
|
---|
| 650 | MatChip.decorators = [
|
---|
| 651 | { type: core.Directive, args: [{
|
---|
| 652 | selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]",
|
---|
| 653 | inputs: ['color', 'disableRipple', 'tabIndex'],
|
---|
| 654 | exportAs: 'matChip',
|
---|
| 655 | host: {
|
---|
| 656 | 'class': 'mat-chip mat-focus-indicator',
|
---|
| 657 | '[attr.tabindex]': 'disabled ? null : tabIndex',
|
---|
| 658 | 'role': 'option',
|
---|
| 659 | '[class.mat-chip-selected]': 'selected',
|
---|
| 660 | '[class.mat-chip-with-avatar]': 'avatar',
|
---|
| 661 | '[class.mat-chip-with-trailing-icon]': 'trailingIcon || removeIcon',
|
---|
| 662 | '[class.mat-chip-disabled]': 'disabled',
|
---|
| 663 | '[class._mat-animation-noopable]': '_animationsDisabled',
|
---|
| 664 | '[attr.disabled]': 'disabled || null',
|
---|
| 665 | '[attr.aria-disabled]': 'disabled.toString()',
|
---|
| 666 | '[attr.aria-selected]': 'ariaSelected',
|
---|
| 667 | '(click)': '_handleClick($event)',
|
---|
| 668 | '(keydown)': '_handleKeydown($event)',
|
---|
| 669 | '(focus)': 'focus()',
|
---|
| 670 | '(blur)': '_blur()',
|
---|
| 671 | },
|
---|
| 672 | },] }
|
---|
| 673 | ];
|
---|
| 674 | MatChip.ctorParameters = function () { return [
|
---|
| 675 | { type: core.ElementRef },
|
---|
| 676 | { type: core.NgZone },
|
---|
| 677 | { type: platform.Platform },
|
---|
| 678 | { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [core$1.MAT_RIPPLE_GLOBAL_OPTIONS,] }] },
|
---|
| 679 | { type: core.ChangeDetectorRef },
|
---|
| 680 | { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] },
|
---|
| 681 | { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [animations.ANIMATION_MODULE_TYPE,] }] },
|
---|
| 682 | { type: String, decorators: [{ type: core.Attribute, args: ['tabindex',] }] }
|
---|
| 683 | ]; };
|
---|
| 684 | MatChip.propDecorators = {
|
---|
| 685 | avatar: [{ type: core.ContentChild, args: [MAT_CHIP_AVATAR,] }],
|
---|
| 686 | trailingIcon: [{ type: core.ContentChild, args: [MAT_CHIP_TRAILING_ICON,] }],
|
---|
| 687 | removeIcon: [{ type: core.ContentChild, args: [MAT_CHIP_REMOVE,] }],
|
---|
| 688 | selected: [{ type: core.Input }],
|
---|
| 689 | value: [{ type: core.Input }],
|
---|
| 690 | selectable: [{ type: core.Input }],
|
---|
| 691 | disabled: [{ type: core.Input }],
|
---|
| 692 | removable: [{ type: core.Input }],
|
---|
| 693 | selectionChange: [{ type: core.Output }],
|
---|
| 694 | destroyed: [{ type: core.Output }],
|
---|
| 695 | removed: [{ type: core.Output }]
|
---|
| 696 | };
|
---|
| 697 | /**
|
---|
| 698 | * Applies proper (click) support and adds styling for use with the Material Design "cancel" icon
|
---|
| 699 | * available at https://material.io/icons/#ic_cancel.
|
---|
| 700 | *
|
---|
| 701 | * Example:
|
---|
| 702 | *
|
---|
| 703 | * `<mat-chip>
|
---|
| 704 | * <mat-icon matChipRemove>cancel</mat-icon>
|
---|
| 705 | * </mat-chip>`
|
---|
| 706 | *
|
---|
| 707 | * You *may* use a custom icon, but you may need to override the `mat-chip-remove` positioning
|
---|
| 708 | * styles to properly center the icon within the chip.
|
---|
| 709 | */
|
---|
| 710 | var MatChipRemove = /** @class */ (function () {
|
---|
| 711 | function MatChipRemove(_parentChip, elementRef) {
|
---|
| 712 | this._parentChip = _parentChip;
|
---|
| 713 | if (elementRef.nativeElement.nodeName === 'BUTTON') {
|
---|
| 714 | elementRef.nativeElement.setAttribute('type', 'button');
|
---|
| 715 | }
|
---|
| 716 | }
|
---|
| 717 | /** Calls the parent chip's public `remove()` method if applicable. */
|
---|
| 718 | MatChipRemove.prototype._handleClick = function (event) {
|
---|
| 719 | var parentChip = this._parentChip;
|
---|
| 720 | if (parentChip.removable && !parentChip.disabled) {
|
---|
| 721 | parentChip.remove();
|
---|
| 722 | }
|
---|
| 723 | // We need to stop event propagation because otherwise the event will bubble up to the
|
---|
| 724 | // form field and cause the `onContainerClick` method to be invoked. This method would then
|
---|
| 725 | // reset the focused chip that has been focused after chip removal. Usually the parent
|
---|
| 726 | // the parent click listener of the `MatChip` would prevent propagation, but it can happen
|
---|
| 727 | // that the chip is being removed before the event bubbles up.
|
---|
| 728 | event.stopPropagation();
|
---|
| 729 | };
|
---|
| 730 | return MatChipRemove;
|
---|
| 731 | }());
|
---|
| 732 | MatChipRemove.decorators = [
|
---|
| 733 | { type: core.Directive, args: [{
|
---|
| 734 | selector: '[matChipRemove]',
|
---|
| 735 | host: {
|
---|
| 736 | 'class': 'mat-chip-remove mat-chip-trailing-icon',
|
---|
| 737 | '(click)': '_handleClick($event)',
|
---|
| 738 | },
|
---|
| 739 | providers: [{ provide: MAT_CHIP_REMOVE, useExisting: MatChipRemove }],
|
---|
| 740 | },] }
|
---|
| 741 | ];
|
---|
| 742 | MatChipRemove.ctorParameters = function () { return [
|
---|
| 743 | { type: MatChip },
|
---|
| 744 | { type: core.ElementRef }
|
---|
| 745 | ]; };
|
---|
| 746 |
|
---|
| 747 | /**
|
---|
| 748 | * @license
|
---|
| 749 | * Copyright Google LLC All Rights Reserved.
|
---|
| 750 | *
|
---|
| 751 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 752 | * found in the LICENSE file at https://angular.io/license
|
---|
| 753 | */
|
---|
| 754 | /** Injection token to be used to override the default options for the chips module. */
|
---|
| 755 | var MAT_CHIPS_DEFAULT_OPTIONS = new core.InjectionToken('mat-chips-default-options');
|
---|
| 756 |
|
---|
| 757 | /**
|
---|
| 758 | * @license
|
---|
| 759 | * Copyright Google LLC All Rights Reserved.
|
---|
| 760 | *
|
---|
| 761 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 762 | * found in the LICENSE file at https://angular.io/license
|
---|
| 763 | */
|
---|
| 764 | // Increasing integer for generating unique ids.
|
---|
| 765 | var nextUniqueId$1 = 0;
|
---|
| 766 | /**
|
---|
| 767 | * Directive that adds chip-specific behaviors to an input element inside `<mat-form-field>`.
|
---|
| 768 | * May be placed inside or outside of an `<mat-chip-list>`.
|
---|
| 769 | */
|
---|
| 770 | var MatChipInput = /** @class */ (function () {
|
---|
| 771 | function MatChipInput(_elementRef, _defaultOptions) {
|
---|
| 772 | this._elementRef = _elementRef;
|
---|
| 773 | this._defaultOptions = _defaultOptions;
|
---|
| 774 | /** Whether the control is focused. */
|
---|
| 775 | this.focused = false;
|
---|
| 776 | this._addOnBlur = false;
|
---|
| 777 | /**
|
---|
| 778 | * The list of key codes that will trigger a chipEnd event.
|
---|
| 779 | *
|
---|
| 780 | * Defaults to `[ENTER]`.
|
---|
| 781 | */
|
---|
| 782 | this.separatorKeyCodes = this._defaultOptions.separatorKeyCodes;
|
---|
| 783 | /** Emitted when a chip is to be added. */
|
---|
| 784 | this.chipEnd = new core.EventEmitter();
|
---|
| 785 | /** The input's placeholder text. */
|
---|
| 786 | this.placeholder = '';
|
---|
| 787 | /** Unique id for the input. */
|
---|
| 788 | this.id = "mat-chip-list-input-" + nextUniqueId$1++;
|
---|
| 789 | this._disabled = false;
|
---|
| 790 | this.inputElement = this._elementRef.nativeElement;
|
---|
| 791 | }
|
---|
| 792 | Object.defineProperty(MatChipInput.prototype, "chipList", {
|
---|
| 793 | /** Register input for chip list */
|
---|
| 794 | set: function (value) {
|
---|
| 795 | if (value) {
|
---|
| 796 | this._chipList = value;
|
---|
| 797 | this._chipList.registerInput(this);
|
---|
| 798 | }
|
---|
| 799 | },
|
---|
| 800 | enumerable: false,
|
---|
| 801 | configurable: true
|
---|
| 802 | });
|
---|
| 803 | Object.defineProperty(MatChipInput.prototype, "addOnBlur", {
|
---|
| 804 | /**
|
---|
| 805 | * Whether or not the chipEnd event will be emitted when the input is blurred.
|
---|
| 806 | */
|
---|
| 807 | get: function () { return this._addOnBlur; },
|
---|
| 808 | set: function (value) { this._addOnBlur = coercion.coerceBooleanProperty(value); },
|
---|
| 809 | enumerable: false,
|
---|
| 810 | configurable: true
|
---|
| 811 | });
|
---|
| 812 | Object.defineProperty(MatChipInput.prototype, "disabled", {
|
---|
| 813 | /** Whether the input is disabled. */
|
---|
| 814 | get: function () { return this._disabled || (this._chipList && this._chipList.disabled); },
|
---|
| 815 | set: function (value) { this._disabled = coercion.coerceBooleanProperty(value); },
|
---|
| 816 | enumerable: false,
|
---|
| 817 | configurable: true
|
---|
| 818 | });
|
---|
| 819 | Object.defineProperty(MatChipInput.prototype, "empty", {
|
---|
| 820 | /** Whether the input is empty. */
|
---|
| 821 | get: function () { return !this.inputElement.value; },
|
---|
| 822 | enumerable: false,
|
---|
| 823 | configurable: true
|
---|
| 824 | });
|
---|
| 825 | MatChipInput.prototype.ngOnChanges = function () {
|
---|
| 826 | this._chipList.stateChanges.next();
|
---|
| 827 | };
|
---|
| 828 | MatChipInput.prototype.ngOnDestroy = function () {
|
---|
| 829 | this.chipEnd.complete();
|
---|
| 830 | };
|
---|
| 831 | MatChipInput.prototype.ngAfterContentInit = function () {
|
---|
| 832 | this._focusLastChipOnBackspace = this.empty;
|
---|
| 833 | };
|
---|
| 834 | /** Utility method to make host definition/tests more clear. */
|
---|
| 835 | MatChipInput.prototype._keydown = function (event) {
|
---|
| 836 | if (event) {
|
---|
| 837 | // Allow the user's focus to escape when they're tabbing forward. Note that we don't
|
---|
| 838 | // want to do this when going backwards, because focus should go back to the first chip.
|
---|
| 839 | if (event.keyCode === keycodes.TAB && !keycodes.hasModifierKey(event, 'shiftKey')) {
|
---|
| 840 | this._chipList._allowFocusEscape();
|
---|
| 841 | }
|
---|
| 842 | // To prevent the user from accidentally deleting chips when pressing BACKSPACE continuously,
|
---|
| 843 | // We focus the last chip on backspace only after the user has released the backspace button,
|
---|
| 844 | // and the input is empty (see behaviour in _keyup)
|
---|
| 845 | if (event.keyCode === keycodes.BACKSPACE && this._focusLastChipOnBackspace) {
|
---|
| 846 | this._chipList._keyManager.setLastItemActive();
|
---|
| 847 | event.preventDefault();
|
---|
| 848 | return;
|
---|
| 849 | }
|
---|
| 850 | else {
|
---|
| 851 | this._focusLastChipOnBackspace = false;
|
---|
| 852 | }
|
---|
| 853 | }
|
---|
| 854 | this._emitChipEnd(event);
|
---|
| 855 | };
|
---|
| 856 | /**
|
---|
| 857 | * Pass events to the keyboard manager. Available here for tests.
|
---|
| 858 | */
|
---|
| 859 | MatChipInput.prototype._keyup = function (event) {
|
---|
| 860 | // Allow user to move focus to chips next time he presses backspace
|
---|
| 861 | if (!this._focusLastChipOnBackspace && event.keyCode === keycodes.BACKSPACE && this.empty) {
|
---|
| 862 | this._focusLastChipOnBackspace = true;
|
---|
| 863 | event.preventDefault();
|
---|
| 864 | }
|
---|
| 865 | };
|
---|
| 866 | /** Checks to see if the blur should emit the (chipEnd) event. */
|
---|
| 867 | MatChipInput.prototype._blur = function () {
|
---|
| 868 | if (this.addOnBlur) {
|
---|
| 869 | this._emitChipEnd();
|
---|
| 870 | }
|
---|
| 871 | this.focused = false;
|
---|
| 872 | // Blur the chip list if it is not focused
|
---|
| 873 | if (!this._chipList.focused) {
|
---|
| 874 | this._chipList._blur();
|
---|
| 875 | }
|
---|
| 876 | this._chipList.stateChanges.next();
|
---|
| 877 | };
|
---|
| 878 | MatChipInput.prototype._focus = function () {
|
---|
| 879 | this.focused = true;
|
---|
| 880 | this._focusLastChipOnBackspace = this.empty;
|
---|
| 881 | this._chipList.stateChanges.next();
|
---|
| 882 | };
|
---|
| 883 | /** Checks to see if the (chipEnd) event needs to be emitted. */
|
---|
| 884 | MatChipInput.prototype._emitChipEnd = function (event) {
|
---|
| 885 | if (!this.inputElement.value && !!event) {
|
---|
| 886 | this._chipList._keydown(event);
|
---|
| 887 | }
|
---|
| 888 | if (!event || this._isSeparatorKey(event)) {
|
---|
| 889 | this.chipEnd.emit({
|
---|
| 890 | input: this.inputElement,
|
---|
| 891 | value: this.inputElement.value,
|
---|
| 892 | chipInput: this,
|
---|
| 893 | });
|
---|
| 894 | event === null || event === void 0 ? void 0 : event.preventDefault();
|
---|
| 895 | }
|
---|
| 896 | };
|
---|
| 897 | MatChipInput.prototype._onInput = function () {
|
---|
| 898 | // Let chip list know whenever the value changes.
|
---|
| 899 | this._chipList.stateChanges.next();
|
---|
| 900 | };
|
---|
| 901 | /** Focuses the input. */
|
---|
| 902 | MatChipInput.prototype.focus = function (options) {
|
---|
| 903 | this.inputElement.focus(options);
|
---|
| 904 | };
|
---|
| 905 | /** Clears the input */
|
---|
| 906 | MatChipInput.prototype.clear = function () {
|
---|
| 907 | this.inputElement.value = '';
|
---|
| 908 | this._focusLastChipOnBackspace = true;
|
---|
| 909 | };
|
---|
| 910 | /** Checks whether a keycode is one of the configured separators. */
|
---|
| 911 | MatChipInput.prototype._isSeparatorKey = function (event) {
|
---|
| 912 | return !keycodes.hasModifierKey(event) && new Set(this.separatorKeyCodes).has(event.keyCode);
|
---|
| 913 | };
|
---|
| 914 | return MatChipInput;
|
---|
| 915 | }());
|
---|
| 916 | MatChipInput.decorators = [
|
---|
| 917 | { type: core.Directive, args: [{
|
---|
| 918 | selector: 'input[matChipInputFor]',
|
---|
| 919 | exportAs: 'matChipInput, matChipInputFor',
|
---|
| 920 | host: {
|
---|
| 921 | 'class': 'mat-chip-input mat-input-element',
|
---|
| 922 | '(keydown)': '_keydown($event)',
|
---|
| 923 | '(keyup)': '_keyup($event)',
|
---|
| 924 | '(blur)': '_blur()',
|
---|
| 925 | '(focus)': '_focus()',
|
---|
| 926 | '(input)': '_onInput()',
|
---|
| 927 | '[id]': 'id',
|
---|
| 928 | '[attr.disabled]': 'disabled || null',
|
---|
| 929 | '[attr.placeholder]': 'placeholder || null',
|
---|
| 930 | '[attr.aria-invalid]': '_chipList && _chipList.ngControl ? _chipList.ngControl.invalid : null',
|
---|
| 931 | '[attr.aria-required]': '_chipList && _chipList.required || null',
|
---|
| 932 | }
|
---|
| 933 | },] }
|
---|
| 934 | ];
|
---|
| 935 | MatChipInput.ctorParameters = function () { return [
|
---|
| 936 | { type: core.ElementRef },
|
---|
| 937 | { type: undefined, decorators: [{ type: core.Inject, args: [MAT_CHIPS_DEFAULT_OPTIONS,] }] }
|
---|
| 938 | ]; };
|
---|
| 939 | MatChipInput.propDecorators = {
|
---|
| 940 | chipList: [{ type: core.Input, args: ['matChipInputFor',] }],
|
---|
| 941 | addOnBlur: [{ type: core.Input, args: ['matChipInputAddOnBlur',] }],
|
---|
| 942 | separatorKeyCodes: [{ type: core.Input, args: ['matChipInputSeparatorKeyCodes',] }],
|
---|
| 943 | chipEnd: [{ type: core.Output, args: ['matChipInputTokenEnd',] }],
|
---|
| 944 | placeholder: [{ type: core.Input }],
|
---|
| 945 | id: [{ type: core.Input }],
|
---|
| 946 | disabled: [{ type: core.Input }]
|
---|
| 947 | };
|
---|
| 948 |
|
---|
| 949 | // Boilerplate for applying mixins to MatChipList.
|
---|
| 950 | /** @docs-private */
|
---|
| 951 | var _MatChipListBase = core$1.mixinErrorState(/** @class */ (function () {
|
---|
| 952 | function class_1(_defaultErrorStateMatcher, _parentForm, _parentFormGroup,
|
---|
| 953 | /** @docs-private */
|
---|
| 954 | ngControl) {
|
---|
| 955 | this._defaultErrorStateMatcher = _defaultErrorStateMatcher;
|
---|
| 956 | this._parentForm = _parentForm;
|
---|
| 957 | this._parentFormGroup = _parentFormGroup;
|
---|
| 958 | this.ngControl = ngControl;
|
---|
| 959 | }
|
---|
| 960 | return class_1;
|
---|
| 961 | }()));
|
---|
| 962 | // Increasing integer for generating unique ids for chip-list components.
|
---|
| 963 | var nextUniqueId = 0;
|
---|
| 964 | /** Change event object that is emitted when the chip list value has changed. */
|
---|
| 965 | var MatChipListChange = /** @class */ (function () {
|
---|
| 966 | function MatChipListChange(
|
---|
| 967 | /** Chip list that emitted the event. */
|
---|
| 968 | source,
|
---|
| 969 | /** Value of the chip list when the event was emitted. */
|
---|
| 970 | value) {
|
---|
| 971 | this.source = source;
|
---|
| 972 | this.value = value;
|
---|
| 973 | }
|
---|
| 974 | return MatChipListChange;
|
---|
| 975 | }());
|
---|
| 976 | /**
|
---|
| 977 | * A material design chips component (named ChipList for its similarity to the List component).
|
---|
| 978 | */
|
---|
| 979 | var MatChipList = /** @class */ (function (_super) {
|
---|
| 980 | __extends(MatChipList, _super);
|
---|
| 981 | function MatChipList(_elementRef, _changeDetectorRef, _dir, _parentForm, _parentFormGroup, _defaultErrorStateMatcher, ngControl) {
|
---|
| 982 | var _this = _super.call(this, _defaultErrorStateMatcher, _parentForm, _parentFormGroup, ngControl) || this;
|
---|
| 983 | _this._elementRef = _elementRef;
|
---|
| 984 | _this._changeDetectorRef = _changeDetectorRef;
|
---|
| 985 | _this._dir = _dir;
|
---|
| 986 | /**
|
---|
| 987 | * Implemented as part of MatFormFieldControl.
|
---|
| 988 | * @docs-private
|
---|
| 989 | */
|
---|
| 990 | _this.controlType = 'mat-chip-list';
|
---|
| 991 | /**
|
---|
| 992 | * When a chip is destroyed, we store the index of the destroyed chip until the chips
|
---|
| 993 | * query list notifies about the update. This is necessary because we cannot determine an
|
---|
| 994 | * appropriate chip that should receive focus until the array of chips updated completely.
|
---|
| 995 | */
|
---|
| 996 | _this._lastDestroyedChipIndex = null;
|
---|
| 997 | /** Subject that emits when the component has been destroyed. */
|
---|
| 998 | _this._destroyed = new rxjs.Subject();
|
---|
| 999 | /** Uid of the chip list */
|
---|
| 1000 | _this._uid = "mat-chip-list-" + nextUniqueId++;
|
---|
| 1001 | /** Tab index for the chip list. */
|
---|
| 1002 | _this._tabIndex = 0;
|
---|
| 1003 | /**
|
---|
| 1004 | * User defined tab index.
|
---|
| 1005 | * When it is not null, use user defined tab index. Otherwise use _tabIndex
|
---|
| 1006 | */
|
---|
| 1007 | _this._userTabIndex = null;
|
---|
| 1008 | /** Function when touched */
|
---|
| 1009 | _this._onTouched = function () { };
|
---|
| 1010 | /** Function when changed */
|
---|
| 1011 | _this._onChange = function () { };
|
---|
| 1012 | _this._multiple = false;
|
---|
| 1013 | _this._compareWith = function (o1, o2) { return o1 === o2; };
|
---|
| 1014 | _this._required = false;
|
---|
| 1015 | _this._disabled = false;
|
---|
| 1016 | /** Orientation of the chip list. */
|
---|
| 1017 | _this.ariaOrientation = 'horizontal';
|
---|
| 1018 | _this._selectable = true;
|
---|
| 1019 | /** Event emitted when the selected chip list value has been changed by the user. */
|
---|
| 1020 | _this.change = new core.EventEmitter();
|
---|
| 1021 | /**
|
---|
| 1022 | * Event that emits whenever the raw value of the chip-list changes. This is here primarily
|
---|
| 1023 | * to facilitate the two-way binding for the `value` input.
|
---|
| 1024 | * @docs-private
|
---|
| 1025 | */
|
---|
| 1026 | _this.valueChange = new core.EventEmitter();
|
---|
| 1027 | if (_this.ngControl) {
|
---|
| 1028 | _this.ngControl.valueAccessor = _this;
|
---|
| 1029 | }
|
---|
| 1030 | return _this;
|
---|
| 1031 | }
|
---|
| 1032 | Object.defineProperty(MatChipList.prototype, "selected", {
|
---|
| 1033 | /** The array of selected chips inside chip list. */
|
---|
| 1034 | get: function () {
|
---|
| 1035 | var _a, _b;
|
---|
| 1036 | return this.multiple ? (((_a = this._selectionModel) === null || _a === void 0 ? void 0 : _a.selected) || []) :
|
---|
| 1037 | (_b = this._selectionModel) === null || _b === void 0 ? void 0 : _b.selected[0];
|
---|
| 1038 | },
|
---|
| 1039 | enumerable: false,
|
---|
| 1040 | configurable: true
|
---|
| 1041 | });
|
---|
| 1042 | Object.defineProperty(MatChipList.prototype, "role", {
|
---|
| 1043 | /** The ARIA role applied to the chip list. */
|
---|
| 1044 | get: function () { return this.empty ? null : 'listbox'; },
|
---|
| 1045 | enumerable: false,
|
---|
| 1046 | configurable: true
|
---|
| 1047 | });
|
---|
| 1048 | Object.defineProperty(MatChipList.prototype, "multiple", {
|
---|
| 1049 | /** Whether the user should be allowed to select multiple chips. */
|
---|
| 1050 | get: function () { return this._multiple; },
|
---|
| 1051 | set: function (value) {
|
---|
| 1052 | this._multiple = coercion.coerceBooleanProperty(value);
|
---|
| 1053 | this._syncChipsState();
|
---|
| 1054 | },
|
---|
| 1055 | enumerable: false,
|
---|
| 1056 | configurable: true
|
---|
| 1057 | });
|
---|
| 1058 | Object.defineProperty(MatChipList.prototype, "compareWith", {
|
---|
| 1059 | /**
|
---|
| 1060 | * A function to compare the option values with the selected values. The first argument
|
---|
| 1061 | * is a value from an option. The second is a value from the selection. A boolean
|
---|
| 1062 | * should be returned.
|
---|
| 1063 | */
|
---|
| 1064 | get: function () { return this._compareWith; },
|
---|
| 1065 | set: function (fn) {
|
---|
| 1066 | this._compareWith = fn;
|
---|
| 1067 | if (this._selectionModel) {
|
---|
| 1068 | // A different comparator means the selection could change.
|
---|
| 1069 | this._initializeSelection();
|
---|
| 1070 | }
|
---|
| 1071 | },
|
---|
| 1072 | enumerable: false,
|
---|
| 1073 | configurable: true
|
---|
| 1074 | });
|
---|
| 1075 | Object.defineProperty(MatChipList.prototype, "value", {
|
---|
| 1076 | /**
|
---|
| 1077 | * Implemented as part of MatFormFieldControl.
|
---|
| 1078 | * @docs-private
|
---|
| 1079 | */
|
---|
| 1080 | get: function () { return this._value; },
|
---|
| 1081 | set: function (value) {
|
---|
| 1082 | this.writeValue(value);
|
---|
| 1083 | this._value = value;
|
---|
| 1084 | },
|
---|
| 1085 | enumerable: false,
|
---|
| 1086 | configurable: true
|
---|
| 1087 | });
|
---|
| 1088 | Object.defineProperty(MatChipList.prototype, "id", {
|
---|
| 1089 | /**
|
---|
| 1090 | * Implemented as part of MatFormFieldControl.
|
---|
| 1091 | * @docs-private
|
---|
| 1092 | */
|
---|
| 1093 | get: function () {
|
---|
| 1094 | return this._chipInput ? this._chipInput.id : this._uid;
|
---|
| 1095 | },
|
---|
| 1096 | enumerable: false,
|
---|
| 1097 | configurable: true
|
---|
| 1098 | });
|
---|
| 1099 | Object.defineProperty(MatChipList.prototype, "required", {
|
---|
| 1100 | /**
|
---|
| 1101 | * Implemented as part of MatFormFieldControl.
|
---|
| 1102 | * @docs-private
|
---|
| 1103 | */
|
---|
| 1104 | get: function () { return this._required; },
|
---|
| 1105 | set: function (value) {
|
---|
| 1106 | this._required = coercion.coerceBooleanProperty(value);
|
---|
| 1107 | this.stateChanges.next();
|
---|
| 1108 | },
|
---|
| 1109 | enumerable: false,
|
---|
| 1110 | configurable: true
|
---|
| 1111 | });
|
---|
| 1112 | Object.defineProperty(MatChipList.prototype, "placeholder", {
|
---|
| 1113 | /**
|
---|
| 1114 | * Implemented as part of MatFormFieldControl.
|
---|
| 1115 | * @docs-private
|
---|
| 1116 | */
|
---|
| 1117 | get: function () {
|
---|
| 1118 | return this._chipInput ? this._chipInput.placeholder : this._placeholder;
|
---|
| 1119 | },
|
---|
| 1120 | set: function (value) {
|
---|
| 1121 | this._placeholder = value;
|
---|
| 1122 | this.stateChanges.next();
|
---|
| 1123 | },
|
---|
| 1124 | enumerable: false,
|
---|
| 1125 | configurable: true
|
---|
| 1126 | });
|
---|
| 1127 | Object.defineProperty(MatChipList.prototype, "focused", {
|
---|
| 1128 | /** Whether any chips or the matChipInput inside of this chip-list has focus. */
|
---|
| 1129 | get: function () {
|
---|
| 1130 | return (this._chipInput && this._chipInput.focused) || this._hasFocusedChip();
|
---|
| 1131 | },
|
---|
| 1132 | enumerable: false,
|
---|
| 1133 | configurable: true
|
---|
| 1134 | });
|
---|
| 1135 | Object.defineProperty(MatChipList.prototype, "empty", {
|
---|
| 1136 | /**
|
---|
| 1137 | * Implemented as part of MatFormFieldControl.
|
---|
| 1138 | * @docs-private
|
---|
| 1139 | */
|
---|
| 1140 | get: function () {
|
---|
| 1141 | return (!this._chipInput || this._chipInput.empty) && (!this.chips || this.chips.length === 0);
|
---|
| 1142 | },
|
---|
| 1143 | enumerable: false,
|
---|
| 1144 | configurable: true
|
---|
| 1145 | });
|
---|
| 1146 | Object.defineProperty(MatChipList.prototype, "shouldLabelFloat", {
|
---|
| 1147 | /**
|
---|
| 1148 | * Implemented as part of MatFormFieldControl.
|
---|
| 1149 | * @docs-private
|
---|
| 1150 | */
|
---|
| 1151 | get: function () { return !this.empty || this.focused; },
|
---|
| 1152 | enumerable: false,
|
---|
| 1153 | configurable: true
|
---|
| 1154 | });
|
---|
| 1155 | Object.defineProperty(MatChipList.prototype, "disabled", {
|
---|
| 1156 | /**
|
---|
| 1157 | * Implemented as part of MatFormFieldControl.
|
---|
| 1158 | * @docs-private
|
---|
| 1159 | */
|
---|
| 1160 | get: function () { return this.ngControl ? !!this.ngControl.disabled : this._disabled; },
|
---|
| 1161 | set: function (value) {
|
---|
| 1162 | this._disabled = coercion.coerceBooleanProperty(value);
|
---|
| 1163 | this._syncChipsState();
|
---|
| 1164 | },
|
---|
| 1165 | enumerable: false,
|
---|
| 1166 | configurable: true
|
---|
| 1167 | });
|
---|
| 1168 | Object.defineProperty(MatChipList.prototype, "selectable", {
|
---|
| 1169 | /**
|
---|
| 1170 | * Whether or not this chip list is selectable. When a chip list is not selectable,
|
---|
| 1171 | * the selected states for all the chips inside the chip list are always ignored.
|
---|
| 1172 | */
|
---|
| 1173 | get: function () { return this._selectable; },
|
---|
| 1174 | set: function (value) {
|
---|
| 1175 | var _this = this;
|
---|
| 1176 | this._selectable = coercion.coerceBooleanProperty(value);
|
---|
| 1177 | if (this.chips) {
|
---|
| 1178 | this.chips.forEach(function (chip) { return chip.chipListSelectable = _this._selectable; });
|
---|
| 1179 | }
|
---|
| 1180 | },
|
---|
| 1181 | enumerable: false,
|
---|
| 1182 | configurable: true
|
---|
| 1183 | });
|
---|
| 1184 | Object.defineProperty(MatChipList.prototype, "tabIndex", {
|
---|
| 1185 | set: function (value) {
|
---|
| 1186 | this._userTabIndex = value;
|
---|
| 1187 | this._tabIndex = value;
|
---|
| 1188 | },
|
---|
| 1189 | enumerable: false,
|
---|
| 1190 | configurable: true
|
---|
| 1191 | });
|
---|
| 1192 | Object.defineProperty(MatChipList.prototype, "chipSelectionChanges", {
|
---|
| 1193 | /** Combined stream of all of the child chips' selection change events. */
|
---|
| 1194 | get: function () {
|
---|
| 1195 | return rxjs.merge.apply(void 0, __spreadArray([], __read(this.chips.map(function (chip) { return chip.selectionChange; }))));
|
---|
| 1196 | },
|
---|
| 1197 | enumerable: false,
|
---|
| 1198 | configurable: true
|
---|
| 1199 | });
|
---|
| 1200 | Object.defineProperty(MatChipList.prototype, "chipFocusChanges", {
|
---|
| 1201 | /** Combined stream of all of the child chips' focus change events. */
|
---|
| 1202 | get: function () {
|
---|
| 1203 | return rxjs.merge.apply(void 0, __spreadArray([], __read(this.chips.map(function (chip) { return chip._onFocus; }))));
|
---|
| 1204 | },
|
---|
| 1205 | enumerable: false,
|
---|
| 1206 | configurable: true
|
---|
| 1207 | });
|
---|
| 1208 | Object.defineProperty(MatChipList.prototype, "chipBlurChanges", {
|
---|
| 1209 | /** Combined stream of all of the child chips' blur change events. */
|
---|
| 1210 | get: function () {
|
---|
| 1211 | return rxjs.merge.apply(void 0, __spreadArray([], __read(this.chips.map(function (chip) { return chip._onBlur; }))));
|
---|
| 1212 | },
|
---|
| 1213 | enumerable: false,
|
---|
| 1214 | configurable: true
|
---|
| 1215 | });
|
---|
| 1216 | Object.defineProperty(MatChipList.prototype, "chipRemoveChanges", {
|
---|
| 1217 | /** Combined stream of all of the child chips' remove change events. */
|
---|
| 1218 | get: function () {
|
---|
| 1219 | return rxjs.merge.apply(void 0, __spreadArray([], __read(this.chips.map(function (chip) { return chip.destroyed; }))));
|
---|
| 1220 | },
|
---|
| 1221 | enumerable: false,
|
---|
| 1222 | configurable: true
|
---|
| 1223 | });
|
---|
| 1224 | MatChipList.prototype.ngAfterContentInit = function () {
|
---|
| 1225 | var _this = this;
|
---|
| 1226 | this._keyManager = new a11y.FocusKeyManager(this.chips)
|
---|
| 1227 | .withWrap()
|
---|
| 1228 | .withVerticalOrientation()
|
---|
| 1229 | .withHomeAndEnd()
|
---|
| 1230 | .withHorizontalOrientation(this._dir ? this._dir.value : 'ltr');
|
---|
| 1231 | if (this._dir) {
|
---|
| 1232 | this._dir.change
|
---|
| 1233 | .pipe(operators.takeUntil(this._destroyed))
|
---|
| 1234 | .subscribe(function (dir) { return _this._keyManager.withHorizontalOrientation(dir); });
|
---|
| 1235 | }
|
---|
| 1236 | this._keyManager.tabOut.pipe(operators.takeUntil(this._destroyed)).subscribe(function () {
|
---|
| 1237 | _this._allowFocusEscape();
|
---|
| 1238 | });
|
---|
| 1239 | // When the list changes, re-subscribe
|
---|
| 1240 | this.chips.changes.pipe(operators.startWith(null), operators.takeUntil(this._destroyed)).subscribe(function () {
|
---|
| 1241 | if (_this.disabled) {
|
---|
| 1242 | // Since this happens after the content has been
|
---|
| 1243 | // checked, we need to defer it to the next tick.
|
---|
| 1244 | Promise.resolve().then(function () {
|
---|
| 1245 | _this._syncChipsState();
|
---|
| 1246 | });
|
---|
| 1247 | }
|
---|
| 1248 | _this._resetChips();
|
---|
| 1249 | // Reset chips selected/deselected status
|
---|
| 1250 | _this._initializeSelection();
|
---|
| 1251 | // Check to see if we need to update our tab index
|
---|
| 1252 | _this._updateTabIndex();
|
---|
| 1253 | // Check to see if we have a destroyed chip and need to refocus
|
---|
| 1254 | _this._updateFocusForDestroyedChips();
|
---|
| 1255 | _this.stateChanges.next();
|
---|
| 1256 | });
|
---|
| 1257 | };
|
---|
| 1258 | MatChipList.prototype.ngOnInit = function () {
|
---|
| 1259 | this._selectionModel = new collections.SelectionModel(this.multiple, undefined, false);
|
---|
| 1260 | this.stateChanges.next();
|
---|
| 1261 | };
|
---|
| 1262 | MatChipList.prototype.ngDoCheck = function () {
|
---|
| 1263 | if (this.ngControl) {
|
---|
| 1264 | // We need to re-evaluate this on every change detection cycle, because there are some
|
---|
| 1265 | // error triggers that we can't subscribe to (e.g. parent form submissions). This means
|
---|
| 1266 | // that whatever logic is in here has to be super lean or we risk destroying the performance.
|
---|
| 1267 | this.updateErrorState();
|
---|
| 1268 | if (this.ngControl.disabled !== this._disabled) {
|
---|
| 1269 | this.disabled = !!this.ngControl.disabled;
|
---|
| 1270 | }
|
---|
| 1271 | }
|
---|
| 1272 | };
|
---|
| 1273 | MatChipList.prototype.ngOnDestroy = function () {
|
---|
| 1274 | this._destroyed.next();
|
---|
| 1275 | this._destroyed.complete();
|
---|
| 1276 | this.stateChanges.complete();
|
---|
| 1277 | this._dropSubscriptions();
|
---|
| 1278 | };
|
---|
| 1279 | /** Associates an HTML input element with this chip list. */
|
---|
| 1280 | MatChipList.prototype.registerInput = function (inputElement) {
|
---|
| 1281 | this._chipInput = inputElement;
|
---|
| 1282 | // We use this attribute to match the chip list to its input in test harnesses.
|
---|
| 1283 | // Set the attribute directly here to avoid "changed after checked" errors.
|
---|
| 1284 | this._elementRef.nativeElement.setAttribute('data-mat-chip-input', inputElement.id);
|
---|
| 1285 | };
|
---|
| 1286 | /**
|
---|
| 1287 | * Implemented as part of MatFormFieldControl.
|
---|
| 1288 | * @docs-private
|
---|
| 1289 | */
|
---|
| 1290 | MatChipList.prototype.setDescribedByIds = function (ids) { this._ariaDescribedby = ids.join(' '); };
|
---|
| 1291 | // Implemented as part of ControlValueAccessor.
|
---|
| 1292 | MatChipList.prototype.writeValue = function (value) {
|
---|
| 1293 | if (this.chips) {
|
---|
| 1294 | this._setSelectionByValue(value, false);
|
---|
| 1295 | }
|
---|
| 1296 | };
|
---|
| 1297 | // Implemented as part of ControlValueAccessor.
|
---|
| 1298 | MatChipList.prototype.registerOnChange = function (fn) {
|
---|
| 1299 | this._onChange = fn;
|
---|
| 1300 | };
|
---|
| 1301 | // Implemented as part of ControlValueAccessor.
|
---|
| 1302 | MatChipList.prototype.registerOnTouched = function (fn) {
|
---|
| 1303 | this._onTouched = fn;
|
---|
| 1304 | };
|
---|
| 1305 | // Implemented as part of ControlValueAccessor.
|
---|
| 1306 | MatChipList.prototype.setDisabledState = function (isDisabled) {
|
---|
| 1307 | this.disabled = isDisabled;
|
---|
| 1308 | this.stateChanges.next();
|
---|
| 1309 | };
|
---|
| 1310 | /**
|
---|
| 1311 | * Implemented as part of MatFormFieldControl.
|
---|
| 1312 | * @docs-private
|
---|
| 1313 | */
|
---|
| 1314 | MatChipList.prototype.onContainerClick = function (event) {
|
---|
| 1315 | if (!this._originatesFromChip(event)) {
|
---|
| 1316 | this.focus();
|
---|
| 1317 | }
|
---|
| 1318 | };
|
---|
| 1319 | /**
|
---|
| 1320 | * Focuses the first non-disabled chip in this chip list, or the associated input when there
|
---|
| 1321 | * are no eligible chips.
|
---|
| 1322 | */
|
---|
| 1323 | MatChipList.prototype.focus = function (options) {
|
---|
| 1324 | if (this.disabled) {
|
---|
| 1325 | return;
|
---|
| 1326 | }
|
---|
| 1327 | // TODO: ARIA says this should focus the first `selected` chip if any are selected.
|
---|
| 1328 | // Focus on first element if there's no chipInput inside chip-list
|
---|
| 1329 | if (this._chipInput && this._chipInput.focused) {
|
---|
| 1330 | // do nothing
|
---|
| 1331 | }
|
---|
| 1332 | else if (this.chips.length > 0) {
|
---|
| 1333 | this._keyManager.setFirstItemActive();
|
---|
| 1334 | this.stateChanges.next();
|
---|
| 1335 | }
|
---|
| 1336 | else {
|
---|
| 1337 | this._focusInput(options);
|
---|
| 1338 | this.stateChanges.next();
|
---|
| 1339 | }
|
---|
| 1340 | };
|
---|
| 1341 | /** Attempt to focus an input if we have one. */
|
---|
| 1342 | MatChipList.prototype._focusInput = function (options) {
|
---|
| 1343 | if (this._chipInput) {
|
---|
| 1344 | this._chipInput.focus(options);
|
---|
| 1345 | }
|
---|
| 1346 | };
|
---|
| 1347 | /**
|
---|
| 1348 | * Pass events to the keyboard manager. Available here for tests.
|
---|
| 1349 | */
|
---|
| 1350 | MatChipList.prototype._keydown = function (event) {
|
---|
| 1351 | var target = event.target;
|
---|
| 1352 | if (target && target.classList.contains('mat-chip')) {
|
---|
| 1353 | this._keyManager.onKeydown(event);
|
---|
| 1354 | this.stateChanges.next();
|
---|
| 1355 | }
|
---|
| 1356 | };
|
---|
| 1357 | /**
|
---|
| 1358 | * Check the tab index as you should not be allowed to focus an empty list.
|
---|
| 1359 | */
|
---|
| 1360 | MatChipList.prototype._updateTabIndex = function () {
|
---|
| 1361 | // If we have 0 chips, we should not allow keyboard focus
|
---|
| 1362 | this._tabIndex = this._userTabIndex || (this.chips.length === 0 ? -1 : 0);
|
---|
| 1363 | };
|
---|
| 1364 | /**
|
---|
| 1365 | * If the amount of chips changed, we need to update the
|
---|
| 1366 | * key manager state and focus the next closest chip.
|
---|
| 1367 | */
|
---|
| 1368 | MatChipList.prototype._updateFocusForDestroyedChips = function () {
|
---|
| 1369 | // Move focus to the closest chip. If no other chips remain, focus the chip-list itself.
|
---|
| 1370 | if (this._lastDestroyedChipIndex != null) {
|
---|
| 1371 | if (this.chips.length) {
|
---|
| 1372 | var newChipIndex = Math.min(this._lastDestroyedChipIndex, this.chips.length - 1);
|
---|
| 1373 | this._keyManager.setActiveItem(newChipIndex);
|
---|
| 1374 | }
|
---|
| 1375 | else {
|
---|
| 1376 | this.focus();
|
---|
| 1377 | }
|
---|
| 1378 | }
|
---|
| 1379 | this._lastDestroyedChipIndex = null;
|
---|
| 1380 | };
|
---|
| 1381 | /**
|
---|
| 1382 | * Utility to ensure all indexes are valid.
|
---|
| 1383 | *
|
---|
| 1384 | * @param index The index to be checked.
|
---|
| 1385 | * @returns True if the index is valid for our list of chips.
|
---|
| 1386 | */
|
---|
| 1387 | MatChipList.prototype._isValidIndex = function (index) {
|
---|
| 1388 | return index >= 0 && index < this.chips.length;
|
---|
| 1389 | };
|
---|
| 1390 | MatChipList.prototype._setSelectionByValue = function (value, isUserInput) {
|
---|
| 1391 | var _this = this;
|
---|
| 1392 | if (isUserInput === void 0) { isUserInput = true; }
|
---|
| 1393 | this._clearSelection();
|
---|
| 1394 | this.chips.forEach(function (chip) { return chip.deselect(); });
|
---|
| 1395 | if (Array.isArray(value)) {
|
---|
| 1396 | value.forEach(function (currentValue) { return _this._selectValue(currentValue, isUserInput); });
|
---|
| 1397 | this._sortValues();
|
---|
| 1398 | }
|
---|
| 1399 | else {
|
---|
| 1400 | var correspondingChip = this._selectValue(value, isUserInput);
|
---|
| 1401 | // Shift focus to the active item. Note that we shouldn't do this in multiple
|
---|
| 1402 | // mode, because we don't know what chip the user interacted with last.
|
---|
| 1403 | if (correspondingChip) {
|
---|
| 1404 | if (isUserInput) {
|
---|
| 1405 | this._keyManager.setActiveItem(correspondingChip);
|
---|
| 1406 | }
|
---|
| 1407 | }
|
---|
| 1408 | }
|
---|
| 1409 | };
|
---|
| 1410 | /**
|
---|
| 1411 | * Finds and selects the chip based on its value.
|
---|
| 1412 | * @returns Chip that has the corresponding value.
|
---|
| 1413 | */
|
---|
| 1414 | MatChipList.prototype._selectValue = function (value, isUserInput) {
|
---|
| 1415 | var _this = this;
|
---|
| 1416 | if (isUserInput === void 0) { isUserInput = true; }
|
---|
| 1417 | var correspondingChip = this.chips.find(function (chip) {
|
---|
| 1418 | return chip.value != null && _this._compareWith(chip.value, value);
|
---|
| 1419 | });
|
---|
| 1420 | if (correspondingChip) {
|
---|
| 1421 | isUserInput ? correspondingChip.selectViaInteraction() : correspondingChip.select();
|
---|
| 1422 | this._selectionModel.select(correspondingChip);
|
---|
| 1423 | }
|
---|
| 1424 | return correspondingChip;
|
---|
| 1425 | };
|
---|
| 1426 | MatChipList.prototype._initializeSelection = function () {
|
---|
| 1427 | var _this = this;
|
---|
| 1428 | // Defer setting the value in order to avoid the "Expression
|
---|
| 1429 | // has changed after it was checked" errors from Angular.
|
---|
| 1430 | Promise.resolve().then(function () {
|
---|
| 1431 | if (_this.ngControl || _this._value) {
|
---|
| 1432 | _this._setSelectionByValue(_this.ngControl ? _this.ngControl.value : _this._value, false);
|
---|
| 1433 | _this.stateChanges.next();
|
---|
| 1434 | }
|
---|
| 1435 | });
|
---|
| 1436 | };
|
---|
| 1437 | /**
|
---|
| 1438 | * Deselects every chip in the list.
|
---|
| 1439 | * @param skip Chip that should not be deselected.
|
---|
| 1440 | */
|
---|
| 1441 | MatChipList.prototype._clearSelection = function (skip) {
|
---|
| 1442 | this._selectionModel.clear();
|
---|
| 1443 | this.chips.forEach(function (chip) {
|
---|
| 1444 | if (chip !== skip) {
|
---|
| 1445 | chip.deselect();
|
---|
| 1446 | }
|
---|
| 1447 | });
|
---|
| 1448 | this.stateChanges.next();
|
---|
| 1449 | };
|
---|
| 1450 | /**
|
---|
| 1451 | * Sorts the model values, ensuring that they keep the same
|
---|
| 1452 | * order that they have in the panel.
|
---|
| 1453 | */
|
---|
| 1454 | MatChipList.prototype._sortValues = function () {
|
---|
| 1455 | var _this = this;
|
---|
| 1456 | if (this._multiple) {
|
---|
| 1457 | this._selectionModel.clear();
|
---|
| 1458 | this.chips.forEach(function (chip) {
|
---|
| 1459 | if (chip.selected) {
|
---|
| 1460 | _this._selectionModel.select(chip);
|
---|
| 1461 | }
|
---|
| 1462 | });
|
---|
| 1463 | this.stateChanges.next();
|
---|
| 1464 | }
|
---|
| 1465 | };
|
---|
| 1466 | /** Emits change event to set the model value. */
|
---|
| 1467 | MatChipList.prototype._propagateChanges = function (fallbackValue) {
|
---|
| 1468 | var valueToEmit = null;
|
---|
| 1469 | if (Array.isArray(this.selected)) {
|
---|
| 1470 | valueToEmit = this.selected.map(function (chip) { return chip.value; });
|
---|
| 1471 | }
|
---|
| 1472 | else {
|
---|
| 1473 | valueToEmit = this.selected ? this.selected.value : fallbackValue;
|
---|
| 1474 | }
|
---|
| 1475 | this._value = valueToEmit;
|
---|
| 1476 | this.change.emit(new MatChipListChange(this, valueToEmit));
|
---|
| 1477 | this.valueChange.emit(valueToEmit);
|
---|
| 1478 | this._onChange(valueToEmit);
|
---|
| 1479 | this._changeDetectorRef.markForCheck();
|
---|
| 1480 | };
|
---|
| 1481 | /** When blurred, mark the field as touched when focus moved outside the chip list. */
|
---|
| 1482 | MatChipList.prototype._blur = function () {
|
---|
| 1483 | var _this = this;
|
---|
| 1484 | if (!this._hasFocusedChip()) {
|
---|
| 1485 | this._keyManager.setActiveItem(-1);
|
---|
| 1486 | }
|
---|
| 1487 | if (!this.disabled) {
|
---|
| 1488 | if (this._chipInput) {
|
---|
| 1489 | // If there's a chip input, we should check whether the focus moved to chip input.
|
---|
| 1490 | // If the focus is not moved to chip input, mark the field as touched. If the focus moved
|
---|
| 1491 | // to chip input, do nothing.
|
---|
| 1492 | // Timeout is needed to wait for the focus() event trigger on chip input.
|
---|
| 1493 | setTimeout(function () {
|
---|
| 1494 | if (!_this.focused) {
|
---|
| 1495 | _this._markAsTouched();
|
---|
| 1496 | }
|
---|
| 1497 | });
|
---|
| 1498 | }
|
---|
| 1499 | else {
|
---|
| 1500 | // If there's no chip input, then mark the field as touched.
|
---|
| 1501 | this._markAsTouched();
|
---|
| 1502 | }
|
---|
| 1503 | }
|
---|
| 1504 | };
|
---|
| 1505 | /** Mark the field as touched */
|
---|
| 1506 | MatChipList.prototype._markAsTouched = function () {
|
---|
| 1507 | this._onTouched();
|
---|
| 1508 | this._changeDetectorRef.markForCheck();
|
---|
| 1509 | this.stateChanges.next();
|
---|
| 1510 | };
|
---|
| 1511 | /**
|
---|
| 1512 | * Removes the `tabindex` from the chip list and resets it back afterwards, allowing the
|
---|
| 1513 | * user to tab out of it. This prevents the list from capturing focus and redirecting
|
---|
| 1514 | * it back to the first chip, creating a focus trap, if it user tries to tab away.
|
---|
| 1515 | */
|
---|
| 1516 | MatChipList.prototype._allowFocusEscape = function () {
|
---|
| 1517 | var _this = this;
|
---|
| 1518 | if (this._tabIndex !== -1) {
|
---|
| 1519 | this._tabIndex = -1;
|
---|
| 1520 | setTimeout(function () {
|
---|
| 1521 | _this._tabIndex = _this._userTabIndex || 0;
|
---|
| 1522 | _this._changeDetectorRef.markForCheck();
|
---|
| 1523 | });
|
---|
| 1524 | }
|
---|
| 1525 | };
|
---|
| 1526 | MatChipList.prototype._resetChips = function () {
|
---|
| 1527 | this._dropSubscriptions();
|
---|
| 1528 | this._listenToChipsFocus();
|
---|
| 1529 | this._listenToChipsSelection();
|
---|
| 1530 | this._listenToChipsRemoved();
|
---|
| 1531 | };
|
---|
| 1532 | MatChipList.prototype._dropSubscriptions = function () {
|
---|
| 1533 | if (this._chipFocusSubscription) {
|
---|
| 1534 | this._chipFocusSubscription.unsubscribe();
|
---|
| 1535 | this._chipFocusSubscription = null;
|
---|
| 1536 | }
|
---|
| 1537 | if (this._chipBlurSubscription) {
|
---|
| 1538 | this._chipBlurSubscription.unsubscribe();
|
---|
| 1539 | this._chipBlurSubscription = null;
|
---|
| 1540 | }
|
---|
| 1541 | if (this._chipSelectionSubscription) {
|
---|
| 1542 | this._chipSelectionSubscription.unsubscribe();
|
---|
| 1543 | this._chipSelectionSubscription = null;
|
---|
| 1544 | }
|
---|
| 1545 | if (this._chipRemoveSubscription) {
|
---|
| 1546 | this._chipRemoveSubscription.unsubscribe();
|
---|
| 1547 | this._chipRemoveSubscription = null;
|
---|
| 1548 | }
|
---|
| 1549 | };
|
---|
| 1550 | /** Listens to user-generated selection events on each chip. */
|
---|
| 1551 | MatChipList.prototype._listenToChipsSelection = function () {
|
---|
| 1552 | var _this = this;
|
---|
| 1553 | this._chipSelectionSubscription = this.chipSelectionChanges.subscribe(function (event) {
|
---|
| 1554 | event.source.selected
|
---|
| 1555 | ? _this._selectionModel.select(event.source)
|
---|
| 1556 | : _this._selectionModel.deselect(event.source);
|
---|
| 1557 | // For single selection chip list, make sure the deselected value is unselected.
|
---|
| 1558 | if (!_this.multiple) {
|
---|
| 1559 | _this.chips.forEach(function (chip) {
|
---|
| 1560 | if (!_this._selectionModel.isSelected(chip) && chip.selected) {
|
---|
| 1561 | chip.deselect();
|
---|
| 1562 | }
|
---|
| 1563 | });
|
---|
| 1564 | }
|
---|
| 1565 | if (event.isUserInput) {
|
---|
| 1566 | _this._propagateChanges();
|
---|
| 1567 | }
|
---|
| 1568 | });
|
---|
| 1569 | };
|
---|
| 1570 | /** Listens to user-generated selection events on each chip. */
|
---|
| 1571 | MatChipList.prototype._listenToChipsFocus = function () {
|
---|
| 1572 | var _this = this;
|
---|
| 1573 | this._chipFocusSubscription = this.chipFocusChanges.subscribe(function (event) {
|
---|
| 1574 | var chipIndex = _this.chips.toArray().indexOf(event.chip);
|
---|
| 1575 | if (_this._isValidIndex(chipIndex)) {
|
---|
| 1576 | _this._keyManager.updateActiveItem(chipIndex);
|
---|
| 1577 | }
|
---|
| 1578 | _this.stateChanges.next();
|
---|
| 1579 | });
|
---|
| 1580 | this._chipBlurSubscription = this.chipBlurChanges.subscribe(function () {
|
---|
| 1581 | _this._blur();
|
---|
| 1582 | _this.stateChanges.next();
|
---|
| 1583 | });
|
---|
| 1584 | };
|
---|
| 1585 | MatChipList.prototype._listenToChipsRemoved = function () {
|
---|
| 1586 | var _this = this;
|
---|
| 1587 | this._chipRemoveSubscription = this.chipRemoveChanges.subscribe(function (event) {
|
---|
| 1588 | var chip = event.chip;
|
---|
| 1589 | var chipIndex = _this.chips.toArray().indexOf(event.chip);
|
---|
| 1590 | // In case the chip that will be removed is currently focused, we temporarily store
|
---|
| 1591 | // the index in order to be able to determine an appropriate sibling chip that will
|
---|
| 1592 | // receive focus.
|
---|
| 1593 | if (_this._isValidIndex(chipIndex) && chip._hasFocus) {
|
---|
| 1594 | _this._lastDestroyedChipIndex = chipIndex;
|
---|
| 1595 | }
|
---|
| 1596 | });
|
---|
| 1597 | };
|
---|
| 1598 | /** Checks whether an event comes from inside a chip element. */
|
---|
| 1599 | MatChipList.prototype._originatesFromChip = function (event) {
|
---|
| 1600 | var currentElement = event.target;
|
---|
| 1601 | while (currentElement && currentElement !== this._elementRef.nativeElement) {
|
---|
| 1602 | if (currentElement.classList.contains('mat-chip')) {
|
---|
| 1603 | return true;
|
---|
| 1604 | }
|
---|
| 1605 | currentElement = currentElement.parentElement;
|
---|
| 1606 | }
|
---|
| 1607 | return false;
|
---|
| 1608 | };
|
---|
| 1609 | /** Checks whether any of the chips is focused. */
|
---|
| 1610 | MatChipList.prototype._hasFocusedChip = function () {
|
---|
| 1611 | return this.chips && this.chips.some(function (chip) { return chip._hasFocus; });
|
---|
| 1612 | };
|
---|
| 1613 | /** Syncs the list's state with the individual chips. */
|
---|
| 1614 | MatChipList.prototype._syncChipsState = function () {
|
---|
| 1615 | var _this = this;
|
---|
| 1616 | if (this.chips) {
|
---|
| 1617 | this.chips.forEach(function (chip) {
|
---|
| 1618 | chip._chipListDisabled = _this._disabled;
|
---|
| 1619 | chip._chipListMultiple = _this.multiple;
|
---|
| 1620 | });
|
---|
| 1621 | }
|
---|
| 1622 | };
|
---|
| 1623 | return MatChipList;
|
---|
| 1624 | }(_MatChipListBase));
|
---|
| 1625 | MatChipList.decorators = [
|
---|
| 1626 | { type: core.Component, args: [{
|
---|
| 1627 | selector: 'mat-chip-list',
|
---|
| 1628 | template: "<div class=\"mat-chip-list-wrapper\"><ng-content></ng-content></div>",
|
---|
| 1629 | exportAs: 'matChipList',
|
---|
| 1630 | host: {
|
---|
| 1631 | '[attr.tabindex]': 'disabled ? null : _tabIndex',
|
---|
| 1632 | '[attr.aria-describedby]': '_ariaDescribedby || null',
|
---|
| 1633 | '[attr.aria-required]': 'role ? required : null',
|
---|
| 1634 | '[attr.aria-disabled]': 'disabled.toString()',
|
---|
| 1635 | '[attr.aria-invalid]': 'errorState',
|
---|
| 1636 | '[attr.aria-multiselectable]': 'multiple',
|
---|
| 1637 | '[attr.role]': 'role',
|
---|
| 1638 | '[class.mat-chip-list-disabled]': 'disabled',
|
---|
| 1639 | '[class.mat-chip-list-invalid]': 'errorState',
|
---|
| 1640 | '[class.mat-chip-list-required]': 'required',
|
---|
| 1641 | '[attr.aria-orientation]': 'ariaOrientation',
|
---|
| 1642 | 'class': 'mat-chip-list',
|
---|
| 1643 | '(focus)': 'focus()',
|
---|
| 1644 | '(blur)': '_blur()',
|
---|
| 1645 | '(keydown)': '_keydown($event)',
|
---|
| 1646 | '[id]': '_uid',
|
---|
| 1647 | },
|
---|
| 1648 | providers: [{ provide: formField.MatFormFieldControl, useExisting: MatChipList }],
|
---|
| 1649 | encapsulation: core.ViewEncapsulation.None,
|
---|
| 1650 | changeDetection: core.ChangeDetectionStrategy.OnPush,
|
---|
| 1651 | styles: [".mat-chip{position:relative;box-sizing:border-box;-webkit-tap-highlight-color:transparent;transform:translateZ(0);border:none;-webkit-appearance:none;-moz-appearance:none}.mat-standard-chip{transition:box-shadow 280ms cubic-bezier(0.4, 0, 0.2, 1);display:inline-flex;padding:7px 12px;border-radius:16px;align-items:center;cursor:default;min-height:32px;height:1px}._mat-animation-noopable.mat-standard-chip{transition:none;animation:none}.mat-standard-chip .mat-chip-remove{border:none;-webkit-appearance:none;-moz-appearance:none;padding:0;background:none}.mat-standard-chip .mat-chip-remove.mat-icon,.mat-standard-chip .mat-chip-remove .mat-icon{width:18px;height:18px;font-size:18px}.mat-standard-chip::after{top:0;left:0;right:0;bottom:0;position:absolute;border-radius:inherit;opacity:0;content:\"\";pointer-events:none;transition:opacity 200ms cubic-bezier(0.35, 0, 0.25, 1)}.mat-standard-chip:hover::after{opacity:.12}.mat-standard-chip:focus{outline:none}.mat-standard-chip:focus::after{opacity:.16}.cdk-high-contrast-active .mat-standard-chip{outline:solid 1px}.cdk-high-contrast-active .mat-standard-chip:focus{outline:dotted 2px}.mat-standard-chip.mat-chip-disabled::after{opacity:0}.mat-standard-chip.mat-chip-disabled .mat-chip-remove,.mat-standard-chip.mat-chip-disabled .mat-chip-trailing-icon{cursor:default}.mat-standard-chip.mat-chip-with-trailing-icon.mat-chip-with-avatar,.mat-standard-chip.mat-chip-with-avatar{padding-top:0;padding-bottom:0}.mat-standard-chip.mat-chip-with-trailing-icon.mat-chip-with-avatar{padding-right:8px;padding-left:0}[dir=rtl] .mat-standard-chip.mat-chip-with-trailing-icon.mat-chip-with-avatar{padding-left:8px;padding-right:0}.mat-standard-chip.mat-chip-with-trailing-icon{padding-top:7px;padding-bottom:7px;padding-right:8px;padding-left:12px}[dir=rtl] .mat-standard-chip.mat-chip-with-trailing-icon{padding-left:8px;padding-right:12px}.mat-standard-chip.mat-chip-with-avatar{padding-left:0;padding-right:12px}[dir=rtl] .mat-standard-chip.mat-chip-with-avatar{padding-right:0;padding-left:12px}.mat-standard-chip .mat-chip-avatar{width:24px;height:24px;margin-right:8px;margin-left:4px}[dir=rtl] .mat-standard-chip .mat-chip-avatar{margin-left:8px;margin-right:4px}.mat-standard-chip .mat-chip-remove,.mat-standard-chip .mat-chip-trailing-icon{width:18px;height:18px;cursor:pointer}.mat-standard-chip .mat-chip-remove,.mat-standard-chip .mat-chip-trailing-icon{margin-left:8px;margin-right:0}[dir=rtl] .mat-standard-chip .mat-chip-remove,[dir=rtl] .mat-standard-chip .mat-chip-trailing-icon{margin-right:8px;margin-left:0}.mat-chip-ripple{top:0;left:0;right:0;bottom:0;position:absolute;pointer-events:none;border-radius:inherit;overflow:hidden}.mat-chip-list-wrapper{display:flex;flex-direction:row;flex-wrap:wrap;align-items:center;margin:-4px}.mat-chip-list-wrapper input.mat-input-element,.mat-chip-list-wrapper .mat-standard-chip{margin:4px}.mat-chip-list-stacked .mat-chip-list-wrapper{flex-direction:column;align-items:flex-start}.mat-chip-list-stacked .mat-chip-list-wrapper .mat-standard-chip{width:100%}.mat-chip-avatar{border-radius:50%;justify-content:center;align-items:center;display:flex;overflow:hidden;object-fit:cover}input.mat-chip-input{width:150px;margin:4px;flex:1 0 150px}\n"]
|
---|
| 1652 | },] }
|
---|
| 1653 | ];
|
---|
| 1654 | MatChipList.ctorParameters = function () { return [
|
---|
| 1655 | { type: core.ElementRef },
|
---|
| 1656 | { type: core.ChangeDetectorRef },
|
---|
| 1657 | { type: bidi.Directionality, decorators: [{ type: core.Optional }] },
|
---|
| 1658 | { type: forms.NgForm, decorators: [{ type: core.Optional }] },
|
---|
| 1659 | { type: forms.FormGroupDirective, decorators: [{ type: core.Optional }] },
|
---|
| 1660 | { type: core$1.ErrorStateMatcher },
|
---|
| 1661 | { type: forms.NgControl, decorators: [{ type: core.Optional }, { type: core.Self }] }
|
---|
| 1662 | ]; };
|
---|
| 1663 | MatChipList.propDecorators = {
|
---|
| 1664 | errorStateMatcher: [{ type: core.Input }],
|
---|
| 1665 | multiple: [{ type: core.Input }],
|
---|
| 1666 | compareWith: [{ type: core.Input }],
|
---|
| 1667 | value: [{ type: core.Input }],
|
---|
| 1668 | required: [{ type: core.Input }],
|
---|
| 1669 | placeholder: [{ type: core.Input }],
|
---|
| 1670 | disabled: [{ type: core.Input }],
|
---|
| 1671 | ariaOrientation: [{ type: core.Input, args: ['aria-orientation',] }],
|
---|
| 1672 | selectable: [{ type: core.Input }],
|
---|
| 1673 | tabIndex: [{ type: core.Input }],
|
---|
| 1674 | change: [{ type: core.Output }],
|
---|
| 1675 | valueChange: [{ type: core.Output }],
|
---|
| 1676 | chips: [{ type: core.ContentChildren, args: [MatChip, {
|
---|
| 1677 | // We need to use `descendants: true`, because Ivy will no longer match
|
---|
| 1678 | // indirect descendants if it's left as false.
|
---|
| 1679 | descendants: true
|
---|
| 1680 | },] }]
|
---|
| 1681 | };
|
---|
| 1682 |
|
---|
| 1683 | /**
|
---|
| 1684 | * @license
|
---|
| 1685 | * Copyright Google LLC All Rights Reserved.
|
---|
| 1686 | *
|
---|
| 1687 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 1688 | * found in the LICENSE file at https://angular.io/license
|
---|
| 1689 | */
|
---|
| 1690 | var CHIP_DECLARATIONS = [
|
---|
| 1691 | MatChipList,
|
---|
| 1692 | MatChip,
|
---|
| 1693 | MatChipInput,
|
---|
| 1694 | MatChipRemove,
|
---|
| 1695 | MatChipAvatar,
|
---|
| 1696 | MatChipTrailingIcon,
|
---|
| 1697 | ];
|
---|
| 1698 | var ɵ0 = {
|
---|
| 1699 | separatorKeyCodes: [keycodes.ENTER]
|
---|
| 1700 | };
|
---|
| 1701 | var MatChipsModule = /** @class */ (function () {
|
---|
| 1702 | function MatChipsModule() {
|
---|
| 1703 | }
|
---|
| 1704 | return MatChipsModule;
|
---|
| 1705 | }());
|
---|
| 1706 | MatChipsModule.decorators = [
|
---|
| 1707 | { type: core.NgModule, args: [{
|
---|
| 1708 | imports: [core$1.MatCommonModule],
|
---|
| 1709 | exports: CHIP_DECLARATIONS,
|
---|
| 1710 | declarations: CHIP_DECLARATIONS,
|
---|
| 1711 | providers: [
|
---|
| 1712 | core$1.ErrorStateMatcher,
|
---|
| 1713 | {
|
---|
| 1714 | provide: MAT_CHIPS_DEFAULT_OPTIONS,
|
---|
| 1715 | useValue: ɵ0
|
---|
| 1716 | }
|
---|
| 1717 | ]
|
---|
| 1718 | },] }
|
---|
| 1719 | ];
|
---|
| 1720 |
|
---|
| 1721 | /**
|
---|
| 1722 | * @license
|
---|
| 1723 | * Copyright Google LLC All Rights Reserved.
|
---|
| 1724 | *
|
---|
| 1725 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 1726 | * found in the LICENSE file at https://angular.io/license
|
---|
| 1727 | */
|
---|
| 1728 |
|
---|
| 1729 | /**
|
---|
| 1730 | * Generated bundle index. Do not edit.
|
---|
| 1731 | */
|
---|
| 1732 |
|
---|
| 1733 | exports.MAT_CHIPS_DEFAULT_OPTIONS = MAT_CHIPS_DEFAULT_OPTIONS;
|
---|
| 1734 | exports.MAT_CHIP_AVATAR = MAT_CHIP_AVATAR;
|
---|
| 1735 | exports.MAT_CHIP_REMOVE = MAT_CHIP_REMOVE;
|
---|
| 1736 | exports.MAT_CHIP_TRAILING_ICON = MAT_CHIP_TRAILING_ICON;
|
---|
| 1737 | exports.MatChip = MatChip;
|
---|
| 1738 | exports.MatChipAvatar = MatChipAvatar;
|
---|
| 1739 | exports.MatChipInput = MatChipInput;
|
---|
| 1740 | exports.MatChipList = MatChipList;
|
---|
| 1741 | exports.MatChipListChange = MatChipListChange;
|
---|
| 1742 | exports.MatChipRemove = MatChipRemove;
|
---|
| 1743 | exports.MatChipSelectionChange = MatChipSelectionChange;
|
---|
| 1744 | exports.MatChipTrailingIcon = MatChipTrailingIcon;
|
---|
| 1745 | exports.MatChipsModule = MatChipsModule;
|
---|
| 1746 | exports.ɵ0 = ɵ0;
|
---|
| 1747 |
|
---|
| 1748 | Object.defineProperty(exports, '__esModule', { value: true });
|
---|
| 1749 |
|
---|
| 1750 | })));
|
---|
| 1751 | //# sourceMappingURL=material-chips.umd.js.map
|
---|