1var App = (function (exports) { 2 'use strict'; 3 4 // Define globals that need to be visible to all ES5 JS in this directory 5 6 window.cookieOptions = { 7 path: '/', 8 domain: publicOptions.COOKIE_DOMAIN ? publicOptions.COOKIE_DOMAIN : document.location.hostname, 9 expires: 365 10 }; 11 12 window.serviceWorkerRegistration = null; 13 14 if (publicOptions.SERVICE_WORKER && 'serviceWorker' in navigator) { 15 window.addEventListener('load', async () => { 16 const options = { 17 scope: '/' 18 }; 19 navigator.serviceWorker.register(publicOptions.SERVICE_WORKER, options).then(function (reg) { 20 window.serviceWorkerRegistration = reg; 21 }); 22 }); 23 } 24 25 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 26 27 function getDefaultExportFromCjs (x) { 28 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; 29 } 30 31 function getDefaultExportFromNamespaceIfPresent (n) { 32 return n && Object.prototype.hasOwnProperty.call(n, 'default') ? n['default'] : n; 33 } 34 35 function getDefaultExportFromNamespaceIfNotNamed (n) { 36 return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n; 37 } 38 39 function getAugmentedNamespace(n) { 40 if (n.__esModule) return n; 41 var a = Object.defineProperty({}, '__esModule', {value: true}); 42 Object.keys(n).forEach(function (k) { 43 var d = Object.getOwnPropertyDescriptor(n, k); 44 Object.defineProperty(a, k, d.get ? d : { 45 enumerable: true, 46 get: function () { 47 return n[k]; 48 } 49 }); 50 }); 51 return a; 52 } 53 54 function createCommonjsModule(fn) { 55 var module = { exports: {} }; 56 return fn(module, module.exports), module.exports; 57 } 58 59 function commonjsRequire (target) { 60 throw new Error('Could not dynamically require "' + target + '". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.'); 61 } 62 63 /** Detect free variable `global` from Node.js. */ 64 65 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; 66 67 var _freeGlobal = freeGlobal; 68 69 /** Detect free variable `self`. */ 70 var freeSelf = typeof self == 'object' && self && self.Object === Object && self; 71 72 /** Used as a reference to the global object. */ 73 var root = _freeGlobal || freeSelf || Function('return this')(); 74 75 var _root = root; 76 77 /** Built-in value references. */ 78 var Symbol$1 = _root.Symbol; 79 80 var _Symbol = Symbol$1; 81 82 /** 83 * A specialized version of `_.map` for arrays without support for iteratee 84 * shorthands. 85 * 86 * @private 87 * @param {Array} [array] The array to iterate over. 88 * @param {Function} iteratee The function invoked per iteration. 89 * @returns {Array} Returns the new mapped array. 90 */ 91 function arrayMap(array, iteratee) { 92 var index = -1, 93 length = array == null ? 0 : array.length, 94 result = Array(length); 95 96 while (++index < length) { 97 result[index] = iteratee(array[index], index, array); 98 } 99 return result; 100 } 101 102 var _arrayMap = arrayMap; 103 104 /** 105 * Checks if `value` is classified as an `Array` object. 106 * 107 * @static 108 * @memberOf _ 109 * @since 0.1.0 110 * @category Lang 111 * @param {*} value The value to check. 112 * @returns {boolean} Returns `true` if `value` is an array, else `false`. 113 * @example 114 * 115 * _.isArray([1, 2, 3]); 116 * // => true 117 * 118 * _.isArray(document.body.children); 119 * // => false 120 * 121 * _.isArray('abc'); 122 * // => false 123 * 124 * _.isArray(_.noop); 125 * // => false 126 */ 127 var isArray = Array.isArray; 128 129 var isArray_1 = isArray; 130 131 /** Used for built-in method references. */ 132 var objectProto$e = Object.prototype; 133 134 /** Used to check objects for own properties. */ 135 var hasOwnProperty$b = objectProto$e.hasOwnProperty; 136 137 /** 138 * Used to resolve the 139 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 140 * of values. 141 */ 142 var nativeObjectToString$1 = objectProto$e.toString; 143 144 /** Built-in value references. */ 145 var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined; 146 147 /** 148 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values. 149 * 150 * @private 151 * @param {*} value The value to query. 152 * @returns {string} Returns the raw `toStringTag`. 153 */ 154 function getRawTag(value) { 155 var isOwn = hasOwnProperty$b.call(value, symToStringTag$1), 156 tag = value[symToStringTag$1]; 157 158 try { 159 value[symToStringTag$1] = undefined; 160 var unmasked = true; 161 } catch (e) {} 162 163 var result = nativeObjectToString$1.call(value); 164 if (unmasked) { 165 if (isOwn) { 166 value[symToStringTag$1] = tag; 167 } else { 168 delete value[symToStringTag$1]; 169 } 170 } 171 return result; 172 } 173 174 var _getRawTag = getRawTag; 175 176 /** Used for built-in method references. */ 177 var objectProto$d = Object.prototype; 178 179 /** 180 * Used to resolve the 181 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) 182 * of values. 183 */ 184 var nativeObjectToString = objectProto$d.toString; 185 186 /** 187 * Converts `value` to a string using `Object.prototype.toString`. 188 * 189 * @private 190 * @param {*} value The value to convert. 191 * @returns {string} Returns the converted string. 192 */ 193 function objectToString(value) { 194 return nativeObjectToString.call(value); 195 } 196 197 var _objectToString = objectToString; 198 199 /** `Object#toString` result references. */ 200 var nullTag = '[object Null]',
vendor: 4,967 bytes, lines 201-393
201 undefinedTag = '[object Undefined]'; 202 203 /** Built-in value references. */ 204 var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined; 205 206 /** 207 * The base implementation of `getTag` without fallbacks for buggy environments. 208 * 209 * @private 210 * @param {*} value The value to query. 211 * @returns {string} Returns the `toStringTag`. 212 */ 213 function baseGetTag(value) { 214 if (value == null) { 215 return value === undefined ? undefinedTag : nullTag; 216 } 217 return (symToStringTag && symToStringTag in Object(value)) 218 ? _getRawTag(value) 219 : _objectToString(value); 220 } 221 222 var _baseGetTag = baseGetTag; 223 224 /** 225 * Checks if `value` is object-like. A value is object-like if it's not `null` 226 * and has a `typeof` result of "object". 227 * 228 * @static 229 * @memberOf _ 230 * @since 4.0.0 231 * @category Lang 232 * @param {*} value The value to check. 233 * @returns {boolean} Returns `true` if `value` is object-like, else `false`. 234 * @example 235 * 236 * _.isObjectLike({}); 237 * // => true 238 * 239 * _.isObjectLike([1, 2, 3]); 240 * // => true 241 * 242 * _.isObjectLike(_.noop); 243 * // => false 244 * 245 * _.isObjectLike(null); 246 * // => false 247 */ 248 function isObjectLike(value) { 249 return value != null && typeof value == 'object'; 250 } 251 252 var isObjectLike_1 = isObjectLike; 253 254 /** `Object#toString` result references. */ 255 var symbolTag$3 = '[object Symbol]'; 256 257 /** 258 * Checks if `value` is classified as a `Symbol` primitive or object. 259 * 260 * @static 261 * @memberOf _ 262 * @since 4.0.0 263 * @category Lang 264 * @param {*} value The value to check. 265 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`. 266 * @example 267 * 268 * _.isSymbol(Symbol.iterator); 269 * // => true 270 * 271 * _.isSymbol('abc'); 272 * // => false 273 */ 274 function isSymbol(value) { 275 return typeof value == 'symbol' || 276 (isObjectLike_1(value) && _baseGetTag(value) == symbolTag$3); 277 } 278 279 var isSymbol_1 = isSymbol; 280 281 /** Used as references for various `Number` constants. */ 282 var INFINITY = 1 / 0; 283 284 /** Used to convert symbols to primitives and strings. */ 285 var symbolProto$2 = _Symbol ? _Symbol.prototype : undefined, 286 symbolToString = symbolProto$2 ? symbolProto$2.toString : undefined; 287 288 /** 289 * The base implementation of `_.toString` which doesn't convert nullish 290 * values to empty strings. 291 * 292 * @private 293 * @param {*} value The value to process. 294 * @returns {string} Returns the string. 295 */ 296 function baseToString(value) { 297 // Exit early for strings to avoid a performance hit in some environments. 298 if (typeof value == 'string') { 299 return value; 300 } 301 if (isArray_1(value)) { 302 // Recursively convert values (susceptible to call stack limits). 303 return _arrayMap(value, baseToString) + ''; 304 } 305 if (isSymbol_1(value)) { 306 return symbolToString ? symbolToString.call(value) : ''; 307 } 308 var result = (value + ''); 309 return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; 310 } 311 312 var _baseToString = baseToString; 313 314 /** 315 * Converts `value` to a string. An empty string is returned for `null` 316 * and `undefined` values. The sign of `-0` is preserved. 317 * 318 * @static 319 * @memberOf _ 320 * @since 4.0.0 321 * @category Lang 322 * @param {*} value The value to convert. 323 * @returns {string} Returns the converted string. 324 * @example 325 * 326 * _.toString(null); 327 * // => '' 328 * 329 * _.toString(-0); 330 * // => '-0' 331 * 332 * _.toString([1, 2, 3]); 333 * // => '1,2,3' 334 */ 335 function toString$2(value) { 336 return value == null ? '' : _baseToString(value); 337 } 338 339 var toString_1$1 = toString$2; 340 341 /** 342 * The base implementation of `_.slice` without an iteratee call guard. 343 * 344 * @private 345 * @param {Array} array The array to slice. 346 * @param {number} [start=0] The start position. 347 * @param {number} [end=array.length] The end position. 348 * @returns {Array} Returns the slice of `array`. 349 */ 350 function baseSlice(array, start, end) { 351 var index = -1, 352 length = array.length; 353 354 if (start < 0) { 355 start = -start > length ? 0 : (length + start); 356 } 357 end = end > length ? length : end; 358 if (end < 0) { 359 end += length; 360 } 361 length = start > end ? 0 : ((end - start) >>> 0); 362 start >>>= 0; 363 364 var result = Array(length); 365 while (++index < length) { 366 result[index] = array[index + start]; 367 } 368 return result; 369 } 370 371 var _baseSlice = baseSlice; 372 373 /** 374 * Casts `array` to a slice if it's needed. 375 * 376 * @private 377 * @param {Array} array The array to inspect. 378 * @param {number} start The start position. 379 * @param {number} [end=array.length] The end position. 380 * @returns {Array} Returns the cast slice. 381 */ 382 function castSlice(array, start, end) { 383 var length = array.length; 384 end = end === undefined ? length : end; 385 return (!start && end >= length) ? array : _baseSlice(array, start, end); 386 } 387 388 var _castSlice = castSlice; 389 390 /** Used to compose unicode character classes. */ 391 var rsAstralRange$2 = '\\ud800-\\udfff', 392 rsComboMarksRange$3 = '\\u0300-\\u036f', 393 reComboHalfMarksRange$3 = '\\ufe20-\\ufe2f',
vendor: 8,157 bytes, lines 394-638
394 rsComboSymbolsRange$3 = '\\u20d0-\\u20ff', 395 rsComboRange$3 = rsComboMarksRange$3 + reComboHalfMarksRange$3 + rsComboSymbolsRange$3, 396 rsVarRange$2 = '\\ufe0e\\ufe0f'; 397 398 /** Used to compose unicode capture groups. */ 399 var rsZWJ$2 = '\\u200d'; 400 401 /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ 402 var reHasUnicode = RegExp('[' + rsZWJ$2 + rsAstralRange$2 + rsComboRange$3 + rsVarRange$2 + ']'); 403 404 /** 405 * Checks if `string` contains Unicode symbols. 406 * 407 * @private 408 * @param {string} string The string to inspect. 409 * @returns {boolean} Returns `true` if a symbol is found, else `false`. 410 */ 411 function hasUnicode(string) { 412 return reHasUnicode.test(string); 413 } 414 415 var _hasUnicode = hasUnicode; 416 417 /** 418 * Converts an ASCII `string` to an array. 419 * 420 * @private 421 * @param {string} string The string to convert. 422 * @returns {Array} Returns the converted array. 423 */ 424 function asciiToArray(string) { 425 return string.split(''); 426 } 427 428 var _asciiToArray = asciiToArray; 429 430 /** Used to compose unicode character classes. */ 431 var rsAstralRange$1 = '\\ud800-\\udfff', 432 rsComboMarksRange$2 = '\\u0300-\\u036f', 433 reComboHalfMarksRange$2 = '\\ufe20-\\ufe2f', 434 rsComboSymbolsRange$2 = '\\u20d0-\\u20ff', 435 rsComboRange$2 = rsComboMarksRange$2 + reComboHalfMarksRange$2 + rsComboSymbolsRange$2, 436 rsVarRange$1 = '\\ufe0e\\ufe0f'; 437 438 /** Used to compose unicode capture groups. */ 439 var rsAstral = '[' + rsAstralRange$1 + ']', 440 rsCombo$2 = '[' + rsComboRange$2 + ']', 441 rsFitz$1 = '\\ud83c[\\udffb-\\udfff]', 442 rsModifier$1 = '(?:' + rsCombo$2 + '|' + rsFitz$1 + ')', 443 rsNonAstral$1 = '[^' + rsAstralRange$1 + ']', 444 rsRegional$1 = '(?:\\ud83c[\\udde6-\\uddff]){2}', 445 rsSurrPair$1 = '[\\ud800-\\udbff][\\udc00-\\udfff]', 446 rsZWJ$1 = '\\u200d'; 447 448 /** Used to compose unicode regexes. */ 449 var reOptMod$1 = rsModifier$1 + '?', 450 rsOptVar$1 = '[' + rsVarRange$1 + ']?', 451 rsOptJoin$1 = '(?:' + rsZWJ$1 + '(?:' + [rsNonAstral$1, rsRegional$1, rsSurrPair$1].join('|') + ')' + rsOptVar$1 + reOptMod$1 + ')*', 452 rsSeq$1 = rsOptVar$1 + reOptMod$1 + rsOptJoin$1, 453 rsSymbol = '(?:' + [rsNonAstral$1 + rsCombo$2 + '?', rsCombo$2, rsRegional$1, rsSurrPair$1, rsAstral].join('|') + ')'; 454 455 /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ 456 var reUnicode = RegExp(rsFitz$1 + '(?=' + rsFitz$1 + ')|' + rsSymbol + rsSeq$1, 'g'); 457 458 /** 459 * Converts a Unicode `string` to an array. 460 * 461 * @private 462 * @param {string} string The string to convert. 463 * @returns {Array} Returns the converted array. 464 */ 465 function unicodeToArray(string) { 466 return string.match(reUnicode) || []; 467 } 468 469 var _unicodeToArray = unicodeToArray; 470 471 /** 472 * Converts `string` to an array. 473 * 474 * @private 475 * @param {string} string The string to convert. 476 * @returns {Array} Returns the converted array. 477 */ 478 function stringToArray(string) { 479 return _hasUnicode(string) 480 ? _unicodeToArray(string) 481 : _asciiToArray(string); 482 } 483 484 var _stringToArray = stringToArray; 485 486 /** 487 * Creates a function like `_.lowerFirst`. 488 * 489 * @private 490 * @param {string} methodName The name of the `String` case method to use. 491 * @returns {Function} Returns the new case function. 492 */ 493 function createCaseFirst(methodName) { 494 return function(string) { 495 string = toString_1$1(string); 496 497 var strSymbols = _hasUnicode(string) 498 ? _stringToArray(string) 499 : undefined; 500 501 var chr = strSymbols 502 ? strSymbols[0] 503 : string.charAt(0); 504 505 var trailing = strSymbols 506 ? _castSlice(strSymbols, 1).join('') 507 : string.slice(1); 508 509 return chr[methodName]() + trailing; 510 }; 511 } 512 513 var _createCaseFirst = createCaseFirst; 514 515 /** 516 * Converts the first character of `string` to upper case. 517 * 518 * @static 519 * @memberOf _ 520 * @since 4.0.0 521 * @category String 522 * @param {string} [string=''] The string to convert. 523 * @returns {string} Returns the converted string. 524 * @example 525 * 526 * _.upperFirst('fred'); 527 * // => 'Fred' 528 * 529 * _.upperFirst('FRED'); 530 * // => 'FRED' 531 */ 532 var upperFirst = _createCaseFirst('toUpperCase'); 533 534 var upperFirst_1 = upperFirst; 535 536 /** 537 * Converts the first character of `string` to upper case and the remaining 538 * to lower case. 539 * 540 * @static 541 * @memberOf _ 542 * @since 3.0.0 543 * @category String 544 * @param {string} [string=''] The string to capitalize. 545 * @returns {string} Returns the capitalized string. 546 * @example 547 * 548 * _.capitalize('FRED'); 549 * // => 'Fred' 550 */ 551 function capitalize(string) { 552 return upperFirst_1(toString_1$1(string).toLowerCase()); 553 } 554 555 var capitalize_1 = capitalize; 556 557 /** 558 * A specialized version of `_.reduce` for arrays without support for 559 * iteratee shorthands. 560 * 561 * @private 562 * @param {Array} [array] The array to iterate over. 563 * @param {Function} iteratee The function invoked per iteration. 564 * @param {*} [accumulator] The initial value. 565 * @param {boolean} [initAccum] Specify using the first element of `array` as 566 * the initial value. 567 * @returns {*} Returns the accumulated value. 568 */ 569 function arrayReduce(array, iteratee, accumulator, initAccum) { 570 var index = -1, 571 length = array == null ? 0 : array.length; 572 573 if (initAccum && length) { 574 accumulator = array[++index]; 575 } 576 while (++index < length) { 577 accumulator = iteratee(accumulator, array[index], index, array); 578 } 579 return accumulator; 580 } 581 582 var _arrayReduce = arrayReduce; 583 584 /** 585 * The base implementation of `_.propertyOf` without support for deep paths. 586 * 587 * @private 588 * @param {Object} object The object to query. 589 * @returns {Function} Returns the new accessor function. 590 */ 591 function basePropertyOf(object) { 592 return function(key) { 593 return object == null ? undefined : object[key]; 594 }; 595 } 596 597 var _basePropertyOf = basePropertyOf; 598 599 /** Used to map Latin Unicode letters to basic Latin letters. */ 600 var deburredLetters = { 601 // Latin-1 Supplement block. 602 '\xc0': 'A', '\xc1': 'A', '\xc2': 'A', '\xc3': 'A', '\xc4': 'A', '\xc5': 'A', 603 '\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a', 604 '\xc7': 'C', '\xe7': 'c', 605 '\xd0': 'D', '\xf0': 'd', 606 '\xc8': 'E', '\xc9': 'E', '\xca': 'E', '\xcb': 'E', 607 '\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e', 608 '\xcc': 'I', '\xcd': 'I', '\xce': 'I', '\xcf': 'I', 609 '\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i', 610 '\xd1': 'N', '\xf1': 'n', 611 '\xd2': 'O', '\xd3': 'O', '\xd4': 'O', '\xd5': 'O', '\xd6': 'O', '\xd8': 'O', 612 '\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o', 613 '\xd9': 'U', '\xda': 'U', '\xdb': 'U', '\xdc': 'U', 614 '\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u', 615 '\xdd': 'Y', '\xfd': 'y', '\xff': 'y', 616 '\xc6': 'Ae', '\xe6': 'ae', 617 '\xde': 'Th', '\xfe': 'th', 618 '\xdf': 'ss', 619 // Latin Extended-A block. 620 '\u0100': 'A', '\u0102': 'A', '\u0104': 'A', 621 '\u0101': 'a', '\u0103': 'a', '\u0105': 'a', 622 '\u0106': 'C', '\u0108': 'C', '\u010a': 'C', '\u010c': 'C', 623 '\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c', 624 '\u010e': 'D', '\u0110': 'D', '\u010f': 'd', '\u0111': 'd', 625 '\u0112': 'E', '\u0114': 'E', '\u0116': 'E', '\u0118': 'E', '\u011a': 'E', 626 '\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e', 627 '\u011c': 'G', '\u011e': 'G', '\u0120': 'G', '\u0122': 'G', 628 '\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g', 629 '\u0124': 'H', '\u0126': 'H', '\u0125': 'h', '\u0127': 'h', 630 '\u0128': 'I', '\u012a': 'I', '\u012c': 'I', '\u012e': 'I', '\u0130': 'I', 631 '\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i', 632 '\u0134': 'J', '\u0135': 'j', 633 '\u0136': 'K', '\u0137': 'k', '\u0138': 'k', 634 '\u0139': 'L', '\u013b': 'L', '\u013d': 'L', '\u013f': 'L', '\u0141': 'L', 635 '\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l', 636 '\u0143': 'N', '\u0145': 'N', '\u0147': 'N', '\u014a': 'N', 637 '\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n', 638 '\u014c': 'O', '\u014e': 'O', '\u0150': 'O',
639 '\u014d': 'o', '\u014f': 'o', '\u0151': 'o', 640 '\u0154': 'R', '\u0156': 'R', '\u0158': 'R', 641 '\u0155': 'r', '\u0157': 'r', '\u0159': 'r', 642 '\u015a': 'S', '\u015c': 'S', '\u015e': 'S', '\u0160': 'S', 643 '\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's', 644 '\u0162': 'T', '\u0164': 'T', '\u0166': 'T', 645 '\u0163': 't', '\u0165': 't', '\u0167': 't', 646 '\u0168': 'U', '\u016a': 'U', '\u016c': 'U', '\u016e': 'U', '\u0170': 'U', '\u0172': 'U', 647 '\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u', 648 '\u0174': 'W', '\u0175': 'w', 649 '\u0176': 'Y', '\u0177': 'y', '\u0178': 'Y', 650 '\u0179': 'Z', '\u017b': 'Z', '\u017d': 'Z', 651 '\u017a': 'z', '\u017c': 'z', '\u017e': 'z', 652 '\u0132': 'IJ', '\u0133': 'ij', 653 '\u0152': 'Oe', '\u0153': 'oe', 654 '\u0149': "'n", '\u017f': 's' 655 }; 656 657 /** 658 * Used by `_.deburr` to convert Latin-1 Supplement and Latin Extended-A 659 * letters to basic Latin letters. 660 * 661 * @private 662 * @param {string} letter The matched letter to deburr. 663 * @returns {string} Returns the deburred letter. 664 */ 665 var deburrLetter = _basePropertyOf(deburredLetters); 666 667 var _deburrLetter = deburrLetter; 668 669 /** Used to match Latin Unicode letters (excluding mathematical operators). */
vendor: 6,692 bytes, lines 670-855
670 var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g; 671 672 /** Used to compose unicode character classes. */ 673 var rsComboMarksRange$1 = '\\u0300-\\u036f', 674 reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f', 675 rsComboSymbolsRange$1 = '\\u20d0-\\u20ff', 676 rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1; 677 678 /** Used to compose unicode capture groups. */ 679 var rsCombo$1 = '[' + rsComboRange$1 + ']'; 680 681 /** 682 * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and 683 * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). 684 */ 685 var reComboMark = RegExp(rsCombo$1, 'g'); 686 687 /** 688 * Deburrs `string` by converting 689 * [Latin-1 Supplement](https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)#Character_table) 690 * and [Latin Extended-A](https://en.wikipedia.org/wiki/Latin_Extended-A) 691 * letters to basic Latin letters and removing 692 * [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). 693 * 694 * @static 695 * @memberOf _ 696 * @since 3.0.0 697 * @category String 698 * @param {string} [string=''] The string to deburr. 699 * @returns {string} Returns the deburred string. 700 * @example 701 * 702 * _.deburr('déjà vu'); 703 * // => 'deja vu' 704 */ 705 function deburr(string) { 706 string = toString_1$1(string); 707 return string && string.replace(reLatin, _deburrLetter).replace(reComboMark, ''); 708 } 709 710 var deburr_1 = deburr; 711 712 /** Used to match words composed of alphanumeric characters. */ 713 var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g; 714 715 /** 716 * Splits an ASCII `string` into an array of its words. 717 * 718 * @private 719 * @param {string} The string to inspect. 720 * @returns {Array} Returns the words of `string`. 721 */ 722 function asciiWords(string) { 723 return string.match(reAsciiWord) || []; 724 } 725 726 var _asciiWords = asciiWords; 727 728 /** Used to detect strings that need a more robust regexp to match words. */ 729 var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/; 730 731 /** 732 * Checks if `string` contains a word composed of Unicode symbols. 733 * 734 * @private 735 * @param {string} string The string to inspect. 736 * @returns {boolean} Returns `true` if a word is found, else `false`. 737 */ 738 function hasUnicodeWord(string) { 739 return reHasUnicodeWord.test(string); 740 } 741 742 var _hasUnicodeWord = hasUnicodeWord; 743 744 /** Used to compose unicode character classes. */ 745 var rsAstralRange = '\\ud800-\\udfff', 746 rsComboMarksRange = '\\u0300-\\u036f', 747 reComboHalfMarksRange = '\\ufe20-\\ufe2f', 748 rsComboSymbolsRange = '\\u20d0-\\u20ff', 749 rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, 750 rsDingbatRange = '\\u2700-\\u27bf', 751 rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', 752 rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', 753 rsNonCharRange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf', 754 rsPunctuationRange = '\\u2000-\\u206f', 755 rsSpaceRange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000', 756 rsUpperRange = 'A-Z\\xc0-\\xd6\\xd8-\\xde', 757 rsVarRange = '\\ufe0e\\ufe0f', 758 rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange; 759 760 /** Used to compose unicode capture groups. */ 761 var rsApos$1 = "['\u2019]", 762 rsBreak = '[' + rsBreakRange + ']', 763 rsCombo = '[' + rsComboRange + ']', 764 rsDigits = '\\d+', 765 rsDingbat = '[' + rsDingbatRange + ']', 766 rsLower = '[' + rsLowerRange + ']', 767 rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', 768 rsFitz = '\\ud83c[\\udffb-\\udfff]', 769 rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', 770 rsNonAstral = '[^' + rsAstralRange + ']', 771 rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', 772 rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', 773 rsUpper = '[' + rsUpperRange + ']', 774 rsZWJ = '\\u200d'; 775 776 /** Used to compose unicode regexes. */ 777 var rsMiscLower = '(?:' + rsLower + '|' + rsMisc + ')', 778 rsMiscUpper = '(?:' + rsUpper + '|' + rsMisc + ')', 779 rsOptContrLower = '(?:' + rsApos$1 + '(?:d|ll|m|re|s|t|ve))?', 780 rsOptContrUpper = '(?:' + rsApos$1 + '(?:D|LL|M|RE|S|T|VE))?', 781 reOptMod = rsModifier + '?', 782 rsOptVar = '[' + rsVarRange + ']?', 783 rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*', 784 rsOrdLower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])', 785 rsOrdUpper = '\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])', 786 rsSeq = rsOptVar + reOptMod + rsOptJoin, 787 rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq; 788 789 /** Used to match complex or compound words. */ 790 var reUnicodeWord = RegExp([ 791 rsUpper + '?' + rsLower + '+' + rsOptContrLower + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', 792 rsMiscUpper + '+' + rsOptContrUpper + '(?=' + [rsBreak, rsUpper + rsMiscLower, '$'].join('|') + ')', 793 rsUpper + '?' + rsMiscLower + '+' + rsOptContrLower, 794 rsUpper + '+' + rsOptContrUpper, 795 rsOrdUpper, 796 rsOrdLower, 797 rsDigits, 798 rsEmoji 799 ].join('|'), 'g'); 800 801 /** 802 * Splits a Unicode `string` into an array of its words. 803 * 804 * @private 805 * @param {string} The string to inspect. 806 * @returns {Array} Returns the words of `string`. 807 */ 808 function unicodeWords(string) { 809 return string.match(reUnicodeWord) || []; 810 } 811 812 var _unicodeWords = unicodeWords; 813 814 /** 815 * Splits `string` into an array of its words. 816 * 817 * @static 818 * @memberOf _ 819 * @since 3.0.0 820 * @category String 821 * @param {string} [string=''] The string to inspect. 822 * @param {RegExp|string} [pattern] The pattern to match words. 823 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. 824 * @returns {Array} Returns the words of `string`. 825 * @example 826 * 827 * _.words('fred, barney, & pebbles'); 828 * // => ['fred', 'barney', 'pebbles'] 829 * 830 * _.words('fred, barney, & pebbles', /[^, ]+/g); 831 * // => ['fred', 'barney', '&', 'pebbles'] 832 */ 833 function words(string, pattern, guard) { 834 string = toString_1$1(string); 835 pattern = guard ? undefined : pattern; 836 837 if (pattern === undefined) { 838 return _hasUnicodeWord(string) ? _unicodeWords(string) : _asciiWords(string); 839 } 840 return string.match(pattern) || []; 841 } 842 843 var words_1 = words; 844 845 /** Used to compose unicode capture groups. */ 846 var rsApos = "['\u2019]"; 847 848 /** Used to match apostrophes. */ 849 var reApos = RegExp(rsApos, 'g'); 850 851 /** 852 * Creates a function like `_.camelCase`. 853 * 854 * @private 855 * @param {Function}
855 callback The function to combine each word. 856 * @returns {Function} Returns the new compounder function. 857 */ 858 function createCompounder(callback) { 859 return function(string) { 860 return _arrayReduce(words_1(deburr_1(string).replace(reApos, '')), callback, ''); 861 }; 862 } 863 864 var _createCompounder = createCompounder; 865 866 /** 867 * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). 868 * 869 * @static 870 * @memberOf _ 871 * @since 3.0.0 872 * @category String 873 * @param {string} [string=''] The string to convert. 874 * @returns {string} Returns the camel cased string. 875 * @example 876 * 877 * _.camelCase('Foo Bar'); 878 * // => 'fooBar' 879 * 880 * _.camelCase('--foo-bar--'); 881 * // => 'fooBar' 882 * 883 * _.camelCase('__FOO_BAR__'); 884 * // => 'fooBar' 885 */ 886 var camelCase = _createCompounder(function(result, word, index) { 887 word = word.toLowerCase(); 888 return result + (index ? capitalize_1(word) : word); 889 }); 890 891 var camelCase_1 = camelCase; 892 893 /** 894 Utility routines for Sargasso classes 895 896 @author Michael Rhodes (except where noted) 897 @license MIT 898 Made in Barbados ð§ð§ Copyright © 2020 Michael Rhodes 899 **/ 900 901 const elementMetaData = new WeakMap(); 902 903 const hasClass = (element, cssClass) => { 904 const className = element.className || ''; 905 const classes = className.split(/\s+/); 906 return classes.indexOf(cssClass) !== -1 907 }; 908 909 // addClasses can be: 910 // a string 'someclass' 911 // a list delimited by comma or space 'class1 class3 class4' 912 // an array ['class1','class2'] 913 const addClass = (element, addClasses) => { 914 const className = element.className || ''; 915 const classes = className.split(/\s+/); 916 917 if (!Array.isArray(addClasses)) { 918 addClasses = addClasses.split(/[\s,]/); 919 } 920 921 addClasses.forEach((c) => { 922 c = c.trim(); 923 if (classes.indexOf(c) === -1) { 924 classes.push(c); 925 } 926 }); 927 928 element.className = classes.join(' '); 929 }; 930 931 // removeClasses can be: 932 // a string 'someclass' 933 // a list delimited by comma or space 'class1 class3 class4' 934 // an array ['class1','class2'] 935 const removeClass = (element, removeClasses) => { 936 const className = element.className || ''; 937 const classes = className.split(/\s+/); 938 939 if (!Array.isArray(removeClasses)) { 940 removeClasses = removeClasses.split(/[\s,]/); 941 } 942 943 removeClasses.forEach((c) => { 944 c = c.trim(); 945 if (classes.indexOf(c) !== -1) { 946 classes.splice(classes.indexOf(c), 1); 947 } 948 }); 949 950 element.className = classes.join(' '); 951 }; 952 953 const isVisible = (element) => { 954 return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length) 955 }; 956 957 const inViewPort = (element, container = window) => { 958 const rect = element.getBoundingClientRect(); 959 const visible = isVisible(element); 960 const aboveTheTop = (rect.bottom < 0); 961 let belowTheFold; 962 963 if (container.self === window) { 964 belowTheFold = (rect.top > (window.innerHeight || document.documentElement.clientHeight)); 965 } else { 966 belowTheFold = (rect.top > container.clientHeight); 967 } 968 969 return (visible && !belowTheFold && !aboveTheTop) 970 }; 971 972 /* 973 element: element to apply to 974 css: JSON object with properties in kebab-case or camelCase (or even in snake_case and seperate words) 975 */ 976 977 const css = (element, css) => { 978 for (const prop in css) { 979 if (Object.prototype.hasOwnProperty.call(css, prop)) { 980 const key = camelCase_1(prop); 981 element.style[key] = css[prop] !== null ? css[prop] : null; 982 } 983 } 984 }; 985 986 const setMetaData = (element, k, v) => { 987 const data = elementMetaData.get(element) || {}; 988 if (v) { 989 data[k] = v; 990 } else { 991 delete data[k]; 992 } 993 elementMetaData.set(element, data); 994 }; 995 996 const getMetaData = (element, k) => { 997 const data = elementMetaData.get(element) || {}; 998 if (k) { 999 return data[k] 1000 } else { 1001 return data 1002 } 1003 }; 1004 1005 const on = function (uid, container, events, selector, fn, options, once) { 1006 // selector is optional 1007 if (typeof selector === 'function') { 1008 once = options; 1009 options = fn; 1010 fn = selector; 1011 selector = undefined; 1012 } 1013 1014 const k = 'on:' + uid + '-' + events + '-' + selector; 1015 1016 if (getMetaData(container, k)) { // duplicate event handler. 1017 console.error('Error: Sargasso utils.on: duplicate event handler specification. %o %s', container, k); 1018 return 1019 } 1020 1021 const handler = (e) => { 1022 if (once) { 1023 off(uid, container, events, selector); 1024 } 1025 1026 if (!selector) { 1027 fn(e); 1028 } else {
1029 Array.from(container.querySelectorAll(selector)).forEach((el) => { 1030 if (e.target === el || el.contains(e.target)) { 1031 fn(e, el); 1032 } 1033 }); 1034 } 1035 }; 1036 1037 // store handler spec in metadata so we can gracefully remove it later 1038 const data = { 1039 uid: uid, 1040 events: events, 1041 selector: selector || undefined, 1042 fn: handler, 1043 options: options || false 1044 }; 1045 1046 setMetaData(container, k, data); 1047 1048 events.split(/[\s,]+/).forEach((evt) => { 1049 container.addEventListener(evt.trim(), data.fn, data.options); 1050 }); 1051 }; 1052 1053 const off = function (uid, container, events, selector) { 1054 const k = 'on:' + uid + '-' + events + '-' + selector; 1055 const data = getMetaData(container, k); 1056 if (data) { 1057 events.split(/[\s,]+/).forEach((evt) => { 1058 container.removeEventListener(evt.trim(), data.fn, data.options); 1059 }); 1060 setMetaData(container, k); 1061 } 1062 }; 1063 1064 // remove all (on,once) event handlers for element 1065 const offAll = function (container) { 1066 const data = elementMetaData.get(container) || {}; 1067 const handlers = []; 1068 1069 for (const k in data) { 1070 if (Object.prototype.hasOwnProperty.call(data, k)) { 1071 if (k.match(/^on:/)) { 1072 handlers.push(k); 1073 } 1074 } 1075 } 1076 1077 handlers.forEach((k) => { 1078 off(data[k].uid, container, data[k].events, data[k].selector); 1079 }); 1080 }; 1081 1082 const once = function (uid, container, events, selector, fn, options) { 1083 if (typeof selector === 'function') { 1084 options = fn; 1085 fn = selector; 1086 selector = undefined; 1087 } 1088 on(uid, container, events, selector, fn, options, true); 1089 }; 1090 1091 const elementTools = { 1092 hasClass: hasClass, 1093 addClass: addClass, 1094 removeClass: removeClass, 1095 isVisible: isVisible, 1096 inViewPort: inViewPort, 1097 setCSS: css, 1098 setMetaData: setMetaData, 1099 getMetaData: getMetaData, 1100 on: on, 1101 off: off, 1102 once: once, 1103 offAll: offAll 1104 }; 1105 1106 /** 1107 * Checks if `value` is the 1108 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) 1109 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) 1110 * 1111 * @static 1112 * @memberOf _ 1113 * @since 0.1.0 1114 * @category Lang 1115 * @param {*} value The value to check. 1116 * @returns {boolean} Returns `true` if `value` is an object, else `false`. 1117 * @example 1118 * 1119 * _.isObject({}); 1120 * // => true 1121 * 1122 * _.isObject([1, 2, 3]); 1123 * // => true 1124 * 1125 * _.isObject(_.noop); 1126 * // => true 1127 * 1128 * _.isObject(null); 1129 * // => false 1130 */ 1131 function isObject(value) { 1132 var type = typeof value; 1133 return value != null && (type == 'object' || type == 'function'); 1134 } 1135 1136 var isObject_1 = isObject; 1137 1138 /** 1139 * Gets the timestamp of the number of milliseconds that have elapsed since 1140 * the Unix epoch (1 January 1970 00:00:00 UTC). 1141 * 1142 * @static 1143 * @memberOf _ 1144 * @since 2.4.0 1145 * @category Date 1146 * @returns {number} Returns the timestamp. 1147 * @example 1148 * 1149 * _.defer(function(stamp) { 1150 * console.log(_.now() - stamp); 1151 * }, _.now()); 1152 * // => Logs the number of milliseconds it took for the deferred invocation. 1153 */ 1154 var now = function() { 1155 return _root.Date.now(); 1156 }; 1157 1158 var now_1 = now; 1159 1160 /** Used to match a single whitespace character. */ 1161 var reWhitespace = /\s/; 1162 1163 /** 1164 * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace 1165 * character of `string`. 1166 * 1167 * @private 1168 * @param {string} string The string to inspect. 1169 * @returns {number} Returns the index of the last non-whitespace character. 1170 */ 1171 function trimmedEndIndex(string) { 1172 var index = string.length; 1173 1174 while (index-- && reWhitespace.test(string.charAt(index))) {} 1175 return index; 1176 } 1177 1178 var _trimmedEndIndex = trimmedEndIndex; 1179 1180 /** Used to match leading whitespace. */ 1181 var reTrimStart = /^\s+/; 1182 1183 /** 1184 * The base implementation of `_.trim`. 1185 * 1186 * @private 1187 * @param {string} string The string to trim. 1188 * @returns {string} Returns the trimmed string. 1189 */ 1190 function baseTrim(string) { 1191 return string 1192 ? string.slice(0, _trimmedEndIndex(string) + 1).replace(reTrimStart, '') 1193 : string; 1194 } 1195 1196 var _baseTrim = baseTrim; 1197 1198 /** Used as references for various `Number` constants. */ 1199 var NAN = 0 / 0; 1200 1201 /** Used to detect bad signed hexadecimal string values. */ 1202 var reIsBadHex = /^[-+]0x[0-9a-f]+$/i; 1203 1204 /** Used to detect binary string values. */
vendor: 8,643 bytes, lines 1205-1504
1205 var reIsBinary = /^0b[01]+$/i; 1206 1207 /** Used to detect octal string values. */ 1208 var reIsOctal = /^0o[0-7]+$/i; 1209 1210 /** Built-in method references without a dependency on `root`. */ 1211 var freeParseInt = parseInt; 1212 1213 /** 1214 * Converts `value` to a number. 1215 * 1216 * @static 1217 * @memberOf _ 1218 * @since 4.0.0 1219 * @category Lang 1220 * @param {*} value The value to process. 1221 * @returns {number} Returns the number. 1222 * @example 1223 * 1224 * _.toNumber(3.2); 1225 * // => 3.2 1226 * 1227 * _.toNumber(Number.MIN_VALUE); 1228 * // => 5e-324 1229 * 1230 * _.toNumber(Infinity); 1231 * // => Infinity 1232 * 1233 * _.toNumber('3.2'); 1234 * // => 3.2 1235 */ 1236 function toNumber(value) { 1237 if (typeof value == 'number') { 1238 return value; 1239 } 1240 if (isSymbol_1(value)) { 1241 return NAN; 1242 } 1243 if (isObject_1(value)) { 1244 var other = typeof value.valueOf == 'function' ? value.valueOf() : value; 1245 value = isObject_1(other) ? (other + '') : other; 1246 } 1247 if (typeof value != 'string') { 1248 return value === 0 ? value : +value; 1249 } 1250 value = _baseTrim(value); 1251 var isBinary = reIsBinary.test(value); 1252 return (isBinary || reIsOctal.test(value)) 1253 ? freeParseInt(value.slice(2), isBinary ? 2 : 8) 1254 : (reIsBadHex.test(value) ? NAN : +value); 1255 } 1256 1257 var toNumber_1 = toNumber; 1258 1259 /** Error message constants. */ 1260 var FUNC_ERROR_TEXT = 'Expected a function'; 1261 1262 /* Built-in method references for those with the same name as other `lodash` methods. */ 1263 var nativeMax = Math.max, 1264 nativeMin = Math.min; 1265 1266 /** 1267 * Creates a debounced function that delays invoking `func` until after `wait` 1268 * milliseconds have elapsed since the last time the debounced function was 1269 * invoked. The debounced function comes with a `cancel` method to cancel 1270 * delayed `func` invocations and a `flush` method to immediately invoke them. 1271 * Provide `options` to indicate whether `func` should be invoked on the 1272 * leading and/or trailing edge of the `wait` timeout. The `func` is invoked 1273 * with the last arguments provided to the debounced function. Subsequent 1274 * calls to the debounced function return the result of the last `func` 1275 * invocation. 1276 * 1277 * **Note:** If `leading` and `trailing` options are `true`, `func` is 1278 * invoked on the trailing edge of the timeout only if the debounced function 1279 * is invoked more than once during the `wait` timeout. 1280 * 1281 * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred 1282 * until to the next tick, similar to `setTimeout` with a timeout of `0`. 1283 * 1284 * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/) 1285 * for details over the differences between `_.debounce` and `_.throttle`. 1286 * 1287 * @static 1288 * @memberOf _ 1289 * @since 0.1.0 1290 * @category Function 1291 * @param {Function} func The function to debounce. 1292 * @param {number} [wait=0] The number of milliseconds to delay. 1293 * @param {Object} [options={}] The options object. 1294 * @param {boolean} [options.leading=false] 1295 * Specify invoking on the leading edge of the timeout. 1296 * @param {number} [options.maxWait] 1297 * The maximum time `func` is allowed to be delayed before it's invoked. 1298 * @param {boolean} [options.trailing=true] 1299 * Specify invoking on the trailing edge of the timeout. 1300 * @returns {Function} Returns the new debounced function. 1301 * @example 1302 * 1303 * // Avoid costly calculations while the window size is in flux. 1304 * jQuery(window).on('resize', _.debounce(calculateLayout, 150)); 1305 * 1306 * // Invoke `sendMail` when clicked, debouncing subsequent calls. 1307 * jQuery(element).on('click', _.debounce(sendMail, 300, { 1308 * 'leading': true, 1309 * 'trailing': false 1310 * })); 1311 * 1312 * // Ensure `batchLog` is invoked once after 1 second of debounced calls. 1313 * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 }); 1314 * var source = new EventSource('/stream'); 1315 * jQuery(source).on('message', debounced); 1316 * 1317 * // Cancel the trailing debounced invocation. 1318 * jQuery(window).on('popstate', debounced.cancel); 1319 */ 1320 function debounce(func, wait, options) { 1321 var lastArgs, 1322 lastThis, 1323 maxWait, 1324 result, 1325 timerId, 1326 lastCallTime, 1327 lastInvokeTime = 0, 1328 leading = false, 1329 maxing = false, 1330 trailing = true; 1331 1332 if (typeof func != 'function') { 1333 throw new TypeError(FUNC_ERROR_TEXT); 1334 } 1335 wait = toNumber_1(wait) || 0; 1336 if (isObject_1(options)) { 1337 leading = !!options.leading; 1338 maxing = 'maxWait' in options; 1339 maxWait = maxing ? nativeMax(toNumber_1(options.maxWait) || 0, wait) : maxWait; 1340 trailing = 'trailing' in options ? !!options.trailing : trailing; 1341 } 1342 1343 function invokeFunc(time) { 1344 var args = lastArgs, 1345 thisArg = lastThis; 1346 1347 lastArgs = lastThis = undefined; 1348 lastInvokeTime = time; 1349 result = func.apply(thisArg, args); 1350 return result; 1351 } 1352 1353 function leadingEdge(time) { 1354 // Reset any `maxWait` timer. 1355 lastInvokeTime = time; 1356 // Start the timer for the trailing edge. 1357 timerId = setTimeout(timerExpired, wait); 1358 // Invoke the leading edge. 1359 return leading ? invokeFunc(time) : result; 1360 } 1361 1362 function remainingWait(time) { 1363 var timeSinceLastCall = time - lastCallTime, 1364 timeSinceLastInvoke = time - lastInvokeTime, 1365 timeWaiting = wait - timeSinceLastCall; 1366 1367 return maxing 1368 ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) 1369 : timeWaiting; 1370 } 1371 1372 function shouldInvoke(time) { 1373 var timeSinceLastCall = time - lastCallTime, 1374 timeSinceLastInvoke = time - lastInvokeTime; 1375 1376 // Either this is the first call, activity has stopped and we're at the 1377 // trailing edge, the system time has gone backwards and we're treating 1378 // it as the trailing edge, or we've hit the `maxWait` limit. 1379 return (lastCallTime === undefined || (timeSinceLastCall >= wait) || 1380 (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait)); 1381 } 1382 1383 function timerExpired() { 1384 var time = now_1(); 1385 if (shouldInvoke(time)) { 1386 return trailingEdge(time); 1387 } 1388 // Restart the timer. 1389 timerId = setTimeout(timerExpired, remainingWait(time)); 1390 } 1391 1392 function trailingEdge(time) { 1393 timerId = undefined; 1394 1395 // Only invoke if we have `lastArgs` which means `func` has been 1396 // debounced at least once. 1397 if (trailing && lastArgs) { 1398 return invokeFunc(time); 1399 } 1400 lastArgs = lastThis = undefined; 1401 return result; 1402 } 1403 1404 function cancel() { 1405 if (timerId !== undefined) { 1406 clearTimeout(timerId); 1407 } 1408 lastInvokeTime = 0; 1409 lastArgs = lastCallTime = lastThis = timerId = undefined; 1410 } 1411 1412 function flush() { 1413 return timerId === undefined ? result : trailingEdge(now_1()); 1414 } 1415 1416 function debounced() { 1417 var time = now_1(), 1418 isInvoking = shouldInvoke(time); 1419 1420 lastArgs = arguments; 1421 lastThis = this; 1422 lastCallTime = time; 1423 1424 if (isInvoking) { 1425 if (timerId === undefined) { 1426 return leadingEdge(lastCallTime); 1427 } 1428 if (maxing) { 1429 // Handle invocations in a tight loop. 1430 clearTimeout(timerId); 1431 timerId = setTimeout(timerExpired, wait); 1432 return invokeFunc(lastCallTime); 1433 } 1434 } 1435 if (timerId === undefined) { 1436 timerId = setTimeout(timerExpired, wait); 1437 } 1438 return result; 1439 } 1440 debounced.cancel = cancel; 1441 debounced.flush = flush; 1442 return debounced; 1443 } 1444 1445 var debounce_1 = debounce; 1446 1447 /** 1448 * Removes all key-value entries from the list cache. 1449 * 1450 * @private 1451 * @name clear 1452 * @memberOf ListCache 1453 */ 1454 function listCacheClear() { 1455 this.__data__ = []; 1456 this.size = 0; 1457 } 1458 1459 var _listCacheClear = listCacheClear; 1460 1461 /** 1462 * Performs a 1463 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 1464 * comparison between two values to determine if they are equivalent. 1465 * 1466 * @static 1467 * @memberOf _ 1468 * @since 4.0.0 1469 * @category Lang 1470 * @param {*} value The value to compare. 1471 * @param {*} other The other value to compare. 1472 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 1473 * @example 1474 * 1475 * var object = { 'a': 1 }; 1476 * var other = { 'a': 1 }; 1477 * 1478 * _.eq(object, object); 1479 * // => true 1480 * 1481 * _.eq(object, other); 1482 * // => false 1483 * 1484 * _.eq('a', 'a'); 1485 * // => true 1486 * 1487 * _.eq('a', Object('a')); 1488 * // => false 1489 * 1490 * _.eq(NaN, NaN); 1491 * // => true 1492 */ 1493 function eq(value, other) { 1494 return value === other || (value !== value && other !== other); 1495 } 1496 1497 var eq_1 = eq; 1498 1499 /** 1500 * Gets the index at which the `key` is found in `array` of key-value pairs. 1501 * 1502 * @private 1503 * @param {Array} array The array to inspect. 1504 * @param {*}
vendor: 17,387 bytes, lines 1504-2227
1504 key The key to search for. 1505 * @returns {number} Returns the index of the matched value, else `-1`. 1506 */ 1507 function assocIndexOf(array, key) { 1508 var length = array.length; 1509 while (length--) { 1510 if (eq_1(array[length][0], key)) { 1511 return length; 1512 } 1513 } 1514 return -1; 1515 } 1516 1517 var _assocIndexOf = assocIndexOf; 1518 1519 /** Used for built-in method references. */ 1520 var arrayProto = Array.prototype; 1521 1522 /** Built-in value references. */ 1523 var splice = arrayProto.splice; 1524 1525 /** 1526 * Removes `key` and its value from the list cache. 1527 * 1528 * @private 1529 * @name delete 1530 * @memberOf ListCache 1531 * @param {string} key The key of the value to remove. 1532 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 1533 */ 1534 function listCacheDelete(key) { 1535 var data = this.__data__, 1536 index = _assocIndexOf(data, key); 1537 1538 if (index < 0) { 1539 return false; 1540 } 1541 var lastIndex = data.length - 1; 1542 if (index == lastIndex) { 1543 data.pop(); 1544 } else { 1545 splice.call(data, index, 1); 1546 } 1547 --this.size; 1548 return true; 1549 } 1550 1551 var _listCacheDelete = listCacheDelete; 1552 1553 /** 1554 * Gets the list cache value for `key`. 1555 * 1556 * @private 1557 * @name get 1558 * @memberOf ListCache 1559 * @param {string} key The key of the value to get. 1560 * @returns {*} Returns the entry value. 1561 */ 1562 function listCacheGet(key) { 1563 var data = this.__data__, 1564 index = _assocIndexOf(data, key); 1565 1566 return index < 0 ? undefined : data[index][1]; 1567 } 1568 1569 var _listCacheGet = listCacheGet; 1570 1571 /** 1572 * Checks if a list cache value for `key` exists. 1573 * 1574 * @private 1575 * @name has 1576 * @memberOf ListCache 1577 * @param {string} key The key of the entry to check. 1578 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 1579 */ 1580 function listCacheHas(key) { 1581 return _assocIndexOf(this.__data__, key) > -1; 1582 } 1583 1584 var _listCacheHas = listCacheHas; 1585 1586 /** 1587 * Sets the list cache `key` to `value`. 1588 * 1589 * @private 1590 * @name set 1591 * @memberOf ListCache 1592 * @param {string} key The key of the value to set. 1593 * @param {*} value The value to set. 1594 * @returns {Object} Returns the list cache instance. 1595 */ 1596 function listCacheSet(key, value) { 1597 var data = this.__data__, 1598 index = _assocIndexOf(data, key); 1599 1600 if (index < 0) { 1601 ++this.size; 1602 data.push([key, value]); 1603 } else { 1604 data[index][1] = value; 1605 } 1606 return this; 1607 } 1608 1609 var _listCacheSet = listCacheSet; 1610 1611 /** 1612 * Creates an list cache object. 1613 * 1614 * @private 1615 * @constructor 1616 * @param {Array} [entries] The key-value pairs to cache. 1617 */ 1618 function ListCache(entries) { 1619 var index = -1, 1620 length = entries == null ? 0 : entries.length; 1621 1622 this.clear(); 1623 while (++index < length) { 1624 var entry = entries[index]; 1625 this.set(entry[0], entry[1]); 1626 } 1627 } 1628 1629 // Add methods to `ListCache`. 1630 ListCache.prototype.clear = _listCacheClear; 1631 ListCache.prototype['delete'] = _listCacheDelete; 1632 ListCache.prototype.get = _listCacheGet; 1633 ListCache.prototype.has = _listCacheHas; 1634 ListCache.prototype.set = _listCacheSet; 1635 1636 var _ListCache = ListCache; 1637 1638 /** 1639 * Removes all key-value entries from the stack. 1640 * 1641 * @private 1642 * @name clear 1643 * @memberOf Stack 1644 */ 1645 function stackClear() { 1646 this.__data__ = new _ListCache; 1647 this.size = 0; 1648 } 1649 1650 var _stackClear = stackClear; 1651 1652 /** 1653 * Removes `key` and its value from the stack. 1654 * 1655 * @private 1656 * @name delete 1657 * @memberOf Stack 1658 * @param {string} key The key of the value to remove. 1659 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 1660 */ 1661 function stackDelete(key) { 1662 var data = this.__data__, 1663 result = data['delete'](key); 1664 1665 this.size = data.size; 1666 return result; 1667 } 1668 1669 var _stackDelete = stackDelete; 1670 1671 /** 1672 * Gets the stack value for `key`. 1673 * 1674 * @private 1675 * @name get 1676 * @memberOf Stack 1677 * @param {string} key The key of the value to get. 1678 * @returns {*} Returns the entry value. 1679 */ 1680 function stackGet(key) { 1681 return this.__data__.get(key); 1682 } 1683 1684 var _stackGet = stackGet; 1685 1686 /** 1687 * Checks if a stack value for `key` exists. 1688 * 1689 * @private 1690 * @name has 1691 * @memberOf Stack 1692 * @param {string} key The key of the entry to check. 1693 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 1694 */ 1695 function stackHas(key) { 1696 return this.__data__.has(key); 1697 } 1698 1699 var _stackHas = stackHas; 1700 1701 /** `Object#toString` result references. */ 1702 var asyncTag = '[object AsyncFunction]', 1703 funcTag$2 = '[object Function]', 1704 genTag$1 = '[object GeneratorFunction]', 1705 proxyTag = '[object Proxy]'; 1706 1707 /** 1708 * Checks if `value` is classified as a `Function` object. 1709 * 1710 * @static 1711 * @memberOf _ 1712 * @since 0.1.0 1713 * @category Lang 1714 * @param {*} value The value to check. 1715 * @returns {boolean} Returns `true` if `value` is a function, else `false`. 1716 * @example 1717 * 1718 * _.isFunction(_); 1719 * // => true 1720 * 1721 * _.isFunction(/abc/); 1722 * // => false 1723 */ 1724 function isFunction(value) { 1725 if (!isObject_1(value)) { 1726 return false; 1727 } 1728 // The use of `Object#toString` avoids issues with the `typeof` operator 1729 // in Safari 9 which returns 'object' for typed arrays and other constructors. 1730 var tag = _baseGetTag(value); 1731 return tag == funcTag$2 || tag == genTag$1 || tag == asyncTag || tag == proxyTag; 1732 } 1733 1734 var isFunction_1 = isFunction; 1735 1736 /** Used to detect overreaching core-js shims. */ 1737 var coreJsData = _root['__core-js_shared__']; 1738 1739 var _coreJsData = coreJsData; 1740 1741 /** Used to detect methods masquerading as native. */ 1742 var maskSrcKey = (function() { 1743 var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || ''); 1744 return uid ? ('Symbol(src)_1.' + uid) : ''; 1745 }()); 1746 1747 /** 1748 * Checks if `func` has its source masked. 1749 * 1750 * @private 1751 * @param {Function} func The function to check. 1752 * @returns {boolean} Returns `true` if `func` is masked, else `false`. 1753 */ 1754 function isMasked(func) { 1755 return !!maskSrcKey && (maskSrcKey in func); 1756 } 1757 1758 var _isMasked = isMasked; 1759 1760 /** Used for built-in method references. */ 1761 var funcProto$1 = Function.prototype; 1762 1763 /** Used to resolve the decompiled source of functions. */ 1764 var funcToString$1 = funcProto$1.toString; 1765 1766 /** 1767 * Converts `func` to its source code. 1768 * 1769 * @private 1770 * @param {Function} func The function to convert. 1771 * @returns {string} Returns the source code. 1772 */ 1773 function toSource(func) { 1774 if (func != null) { 1775 try { 1776 return funcToString$1.call(func); 1777 } catch (e) {} 1778 try { 1779 return (func + ''); 1780 } catch (e) {} 1781 } 1782 return ''; 1783 } 1784 1785 var _toSource = toSource; 1786 1787 /** 1788 * Used to match `RegExp` 1789 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). 1790 */ 1791 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; 1792 1793 /** Used to detect host constructors (Safari). */ 1794 var reIsHostCtor = /^\[object .+?Constructor\]$/; 1795 1796 /** Used for built-in method references. */ 1797 var funcProto = Function.prototype, 1798 objectProto$c = Object.prototype; 1799 1800 /** Used to resolve the decompiled source of functions. */ 1801 var funcToString = funcProto.toString; 1802 1803 /** Used to check objects for own properties. */ 1804 var hasOwnProperty$a = objectProto$c.hasOwnProperty; 1805 1806 /** Used to detect if a method is native. */ 1807 var reIsNative = RegExp('^' + 1808 funcToString.call(hasOwnProperty$a).replace(reRegExpChar, '\\$&') 1809 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' 1810 ); 1811 1812 /** 1813 * The base implementation of `_.isNative` without bad shim checks. 1814 * 1815 * @private 1816 * @param {*} value The value to check. 1817 * @returns {boolean} Returns `true` if `value` is a native function, 1818 * else `false`. 1819 */ 1820 function baseIsNative(value) { 1821 if (!isObject_1(value) || _isMasked(value)) { 1822 return false; 1823 } 1824 var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor; 1825 return pattern.test(_toSource(value)); 1826 } 1827 1828 var _baseIsNative = baseIsNative; 1829 1830 /** 1831 * Gets the value at `key` of `object`. 1832 * 1833 * @private 1834 * @param {Object} [object] The object to query. 1835 * @param {string} key The key of the property to get. 1836 * @returns {*} Returns the property value. 1837 */ 1838 function getValue(object, key) { 1839 return object == null ? undefined : object[key]; 1840 } 1841 1842 var _getValue = getValue; 1843 1844 /** 1845 * Gets the native function at `key` of `object`. 1846 * 1847 * @private 1848 * @param {Object} object The object to query. 1849 * @param {string} key The key of the method to get. 1850 * @returns {*} Returns the function if it's native, else `undefined`. 1851 */ 1852 function getNative(object, key) { 1853 var value = _getValue(object, key); 1854 return _baseIsNative(value) ? value : undefined; 1855 } 1856 1857 var _getNative = getNative; 1858 1859 /* Built-in method references that are verified to be native. */ 1860 var Map$1 = _getNative(_root, 'Map'); 1861 1862 var _Map = Map$1; 1863 1864 /* Built-in method references that are verified to be native. */ 1865 var nativeCreate = _getNative(Object, 'create'); 1866 1867 var _nativeCreate = nativeCreate; 1868 1869 /** 1870 * Removes all key-value entries from the hash. 1871 * 1872 * @private 1873 * @name clear 1874 * @memberOf Hash 1875 */ 1876 function hashClear() { 1877 this.__data__ = _nativeCreate ? _nativeCreate(null) : {}; 1878 this.size = 0; 1879 } 1880 1881 var _hashClear = hashClear; 1882 1883 /** 1884 * Removes `key` and its value from the hash. 1885 * 1886 * @private 1887 * @name delete 1888 * @memberOf Hash 1889 * @param {Object} hash The hash to modify. 1890 * @param {string} key The key of the value to remove. 1891 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 1892 */ 1893 function hashDelete(key) { 1894 var result = this.has(key) && delete this.__data__[key]; 1895 this.size -= result ? 1 : 0; 1896 return result; 1897 } 1898 1899 var _hashDelete = hashDelete; 1900 1901 /** Used to stand-in for `undefined` hash values. */ 1902 var HASH_UNDEFINED$2 = '__lodash_hash_undefined__'; 1903 1904 /** Used for built-in method references. */ 1905 var objectProto$b = Object.prototype; 1906 1907 /** Used to check objects for own properties. */ 1908 var hasOwnProperty$9 = objectProto$b.hasOwnProperty; 1909 1910 /** 1911 * Gets the hash value for `key`. 1912 * 1913 * @private 1914 * @name get 1915 * @memberOf Hash 1916 * @param {string} key The key of the value to get. 1917 * @returns {*} Returns the entry value. 1918 */ 1919 function hashGet(key) { 1920 var data = this.__data__; 1921 if (_nativeCreate) { 1922 var result = data[key]; 1923 return result === HASH_UNDEFINED$2 ? undefined : result; 1924 } 1925 return hasOwnProperty$9.call(data, key) ? data[key] : undefined; 1926 } 1927 1928 var _hashGet = hashGet; 1929 1930 /** Used for built-in method references. */ 1931 var objectProto$a = Object.prototype; 1932 1933 /** Used to check objects for own properties. */ 1934 var hasOwnProperty$8 = objectProto$a.hasOwnProperty; 1935 1936 /** 1937 * Checks if a hash value for `key` exists. 1938 * 1939 * @private 1940 * @name has 1941 * @memberOf Hash 1942 * @param {string} key The key of the entry to check. 1943 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 1944 */ 1945 function hashHas(key) { 1946 var data = this.__data__; 1947 return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$8.call(data, key); 1948 } 1949 1950 var _hashHas = hashHas; 1951 1952 /** Used to stand-in for `undefined` hash values. */ 1953 var HASH_UNDEFINED$1 = '__lodash_hash_undefined__'; 1954 1955 /** 1956 * Sets the hash `key` to `value`. 1957 * 1958 * @private 1959 * @name set 1960 * @memberOf Hash 1961 * @param {string} key The key of the value to set. 1962 * @param {*} value The value to set. 1963 * @returns {Object} Returns the hash instance. 1964 */ 1965 function hashSet(key, value) { 1966 var data = this.__data__; 1967 this.size += this.has(key) ? 0 : 1; 1968 data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value; 1969 return this; 1970 } 1971 1972 var _hashSet = hashSet; 1973 1974 /** 1975 * Creates a hash object. 1976 * 1977 * @private 1978 * @constructor 1979 * @param {Array} [entries] The key-value pairs to cache. 1980 */ 1981 function Hash(entries) { 1982 var index = -1, 1983 length = entries == null ? 0 : entries.length; 1984 1985 this.clear(); 1986 while (++index < length) { 1987 var entry = entries[index]; 1988 this.set(entry[0], entry[1]); 1989 } 1990 } 1991 1992 // Add methods to `Hash`. 1993 Hash.prototype.clear = _hashClear; 1994 Hash.prototype['delete'] = _hashDelete; 1995 Hash.prototype.get = _hashGet; 1996 Hash.prototype.has = _hashHas; 1997 Hash.prototype.set = _hashSet; 1998 1999 var _Hash = Hash; 2000 2001 /** 2002 * Removes all key-value entries from the map. 2003 * 2004 * @private 2005 * @name clear 2006 * @memberOf MapCache 2007 */ 2008 function mapCacheClear() { 2009 this.size = 0; 2010 this.__data__ = { 2011 'hash': new _Hash, 2012 'map': new (_Map || _ListCache), 2013 'string': new _Hash 2014 }; 2015 } 2016 2017 var _mapCacheClear = mapCacheClear; 2018 2019 /** 2020 * Checks if `value` is suitable for use as unique object key. 2021 * 2022 * @private 2023 * @param {*} value The value to check. 2024 * @returns {boolean} Returns `true` if `value` is suitable, else `false`. 2025 */ 2026 function isKeyable(value) { 2027 var type = typeof value; 2028 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean') 2029 ? (value !== '__proto__') 2030 : (value === null); 2031 } 2032 2033 var _isKeyable = isKeyable; 2034 2035 /** 2036 * Gets the data for `map`. 2037 * 2038 * @private 2039 * @param {Object} map The map to query. 2040 * @param {string} key The reference key. 2041 * @returns {*} Returns the map data. 2042 */ 2043 function getMapData(map, key) { 2044 var data = map.__data__; 2045 return _isKeyable(key) 2046 ? data[typeof key == 'string' ? 'string' : 'hash'] 2047 : data.map; 2048 } 2049 2050 var _getMapData = getMapData; 2051 2052 /** 2053 * Removes `key` and its value from the map. 2054 * 2055 * @private 2056 * @name delete 2057 * @memberOf MapCache 2058 * @param {string} key The key of the value to remove. 2059 * @returns {boolean} Returns `true` if the entry was removed, else `false`. 2060 */ 2061 function mapCacheDelete(key) { 2062 var result = _getMapData(this, key)['delete'](key); 2063 this.size -= result ? 1 : 0; 2064 return result; 2065 } 2066 2067 var _mapCacheDelete = mapCacheDelete; 2068 2069 /** 2070 * Gets the map value for `key`. 2071 * 2072 * @private 2073 * @name get 2074 * @memberOf MapCache 2075 * @param {string} key The key of the value to get. 2076 * @returns {*} Returns the entry value. 2077 */ 2078 function mapCacheGet(key) { 2079 return _getMapData(this, key).get(key); 2080 } 2081 2082 var _mapCacheGet = mapCacheGet; 2083 2084 /** 2085 * Checks if a map value for `key` exists. 2086 * 2087 * @private 2088 * @name has 2089 * @memberOf MapCache 2090 * @param {string} key The key of the entry to check. 2091 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2092 */ 2093 function mapCacheHas(key) { 2094 return _getMapData(this, key).has(key); 2095 } 2096 2097 var _mapCacheHas = mapCacheHas; 2098 2099 /** 2100 * Sets the map `key` to `value`. 2101 * 2102 * @private 2103 * @name set 2104 * @memberOf MapCache 2105 * @param {string} key The key of the value to set. 2106 * @param {*} value The value to set. 2107 * @returns {Object} Returns the map cache instance. 2108 */ 2109 function mapCacheSet(key, value) { 2110 var data = _getMapData(this, key), 2111 size = data.size; 2112 2113 data.set(key, value); 2114 this.size += data.size == size ? 0 : 1; 2115 return this; 2116 } 2117 2118 var _mapCacheSet = mapCacheSet; 2119 2120 /** 2121 * Creates a map cache object to store key-value pairs. 2122 * 2123 * @private 2124 * @constructor 2125 * @param {Array} [entries] The key-value pairs to cache. 2126 */ 2127 function MapCache(entries) { 2128 var index = -1, 2129 length = entries == null ? 0 : entries.length; 2130 2131 this.clear(); 2132 while (++index < length) { 2133 var entry = entries[index]; 2134 this.set(entry[0], entry[1]); 2135 } 2136 } 2137 2138 // Add methods to `MapCache`. 2139 MapCache.prototype.clear = _mapCacheClear; 2140 MapCache.prototype['delete'] = _mapCacheDelete; 2141 MapCache.prototype.get = _mapCacheGet; 2142 MapCache.prototype.has = _mapCacheHas; 2143 MapCache.prototype.set = _mapCacheSet; 2144 2145 var _MapCache = MapCache; 2146 2147 /** Used as the size to enable large array optimizations. */ 2148 var LARGE_ARRAY_SIZE = 200; 2149 2150 /** 2151 * Sets the stack `key` to `value`. 2152 * 2153 * @private 2154 * @name set 2155 * @memberOf Stack 2156 * @param {string} key The key of the value to set. 2157 * @param {*} value The value to set. 2158 * @returns {Object} Returns the stack cache instance. 2159 */ 2160 function stackSet(key, value) { 2161 var data = this.__data__; 2162 if (data instanceof _ListCache) { 2163 var pairs = data.__data__; 2164 if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) { 2165 pairs.push([key, value]); 2166 this.size = ++data.size; 2167 return this; 2168 } 2169 data = this.__data__ = new _MapCache(pairs); 2170 } 2171 data.set(key, value); 2172 this.size = data.size; 2173 return this; 2174 } 2175 2176 var _stackSet = stackSet; 2177 2178 /** 2179 * Creates a stack cache object to store key-value pairs. 2180 * 2181 * @private 2182 * @constructor 2183 * @param {Array} [entries] The key-value pairs to cache. 2184 */ 2185 function Stack(entries) { 2186 var data = this.__data__ = new _ListCache(entries); 2187 this.size = data.size; 2188 } 2189 2190 // Add methods to `Stack`. 2191 Stack.prototype.clear = _stackClear; 2192 Stack.prototype['delete'] = _stackDelete; 2193 Stack.prototype.get = _stackGet; 2194 Stack.prototype.has = _stackHas; 2195 Stack.prototype.set = _stackSet; 2196 2197 var _Stack = Stack; 2198 2199 /** Used to stand-in for `undefined` hash values. */ 2200 var HASH_UNDEFINED = '__lodash_hash_undefined__'; 2201 2202 /** 2203 * Adds `value` to the array cache. 2204 * 2205 * @private 2206 * @name add 2207 * @memberOf SetCache 2208 * @alias push 2209 * @param {*} value The value to cache. 2210 * @returns {Object} Returns the cache instance. 2211 */ 2212 function setCacheAdd(value) { 2213 this.__data__.set(value, HASH_UNDEFINED); 2214 return this; 2215 } 2216 2217 var _setCacheAdd = setCacheAdd; 2218 2219 /** 2220 * Checks if `value` is in the array cache. 2221 * 2222 * @private 2223 * @name has 2224 * @memberOf SetCache 2225 * @param {*} value The value to search for. 2226 * @returns {number} Returns `true` if `value` is found, else `false`. 2227 */
vendor: 2,755 bytes, lines 2228-2323
2228 function setCacheHas(value) { 2229 return this.__data__.has(value); 2230 } 2231 2232 var _setCacheHas = setCacheHas; 2233 2234 /** 2235 * 2236 * Creates an array cache object to store unique values. 2237 * 2238 * @private 2239 * @constructor 2240 * @param {Array} [values] The values to cache. 2241 */ 2242 function SetCache(values) { 2243 var index = -1, 2244 length = values == null ? 0 : values.length; 2245 2246 this.__data__ = new _MapCache; 2247 while (++index < length) { 2248 this.add(values[index]); 2249 } 2250 } 2251 2252 // Add methods to `SetCache`. 2253 SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd; 2254 SetCache.prototype.has = _setCacheHas; 2255 2256 var _SetCache = SetCache; 2257 2258 /** 2259 * A specialized version of `_.some` for arrays without support for iteratee 2260 * shorthands. 2261 * 2262 * @private 2263 * @param {Array} [array] The array to iterate over. 2264 * @param {Function} predicate The function invoked per iteration. 2265 * @returns {boolean} Returns `true` if any element passes the predicate check, 2266 * else `false`. 2267 */ 2268 function arraySome(array, predicate) { 2269 var index = -1, 2270 length = array == null ? 0 : array.length; 2271 2272 while (++index < length) { 2273 if (predicate(array[index], index, array)) { 2274 return true; 2275 } 2276 } 2277 return false; 2278 } 2279 2280 var _arraySome = arraySome; 2281 2282 /** 2283 * Checks if a `cache` value for `key` exists. 2284 * 2285 * @private 2286 * @param {Object} cache The cache to query. 2287 * @param {string} key The key of the entry to check. 2288 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`. 2289 */ 2290 function cacheHas(cache, key) { 2291 return cache.has(key); 2292 } 2293 2294 var _cacheHas = cacheHas; 2295 2296 /** Used to compose bitmasks for value comparisons. */ 2297 var COMPARE_PARTIAL_FLAG$3 = 1, 2298 COMPARE_UNORDERED_FLAG$1 = 2; 2299 2300 /** 2301 * A specialized version of `baseIsEqualDeep` for arrays with support for 2302 * partial deep comparisons. 2303 * 2304 * @private 2305 * @param {Array} array The array to compare. 2306 * @param {Array} other The other array to compare. 2307 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 2308 * @param {Function} customizer The function to customize comparisons. 2309 * @param {Function} equalFunc The function to determine equivalents of values. 2310 * @param {Object} stack Tracks traversed `array` and `other` objects. 2311 * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. 2312 */ 2313 function equalArrays(array, other, bitmask, customizer, equalFunc, stack) { 2314 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, 2315 arrLength = array.length, 2316 othLength = other.length; 2317 2318 if (arrLength != othLength && !(isPartial && othLength > arrLength)) { 2319 return false; 2320 } 2321 // Check that cyclic values are equal. 2322 var arrStacked = stack.get(array); 2323 var othStacked = stack.get(other);
vendor: 1,146 bytes, lines 2324-2359
2324 if (arrStacked && othStacked) { 2325 return arrStacked == other && othStacked == array; 2326 } 2327 var index = -1, 2328 result = true, 2329 seen = (bitmask & COMPARE_UNORDERED_FLAG$1) ? new _SetCache : undefined; 2330 2331 stack.set(array, other); 2332 stack.set(other, array); 2333 2334 // Ignore non-index properties. 2335 while (++index < arrLength) { 2336 var arrValue = array[index], 2337 othValue = other[index]; 2338 2339 if (customizer) { 2340 var compared = isPartial 2341 ? customizer(othValue, arrValue, index, other, array, stack) 2342 : customizer(arrValue, othValue, index, array, other, stack); 2343 } 2344 if (compared !== undefined) { 2345 if (compared) { 2346 continue; 2347 } 2348 result = false; 2349 break; 2350 } 2351 // Recursively compare arrays (susceptible to call stack limits). 2352 if (seen) { 2353 if (!_arraySome(other, function(othValue, othIndex) { 2354 if (!_cacheHas(seen, othIndex) && 2355 (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) { 2356 return seen.push(othIndex); 2357 } 2358 })) { 2359 result = false;
vendor: 23,458 bytes, lines 2360-3172
2360 break; 2361 } 2362 } else if (!( 2363 arrValue === othValue || 2364 equalFunc(arrValue, othValue, bitmask, customizer, stack) 2365 )) { 2366 result = false; 2367 break; 2368 } 2369 } 2370 stack['delete'](array); 2371 stack['delete'](other); 2372 return result; 2373 } 2374 2375 var _equalArrays = equalArrays; 2376 2377 /** Built-in value references. */ 2378 var Uint8Array = _root.Uint8Array; 2379 2380 var _Uint8Array = Uint8Array; 2381 2382 /** 2383 * Converts `map` to its key-value pairs. 2384 * 2385 * @private 2386 * @param {Object} map The map to convert. 2387 * @returns {Array} Returns the key-value pairs. 2388 */ 2389 function mapToArray(map) { 2390 var index = -1, 2391 result = Array(map.size); 2392 2393 map.forEach(function(value, key) { 2394 result[++index] = [key, value]; 2395 }); 2396 return result; 2397 } 2398 2399 var _mapToArray = mapToArray; 2400 2401 /** 2402 * Converts `set` to an array of its values. 2403 * 2404 * @private 2405 * @param {Object} set The set to convert. 2406 * @returns {Array} Returns the values. 2407 */ 2408 function setToArray(set) { 2409 var index = -1, 2410 result = Array(set.size); 2411 2412 set.forEach(function(value) { 2413 result[++index] = value; 2414 }); 2415 return result; 2416 } 2417 2418 var _setToArray = setToArray; 2419 2420 /** Used to compose bitmasks for value comparisons. */ 2421 var COMPARE_PARTIAL_FLAG$2 = 1, 2422 COMPARE_UNORDERED_FLAG = 2; 2423 2424 /** `Object#toString` result references. */ 2425 var boolTag$3 = '[object Boolean]', 2426 dateTag$3 = '[object Date]', 2427 errorTag$2 = '[object Error]', 2428 mapTag$5 = '[object Map]', 2429 numberTag$3 = '[object Number]', 2430 regexpTag$3 = '[object RegExp]', 2431 setTag$5 = '[object Set]', 2432 stringTag$3 = '[object String]', 2433 symbolTag$2 = '[object Symbol]'; 2434 2435 var arrayBufferTag$3 = '[object ArrayBuffer]', 2436 dataViewTag$4 = '[object DataView]'; 2437 2438 /** Used to convert symbols to primitives and strings. */ 2439 var symbolProto$1 = _Symbol ? _Symbol.prototype : undefined, 2440 symbolValueOf$1 = symbolProto$1 ? symbolProto$1.valueOf : undefined; 2441 2442 /** 2443 * A specialized version of `baseIsEqualDeep` for comparing objects of 2444 * the same `toStringTag`. 2445 * 2446 * **Note:** This function only supports comparing values with tags of 2447 * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`. 2448 * 2449 * @private 2450 * @param {Object} object The object to compare. 2451 * @param {Object} other The other object to compare. 2452 * @param {string} tag The `toStringTag` of the objects to compare. 2453 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 2454 * @param {Function} customizer The function to customize comparisons. 2455 * @param {Function} equalFunc The function to determine equivalents of values. 2456 * @param {Object} stack Tracks traversed `object` and `other` objects. 2457 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 2458 */ 2459 function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) { 2460 switch (tag) { 2461 case dataViewTag$4: 2462 if ((object.byteLength != other.byteLength) || 2463 (object.byteOffset != other.byteOffset)) { 2464 return false; 2465 } 2466 object = object.buffer; 2467 other = other.buffer; 2468 2469 case arrayBufferTag$3: 2470 if ((object.byteLength != other.byteLength) || 2471 !equalFunc(new _Uint8Array(object), new _Uint8Array(other))) { 2472 return false; 2473 } 2474 return true; 2475 2476 case boolTag$3: 2477 case dateTag$3: 2478 case numberTag$3: 2479 // Coerce booleans to `1` or `0` and dates to milliseconds. 2480 // Invalid dates are coerced to `NaN`. 2481 return eq_1(+object, +other); 2482 2483 case errorTag$2: 2484 return object.name == other.name && object.message == other.message; 2485 2486 case regexpTag$3: 2487 case stringTag$3: 2488 // Coerce regexes to strings and treat strings, primitives and objects, 2489 // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring 2490 // for more details. 2491 return object == (other + ''); 2492 2493 case mapTag$5: 2494 var convert = _mapToArray; 2495 2496 case setTag$5: 2497 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$2; 2498 convert || (convert = _setToArray); 2499 2500 if (object.size != other.size && !isPartial) { 2501 return false; 2502 } 2503 // Assume cyclic values are equal. 2504 var stacked = stack.get(object); 2505 if (stacked) { 2506 return stacked == other; 2507 } 2508 bitmask |= COMPARE_UNORDERED_FLAG; 2509 2510 // Recursively compare objects (susceptible to call stack limits). 2511 stack.set(object, other); 2512 var result = _equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack); 2513 stack['delete'](object); 2514 return result; 2515 2516 case symbolTag$2: 2517 if (symbolValueOf$1) { 2518 return symbolValueOf$1.call(object) == symbolValueOf$1.call(other); 2519 } 2520 } 2521 return false; 2522 } 2523 2524 var _equalByTag = equalByTag; 2525 2526 /** 2527 * Appends the elements of `values` to `array`. 2528 * 2529 * @private 2530 * @param {Array} array The array to modify. 2531 * @param {Array} values The values to append. 2532 * @returns {Array} Returns `array`. 2533 */ 2534 function arrayPush(array, values) { 2535 var index = -1, 2536 length = values.length, 2537 offset = array.length; 2538 2539 while (++index < length) { 2540 array[offset + index] = values[index]; 2541 } 2542 return array; 2543 } 2544 2545 var _arrayPush = arrayPush; 2546 2547 /** 2548 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses 2549 * `keysFunc` and `symbolsFunc` to get the enumerable property names and 2550 * symbols of `object`. 2551 * 2552 * @private 2553 * @param {Object} object The object to query. 2554 * @param {Function} keysFunc The function to get the keys of `object`. 2555 * @param {Function} symbolsFunc The function to get the symbols of `object`. 2556 * @returns {Array} Returns the array of property names and symbols. 2557 */ 2558 function baseGetAllKeys(object, keysFunc, symbolsFunc) { 2559 var result = keysFunc(object); 2560 return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object)); 2561 } 2562 2563 var _baseGetAllKeys = baseGetAllKeys; 2564 2565 /** 2566 * A specialized version of `_.filter` for arrays without support for 2567 * iteratee shorthands. 2568 * 2569 * @private 2570 * @param {Array} [array] The array to iterate over. 2571 * @param {Function} predicate The function invoked per iteration. 2572 * @returns {Array} Returns the new filtered array. 2573 */ 2574 function arrayFilter(array, predicate) { 2575 var index = -1, 2576 length = array == null ? 0 : array.length, 2577 resIndex = 0, 2578 result = []; 2579 2580 while (++index < length) { 2581 var value = array[index]; 2582 if (predicate(value, index, array)) { 2583 result[resIndex++] = value; 2584 } 2585 } 2586 return result; 2587 } 2588 2589 var _arrayFilter = arrayFilter; 2590 2591 /** 2592 * This method returns a new empty array. 2593 * 2594 * @static 2595 * @memberOf _ 2596 * @since 4.13.0 2597 * @category Util 2598 * @returns {Array} Returns the new empty array. 2599 * @example 2600 * 2601 * var arrays = _.times(2, _.stubArray); 2602 * 2603 * console.log(arrays); 2604 * // => [[], []] 2605 * 2606 * console.log(arrays[0] === arrays[1]); 2607 * // => false 2608 */ 2609 function stubArray() { 2610 return []; 2611 } 2612 2613 var stubArray_1 = stubArray; 2614 2615 /** Used for built-in method references. */ 2616 var objectProto$9 = Object.prototype; 2617 2618 /** Built-in value references. */ 2619 var propertyIsEnumerable$1 = objectProto$9.propertyIsEnumerable; 2620 2621 /* Built-in method references for those with the same name as other `lodash` methods. */ 2622 var nativeGetSymbols$1 = Object.getOwnPropertySymbols; 2623 2624 /** 2625 * Creates an array of the own enumerable symbols of `object`. 2626 * 2627 * @private 2628 * @param {Object} object The object to query. 2629 * @returns {Array} Returns the array of symbols. 2630 */ 2631 var getSymbols = !nativeGetSymbols$1 ? stubArray_1 : function(object) { 2632 if (object == null) { 2633 return []; 2634 } 2635 object = Object(object); 2636 return _arrayFilter(nativeGetSymbols$1(object), function(symbol) { 2637 return propertyIsEnumerable$1.call(object, symbol); 2638 }); 2639 }; 2640 2641 var _getSymbols = getSymbols; 2642 2643 /** 2644 * The base implementation of `_.times` without support for iteratee shorthands 2645 * or max array length checks. 2646 * 2647 * @private 2648 * @param {number} n The number of times to invoke `iteratee`. 2649 * @param {Function} iteratee The function invoked per iteration. 2650 * @returns {Array} Returns the array of results. 2651 */ 2652 function baseTimes(n, iteratee) { 2653 var index = -1, 2654 result = Array(n); 2655 2656 while (++index < n) { 2657 result[index] = iteratee(index); 2658 } 2659 return result; 2660 } 2661 2662 var _baseTimes = baseTimes; 2663 2664 /** `Object#toString` result references. */ 2665 var argsTag$3 = '[object Arguments]'; 2666 2667 /** 2668 * The base implementation of `_.isArguments`. 2669 * 2670 * @private 2671 * @param {*} value The value to check. 2672 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 2673 */ 2674 function baseIsArguments(value) { 2675 return isObjectLike_1(value) && _baseGetTag(value) == argsTag$3; 2676 } 2677 2678 var _baseIsArguments = baseIsArguments; 2679 2680 /** Used for built-in method references. */ 2681 var objectProto$8 = Object.prototype; 2682 2683 /** Used to check objects for own properties. */ 2684 var hasOwnProperty$7 = objectProto$8.hasOwnProperty; 2685 2686 /** Built-in value references. */ 2687 var propertyIsEnumerable = objectProto$8.propertyIsEnumerable; 2688 2689 /** 2690 * Checks if `value` is likely an `arguments` object. 2691 * 2692 * @static 2693 * @memberOf _ 2694 * @since 0.1.0 2695 * @category Lang 2696 * @param {*} value The value to check. 2697 * @returns {boolean} Returns `true` if `value` is an `arguments` object, 2698 * else `false`. 2699 * @example 2700 * 2701 * _.isArguments(function() { return arguments; }()); 2702 * // => true 2703 * 2704 * _.isArguments([1, 2, 3]); 2705 * // => false 2706 */ 2707 var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) { 2708 return isObjectLike_1(value) && hasOwnProperty$7.call(value, 'callee') && 2709 !propertyIsEnumerable.call(value, 'callee'); 2710 }; 2711 2712 var isArguments_1 = isArguments; 2713 2714 /** 2715 * This method returns `false`. 2716 * 2717 * @static 2718 * @memberOf _ 2719 * @since 4.13.0 2720 * @category Util 2721 * @returns {boolean} Returns `false`. 2722 * @example 2723 * 2724 * _.times(2, _.stubFalse); 2725 * // => [false, false] 2726 */ 2727 function stubFalse() { 2728 return false; 2729 } 2730 2731 var stubFalse_1 = stubFalse; 2732 2733 var isBuffer_1 = createCommonjsModule(function (module, exports) { 2734 /** Detect free variable `exports`. */ 2735 var freeExports = 'object' == 'object' && exports && !exports.nodeType && exports; 2736 2737 /** Detect free variable `module`. */ 2738 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module; 2739 2740 /** Detect the popular CommonJS extension `module.exports`. */ 2741 var moduleExports = freeModule && freeModule.exports === freeExports; 2742 2743 /** Built-in value references. */ 2744 var Buffer = moduleExports ? _root.Buffer : undefined; 2745 2746 /* Built-in method references for those with the same name as other `lodash` methods. */ 2747 var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined; 2748 2749 /** 2750 * Checks if `value` is a buffer. 2751 * 2752 * @static 2753 * @memberOf _ 2754 * @since 4.3.0 2755 * @category Lang 2756 * @param {*} value The value to check. 2757 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`. 2758 * @example 2759 * 2760 * _.isBuffer(new Buffer(2)); 2761 * // => true 2762 * 2763 * _.isBuffer(new Uint8Array(2)); 2764 * // => false 2765 */ 2766 var isBuffer = nativeIsBuffer || stubFalse_1; 2767 2768 module.exports = isBuffer; 2769 }); 2770 2771 /** Used as references for various `Number` constants. */ 2772 var MAX_SAFE_INTEGER$1 = 9007199254740991; 2773 2774 /** Used to detect unsigned integer values. */ 2775 var reIsUint = /^(?:0|[1-9]\d*)$/; 2776 2777 /** 2778 * Checks if `value` is a valid array-like index. 2779 * 2780 * @private 2781 * @param {*} value The value to check. 2782 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index. 2783 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`. 2784 */ 2785 function isIndex(value, length) { 2786 var type = typeof value; 2787 length = length == null ? MAX_SAFE_INTEGER$1 : length; 2788 2789 return !!length && 2790 (type == 'number' || 2791 (type != 'symbol' && reIsUint.test(value))) && 2792 (value > -1 && value % 1 == 0 && value < length); 2793 } 2794 2795 var _isIndex = isIndex; 2796 2797 /** Used as references for various `Number` constants. */ 2798 var MAX_SAFE_INTEGER = 9007199254740991; 2799 2800 /** 2801 * Checks if `value` is a valid array-like length. 2802 * 2803 * **Note:** This method is loosely based on 2804 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). 2805 * 2806 * @static 2807 * @memberOf _ 2808 * @since 4.0.0 2809 * @category Lang 2810 * @param {*} value The value to check. 2811 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. 2812 * @example 2813 * 2814 * _.isLength(3); 2815 * // => true 2816 * 2817 * _.isLength(Number.MIN_VALUE); 2818 * // => false 2819 * 2820 * _.isLength(Infinity); 2821 * // => false 2822 * 2823 * _.isLength('3'); 2824 * // => false 2825 */ 2826 function isLength$1(value) { 2827 return typeof value == 'number' && 2828 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER; 2829 } 2830 2831 var isLength_1$1 = isLength$1; 2832 2833 /** `Object#toString` result references. */ 2834 var argsTag$2 = '[object Arguments]', 2835 arrayTag$2 = '[object Array]', 2836 boolTag$2 = '[object Boolean]', 2837 dateTag$2 = '[object Date]', 2838 errorTag$1 = '[object Error]', 2839 funcTag$1 = '[object Function]', 2840 mapTag$4 = '[object Map]', 2841 numberTag$2 = '[object Number]', 2842 objectTag$3 = '[object Object]', 2843 regexpTag$2 = '[object RegExp]', 2844 setTag$4 = '[object Set]', 2845 stringTag$2 = '[object String]', 2846 weakMapTag$2 = '[object WeakMap]'; 2847 2848 var arrayBufferTag$2 = '[object ArrayBuffer]', 2849 dataViewTag$3 = '[object DataView]', 2850 float32Tag$2 = '[object Float32Array]', 2851 float64Tag$2 = '[object Float64Array]', 2852 int8Tag$2 = '[object Int8Array]', 2853 int16Tag$2 = '[object Int16Array]', 2854 int32Tag$2 = '[object Int32Array]', 2855 uint8Tag$2 = '[object Uint8Array]', 2856 uint8ClampedTag$2 = '[object Uint8ClampedArray]', 2857 uint16Tag$2 = '[object Uint16Array]', 2858 uint32Tag$2 = '[object Uint32Array]'; 2859 2860 /** Used to identify `toStringTag` values of typed arrays. */ 2861 var typedArrayTags = {}; 2862 typedArrayTags[float32Tag$2] = typedArrayTags[float64Tag$2] = 2863 typedArrayTags[int8Tag$2] = typedArrayTags[int16Tag$2] = 2864 typedArrayTags[int32Tag$2] = typedArrayTags[uint8Tag$2] = 2865 typedArrayTags[uint8ClampedTag$2] = typedArrayTags[uint16Tag$2] = 2866 typedArrayTags[uint32Tag$2] = true; 2867 typedArrayTags[argsTag$2] = typedArrayTags[arrayTag$2] = 2868 typedArrayTags[arrayBufferTag$2] = typedArrayTags[boolTag$2] = 2869 typedArrayTags[dataViewTag$3] = typedArrayTags[dateTag$2] = 2870 typedArrayTags[errorTag$1] = typedArrayTags[funcTag$1] = 2871 typedArrayTags[mapTag$4] = typedArrayTags[numberTag$2] = 2872 typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$2] = 2873 typedArrayTags[setTag$4] = typedArrayTags[stringTag$2] = 2874 typedArrayTags[weakMapTag$2] = false; 2875 2876 /** 2877 * The base implementation of `_.isTypedArray` without Node.js optimizations. 2878 * 2879 * @private 2880 * @param {*} value The value to check. 2881 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 2882 */ 2883 function baseIsTypedArray(value) { 2884 return isObjectLike_1(value) && 2885 isLength_1$1(value.length) && !!typedArrayTags[_baseGetTag(value)]; 2886 } 2887 2888 var _baseIsTypedArray = baseIsTypedArray; 2889 2890 /** 2891 * The base implementation of `_.unary` without support for storing metadata. 2892 * 2893 * @private 2894 * @param {Function} func The function to cap arguments for. 2895 * @returns {Function} Returns the new capped function. 2896 */ 2897 function baseUnary(func) { 2898 return function(value) { 2899 return func(value); 2900 }; 2901 } 2902 2903 var _baseUnary = baseUnary; 2904 2905 var _nodeUtil = createCommonjsModule(function (module, exports) { 2906 /** Detect free variable `exports`. */ 2907 var freeExports = 'object' == 'object' && exports && !exports.nodeType && exports; 2908 2909 /** Detect free variable `module`. */ 2910 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module; 2911 2912 /** Detect the popular CommonJS extension `module.exports`. */ 2913 var moduleExports = freeModule && freeModule.exports === freeExports; 2914 2915 /** Detect free variable `process` from Node.js. */ 2916 var freeProcess = moduleExports && _freeGlobal.process; 2917 2918 /** Used to access faster Node.js helpers. */ 2919 var nodeUtil = (function() { 2920 try { 2921 // Use `util.types` for Node.js 10+. 2922 var types = freeModule && freeModule.require && freeModule.require('util').types; 2923 2924 if (types) { 2925 return types; 2926 } 2927 2928 // Legacy `process.binding('util')` for Node.js < 10. 2929 return freeProcess && freeProcess.binding && freeProcess.binding('util'); 2930 } catch (e) {} 2931 }()); 2932 2933 module.exports = nodeUtil; 2934 }); 2935 2936 /* Node.js helper references. */ 2937 var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray; 2938 2939 /** 2940 * Checks if `value` is classified as a typed array. 2941 * 2942 * @static 2943 * @memberOf _ 2944 * @since 3.0.0 2945 * @category Lang 2946 * @param {*} value The value to check. 2947 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`. 2948 * @example 2949 * 2950 * _.isTypedArray(new Uint8Array); 2951 * // => true 2952 * 2953 * _.isTypedArray([]); 2954 * // => false 2955 */ 2956 var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray; 2957 2958 var isTypedArray_1 = isTypedArray; 2959 2960 /** Used for built-in method references. */ 2961 var objectProto$7 = Object.prototype; 2962 2963 /** Used to check objects for own properties. */ 2964 var hasOwnProperty$6 = objectProto$7.hasOwnProperty; 2965 2966 /** 2967 * Creates an array of the enumerable property names of the array-like `value`. 2968 * 2969 * @private 2970 * @param {*} value The value to query. 2971 * @param {boolean} inherited Specify returning inherited property names. 2972 * @returns {Array} Returns the array of property names. 2973 */ 2974 function arrayLikeKeys(value, inherited) { 2975 var isArr = isArray_1(value), 2976 isArg = !isArr && isArguments_1(value), 2977 isBuff = !isArr && !isArg && isBuffer_1(value), 2978 isType = !isArr && !isArg && !isBuff && isTypedArray_1(value), 2979 skipIndexes = isArr || isArg || isBuff || isType, 2980 result = skipIndexes ? _baseTimes(value.length, String) : [], 2981 length = result.length; 2982 2983 for (var key in value) { 2984 if ((inherited || hasOwnProperty$6.call(value, key)) && 2985 !(skipIndexes && ( 2986 // Safari 9 has enumerable `arguments.length` in strict mode. 2987 key == 'length' || 2988 // Node.js 0.10 has enumerable non-index properties on buffers. 2989 (isBuff && (key == 'offset' || key == 'parent')) || 2990 // PhantomJS 2 has enumerable non-index properties on typed arrays. 2991 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) || 2992 // Skip index properties. 2993 _isIndex(key, length) 2994 ))) { 2995 result.push(key); 2996 } 2997 } 2998 return result; 2999 } 3000 3001 var _arrayLikeKeys = arrayLikeKeys; 3002 3003 /** Used for built-in method references. */ 3004 var objectProto$6 = Object.prototype; 3005 3006 /** 3007 * Checks if `value` is likely a prototype object. 3008 * 3009 * @private 3010 * @param {*} value The value to check. 3011 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`. 3012 */ 3013 function isPrototype(value) { 3014 var Ctor = value && value.constructor, 3015 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6; 3016 3017 return value === proto; 3018 } 3019 3020 var _isPrototype = isPrototype; 3021 3022 /** 3023 * Creates a unary function that invokes `func` with its argument transformed. 3024 * 3025 * @private 3026 * @param {Function} func The function to wrap. 3027 * @param {Function} transform The argument transform. 3028 * @returns {Function} Returns the new function. 3029 */ 3030 function overArg(func, transform) { 3031 return function(arg) { 3032 return func(transform(arg)); 3033 }; 3034 } 3035 3036 var _overArg = overArg; 3037 3038 /* Built-in method references for those with the same name as other `lodash` methods. */ 3039 var nativeKeys = _overArg(Object.keys, Object); 3040 3041 var _nativeKeys = nativeKeys; 3042 3043 /** Used for built-in method references. */ 3044 var objectProto$5 = Object.prototype; 3045 3046 /** Used to check objects for own properties. */ 3047 var hasOwnProperty$5 = objectProto$5.hasOwnProperty; 3048 3049 /** 3050 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. 3051 * 3052 * @private 3053 * @param {Object} object The object to query. 3054 * @returns {Array} Returns the array of property names. 3055 */ 3056 function baseKeys(object) { 3057 if (!_isPrototype(object)) { 3058 return _nativeKeys(object); 3059 } 3060 var result = []; 3061 for (var key in Object(object)) { 3062 if (hasOwnProperty$5.call(object, key) && key != 'constructor') { 3063 result.push(key); 3064 } 3065 } 3066 return result; 3067 } 3068 3069 var _baseKeys = baseKeys; 3070 3071 /** 3072 * Checks if `value` is array-like. A value is considered array-like if it's 3073 * not a function and has a `value.length` that's an integer greater than or 3074 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`. 3075 * 3076 * @static 3077 * @memberOf _ 3078 * @since 4.0.0 3079 * @category Lang 3080 * @param {*} value The value to check. 3081 * @returns {boolean} Returns `true` if `value` is array-like, else `false`. 3082 * @example 3083 * 3084 * _.isArrayLike([1, 2, 3]); 3085 * // => true 3086 * 3087 * _.isArrayLike(document.body.children); 3088 * // => true 3089 * 3090 * _.isArrayLike('abc'); 3091 * // => true 3092 * 3093 * _.isArrayLike(_.noop); 3094 * // => false 3095 */ 3096 function isArrayLike(value) { 3097 return value != null && isLength_1$1(value.length) && !isFunction_1(value); 3098 } 3099 3100 var isArrayLike_1 = isArrayLike; 3101 3102 /** 3103 * Creates an array of the own enumerable property names of `object`. 3104 * 3105 * **Note:** Non-object values are coerced to objects. See the 3106 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 3107 * for more details. 3108 * 3109 * @static 3110 * @since 0.1.0 3111 * @memberOf _ 3112 * @category Object 3113 * @param {Object} object The object to query. 3114 * @returns {Array} Returns the array of property names. 3115 * @example 3116 * 3117 * function Foo() { 3118 * this.a = 1; 3119 * this.b = 2; 3120 * } 3121 * 3122 * Foo.prototype.c = 3; 3123 * 3124 * _.keys(new Foo); 3125 * // => ['a', 'b'] (iteration order is not guaranteed) 3126 * 3127 * _.keys('hi'); 3128 * // => ['0', '1'] 3129 */ 3130 function keys(object) { 3131 return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object); 3132 } 3133 3134 var keys_1 = keys; 3135 3136 /** 3137 * Creates an array of own enumerable property names and symbols of `object`. 3138 * 3139 * @private 3140 * @param {Object} object The object to query. 3141 * @returns {Array} Returns the array of property names and symbols. 3142 */ 3143 function getAllKeys(object) { 3144 return _baseGetAllKeys(object, keys_1, _getSymbols); 3145 } 3146 3147 var _getAllKeys = getAllKeys; 3148 3149 /** Used to compose bitmasks for value comparisons. */ 3150 var COMPARE_PARTIAL_FLAG$1 = 1; 3151 3152 /** Used for built-in method references. */ 3153 var objectProto$4 = Object.prototype; 3154 3155 /** Used to check objects for own properties. */ 3156 var hasOwnProperty$4 = objectProto$4.hasOwnProperty; 3157 3158 /** 3159 * A specialized version of `baseIsEqualDeep` for objects with support for 3160 * partial deep comparisons. 3161 * 3162 * @private 3163 * @param {Object} object The object to compare. 3164 * @param {Object} other The other object to compare. 3165 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 3166 * @param {Function} customizer The function to customize comparisons. 3167 * @param {Function} equalFunc The function to determine equivalents of values. 3168 * @param {Object} stack Tracks traversed `object` and `other` objects. 3169 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 3170 */ 3171 function equalObjects(object, other, bitmask, customizer, equalFunc, stack) { 3172 var isPartial = bitmask & COMPARE_PARTIAL_FLAG$1,
vendor: 1,326 bytes, lines 3173-3214
3173 objProps = _getAllKeys(object), 3174 objLength = objProps.length, 3175 othProps = _getAllKeys(other), 3176 othLength = othProps.length; 3177 3178 if (objLength != othLength && !isPartial) { 3179 return false; 3180 } 3181 var index = objLength; 3182 while (index--) { 3183 var key = objProps[index]; 3184 if (!(isPartial ? key in other : hasOwnProperty$4.call(other, key))) { 3185 return false; 3186 } 3187 } 3188 // Check that cyclic values are equal. 3189 var objStacked = stack.get(object); 3190 var othStacked = stack.get(other); 3191 if (objStacked && othStacked) { 3192 return objStacked == other && othStacked == object; 3193 } 3194 var result = true; 3195 stack.set(object, other); 3196 stack.set(other, object); 3197 3198 var skipCtor = isPartial; 3199 while (++index < objLength) { 3200 key = objProps[index]; 3201 var objValue = object[key], 3202 othValue = other[key]; 3203 3204 if (customizer) { 3205 var compared = isPartial 3206 ? customizer(othValue, objValue, key, other, object, stack) 3207 : customizer(objValue, othValue, key, object, other, stack); 3208 } 3209 // Recursively compare objects (susceptible to call stack limits). 3210 if (!(compared === undefined 3211 ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack)) 3212 : compared 3213 )) { 3214 result = false;
vendor: 4,638 bytes, lines 3215-3352
3215 break; 3216 } 3217 skipCtor || (skipCtor = key == 'constructor'); 3218 } 3219 if (result && !skipCtor) { 3220 var objCtor = object.constructor, 3221 othCtor = other.constructor; 3222 3223 // Non `Object` object instances with different constructors are not equal. 3224 if (objCtor != othCtor && 3225 ('constructor' in object && 'constructor' in other) && 3226 !(typeof objCtor == 'function' && objCtor instanceof objCtor && 3227 typeof othCtor == 'function' && othCtor instanceof othCtor)) { 3228 result = false; 3229 } 3230 } 3231 stack['delete'](object); 3232 stack['delete'](other); 3233 return result; 3234 } 3235 3236 var _equalObjects = equalObjects; 3237 3238 /* Built-in method references that are verified to be native. */ 3239 var DataView = _getNative(_root, 'DataView'); 3240 3241 var _DataView = DataView; 3242 3243 /* Built-in method references that are verified to be native. */ 3244 var Promise$1 = _getNative(_root, 'Promise'); 3245 3246 var _Promise = Promise$1; 3247 3248 /* Built-in method references that are verified to be native. */ 3249 var Set$1 = _getNative(_root, 'Set'); 3250 3251 var _Set = Set$1; 3252 3253 /* Built-in method references that are verified to be native. */ 3254 var WeakMap$1 = _getNative(_root, 'WeakMap'); 3255 3256 var _WeakMap = WeakMap$1; 3257 3258 /** `Object#toString` result references. */ 3259 var mapTag$3 = '[object Map]', 3260 objectTag$2 = '[object Object]', 3261 promiseTag = '[object Promise]', 3262 setTag$3 = '[object Set]', 3263 weakMapTag$1 = '[object WeakMap]'; 3264 3265 var dataViewTag$2 = '[object DataView]'; 3266 3267 /** Used to detect maps, sets, and weakmaps. */ 3268 var dataViewCtorString = _toSource(_DataView), 3269 mapCtorString = _toSource(_Map), 3270 promiseCtorString = _toSource(_Promise), 3271 setCtorString = _toSource(_Set), 3272 weakMapCtorString = _toSource(_WeakMap); 3273 3274 /** 3275 * Gets the `toStringTag` of `value`. 3276 * 3277 * @private 3278 * @param {*} value The value to query. 3279 * @returns {string} Returns the `toStringTag`. 3280 */ 3281 var getTag = _baseGetTag; 3282 3283 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6. 3284 if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$2) || 3285 (_Map && getTag(new _Map) != mapTag$3) || 3286 (_Promise && getTag(_Promise.resolve()) != promiseTag) || 3287 (_Set && getTag(new _Set) != setTag$3) || 3288 (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) { 3289 getTag = function(value) { 3290 var result = _baseGetTag(value), 3291 Ctor = result == objectTag$2 ? value.constructor : undefined, 3292 ctorString = Ctor ? _toSource(Ctor) : ''; 3293 3294 if (ctorString) { 3295 switch (ctorString) { 3296 case dataViewCtorString: return dataViewTag$2; 3297 case mapCtorString: return mapTag$3; 3298 case promiseCtorString: return promiseTag; 3299 case setCtorString: return setTag$3; 3300 case weakMapCtorString: return weakMapTag$1; 3301 } 3302 } 3303 return result; 3304 }; 3305 } 3306 3307 var _getTag = getTag; 3308 3309 /** Used to compose bitmasks for value comparisons. */ 3310 var COMPARE_PARTIAL_FLAG = 1; 3311 3312 /** `Object#toString` result references. */ 3313 var argsTag$1 = '[object Arguments]', 3314 arrayTag$1 = '[object Array]', 3315 objectTag$1 = '[object Object]'; 3316 3317 /** Used for built-in method references. */ 3318 var objectProto$3 = Object.prototype; 3319 3320 /** Used to check objects for own properties. */ 3321 var hasOwnProperty$3 = objectProto$3.hasOwnProperty; 3322 3323 /** 3324 * A specialized version of `baseIsEqual` for arrays and objects which performs 3325 * deep comparisons and tracks traversed objects enabling objects with circular 3326 * references to be compared. 3327 * 3328 * @private 3329 * @param {Object} object The object to compare. 3330 * @param {Object} other The other object to compare. 3331 * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details. 3332 * @param {Function} customizer The function to customize comparisons. 3333 * @param {Function} equalFunc The function to determine equivalents of values. 3334 * @param {Object} [stack] Tracks traversed `object` and `other` objects. 3335 * @returns {boolean} Returns `true` if the objects are equivalent, else `false`. 3336 */ 3337 function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) { 3338 var objIsArr = isArray_1(object), 3339 othIsArr = isArray_1(other), 3340 objTag = objIsArr ? arrayTag$1 : _getTag(object), 3341 othTag = othIsArr ? arrayTag$1 : _getTag(other); 3342 3343 objTag = objTag == argsTag$1 ? objectTag$1 : objTag; 3344 othTag = othTag == argsTag$1 ? objectTag$1 : othTag; 3345 3346 var objIsObj = objTag == objectTag$1, 3347 othIsObj = othTag == objectTag$1, 3348 isSameTag = objTag == othTag; 3349 3350 if (isSameTag && isBuffer_1(object)) { 3351 if (!isBuffer_1(other)) { 3352 return false;
3353 } 3354 objIsArr = true; 3355 objIsObj = false; 3356 } 3357 if (isSameTag && !objIsObj) { 3358 stack || (stack = new _Stack); 3359 return (objIsArr || isTypedArray_1(object)) 3360 ? _equalArrays(object, other, bitmask, customizer, equalFunc, stack) 3361 : _equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack); 3362 } 3363 if (!(bitmask & COMPARE_PARTIAL_FLAG)) { 3364 var objIsWrapped = objIsObj && hasOwnProperty$3.call(object, '__wrapped__'), 3365 othIsWrapped = othIsObj && hasOwnProperty$3.call(other, '__wrapped__'); 3366 3367 if (objIsWrapped || othIsWrapped) { 3368 var objUnwrapped = objIsWrapped ? object.value() : object, 3369 othUnwrapped = othIsWrapped ? other.value() : other; 3370 3371 stack || (stack = new _Stack); 3372 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack); 3373 } 3374 } 3375 if (!isSameTag) { 3376 return false; 3377 } 3378 stack || (stack = new _Stack); 3379 return _equalObjects(object, other, bitmask, customizer, equalFunc, stack); 3380 } 3381 3382 var _baseIsEqualDeep = baseIsEqualDeep; 3383 3384 /** 3385 * The base implementation of `_.isEqual` which supports partial comparisons 3386 * and tracks traversed objects. 3387 * 3388 * @private 3389 * @param {*} value The value to compare. 3390 * @param {*} other The other value to compare. 3391 * @param {boolean} bitmask The bitmask flags. 3392 * 1 - Unordered comparison 3393 * 2 - Partial comparison 3394 * @param {Function} [customizer] The function to customize comparisons. 3395 * @param {Object} [stack] Tracks traversed `value` and `other` objects. 3396 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 3397 */ 3398 function baseIsEqual(value, other, bitmask, customizer, stack) { 3399 if (value === other) { 3400 return true; 3401 } 3402 if (value == null || other == null || (!isObjectLike_1(value) && !isObjectLike_1(other))) { 3403 return value !== value && other !== other; 3404 } 3405 return _baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack); 3406 } 3407 3408 var _baseIsEqual = baseIsEqual; 3409 3410 /** 3411 * Performs a deep comparison between two values to determine if they are 3412 * equivalent. 3413 * 3414 * **Note:** This method supports comparing arrays, array buffers, booleans, 3415 * date objects, error objects, maps, numbers, `Object` objects, regexes, 3416 * sets, strings, symbols, and typed arrays. `Object` objects are compared 3417 * by their own, not inherited, enumerable properties. Functions and DOM 3418 * nodes are compared by strict equality, i.e. `===`. 3419 * 3420 * @static 3421 * @memberOf _ 3422 * @since 0.1.0 3423 * @category Lang 3424 * @param {*} value The value to compare. 3425 * @param {*} other The other value to compare. 3426 * @returns {boolean} Returns `true` if the values are equivalent, else `false`. 3427 * @example 3428 * 3429 * var object = { 'a': 1 }; 3430 * var other = { 'a': 1 }; 3431 * 3432 * _.isEqual(object, other); 3433 * // => true 3434 * 3435 * object === other; 3436 * // => false 3437 */ 3438 function isEqual(value, other) { 3439 return _baseIsEqual(value, other); 3440 } 3441 3442 var isEqual_1 = isEqual; 3443 3444 /* 3445 build Proxy to observe changes to object properties 3446 */ 3447 3448 const registeredObservables = {}; 3449 const getObservable = (id) => { 3450 return registeredObservables[id] 3451 }; 3452 3453 const objectConstructor = ({}).constructor; 3454 3455 const buildProxy = (self) => { 3456 return { 3457 get (target, property) { 3458 const val = Reflect.get(target, property); 3459 if (val && typeof val === 'object') return new Proxy(val, buildProxy(self)) 3460 return val 3461 }, 3462 set (target, property, value) { 3463 self.sync(property); 3464 return Reflect.set(target, property, value) 3465 }, 3466 deleteProperty (target, property) { 3467 self.sync(property); 3468 return Reflect.deleteProperty(target, property) 3469 } 3470 } 3471 }; 3472 3473 /* 3474 @class ObservableObject 3475 3476 Base class for data binding. Implements Proxy and Reflect on an object so that 3477 changes can be observed and manages subscribing and notifying observers. 3478 3479 */ 3480 class ObservableObject { 3481 /* 3482 @param { String } id - unique id of 3483 @param { Object } data - optional externally defined javascript object to observe 3484 @param { Object } options - optional, used by subclasses 3485 */ 3486 constructor (id, data = {}, options = {}) { 3487 this.id = id; 3488 3489 if (registeredObservables[this.id]) { 3490 throw (new Error('ObservableObject ' + id + ' already exists.')) 3491 } 3492 3493 this.bound = {}; // watchers to sync on value change 3494 3495 this.data = new Proxy(data, buildProxy(this)); 3496 3497 this.options = options; 3498 3499 registeredObservables[this.id] = this; 3500 } 3501 3502 /* 3503 @function destroy - remove all bindings 3504 */ 3505 destroy () { 3506 delete registeredObservables[this.id]; 3507 delete this.data;
3508 Object.keys(this.bound).forEach((prop) => { 3509 Object.keys(this.bound[prop]).forEach((k) => { 3510 this.unbind(prop, k); 3511 }); 3512 }); 3513 } 3514 3515 /* 3516 @function getBoundData - return object being observed 3517 */ 3518 getBoundData () { 3519 return this.data 3520 } 3521 3522 /* 3523 @function set - set observed object property 3524 @param { String } property - observed object property to set 3525 @param value - string, array, object or whatever to assign to property 3526 */ 3527 set (property, value) { 3528 if (!isEqual_1(this.get(property), value)) { 3529 this.data[property] = value; 3530 } 3531 } 3532 3533 /* 3534 @function get - get observed object property 3535 @param { String } property - observed object property to get 3536 */ 3537 get (property) { 3538 return this.data[property] 3539 } 3540 3541 /* 3542 @function delete - delete observed object property 3543 @param { String } property - observed object property to delete 3544 */ 3545 delete (property) { 3546 delete this.data[property]; 3547 } 3548 3549 /* 3550 @function syncAll - sync all observed object properties 3551 */ 3552 syncAll () { 3553 Object.keys(this.data || {}).forEach((k) => { 3554 this.sync(k); 3555 }); 3556 } 3557 3558 /* 3559 @function bind - attach a function to observe property changes 3560 @param { String } id - unique id of observer function 3561 @param { Function } fn - handler called when property changes 3562 @param { String } property - optional name of property to observe 3563 3564 Handler function prototype: 3565 3566 If property is not supplied, callback receives property and value 3567 (property, value) => {} 3568 3569 Otherwise just the value is supplied 3570 (value) => {} 3571 */ 3572 bind (id, fn, property = '*') { 3573 if (!this.bound[property]) { 3574 this.bound[property] = {}; 3575 } 3576 this.bound[property][id] = fn; 3577 Object.keys(this.data).forEach((k) => { 3578 fn(this.id, k, this.get(k)); 3579 }); 3580 } 3581 3582 /* 3583 @function unbind - unattach observer 3584 @param { String } id - unique id of observer function 3585 @param { String } property - optional name of property being observed 3586 */ 3587 unbind (id, property = '*') { 3588 if (this.bound[property][id]) { 3589 delete this.bound[property][id]; 3590 } 3591 } 3592 3593 /* 3594 @function observers - return current observer count 3595 */ 3596 observers () { 3597 let c = 0; 3598 for (const id in this.bound) { 3599 if (this.bound.hasOwnProperty(id)) { 3600 c++; 3601 } 3602 } 3603 return c 3604 } 3605 3606 /* 3607 function sync - notify observers of property value change 3608 @param { String } property - property that changed 3609 */ 3610 sync (property) { 3611 Object.keys(this.bound['*'] || {}).forEach((k) => { 3612 this.bound['*'][k](this.id, property, this.get(property)); 3613 }); 3614 Object.keys(this.bound[property] || {}).forEach((k) => { 3615 this.bound[property][k](this.id, property, this.get(property)); 3616 }); 3617 } 3618 } 3619 3620 /** 3621 Shared event observers used by Sargasso classes. 3622 3623 When these observers have subscribers they watch for events 3624 and notify the subscriber's specific event handler 3625 method when they occur. 3626 3627 @author Michael Rhodes (except where noted) 3628 @license MIT 3629 Made in Barbados ð§ð§ Copyright © 2020 Michael Rhodes 3630 3631 Subscribers to these services must imlement handler methods 3632 EG. watchDOM, watchScroll, watchResize, watchOrientation 3633 **/ 3634 3635 let theDOMWatcher; 3636 let theScrollWatcher; 3637 let theResizeWatcher; 3638 let theOrientationWatcher; 3639 let theWorkerWatcher; 3640 let theObservableObjectWatcher; 3641 3642 class ObserverSubscriptionManager { 3643 constructor (options) { 3644 this.options = options; 3645 this.observers = []; 3646 this.pendingAnimationFrame = undefined; 3647 this.frameQueue = []; 3648 this.sleeping = true; 3649 } 3650 3651 subscribe (observer) { 3652 if (!this.observers.length && this.sleeping) { 3653 this.wakeup(); 3654 } 3655 this.observers.push(observer); 3656 } 3657 3658 unSubscribe (observer) { 3659 if (this.observers.indexOf(observer) !== -1) { 3660 this.observers.splice(this.observers.indexOf(observer), 1); 3661 } 3662 3663 if (!this.observers.length) { 3664 this.sleep(); 3665 } 3666 } 3667 3668 sleep () { 3669 this.sleeping = true; 3670 } 3671 3672 wakeup () { 3673 this.sleeping = false; 3674 } 3675 3676 notifyObservers (event, params) { 3677 for (let i = 0; i < this.observers.length; i++) { 3678 if (this.observers[i][event]) { 3679 this.observers[i][event].apply(this.observers[i], params || []); 3680 } 3681 } 3682 } 3683 3684 flushQueue () { 3685 if (this.pendingAnimationFrame) { 3686 cancelAnimationFrame(this.pendingAnimationFrame); 3687 this.pendingAnimationFrame = undefined; 3688 } 3689 this.frameQueue = []; 3690 } 3691 3692 queueFrame (frame) { 3693 this.frameQueue.push(frame.bind(this)); 3694 if (!this.pendingAnimationFrame) { 3695 this.pendingAnimationFrame = requestAnimationFrame(() => { 3696 this.processQueue(); 3697 }); 3698 } 3699 } 3700 3701 processQueue () { 3702 this.pendingAnimationFrame = undefined; 3703 const toProcess = this.frameQueue.slice(0); 3704 this.frameQueue = []; 3705 for (let i = 0; i < toProcess.length; i++) { 3706 toProcess[i](); 3707 } 3708 } 3709 } 3710 3711 class DOMWatcher extends ObserverSubscriptionManager { 3712 constructor (options = {}) { 3713 super(options); 3714 3715 // debounce - just need to know if a change occured, not every change 3716 this.mutationHandler = debounce_1((mutations, observer) => { 3717 this.observeDOM(this.options.shadowDOM || document.body); 3718 }, 25, { 3719 maxWait: 100 3720 }); 3721 3722 this.mutationObserver = new MutationObserver(this.mutationHandler, false); 3723 } 3724 3725 subscribe (observer) { 3726 super.subscribe(observer); 3727 observer.watchDOM(this.options.shadowDOM || document.body); 3728 } 3729 3730 wakeup () { 3731 super.wakeup(); 3732 this.mutationObserver.observe(this.options.shadowDOM || document.body, { 3733 childList: true, 3734 subtree: true 3735 }); 3736 } 3737 3738 sleep () { 3739 super.sleep(); 3740 this.mutationObserver.disconnect(); 3741 } 3742 3743 observeDOM (root) { 3744 this.notifyObservers('watchDOM', [root || this.options.shadowDOM || document.body]); 3745 } 3746 } 3747 3748 class ScrollWatcher extends ObserverSubscriptionManager { 3749 constructor (options = {}) { 3750 super(options); 3751 3752 this.scrollElement = this.options.scrollElement || window; 3753 this.lastscroll = 0; 3754 this.scrolling = false;
3755 } 3756 3757 // use 'scroll' event to start scroll loop unless it's already looping 3758 trigger () { 3759 if (!this.scrolling) { 3760 this.scrollLoop(); 3761 } 3762 } 3763 3764 scrollLoop () { 3765 if (this.lastscroll !== this.scrollTop()) { // are we still scrolling? 3766 this.scrolling = true; 3767 this.lastscroll = this.scrollTop(); 3768 this.watchScroll(); // tell our observers 3769 const frame = () => { 3770 this.scrollLoop(); 3771 }; 3772 this.queueFrame(frame); 3773 } else { 3774 this.scrolling = false; // exit the scroll loop and wait for next 'scroll' event 3775 } 3776 } 3777 3778 setOptions (options = {}) { 3779 this.sleep(); 3780 this.scrollElement = options.scrollElement || window; 3781 this.wakeup(); 3782 } 3783 3784 subscribe (observer) { 3785 super.subscribe(observer); 3786 observer.watchScroll(); 3787 } 3788 3789 wakeup () { 3790 super.wakeup(); 3791 elementTools.on('theScrollWatcher', this.scrollElement, 'scroll', () => { 3792 this.trigger(); 3793 }); 3794 } 3795 3796 sleep () { 3797 super.sleep(); 3798 elementTools.off('theScrollWatcher', this.scrollElement, 'scroll'); 3799 } 3800 3801 inViewPort (element) { 3802 return elementTools.inViewPort(element, this.scrollElement) 3803 } 3804 3805 watchScroll () { 3806 this.notifyObservers('watchScroll'); 3807 } 3808 3809 scrollTop (newTop) { 3810 if (this.scrollElement === window) { 3811 if (newTop !== undefined) { 3812 window.scrollTo(0, newTop); 3813 } else { 3814 return window.pageYOffset 3815 } 3816 } else { 3817 if (newTop !== undefined) { 3818 this.scrollElement.scrollTop = newTop; 3819 } else { 3820 return this.scrollElement.scrollTop 3821 } 3822 } 3823 } 3824 } 3825 3826 class ResizeWatcher extends ObserverSubscriptionManager { 3827 constructor (options) { 3828 super(options); 3829 3830 this.debounce = debounce_1(() => { 3831 this.watchResize(); 3832 }, 250); 3833 } 3834 3835 subscribe (observer) { 3836 super.subscribe(observer); 3837 observer.watchResize(); 3838 } 3839 3840 wakeup () { 3841 super.wakeup(); 3842 window.addEventListener('resize', this.debounce, false); 3843 } 3844 3845 sleep () { 3846 super.sleep(); 3847 window.removeEventListener('resize', this.debounce); 3848 } 3849 3850 watchResize () { 3851 this.notifyObservers('watchResize'); 3852 } 3853 } 3854 3855 class OrientationWatcher extends ObserverSubscriptionManager { 3856 constructor (options) { 3857 super(options); 3858 3859 if ('onorientationchange' in window) { 3860 elementTools.addClass(document.body, 'have-orientation'); 3861 } else { 3862 elementTools.addClass(document.body, 'no-orientation'); 3863 } 3864 3865 this.debounce = debounce_1(() => { 3866 this.watchOrientation(); 3867 }, 250); 3868 } 3869 3870 subscribe (observer) { 3871 super.subscribe(observer); 3872 observer.watchOrientation(); 3873 } 3874 3875 wakeup () { 3876 super.wakeup(); 3877 if ('onorientationchange' in window) { 3878 window.addEventListener('orientationchange', this.debounce, false); 3879 } 3880 } 3881 3882 sleep () { 3883 super.sleep(); 3884 if ('onorientationchange' in window) { 3885 window.removeEventListener('orientationchange', this.debounce); 3886 } 3887 } 3888 3889 watchOrientation () { 3890 this.notifyObservers('watchOrientation'); 3891 } 3892 } 3893 3894 // keep track of who is using web workers and 3895 // cleanup dangling worker when no subscribers remain 3896 class WorkerWatcher extends ObserverSubscriptionManager { 3897 constructor (options) { 3898 super(options); 3899 this.workers = {}; 3900 } 3901 3902 registerWorker (id, codeOrURL) { 3903 if (!this.workers[id]) { 3904 // create a worker for the id if worker id is unknown 3905 3906 let blobURL = codeOrURL; 3907 3908 let revoke = false; 3909 if (!codeOrURL.match(/^(http|\/)/i)) { 3910 const blob = new Blob([codeOrURL], { 3911 type: 'text/javascript' 3912 }); 3913 blobURL = URL.createObjectURL(blob); 3914 revoke = true; 3915 } 3916 3917 this.workers[id] = { 3918 worker: new Worker(blobURL), 3919 observers: [] 3920 }; 3921 3922 if (revoke) { 3923 URL.revokeObjectURL(blobURL); 3924 } 3925 3926 this.workers[id].worker.onmessage = (e) => { 3927 this.workerMessage(id, e); 3928 }; 3929 } 3930 3931 return this.workers[id].worker 3932 } 3933 3934 subscribe (observer, id) { 3935 if (!this.workers[id]) { 3936 throw (new Error('worker ' + id + ' does not exist')) 3937 } 3938 const workerObservers = this.workers[id].observers; 3939 workerObservers.push(observer); 3940 super.subscribe(observer); 3941 } 3942 3943 unSubscribe (observer, id) { 3944 if (!this.workers[id]) { 3945 throw (new Error('worker ' + id + ' does not exist')) 3946 } 3947 3948 const workerObservers = this.workers[id].observers; 3949 if (workerObservers.indexOf(observer) !== -1) { 3950 workerObservers.splice(workerObservers.indexOf(observer), 1); 3951 } 3952 3953 if (!workerObservers.length) { 3954 this.workers[id].worker.terminate(); 3955 delete this.workers[id]; 3956 } 3957 3958 super.unSubscribe(observer); 3959 } 3960 3961 workerMessage (id, e) { 3962 const workerObservers = this.workers[id].observers;
3963 workerObservers.forEach((observer) => { 3964 if (observer.workerMessage) { 3965 observer.workerMessage(id, e); 3966 } 3967 }); 3968 } 3969 3970 wakeup () { 3971 super.wakeup(); 3972 } 3973 3974 sleep () { 3975 super.sleep(); 3976 } 3977 } 3978 3979 class ObservableObjectWatcher extends ObserverSubscriptionManager { 3980 constructor (options) { 3981 super(options); 3982 this.registeredObservableObjects = {}; 3983 } 3984 3985 getObservable (id) { 3986 return this.registeredObservableObjects[id] ? this.registeredObservableObjects[id].observable : undefined 3987 } 3988 3989 observableStart (id, data) { 3990 const foundObservable = getObservable(id); 3991 3992 // trying to define with data but already exists 3993 if (foundObservable && data !== undefined) { 3994 throw (new Error('ObservableObject ' + id + ' already exists, can\'t build.')) 3995 } 3996 3997 if (!this.registeredObservableObjects[id]) { // not already managing observable 3998 if (foundObservable) { // add to service 3999 this.registeredObservableObjects[id] = { 4000 id: id, 4001 observable: foundObservable, 4002 observers: [], 4003 managed: false 4004 }; 4005 } else { // make it 4006 this.registeredObservableObjects[id] = { 4007 id: id, 4008 observable: new ObservableObject(id, data), 4009 observers: [], 4010 managed: true 4011 }; 4012 } 4013 this.registeredObservableObjects[id].observable.bind(this.constructor.name, this.notify.bind(this)); 4014 } 4015 4016 return this.registeredObservableObjects[id].observable 4017 } 4018 4019 // delete an observable 4020 observableDestroy (id) { 4021 if (!this.registeredObservableObjects[id]) { 4022 throw (new Error('ObservableObject observableDestroy ' + id + ' does not exist')) 4023 } 4024 this.registeredObservableObjects[id].observable.unbind(this.constructor.name); 4025 this.registeredObservableObjects[id].observable.destroy(); 4026 delete this.registeredObservableObjects[id]; 4027 } 4028 4029 subscribe (observer, id, data) { 4030 if (!this.registeredObservableObjects[id]) { 4031 this.observableStart(id, data); 4032 } 4033 this.registeredObservableObjects[id].observers.push(observer); 4034 super.subscribe(observer); 4035 } 4036 4037 unSubscribe (observer, id) { 4038 if (!this.registeredObservableObjects[id]) { 4039 throw (new Error('ObservableObject unSubscribe ' + id + ' does not exist')) 4040 } 4041 4042 const observers = this.registeredObservableObjects[id].observers; 4043 if (observers.indexOf(observer) !== -1) { 4044 observers.splice(observers.indexOf(observer), 1); 4045 } 4046 4047 if (!observers.length && this.registeredObservableObjects[id].managed) { 4048 this.observableDestroy(id); 4049 } 4050 4051 super.unSubscribe(observer); 4052 } 4053 4054 notify (id, property, value, source) { 4055 if (!this.registeredObservableObjects[id]) { 4056 throw (new Error('ObservableObject notify ' + id + ' does not exist')) 4057 } 4058 const observers = this.registeredObservableObjects[id].observers; 4059 observers.forEach((observer) => { 4060 if (observer.observableChanged) { 4061 observer.observableChanged(id, property, value, source); 4062 } 4063 }); 4064 } 4065 } 4066 4067 // build subscription services 4068 4069 theDOMWatcher = new DOMWatcher(); 4070 theScrollWatcher = new ScrollWatcher(); 4071 theResizeWatcher = new ResizeWatcher(); 4072 theOrientationWatcher = new OrientationWatcher(); 4073 theWorkerWatcher = new WorkerWatcher(); 4074 theObservableObjectWatcher = new ObservableObjectWatcher(); 4075 4076 /** 4077 * Converts `string` to 4078 * [kebab case](https://en.wikipedia.org/wiki/Letter_case#Special_case_styles). 4079 * 4080 * @static 4081 * @memberOf _ 4082 * @since 3.0.0 4083 * @category String 4084 * @param {string} [string=''] The string to convert. 4085 * @returns {string} Returns the kebab cased string. 4086 * @example 4087 * 4088 * _.kebabCase('Foo Bar'); 4089 * // => 'foo-bar' 4090 * 4091 * _.kebabCase('fooBar'); 4092 * // => 'foo-bar' 4093 * 4094 * _.kebabCase('__FOO_BAR__'); 4095 * // => 'foo-bar' 4096 */ 4097 var kebabCase = _createCompounder(function(result, word, index) { 4098 return result + (index ? '-' : '') + word.toLowerCase(); 4099 }); 4100 4101 var kebabCase_1 = kebabCase; 4102 4103 /** 4104 Sargasso 4105 4106 Base class for responsive Sargasso element controllers. Subclass this to 4107 define specific behavior. If you mutate the DOM in your code you 4108 should use frames for best results. 4109 4110 @author Michael Rhodes (except where noted) 4111 @license MIT 4112 Made in Barbados ð§ð§ Copyright © 2020 Michael Rhodes 4113 **/ 4114 4115 let unique = 0; // unique IDs for controllers 4116 const liveElements = []; // instantiated controllers 4117 4118 const supportsCustomElements = ('customElements' in window); // browser supports custom elements 4119 4120 const registeredClasses = {}; 4121 4122 /* 4123 @function registerSargassoClass 4124 @param { String } className - name of class 4125 @param { Object } object - class reference 4126 4127 All subclasses of Sargasso must register the class so that 4128 the SargassoSupervisor can instantiate them. 4129 4130 EG. 4131 class mySubclass extends Sargasso {} 4132 registerSargassoClass('mySubclass',mySubclass) 4133 4134 Then an instance of mySubclass will be instantiated and attached to the element 4135 whenever it appears in the DOM usind data tag or custom element tag: 4136 4137 <div data-sargasso-class="mySubclass"></div> 4138 4139 - or - 4140 4141 <sargasso-my-subclass></sargasso-my-subclass> 4142 4143 */ 4144 const registerSargassoClass = (className, object) => { 4145 if (registeredClasses[className]) { 4146 throw (new Error('Sargasso class ' + className + ' is already registered.')) 4147 } 4148 4149 registeredClasses[className] = object; 4150 4151 if (supportsCustomElements) { 4152 /* 4153 for custom html element scheme <sargasso-class-name sargasso-other-class-name></sargasso-class-name> 4154 we define a factory to build a class that is a subclass of HTMLElement. 4155 The browser will instantiate this class when the element appears in the DOM 4156 allowing us to instantiate the required sargasso controller 4157 and cleanup when the html element is removed from the dom using 4158 connectedCallback and disconnectedCallback. 4159 4160 This scheme allows us to keep the namespace of the element unpolluted with 4161 sargasso properties and methods. 4162 */ 4163 const customElementClassFactory = 4164 ` 4165 return class ${className}Element extends HTMLElement { 4166 constructor(element, options = {}) { 4167 super() 4168 this.helperClass= '${className}' 4169 this.helpers = [] 4170 } 4171 4172 connectedCallback () { 4173 this.helpers.push(new registeredClasses[this.helperClass](this,{isCustomElement:true})) 4174 if (this.hasAttributes()) { 4175 for(let i = 0; i < this.attributes.length; i++) { 4176 if(this.attributes[i].name.match(/^sargasso-/)) {
4177 let classname = this.attributes[i].name.replace(/^sargasso-/,'').split('-').map(word=> word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join('') 4178 if(!registeredClasses[classname]) { 4179 console.log('instantiate by attribute ' + this.attributes[i].name + ' > ' + classname + ' is not a sargasso class') 4180 continue 4181 } 4182 this.helpers.push(new registeredClasses[classname](this,{isCustomElement:true})) 4183 } 4184 } 4185 } 4186 4187 this.helpers.forEach((helper) => { 4188 helper.start() 4189 }) 4190 } 4191 4192 disconnectedCallback () { 4193 this.helpers.forEach((helper) => { 4194 helper.sleep() 4195 helper.destroy() 4196 }) 4197 this.helpers = [] // nuke the reference for trash collection 4198 } 4199 }`; 4200 4201 const fn = new Function('registeredClasses', customElementClassFactory)(registeredClasses); 4202 customElements.define('sargasso-' + kebabCase_1(className), fn); 4203 } 4204 }; 4205 4206 // the public event handlers to implement in subclasses 4207 const eventNames = [ 4208 'DOMChanged', 4209 'didScroll', 4210 'didResize', 4211 'didBreakpoint',
4212 'enterViewport', 4213 'exitViewport', 4214 'enterFullscreen', 4215 'exitFullscreen', 4216 'newPage', 4217 'elementEvent', 4218 'workerOnMessage', 4219 'observableChanged' 4220 ]; 4221 4222 /* 4223 @class Sargasso - the superclass for all element controllers 4224 */ 4225 class Sargasso { 4226 constructor (element, options = {}) { 4227 this.uid = ++unique; 4228 this.element = element; 4229 if (options.shadowDOM) { 4230 this.shadowDOM = element.attachShadow({ 4231 mode: 'open' 4232 }); 4233 this.shadowRoot = document.createElement('div'); 4234 this.shadowDOM.append(this.shadowRoot); 4235 this.hostElement = this.element; 4236 this.element = this.shadowRoot; 4237 this.hostTemplates = {}; // <template id="xxx"></template> 4238 const templates = this.hostElement.querySelectorAll('template'); 4239 if (templates.length) { 4240 templates.forEach((t) => { 4241 if (t.getAttribute('id')) { 4242 this.hostTemplates[t.getAttribute('id')] = t.content.cloneNode(true); 4243 } 4244 }); 4245 } 4246 } 4247 this.options = options; 4248 this.pendingAnimationFrame = undefined; 4249 this.frameQueue = []; 4250 this.isInViewport = false; 4251 this.workers = {}; 4252 this.observables = {}; 4253 this.template = undefined; 4254 this.templateArgs = {}; 4255 this.started = false; 4256 4257 this.render = debounce_1(() => { 4258 this._render(); 4259 }, 100, { 4260 maxWait: 250 4261 }); 4262 } 4263 4264 /* 4265 @function start - called when controller is instantiated 4266 4267 Override this to perform any initialization such as event listeners 4268 4269 Note: always call super.start() in at the top of your subclass start method 4270 */ 4271 start () { 4272 const registeredResponsiveControllers = this.getMetaData('registeredResponsiveControllers') || []; 4273 registeredResponsiveControllers.push(this); 4274 this.setMetaData('registeredResponsiveControllers', registeredResponsiveControllers); 4275 this.setMetaData(this.constructor.name, this); 4276 4277 liveElements.push(this); 4278 4279 // if using shadow DOM, build a DOMWatcher to observe changes 4280 if (this.shadowDOM) { 4281 if (!this.shadowDOMWatcher) { 4282 this.shadowDOMWatcher = new DOMWatcher({ 4283 shadowDOM: this.shadowRoot 4284 }); 4285 } 4286 this.shadowDOMWatcher.subscribe(this); 4287 } 4288 4289 // subscribe to desired event services 4290 4291 if (this.options.watchDOM) { 4292 theDOMWatcher.subscribe(this); 4293 } 4294 4295 if (this.options.watchScroll || this.options.watchViewport) { 4296 theScrollWatcher.subscribe(this); 4297 } 4298 4299 if (this.options.watchResize || this.options.watchViewport) { 4300 theResizeWatcher.subscribe(this); 4301 } 4302 4303 if (this.options.watchOrientation || this.options.watchViewport) { 4304 theOrientationWatcher.subscribe(this); 4305 } 4306 4307 /* 4308 listen for 'sargasso' events 4309 Call the method named in e.detail.sargassoEvent or call this.elementEvent 4310 */ 4311 4312 this.elementListener = (e) => { 4313 if (e.detail && e.detail.sargassoEvent && eventNames.indexOf(e.detail.sargassoEvent) !== -1) { 4314 this[e.detail.sargassoEvent].apply(this, e.detail.sargassoEventOptions || []); 4315 } else { 4316 this.elementEvent(e); 4317 } 4318 }; 4319 4320 this.element.addEventListener('sargasso', this.elementListener); 4321 4322 this.started = true; 4323 } 4324 4325 /* 4326 @function sleep - override this to clean up any events or references in your subclass 4327 4328 Called when element has been removed from DOM just before it is destroyed 4329 4330 Note: always call super.sleep() at the end of your subclass sleep method 4331 */ 4332 sleep () { 4333 if (this.shadowDOM) { 4334 this.shadowDOMWatcher.unSubscribe(this); 4335 } 4336 4337 if (this.options.watchDOM) { 4338 theDOMWatcher.unSubscribe(this); 4339 } 4340 4341 if (this.options.watchScroll || this.options.watchViewport) { 4342 theScrollWatcher.unSubscribe(this); 4343 } 4344 4345 if (this.options.watchResize || this.options.watchViewport) { 4346 theResizeWatcher.unSubscribe(this); 4347 } 4348 4349 if (this.options.watchOrientation || this.options.watchViewport) { 4350 theOrientationWatcher.unSubscribe(this); 4351 } 4352 4353 this.element.removeEventListener('sargasso', this.elementListener); 4354 4355 elementTools.offAll(this.element); // remove all dangling event listeners created with on/once 4356 4357 this.started = false; 4358 } 4359 4360 /************************************************************** 4361 EVENT HOOKS - Override these methods in your subclass as needed 4362 ***************************************************************/ 4363 4364 /* 4365 @function DOMChanged - something changed on the page 4366 called if options.watchDOM set, override as needed. 4367 */ 4368 DOMChanged (root) {} 4369 4370 /* 4371 @function didScroll - scroll occured 4372 called if options.watchScroll set, override as needed. 4373 */ 4374 didScroll () {} 4375 4376 /* 4377 @function didResize - resize occured 4378 called if options.watchResize set, override as needed. 4379 */ 4380 didResize () {} 4381 4382 /* 4383 @function didBreakpoint - new breakpoint, override as needed. 4384 */ 4385 didBreakpoint () {} 4386 4387 /*
4388 @function enterViewport - element entered the viewport 4389 called if options.watchViewport set, override as needed. 4390 */ 4391 enterViewport () {} 4392 4393 /* 4394 @function exitViewport - element exited the viewport 4395 called if options.watchViewport set, override as needed. 4396 */ 4397 exitViewport () {} 4398 4399 /* 4400 @function enterFullscreen - element entered fullscreen, override as needed. 4401 */ 4402 enterFullscreen () {} 4403 4404 /* 4405 @function exitFullscreen - element exited fullscreen, override as needed. 4406 */ 4407 exitFullscreen () {} 4408 4409 /* 4410 @function newPage - page changed 4411 @param { String } oldPath - outgoing page 4412 @param { String } newPath - incoming page 4413 */ 4414 newPage (oldPath, newPath) {} 4415 4416 /* 4417 @function elementEvent - element received a 'sargasso' custom event from somewhere 4418 @param { Object } e - event 4419 */ 4420 elementEvent (e) {} 4421 4422 /* 4423 @function workerOnMessage - listen for worker postMessage event 4424 @param { String } id - id of worker started with this.workerStart() 4425 @param { Object } data - data received from worker 4426 */ 4427 workerOnMessage (id, data) {} 4428 4429 /* 4430 @function observableChange - listen for changes to observable object 4431 @param { String } id - id of observable 4432 @param { String } property - property that changed 4433 @param { String } value - new value 4434 */ 4435 observableChanged (id, property, value) { 4436 this.render(); 4437 } 4438 4439 /**************************************************** 4440 UTILITY METHODS - callable but normally not overriden 4441 *****************************************************/ 4442 4443 /* 4444 @function setMetaData - Set metadata. Key value storage implemented as a weakMap 4445 @param { String } - key name for value 4446 @param { Object } - value or JSON object, null will remove from key from metadate 4447 */ 4448 setMetaData (k, v) { 4449 elementTools.setMetaData(this.element, k, v); 4450 } 4451 4452 /* 4453 @function getMetaData - Retrieve metadata 4454 @param { String } key - name of value to return 4455 @return { Object } if key is found otherwise undefined 4456 */ 4457 getMetaData (k) { 4458 return elementTools.getMetaData(this.element, k) 4459 } 4460 4461 /* 4462 @function on - add delegated event handler for this.element 4463 @param { String} evt - HTML element event name 4464 @param { String } selector - optional element query selector 4465 @param { Function } fn - event handler function 4466 @param { Object } [options] - for addEventListener 4467 */ 4468 on (evt, selector, fn, options) { 4469 elementTools.on(this.constructor.name + '-' + this.uid, this.element, evt, selector, fn, options); 4470 } 4471 4472 /* 4473 @function off - Remove delegated event handler 4474 @param { String} evt - HTML element event name 4475 @param { String } [selector] - element query selector 4476 */ 4477 off (evt, selector) { 4478 elementTools.off(this.constructor.name + '-' + this.uid, this.element, evt, selector); 4479 } 4480 4481 /* 4482 @function once - add delegated event handler for this.element witch executes only once 4483 @param { String} evt - HTML element event name 4484 @param { String } selector - optional element query selector 4485 @param { Function } fn - event handler function 4486 @param { Object } [options] - for addEventListener 4487 */ 4488 once (evt, selector, fn, options) { 4489 elementTools.once(this.constructor.name + '-' + this.uid, this.element, evt, selector, fn, options); 4490 } 4491 4492 /* 4493 @function notifyAll - broadcast 'event' to all instantiated sargasso controllers 4494 @param { String } event - name of sargasso event 4495 @param { Object } params - array of params to attach to event 4496 */ 4497 notifyAll (event, params) { 4498 if (eventNames.indexOf(event) === -1) { 4499 throw (new Error('invalid event name ' + event)) 4500 } 4501 for (let i = 0; i < liveElements.length; i++) { 4502 const peer = liveElements[i]; 4503 if (peer !== this && peer[event]) { 4504 peer[event].apply(peer, params); 4505 } 4506 } 4507 } 4508 4509 /* 4510 @function notifyElement - broadcast event to all sargasso controllers for 'this.element' 4511 @param { String } event - name of sargasso event 4512 @param { Object } params - array of params to attach to event 4513 */ 4514 notifyElement (element, event, params) { 4515 if (eventNames.indexOf(event) === -1) { 4516 throw (new Error('invalid event name ' + event)) 4517 } 4518 4519 const registeredResponsiveControllers = this.getMetaData('registeredResponsiveControllers'); 4520 if (registeredResponsiveControllers) { 4521 for (let i = 0; i < registeredResponsiveControllers.length; i++) { 4522 const peer = registeredResponsiveControllers[i]; 4523 if (peer !== this && peer[event]) { 4524 peer[event].apply(peer, params); 4525 } 4526 } 4527 } 4528 } 4529 4530 /* 4531 @function queueFrame - schedule a task in the requestAnimation frame event loop 4532 @param { function } frame - function to execute 4533 4534 Call this to queue functions that mutate the DOM (make changes to html) 4535 4536 EG: 4537 let frame = () => { 4538 this.element.addClass('big') 4539 } 4540 this.queueFrame(frame) 4541 4542 The frame will then be executed in the next requested animation frame 4543 */ 4544 queueFrame (frame) { 4545 this.frameQueue.push(frame.bind(this)); 4546 if (!this.pendingAnimationFrame) { 4547 this.pendingAnimationFrame = requestAnimationFrame(() => { 4548 this.processQueue(); 4549 }); 4550 } 4551 } 4552 4553 /* 4554 @function wantFullscreen - request full screen 4555 you can call this from a subclass controller such as an 'enlarge to full screen' button 4556 otherwise if watchOrientation is set it will call this when phone is in landscape 4557 it would be nice to acually use the experimental requestFullScreen thing but 4558 you can't do that on rotate at the moment, only on click. 4559 */ 4560 wantFullscreen (want) { 4561 if (want) { 4562 this.enterFullscreen(); 4563 } else { 4564 this.exitFullscreen(); 4565 } 4566 } 4567 4568 /********************************************************************** 4569 ELEMENT UTILITIES - convienience methods for manipilating HTML elements 4570 ***********************************************************************/ 4571 4572 hasClass (cssClass) { 4573 return elementTools.hasClass(this.element, cssClass) 4574 } 4575
4576 addClass (cssClasses) { 4577 elementTools.addClass(this.element, cssClasses); 4578 } 4579 4580 removeClass (cssClasses) { 4581 elementTools.removeClass(this.element, cssClasses); 4582 } 4583 4584 setCSS (cssObject) { 4585 elementTools.setCSS(this.element, cssObject); 4586 } 4587 4588 isVisible () { 4589 return elementTools.isVisible(this.element) 4590 } 4591 4592 /* 4593 @function workerStart - start a web worker 4594 @param { String } id - id of worker 4595 @param { String | Url } codeOrURL - javascript worker code or url to download shared worker code 4596 4597 Offload compute heavy tasks to a new thread and listen for result 4598 4599 Pass it a url of a web worker js file or create an inline web worker 4600 from string of raw code such as: 4601 4602 let mycode = `onmessage = function (e) { 4603 // e.data contains whatever is passed by this.workerPostMessage() 4604 4605 // do something here 4606 4607 // when done send message back to sargasso controller: 4608 postMessage({ 4609 uid: e.data.uid, // ALWAYS pass this back 4610 result: 'Done doing pointless stuff: ' + e.data.answer 4611 }) 4612 }` 4613 4614 this.workerStart('pointless-stuff', mycode) 4615 4616 this.workerPostMessage('pointless-stuff', {answer:42}) 4617 4618 */ 4619 workerStart (id, codeOrURL) { 4620 this.workers[id] = theWorkerWatcher.registerWorker(id, codeOrURL); 4621 theWorkerWatcher.subscribe(this, id); 4622 return this.workers[id] 4623 } 4624 4625 /* 4626 @function workerPostMessage - send a message to a running worker 4627 @param { String } id - id of worker 4628 @param { Object } message - data to send to worker 4629 */ 4630 workerPostMessage (id, message) { 4631 if (!message.uid) { 4632 message.uid = this.uid; 4633 } 4634 if (this.workers[id]) { 4635 this.workers[id].postMessage(message); 4636 } 4637 } 4638 4639 /************************************************ 4640 observe observable objects 4641 get or set observable object by unique id 4642 obj optional external object 4643 *************************************************/ 4644 4645 getObservable (id) { 4646 return this.observables[id] 4647 } 4648 4649 observableStart (id, data) { 4650 theObservableObjectWatcher.subscribe(this, id, data); 4651 this.observables[id] = theObservableObjectWatcher.getObservable(id); 4652 return this.observables[id] 4653 } 4654 4655 observableStop (id) { 4656 if (this.observables[id]) { 4657 theObservableObjectWatcher.unSubscribe(this, id); 4658 delete this.observables[id]; 4659 } 4660 } 4661 4662 observableStopAll () { 4663 for (const id in this.observables) { 4664 this.observableStop(id); 4665 } 4666 } 4667 4668 setTemplate (template) { 4669 this.template = template; 4670 } 4671 4672 setRenderer (renderer) { 4673 this.renderer = renderer; 4674 } 4675 4676 setTemplateArgs (args = {}) { 4677 this.templateArgs = args.constructor && args.constructor.name === 'ObservableObject' ? args.data : args; 4678 this.render(); 4679 } 4680 4681 getTemplateArgs () { 4682 return JSON.parse(JSON.stringify(this.templateArgs || {})) 4683 } 4684 4685 // this.render is a debounced call to this 4686 _render () { 4687 if (this.template && this.renderer) { 4688 this.renderer(this.template(this.getTemplateArgs()), this.element); 4689 } 4690 } 4691 4692 /************************************************ 4693 PRIVATE METHODS: normally not called or overriden 4694 *************************************************/ 4695 4696 /* 4697 @function flushQueue - disgard all pending frames 4698 */ 4699 flushQueue () { 4700 if (this.pendingAnimationFrame) { 4701 cancelAnimationFrame(this.pendingAnimationFrame); 4702 this.pendingAnimationFrame = undefined; 4703 } 4704 this.frameQueue = []; 4705 } 4706 4707 /* 4708 @function flushQueue - execute pending frames 4709 */ 4710 processQueue () { 4711 this.pendingAnimationFrame = undefined; 4712 const toProcess = this.frameQueue.slice(0); 4713 this.frameQueue = []; 4714 for (let i = 0; i < toProcess.length; i++) { 4715 toProcess[i](); 4716 } 4717 } 4718 4719 /* 4720 @function stopWorker - stop a worker 4721 */ 4722 stopWorker (id) { 4723 if (this.workers[id]) { 4724 theWorkerWatcher.unSubscribe(this, id); 4725 delete this.workers[id]; 4726 } 4727 } 4728 4729 /* 4730 @function stopAllWorkers - cleanup all workers registered by me 4731 */ 4732 stopAllWorkers () { 4733 for (const worker in this.workers) { 4734 this.stopWorker(worker); 4735 } 4736 } 4737 4738 /* 4739 @function destroy - called when this.element is removed from the DOM 4740 */ 4741 destroy () { 4742 this.stopAllWorkers(); 4743 this.observableStopAll(); 4744 4745 this.flushQueue(); 4746 4747 if (this.started) { 4748 this.sleep(); 4749 } 4750 4751 const registeredResponsiveControllers = this.getMetaData('registeredResponsiveControllers'); 4752 if (registeredResponsiveControllers) { 4753 if (registeredResponsiveControllers.indexOf(this) !== -1) { 4754 registeredResponsiveControllers.splice(registeredResponsiveControllers.indexOf(this), 1); 4755 this.setMetaData('registeredResponsiveControllers', registeredResponsiveControllers); 4756 } 4757 } 4758 4759 this.setMetaData(this.constructor.name, null); 4760 4761 this.element = null; 4762 4763 if (liveElements.indexOf(this) !== -1) { 4764 liveElements.splice(liveElements.indexOf(this), 1); 4765 } 4766 } 4767 4768 /**************************************************** 4769 EVENT HOOK METHODS - normally not called or overriden 4770 *****************************************************/ 4771 4772 /*
4773 @function watchDOM - hook called if options.watchDOM set and DOM changed 4774 */ 4775 watchDOM (root) { 4776 if (root === this.shadowRoot) { 4777 // something happend this element's my shadow DOM, tell in the DOM about it 4778 // so dom observers can take actions such as instantiating new sargasso 4779 // controllers, etc. 4780 theDOMWatcher.observeDOM(this.shadowRoot); 4781 } else { 4782 this.DOMChanged(root); 4783 } 4784 } 4785 4786 /* 4787 @function watchScroll - hook called if options.watchScroll set and Scroll Wrapper scrolled 4788 */ 4789 watchScroll () { 4790 if (this.options.watchViewport) { 4791 this.inViewport(); 4792 } 4793 4794 this.didScroll(); 4795 } 4796 4797 /* 4798 @function watchResize - hook called if options.watchResize set and window changed size 4799 */ 4800 watchResize () { 4801 if (this.options.watchViewport) { 4802 this.inViewport(); 4803 } 4804 4805 this.didResize(); 4806 } 4807 4808 /* 4809 @function watchOrientation - hook called if options.watchOrientation set and orientation changes 4810 */ 4811 watchOrientation () { 4812 if (window.orientation && (window.orientation === 90 || window.orientation === -90)) { 4813 this.wantFullscreen(true); 4814 } else { 4815 this.wantFullscreen(false); 4816 } 4817 } 4818 4819 /* 4820 @function inViewport - hook called if options.watchViewPort set and this.element enters viewport 4821 */ 4822 inViewport () { 4823 if (theScrollWatcher.inViewPort(this.element)) { 4824 if (!this.isInViewport) { 4825 this.enterViewport(); 4826 this.isInViewport = true; 4827 } 4828 } else { 4829 if (this.isInViewport) { 4830 this.exitViewport(); 4831 this.isInViewport = false; 4832 } 4833 } 4834 }; 4835 4836 /* 4837 @function workerMessage - hook called when worker posts a message 4838 */ 4839 workerMessage (id, e) { 4840 if (e.data.uid === this.uid) { 4841 this.workerOnMessage(id, e.data); 4842 } 4843 } 4844 4845 // experimental 4846 4847 nativeRequestFullScreen () { 4848 if (document.fullscreenElement) { 4849 if (document.fullscreenElement === this.element) { 4850 return 4851 } 4852 document.exitFullscreen(); 4853 } 4854 4855 this.element.requestFullscreen(); 4856 } 4857 4858 nativeExitFullScreen () { 4859 if (document.fullscreenElement && document.fullscreenElement === this.element) { 4860 document.exitFullscreen(); 4861 } 4862 } 4863 } 4864 4865 registerSargassoClass('Sargasso', Sargasso); 4866 4867 /** 4868 LazyInstantiate 4869 4870 Sargasso class watches the document for new content and instantiates 4871 Sargasso classes liested in element's data-lazy-sargasso-class only when 4872 the element scrolls into view 4873 4874 @author Michael Rhodes (except where noted) 4875 @license MIT 4876 Made in Barbados ð§ð§ Copyright © 2020 Michael Rhodes 4877 **/ 4878 4879 class LazyInstantiate extends Sargasso { 4880 constructor (element, options = {}) { 4881 options.watchScroll = true; 4882 options.watchResize = true; 4883 options.watchDOM = true; 4884 options.immortal = true; 4885 super(element, options); 4886 } 4887 4888 didResize () { 4889 super.didResize(); 4890 this.lazyHandler(); 4891 } 4892 4893 didScroll () { 4894 super.didScroll(); 4895 this.lazyHandler(); 4896 } 4897 4898 DOMChanged (root) { 4899 super.DOMChanged(root); 4900 this.lazyHandler(root); 4901 } 4902 4903 // watch viewport and instantiate lazy-instantiate-responsive things when visible 4904 lazyHandler (root = document) { 4905 const els = root.querySelectorAll('[data-lazy-sargasso-class]'); 4906 for (let i = 0; i < els.length; i++) { 4907 const element = els[i]; 4908 if (theScrollWatcher.inViewPort(element)) { 4909 const cls = element.getAttribute('data-lazy-sargasso-class').split(/\s*,\s*/); 4910 for (let j = 0; j < cls.length; j++) { 4911 const thing = new registeredClasses[cls[j]](els[i]); 4912 thing.start(); 4913 } 4914 element.removeAttribute('data-lazy-sargasso-class'); 4915 } 4916 } 4917 } 4918 } 4919 4920 registerSargassoClass('LazyInstantiate', LazyInstantiate); 4921 4922 /** 4923 SargassoSupervisor 4924 4925 Sargasso class which watches the document for new content and instantiates 4926 Sargasso classes liested in element's data-sargasso-class attribute. 4927 Once instantiated, Sargasso objects are trash collected when element is 4928 removed from the DOM 4929 4930 @author Michael Rhodes (except where noted) 4931 @license MIT 4932 Made in Barbados ð§ð§ Copyright © 2020 Michael Rhodes 4933 **/ 4934 4935 class SargassoSupervisor extends Sargasso { 4936 constructor (element, options = {}) { 4937 super(element, { 4938 watchDOM: true, 4939 mortal: false 4940 });
4941 this.lazy = new LazyInstantiate(element, options); 4942 } 4943 4944 start () { 4945 this.lazy.start(); 4946 super.start(); 4947 } 4948 4949 instantiate (element) { 4950 const cls = element.getAttribute('data-sargasso-class').split(/\s*,\s*/); 4951 for (let i = 0; i < cls.length; i++) { 4952 try { 4953 const thing = new registeredClasses[cls[i]](element); 4954 thing.start(); 4955 } catch (e) { 4956 console.log('error instantiating ' + cls[i], e, registeredClasses); 4957 } 4958 } 4959 4960 element.removeAttribute('data-sargasso-class'); 4961 } 4962 4963 newPage () { 4964 this.doIt(); 4965 } 4966 4967 DOMChanged (root) { 4968 this.doIt(root); 4969 } 4970 4971 doIt (root = document.body) { 4972 if (root.getAttribute('data-sargasso-class')) { 4973 this.instantiate(root); 4974 } 4975 4976 const elements = root.querySelectorAll('[data-sargasso-class]'); 4977 for (const element of elements) { 4978 this.instantiate(element); 4979 } 4980 4981 // check for dangling live elements and kill them 4982 const toCleanup = []; 4983 for (let i = 0; i < liveElements.length; i++) { 4984 if (!liveElements[i].options.immortal && !liveElements[i].options.isCustomElement && !document.body.contains(liveElements[i].element)) { 4985 toCleanup.push(liveElements[i]); 4986 } 4987 } 4988 for (let i = 0; i < toCleanup.length; i++) { 4989 toCleanup[i].destroy(); 4990 } 4991 } 4992 } 4993 4994 registerSargassoClass('SargassoSupervisor', SargassoSupervisor); 4995 4996 "use strict"; 4997 var __assign$1 = (commonjsGlobal && commonjsGlobal.__assign) || function () { 4998 __assign$1 = Object.assign || function(t) { 4999 for (var s, i = 1, n = arguments.length; i < n; i++) { 5000 s = arguments[i]; 5001 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 5002 t[p] = s[p]; 5003 } 5004 return t; 5005 }; 5006 return __assign$1.apply(this, arguments); 5007 }; 5008 5009 function stringifyAttribute(name, value) { 5010 if (!value) { 5011 return ''; 5012 } 5013 var stringified = '; ' + name; 5014 if (value === true) { 5015 return stringified; // boolean attributes shouldn't have a value 5016 } 5017 return stringified + '=' + value; 5018 } 5019 function stringifyAttributes(attributes) { 5020 if (typeof attributes.expires === 'number') { 5021 var expires = new Date(); 5022 expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5); 5023 attributes.expires = expires; 5024 } 5025 return stringifyAttribute('Expires', attributes.expires ? attributes.expires.toUTCString() : '') 5026 + stringifyAttribute('Domain', attributes.domain) 5027 + stringifyAttribute('Path', attributes.path) 5028 + stringifyAttribute('Secure', attributes.secure) 5029 + stringifyAttribute('SameSite', attributes.sameSite); 5030 } 5031 function encode(name, value, attributes) { 5032 return encodeURIComponent(name) 5033 .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent) // allowed special characters 5034 .replace(/\(/g, '%28').replace(/\)/g, '%29') // replace opening and closing parens 5035 + '=' + encodeURIComponent(value) 5036 // allowed special characters 5037 .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent) 5038 + stringifyAttributes(attributes); 5039 } 5040 var encode_1 = encode; 5041 function parse(cookieString) { 5042 var result = {}; 5043 var cookies = cookieString ? cookieString.split('; ') : []; 5044 var rdecode = /(%[\dA-F]{2})+/gi; 5045 for (var i = 0; i < cookies.length; i++) { 5046 var parts = cookies[i].split('='); 5047 var cookie = parts.slice(1).join('='); 5048 if (cookie.charAt(0) === '"') { 5049 cookie = cookie.slice(1, -1); 5050 } 5051 try { 5052 var name_1 = parts[0].replace(rdecode, decodeURIComponent); 5053 result[name_1] = cookie.replace(rdecode, decodeURIComponent); 5054 } 5055 catch (e) { 5056 // ignore cookies with invalid name/value encoding 5057 } 5058 } 5059 return result; 5060 } 5061 var parse_1 = parse; 5062 function getAll() { 5063 return parse(document.cookie); 5064 } 5065 var getAll_1 = getAll; 5066 function get(name) { 5067 return getAll()[name]; 5068 } 5069 var get_1 = get; 5070 function set(name, value, attributes) { 5071 document.cookie = encode(name, value, __assign$1({ path: '/' }, attributes)); 5072 } 5073 var set_1 = set; 5074 function remove(name, attributes) { 5075 set(name, '', __assign$1(__assign$1({}, attributes), { expires: -1 })); 5076 } 5077 var remove_1 = remove; 5078 5079 var esCookie = /*#__PURE__*/Object.defineProperty({ 5080 encode: encode_1, 5081 parse: parse_1, 5082 getAll: getAll_1, 5083 get: get_1, 5084 set: set_1, 5085 remove: remove_1 5086 }, '__esModule', {value: true}); 5087 5088 /** 5089 Breakpoints 5090 5091 Sargasso class that maintains css classes on the document body 5092 to be used in css rules for implementing visibility and 5093 responsive behavior 5094 5095 @author Michael Rhodes (except where noted) 5096 @license MIT 5097 Made in Barbados ð§ð§ Copyright © 2020 Michael Rhodes 5098 **/ 5099
5100 const materialBreakpoints = [{ 5101 className: 'screen-xs', 5102 maxWidth: 599 5103 }, { 5104 className: 'screen-sm', 5105 maxWidth: 1023 5106 }, { 5107 className: 'screen-md', 5108 maxWidth: 1439 5109 }, { 5110 className: 'screen-lg', 5111 maxWidth: 1999 5112 }, { 5113 className: 'screen-xl', 5114 maxWidth: undefined 5115 }]; 5116 5117 class Breakpoints extends Sargasso { 5118 constructor (element, options = {}) { 5119 options.watchResize = true; 5120 super(element, options); 5121 5122 if (options.widths) { 5123 this.options.widths = options.widths; 5124 } else { 5125 this.options.widths = materialBreakpoints; 5126 } 5127 5128 this.scale = undefined; 5129 this.disabled = false; 5130 this.forceScale = undefined; 5131 this.orientation = undefined; 5132 5133 this.widths = []; 5134 this.classes = []; 5135 } 5136 5137 start () { 5138 super.start(); 5139 let css = '.show-hide{display:none;}\n'; 5140 this.widths.push(0); 5141 for (let i = 0; i < this.options.widths.length; i++) { 5142 if (this.options.widths[i].maxWidth) { 5143 this.widths.push(this.options.widths[i].maxWidth); 5144 } 5145 this.classes.push(this.options.widths[i].className); 5146 5147 css += '.' + this.options.widths[i].className + ' .hidden-' + this.options.widths[i].className + '{display:none;}\n'; 5148 css += '.not-' + this.options.widths[i].className + ' .hidden-not-' + this.options.widths[i].className + '{display:none;}\n'; 5149 css += '.' + this.options.widths[i].className + ' .shown-' + this.options.widths[i].className + '{display:block;}\n'; 5150 css += '.not-' + this.options.widths[i].className + ' .shown-not-' + this.options.widths[i].className + '{display:block;}\n'; 5151 } 5152 5153 const style = document.createElement('style'); 5154 style.type = 'text/css'; 5155 style.innerHTML = css; 5156 document.getElementsByTagName('head')[0].appendChild(style); 5157 this.detectGeometry(); 5158 }; 5159 5160 didResize () { 5161 super.didResize(); 5162 this.detectGeometry(); 5163 } 5164 5165 disableResponsive (scale) { 5166 elementTools.addClass(document.body, 'disable-responsive'); 5167 this.disabled = true; 5168 this.forceScale = scale; 5169 this.detectGeometry(); 5170 } 5171 5172 enableResponsive () { 5173 elementTools.removeClass(document.body, 'disable-responsive'); 5174 this.disabled = false; 5175 this.forceScale = ''; 5176 this.detectGeometry(); 5177 } 5178 5179 detectGeometry () { 5180 let newScale = this.classes[this.widths.length - 1]; 5181 5182 if (this.disabled) { 5183 newScale = this.forceScale; 5184 } else { 5185 const ww = window.innerWidth; 5186 const wh = window.innerHeight; 5187 if (wh > ww) { 5188 if (this.orientation !== 'portrait') { 5189 const frame = () => { 5190 elementTools.removeClass(document.body, 'landscape'); 5191 elementTools.addClass(document.body, 'portrait'); 5192 }; 5193 this.queueFrame(frame); 5194 this.orientation = 'portrait'; 5195 } 5196 } else { 5197 if (this.orientation !== 'landscape') { 5198 const frame = () => { 5199 elementTools.removeClass(document.body, 'portrait'); 5200 elementTools.addClass(document.body, 'landscape'); 5201 }; 5202 this.queueFrame(frame); 5203 this.orientation = 'landscape'; 5204 } 5205 } 5206 for (let i = 0; i < this.widths.length - 1; i++) { 5207 if (ww >= this.widths[i] && ww < this.widths[i + 1]) { 5208 newScale = this.classes[i]; 5209 break 5210 } 5211 } 5212 } 5213 5214 let changed = 0; 5215 5216 if (newScale !== this.scale) { 5217 ++changed; 5218 const frame = () => { 5219 for (let i = 0; i < this.classes.length; i++) { 5220 if (this.classes[i] !== newScale) { 5221 elementTools.addClass(document.body, 'not-' + this.classes[i]); 5222 elementTools.removeClass(document.body, this.classes[i]); 5223 elementTools.removeClass(document.body, 'shown-' + this.classes[i]); 5224 elementTools.removeClass(document.body, 'hidden-' + this.classes[i]); 5225 } else { 5226 elementTools.removeClass(document.body, 'not-' + this.classes[i]); 5227 } 5228 } 5229 elementTools.addClass(document.body, newScale); 5230 elementTools.addClass(document.body, 'shown-' + newScale); 5231 elementTools.addClass(document.body, 'hidden-' + newScale); 5232 5233 this.notifyAll('didBreakpoint', [newScale]); 5234 }; 5235 this.queueFrame(frame); 5236 } 5237 5238 this.scale = newScale; 5239 5240 if (changed) { 5241 this.setHints(); 5242 } 5243 } 5244 5245 setHints () { 5246 let classes = ''; 5247 5248 if (this.scale) { 5249 if (classes) { 5250 classes += ' '; 5251 } 5252 classes += this.scale; 5253 } 5254 5255 if (classes !== this.getCookie('responsive')) { 5256 this.setCookie('responsive', classes); 5257 } 5258 }; 5259 5260 getCookie (key) { 5261 return esCookie.get(key) 5262 }; 5263 5264 setCookie (key, value, expires) { 5265 const options = { 5266 path: '/', 5267 domain: this.options.cookieDomain || null, 5268 expires: expires 5269 }; 5270 esCookie.set(key, value, options); 5271 }; 5272 5273 deleteCookie (key) { 5274 this.setCookie(key, null); 5275 }; 5276 }; 5277 5278 registerSargassoClass('Breakpoints', Breakpoints); 5279 5280 /** 5281 HijaxLoader 5282 5283 Sargasso class that captures links on the page and loads pages 5284 using AJAX only replacing elements on the page that are marked
5285 with data-hijax attributes. 5286 5287 @author Michael Rhodes (except where noted) 5288 @license MIT 5289 Made in Barbados ð§ð§ Copyright © 2020 Michael Rhodes 5290 **/ 5291 5292 class HijaxLoader extends Sargasso { 5293 constructor (element, options = {}) { 5294 options.watchDOM = true; 5295 options.immortal = true; 5296 super(element, options); 5297 this.excludeRegex = new RegExp('^(//|http|javascript|mailto|#)', 'i'); 5298 this.currentPage = location.pathname + location.search; 5299 this.cachedMarkup = {}; 5300 } 5301 5302 start () { 5303 // set up hijax markup cache 5304 const containers = document.querySelectorAll('[data-hijax-skip-unchanged]'); 5305 for (let i = 0; i < containers.length; i++) { 5306 const container = containers[i]; 5307 const id = container.getAttribute('id'); 5308 this.cachedMarkup[id] = container.innerHTML; 5309 } 5310 5311 super.start(); 5312 window.addEventListener('popstate', (e) => { 5313 this.watchPopState(e); 5314 }, false); 5315 } 5316 5317 DOMChanged (root) { 5318 super.DOMChanged(root); 5319 this.hijaxLinks(root); 5320 } 5321 5322 watchPopState (e) { 5323 if (location.pathname + location.search !== this.currentPage) { 5324 this.preFlight(location.pathname + location.search); 5325 } 5326 } 5327 5328 hijaxLinks (fragment) { 5329 const links = fragment ? fragment.getElementsByTagName('a') : this.element.getElementsByTagName('a'); 5330 for (let i = 0; i < links.length; i++) { 5331 const link = links[i]; 5332 const href = link.getAttribute('href'); 5333 if (href && 5334 !link.getAttribute('data-hijaxed') && 5335 !link.getAttribute('target') && 5336 !link.hasAttribute('data-no-hijax') && 5337 !this.excludeRegex.exec(href) 5338 ) { 5339 link.setAttribute('data-hijaxed', true); 5340 link.addEventListener('click', (e) => { 5341 e.preventDefault(); 5342 this.setPage(href); 5343 }, false); 5344 } 5345 } 5346 } 5347 5348 setPage (url, reload) { 5349 if (url === this.currentPage || reload) { 5350 this.preFlight(url); 5351 } else { 5352 history.pushState(null, null, url); 5353 this.watchPopState(); 5354 } 5355 } 5356 5357 preFlight (url) { 5358 if (!this.options.preFlight) { 5359 return this.loadPage(url) 5360 } 5361 5362 this.options.preFlight(url, (err, handled, rewrite) => { 5363 if (err) { 5364 if (this.options.onError) { 5365 this.options.onError('danger', err); 5366 } else { 5367 alert('Error loading page: ' + err); 5368 } 5369 } 5370 if (handled) { 5371 this.currentPage = location.pathname + location.search; 5372 } else { 5373 this.loadPage(rewrite || url); 5374 } 5375 }); 5376 } 5377 5378 loadPage (url) { 5379 const frame = () => { 5380 elementTools.addClass(document.body, 'hijax-loading'); 5381 }; 5382 this.queueFrame(frame); 5383 if (this.options.onExitPage) { 5384 this.options.onExitPage(); 5385 } 5386 const xhr = new XMLHttpRequest(); 5387 xhr.open('GET', url); 5388 xhr.setRequestHeader('Sargasso-Hijax', 1); 5389 xhr.setRequestHeader('x-digitopia-hijax', 1); 5390 if (this.options.onLoading) { 5391 this.options.onLoading(); 5392 xhr.onreadystatechange = this.options.onLoading; 5393 } 5394 xhr.onload = () => { 5395 if (xhr.status === 301 || xhr.status === 302 || xhr.getResponseHeader('Sargasso-Location')) { 5396 const loc = xhr.getResponseHeader('Location') ? xhr.getResponseHeader('Location') : xhr.getResponseHeader('Sargasso-Location'); 5397 this.setPage(loc); 5398 } else if (xhr.status === 200) { 5399 theScrollWatcher.scrollTop(0); 5400 this.mergePage(xhr.responseText); 5401 const oldPage = this.currentPage; 5402 const frame = () => { 5403 this.notifyAll('newPage', [oldPage, location.pathname + location.search]); 5404 elementTools.removeClass(document.body, 'hijax-loading'); 5405 }; 5406 this.queueFrame(frame); 5407 this.currentPage = location.pathname + location.search; 5408 } else { 5409 const flashLevel = xhr.getResponseHeader('Sargasso-Flash-Level') || 'danger'; 5410 let flashMessage = xhr.getResponseHeader('Sargasso-Flash-Message') || xhr.statusText; 5411 if (!flashMessage) { 5412 flashMessage = 'Could not connect to server.'; 5413 } 5414 if (this.options.onError) { 5415 this.options.onError(flashLevel, flashMessage); 5416 } else { 5417 alert('Error loading page: ' + flashMessage); 5418 } 5419 } 5420 }; 5421 xhr.send(); 5422 } 5423 5424 processScripts (scripts) {
5425 Array.from(scripts).forEach((script) => { 5426 script.remove(); 5427 const id = script.getAttribute('id'); 5428 if (!document.getElementById(id)) { 5429 // script.onload = function () {} 5430 document.getElementsByTagName('head')[0].appendChild(script); 5431 } 5432 }); 5433 } 5434 5435 mergePage (html) { 5436 const ephemerals = document.querySelectorAll('[data-ephemeral]'); 5437 Array.from(ephemerals).forEach((ephemeral) => { 5438 ephemeral.remove(); 5439 }); 5440 5441 const doc = html.split(/(<body[^>]*>|<\/body>)/ig); 5442 const fragment = makeFragment(doc[2]); 5443 const containers = document.querySelectorAll('[data-hijax]'); 5444 for (let i = 0; i < containers.length; i++) { 5445 const container = containers[i]; 5446 const id = container.getAttribute('id'); 5447 const replace = fragment.getElementById(id); 5448 5449 // compare raw markup for changes 5450 if (container.hasAttribute('data-hijax-skip-unchanged')) { 5451 if (this.cachedMarkup[id] === replace.innerHTML) { // unchanged 5452 continue 5453 } 5454 this.cachedMarkup[id] = replace.innerHTML; 5455 } 5456 5457 // use a key found in data-hijax-cache-key on a child element found by css selector defined in data-hijax-cache-key-selector 5458 const k = container.getAttribute('data-hijax-cache-key-selector'); 5459 if (k) { 5460 if (replace.querySelector(k) && container.querySelector(k) && container.querySelector(k).getAttribute('data-hijax-cache-key') === replace.querySelector(k).getAttribute('data-hijax-cache-key')) { 5461 continue 5462 } 5463 } 5464 5465 this.processScripts(replace.querySelectorAll('script')); 5466 const frame = () => { 5467 container.parentNode.replaceChild(replace, container); 5468 if (this.options.onEnterPage) { 5469 this.options.onEnterPage(); 5470 } 5471 this.hijaxLinks(replace); 5472 }; 5473 this.queueFrame(frame); 5474 } 5475 } 5476 } 5477 5478 registerSargassoClass('HijaxLoader', HijaxLoader); 5479 5480 // shims for borked browsers 5481 // ========================= 5482 5483 const makeFragment = (html) => { 5484 if (document.createRange && document.createRange().createContextualFragment) { 5485 return document.createRange().createContextualFragment(html) 5486 } 5487 const fragment = document.createDocumentFragment(); 5488 const div = document.createElement('div'); 5489 div.insertAdjacentHTML('afterBegin', html); 5490 fragment.appendChild(div); 5491 return fragment 5492 }; 5493 5494 let loadPageHandler; 5495 5496 const bootSargasso = (options = {}) => { 5497 if (options.scrollElement) { 5498 theScrollWatcher.setOptions(options); 5499 } 5500 if (options.breakpoints) { 5501 const breakpoints = new Breakpoints(document.body, options.breakpoints); 5502 breakpoints.start(); 5503 } 5504 if (options.hijax) { 5505 const hijax = new HijaxLoader(document.body, options.hijax); 5506 hijax.start(); 5507 loadPageHandler = hijax.setPage.bind(hijax); 5508 } else { 5509 loadPageHandler = (url) => { 5510 document.location.href = url; 5511 }; 5512 } 5513 5514 const supervisor = new SargassoSupervisor(document.body, options); 5515 supervisor.start(options); 5516 }; 5517 5518 /* 5519 Sargasso 5520 5521 Simple, Fast, Reactive, supervised Javascript controllers for html elements. 5522 5523 @author Michael Rhodes (except where noted) 5524 @license MIT 5525 Made in Barbados ð§ð§ Copyright © 2020 Michael Rhodes 5526 5527 */ 5528 5529 const utils$1 = { 5530 registerSargassoClass: registerSargassoClass, 5531 bootSargasso: bootSargasso, 5532 elementTools: elementTools 5533 }; 5534 5535 const services = { 5536 theDOMWatcher: theDOMWatcher, 5537 theScrollWatcher: theScrollWatcher, 5538 theResizeWatcher: theResizeWatcher, 5539 theOrientationWatcher: theOrientationWatcher, 5540 theWorkerWatcher: theWorkerWatcher, 5541 theObservableObjectWatcher: theObservableObjectWatcher 5542 }; 5543 5544 /*! 5545 * JavaScript Cookie v2.2.1 5546 * https://github.com/js-cookie/js-cookie 5547 * 5548 * Copyright 2006, 2015 Klaus Hartl & Fagner Brack 5549 * Released under the MIT license 5550 */ 5551 5552 var js_cookie = createCommonjsModule(function (module, exports) { 5553 ;(function (factory) { 5554 var registeredInModuleLoader; 5555 if (typeof undefined === 'function' && undefined.amd) { 5556 undefined(factory); 5557 registeredInModuleLoader = true; 5558 } 5559 if ('object' === 'object') { 5560 module.exports = factory(); 5561 registeredInModuleLoader = true; 5562 } 5563 if (!registeredInModuleLoader) { 5564 var OldCookies = window.Cookies; 5565 var api = window.Cookies = factory(); 5566 api.noConflict = function () { 5567 window.Cookies = OldCookies; 5568 return api; 5569 }; 5570 } 5571 }(function () { 5572 function extend () { 5573 var i = 0; 5574 var result = {}; 5575 for (; i < arguments.length; i++) { 5576 var attributes = arguments[ i ]; 5577 for (var key in attributes) { 5578 result[key] = attributes[key]; 5579 } 5580 } 5581 return result; 5582 } 5583 5584 function decode (s) { 5585 return s.replace(/(%[0-9A-Z]{2})+/g, decodeURIComponent); 5586 } 5587 5588 function init (converter) { 5589 function api() {} 5590
5591 function set (key, value, attributes) { 5592 if (typeof document === 'undefined') { 5593 return; 5594 } 5595 5596 attributes = extend({ 5597 path: '/' 5598 }, api.defaults, attributes); 5599 5600 if (typeof attributes.expires === 'number') { 5601 attributes.expires = new Date(new Date() * 1 + attributes.expires * 864e+5); 5602 } 5603 5604 // We're using "expires" because "max-age" is not supported by IE 5605 attributes.expires = attributes.expires ? attributes.expires.toUTCString() : ''; 5606 5607 try { 5608 var result = JSON.stringify(value); 5609 if (/^[\{\[]/.test(result)) { 5610 value = result; 5611 } 5612 } catch (e) {} 5613 5614 value = converter.write ? 5615 converter.write(value, key) : 5616 encodeURIComponent(String(value)) 5617 .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent); 5618 5619 key = encodeURIComponent(String(key)) 5620 .replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent) 5621 .replace(/[\(\)]/g, escape); 5622 5623 var stringifiedAttributes = ''; 5624 for (var attributeName in attributes) { 5625 if (!attributes[attributeName]) { 5626 continue; 5627 } 5628 stringifiedAttributes += '; ' + attributeName; 5629 if (attributes[attributeName] === true) { 5630 continue; 5631 } 5632 5633 // Considers RFC 6265 section 5.2: 5634 // ... 5635 // 3. If the remaining unparsed-attributes contains a %x3B (";") 5636 // character: 5637 // Consume the characters of the unparsed-attributes up to, 5638 // not including, the first %x3B (";") character. 5639 // ... 5640 stringifiedAttributes += '=' + attributes[attributeName].split(';')[0]; 5641 } 5642 5643 return (document.cookie = key + '=' + value + stringifiedAttributes); 5644 } 5645 5646 function get (key, json) { 5647 if (typeof document === 'undefined') { 5648 return; 5649 } 5650 5651 var jar = {}; 5652 // To prevent the for loop in the first place assign an empty array 5653 // in case there are no cookies at all. 5654 var cookies = document.cookie ? document.cookie.split('; ') : []; 5655 var i = 0; 5656 5657 for (; i < cookies.length; i++) { 5658 var parts = cookies[i].split('='); 5659 var cookie = parts.slice(1).join('='); 5660 5661 if (!json && cookie.charAt(0) === '"') { 5662 cookie = cookie.slice(1, -1); 5663 } 5664 5665 try { 5666 var name = decode(parts[0]); 5667 cookie = (converter.read || converter)(cookie, name) || 5668 decode(cookie); 5669 5670 if (json) { 5671 try { 5672 cookie = JSON.parse(cookie); 5673 } catch (e) {} 5674 } 5675 5676 jar[name] = cookie; 5677 5678 if (key === name) { 5679 break; 5680 } 5681 } catch (e) {} 5682 } 5683 5684 return key ? jar[key] : jar; 5685 } 5686 5687 api.set = set; 5688 api.get = function (key) { 5689 return get(key, false /* read as raw */); 5690 }; 5691 api.getJSON = function (key) { 5692 return get(key, true /* read as json */); 5693 }; 5694 api.remove = function (key, attributes) { 5695 set(key, '', extend(attributes, { 5696 expires: -1 5697 })); 5698 }; 5699 5700 api.defaults = {}; 5701 5702 api.withConverter = init; 5703 5704 return api; 5705 } 5706 5707 return init(function () {}); 5708 })); 5709 }); 5710 5711 /** 5712 * Stores result from supportsCssVariables to avoid redundant processing to 5713 * detect CSS custom variable support. 5714 */ 5715 var supportsCssVariables_; 5716 function supportsCssVariables(windowObj, forceRefresh) { 5717 if (forceRefresh === void 0) { forceRefresh = false; } 5718 var CSS = windowObj.CSS; 5719 var supportsCssVars = supportsCssVariables_; 5720 if (typeof supportsCssVariables_ === 'boolean' && !forceRefresh) { 5721 return supportsCssVariables_; 5722 } 5723 var supportsFunctionPresent = CSS && typeof CSS.supports === 'function'; 5724 if (!supportsFunctionPresent) { 5725 return false; 5726 } 5727 var explicitlySupportsCssVars = CSS.supports('--css-vars', 'yes'); 5728 // See: https://bugs.webkit.org/show_bug.cgi?id=154669 5729 // See: README section on Safari 5730 var weAreFeatureDetectingSafari10plus = (CSS.supports('(--css-vars: yes)') && 5731 CSS.supports('color', '#00000000')); 5732 supportsCssVars = 5733 explicitlySupportsCssVars || weAreFeatureDetectingSafari10plus; 5734 if (!forceRefresh) { 5735 supportsCssVariables_ = supportsCssVars; 5736 } 5737 return supportsCssVars; 5738 } 5739 function getNormalizedEventCoords(evt, pageOffset, clientRect) { 5740 if (!evt) { 5741 return { x: 0, y: 0 }; 5742 } 5743 var x = pageOffset.x, y = pageOffset.y; 5744 var documentX = x + clientRect.left; 5745 var documentY = y + clientRect.top; 5746 var normalizedX; 5747 var normalizedY; 5748 // Determine touch point relative to the ripple container. 5749 if (evt.type === 'touchstart') { 5750 var touchEvent = evt; 5751 normalizedX = touchEvent.changedTouches[0].pageX - documentX; 5752 normalizedY = touchEvent.changedTouches[0].pageY - documentY; 5753 } 5754 else { 5755 var mouseEvent = evt; 5756 normalizedX = mouseEvent.pageX - documentX; 5757 normalizedY = mouseEvent.pageY - documentY; 5758 } 5759 return { x: normalizedX, y: normalizedY }; 5760 } 5761 5762 /*! ***************************************************************************** 5763 Copyright (c) Microsoft Corporation. 5764 5765 Permission to use, copy, modify, and/or distribute this software for any 5766 purpose with or without fee is hereby granted. 5767 5768 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 5769 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 5770 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 5771 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 5772 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 5773 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 5774 PERFORMANCE OF THIS SOFTWARE. 5775 ***************************************************************************** */ 5776 /* global Reflect, Promise */ 5777 5778 var extendStatics = function(d, b) { 5779 extendStatics = Object.setPrototypeOf || 5780 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 5781 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 5782 return extendStatics(d, b); 5783 }; 5784 5785 function __extends(d, b) { 5786 extendStatics(d, b); 5787 function __() { this.constructor = d; } 5788 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 5789 } 5790 5791 var __assign = function() { 5792 __assign = Object.assign || function __assign(t) { 5793 for (var s, i = 1, n = arguments.length; i < n; i++) { 5794 s = arguments[i]; 5795 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 5796 } 5797 return t; 5798 }; 5799 return __assign.apply(this, arguments); 5800 }; 5801 5802 function __rest(s, e) { 5803 var t = {}; 5804 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 5805 t[p] = s[p]; 5806 if (s != null && typeof Object.getOwnPropertySymbols === "function") 5807 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 5808 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) 5809 t[p[i]] = s[p[i]]; 5810 } 5811 return t; 5812 } 5813 5814 function __decorate(decorators, target, key, desc) { 5815 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; 5816 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 5817 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c >
vendor: 6,099 bytes, lines 5817-5943
5817 3 ? d(target, key, r) : d(target, key)) || r; 5818 return c > 3 && r && Object.defineProperty(target, key, r), r; 5819 } 5820 5821 function __param(paramIndex, decorator) { 5822 return function (target, key) { decorator(target, key, paramIndex); } 5823 } 5824 5825 function __metadata(metadataKey, metadataValue) { 5826 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); 5827 } 5828 5829 function __awaiter(thisArg, _arguments, P, generator) { 5830 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 5831 return new (P || (P = Promise))(function (resolve, reject) { 5832 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 5833 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 5834 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 5835 step((generator = generator.apply(thisArg, _arguments || [])).next()); 5836 }); 5837 } 5838 5839 function __generator(thisArg, body) { 5840 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 5841 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 5842 function verb(n) { return function (v) { return step([n, v]); }; } 5843 function step(op) { 5844 if (f) throw new TypeError("Generator is already executing."); 5845 while (_) try { 5846 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) return t; 5847 if (y = 0, t) op = [op[0] & 2, t.value]; 5848 switch (op[0]) { 5849 case 0: case 1: t = op; break; 5850 case 4: _.label++; return { value: op[1], done: false }; 5851 case 5: _.label++; y = op[1]; op = [0]; continue; 5852 case 7: op = _.ops.pop(); _.trys.pop(); continue; 5853 default: 5854 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 5855 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 5856 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 5857 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 5858 if (t[2]) _.ops.pop(); 5859 _.trys.pop(); continue; 5860 } 5861 op = body.call(thisArg, _); 5862 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 5863 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 5864 } 5865 } 5866 5867 function __createBinding(o, m, k, k2) { 5868 if (k2 === undefined) k2 = k; 5869 o[k2] = m[k]; 5870 } 5871 5872 function __exportStar(m, exports) { 5873 for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p]; 5874 } 5875 5876 function __values(o) { 5877 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; 5878 if (m) return m.call(o); 5879 if (o && typeof o.length === "number") return { 5880 next: function () { 5881 if (o && i >= o.length) o = void 0; 5882 return { value: o && o[i++], done: !o }; 5883 } 5884 }; 5885 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); 5886 } 5887 5888 function __read(o, n) { 5889 var m = typeof Symbol === "function" && o[Symbol.iterator]; 5890 if (!m) return o; 5891 var i = m.call(o), r, ar = [], e; 5892 try { 5893 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 5894 } 5895 catch (error) { e = { error: error }; } 5896 finally { 5897 try { 5898 if (r && !r.done && (m = i["return"])) m.call(i); 5899 } 5900 finally { if (e) throw e.error; } 5901 } 5902 return ar; 5903 } 5904 5905 function __spread() { 5906 for (var ar = [], i = 0; i < arguments.length; i++) 5907 ar = ar.concat(__read(arguments[i])); 5908 return ar; 5909 } 5910 5911 function __spreadArrays() { 5912 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; 5913 for (var r = Array(s), k = 0, i = 0; i < il; i++) 5914 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) 5915 r[k] = a[j]; 5916 return r; 5917 }; 5918 5919 function __await(v) { 5920 return this instanceof __await ? (this.v = v, this) : new __await(v); 5921 } 5922 5923 function __asyncGenerator(thisArg, _arguments, generator) { 5924 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 5925 var g = generator.apply(thisArg, _arguments || []), i, q = []; 5926 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; 5927 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } 5928 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } 5929 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } 5930 function fulfill(value) { resume("next", value); } 5931 function reject(value) { resume("throw", value); } 5932 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } 5933 } 5934 5935 function __asyncDelegator(o) { 5936 var i, p; 5937 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; 5938 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; } 5939 } 5940 5941 function __asyncValues(o) { 5942 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); 5943 var m = o[Symbol.asyncIterator], i;
5944 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); 5945 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); }); }; } 5946 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } 5947 } 5948 5949 function __makeTemplateObject(cooked, raw) { 5950 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } 5951 return cooked; 5952 }; 5953 5954 function __importStar(mod) { 5955 if (mod && mod.__esModule) return mod; 5956 var result = {}; 5957 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; 5958 result.default = mod; 5959 return result; 5960 } 5961 5962 function __importDefault(mod) { 5963 return (mod && mod.__esModule) ? mod : { default: mod }; 5964 } 5965 5966 function __classPrivateFieldGet(receiver, privateMap) { 5967 if (!privateMap.has(receiver)) { 5968 throw new TypeError("attempted to get private field on non-instance"); 5969 } 5970 return privateMap.get(receiver); 5971 } 5972 5973 function __classPrivateFieldSet(receiver, privateMap, value) { 5974 if (!privateMap.has(receiver)) { 5975 throw new TypeError("attempted to set private field on non-instance"); 5976 } 5977 privateMap.set(receiver, value); 5978 return value; 5979 } 5980 5981 /** 5982 * @license 5983 * Copyright 2016 Google Inc. 5984 * 5985 * Permission is hereby granted, free of charge, to any person obtaining a copy 5986 * of this software and associated documentation files (the "Software"), to deal 5987 * in the Software without restriction, including without limitation the rights 5988 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 5989 * copies of the Software, and to permit persons to whom the Software is 5990 * furnished to do so, subject to the following conditions: 5991 * 5992 * The above copyright notice and this permission notice shall be included in 5993 * all copies or substantial portions of the Software. 5994 * 5995 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 5996 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 5997 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 5998 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 5999 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6000 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6001 * THE SOFTWARE. 6002 */ 6003 var MDCFoundation = /** @class */ (function () { 6004 function MDCFoundation(adapter) { 6005 if (adapter === void 0) { adapter = {}; } 6006 this.adapter = adapter; 6007 } 6008 Object.defineProperty(MDCFoundation, "cssClasses", { 6009 get: function () { 6010 // Classes extending MDCFoundation should implement this method to return an object which exports every 6011 // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'} 6012 return {}; 6013 }, 6014 enumerable: true, 6015 configurable: true 6016 }); 6017 Object.defineProperty(MDCFoundation, "strings", { 6018 get: function () { 6019 // Classes extending MDCFoundation should implement this method to return an object which exports all 6020 // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'} 6021 return {}; 6022 }, 6023 enumerable: true, 6024 configurable: true 6025 }); 6026 Object.defineProperty(MDCFoundation, "numbers", { 6027 get: function () { 6028 // Classes extending MDCFoundation should implement this method to return an object which exports all 6029 // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350} 6030 return {}; 6031 }, 6032 enumerable: true, 6033 configurable: true 6034 }); 6035 Object.defineProperty(MDCFoundation, "defaultAdapter", { 6036 get: function () { 6037 // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient 6038 // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter 6039 // validation. 6040 return {}; 6041 }, 6042 enumerable: true, 6043 configurable: true 6044 }); 6045 MDCFoundation.prototype.init = function () { 6046 // Subclasses should override this method to perform initialization routines (registering events, etc.) 6047 }; 6048 MDCFoundation.prototype.destroy = function () { 6049 // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.) 6050 };
6051 return MDCFoundation; 6052 }()); 6053 6054 /** 6055 * @license 6056 * Copyright 2016 Google Inc. 6057 * 6058 * Permission is hereby granted, free of charge, to any person obtaining a copy 6059 * of this software and associated documentation files (the "Software"), to deal 6060 * in the Software without restriction, including without limitation the rights 6061 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6062 * copies of the Software, and to permit persons to whom the Software is 6063 * furnished to do so, subject to the following conditions: 6064 * 6065 * The above copyright notice and this permission notice shall be included in 6066 * all copies or substantial portions of the Software. 6067 * 6068 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6069 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6070 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 6071 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 6072 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6073 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6074 * THE SOFTWARE. 6075 */ 6076 var MDCComponent = /** @class */ (function () { 6077 function MDCComponent(root, foundation) { 6078 var args = []; 6079 for (var _i = 2; _i < arguments.length; _i++) { 6080 args[_i - 2] = arguments[_i]; 6081 } 6082 this.root = root; 6083 this.initialize.apply(this, __spread(args)); 6084 // Note that we initialize foundation here and not within the constructor's default param so that 6085 // this.root_ is defined and can be used within the foundation class. 6086 this.foundation = 6087 foundation === undefined ? this.getDefaultFoundation() : foundation; 6088 this.foundation.init(); 6089 this.initialSyncWithDOM(); 6090 } 6091 MDCComponent.attachTo = function (root) { 6092 // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and 6093 // returns an instantiated component with its root set to that element. Also note that in the cases of 6094 // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized 6095 // from getDefaultFoundation(). 6096 return new MDCComponent(root, new MDCFoundation({})); 6097 }; 6098 /* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */ 6099 MDCComponent.prototype.initialize = function () { 6100 var _args = []; 6101 for (var _i = 0; _i < arguments.length; _i++) { 6102 _args[_i] = arguments[_i]; 6103 } 6104 // Subclasses can override this to do any additional setup work that would be considered part of a 6105 // "constructor". Essentially, it is a hook into the parent constructor before the foundation is 6106 // initialized. Any additional arguments besides root and foundation will be passed in here. 6107 }; 6108 MDCComponent.prototype.getDefaultFoundation = function () { 6109 // Subclasses must override this method to return a properly configured foundation class for the 6110 // component. 6111 throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 6112 'foundation class'); 6113 }; 6114 MDCComponent.prototype.initialSyncWithDOM = function () { 6115 // Subclasses should override this method if they need to perform work to synchronize with a host DOM 6116 // object. An example of this would be a form control wrapper that needs to synchronize its internal state 6117 // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM 6118 // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor. 6119 }; 6120 MDCComponent.prototype.destroy = function () { 6121 // Subclasses may implement this method to release any resources / deregister any listeners they have 6122 // attached. An example of this might be deregistering a resize event from the window object. 6123 this.foundation.destroy(); 6124 }; 6125 MDCComponent.prototype.listen = function (evtType, handler, options) { 6126 this.root.addEventListener(evtType, handler, options); 6127 }; 6128 MDCComponent.prototype.unlisten = function (evtType, handler, options) { 6129 this.root.removeEventListener(evtType, handler, options); 6130 }; 6131 /** 6132 * Fires a cross-browser-compatible custom event from the component root of the given type, with the given data. 6133 */ 6134 MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) { 6135 if (shouldBubble === void 0) { shouldBubble = false; } 6136 var evt; 6137 if (typeof CustomEvent === 'function') { 6138 evt = new CustomEvent(evtType, { 6139 bubbles: shouldBubble, 6140 detail: evtData, 6141 }); 6142 } 6143 else { 6144 evt = document.createEvent('CustomEvent'); 6145 evt.initCustomEvent(evtType, shouldBubble, false, evtData); 6146 } 6147 this.root.dispatchEvent(evt); 6148 }; 6149 return MDCComponent; 6150 }()); 6151 6152 /** 6153 * @license 6154 * Copyright 2019 Google Inc. 6155 * 6156 * Permission is hereby granted, free of charge, to any person obtaining a copy 6157 * of this software and associated documentation files (the "Software"), to deal 6158 * in the Software without restriction, including without limitation the rights 6159 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6160 * copies of the Software, and to permit persons to whom the Software is 6161 * furnished to do so, subject to the following conditions: 6162 * 6163 * The above copyright notice and this permission notice shall be included in 6164 * all copies or substantial portions of the Software. 6165 * 6166 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6167 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6168 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 6169 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 6170 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6171 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6172 * THE SOFTWARE. 6173 */ 6174 /** 6175 * Determine whether the current browser supports passive event listeners, and 6176 * if so, use them. 6177 */ 6178 function applyPassive(globalObj) { 6179 if (globalObj === void 0) { globalObj = window; } 6180 return supportsPassiveOption(globalObj) ? 6181 { passive: true } : 6182 false; 6183 } 6184 function supportsPassiveOption(globalObj) { 6185 if (globalObj === void 0) { globalObj = window; } 6186 // See 6187 // https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener 6188 var passiveSupported = false;
6189 try { 6190 var options = { 6191 // This function will be called when the browser 6192 // attempts to access the passive property. 6193 get passive() { 6194 passiveSupported = true; 6195 return false; 6196 } 6197 }; 6198 var handler = function () { }; 6199 globalObj.document.addEventListener('test', handler, options); 6200 globalObj.document.removeEventListener('test', handler, options); 6201 } 6202 catch (err) { 6203 passiveSupported = false; 6204 } 6205 return passiveSupported; 6206 } 6207 6208 /** 6209 * @license 6210 * Copyright 2018 Google Inc. 6211 * 6212 * Permission is hereby granted, free of charge, to any person obtaining a copy 6213 * of this software and associated documentation files (the "Software"), to deal 6214 * in the Software without restriction, including without limitation the rights 6215 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6216 * copies of the Software, and to permit persons to whom the Software is 6217 * furnished to do so, subject to the following conditions: 6218 * 6219 * The above copyright notice and this permission notice shall be included in 6220 * all copies or substantial portions of the Software. 6221 * 6222 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6223 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6224 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 6225 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 6226 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6227 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6228 * THE SOFTWARE. 6229 */ 6230 /** 6231 * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain. 6232 * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC. 6233 */ 6234 function closest(element, selector) { 6235 if (element.closest) { 6236 return element.closest(selector); 6237 } 6238 var el = element; 6239 while (el) { 6240 if (matches$1(el, selector)) { 6241 return el; 6242 } 6243 el = el.parentElement; 6244 } 6245 return null; 6246 } 6247 function matches$1(element, selector) { 6248 var nativeMatches = element.matches 6249 || element.webkitMatchesSelector 6250 || element.msMatchesSelector; 6251 return nativeMatches.call(element, selector); 6252 } 6253 /** 6254 * Used to compute the estimated scroll width of elements. When an element is 6255 * hidden due to display: none; being applied to a parent element, the width is 6256 * returned as 0. However, the element will have a true width once no longer 6257 * inside a display: none context. This method computes an estimated width when 6258 * the element is hidden or returns the true width when the element is visble. 6259 * @param {Element} element the element whose width to estimate 6260 */ 6261 function estimateScrollWidth(element) { 6262 // Check the offsetParent. If the element inherits display: none from any 6263 // parent, the offsetParent property will be null (see 6264 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent). 6265 // This check ensures we only clone the node when necessary. 6266 var htmlEl = element; 6267 if (htmlEl.offsetParent !== null) { 6268 return htmlEl.scrollWidth; 6269 } 6270 var clone = htmlEl.cloneNode(true); 6271 clone.style.setProperty('position', 'absolute'); 6272 clone.style.setProperty('transform', 'translate(-9999px, -9999px)'); 6273 document.documentElement.appendChild(clone); 6274 var scrollWidth = clone.scrollWidth; 6275 document.documentElement.removeChild(clone); 6276 return scrollWidth; 6277 } 6278 6279 /** 6280 * @license 6281 * Copyright 2016 Google Inc. 6282 * 6283 * Permission is hereby granted, free of charge, to any person obtaining a copy 6284 * of this software and associated documentation files (the "Software"), to deal 6285 * in the Software without restriction, including without limitation the rights 6286 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6287 * copies of the Software, and to permit persons to whom the Software is 6288 * furnished to do so, subject to the following conditions: 6289 * 6290 * The above copyright notice and this permission notice shall be included in 6291 * all copies or substantial portions of the Software. 6292 * 6293 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6294 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6295 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 6296 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 6297 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6298 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6299 * THE SOFTWARE. 6300 */
vendor: 6,167 bytes, lines 6301-6433
6301 var cssClasses$q = { 6302 // Ripple is a special case where the "root" component is really a "mixin" of sorts, 6303 // given that it's an 'upgrade' to an existing component. That being said it is the root 6304 // CSS class that all other CSS classes derive from. 6305 BG_FOCUSED: 'mdc-ripple-upgraded--background-focused', 6306 FG_ACTIVATION: 'mdc-ripple-upgraded--foreground-activation', 6307 FG_DEACTIVATION: 'mdc-ripple-upgraded--foreground-deactivation', 6308 ROOT: 'mdc-ripple-upgraded', 6309 UNBOUNDED: 'mdc-ripple-upgraded--unbounded', 6310 }; 6311 var strings$t = { 6312 VAR_FG_SCALE: '--mdc-ripple-fg-scale', 6313 VAR_FG_SIZE: '--mdc-ripple-fg-size', 6314 VAR_FG_TRANSLATE_END: '--mdc-ripple-fg-translate-end', 6315 VAR_FG_TRANSLATE_START: '--mdc-ripple-fg-translate-start', 6316 VAR_LEFT: '--mdc-ripple-left', 6317 VAR_TOP: '--mdc-ripple-top', 6318 }; 6319 var numbers$b = { 6320 DEACTIVATION_TIMEOUT_MS: 225, 6321 FG_DEACTIVATION_MS: 150, 6322 INITIAL_ORIGIN_SCALE: 0.6, 6323 PADDING: 10, 6324 TAP_DELAY_MS: 300, 6325 }; 6326 6327 /** 6328 * @license 6329 * Copyright 2016 Google Inc. 6330 * 6331 * Permission is hereby granted, free of charge, to any person obtaining a copy 6332 * of this software and associated documentation files (the "Software"), to deal 6333 * in the Software without restriction, including without limitation the rights 6334 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6335 * copies of the Software, and to permit persons to whom the Software is 6336 * furnished to do so, subject to the following conditions: 6337 * 6338 * The above copyright notice and this permission notice shall be included in 6339 * all copies or substantial portions of the Software. 6340 * 6341 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6342 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6343 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 6344 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 6345 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6346 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6347 * THE SOFTWARE. 6348 */ 6349 // Activation events registered on the root element of each instance for activation 6350 var ACTIVATION_EVENT_TYPES = [ 6351 'touchstart', 'pointerdown', 'mousedown', 'keydown', 6352 ]; 6353 // Deactivation events registered on documentElement when a pointer-related down event occurs 6354 var POINTER_DEACTIVATION_EVENT_TYPES = [ 6355 'touchend', 'pointerup', 'mouseup', 'contextmenu', 6356 ]; 6357 // simultaneous nested activations 6358 var activatedTargets = []; 6359 var MDCRippleFoundation = /** @class */ (function (_super) { 6360 __extends(MDCRippleFoundation, _super); 6361 function MDCRippleFoundation(adapter) { 6362 var _this = _super.call(this, __assign(__assign({}, MDCRippleFoundation.defaultAdapter), adapter)) || this; 6363 _this.activationAnimationHasEnded_ = false; 6364 _this.activationTimer_ = 0; 6365 _this.fgDeactivationRemovalTimer_ = 0; 6366 _this.fgScale_ = '0'; 6367 _this.frame_ = { width: 0, height: 0 }; 6368 _this.initialSize_ = 0; 6369 _this.layoutFrame_ = 0; 6370 _this.maxRadius_ = 0; 6371 _this.unboundedCoords_ = { left: 0, top: 0 }; 6372 _this.activationState_ = _this.defaultActivationState_(); 6373 _this.activationTimerCallback_ = function () { 6374 _this.activationAnimationHasEnded_ = true; 6375 _this.runDeactivationUXLogicIfReady_(); 6376 }; 6377 _this.activateHandler_ = function (e) { return _this.activate_(e); }; 6378 _this.deactivateHandler_ = function () { return _this.deactivate_(); }; 6379 _this.focusHandler_ = function () { return _this.handleFocus(); }; 6380 _this.blurHandler_ = function () { return _this.handleBlur(); }; 6381 _this.resizeHandler_ = function () { return _this.layout(); }; 6382 return _this; 6383 } 6384 Object.defineProperty(MDCRippleFoundation, "cssClasses", { 6385 get: function () { 6386 return cssClasses$q; 6387 }, 6388 enumerable: true, 6389 configurable: true 6390 }); 6391 Object.defineProperty(MDCRippleFoundation, "strings", { 6392 get: function () { 6393 return strings$t; 6394 }, 6395 enumerable: true, 6396 configurable: true 6397 }); 6398 Object.defineProperty(MDCRippleFoundation, "numbers", { 6399 get: function () { 6400 return numbers$b; 6401 }, 6402 enumerable: true, 6403 configurable: true 6404 }); 6405 Object.defineProperty(MDCRippleFoundation, "defaultAdapter", { 6406 get: function () { 6407 return { 6408 addClass: function () { return undefined; }, 6409 browserSupportsCssVars: function () { return true; }, 6410 computeBoundingRect: function () { return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 }); }, 6411 containsEventTarget: function () { return true; }, 6412 deregisterDocumentInteractionHandler: function () { return undefined; }, 6413 deregisterInteractionHandler: function () { return undefined; }, 6414 deregisterResizeHandler: function () { return undefined; }, 6415 getWindowPageOffset: function () { return ({ x: 0, y: 0 }); }, 6416 isSurfaceActive: function () { return true; }, 6417 isSurfaceDisabled: function () { return true; }, 6418 isUnbounded: function () { return true; }, 6419 registerDocumentInteractionHandler: function () { return undefined; }, 6420 registerInteractionHandler: function () { return undefined; }, 6421 registerResizeHandler: function () { return undefined; }, 6422 removeClass: function () { return undefined; }, 6423 updateCssVariable: function () { return undefined; }, 6424 }; 6425 }, 6426 enumerable: true, 6427 configurable: true 6428 }); 6429 MDCRippleFoundation.prototype.init = function () { 6430 var _this = this; 6431 var supportsPressRipple = this.supportsPressRipple_(); 6432 this.registerRootHandlers_(supportsPressRipple); 6433 if (supportsPressRipple) {
vendor: 6,109 bytes, lines 6434-6569
6434 var _a = MDCRippleFoundation.cssClasses, ROOT_1 = _a.ROOT, UNBOUNDED_1 = _a.UNBOUNDED; 6435 requestAnimationFrame(function () { 6436 _this.adapter.addClass(ROOT_1); 6437 if (_this.adapter.isUnbounded()) { 6438 _this.adapter.addClass(UNBOUNDED_1); 6439 // Unbounded ripples need layout logic applied immediately to set coordinates for both shade and ripple 6440 _this.layoutInternal_(); 6441 } 6442 }); 6443 } 6444 }; 6445 MDCRippleFoundation.prototype.destroy = function () { 6446 var _this = this; 6447 if (this.supportsPressRipple_()) { 6448 if (this.activationTimer_) { 6449 clearTimeout(this.activationTimer_); 6450 this.activationTimer_ = 0; 6451 this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_ACTIVATION); 6452 } 6453 if (this.fgDeactivationRemovalTimer_) { 6454 clearTimeout(this.fgDeactivationRemovalTimer_); 6455 this.fgDeactivationRemovalTimer_ = 0; 6456 this.adapter.removeClass(MDCRippleFoundation.cssClasses.FG_DEACTIVATION); 6457 } 6458 var _a = MDCRippleFoundation.cssClasses, ROOT_2 = _a.ROOT, UNBOUNDED_2 = _a.UNBOUNDED; 6459 requestAnimationFrame(function () { 6460 _this.adapter.removeClass(ROOT_2); 6461 _this.adapter.removeClass(UNBOUNDED_2); 6462 _this.removeCssVars_(); 6463 }); 6464 } 6465 this.deregisterRootHandlers_(); 6466 this.deregisterDeactivationHandlers_(); 6467 }; 6468 /** 6469 * @param evt Optional event containing position information. 6470 */ 6471 MDCRippleFoundation.prototype.activate = function (evt) { 6472 this.activate_(evt); 6473 }; 6474 MDCRippleFoundation.prototype.deactivate = function () { 6475 this.deactivate_(); 6476 }; 6477 MDCRippleFoundation.prototype.layout = function () { 6478 var _this = this; 6479 if (this.layoutFrame_) { 6480 cancelAnimationFrame(this.layoutFrame_); 6481 } 6482 this.layoutFrame_ = requestAnimationFrame(function () { 6483 _this.layoutInternal_(); 6484 _this.layoutFrame_ = 0; 6485 }); 6486 }; 6487 MDCRippleFoundation.prototype.setUnbounded = function (unbounded) { 6488 var UNBOUNDED = MDCRippleFoundation.cssClasses.UNBOUNDED; 6489 if (unbounded) { 6490 this.adapter.addClass(UNBOUNDED); 6491 } 6492 else { 6493 this.adapter.removeClass(UNBOUNDED); 6494 } 6495 }; 6496 MDCRippleFoundation.prototype.handleFocus = function () { 6497 var _this = this; 6498 requestAnimationFrame(function () { return _this.adapter.addClass(MDCRippleFoundation.cssClasses.BG_FOCUSED); }); 6499 }; 6500 MDCRippleFoundation.prototype.handleBlur = function () { 6501 var _this = this; 6502 requestAnimationFrame(function () { return _this.adapter.removeClass(MDCRippleFoundation.cssClasses.BG_FOCUSED); }); 6503 }; 6504 /** 6505 * We compute this property so that we are not querying information about the client 6506 * until the point in time where the foundation requests it. This prevents scenarios where 6507 * client-side feature-detection may happen too early, such as when components are rendered on the server 6508 * and then initialized at mount time on the client. 6509 */ 6510 MDCRippleFoundation.prototype.supportsPressRipple_ = function () { 6511 return this.adapter.browserSupportsCssVars(); 6512 }; 6513 MDCRippleFoundation.prototype.defaultActivationState_ = function () { 6514 return { 6515 activationEvent: undefined, 6516 hasDeactivationUXRun: false, 6517 isActivated: false, 6518 isProgrammatic: false, 6519 wasActivatedByPointer: false, 6520 wasElementMadeActive: false, 6521 }; 6522 }; 6523 /** 6524 * supportsPressRipple Passed from init to save a redundant function call 6525 */ 6526 MDCRippleFoundation.prototype.registerRootHandlers_ = function (supportsPressRipple) { 6527 var _this = this; 6528 if (supportsPressRipple) { 6529 ACTIVATION_EVENT_TYPES.forEach(function (evtType) { 6530 _this.adapter.registerInteractionHandler(evtType, _this.activateHandler_); 6531 }); 6532 if (this.adapter.isUnbounded()) { 6533 this.adapter.registerResizeHandler(this.resizeHandler_); 6534 } 6535 } 6536 this.adapter.registerInteractionHandler('focus', this.focusHandler_); 6537 this.adapter.registerInteractionHandler('blur', this.blurHandler_); 6538 }; 6539 MDCRippleFoundation.prototype.registerDeactivationHandlers_ = function (evt) { 6540 var _this = this; 6541 if (evt.type === 'keydown') { 6542 this.adapter.registerInteractionHandler('keyup', this.deactivateHandler_); 6543 } 6544 else { 6545 POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) { 6546 _this.adapter.registerDocumentInteractionHandler(evtType, _this.deactivateHandler_); 6547 }); 6548 } 6549 }; 6550 MDCRippleFoundation.prototype.deregisterRootHandlers_ = function () { 6551 var _this = this; 6552 ACTIVATION_EVENT_TYPES.forEach(function (evtType) { 6553 _this.adapter.deregisterInteractionHandler(evtType, _this.activateHandler_); 6554 }); 6555 this.adapter.deregisterInteractionHandler('focus', this.focusHandler_); 6556 this.adapter.deregisterInteractionHandler('blur', this.blurHandler_); 6557 if (this.adapter.isUnbounded()) { 6558 this.adapter.deregisterResizeHandler(this.resizeHandler_); 6559 } 6560 }; 6561 MDCRippleFoundation.prototype.deregisterDeactivationHandlers_ = function () { 6562 var _this = this; 6563 this.adapter.deregisterInteractionHandler('keyup', this.deactivateHandler_); 6564 POINTER_DEACTIVATION_EVENT_TYPES.forEach(function (evtType) { 6565 _this.adapter.deregisterDocumentInteractionHandler(evtType, _this.deactivateHandler_); 6566 }); 6567 }; 6568 MDCRippleFoundation.prototype.removeCssVars_ = function () { 6569 var _this = this;
vendor: 5,107 bytes, lines 6570-6661
6570 var rippleStrings = MDCRippleFoundation.strings; 6571 var keys = Object.keys(rippleStrings); 6572 keys.forEach(function (key) { 6573 if (key.indexOf('VAR_') === 0) { 6574 _this.adapter.updateCssVariable(rippleStrings[key], null); 6575 } 6576 }); 6577 }; 6578 MDCRippleFoundation.prototype.activate_ = function (evt) { 6579 var _this = this; 6580 if (this.adapter.isSurfaceDisabled()) { 6581 return; 6582 } 6583 var activationState = this.activationState_; 6584 if (activationState.isActivated) { 6585 return; 6586 } 6587 // Avoid reacting to follow-on events fired by touch device after an already-processed user interaction 6588 var previousActivationEvent = this.previousActivationEvent_; 6589 var isSameInteraction = previousActivationEvent && evt !== undefined && previousActivationEvent.type !== evt.type; 6590 if (isSameInteraction) { 6591 return; 6592 } 6593 activationState.isActivated = true; 6594 activationState.isProgrammatic = evt === undefined; 6595 activationState.activationEvent = evt; 6596 activationState.wasActivatedByPointer = activationState.isProgrammatic ? false : evt !== undefined && (evt.type === 'mousedown' || evt.type === 'touchstart' || evt.type === 'pointerdown'); 6597 var hasActivatedChild = evt !== undefined && 6598 activatedTargets.length > 0 && 6599 activatedTargets.some(function (target) { return _this.adapter.containsEventTarget(target); }); 6600 if (hasActivatedChild) { 6601 // Immediately reset activation state, while preserving logic that prevents touch follow-on events 6602 this.resetActivationState_(); 6603 return; 6604 } 6605 if (evt !== undefined) { 6606 activatedTargets.push(evt.target); 6607 this.registerDeactivationHandlers_(evt); 6608 } 6609 activationState.wasElementMadeActive = this.checkElementMadeActive_(evt); 6610 if (activationState.wasElementMadeActive) { 6611 this.animateActivation_(); 6612 } 6613 requestAnimationFrame(function () { 6614 // Reset array on next frame after the current event has had a chance to bubble to prevent ancestor ripples 6615 activatedTargets = []; 6616 if (!activationState.wasElementMadeActive 6617 && evt !== undefined 6618 && (evt.key === ' ' || evt.keyCode === 32)) { 6619 // If space was pressed, try again within an rAF call to detect :active, because different UAs report 6620 // active states inconsistently when they're called within event handling code: 6621 // - https://bugs.chromium.org/p/chromium/issues/detail?id=635971 6622 // - https://bugzilla.mozilla.org/show_bug.cgi?id=1293741 6623 // We try first outside rAF to support Edge, which does not exhibit this problem, but will crash if a CSS 6624 // variable is set within a rAF callback for a submit button interaction (#2241). 6625 activationState.wasElementMadeActive = _this.checkElementMadeActive_(evt); 6626 if (activationState.wasElementMadeActive) { 6627 _this.animateActivation_(); 6628 } 6629 } 6630 if (!activationState.wasElementMadeActive) { 6631 // Reset activation state immediately if element was not made active. 6632 _this.activationState_ = _this.defaultActivationState_(); 6633 } 6634 }); 6635 }; 6636 MDCRippleFoundation.prototype.checkElementMadeActive_ = function (evt) { 6637 return (evt !== undefined && evt.type === 'keydown') ? 6638 this.adapter.isSurfaceActive() : 6639 true; 6640 }; 6641 MDCRippleFoundation.prototype.animateActivation_ = function () { 6642 var _this = this; 6643 var _a = MDCRippleFoundation.strings, VAR_FG_TRANSLATE_START = _a.VAR_FG_TRANSLATE_START, VAR_FG_TRANSLATE_END = _a.VAR_FG_TRANSLATE_END; 6644 var _b = MDCRippleFoundation.cssClasses, FG_DEACTIVATION = _b.FG_DEACTIVATION, FG_ACTIVATION = _b.FG_ACTIVATION; 6645 var DEACTIVATION_TIMEOUT_MS = MDCRippleFoundation.numbers.DEACTIVATION_TIMEOUT_MS; 6646 this.layoutInternal_(); 6647 var translateStart = ''; 6648 var translateEnd = ''; 6649 if (!this.adapter.isUnbounded()) { 6650 var _c = this.getFgTranslationCoordinates_(), startPoint = _c.startPoint, endPoint = _c.endPoint; 6651 translateStart = startPoint.x + "px, " + startPoint.y + "px"; 6652 translateEnd = endPoint.x + "px, " + endPoint.y + "px"; 6653 } 6654 this.adapter.updateCssVariable(VAR_FG_TRANSLATE_START, translateStart); 6655 this.adapter.updateCssVariable(VAR_FG_TRANSLATE_END, translateEnd); 6656 // Cancel any ongoing activation/deactivation animations 6657 clearTimeout(this.activationTimer_); 6658 clearTimeout(this.fgDeactivationRemovalTimer_); 6659 this.rmBoundedActivationClasses_(); 6660 this.adapter.removeClass(FG_DEACTIVATION); 6661 // Force layout in order to re-trigger the animation.
vendor: 4,417 bytes, lines 6662-6746
6662 this.adapter.computeBoundingRect(); 6663 this.adapter.addClass(FG_ACTIVATION); 6664 this.activationTimer_ = setTimeout(function () { return _this.activationTimerCallback_(); }, DEACTIVATION_TIMEOUT_MS); 6665 }; 6666 MDCRippleFoundation.prototype.getFgTranslationCoordinates_ = function () { 6667 var _a = this.activationState_, activationEvent = _a.activationEvent, wasActivatedByPointer = _a.wasActivatedByPointer; 6668 var startPoint; 6669 if (wasActivatedByPointer) { 6670 startPoint = getNormalizedEventCoords(activationEvent, this.adapter.getWindowPageOffset(), this.adapter.computeBoundingRect()); 6671 } 6672 else { 6673 startPoint = { 6674 x: this.frame_.width / 2, 6675 y: this.frame_.height / 2, 6676 }; 6677 } 6678 // Center the element around the start point. 6679 startPoint = { 6680 x: startPoint.x - (this.initialSize_ / 2), 6681 y: startPoint.y - (this.initialSize_ / 2), 6682 }; 6683 var endPoint = { 6684 x: (this.frame_.width / 2) - (this.initialSize_ / 2), 6685 y: (this.frame_.height / 2) - (this.initialSize_ / 2), 6686 }; 6687 return { startPoint: startPoint, endPoint: endPoint }; 6688 }; 6689 MDCRippleFoundation.prototype.runDeactivationUXLogicIfReady_ = function () { 6690 var _this = this; 6691 // This method is called both when a pointing device is released, and when the activation animation ends. 6692 // The deactivation animation should only run after both of those occur. 6693 var FG_DEACTIVATION = MDCRippleFoundation.cssClasses.FG_DEACTIVATION; 6694 var _a = this.activationState_, hasDeactivationUXRun = _a.hasDeactivationUXRun, isActivated = _a.isActivated; 6695 var activationHasEnded = hasDeactivationUXRun || !isActivated; 6696 if (activationHasEnded && this.activationAnimationHasEnded_) { 6697 this.rmBoundedActivationClasses_(); 6698 this.adapter.addClass(FG_DEACTIVATION); 6699 this.fgDeactivationRemovalTimer_ = setTimeout(function () { 6700 _this.adapter.removeClass(FG_DEACTIVATION); 6701 }, numbers$b.FG_DEACTIVATION_MS); 6702 } 6703 }; 6704 MDCRippleFoundation.prototype.rmBoundedActivationClasses_ = function () { 6705 var FG_ACTIVATION = MDCRippleFoundation.cssClasses.FG_ACTIVATION; 6706 this.adapter.removeClass(FG_ACTIVATION); 6707 this.activationAnimationHasEnded_ = false; 6708 this.adapter.computeBoundingRect(); 6709 }; 6710 MDCRippleFoundation.prototype.resetActivationState_ = function () { 6711 var _this = this; 6712 this.previousActivationEvent_ = this.activationState_.activationEvent; 6713 this.activationState_ = this.defaultActivationState_(); 6714 // Touch devices may fire additional events for the same interaction within a short time. 6715 // Store the previous event until it's safe to assume that subsequent events are for new interactions. 6716 setTimeout(function () { return _this.previousActivationEvent_ = undefined; }, MDCRippleFoundation.numbers.TAP_DELAY_MS); 6717 }; 6718 MDCRippleFoundation.prototype.deactivate_ = function () { 6719 var _this = this; 6720 var activationState = this.activationState_; 6721 // This can happen in scenarios such as when you have a keyup event that blurs the element. 6722 if (!activationState.isActivated) { 6723 return; 6724 } 6725 var state = __assign({}, activationState); 6726 if (activationState.isProgrammatic) { 6727 requestAnimationFrame(function () { return _this.animateDeactivation_(state); }); 6728 this.resetActivationState_(); 6729 } 6730 else { 6731 this.deregisterDeactivationHandlers_(); 6732 requestAnimationFrame(function () { 6733 _this.activationState_.hasDeactivationUXRun = true; 6734 _this.animateDeactivation_(state); 6735 _this.resetActivationState_(); 6736 }); 6737 } 6738 }; 6739 MDCRippleFoundation.prototype.animateDeactivation_ = function (_a) { 6740 var wasActivatedByPointer = _a.wasActivatedByPointer, wasElementMadeActive = _a.wasElementMadeActive; 6741 if (wasActivatedByPointer || wasElementMadeActive) { 6742 this.runDeactivationUXLogicIfReady_(); 6743 } 6744 }; 6745 MDCRippleFoundation.prototype.layoutInternal_ = function () { 6746 var _this = this;
vendor: 5,416 bytes, lines 6747-6842
6747 this.frame_ = this.adapter.computeBoundingRect(); 6748 var maxDim = Math.max(this.frame_.height, this.frame_.width); 6749 // Surface diameter is treated differently for unbounded vs. bounded ripples. 6750 // Unbounded ripple diameter is calculated smaller since the surface is expected to already be padded appropriately 6751 // to extend the hitbox, and the ripple is expected to meet the edges of the padded hitbox (which is typically 6752 // square). Bounded ripples, on the other hand, are fully expected to expand beyond the surface's longest diameter 6753 // (calculated based on the diagonal plus a constant padding), and are clipped at the surface's border via 6754 // `overflow: hidden`. 6755 var getBoundedRadius = function () { 6756 var hypotenuse = Math.sqrt(Math.pow(_this.frame_.width, 2) + Math.pow(_this.frame_.height, 2)); 6757 return hypotenuse + MDCRippleFoundation.numbers.PADDING; 6758 }; 6759 this.maxRadius_ = this.adapter.isUnbounded() ? maxDim : getBoundedRadius(); 6760 // Ripple is sized as a fraction of the largest dimension of the surface, then scales up using a CSS scale transform 6761 var initialSize = Math.floor(maxDim * MDCRippleFoundation.numbers.INITIAL_ORIGIN_SCALE); 6762 // Unbounded ripple size should always be even number to equally center align. 6763 if (this.adapter.isUnbounded() && initialSize % 2 !== 0) { 6764 this.initialSize_ = initialSize - 1; 6765 } 6766 else { 6767 this.initialSize_ = initialSize; 6768 } 6769 this.fgScale_ = "" + this.maxRadius_ / this.initialSize_; 6770 this.updateLayoutCssVars_(); 6771 }; 6772 MDCRippleFoundation.prototype.updateLayoutCssVars_ = function () { 6773 var _a = MDCRippleFoundation.strings, VAR_FG_SIZE = _a.VAR_FG_SIZE, VAR_LEFT = _a.VAR_LEFT, VAR_TOP = _a.VAR_TOP, VAR_FG_SCALE = _a.VAR_FG_SCALE; 6774 this.adapter.updateCssVariable(VAR_FG_SIZE, this.initialSize_ + "px"); 6775 this.adapter.updateCssVariable(VAR_FG_SCALE, this.fgScale_); 6776 if (this.adapter.isUnbounded()) { 6777 this.unboundedCoords_ = { 6778 left: Math.round((this.frame_.width / 2) - (this.initialSize_ / 2)), 6779 top: Math.round((this.frame_.height / 2) - (this.initialSize_ / 2)), 6780 }; 6781 this.adapter.updateCssVariable(VAR_LEFT, this.unboundedCoords_.left + "px"); 6782 this.adapter.updateCssVariable(VAR_TOP, this.unboundedCoords_.top + "px"); 6783 } 6784 }; 6785 return MDCRippleFoundation; 6786 }(MDCFoundation)); 6787 6788 /** 6789 * @license 6790 * Copyright 2016 Google Inc. 6791 * 6792 * Permission is hereby granted, free of charge, to any person obtaining a copy 6793 * of this software and associated documentation files (the "Software"), to deal 6794 * in the Software without restriction, including without limitation the rights 6795 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6796 * copies of the Software, and to permit persons to whom the Software is 6797 * furnished to do so, subject to the following conditions: 6798 * 6799 * The above copyright notice and this permission notice shall be included in 6800 * all copies or substantial portions of the Software. 6801 * 6802 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6803 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6804 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 6805 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 6806 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6807 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6808 * THE SOFTWARE. 6809 */ 6810 var MDCRipple = /** @class */ (function (_super) { 6811 __extends(MDCRipple, _super); 6812 function MDCRipple() { 6813 var _this = _super !== null && _super.apply(this, arguments) || this; 6814 _this.disabled = false; 6815 return _this; 6816 } 6817 MDCRipple.attachTo = function (root, opts) { 6818 if (opts === void 0) { opts = { isUnbounded: undefined }; } 6819 var ripple = new MDCRipple(root); 6820 // Only override unbounded behavior if option is explicitly specified 6821 if (opts.isUnbounded !== undefined) { 6822 ripple.unbounded = opts.isUnbounded; 6823 } 6824 return ripple; 6825 }; 6826 MDCRipple.createAdapter = function (instance) { 6827 return { 6828 addClass: function (className) { return instance.root.classList.add(className); }, 6829 browserSupportsCssVars: function () { return supportsCssVariables(window); }, 6830 computeBoundingRect: function () { return instance.root.getBoundingClientRect(); }, 6831 containsEventTarget: function (target) { return instance.root.contains(target); }, 6832 deregisterDocumentInteractionHandler: function (evtType, handler) { 6833 return document.documentElement.removeEventListener(evtType, handler, applyPassive()); 6834 }, 6835 deregisterInteractionHandler: function (evtType, handler) { 6836 return instance.root 6837 .removeEventListener(evtType, handler, applyPassive()); 6838 }, 6839 deregisterResizeHandler: function (handler) { 6840 return window.removeEventListener('resize', handler); 6841 }, 6842 getWindowPageOffset: function () {
vendor: 4,868 bytes, lines 6843-6947
6843 return ({ x: window.pageXOffset, y: window.pageYOffset }); 6844 }, 6845 isSurfaceActive: function () { return matches$1(instance.root, ':active'); }, 6846 isSurfaceDisabled: function () { return Boolean(instance.disabled); }, 6847 isUnbounded: function () { return Boolean(instance.unbounded); }, 6848 registerDocumentInteractionHandler: function (evtType, handler) { 6849 return document.documentElement.addEventListener(evtType, handler, applyPassive()); 6850 }, 6851 registerInteractionHandler: function (evtType, handler) { 6852 return instance.root 6853 .addEventListener(evtType, handler, applyPassive()); 6854 }, 6855 registerResizeHandler: function (handler) { 6856 return window.addEventListener('resize', handler); 6857 }, 6858 removeClass: function (className) { return instance.root.classList.remove(className); }, 6859 updateCssVariable: function (varName, value) { 6860 return instance.root.style.setProperty(varName, value); 6861 }, 6862 }; 6863 }; 6864 Object.defineProperty(MDCRipple.prototype, "unbounded", { 6865 get: function () { 6866 return Boolean(this.unbounded_); 6867 }, 6868 set: function (unbounded) { 6869 this.unbounded_ = Boolean(unbounded); 6870 this.setUnbounded_(); 6871 }, 6872 enumerable: true, 6873 configurable: true 6874 }); 6875 MDCRipple.prototype.activate = function () { 6876 this.foundation.activate(); 6877 }; 6878 MDCRipple.prototype.deactivate = function () { 6879 this.foundation.deactivate(); 6880 }; 6881 MDCRipple.prototype.layout = function () { 6882 this.foundation.layout(); 6883 }; 6884 MDCRipple.prototype.getDefaultFoundation = function () { 6885 return new MDCRippleFoundation(MDCRipple.createAdapter(this)); 6886 }; 6887 MDCRipple.prototype.initialSyncWithDOM = function () { 6888 var root = this.root; 6889 this.unbounded = 'mdcRippleIsUnbounded' in root.dataset; 6890 }; 6891 /** 6892 * Closure Compiler throws an access control error when directly accessing a 6893 * protected or private property inside a getter/setter, like unbounded above. 6894 * By accessing the protected property inside a method, we solve that problem. 6895 * That's why this function exists. 6896 */ 6897 MDCRipple.prototype.setUnbounded_ = function () { 6898 this.foundation.setUnbounded(Boolean(this.unbounded_)); 6899 }; 6900 return MDCRipple; 6901 }(MDCComponent)); 6902 6903 /** 6904 * @license 6905 * Copyright 2019 Google Inc. 6906 * 6907 * Permission is hereby granted, free of charge, to any person obtaining a copy 6908 * of this software and associated documentation files (the "Software"), to deal 6909 * in the Software without restriction, including without limitation the rights 6910 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6911 * copies of the Software, and to permit persons to whom the Software is 6912 * furnished to do so, subject to the following conditions: 6913 * 6914 * The above copyright notice and this permission notice shall be included in 6915 * all copies or substantial portions of the Software. 6916 * 6917 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6918 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6919 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 6920 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 6921 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6922 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6923 * THE SOFTWARE. 6924 */ 6925 6926 /** 6927 * @license 6928 * Copyright 2018 Google Inc. 6929 * 6930 * Permission is hereby granted, free of charge, to any person obtaining a copy 6931 * of this software and associated documentation files (the "Software"), to deal 6932 * in the Software without restriction, including without limitation the rights 6933 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6934 * copies of the Software, and to permit persons to whom the Software is 6935 * furnished to do so, subject to the following conditions: 6936 * 6937 * The above copyright notice and this permission notice shall be included in 6938 * all copies or substantial portions of the Software. 6939 * 6940 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6941 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6942 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 6943 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 6944 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6945 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6946 * THE SOFTWARE. 6947 */
vendor: 4,115 bytes, lines 6948-7030
6948 var cssClasses$p = { 6949 LINE_RIPPLE_ACTIVE: 'mdc-line-ripple--active', 6950 LINE_RIPPLE_DEACTIVATING: 'mdc-line-ripple--deactivating', 6951 }; 6952 6953 /** 6954 * @license 6955 * Copyright 2018 Google Inc. 6956 * 6957 * Permission is hereby granted, free of charge, to any person obtaining a copy 6958 * of this software and associated documentation files (the "Software"), to deal 6959 * in the Software without restriction, including without limitation the rights 6960 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6961 * copies of the Software, and to permit persons to whom the Software is 6962 * furnished to do so, subject to the following conditions: 6963 * 6964 * The above copyright notice and this permission notice shall be included in 6965 * all copies or substantial portions of the Software. 6966 * 6967 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 6968 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 6969 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 6970 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 6971 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 6972 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 6973 * THE SOFTWARE. 6974 */ 6975 var MDCLineRippleFoundation = /** @class */ (function (_super) { 6976 __extends(MDCLineRippleFoundation, _super); 6977 function MDCLineRippleFoundation(adapter) { 6978 var _this = _super.call(this, __assign(__assign({}, MDCLineRippleFoundation.defaultAdapter), adapter)) || this; 6979 _this.transitionEndHandler_ = function (evt) { return _this.handleTransitionEnd(evt); }; 6980 return _this; 6981 } 6982 Object.defineProperty(MDCLineRippleFoundation, "cssClasses", { 6983 get: function () { 6984 return cssClasses$p; 6985 }, 6986 enumerable: true, 6987 configurable: true 6988 }); 6989 Object.defineProperty(MDCLineRippleFoundation, "defaultAdapter", { 6990 /** 6991 * See {@link MDCLineRippleAdapter} for typing information on parameters and return types. 6992 */ 6993 get: function () { 6994 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 6995 return { 6996 addClass: function () { return undefined; }, 6997 removeClass: function () { return undefined; }, 6998 hasClass: function () { return false; }, 6999 setStyle: function () { return undefined; }, 7000 registerEventHandler: function () { return undefined; }, 7001 deregisterEventHandler: function () { return undefined; }, 7002 }; 7003 // tslint:enable:object-literal-sort-keys 7004 }, 7005 enumerable: true, 7006 configurable: true 7007 }); 7008 MDCLineRippleFoundation.prototype.init = function () { 7009 this.adapter.registerEventHandler('transitionend', this.transitionEndHandler_); 7010 }; 7011 MDCLineRippleFoundation.prototype.destroy = function () { 7012 this.adapter.deregisterEventHandler('transitionend', this.transitionEndHandler_); 7013 }; 7014 MDCLineRippleFoundation.prototype.activate = function () { 7015 this.adapter.removeClass(cssClasses$p.LINE_RIPPLE_DEACTIVATING); 7016 this.adapter.addClass(cssClasses$p.LINE_RIPPLE_ACTIVE); 7017 }; 7018 MDCLineRippleFoundation.prototype.setRippleCenter = function (xCoordinate) { 7019 this.adapter.setStyle('transform-origin', xCoordinate + "px center"); 7020 }; 7021 MDCLineRippleFoundation.prototype.deactivate = function () { 7022 this.adapter.addClass(cssClasses$p.LINE_RIPPLE_DEACTIVATING); 7023 }; 7024 MDCLineRippleFoundation.prototype.handleTransitionEnd = function (evt) { 7025 // Wait for the line ripple to be either transparent or opaque 7026 // before emitting the animation end event 7027 var isDeactivating = this.adapter.hasClass(cssClasses$p.LINE_RIPPLE_DEACTIVATING); 7028 if (evt.propertyName === 'opacity') { 7029 if (isDeactivating) { 7030 this.adapter.removeClass(cssClasses$p.LINE_RIPPLE_ACTIVE);
7031 this.adapter.removeClass(cssClasses$p.LINE_RIPPLE_DEACTIVATING); 7032 } 7033 } 7034 }; 7035 return MDCLineRippleFoundation; 7036 }(MDCFoundation)); 7037 7038 /** 7039 * @license 7040 * Copyright 2018 Google Inc. 7041 * 7042 * Permission is hereby granted, free of charge, to any person obtaining a copy 7043 * of this software and associated documentation files (the "Software"), to deal 7044 * in the Software without restriction, including without limitation the rights 7045 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7046 * copies of the Software, and to permit persons to whom the Software is 7047 * furnished to do so, subject to the following conditions: 7048 * 7049 * The above copyright notice and this permission notice shall be included in 7050 * all copies or substantial portions of the Software. 7051 * 7052 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7053 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7054 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7055 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7056 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7057 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7058 * THE SOFTWARE. 7059 */ 7060 var MDCLineRipple = /** @class */ (function (_super) { 7061 __extends(MDCLineRipple, _super); 7062 function MDCLineRipple() { 7063 return _super !== null && _super.apply(this, arguments) || this; 7064 } 7065 MDCLineRipple.attachTo = function (root) { 7066 return new MDCLineRipple(root); 7067 }; 7068 /** 7069 * Activates the line ripple 7070 */ 7071 MDCLineRipple.prototype.activate = function () { 7072 this.foundation.activate(); 7073 }; 7074 /** 7075 * Deactivates the line ripple 7076 */ 7077 MDCLineRipple.prototype.deactivate = function () { 7078 this.foundation.deactivate(); 7079 }; 7080 /** 7081 * Sets the transform origin given a user's click location. 7082 * The `rippleCenter` is the x-coordinate of the middle of the ripple. 7083 */ 7084 MDCLineRipple.prototype.setRippleCenter = function (xCoordinate) { 7085 this.foundation.setRippleCenter(xCoordinate); 7086 }; 7087 MDCLineRipple.prototype.getDefaultFoundation = function () { 7088 var _this = this; 7089 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 7090 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 7091 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 7092 var adapter = { 7093 addClass: function (className) { return _this.root.classList.add(className); }, 7094 removeClass: function (className) { return _this.root.classList.remove(className); }, 7095 hasClass: function (className) { return _this.root.classList.contains(className); }, 7096 setStyle: function (propertyName, value) { return _this.root.style.setProperty(propertyName, value); }, 7097 registerEventHandler: function (evtType, handler) { return _this.listen(evtType, handler); }, 7098 deregisterEventHandler: function (evtType, handler) { return _this.unlisten(evtType, handler); }, 7099 }; 7100 // tslint:enable:object-literal-sort-keys 7101 return new MDCLineRippleFoundation(adapter); 7102 }; 7103 return MDCLineRipple; 7104 }(MDCComponent)); 7105 7106 /** 7107 * @license 7108 * Copyright 2019 Google Inc. 7109 * 7110 * Permission is hereby granted, free of charge, to any person obtaining a copy 7111 * of this software and associated documentation files (the "Software"), to deal 7112 * in the Software without restriction, including without limitation the rights 7113 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7114 * copies of the Software, and to permit persons to whom the Software is 7115 * furnished to do so, subject to the following conditions: 7116 * 7117 * The above copyright notice and this permission notice shall be included in 7118 * all copies or substantial portions of the Software. 7119 * 7120 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7121 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7122 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7123 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7124 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7125 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7126 * THE SOFTWARE. 7127 */ 7128 7129 /** 7130 * @license 7131 * Copyright 2018 Google Inc. 7132 * 7133 * Permission is hereby granted, free of charge, to any person obtaining a copy 7134 * of this software and associated documentation files (the "Software"), to deal 7135 * in the Software without restriction, including without limitation the rights 7136 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7137 * copies of the Software, and to permit persons to whom the Software is 7138 * furnished to do so, subject to the following conditions: 7139 * 7140 * The above copyright notice and this permission notice shall be included in 7141 * all copies or substantial portions of the Software. 7142 * 7143 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7144 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7145 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7146 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7147 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7148 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7149 * THE SOFTWARE. 7150 */
vendor: 4,324 bytes, lines 7151-7244
7151 var cssClasses$o = { 7152 FIXED_CLASS: 'mdc-top-app-bar--fixed', 7153 FIXED_SCROLLED_CLASS: 'mdc-top-app-bar--fixed-scrolled', 7154 SHORT_CLASS: 'mdc-top-app-bar--short', 7155 SHORT_COLLAPSED_CLASS: 'mdc-top-app-bar--short-collapsed', 7156 SHORT_HAS_ACTION_ITEM_CLASS: 'mdc-top-app-bar--short-has-action-item', 7157 }; 7158 var numbers$a = { 7159 DEBOUNCE_THROTTLE_RESIZE_TIME_MS: 100, 7160 MAX_TOP_APP_BAR_HEIGHT: 128, 7161 }; 7162 var strings$s = { 7163 ACTION_ITEM_SELECTOR: '.mdc-top-app-bar__action-item', 7164 NAVIGATION_EVENT: 'MDCTopAppBar:nav', 7165 NAVIGATION_ICON_SELECTOR: '.mdc-top-app-bar__navigation-icon', 7166 ROOT_SELECTOR: '.mdc-top-app-bar', 7167 TITLE_SELECTOR: '.mdc-top-app-bar__title', 7168 }; 7169 7170 /** 7171 * @license 7172 * Copyright 2018 Google Inc. 7173 * 7174 * Permission is hereby granted, free of charge, to any person obtaining a copy 7175 * of this software and associated documentation files (the "Software"), to deal 7176 * in the Software without restriction, including without limitation the rights 7177 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7178 * copies of the Software, and to permit persons to whom the Software is 7179 * furnished to do so, subject to the following conditions: 7180 * 7181 * The above copyright notice and this permission notice shall be included in 7182 * all copies or substantial portions of the Software. 7183 * 7184 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7185 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7186 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7187 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7188 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7189 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7190 * THE SOFTWARE. 7191 */ 7192 var MDCTopAppBarBaseFoundation = /** @class */ (function (_super) { 7193 __extends(MDCTopAppBarBaseFoundation, _super); 7194 /* istanbul ignore next: optional argument is not a branch statement */ 7195 function MDCTopAppBarBaseFoundation(adapter) { 7196 return _super.call(this, __assign(__assign({}, MDCTopAppBarBaseFoundation.defaultAdapter), adapter)) || this; 7197 } 7198 Object.defineProperty(MDCTopAppBarBaseFoundation, "strings", { 7199 get: function () { 7200 return strings$s; 7201 }, 7202 enumerable: true, 7203 configurable: true 7204 }); 7205 Object.defineProperty(MDCTopAppBarBaseFoundation, "cssClasses", { 7206 get: function () { 7207 return cssClasses$o; 7208 }, 7209 enumerable: true, 7210 configurable: true 7211 }); 7212 Object.defineProperty(MDCTopAppBarBaseFoundation, "numbers", { 7213 get: function () { 7214 return numbers$a; 7215 }, 7216 enumerable: true, 7217 configurable: true 7218 }); 7219 Object.defineProperty(MDCTopAppBarBaseFoundation, "defaultAdapter", { 7220 /** 7221 * See {@link MDCTopAppBarAdapter} for typing information on parameters and return types. 7222 */ 7223 get: function () { 7224 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 7225 return { 7226 addClass: function () { return undefined; }, 7227 removeClass: function () { return undefined; }, 7228 hasClass: function () { return false; }, 7229 setStyle: function () { return undefined; }, 7230 getTopAppBarHeight: function () { return 0; }, 7231 notifyNavigationIconClicked: function () { return undefined; }, 7232 getViewportScrollY: function () { return 0; }, 7233 getTotalActionItems: function () { return 0; }, 7234 }; 7235 // tslint:enable:object-literal-sort-keys 7236 }, 7237 enumerable: true, 7238 configurable: true 7239 }); 7240 /** Other variants of TopAppBar foundation overrides this method */ 7241 MDCTopAppBarBaseFoundation.prototype.handleTargetScroll = function () { }; // tslint:disable-line:no-empty 7242 /** Other variants of TopAppBar foundation overrides this method */ 7243 MDCTopAppBarBaseFoundation.prototype.handleWindowResize = function () { }; // tslint:disable-line:no-empty 7244 MDCTopAppBarBaseFoundation.prototype.handleNavigationClick = function () {
7245 this.adapter.notifyNavigationIconClicked(); 7246 }; 7247 return MDCTopAppBarBaseFoundation; 7248 }(MDCFoundation)); 7249 7250 /** 7251 * @license 7252 * Copyright 2018 Google Inc. 7253 * 7254 * Permission is hereby granted, free of charge, to any person obtaining a copy 7255 * of this software and associated documentation files (the "Software"), to deal 7256 * in the Software without restriction, including without limitation the rights 7257 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7258 * copies of the Software, and to permit persons to whom the Software is 7259 * furnished to do so, subject to the following conditions: 7260 * 7261 * The above copyright notice and this permission notice shall be included in 7262 * all copies or substantial portions of the Software. 7263 * 7264 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7265 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7266 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7267 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7268 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7269 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7270 * THE SOFTWARE. 7271 */ 7272 var INITIAL_VALUE = 0; 7273 var MDCTopAppBarFoundation = /** @class */ (function (_super) { 7274 __extends(MDCTopAppBarFoundation, _super); 7275 /* istanbul ignore next: optional argument is not a branch statement */ 7276 function MDCTopAppBarFoundation(adapter) { 7277 var _this = _super.call(this, adapter) || this; 7278 /** 7279 * Indicates if the top app bar was docked in the previous scroll handler iteration. 7280 */ 7281 _this.wasDocked_ = true; 7282 /** 7283 * Indicates if the top app bar is docked in the fully shown position. 7284 */ 7285 _this.isDockedShowing_ = true; 7286 /** 7287 * Variable for current scroll position of the top app bar 7288 */ 7289 _this.currentAppBarOffsetTop_ = 0; 7290 /** 7291 * Used to prevent the top app bar from being scrolled out of view during resize events 7292 */ 7293 _this.isCurrentlyBeingResized_ = false; 7294 /** 7295 * The timeout that's used to throttle the resize events 7296 */ 7297 _this.resizeThrottleId_ = INITIAL_VALUE; 7298 /** 7299 * The timeout that's used to debounce toggling the isCurrentlyBeingResized_ variable after a resize 7300 */ 7301 _this.resizeDebounceId_ = INITIAL_VALUE; 7302 _this.lastScrollPosition_ = _this.adapter.getViewportScrollY(); 7303 _this.topAppBarHeight_ = _this.adapter.getTopAppBarHeight(); 7304 return _this; 7305 } 7306 MDCTopAppBarFoundation.prototype.destroy = function () { 7307 _super.prototype.destroy.call(this); 7308 this.adapter.setStyle('top', ''); 7309 }; 7310 /** 7311 * Scroll handler for the default scroll behavior of the top app bar. 7312 * @override 7313 */ 7314 MDCTopAppBarFoundation.prototype.handleTargetScroll = function () { 7315 var currentScrollPosition = Math.max(this.adapter.getViewportScrollY(), 0
vendor: 5,740 bytes, lines 7315-7438
7315); 7316 var diff = currentScrollPosition - this.lastScrollPosition_; 7317 this.lastScrollPosition_ = currentScrollPosition; 7318 // If the window is being resized the lastScrollPosition_ needs to be updated but the 7319 // current scroll of the top app bar should stay in the same position. 7320 if (!this.isCurrentlyBeingResized_) { 7321 this.currentAppBarOffsetTop_ -= diff; 7322 if (this.currentAppBarOffsetTop_ > 0) { 7323 this.currentAppBarOffsetTop_ = 0; 7324 } 7325 else if (Math.abs(this.currentAppBarOffsetTop_) > this.topAppBarHeight_) { 7326 this.currentAppBarOffsetTop_ = -this.topAppBarHeight_; 7327 } 7328 this.moveTopAppBar_(); 7329 } 7330 }; 7331 /** 7332 * Top app bar resize handler that throttle/debounce functions that execute updates. 7333 * @override 7334 */ 7335 MDCTopAppBarFoundation.prototype.handleWindowResize = function () { 7336 var _this = this; 7337 // Throttle resize events 10 p/s 7338 if (!this.resizeThrottleId_) { 7339 this.resizeThrottleId_ = setTimeout(function () { 7340 _this.resizeThrottleId_ = INITIAL_VALUE; 7341 _this.throttledResizeHandler_(); 7342 }, numbers$a.DEBOUNCE_THROTTLE_RESIZE_TIME_MS); 7343 } 7344 this.isCurrentlyBeingResized_ = true; 7345 if (this.resizeDebounceId_) { 7346 clearTimeout(this.resizeDebounceId_); 7347 } 7348 this.resizeDebounceId_ = setTimeout(function () { 7349 _this.handleTargetScroll(); 7350 _this.isCurrentlyBeingResized_ = false; 7351 _this.resizeDebounceId_ = INITIAL_VALUE; 7352 }, numbers$a.DEBOUNCE_THROTTLE_RESIZE_TIME_MS); 7353 }; 7354 /** 7355 * Function to determine if the DOM needs to update. 7356 */ 7357 MDCTopAppBarFoundation.prototype.checkForUpdate_ = function () { 7358 var offscreenBoundaryTop = -this.topAppBarHeight_; 7359 var hasAnyPixelsOffscreen = this.currentAppBarOffsetTop_ < 0; 7360 var hasAnyPixelsOnscreen = this.currentAppBarOffsetTop_ > offscreenBoundaryTop; 7361 var partiallyShowing = hasAnyPixelsOffscreen && hasAnyPixelsOnscreen; 7362 // If it's partially showing, it can't be docked. 7363 if (partiallyShowing) { 7364 this.wasDocked_ = false; 7365 } 7366 else { 7367 // Not previously docked and not partially showing, it's now docked. 7368 if (!this.wasDocked_) { 7369 this.wasDocked_ = true; 7370 return true; 7371 } 7372 else if (this.isDockedShowing_ !== hasAnyPixelsOnscreen) { 7373 this.isDockedShowing_ = hasAnyPixelsOnscreen; 7374 return true; 7375 } 7376 } 7377 return partiallyShowing; 7378 }; 7379 /** 7380 * Function to move the top app bar if needed. 7381 */ 7382 MDCTopAppBarFoundation.prototype.moveTopAppBar_ = function () { 7383 if (this.checkForUpdate_()) { 7384 // Once the top app bar is fully hidden we use the max potential top app bar height as our offset 7385 // so the top app bar doesn't show if the window resizes and the new height > the old height. 7386 var offset = this.currentAppBarOffsetTop_; 7387 if (Math.abs(offset) >= this.topAppBarHeight_) { 7388 offset = -numbers$a.MAX_TOP_APP_BAR_HEIGHT; 7389 } 7390 this.adapter.setStyle('top', offset + 'px'); 7391 } 7392 }; 7393 /** 7394 * Throttled function that updates the top app bar scrolled values if the 7395 * top app bar height changes. 7396 */ 7397 MDCTopAppBarFoundation.prototype.throttledResizeHandler_ = function () { 7398 var currentHeight = this.adapter.getTopAppBarHeight(); 7399 if (this.topAppBarHeight_ !== currentHeight) { 7400 this.wasDocked_ = false; 7401 // Since the top app bar has a different height depending on the screen width, this 7402 // will ensure that the top app bar remains in the correct location if 7403 // completely hidden and a resize makes the top app bar a different height. 7404 this.currentAppBarOffsetTop_ -= this.topAppBarHeight_ - currentHeight; 7405 this.topAppBarHeight_ = currentHeight; 7406 } 7407 this.handleTargetScroll(); 7408 }; 7409 return MDCTopAppBarFoundation; 7410 }(MDCTopAppBarBaseFoundation)); 7411 7412 /** 7413 * @license 7414 * Copyright 2018 Google Inc. 7415 * 7416 * Permission is hereby granted, free of charge, to any person obtaining a copy 7417 * of this software and associated documentation files (the "Software"), to deal 7418 * in the Software without restriction, including without limitation the rights 7419 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7420 * copies of the Software, and to permit persons to whom the Software is 7421 * furnished to do so, subject to the following conditions: 7422 * 7423 * The above copyright notice and this permission notice shall be included in 7424 * all copies or substantial portions of the Software. 7425 * 7426 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7427 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7428 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7429 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7430 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7431 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7432 * THE SOFTWARE. 7433 */ 7434 var MDCFixedTopAppBarFoundation = /** @class */ (function (_super) { 7435 __extends(MDCFixedTopAppBarFoundation, _super); 7436 function MDCFixedTopAppBarFoundation() { 7437 var _this = _super !== null && _super.apply(this, arguments) || this; 7438 /**
7439 * State variable for the previous scroll iteration top app bar state 7440 */ 7441 _this.wasScrolled_ = false; 7442 return _this; 7443 } 7444 /** 7445 * Scroll handler for applying/removing the modifier class on the fixed top app bar. 7446 * @override 7447 */ 7448 MDCFixedTopAppBarFoundation.prototype.handleTargetScroll = function () { 7449 var currentScroll = this.adapter.getViewportScrollY(); 7450 if (currentScroll <= 0) { 7451 if (this.wasScrolled_) { 7452 this.adapter.removeClass(cssClasses$o.FIXED_SCROLLED_CLASS); 7453 this.wasScrolled_ = false; 7454 } 7455 } 7456 else { 7457 if (!this.wasScrolled_) { 7458 this.adapter.addClass(cssClasses$o.FIXED_SCROLLED_CLASS); 7459 this.wasScrolled_ = true; 7460 } 7461 } 7462 }; 7463 return MDCFixedTopAppBarFoundation; 7464 }(MDCTopAppBarFoundation)); 7465 7466 /** 7467 * @license 7468 * Copyright 2018 Google Inc. 7469 * 7470 * Permission is hereby granted, free of charge, to any person obtaining a copy 7471 * of this software and associated documentation files (the "Software"), to deal 7472 * in the Software without restriction, including without limitation the rights 7473 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7474 * copies of the Software, and to permit persons to whom the Software is 7475 * furnished to do so, subject to the following conditions: 7476 * 7477 * The above copyright notice and this permission notice shall be included in 7478 * all copies or substantial portions of the Software. 7479 * 7480 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7481 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7482 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7483 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7484 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7485 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7486 * THE SOFTWARE. 7487 */ 7488 var MDCShortTopAppBarFoundation = /** @class */ (function (_super) { 7489 __extends(MDCShortTopAppBarFoundation, _super); 7490 /* istanbul ignore next: optional argument is not a branch statement */ 7491 function MDCShortTopAppBarFoundation(adapter) { 7492 var _this = _super.call(this, adapter) || this; 7493 _this.isCollapsed_ = false; 7494 _this.isAlwaysCollapsed_ = false; 7495 return _this; 7496 } 7497 Object.defineProperty(MDCShortTopAppBarFoundation.prototype, "isCollapsed", { 7498 // Public visibility for backward compatibility. 7499 get: function () { 7500 return this.isCollapsed_; 7501 }, 7502 enumerable: true, 7503 configurable: true 7504 }); 7505 MDCShortTopAppBarFoundation.prototype.init = function () { 7506 _super.prototype.init.call(this); 7507 if (this.adapter.getTotalActionItems() > 0) { 7508 this.adapter.addClass(cssClasses$o.SHORT_HAS_ACTION_ITEM_CLASS); 7509 } 7510 // If initialized with SHORT_COLLAPSED_CLASS, the bar should always be collapsed 7511 this.setAlwaysCollapsed(this.adapter.hasClass(cssClasses$o.SHORT_COLLAPSED_CLASS)); 7512 }; 7513 /** 7514 * Set if the short top app bar should always be collapsed. 7515 * 7516 * @param value When `true`, bar will always be collapsed. When `false`, bar may collapse or expand based on scroll. 7517 */ 7518 MDCShortTopAppBarFoundation.prototype.setAlwaysCollapsed = function (value) { 7519 this.isAlwaysCollapsed_ = !!value; 7520 if (this.isAlwaysCollapsed_) { 7521 this.collapse_(); 7522 } 7523 else { 7524 // let maybeCollapseBar_ determine if the bar should be collapsed 7525 this.maybeCollapseBar_(); 7526 } 7527 }; 7528 MDCShortTopAppBarFoundation.prototype.getAlwaysCollapsed = function () { 7529 return this.isAlwaysCollapsed_; 7530 }; 7531 /** 7532 * Scroll handler for applying/removing the collapsed modifier class on the short top app bar. 7533 * @override 7534 */ 7535 MDCShortTopAppBarFoundation.prototype.handleTargetScroll = function () { 7536 this.maybeCollapseBar_(); 7537 }; 7538 MDCShortTopAppBarFoundation.prototype.maybeCollapseBar_ = function () { 7539 if (this.isAlwaysCollapsed_) { 7540 return; 7541 } 7542 var currentScroll = this.adapter.getViewportScrollY(); 7543 if (currentScroll <= 0) { 7544 if (this.isCollapsed_) { 7545 this.uncollapse_(); 7546 } 7547 } 7548 else { 7549 if (!this.isCollapsed_) { 7550 this.collapse_(); 7551 } 7552 } 7553 }; 7554 MDCShortTopAppBarFoundation.prototype.uncollapse_ = function () {
7555 this.adapter.removeClass(cssClasses$o.SHORT_COLLAPSED_CLASS); 7556 this.isCollapsed_ = false; 7557 }; 7558 MDCShortTopAppBarFoundation.prototype.collapse_ = function () { 7559 this.adapter.addClass(cssClasses$o.SHORT_COLLAPSED_CLASS); 7560 this.isCollapsed_ = true; 7561 }; 7562 return MDCShortTopAppBarFoundation; 7563 }(MDCTopAppBarBaseFoundation)); 7564 7565 /** 7566 * @license 7567 * Copyright 2018 Google Inc. 7568 * 7569 * Permission is hereby granted, free of charge, to any person obtaining a copy 7570 * of this software and associated documentation files (the "Software"), to deal 7571 * in the Software without restriction, including without limitation the rights 7572 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7573 * copies of the Software, and to permit persons to whom the Software is 7574 * furnished to do so, subject to the following conditions: 7575 * 7576 * The above copyright notice and this permission notice shall be included in 7577 * all copies or substantial portions of the Software. 7578 * 7579 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7580 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7581 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7582 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7583 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7584 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7585 * THE SOFTWARE. 7586 */ 7587 var MDCTopAppBar = /** @class */ (function (_super) { 7588 __extends(MDCTopAppBar, _super); 7589 function MDCTopAppBar() { 7590 return _super !== null && _super.apply(this, arguments) || this; 7591 } 7592 MDCTopAppBar.attachTo = function (root) { 7593 return new MDCTopAppBar(root); 7594 }; 7595 MDCTopAppBar.prototype.initialize = function (rippleFactory) { 7596 if (rippleFactory === void 0) { rippleFactory = function (el) { return MDCRipple.attachTo(el); }; } 7597 this.navIcon_ = this.root.querySelector(strings$s.NAVIGATION_ICON_SELECTOR); 7598 // Get all icons in the toolbar and instantiate the ripples 7599 var icons = [].slice.call(this.root.querySelectorAll(strings$s.ACTION_ITEM_SELECTOR)); 7600 if (this.navIcon_) { 7601 icons.push(this.navIcon_); 7602 } 7603 this.iconRipples_ = icons.map(function (icon) { 7604 var ripple = rippleFactory(icon); 7605 ripple.unbounded = true; 7606 return ripple; 7607 }); 7608 this.scrollTarget_ = window; 7609 }; 7610 MDCTopAppBar.prototype.initialSyncWithDOM = function () { 7611 this.handleNavigationClick_ = 7612 this.foundation.handleNavigationClick.bind(this.foundation); 7613 this.handleWindowResize_ = 7614 this.foundation.handleWindowResize.bind(this.foundation); 7615 this.handleTargetScroll_ = 7616 this.foundation.handleTargetScroll.bind(this.foundation); 7617 this.scrollTarget_.addEventListener('scroll', this.handleTargetScroll_); 7618 if (this.navIcon_) { 7619 this.navIcon_.addEventListener('click', this.handleNavigationClick_); 7620 } 7621 var isFixed = this.root.classList.contains(cssClasses$o.FIXED_CLASS); 7622 var isShort = this.root.classList.contains(cssClasses$o.SHORT_CLASS); 7623 if (!isShort && !isFixed) { 7624 window.addEventListener('resize', this.handleWindowResize_); 7625 } 7626 }; 7627 MDCTopAppBar.prototype.destroy = function () { 7628 this.iconRipples_.forEach(function (iconRipple) { return iconRipple.destroy(); }); 7629 this.scrollTarget_.removeEventListener('scroll', this.handleTargetScroll_); 7630 if (this.navIcon_) { 7631 this.navIcon_.removeEventListener('click', this.handleNavigationClick_); 7632 } 7633 var isFixed = this.root.classList.contains(cssClasses$o.FIXED_CLASS); 7634 var isShort = this.root.classList.contains(cssClasses$o.SHORT_CLASS); 7635 if (!isShort && !isFixed) { 7636 window.removeEventListener('resize', this.handleWindowResize_); 7637 } 7638 _super.prototype.destroy.call(this); 7639 }; 7640 MDCTopAppBar.prototype.setScrollTarget = function (target) { 7641 // Remove scroll handler from the previous scroll target 7642 this.scrollTarget_.removeEventListener('scroll', this.handleTargetScroll_); 7643 this.scrollTarget_ = target; 7644 // Initialize scroll handler on the new scroll target 7645 this.handleTargetScroll_ = 7646 this.foundation.handleTargetScroll.bind(this.foundation); 7647 this.scrollTarget_.addEventListener('scroll', this.handleTargetScroll_); 7648 }; 7649 MDCTopAppBar.prototype.getDefaultFoundation = function () { 7650 var _this = this; 7651 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 7652 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 7653 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 7654 var adapter = { 7655 hasClass: function (className) { return _this.root.classList.contains(className); }, 7656 addClass: function (className) { return _this.root.classList.add(className); }, 7657 removeClass: function (className) { return _this.root.classList.remove(className); }, 7658 setStyle: function (property, value) { 7659 return _this.root.style.setProperty(property, value); 7660 }, 7661 getTopAppBarHeight: function () { return _this.root.clientHeight; },
7662 notifyNavigationIconClicked: function () { 7663 return _this.emit(strings$s.NAVIGATION_EVENT, {}); 7664 }, 7665 getViewportScrollY: function () { 7666 var win = _this.scrollTarget_; 7667 var el = _this.scrollTarget_; 7668 return win.pageYOffset !== undefined ? win.pageYOffset : el.scrollTop; 7669 }, 7670 getTotalActionItems: function () { 7671 return _this.root.querySelectorAll(strings$s.ACTION_ITEM_SELECTOR).length; 7672 }, 7673 }; 7674 // tslint:enable:object-literal-sort-keys 7675 var foundation; 7676 if (this.root.classList.contains(cssClasses$o.SHORT_CLASS)) { 7677 foundation = new MDCShortTopAppBarFoundation(adapter); 7678 } 7679 else if (this.root.classList.contains(cssClasses$o.FIXED_CLASS)) { 7680 foundation = new MDCFixedTopAppBarFoundation(adapter); 7681 } 7682 else { 7683 foundation = new MDCTopAppBarFoundation(adapter); 7684 } 7685 return foundation; 7686 }; 7687 return MDCTopAppBar; 7688 }(MDCComponent)); 7689 7690 /** 7691 * @license 7692 * Copyright 2019 Google Inc. 7693 * 7694 * Permission is hereby granted, free of charge, to any person obtaining a copy 7695 * of this software and associated documentation files (the "Software"), to deal 7696 * in the Software without restriction, including without limitation the rights 7697 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7698 * copies of the Software, and to permit persons to whom the Software is 7699 * furnished to do so, subject to the following conditions: 7700 * 7701 * The above copyright notice and this permission notice shall be included in 7702 * all copies or substantial portions of the Software. 7703 * 7704 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7705 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7706 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7707 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7708 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7709 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7710 * THE SOFTWARE. 7711 */ 7712 7713 /** 7714 * @license 7715 * Copyright 2016 Google Inc. 7716 * 7717 * Permission is hereby granted, free of charge, to any person obtaining a copy 7718 * of this software and associated documentation files (the "Software"), to deal 7719 * in the Software without restriction, including without limitation the rights 7720 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7721 * copies of the Software, and to permit persons to whom the Software is 7722 * furnished to do so, subject to the following conditions: 7723 * 7724 * The above copyright notice and this permission notice shall be included in 7725 * all copies or substantial portions of the Software. 7726 * 7727 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7728 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7729 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7730 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7731 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7732 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7733 * THE SOFTWARE. 7734 */ 7735 function createFocusTrapInstance$1(surfaceEl, focusTrapFactory) { 7736 return focusTrapFactory(surfaceEl, { 7737 // Component handles focusing on active nav item. 7738 skipInitialFocus: true, 7739 }); 7740 } 7741 7742 /** 7743 * @license 7744 * Copyright 2020 Google Inc. 7745 * 7746 * Permission is hereby granted, free of charge, to any person obtaining a copy 7747 * of this software and associated documentation files (the "Software"), to deal 7748 * in the Software without restriction, including without limitation the rights 7749 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7750 * copies of the Software, and to permit persons to whom the Software is 7751 * furnished to do so, subject to the following conditions: 7752 * 7753 * The above copyright notice and this permission notice shall be included in 7754 * all copies or substantial portions of the Software. 7755 * 7756 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7757 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7758 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7759 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7760 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7761 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7762 * THE SOFTWARE. 7763 */ 7764 var FOCUS_SENTINEL_CLASS = 'mdc-dom-focus-sentinel'; 7765 /** 7766 * Utility to trap focus in a given root element, e.g. for modal components such 7767 * as dialogs. The root should have at least one focusable child element, 7768 * for setting initial focus when trapping focus. 7769 * Also tracks the previously focused element, and restores focus to that 7770 * element when releasing focus. 7771 */ 7772 var FocusTrap = /** @class */ (function () { 7773 function FocusTrap(root, options) { 7774 if (options === void 0) { options = {}; } 7775 this.root = root; 7776 this.options = options; 7777 // Previously focused element before trapping focus. 7778 this.elFocusedBeforeTrapFocus = null; 7779 } 7780 /**
7781 * Traps focus in `root`. Also focuses on either `initialFocusEl` if set; 7782 * otherwises sets initial focus to the first focusable child element. 7783 */ 7784 FocusTrap.prototype.trapFocus = function () { 7785 var focusableEls = this.getFocusableElements(this.root); 7786 if (focusableEls.length === 0) { 7787 throw new Error('FocusTrap: Element must have at least one focusable child.'); 7788 } 7789 this.elFocusedBeforeTrapFocus = 7790 document.activeElement instanceof HTMLElement ? document.activeElement : 7791 null; 7792 this.wrapTabFocus(this.root, focusableEls); 7793 if (!this.options.skipInitialFocus) { 7794 this.focusInitialElement(focusableEls, this.options.initialFocusEl); 7795 } 7796 }; 7797 /** 7798 * Releases focus from `root`. Also restores focus to the previously focused 7799 * element. 7800 */ 7801 FocusTrap.prototype.releaseFocus = function () { 7802 [].slice.call(this.root.querySelectorAll("." + FOCUS_SENTINEL_CLASS)) 7803 .forEach(function (sentinelEl) { 7804 sentinelEl.parentElement.removeChild(sentinelEl); 7805 }); 7806 if (this.elFocusedBeforeTrapFocus) { 7807 this.elFocusedBeforeTrapFocus.focus(); 7808 } 7809 }; 7810 /** 7811 * Wraps tab focus within `el` by adding two hidden sentinel divs which are 7812 * used to mark the beginning and the end of the tabbable region. When 7813 * focused, these sentinel elements redirect focus to the first/last 7814 * children elements of the tabbable region, ensuring that focus is trapped 7815 * within that region. 7816 */ 7817 FocusTrap.prototype.wrapTabFocus = function (el, focusableEls) { 7818 var sentinelStart = this.createSentinel(); 7819 var sentinelEnd = this.createSentinel(); 7820 sentinelStart.addEventListener('focus', function () { 7821 if (focusableEls.length > 0) { 7822 focusableEls[focusableEls.length - 1].focus(); 7823 } 7824 }); 7825 sentinelEnd.addEventListener('focus', function () { 7826 if (focusableEls.length > 0) { 7827 focusableEls[0].focus(); 7828 } 7829 }); 7830 el.insertBefore(sentinelStart, el.children[0]); 7831 el.appendChild(sentinelEnd); 7832 }; 7833 /** 7834 * Focuses on `initialFocusEl` if defined and a child of the root element. 7835 * Otherwise, focuses on the first focusable child element of the root. 7836 */ 7837 FocusTrap.prototype.focusInitialElement = function (focusableEls, initialFocusEl) { 7838 var focusIndex = 0; 7839 if (initialFocusEl) { 7840 focusIndex = Math.max(focusableEls.indexOf(initialFocusEl), 0); 7841 } 7842 focusableEls[focusIndex].focus(); 7843 }; 7844 FocusTrap.prototype.getFocusableElements = function (root) { 7845 var focusableEls = [].slice.call(root.querySelectorAll('[autofocus], [tabindex], a, input, textarea, select, button')); 7846 return focusableEls.filter(function (el) { 7847 var isDisabledOrHidden = el.getAttribute('aria-disabled') === 'true' || 7848 el.getAttribute('disabled') != null || 7849 el.getAttribute('hidden') != null || 7850 el.getAttribute('aria-hidden') === 'true'; 7851 var isTabbableAndVisible = el.tabIndex >= 0 && 7852 el.getBoundingClientRect().width > 0 && 7853 !el.classList.contains(FOCUS_SENTINEL_CLASS) && !isDisabledOrHidden; 7854 var isProgrammaticallyHidden = false; 7855 if (isTabbableAndVisible) { 7856 var style = getComputedStyle(el); 7857 isProgrammaticallyHidden = 7858 style.display === 'none' || style.visibility === 'hidden'; 7859 } 7860 return isTabbableAndVisible && !isProgrammaticallyHidden; 7861 }); 7862 }; 7863 FocusTrap.prototype.createSentinel = function () { 7864 var sentinel = document.createElement('div'); 7865 sentinel.setAttribute('tabindex', '0'); 7866 // Don't announce in screen readers. 7867 sentinel.setAttribute('aria-hidden', 'true'); 7868 sentinel.classList.add(FOCUS_SENTINEL_CLASS); 7869 return sentinel; 7870 }; 7871 return FocusTrap; 7872 }()); 7873 7874 /** 7875 * @license 7876 * Copyright 2018 Google Inc. 7877 * 7878 * Permission is hereby granted, free of charge, to any person obtaining a copy 7879 * of this software and associated documentation files (the "Software"), to deal 7880 * in the Software without restriction, including without limitation the rights 7881 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7882 * copies of the Software, and to permit persons to whom the Software is 7883 * furnished to do so, subject to the following conditions: 7884 * 7885 * The above copyright notice and this permission notice shall be included in 7886 * all copies or substantial portions of the Software. 7887 * 7888 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7889 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7890 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7891 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7892 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7893 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7894 * THE SOFTWARE. 7895 */ 7896 var _a$1;
7897 var cssClasses$n = { 7898 LIST_ITEM_ACTIVATED_CLASS: 'mdc-list-item--activated', 7899 LIST_ITEM_CLASS: 'mdc-list-item', 7900 LIST_ITEM_DISABLED_CLASS: 'mdc-list-item--disabled', 7901 LIST_ITEM_SELECTED_CLASS: 'mdc-list-item--selected', 7902 LIST_ITEM_TEXT_CLASS: 'mdc-list-item__text', 7903 LIST_ITEM_PRIMARY_TEXT_CLASS: 'mdc-list-item__primary-text', 7904 ROOT: 'mdc-list', 7905 }; 7906 var strings$r = { 7907 ACTION_EVENT: 'MDCList:action', 7908 ARIA_CHECKED: 'aria-checked', 7909 ARIA_CHECKED_CHECKBOX_SELECTOR: '[role="checkbox"][aria-checked="true"]', 7910 ARIA_CHECKED_RADIO_SELECTOR: '[role="radio"][aria-checked="true"]', 7911 ARIA_CURRENT: 'aria-current', 7912 ARIA_DISABLED: 'aria-disabled', 7913 ARIA_ORIENTATION: 'aria-orientation', 7914 ARIA_ORIENTATION_HORIZONTAL: 'horizontal', 7915 ARIA_ROLE_CHECKBOX_SELECTOR: '[role="checkbox"]', 7916 ARIA_SELECTED: 'aria-selected', 7917 ARIA_INTERACTIVE_ROLES_SELECTOR: '[role="listbox"], [role="menu"]', 7918 ARIA_MULTI_SELECTABLE_SELECTOR: '[aria-multiselectable="true"]', 7919 CHECKBOX_RADIO_SELECTOR: 'input[type="checkbox"], input[type="radio"]', 7920 CHECKBOX_SELECTOR: 'input[type="checkbox"]', 7921 CHILD_ELEMENTS_TO_TOGGLE_TABINDEX: 'button:not(:disabled), a', 7922 FOCUSABLE_CHILD_ELEMENTS: 'button:not(:disabled), a, input[type="radio"]:not(:disabled), input[type="checkbox"]:not(:disabled)', 7923 RADIO_SELECTOR: 'input[type="radio"]', 7924 SELECTED_ITEM_SELECTOR: '[aria-selected="true"], [aria-current="true"]', 7925 }; 7926 var numbers$9 = { 7927 UNSET_INDEX: -1, 7928 TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS: 300 7929 }; 7930 var evolutionClassNameMap = (_a$1 = {}, 7931 _a$1["" + cssClasses$n.LIST_ITEM_ACTIVATED_CLASS] = 'mdc-evolution-list-item--activated', 7932 _a$1["" + cssClasses$n.LIST_ITEM_CLASS] = 'mdc-evolution-list-item', 7933 _a$1["" + cssClasses$n.LIST_ITEM_DISABLED_CLASS] = 'mdc-evolution-list-item--disabled', 7934 _a$1["" + cssClasses$n.LIST_ITEM_SELECTED_CLASS] = 'mdc-evolution-list-item--selected', 7935 _a$1["" + cssClasses$n.LIST_ITEM_PRIMARY_TEXT_CLASS] = 'mdc-evolution-list-item__primary-text', 7936 _a$1["" + cssClasses$n.ROOT] = 'mdc-evolution-list', 7937 _a$1); 7938 var evolutionAttribute = 'evolution'; 7939 7940 /** 7941 * @license 7942 * Copyright 2020 Google Inc. 7943 * 7944 * Permission is hereby granted, free of charge, to any person obtaining a copy 7945 * of this software and associated documentation files (the "Software"), to deal 7946 * in the Software without restriction, including without limitation the rights 7947 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7948 * copies of the Software, and to permit persons to whom the Software is 7949 * furnished to do so, subject to the following conditions: 7950 * 7951 * The above copyright notice and this permission notice shall be included in 7952 * all copies or substantial portions of the Software. 7953 * 7954 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7955 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 7956 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 7957 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 7958 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 7959 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 7960 * THE SOFTWARE. 7961 */ 7962 /** 7963 * KEY provides normalized string values for keys. 7964 */ 7965 var KEY = { 7966 UNKNOWN: 'Unknown', 7967 BACKSPACE: 'Backspace', 7968 ENTER: 'Enter', 7969 SPACEBAR: 'Spacebar', 7970 PAGE_UP: 'PageUp', 7971 PAGE_DOWN: 'PageDown', 7972 END: 'End', 7973 HOME: 'Home', 7974 ARROW_LEFT: 'ArrowLeft', 7975 ARROW_UP: 'ArrowUp', 7976 ARROW_RIGHT: 'ArrowRight', 7977 ARROW_DOWN: 'ArrowDown', 7978 DELETE: 'Delete', 7979 ESCAPE: 'Escape', 7980 }; 7981 var normalizedKeys = new Set(); 7982 // IE11 has no support for new Map with iterable so we need to initialize this 7983 // by hand. 7984 normalizedKeys.add(KEY.BACKSPACE); 7985 normalizedKeys.add(KEY.ENTER); 7986 normalizedKeys.add(KEY.SPACEBAR); 7987 normalizedKeys.add(KEY.PAGE_UP); 7988 normalizedKeys.add(KEY.PAGE_DOWN); 7989 normalizedKeys.add(KEY.END); 7990 normalizedKeys.add(KEY.HOME); 7991 normalizedKeys.add(KEY.ARROW_LEFT); 7992 normalizedKeys.add(KEY.ARROW_UP); 7993 normalizedKeys.add(KEY.ARROW_RIGHT); 7994 normalizedKeys.add(KEY.ARROW_DOWN); 7995 normalizedKeys.add(KEY.DELETE); 7996 normalizedKeys.add(KEY.ESCAPE); 7997 var KEY_CODE = { 7998 BACKSPACE: 8, 7999 ENTER: 13, 8000 SPACEBAR: 32, 8001 PAGE_UP: 33, 8002 PAGE_DOWN: 34, 8003 END: 35, 8004 HOME: 36, 8005 ARROW_LEFT: 37, 8006 ARROW_UP: 38, 8007 ARROW_RIGHT: 39, 8008 ARROW_DOWN: 40, 8009 DELETE: 46, 8010 ESCAPE: 27, 8011 }; 8012 var mappedKeyCodes = new Map(); 8013 // IE11 has no support for new Map with iterable so we need to initialize this 8014 // by hand. 8015 mappedKeyCodes.set(KEY_CODE.BACKSPACE, KEY.BACKSPACE); 8016 mappedKeyCodes.set(KEY_CODE.ENTER, KEY.ENTER); 8017 mappedKeyCodes.set(KEY_CODE.SPACEBAR, KEY.SPACEBAR); 8018 mappedKeyCodes.set(KEY_CODE.PAGE_UP, KEY.PAGE_UP); 8019 mappedKeyCodes.set(KEY_CODE.PAGE_DOWN, KEY.PAGE_DOWN); 8020 mappedKeyCodes.set(KEY_CODE.END, KEY.END); 8021 mappedKeyCodes.set(KEY_CODE.HOME, KEY.HOME); 8022 mappedKeyCodes.set(KEY_CODE.ARROW_LEFT, KEY.ARROW_LEFT); 8023 mappedKeyCodes.set(KEY_CODE.ARROW_UP, KEY.ARROW_UP); 8024 mappedKeyCodes.set(KEY_CODE.ARROW_RIGHT, KEY.ARROW_RIGHT); 8025 mappedKeyCodes.set(KEY_CODE.ARROW_DOWN, KEY.ARROW_DOWN); 8026 mappedKeyCodes.set(KEY_CODE.DELETE, KEY.DELETE); 8027 mappedKeyCodes.set(KEY_CODE.ESCAPE, KEY.ESCAPE); 8028 var navigationKeys$1 = new Set(); 8029 // IE11 has no support for new Set with iterable so we need to initialize this 8030 // by hand. 8031 navigationKeys$1.add(KEY.PAGE_UP); 8032 navigationKeys$1.add(KEY.PAGE_DOWN); 8033 navigationKeys$1.add(KEY.END); 8034 navigationKeys$1.add(KEY.HOME); 8035 navigationKeys$1.add(KEY.ARROW_LEFT); 8036 navigationKeys$1.add(KEY.ARROW_UP); 8037 navigationKeys$1.add(KEY.ARROW_RIGHT); 8038 navigationKeys$1.add(KEY.ARROW_DOWN); 8039 /** 8040 * normalizeKey returns the normalized string for a navigational action. 8041 */ 8042 function normalizeKey(evt) { 8043 var key = evt.key; 8044 // If the event already has a normalized key, return it 8045 if (normalizedKeys.has(key)) { 8046 return key; 8047 } 8048 // tslint:disable-next-line:deprecation 8049 var mappedKey = mappedKeyCodes.get(evt.keyCode); 8050 if (mappedKey) { 8051 return mappedKey; 8052 } 8053 return KEY.UNKNOWN; 8054 } 8055 /** 8056 * isNavigationEvent returns whether the event is a navigation event 8057 */ 8058 function isNavigationEvent(evt) { 8059 return navigationKeys$1.has(normalizeKey(evt)); 8060 } 8061 8062 /** 8063 * @license 8064 * Copyright 2020 Google Inc. 8065 * 8066 * Permission is hereby granted, free of charge, to any person obtaining a copy 8067 * of this software and associated documentation files (the "Software"), to deal 8068 * in the Software without restriction, including without limitation the rights 8069 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8070 * copies of the Software, and to permit persons to whom the Software is 8071 * furnished to do so, subject to the following conditions: 8072 * 8073 * The above copyright notice and this permission notice shall be included in 8074 * all copies or substantial portions of the Software. 8075 * 8076 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8077 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 8078 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 8079 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 8080 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 8081 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 8082 * THE SOFTWARE. 8083 */ 8084 var ELEMENTS_KEY_ALLOWED_IN = ['input', 'button', 'textarea', 'select']; 8085 /**
vendor: 9,705 bytes, lines 8086-8316
8086 * Ensures that preventDefault is only called if the containing element 8087 * doesn't consume the event, and it will cause an unintended scroll. 8088 * 8089 * @param evt keyboard event to be prevented. 8090 */ 8091 var preventDefaultEvent = function (evt) { 8092 var target = evt.target; 8093 if (!target) { 8094 return; 8095 } 8096 var tagName = ("" + target.tagName).toLowerCase(); 8097 if (ELEMENTS_KEY_ALLOWED_IN.indexOf(tagName) === -1) { 8098 evt.preventDefault(); 8099 } 8100 }; 8101 8102 /** 8103 * @license 8104 * Copyright 2020 Google Inc. 8105 * 8106 * Permission is hereby granted, free of charge, to any person obtaining a copy 8107 * of this software and associated documentation files (the "Software"), to deal 8108 * in the Software without restriction, including without limitation the rights 8109 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8110 * copies of the Software, and to permit persons to whom the Software is 8111 * furnished to do so, subject to the following conditions: 8112 * 8113 * The above copyright notice and this permission notice shall be included in 8114 * all copies or substantial portions of the Software. 8115 * 8116 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8117 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 8118 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 8119 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 8120 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 8121 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 8122 * THE SOFTWARE. 8123 */ 8124 /** 8125 * Initializes a state object for typeahead. Use the same reference for calls to 8126 * typeahead functions. 8127 * 8128 * @return The current state of the typeahead process. Each state reference 8129 * represents a typeahead instance as the reference is typically mutated 8130 * in-place. 8131 */ 8132 function initState() { 8133 var state = { 8134 bufferClearTimeout: 0, 8135 currentFirstChar: '', 8136 sortedIndexCursor: 0, 8137 typeaheadBuffer: '', 8138 }; 8139 return state; 8140 } 8141 /** 8142 * Initializes typeahead state by indexing the current list items by primary 8143 * text into the sortedIndexByFirstChar data structure. 8144 * 8145 * @param listItemCount numer of items in the list 8146 * @param getPrimaryTextByItemIndex function that returns the primary text at a 8147 * given index 8148 * 8149 * @return Map that maps the first character of the primary text to the full 8150 * list text and it's index 8151 */ 8152 function initSortedIndex(listItemCount, getPrimaryTextByItemIndex) { 8153 var sortedIndexByFirstChar = new Map(); 8154 // Aggregate item text to index mapping 8155 for (var i = 0; i < listItemCount; i++) { 8156 var primaryText = getPrimaryTextByItemIndex(i).trim(); 8157 if (!primaryText) { 8158 continue; 8159 } 8160 var firstChar = primaryText[0].toLowerCase(); 8161 if (!sortedIndexByFirstChar.has(firstChar)) { 8162 sortedIndexByFirstChar.set(firstChar, []); 8163 } 8164 sortedIndexByFirstChar.get(firstChar).push({ text: primaryText.toLowerCase(), index: i }); 8165 } 8166 // Sort the mapping 8167 // TODO(b/157162694): Investigate replacing forEach with Map.values() 8168 sortedIndexByFirstChar.forEach(function (values) { 8169 values.sort(function (first, second) { 8170 return first.index - second.index; 8171 }); 8172 }); 8173 return sortedIndexByFirstChar; 8174 } 8175 /** 8176 * Given the next desired character from the user, it attempts to find the next 8177 * list option matching the buffer. Wraps around if at the end of options. 8178 * 8179 * @param opts Options and accessors 8180 * - nextChar - the next character to match against items 8181 * - sortedIndexByFirstChar - output of `initSortedIndex(...)` 8182 * - focusedItemIndex - the index of the currently focused item 8183 * - focusItemAtIndex - function that focuses a list item at given index 8184 * - skipFocus - whether or not to focus the matched item 8185 * - isItemAtIndexDisabled - function that determines whether an item at a 8186 * given index is disabled 8187 * @param state The typeahead state instance. See `initState`. 8188 * 8189 * @return The index of the matched item, or -1 if no match. 8190 */ 8191 function matchItem(opts, state) { 8192 var nextChar = opts.nextChar, focusItemAtIndex = opts.focusItemAtIndex, sortedIndexByFirstChar = opts.sortedIndexByFirstChar, focusedItemIndex = opts.focusedItemIndex, skipFocus = opts.skipFocus, isItemAtIndexDisabled = opts.isItemAtIndexDisabled; 8193 clearTimeout(state.bufferClearTimeout); 8194 state.bufferClearTimeout = setTimeout(function () { 8195 clearBuffer(state); 8196 }, numbers$9.TYPEAHEAD_BUFFER_CLEAR_TIMEOUT_MS); 8197 state.typeaheadBuffer = state.typeaheadBuffer + nextChar; 8198 var index; 8199 if (state.typeaheadBuffer.length === 1) { 8200 index = matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state); 8201 } 8202 else { 8203 index = matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state); 8204 } 8205 if (index !== -1 && !skipFocus) { 8206 focusItemAtIndex(index); 8207 } 8208 return index; 8209 } 8210 /** 8211 * Matches the user's single input character in the buffer to the 8212 * next option that begins with such character. Wraps around if at 8213 * end of options. Returns -1 if no match is found. 8214 */ 8215 function matchFirstChar(sortedIndexByFirstChar, focusedItemIndex, isItemAtIndexDisabled, state) { 8216 var firstChar = state.typeaheadBuffer[0]; 8217 var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar); 8218 if (!itemsMatchingFirstChar) { 8219 return -1; 8220 } 8221 // Has the same firstChar been recently matched? 8222 // Also, did starting index remain the same between key presses? 8223 // If both hold true, simply increment index. 8224 if (firstChar === state.currentFirstChar && 8225 itemsMatchingFirstChar[state.sortedIndexCursor].index === 8226 focusedItemIndex) { 8227 state.sortedIndexCursor = 8228 (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length; 8229 var newIndex = itemsMatchingFirstChar[state.sortedIndexCursor].index; 8230 if (!isItemAtIndexDisabled(newIndex)) { 8231 return newIndex; 8232 } 8233 } 8234 // If we're here, it means one of the following happened: 8235 // - either firstChar or startingIndex has changed, invalidating the 8236 // cursor. 8237 // - The next item of typeahead is disabled, so we have to look further. 8238 state.currentFirstChar = firstChar; 8239 var newCursorPosition = -1; 8240 var cursorPosition; 8241 // Find the first non-disabled item as a fallback. 8242 for (cursorPosition = 0; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) { 8243 if (!isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) { 8244 newCursorPosition = cursorPosition; 8245 break; 8246 } 8247 } 8248 // Advance cursor to first item matching the firstChar that is positioned 8249 // after starting item. Cursor is unchanged from fallback if there's no 8250 // such item. 8251 for (; cursorPosition < itemsMatchingFirstChar.length; cursorPosition++) { 8252 if (itemsMatchingFirstChar[cursorPosition].index > focusedItemIndex && 8253 !isItemAtIndexDisabled(itemsMatchingFirstChar[cursorPosition].index)) { 8254 newCursorPosition = cursorPosition; 8255 break; 8256 } 8257 } 8258 if (newCursorPosition !== -1) { 8259 state.sortedIndexCursor = newCursorPosition; 8260 return itemsMatchingFirstChar[state.sortedIndexCursor].index; 8261 } 8262 return -1; 8263 } 8264 /** 8265 * Attempts to find the next item that matches all of the typeahead buffer. 8266 * Wraps around if at end of options. Returns -1 if no match is found. 8267 */ 8268 function matchAllChars(sortedIndexByFirstChar, isItemAtIndexDisabled, state) { 8269 var firstChar = state.typeaheadBuffer[0]; 8270 var itemsMatchingFirstChar = sortedIndexByFirstChar.get(firstChar); 8271 if (!itemsMatchingFirstChar) { 8272 return -1; 8273 } 8274 // Do nothing if text already matches 8275 var startingItem = itemsMatchingFirstChar[state.sortedIndexCursor]; 8276 if (startingItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0 && 8277 !isItemAtIndexDisabled(startingItem.index)) { 8278 return startingItem.index; 8279 } 8280 // Find next item that matches completely; if no match, we'll eventually 8281 // loop around to same position 8282 var cursorPosition = (state.sortedIndexCursor + 1) % itemsMatchingFirstChar.length; 8283 var nextCursorPosition = -1; 8284 while (cursorPosition !== state.sortedIndexCursor) { 8285 var currentItem = itemsMatchingFirstChar[cursorPosition]; 8286 var matches = currentItem.text.lastIndexOf(state.typeaheadBuffer, 0) === 0; 8287 var isEnabled = !isItemAtIndexDisabled(currentItem.index); 8288 if (matches && isEnabled) { 8289 nextCursorPosition = cursorPosition; 8290 break; 8291 } 8292 cursorPosition = (cursorPosition + 1) % itemsMatchingFirstChar.length; 8293 } 8294 if (nextCursorPosition !== -1) { 8295 state.sortedIndexCursor = nextCursorPosition; 8296 return itemsMatchingFirstChar[state.sortedIndexCursor].index; 8297 } 8298 return -1; 8299 } 8300 /** 8301 * Whether or not the given typeahead instaance state is currently typing. 8302 * 8303 * @param state The typeahead state instance. See `initState`. 8304 */ 8305 function isTypingInProgress(state) { 8306 return state.typeaheadBuffer.length > 0; 8307 } 8308 /** 8309 * Clears the typeahaed buffer so that it resets item matching to the first 8310 * character. 8311 * 8312 * @param state The typeahead state instance. See `initState`. 8313 */ 8314 function clearBuffer(state) { 8315 state.typeaheadBuffer = ''; 8316 }
vendor: 4,476 bytes, lines 8317-8412
8317 /** 8318 * Given a keydown event, it calculates whether or not to automatically focus a 8319 * list item depending on what was typed mimicing the typeahead functionality of 8320 * a standard <select> element that is open. 8321 * 8322 * @param opts Options and accessors 8323 * - event - the KeyboardEvent to handle and parse 8324 * - sortedIndexByFirstChar - output of `initSortedIndex(...)` 8325 * - focusedItemIndex - the index of the currently focused item 8326 * - focusItemAtIndex - function that focuses a list item at given index 8327 * - isItemAtFocusedIndexDisabled - whether or not the currently focused item 8328 * is disabled 8329 * - isTargetListItem - whether or not the event target is a list item 8330 * @param state The typeahead state instance. See `initState`. 8331 * 8332 * @returns index of the item matched by the keydown. -1 if not matched. 8333 */ 8334 function handleKeydown(opts, state) { 8335 var event = opts.event, isTargetListItem = opts.isTargetListItem, focusedItemIndex = opts.focusedItemIndex, focusItemAtIndex = opts.focusItemAtIndex, sortedIndexByFirstChar = opts.sortedIndexByFirstChar, isItemAtIndexDisabled = opts.isItemAtIndexDisabled; 8336 var isArrowLeft = normalizeKey(event) === 'ArrowLeft'; 8337 var isArrowUp = normalizeKey(event) === 'ArrowUp'; 8338 var isArrowRight = normalizeKey(event) === 'ArrowRight'; 8339 var isArrowDown = normalizeKey(event) === 'ArrowDown'; 8340 var isHome = normalizeKey(event) === 'Home'; 8341 var isEnd = normalizeKey(event) === 'End'; 8342 var isEnter = normalizeKey(event) === 'Enter'; 8343 var isSpace = normalizeKey(event) === 'Spacebar'; 8344 if (isArrowLeft || isArrowUp || isArrowRight || isArrowDown || isHome || 8345 isEnd || isEnter) { 8346 return -1; 8347 } 8348 var isCharacterKey = !isSpace && event.key.length === 1; 8349 if (isCharacterKey) { 8350 preventDefaultEvent(event); 8351 var matchItemOpts = { 8352 focusItemAtIndex: focusItemAtIndex, 8353 focusedItemIndex: focusedItemIndex, 8354 nextChar: event.key.toLowerCase(), 8355 sortedIndexByFirstChar: sortedIndexByFirstChar, 8356 skipFocus: false, 8357 isItemAtIndexDisabled: isItemAtIndexDisabled, 8358 }; 8359 return matchItem(matchItemOpts, state); 8360 } 8361 if (!isSpace) { 8362 return -1; 8363 } 8364 if (isTargetListItem) { 8365 preventDefaultEvent(event); 8366 } 8367 var typeaheadOnListItem = isTargetListItem && isTypingInProgress(state); 8368 if (typeaheadOnListItem) { 8369 var matchItemOpts = { 8370 focusItemAtIndex: focusItemAtIndex, 8371 focusedItemIndex: focusedItemIndex, 8372 nextChar: ' ', 8373 sortedIndexByFirstChar: sortedIndexByFirstChar, 8374 skipFocus: false, 8375 isItemAtIndexDisabled: isItemAtIndexDisabled, 8376 }; 8377 // space participates in typeahead matching if in rapid typing mode 8378 return matchItem(matchItemOpts, state); 8379 } 8380 return -1; 8381 } 8382 8383 /** 8384 * @license 8385 * Copyright 2018 Google Inc. 8386 * 8387 * Permission is hereby granted, free of charge, to any person obtaining a copy 8388 * of this software and associated documentation files (the "Software"), to deal 8389 * in the Software without restriction, including without limitation the rights 8390 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8391 * copies of the Software, and to permit persons to whom the Software is 8392 * furnished to do so, subject to the following conditions: 8393 * 8394 * The above copyright notice and this permission notice shall be included in 8395 * all copies or substantial portions of the Software. 8396 * 8397 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 8398 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 8399 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 8400 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 8401 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 8402 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 8403 * THE SOFTWARE. 8404 */ 8405 function isNumberArray(selectedIndex) { 8406 return selectedIndex instanceof Array; 8407 } 8408 var MDCListFoundation = /** @class */ (function (_super) { 8409 __extends(MDCListFoundation, _super); 8410 function MDCListFoundation(adapter) { 8411 var _this = _super.call(this, __assign(__assign({}, MDCListFoundation.defaultAdapter), adapter)) || this; 8412 _this.wrapFocus_ = false;
vendor: 4,388 bytes, lines 8413-8520
8413 _this.isVertical_ = true; 8414 _this.isSingleSelectionList_ = false; 8415 _this.selectedIndex_ = numbers$9.UNSET_INDEX; 8416 _this.focusedItemIndex = numbers$9.UNSET_INDEX; 8417 _this.useActivatedClass_ = false; 8418 _this.useSelectedAttr_ = false; 8419 _this.ariaCurrentAttrValue_ = null; 8420 _this.isCheckboxList_ = false; 8421 _this.isRadioList_ = false; 8422 _this.hasTypeahead = false; 8423 // Transiently holds current typeahead prefix from user. 8424 _this.typeaheadState = initState(); 8425 _this.sortedIndexByFirstChar = new Map(); 8426 return _this; 8427 } 8428 Object.defineProperty(MDCListFoundation, "strings", { 8429 get: function () { 8430 return strings$r; 8431 }, 8432 enumerable: true, 8433 configurable: true 8434 }); 8435 Object.defineProperty(MDCListFoundation, "cssClasses", { 8436 get: function () { 8437 return cssClasses$n; 8438 }, 8439 enumerable: true, 8440 configurable: true 8441 }); 8442 Object.defineProperty(MDCListFoundation, "numbers", { 8443 get: function () { 8444 return numbers$9; 8445 }, 8446 enumerable: true, 8447 configurable: true 8448 }); 8449 Object.defineProperty(MDCListFoundation, "defaultAdapter", { 8450 get: function () { 8451 return { 8452 addClassForElementIndex: function () { return undefined; }, 8453 focusItemAtIndex: function () { return undefined; }, 8454 getAttributeForElementIndex: function () { return null; }, 8455 getFocusedElementIndex: function () { return 0; }, 8456 getListItemCount: function () { return 0; }, 8457 hasCheckboxAtIndex: function () { return false; }, 8458 hasRadioAtIndex: function () { return false; }, 8459 isCheckboxCheckedAtIndex: function () { return false; }, 8460 isFocusInsideList: function () { return false; }, 8461 isRootFocused: function () { return false; }, 8462 listItemAtIndexHasClass: function () { return false; }, 8463 notifyAction: function () { return undefined; }, 8464 removeClassForElementIndex: function () { return undefined; }, 8465 setAttributeForElementIndex: function () { return undefined; }, 8466 setCheckedCheckboxOrRadioAtIndex: function () { return undefined; }, 8467 setTabIndexForListItemChildren: function () { return undefined; }, 8468 getPrimaryTextAtIndex: function () { return ''; }, 8469 }; 8470 }, 8471 enumerable: true, 8472 configurable: true 8473 }); 8474 MDCListFoundation.prototype.layout = function () { 8475 if (this.adapter.getListItemCount() === 0) { 8476 return; 8477 } 8478 // TODO(b/172274142): consider all items when determining the list's type. 8479 if (this.adapter.hasCheckboxAtIndex(0)) { 8480 this.isCheckboxList_ = true; 8481 } 8482 else if (this.adapter.hasRadioAtIndex(0)) { 8483 this.isRadioList_ = true; 8484 } 8485 else { 8486 this.maybeInitializeSingleSelection(); 8487 } 8488 if (this.hasTypeahead) { 8489 this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex(); 8490 } 8491 }; 8492 /** 8493 * Sets the private wrapFocus_ variable. 8494 */ 8495 MDCListFoundation.prototype.setWrapFocus = function (value) { 8496 this.wrapFocus_ = value; 8497 }; 8498 /** 8499 * Sets the isVertical_ private variable. 8500 */ 8501 MDCListFoundation.prototype.setVerticalOrientation = function (value) { 8502 this.isVertical_ = value; 8503 }; 8504 /** 8505 * Sets the isSingleSelectionList_ private variable. 8506 */ 8507 MDCListFoundation.prototype.setSingleSelection = function (value) { 8508 this.isSingleSelectionList_ = value; 8509 if (value) { 8510 this.maybeInitializeSingleSelection(); 8511 } 8512 }; 8513 /** 8514 * Automatically determines whether the list is single selection list. If so, 8515 * initializes the internal state to match the selected item. 8516 */ 8517 MDCListFoundation.prototype.maybeInitializeSingleSelection = function () { 8518 var listItemsCount = this.adapter.getListItemCount(); 8519 for (var i = 0; i < listItemsCount; i++) { 8520 var hasSelectedClass = this.adapter.listItemAtIndexHasClass(i, cssClasse
8520s$n.LIST_ITEM_SELECTED_CLASS); 8521 var hasActivatedClass = this.adapter.listItemAtIndexHasClass(i, cssClasses$n.LIST_ITEM_ACTIVATED_CLASS); 8522 if (!(hasSelectedClass || hasActivatedClass)) { 8523 continue; 8524 } 8525 if (hasActivatedClass) { 8526 this.setUseActivatedClass(true); 8527 } 8528 this.isSingleSelectionList_ = true; 8529 this.selectedIndex_ = i; 8530 return; 8531 } 8532 }; 8533 /** 8534 * Sets whether typeahead is enabled on the list. 8535 * @param hasTypeahead Whether typeahead is enabled. 8536 */ 8537 MDCListFoundation.prototype.setHasTypeahead = function (hasTypeahead) { 8538 this.hasTypeahead = hasTypeahead; 8539 if (hasTypeahead) { 8540 this.sortedIndexByFirstChar = this.typeaheadInitSortedIndex(); 8541 } 8542 }; 8543 /** 8544 * @return Whether typeahead is currently matching a user-specified prefix. 8545 */ 8546 MDCListFoundation.prototype.isTypeaheadInProgress = function () { 8547 return this.hasTypeahead && 8548 isTypingInProgress(this.typeaheadState); 8549 }; 8550 /** 8551 * Sets the useActivatedClass_ private variable. 8552 */ 8553 MDCListFoundation.prototype.setUseActivatedClass = function (useActivated) { 8554 this.useActivatedClass_ = useActivated; 8555 }; 8556 /** 8557 * Sets the useSelectedAttr_ private variable. 8558 */ 8559 MDCListFoundation.prototype.setUseSelectedAttribute = function (useSelected) { 8560 this.useSelectedAttr_ = useSelected; 8561 }; 8562 MDCListFoundation.prototype.getSelectedIndex = function () { 8563 return this.selectedIndex_; 8564 }; 8565 MDCListFoundation.prototype.setSelectedIndex = function (index) { 8566 if (!this.isIndexValid_(index)) { 8567 return; 8568 } 8569 if (this.isCheckboxList_) { 8570 this.setCheckboxAtIndex_(index); 8571 } 8572 else if (this.isRadioList_) { 8573 this.setRadioAtIndex_(index); 8574 } 8575 else { 8576 this.setSingleSelectionAtIndex_(index); 8577 } 8578 }; 8579 /** 8580 * Focus in handler for the list items. 8581 */ 8582 MDCListFoundation.prototype.handleFocusIn = function (_, listItemIndex) { 8583 if (listItemIndex >= 0) { 8584 this.focusedItemIndex = listItemIndex; 8585 this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '0'); 8586 this.adapter.setTabIndexForListItemChildren(listItemIndex, '0'); 8587 } 8588 }; 8589 /** 8590 * Focus out handler for the list items. 8591 */ 8592 MDCListFoundation.prototype.handleFocusOut = function (_, listItemIndex) { 8593 var _this = this; 8594 if (listItemIndex >= 0) { 8595 this.adapter.setAttributeForElementIndex(listItemIndex, 'tabindex', '-1'); 8596 this.adapter.setTabIndexForListItemChildren(listItemIndex, '-1'); 8597 } 8598 /** 8599 * Between Focusout & Focusin some browsers do not have focus on any 8600 * element. Setting a delay to wait till the focus is moved to next element. 8601 */ 8602 setTimeout(function () { 8603 if (!_this.adapter.isFocusInsideList()) { 8604 _this.setTabindexToFirstSelectedOrFocusedItem(); 8605 } 8606 }, 0); 8607 }; 8608 /** 8609 * Key handler for the list. 8610 */ 8611 MDCListFoundation.prototype.handleKeydown = function (event, isRootListItem, listItemIndex) { 8612 var _this = this; 8613 var isArrowLeft = normalizeKey(event) === 'ArrowLeft'; 8614 var isArrowUp = normalizeKey(event) === 'ArrowUp'; 8615 var isArrowRight = normalizeKey(event) === 'ArrowRight'; 8616 var isArrowDown = normalizeKey(event) === 'ArrowDown'; 8617 var isHome = normalizeKey(event) === 'Home'; 8618 var isEnd = normalizeKey(event) === 'End'; 8619 var isEnter = normalizeKey(event) === 'Enter'; 8620 var isSpace = normalizeKey(event) === 'Spacebar'; 8621 // Have to check both upper and lower case, because having caps lock on affects the value. 8622 var isLetterA = event.key === 'A' || event.key === 'a'; 8623 if (this.adapter.isRootFocused()) { 8624 if (isArrowUp || isEnd) { 8625 event.preventDefault(); 8626 this.focusLastElement(); 8627 } 8628 else if (isArrowDown || isHome) { 8629 event.preventDefault(); 8630 this.focusFirstElement(); 8631 } 8632 if (this.hasTypeahead) { 8633 var handleKeydownOpts = { 8634 event: event, 8635 focusItemAtIndex: function (index) { 8636 _this.focusItemAtIndex(index); 8637 }, 8638 focusedItemIndex: -1, 8639 isTargetListItem: isRootListItem, 8640 sortedIndexByFirstChar: this.sortedIndexByFirstChar, 8641 isItemAtIndexDisabled: function (index) { 8642 return _this.adapter.listItemAtIndexHasClass(index, cssClasse
vendor: 5,575 bytes, lines 8642-8786
8642s$n.LIST_ITEM_DISABLED_CLASS); 8643 }, 8644 }; 8645 handleKeydown(handleKeydownOpts, this.typeaheadState); 8646 } 8647 return; 8648 } 8649 var currentIndex = this.adapter.getFocusedElementIndex(); 8650 if (currentIndex === -1) { 8651 currentIndex = listItemIndex; 8652 if (currentIndex < 0) { 8653 // If this event doesn't have a mdc-list-item ancestor from the 8654 // current list (not from a sublist), return early. 8655 return; 8656 } 8657 } 8658 if ((this.isVertical_ && isArrowDown) || 8659 (!this.isVertical_ && isArrowRight)) { 8660 preventDefaultEvent(event); 8661 this.focusNextElement(currentIndex); 8662 } 8663 else if ((this.isVertical_ && isArrowUp) || (!this.isVertical_ && isArrowLeft)) { 8664 preventDefaultEvent(event); 8665 this.focusPrevElement(currentIndex); 8666 } 8667 else if (isHome) { 8668 preventDefaultEvent(event); 8669 this.focusFirstElement(); 8670 } 8671 else if (isEnd) { 8672 preventDefaultEvent(event); 8673 this.focusLastElement(); 8674 } 8675 else if (isLetterA && event.ctrlKey && this.isCheckboxList_) { 8676 event.preventDefault(); 8677 this.toggleAll(this.selectedIndex_ === numbers$9.UNSET_INDEX ? [] : this.selectedIndex_); 8678 } 8679 else if (isEnter || isSpace) { 8680 if (isRootListItem) { 8681 // Return early if enter key is pressed on anchor element which triggers 8682 // synthetic MouseEvent event. 8683 var target = event.target; 8684 if (target && target.tagName === 'A' && isEnter) { 8685 return; 8686 } 8687 preventDefaultEvent(event); 8688 if (this.adapter.listItemAtIndexHasClass(currentIndex, cssClasses$n.LIST_ITEM_DISABLED_CLASS)) { 8689 return; 8690 } 8691 if (!this.isTypeaheadInProgress()) { 8692 if (this.isSelectableList_()) { 8693 this.setSelectedIndexOnAction_(currentIndex); 8694 } 8695 this.adapter.notifyAction(currentIndex); 8696 } 8697 } 8698 } 8699 if (this.hasTypeahead) { 8700 var handleKeydownOpts = { 8701 event: event, 8702 focusItemAtIndex: function (index) { 8703 _this.focusItemAtIndex(index); 8704 }, 8705 focusedItemIndex: this.focusedItemIndex, 8706 isTargetListItem: isRootListItem, 8707 sortedIndexByFirstChar: this.sortedIndexByFirstChar, 8708 isItemAtIndexDisabled: function (index) { return _this.adapter.listItemAtIndexHasClass(index, cssClasses$n.LIST_ITEM_DISABLED_CLASS); }, 8709 }; 8710 handleKeydown(handleKeydownOpts, this.typeaheadState); 8711 } 8712 }; 8713 /** 8714 * Click handler for the list. 8715 */ 8716 MDCListFoundation.prototype.handleClick = function (index, toggleCheckbox) { 8717 if (index === numbers$9.UNSET_INDEX) { 8718 return; 8719 } 8720 if (this.adapter.listItemAtIndexHasClass(index, cssClasses$n.LIST_ITEM_DISABLED_CLASS)) { 8721 return; 8722 } 8723 if (this.isSelectableList_()) { 8724 this.setSelectedIndexOnAction_(index, toggleCheckbox); 8725 } 8726 this.adapter.notifyAction(index); 8727 }; 8728 /** 8729 * Focuses the next element on the list. 8730 */ 8731 MDCListFoundation.prototype.focusNextElement = function (index) { 8732 var count = this.adapter.getListItemCount(); 8733 var nextIndex = index + 1; 8734 if (nextIndex >= count) { 8735 if (this.wrapFocus_) { 8736 nextIndex = 0; 8737 } 8738 else { 8739 // Return early because last item is already focused. 8740 return index; 8741 } 8742 } 8743 this.focusItemAtIndex(nextIndex); 8744 return nextIndex; 8745 }; 8746 /** 8747 * Focuses the previous element on the list. 8748 */ 8749 MDCListFoundation.prototype.focusPrevElement = function (index) { 8750 var prevIndex = index - 1; 8751 if (prevIndex < 0) { 8752 if (this.wrapFocus_) { 8753 prevIndex = this.adapter.getListItemCount() - 1; 8754 } 8755 else { 8756 // Return early because first item is already focused. 8757 return index; 8758 } 8759 } 8760 this.focusItemAtIndex(prevIndex); 8761 return prevIndex; 8762 }; 8763 MDCListFoundation.prototype.focusFirstElement = function () { 8764 this.focusItemAtIndex(0); 8765 return 0; 8766 }; 8767 MDCListFoundation.prototype.focusLastElement = function () { 8768 var lastIndex = this.adapter.getListItemCount() - 1; 8769 this.focusItemAtIndex(lastIndex); 8770 return lastIndex; 8771 }; 8772 MDCListFoundation.prototype.focusInitialElement = function () { 8773 var initialIndex = this.getFirstSelectedOrFocusedItemIndex(); 8774 this.focusItemAtIndex(initialIndex); 8775 return initialIndex; 8776 }; 8777 /** 8778 * @param itemIndex Index of the list item 8779 * @param isEnabled Sets the list item to enabled or disabled. 8780 */ 8781 MDCListFoundation.prototype.setEnabled = function (itemIndex, isEnabled) { 8782 if (!this.isIndexValid_(itemIndex)) { 8783 return; 8784 } 8785 if (isEnabled) { 8786 this.adapter.removeClassForElementIndex(itemIndex, cssClasse
8786s$n.LIST_ITEM_DISABLED_CLASS); 8787 this.adapter.setAttributeForElementIndex(itemIndex, strings$r.ARIA_DISABLED, 'false'); 8788 } 8789 else { 8790 this.adapter.addClassForElementIndex(itemIndex, cssClasses$n.LIST_ITEM_DISABLED_CLASS); 8791 this.adapter.setAttributeForElementIndex(itemIndex, strings$r.ARIA_DISABLED, 'true'); 8792 } 8793 }; 8794 MDCListFoundation.prototype.setSingleSelectionAtIndex_ = function (index) { 8795 if (this.selectedIndex_ === index) { 8796 return; 8797 } 8798 var selectedClassName = cssClasses$n.LIST_ITEM_SELECTED_CLASS; 8799 if (this.useActivatedClass_) { 8800 selectedClassName = cssClasses$n.LIST_ITEM_ACTIVATED_CLASS; 8801 } 8802 if (this.selectedIndex_ !== numbers$9.UNSET_INDEX) { 8803 this.adapter.removeClassForElementIndex(this.selectedIndex_, selectedClassName); 8804 } 8805 this.setAriaForSingleSelectionAtIndex_(index); 8806 this.setTabindexAtIndex(index); 8807 if (index !== numbers$9.UNSET_INDEX) { 8808 this.adapter.addClassForElementIndex(index, selectedClassName); 8809 } 8810 this.selectedIndex_ = index; 8811 }; 8812 /** 8813 * Sets aria attribute for single selection at given index. 8814 */ 8815 MDCListFoundation.prototype.setAriaForSingleSelectionAtIndex_ = function (index) { 8816 // Detect the presence of aria-current and get the value only during list 8817 // initialization when it is in unset state. 8818 if (this.selectedIndex_ === numbers$9.UNSET_INDEX) { 8819 this.ariaCurrentAttrValue_ = 8820 this.adapter.getAttributeForElementIndex(index, strings$r.ARIA_CURRENT); 8821 } 8822 var isAriaCurrent = this.ariaCurrentAttrValue_ !== null; 8823 var ariaAttribute = isAriaCurrent ? strings$r.ARIA_CURRENT : strings$r.ARIA_SELECTED; 8824 if (this.selectedIndex_ !== numbers$9.UNSET_INDEX) { 8825 this.adapter.setAttributeForElementIndex(this.selectedIndex_, ariaAttribute, 'false'); 8826 } 8827 if (index !== numbers$9.UNSET_INDEX) { 8828 var ariaAttributeValue = isAriaCurrent ? this.ariaCurrentAttrValue_ : 'true'; 8829 this.adapter.setAttributeForElementIndex(index, ariaAttribute, ariaAttributeValue); 8830 } 8831 }; 8832 /** 8833 * Returns the attribute to use for indicating selection status. 8834 */ 8835 MDCListFoundation.prototype.getSelectionAttribute = function () { 8836 return this.useSelectedAttr_ ? strings$r.ARIA_SELECTED : strings$r.ARIA_CHECKED; 8837 }; 8838 /** 8839 * Toggles radio at give index. Radio doesn't change the checked state if it 8840 * is already checked. 8841 */ 8842 MDCListFoundation.prototype.setRadioAtIndex_ = function (index) { 8843 var selectionAttribute = this.getSelectionAttribute(); 8844 this.adapter.setCheckedCheckboxOrRadioAtIndex(index, true); 8845 if (this.selectedIndex_ !== numbers$9.UNSET_INDEX) { 8846 this.adapter.setAttributeForElementIndex(this.selectedIndex_, selectionAttribute, 'false'); 8847 } 8848 this.adapter.setAttributeForElementIndex(index, selectionAttribute, 'true'); 8849 this.selectedIndex_ = index; 8850 }; 8851 MDCListFoundation.prototype.setCheckboxAtIndex_ = function (index) { 8852 var selectionAttribute = this.getSelectionAttribute(); 8853 for (var i = 0; i < this.adapter.getListItemCount(); i++) { 8854 var isChecked = false; 8855 if (index.indexOf(i) >= 0) { 8856 isChecked = true; 8857 } 8858 this.adapter.setCheckedCheckboxOrRadioAtIndex(i, isChecked); 8859 this.adapter.setAttributeForElementIndex(i, selectionAttribute, isChecked ? 'true' : 'false'); 8860 } 8861 this.selectedIndex_ = index; 8862 }; 8863 MDCListFoundation.prototype.setTabindexAtIndex = function (index) { 8864 if (this.focusedItemIndex === numbers$9.UNSET_INDEX && index !== 0) { 8865 // If some list item was selected set first list item's tabindex to -1. 8866 // Generally, tabindex is set to 0 on first list item of list that has no 8867 // preselected items. 8868 this.adapter.setAttributeForElementIndex(0, 'tabindex', '-1'); 8869 } 8870 else if (this.focusedItemIndex >= 0 && this.focusedItemIndex !== index) { 8871 this.adapter.setAttributeForElementIndex(this.focusedItemIndex, 'tabindex', '-1'); 8872 } 8873 // Set the previous selection's tabindex to -1. We need this because 8874 // in selection menus that are not visible, programmatically setting an 8875 // option will not change focus but will change where tabindex should be 0. 8876 if (!(this.selectedIndex_ instanceof Array) && 8877 this.selectedIndex_ !== index) { 8878 this.adapter.setAttributeForElementIndex(this.selectedIndex_, 'tabindex', '-1'); 8879 } 8880 if (index !== numbers$9.UNSET_INDEX) { 8881 this.adapter.setAttributeForElementIndex(index, 'tabindex', '0'); 8882 } 8883 }; 8884 /** 8885 * @return Return true if it is single selectin list, checkbox list or radio 8886 * list. 8887 */ 8888 MDCListFoundation.prototype.isSelectableList_ = function () { 8889 return this.isSingleSelectionList_ || this.isCheckboxList_ || 8890 this.isRadioList_; 8891 }; 8892 MDCListFoundation.prototype.setTabindexToFirstSelectedOrFocusedItem = function () { 8893 var targetIndex = this.getFirstSelectedOrFocusedItemIndex(); 8894 this.setTabindexAtIndex(targetIndex); 8895 }; 8896 MDCListFoundation.prototype.getFirstSelectedOrFocusedItemIndex = function () { 8897 var targetIndex = this.focusedItemIndex >= 0 ? this.focusedItemIndex : 0; 8898 if (this.isSelectableList_()) { 8899 if (typeof this.selectedIndex_ === 'number' && 8900 this.selectedIndex_ !== numbers$9.UNSET_INDEX) { 8901 targetIndex = this.selectedIndex_; 8902 } 8903 else if (isNumberArray(this.selectedIndex_) && 8904 this.selectedIndex_.length > 0) { 8905 targetIndex = this.selectedIndex_.reduce(function (currentIndex, minIndex) { return Math.min(currentIndex, minIndex); }); 8906 } 8907 } 8908 return targetIndex; 8909 }; 8910 MDCListFoundation.prototype.isIndexValid_ = function (index) { 8911 var _this = this; 8912 if (index instanceof Array) { 8913 if (!this.isCheckboxList_) { 8914 throw new Error('MDCListFoundation: Array of index is only supported for checkbox based list'); 8915 } 8916 if (index.length === 0) { 8917 return true; 8918 } 8919 else { 8920 return index.some(function (i) { return _this.isIndexInRange_(i); }); 8921 } 8922 } 8923 else if (typeof index === 'number') { 8924 if (this.isCheckboxList_) { 8925 throw new Error("MDCListFoundation: Expected array of index for checkbox based list but got number: " + index); 8926 } 8927 return this.isIndexInRange_(index) || 8928 this.isSingleSelectionList_ && index === numbers$9.UNSET_INDEX; 8929 } 8930 else { 8931 return false;
vendor: 2,471 bytes, lines 8932-8987
8932 } 8933 }; 8934 MDCListFoundation.prototype.isIndexInRange_ = function (index) { 8935 var listSize = this.adapter.getListItemCount(); 8936 return index >= 0 && index < listSize; 8937 }; 8938 /** 8939 * Sets selected index on user action, toggles checkbox / radio based on 8940 * toggleCheckbox value. User interaction should not toggle list item(s) when 8941 * disabled. 8942 */ 8943 MDCListFoundation.prototype.setSelectedIndexOnAction_ = function (index, toggleCheckbox) { 8944 if (toggleCheckbox === void 0) { toggleCheckbox = true; } 8945 if (this.isCheckboxList_) { 8946 this.toggleCheckboxAtIndex_(index, toggleCheckbox); 8947 } 8948 else { 8949 this.setSelectedIndex(index); 8950 } 8951 }; 8952 MDCListFoundation.prototype.toggleCheckboxAtIndex_ = function (index, toggleCheckbox) { 8953 var selectionAttribute = this.getSelectionAttribute(); 8954 var isChecked = this.adapter.isCheckboxCheckedAtIndex(index); 8955 if (toggleCheckbox) { 8956 isChecked = !isChecked; 8957 this.adapter.setCheckedCheckboxOrRadioAtIndex(index, isChecked); 8958 } 8959 this.adapter.setAttributeForElementIndex(index, selectionAttribute, isChecked ? 'true' : 'false'); 8960 // If none of the checkbox items are selected and selectedIndex is not 8961 // initialized then provide a default value. 8962 var selectedIndexes = this.selectedIndex_ === numbers$9.UNSET_INDEX ? 8963 [] : 8964 this.selectedIndex_.slice(); 8965 if (isChecked) { 8966 selectedIndexes.push(index); 8967 } 8968 else { 8969 selectedIndexes = selectedIndexes.filter(function (i) { return i !== index; }); 8970 } 8971 this.selectedIndex_ = selectedIndexes; 8972 }; 8973 MDCListFoundation.prototype.focusItemAtIndex = function (index) { 8974 this.adapter.focusItemAtIndex(index); 8975 this.focusedItemIndex = index; 8976 }; 8977 MDCListFoundation.prototype.toggleAll = function (currentlySelectedIndexes) { 8978 var count = this.adapter.getListItemCount(); 8979 // If all items are selected, deselect everything. 8980 if (currentlySelectedIndexes.length === count) { 8981 this.setCheckboxAtIndex_([]); 8982 } 8983 else { 8984 // Otherwise select all enabled options. 8985 var allIndexes = []; 8986 for (var i = 0; i < count; i++) { 8987 if (!this.adapter.listItemAtIndexHasClass(i, cssClasse
8987s$n.LIST_ITEM_DISABLED_CLASS) || 8988 currentlySelectedIndexes.indexOf(i) > -1) { 8989 allIndexes.push(i); 8990 } 8991 } 8992 this.setCheckboxAtIndex_(allIndexes); 8993 } 8994 }; 8995 /** 8996 * Given the next desired character from the user, adds it to the typeahead 8997 * buffer. Then, attempts to find the next option matching the buffer. Wraps 8998 * around if at the end of options. 8999 * 9000 * @param nextChar The next character to add to the prefix buffer. 9001 * @param startingIndex The index from which to start matching. Only relevant 9002 * when starting a new match sequence. To start a new match sequence, 9003 * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer 9004 * to clear after a set interval defined in list foundation. Defaults to 9005 * the currently focused index. 9006 * @return The index of the matched item, or -1 if no match. 9007 */ 9008 MDCListFoundation.prototype.typeaheadMatchItem = function (nextChar, startingIndex, skipFocus) { 9009 var _this = this; 9010 if (skipFocus === void 0) { skipFocus = false; } 9011 var opts = { 9012 focusItemAtIndex: function (index) { 9013 _this.focusItemAtIndex(index); 9014 }, 9015 focusedItemIndex: startingIndex ? startingIndex : this.focusedItemIndex, 9016 nextChar: nextChar, 9017 sortedIndexByFirstChar: this.sortedIndexByFirstChar, 9018 skipFocus: skipFocus, 9019 isItemAtIndexDisabled: function (index) { return _this.adapter.listItemAtIndexHasClass(index, cssClasse
9019s$n.LIST_ITEM_DISABLED_CLASS); } 9020 }; 9021 return matchItem(opts, this.typeaheadState); 9022 }; 9023 /** 9024 * Initializes the MDCListTextAndIndex data structure by indexing the current 9025 * list items by primary text. 9026 * 9027 * @return The primary texts of all the list items sorted by first character. 9028 */ 9029 MDCListFoundation.prototype.typeaheadInitSortedIndex = function () { 9030 return initSortedIndex(this.adapter.getListItemCount(), this.adapter.getPrimaryTextAtIndex); 9031 }; 9032 /** 9033 * Clears the typeahead buffer. 9034 */ 9035 MDCListFoundation.prototype.clearTypeaheadBuffer = function () { 9036 clearBuffer(this.typeaheadState); 9037 }; 9038 return MDCListFoundation; 9039 }(MDCFoundation)); 9040 9041 /** 9042 * @license 9043 * Copyright 2018 Google Inc. 9044 * 9045 * Permission is hereby granted, free of charge, to any person obtaining a copy 9046 * of this software and associated documentation files (the "Software"), to deal 9047 * in the Software without restriction, including without limitation the rights 9048 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9049 * copies of the Software, and to permit persons to whom the Software is 9050 * furnished to do so, subject to the following conditions: 9051 * 9052 * The above copyright notice and this permission notice shall be included in 9053 * all copies or substantial portions of the Software. 9054 * 9055 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 9056 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9057 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9058 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9059 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9060 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 9061 * THE SOFTWARE. 9062 */ 9063 var MDCList = /** @class */ (function (_super) { 9064 __extends(MDCList, _super); 9065 function MDCList() { 9066 return _super !== null && _super.apply(this, arguments) || this; 9067 } 9068 Object.defineProperty(MDCList.prototype, "vertical", { 9069 set: function (value) { 9070 this.foundation.setVerticalOrientation(value); 9071 }, 9072 enumerable: true, 9073 configurable: true 9074 }); 9075 Object.defineProperty(MDCList.prototype, "listElements", { 9076 get: function () { 9077 return Array.from(this.root.querySelectorAll("." + this.classNameMap[cssClasses$n.LIST_ITEM_CLASS])); 9078 }, 9079 enumerable: true, 9080 configurable: true 9081 }); 9082 Object.defineProperty(MDCList.prototype, "wrapFocus", { 9083 set: function (value) { 9084 this.foundation.setWrapFocus(value); 9085 }, 9086 enumerable: true, 9087 configurable: true 9088 }); 9089 Object.defineProperty(MDCList.prototype, "typeaheadInProgress", { 9090 /** 9091 * @return Whether typeahead is currently matching a user-specified prefix. 9092 */ 9093 get: function () { 9094 return this.foundation.isTypeaheadInProgress(); 9095 }, 9096 enumerable: true, 9097 configurable: true 9098 }); 9099 Object.defineProperty(MDCList.prototype, "hasTypeahead", { 9100 /** 9101 * Sets whether typeahead functionality is enabled on the list. 9102 * @param hasTypeahead Whether typeahead is enabled. 9103 */ 9104 set: function (hasTypeahead) { 9105 this.foundation.setHasTypeahead(hasTypeahead); 9106 }, 9107 enumerable: true, 9108 configurable: true 9109 }); 9110 Object.defineProperty(MDCList.prototype, "singleSelection", { 9111 set: function (isSingleSelectionList) { 9112 this.foundation.setSingleSelection(isSingleSelectionList); 9113 }, 9114 enumerable: true, 9115 configurable: true 9116 }); 9117 Object.defineProperty(MDCList.prototype, "selectedIndex", { 9118 get: function () { 9119 return this.foundation.getSelectedIndex(); 9120 }, 9121 set: function (index) { 9122 this.foundation.setSelectedIndex(index); 9123 }, 9124 enumerable: true, 9125 configurable: true 9126 }); 9127 MDCList.attachTo = function (root) { 9128 return new MDCList(root); 9129 }; 9130 MDCList.prototype.initialSyncWithDOM = function () { 9131 this.isEvolutionEnabled = 9132 evolutionAttribute in this.root.dataset; 9133 this.classNameMap = this.isEvolutionEnabled ? 9134 evolutionClassNameMap :
9135 Object.values(cssClasses$n) 9136 .reduce(function (obj, className) { 9137 obj[className] = className; 9138 return obj; 9139 }, {}); 9140 this.handleClick = this.handleClickEvent.bind(this); 9141 this.handleKeydown = this.handleKeydownEvent.bind(this); 9142 this.focusInEventListener = this.handleFocusInEvent.bind(this); 9143 this.focusOutEventListener = this.handleFocusOutEvent.bind(this); 9144 this.listen('keydown', this.handleKeydown); 9145 this.listen('click', this.handleClick); 9146 this.listen('focusin', this.focusInEventListener); 9147 this.listen('focusout', this.focusOutEventListener); 9148 this.layout(); 9149 this.initializeListType(); 9150 this.ensureFocusable(); 9151 }; 9152 MDCList.prototype.destroy = function () { 9153 this.unlisten('keydown', this.handleKeydown); 9154 this.unlisten('click', this.handleClick); 9155 this.unlisten('focusin', this.focusInEventListener); 9156 this.unlisten('focusout', this.focusOutEventListener); 9157 }; 9158 MDCList.prototype.layout = function () { 9159 var direction = this.root.getAttribute(strings$r.ARIA_ORIENTATION); 9160 this.vertical = direction !== strings$r.ARIA_ORIENTATION_HORIZONTAL; 9161 var itemSelector = "." + this.classNameMap[cssClasses$n.LIST_ITEM_CLASS] + ":not([tabindex])"; 9162 var childSelector = "." + this.classNameMap[cssClasses$n.LIST_ITEM_CLASS] + " " + strings$r.FOCUSABLE_CHILD_ELEMENTS; 9163 // List items need to have at least tabindex=-1 to be focusable. 9164 Array.prototype.forEach.call(this.root.querySelectorAll(itemSelector), function (el) { 9165 el.setAttribute('tabindex', '-1'); 9166 }); 9167 // Child button/a elements are not tabbable until the list item is focused. 9168 Array.prototype.forEach.call(this.root.querySelectorAll(childSelector), function (el) { 9169 el.setAttribute('tabindex', '-1'); 9170 }); 9171 if (this.isEvolutionEnabled) { 9172 this.foundation.setUseSelectedAttribute(true); 9173 } 9174 this.foundation.layout(); 9175 }; 9176 /** 9177 * Extracts the primary text from a list item. 9178 * @param item The list item element. 9179 * @return The primary text in the element. 9180 */ 9181 MDCList.prototype.getPrimaryText = function (item) { 9182 var _a; 9183 var primaryText = item.querySelector("." + this.classNameMap[cssClasses$n.LIST_ITEM_PRIMARY_TEXT_CLASS]); 9184 if (this.isEvolutionEnabled || primaryText) { 9185 return (_a = primaryText === null || primaryText === void 0 ? void 0 : primaryText.textContent) !== null && _a !== void 0 ? _a : ''; 9186 } 9187 var singleLineText = item.querySelector("." + this.classNameMap[cssClasses$n.LIST_ITEM_TEXT_CLASS]); 9188 return (singleLineText && singleLineText.textContent) || ''; 9189 }; 9190 /** 9191 * Initialize selectedIndex value based on pre-selected list items. 9192 */ 9193 MDCList.prototype.initializeListType = function () { 9194 var _this = this; 9195 this.isInteractive = 9196 matches$1(this.root, strings$r.ARIA_INTERACTIVE_ROLES_SELECTOR); 9197 if (this.isEvolutionEnabled && this.isInteractive) { 9198 var selection = Array.from(this.root.querySelectorAll(strings$r.SELECTED_ITEM_SELECTOR), function (listItem) { return _this.listElements.indexOf(listItem); }); 9199 if (matches$1(this.root, strings$r.ARIA_MULTI_SELECTABLE_SELECTOR)) { 9200 this.selectedIndex = selection; 9201 } 9202 else if (selection.length > 0) { 9203 this.selectedIndex = selection[0]; 9204 } 9205 return; 9206 } 9207 var checkboxListItems = this.root.querySelectorAll(strings$r.ARIA_ROLE_CHECKBOX_SELECTOR); 9208 var radioSelectedListItem = this.root.querySelector(strings$r.ARIA_CHECKED_RADIO_SELECTOR); 9209 if (checkboxListItems.length) { 9210 var preselectedItems = this.root.querySelectorAll(strings$r.ARIA_CHECKED_CHECKBOX_SELECTOR); 9211 this.selectedIndex = Array.from(preselectedItems, function (listItem) { return _this.listElements.indexOf(listItem); }); 9212 } 9213 else if (radioSelectedListItem) { 9214 this.selectedIndex = this.listElements.indexOf(radioSelectedListItem); 9215 } 9216 }; 9217 /** 9218 * Updates the list item at itemIndex to the desired isEnabled state. 9219 * @param itemIndex Index of the list item 9220 * @param isEnabled Sets the list item to enabled or disabled. 9221 */ 9222 MDCList.prototype.setEnabled = function (itemIndex, isEnabled) { 9223 this.foundation.setEnabled(itemIndex, isEnabled); 9224 }; 9225 /** 9226 * Given the next desired character from the user, adds it to the typeahead 9227 * buffer. Then, attempts to find the next option matching the buffer. Wraps 9228 * around if at the end of options. 9229 * 9230 * @param nextChar The next character to add to the prefix buffer. 9231 * @param startingIndex The index from which to start matching. Defaults to 9232 * the currently focused index. 9233 * @return The index of the matched item. 9234 */ 9235 MDCList.prototype.typeaheadMatchItem = function (nextChar, startingIndex) { 9236 return this.foundation.typeaheadMatchItem(nextChar, startingIndex, /** skipFocus */ true); 9237 }; 9238 MDCList.prototype.getDefaultFoundation = function () { 9239 var _this = this; 9240 // DO NOT INLINE this variable. For backward compatibility, foundations take 9241 // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any 9242 // methods, we need a separate, strongly typed adapter variable. 9243 var adapter = {
9244 addClassForElementIndex: function (index, className) { 9245 var element = _this.listElements[index]; 9246 if (element) { 9247 element.classList.add(_this.classNameMap[className]); 9248 } 9249 }, 9250 focusItemAtIndex: function (index) { 9251 var element = _this.listElements[index]; 9252 if (element) { 9253 element.focus(); 9254 } 9255 }, 9256 getAttributeForElementIndex: function (index, attr) { 9257 return _this.listElements[index].getAttribute(attr); 9258 }, 9259 getFocusedElementIndex: function () { 9260 return _this.listElements.indexOf(document.activeElement); 9261 }, 9262 getListItemCount: function () { return _this.listElements.length; }, 9263 getPrimaryTextAtIndex: function (index) { 9264 return _this.getPrimaryText(_this.listElements[index]); 9265 }, 9266 hasCheckboxAtIndex: function (index) { 9267 var listItem = _this.listElements[index]; 9268 return !!listItem.querySelector(strings$r.CHECKBOX_SELECTOR); 9269 }, 9270 hasRadioAtIndex: function (index) { 9271 var listItem = _this.listElements[index]; 9272 return !!listItem.querySelector(strings$r.RADIO_SELECTOR); 9273 }, 9274 isCheckboxCheckedAtIndex: function (index) { 9275 var listItem = _this.listElements[index]; 9276 var toggleEl = listItem.querySelector(strings$r.CHECKBOX_SELECTOR); 9277 return toggleEl.checked; 9278 }, 9279 isFocusInsideList: function () { 9280 return _this.root !== document.activeElement && 9281 _this.root.contains(document.activeElement); 9282 }, 9283 isRootFocused: function () { return document.activeElement === _this.root; }, 9284 listItemAtIndexHasClass: function (index, className) { 9285 return _this.listElements[index].classList.contains(_this.classNameMap[className]); 9286 }, 9287 notifyAction: function (index) { 9288 _this.emit(strings$r.ACTION_EVENT, { index: index }, /** shouldBubble */ true); 9289 }, 9290 removeClassForElementIndex: function (index, className) { 9291 var element = _this.listElements[index]; 9292 if (element) { 9293 element.classList.remove(_this.classNameMap[className]); 9294 } 9295 }, 9296 setAttributeForElementIndex: function (index, attr, value) { 9297 var element = _this.listElements[index]; 9298 if (element) { 9299 element.setAttribute(attr, value); 9300 } 9301 }, 9302 setCheckedCheckboxOrRadioAtIndex: function (index, isChecked) { 9303 var listItem = _this.listElements[index]; 9304 var toggleEl = listItem.querySelector(strings$r.CHECKBOX_RADIO_SELECTOR); 9305 toggleEl.checked = isChecked; 9306 var event = document.createEvent('Event'); 9307 event.initEvent('change', true, true); 9308 toggleEl.dispatchEvent(event); 9309 }, 9310 setTabIndexForListItemChildren: function (listItemIndex, tabIndexValue) { 9311 var element = _this.listElements[listItemIndex]; 9312 var selector = "." + _this.classNameMap[cssClasses$n.LIST_ITEM_CLASS] + " " + strings$r.CHILD_ELEMENTS_TO_TOGGLE_TABINDEX; 9313 Array.prototype.forEach.call(element.querySelectorAll(selector), function (el) { 9314 el.setAttribute('tabindex', tabIndexValue); 9315 }); 9316 }, 9317 }; 9318 return new MDCListFoundation(adapter); 9319 }; 9320 /** 9321 * Ensures that at least one item is focusable if the list is interactive and 9322 * doesn't specify a suitable tabindex. 9323 */ 9324 MDCList.prototype.ensureFocusable = function () { 9325 if (this.isEvolutionEnabled && this.isInteractive) { 9326 if (!this.root.querySelector("." + this.classNameMap[cssClasse
vendor: 4,311 bytes, lines 9326-9422
9326s$n.LIST_ITEM_CLASS] + "[tabindex=\"0\"]")) { 9327 var index = this.initialFocusIndex(); 9328 if (index !== -1) { 9329 this.listElements[index].tabIndex = 0; 9330 } 9331 } 9332 } 9333 }; 9334 MDCList.prototype.initialFocusIndex = function () { 9335 if (this.selectedIndex instanceof Array && this.selectedIndex.length > 0) { 9336 return this.selectedIndex[0]; 9337 } 9338 if (typeof this.selectedIndex === 'number' && 9339 this.selectedIndex !== numbers$9.UNSET_INDEX) { 9340 return this.selectedIndex; 9341 } 9342 var el = this.root.querySelector("." + this.classNameMap[cssClasses$n.LIST_ITEM_CLASS] + ":not(." + this.classNameMap[cssClasses$n.LIST_ITEM_DISABLED_CLASS] + ")"); 9343 if (el === null) { 9344 return -1; 9345 } 9346 return this.getListItemIndex(el); 9347 }; 9348 /** 9349 * Used to figure out which list item this event is targetting. Or returns -1 9350 * if there is no list item 9351 */ 9352 MDCList.prototype.getListItemIndex = function (el) { 9353 var nearestParent = closest(el, "." + this.classNameMap[cssClasses$n.LIST_ITEM_CLASS] + ", ." + this.classNameMap[cssClasses$n.ROOT]); 9354 // Get the index of the element if it is a list item. 9355 if (nearestParent && 9356 matches$1(nearestParent, "." + this.classNameMap[cssClasses$n.LIST_ITEM_CLASS])) { 9357 return this.listElements.indexOf(nearestParent); 9358 } 9359 return -1; 9360 }; 9361 /** 9362 * Used to figure out which element was clicked before sending the event to 9363 * the foundation. 9364 */ 9365 MDCList.prototype.handleFocusInEvent = function (evt) { 9366 var index = this.getListItemIndex(evt.target); 9367 this.foundation.handleFocusIn(evt, index); 9368 }; 9369 /** 9370 * Used to figure out which element was clicked before sending the event to 9371 * the foundation. 9372 */ 9373 MDCList.prototype.handleFocusOutEvent = function (evt) { 9374 var index = this.getListItemIndex(evt.target); 9375 this.foundation.handleFocusOut(evt, index); 9376 }; 9377 /** 9378 * Used to figure out which element was focused when keydown event occurred 9379 * before sending the event to the foundation. 9380 */ 9381 MDCList.prototype.handleKeydownEvent = function (evt) { 9382 var index = this.getListItemIndex(evt.target); 9383 var target = evt.target; 9384 this.foundation.handleKeydown(evt, target.classList.contains(this.classNameMap[cssClasses$n.LIST_ITEM_CLASS]), index); 9385 }; 9386 /** 9387 * Used to figure out which element was clicked before sending the event to 9388 * the foundation. 9389 */ 9390 MDCList.prototype.handleClickEvent = function (evt) { 9391 var index = this.getListItemIndex(evt.target); 9392 var target = evt.target; 9393 // Toggle the checkbox only if it's not the target of the event, or the 9394 // checkbox will have 2 change events. 9395 var toggleCheckbox = !matches$1(target, strings$r.CHECKBOX_RADIO_SELECTOR); 9396 this.foundation.handleClick(index, toggleCheckbox); 9397 }; 9398 return MDCList; 9399 }(MDCComponent)); 9400 9401 /** 9402 * @license 9403 * Copyright 2016 Google Inc. 9404 * 9405 * Permission is hereby granted, free of charge, to any person obtaining a copy 9406 * of this software and associated documentation files (the "Software"), to deal 9407 * in the Software without restriction, including without limitation the rights 9408 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9409 * copies of the Software, and to permit persons to whom the Software is 9410 * furnished to do so, subject to the following conditions: 9411 * 9412 * The above copyright notice and this permission notice shall be included in 9413 * all copies or substantial portions of the Software. 9414 * 9415 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 9416 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9417 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9418 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9419 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9420 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 9421 * THE SOFTWARE. 9422 */
9423 var cssClasses$m = { 9424 ANIMATE: 'mdc-drawer--animate', 9425 CLOSING: 'mdc-drawer--closing', 9426 DISMISSIBLE: 'mdc-drawer--dismissible', 9427 MODAL: 'mdc-drawer--modal', 9428 OPEN: 'mdc-drawer--open', 9429 OPENING: 'mdc-drawer--opening', 9430 ROOT: 'mdc-drawer', 9431 }; 9432 var strings$q = { 9433 APP_CONTENT_SELECTOR: '.mdc-drawer-app-content', 9434 CLOSE_EVENT: 'MDCDrawer:closed', 9435 OPEN_EVENT: 'MDCDrawer:opened', 9436 SCRIM_SELECTOR: '.mdc-drawer-scrim', 9437 }; 9438 9439 /** 9440 * @license 9441 * Copyright 2018 Google Inc. 9442 * 9443 * Permission is hereby granted, free of charge, to any person obtaining a copy 9444 * of this software and associated documentation files (the "Software"), to deal 9445 * in the Software without restriction, including without limitation the rights 9446 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9447 * copies of the Software, and to permit persons to whom the Software is 9448 * furnished to do so, subject to the following conditions: 9449 * 9450 * The above copyright notice and this permission notice shall be included in 9451 * all copies or substantial portions of the Software. 9452 * 9453 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 9454 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9455 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9456 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9457 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9458 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 9459 * THE SOFTWARE. 9460 */ 9461 var MDCDismissibleDrawerFoundation = /** @class */ (function (_super) { 9462 __extends(MDCDismissibleDrawerFoundation, _super); 9463 function MDCDismissibleDrawerFoundation(adapter) { 9464 var _this = _super.call(this, __assign(__assign({}, MDCDismissibleDrawerFoundation.defaultAdapter), adapter)) || this; 9465 _this.animationFrame_ = 0; 9466 _this.animationTimer_ = 0; 9467 return _this; 9468 } 9469 Object.defineProperty(MDCDismissibleDrawerFoundation, "strings", { 9470 get: function () { 9471 return strings$q; 9472 }, 9473 enumerable: true, 9474 configurable: true 9475 }); 9476 Object.defineProperty(MDCDismissibleDrawerFoundation, "cssClasses", { 9477 get: function () { 9478 return cssClasses$m; 9479 }, 9480 enumerable: true, 9481 configurable: true 9482 }); 9483 Object.defineProperty(MDCDismissibleDrawerFoundation, "defaultAdapter", { 9484 get: function () { 9485 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 9486 return { 9487 addClass: function () { return undefined; }, 9488 removeClass: function () { return undefined; }, 9489 hasClass: function () { return false; }, 9490 elementHasClass: function () { return false; }, 9491 notifyClose: function () { return undefined; }, 9492 notifyOpen: function () { return undefined; }, 9493 saveFocus: function () { return undefined; }, 9494 restoreFocus: function () { return undefined; }, 9495 focusActiveNavigationItem: function () { return undefined; }, 9496 trapFocus: function () { return undefined; }, 9497 releaseFocus: function () { return undefined; }, 9498 }; 9499 // tslint:enable:object-literal-sort-keys 9500 }, 9501 enumerable: true, 9502 configurable: true 9503 }); 9504 MDCDismissibleDrawerFoundation.prototype.destroy = function () { 9505 if (this.animationFrame_) { 9506 cancelAnimationFrame(this.animationFrame_); 9507 } 9508 if (this.animationTimer_) { 9509 clearTimeout(this.animationTimer_); 9510 } 9511 }; 9512 /** 9513 * Opens the drawer from the closed state. 9514 */ 9515 MDCDismissibleDrawerFoundation.prototype.open = function () { 9516 var _this = this; 9517 if (this.isOpen() || this.isOpening() || this.isClosing()) { 9518 return; 9519 }
vendor: 7,408 bytes, lines 9520-9692
9520 this.adapter.addClass(cssClasses$m.OPEN); 9521 this.adapter.addClass(cssClasses$m.ANIMATE); 9522 // Wait a frame once display is no longer "none", to establish basis for animation 9523 this.runNextAnimationFrame_(function () { 9524 _this.adapter.addClass(cssClasses$m.OPENING); 9525 }); 9526 this.adapter.saveFocus(); 9527 }; 9528 /** 9529 * Closes the drawer from the open state. 9530 */ 9531 MDCDismissibleDrawerFoundation.prototype.close = function () { 9532 if (!this.isOpen() || this.isOpening() || this.isClosing()) { 9533 return; 9534 } 9535 this.adapter.addClass(cssClasses$m.CLOSING); 9536 }; 9537 /** 9538 * Returns true if the drawer is in the open position. 9539 * @return true if drawer is in open state. 9540 */ 9541 MDCDismissibleDrawerFoundation.prototype.isOpen = function () { 9542 return this.adapter.hasClass(cssClasses$m.OPEN); 9543 }; 9544 /** 9545 * Returns true if the drawer is animating open. 9546 * @return true if drawer is animating open. 9547 */ 9548 MDCDismissibleDrawerFoundation.prototype.isOpening = function () { 9549 return this.adapter.hasClass(cssClasses$m.OPENING) || 9550 this.adapter.hasClass(cssClasses$m.ANIMATE); 9551 }; 9552 /** 9553 * Returns true if the drawer is animating closed. 9554 * @return true if drawer is animating closed. 9555 */ 9556 MDCDismissibleDrawerFoundation.prototype.isClosing = function () { 9557 return this.adapter.hasClass(cssClasses$m.CLOSING); 9558 }; 9559 /** 9560 * Keydown handler to close drawer when key is escape. 9561 */ 9562 MDCDismissibleDrawerFoundation.prototype.handleKeydown = function (evt) { 9563 var keyCode = evt.keyCode, key = evt.key; 9564 var isEscape = key === 'Escape' || keyCode === 27; 9565 if (isEscape) { 9566 this.close(); 9567 } 9568 }; 9569 /** 9570 * Handles the `transitionend` event when the drawer finishes opening/closing. 9571 */ 9572 MDCDismissibleDrawerFoundation.prototype.handleTransitionEnd = function (evt) { 9573 var OPENING = cssClasses$m.OPENING, CLOSING = cssClasses$m.CLOSING, OPEN = cssClasses$m.OPEN, ANIMATE = cssClasses$m.ANIMATE, ROOT = cssClasses$m.ROOT; 9574 // In Edge, transitionend on ripple pseudo-elements yields a target without classList, so check for Element first. 9575 var isRootElement = this.isElement_(evt.target) && 9576 this.adapter.elementHasClass(evt.target, ROOT); 9577 if (!isRootElement) { 9578 return; 9579 } 9580 if (this.isClosing()) { 9581 this.adapter.removeClass(OPEN); 9582 this.closed_(); 9583 this.adapter.restoreFocus(); 9584 this.adapter.notifyClose(); 9585 } 9586 else { 9587 this.adapter.focusActiveNavigationItem(); 9588 this.opened_(); 9589 this.adapter.notifyOpen(); 9590 } 9591 this.adapter.removeClass(ANIMATE); 9592 this.adapter.removeClass(OPENING); 9593 this.adapter.removeClass(CLOSING); 9594 }; 9595 /** 9596 * Extension point for when drawer finishes open animation. 9597 */ 9598 MDCDismissibleDrawerFoundation.prototype.opened_ = function () { }; // tslint:disable-line:no-empty 9599 /** 9600 * Extension point for when drawer finishes close animation. 9601 */ 9602 MDCDismissibleDrawerFoundation.prototype.closed_ = function () { }; // tslint:disable-line:no-empty 9603 /** 9604 * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior. 9605 */ 9606 MDCDismissibleDrawerFoundation.prototype.runNextAnimationFrame_ = function (callback) { 9607 var _this = this; 9608 cancelAnimationFrame(this.animationFrame_); 9609 this.animationFrame_ = requestAnimationFrame(function () { 9610 _this.animationFrame_ = 0; 9611 clearTimeout(_this.animationTimer_); 9612 _this.animationTimer_ = setTimeout(callback, 0); 9613 }); 9614 }; 9615 MDCDismissibleDrawerFoundation.prototype.isElement_ = function (element) { 9616 // In Edge, transitionend on ripple pseudo-elements yields a target without classList. 9617 return Boolean(element.classList); 9618 }; 9619 return MDCDismissibleDrawerFoundation; 9620 }(MDCFoundation)); 9621 9622 /** 9623 * @license 9624 * Copyright 2018 Google Inc. 9625 * 9626 * Permission is hereby granted, free of charge, to any person obtaining a copy 9627 * of this software and associated documentation files (the "Software"), to deal 9628 * in the Software without restriction, including without limitation the rights 9629 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9630 * copies of the Software, and to permit persons to whom the Software is 9631 * furnished to do so, subject to the following conditions: 9632 * 9633 * The above copyright notice and this permission notice shall be included in 9634 * all copies or substantial portions of the Software. 9635 * 9636 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 9637 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9638 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9639 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9640 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9641 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 9642 * THE SOFTWARE. 9643 */ 9644 /* istanbul ignore next: subclass is not a branch statement */ 9645 var MDCModalDrawerFoundation = /** @class */ (function (_super) { 9646 __extends(MDCModalDrawerFoundation, _super); 9647 function MDCModalDrawerFoundation() { 9648 return _super !== null && _super.apply(this, arguments) || this; 9649 } 9650 /** 9651 * Handles click event on scrim. 9652 */ 9653 MDCModalDrawerFoundation.prototype.handleScrimClick = function () { 9654 this.close(); 9655 }; 9656 /** 9657 * Called when drawer finishes open animation. 9658 */ 9659 MDCModalDrawerFoundation.prototype.opened_ = function () { 9660 this.adapter.trapFocus(); 9661 }; 9662 /** 9663 * Called when drawer finishes close animation. 9664 */ 9665 MDCModalDrawerFoundation.prototype.closed_ = function () { 9666 this.adapter.releaseFocus(); 9667 }; 9668 return MDCModalDrawerFoundation; 9669 }(MDCDismissibleDrawerFoundation)); 9670 9671 /** 9672 * @license 9673 * Copyright 2016 Google Inc. 9674 * 9675 * Permission is hereby granted, free of charge, to any person obtaining a copy 9676 * of this software and associated documentation files (the "Software"), to deal 9677 * in the Software without restriction, including without limitation the rights 9678 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9679 * copies of the Software, and to permit persons to whom the Software is 9680 * furnished to do so, subject to the following conditions: 9681 * 9682 * The above copyright notice and this permission notice shall be included in 9683 * all copies or substantial portions of the Software. 9684 * 9685 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 9686 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9687 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9688 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9689 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9690 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 9691 * THE SOFTWARE. 9692 */
vendor: 5,017 bytes, lines 9693-9800
9693 var cssClasses$l = MDCDismissibleDrawerFoundation.cssClasses, strings$p = MDCDismissibleDrawerFoundation.strings; 9694 /** 9695 * @events `MDCDrawer:closed {}` Emits when the navigation drawer has closed. 9696 * @events `MDCDrawer:opened {}` Emits when the navigation drawer has opened. 9697 */ 9698 var MDCDrawer = /** @class */ (function (_super) { 9699 __extends(MDCDrawer, _super); 9700 function MDCDrawer() { 9701 return _super !== null && _super.apply(this, arguments) || this; 9702 } 9703 MDCDrawer.attachTo = function (root) { 9704 return new MDCDrawer(root); 9705 }; 9706 Object.defineProperty(MDCDrawer.prototype, "open", { 9707 /** 9708 * @return boolean Proxies to the foundation's `open`/`close` methods. 9709 * Also returns true if drawer is in the open position. 9710 */ 9711 get: function () { 9712 return this.foundation.isOpen(); 9713 }, 9714 /** 9715 * Toggles the drawer open and closed. 9716 */ 9717 set: function (isOpen) { 9718 if (isOpen) { 9719 this.foundation.open(); 9720 } 9721 else { 9722 this.foundation.close(); 9723 } 9724 }, 9725 enumerable: true, 9726 configurable: true 9727 }); 9728 Object.defineProperty(MDCDrawer.prototype, "list", { 9729 get: function () { 9730 return this.list_; 9731 }, 9732 enumerable: true, 9733 configurable: true 9734 }); 9735 MDCDrawer.prototype.initialize = function (focusTrapFactory, listFactory) { 9736 if (focusTrapFactory === void 0) { focusTrapFactory = function (el) { return new FocusTrap(el); }; } 9737 if (listFactory === void 0) { listFactory = function (el) { return new MDCList(el); }; } 9738 var listEl = this.root.querySelector("." + MDCListFoundation.cssClasses.ROOT); 9739 if (listEl) { 9740 this.list_ = listFactory(listEl); 9741 this.list_.wrapFocus = true; 9742 } 9743 this.focusTrapFactory_ = focusTrapFactory; 9744 }; 9745 MDCDrawer.prototype.initialSyncWithDOM = function () { 9746 var _this = this; 9747 var MODAL = cssClasses$l.MODAL; 9748 var SCRIM_SELECTOR = strings$p.SCRIM_SELECTOR; 9749 this.scrim_ = this.root.parentNode 9750 .querySelector(SCRIM_SELECTOR); 9751 if (this.scrim_ && this.root.classList.contains(MODAL)) { 9752 this.handleScrimClick_ = function () { 9753 return _this.foundation.handleScrimClick(); 9754 }; 9755 this.scrim_.addEventListener('click', this.handleScrimClick_); 9756 this.focusTrap_ = createFocusTrapInstance$1(this.root, this.focusTrapFactory_); 9757 } 9758 this.handleKeydown_ = function (evt) { return _this.foundation.handleKeydown(evt); }; 9759 this.handleTransitionEnd_ = function (evt) { 9760 return _this.foundation.handleTransitionEnd(evt); 9761 }; 9762 this.listen('keydown', this.handleKeydown_); 9763 this.listen('transitionend', this.handleTransitionEnd_); 9764 }; 9765 MDCDrawer.prototype.destroy = function () { 9766 this.unlisten('keydown', this.handleKeydown_); 9767 this.unlisten('transitionend', this.handleTransitionEnd_); 9768 if (this.list_) { 9769 this.list_.destroy(); 9770 } 9771 var MODAL = cssClasses$l.MODAL; 9772 if (this.scrim_ && this.handleScrimClick_ && 9773 this.root.classList.contains(MODAL)) { 9774 this.scrim_.removeEventListener('click', this.handleScrimClick_); 9775 // Ensure drawer is closed to hide scrim and release focus 9776 this.open = false; 9777 } 9778 }; 9779 MDCDrawer.prototype.getDefaultFoundation = function () { 9780 var _this = this; 9781 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 9782 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 9783 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 9784 var adapter = { 9785 addClass: function (className) { return _this.root.classList.add(className); }, 9786 removeClass: function (className) { return _this.root.classList.remove(className); }, 9787 hasClass: function (className) { return _this.root.classList.contains(className); }, 9788 elementHasClass: function (element, className) { 9789 return element.classList.contains(className); 9790 }, 9791 saveFocus: function () { return _this.previousFocus_ = document.activeElement; }, 9792 restoreFocus: function () { 9793 var previousFocus = _this.previousFocus_; 9794 if (previousFocus && previousFocus.focus && 9795 _this.root.contains(document.activeElement)) { 9796 previousFocus.focus(); 9797 } 9798 }, 9799 focusActiveNavigationItem: function () { 9800 var activeNavItemEl = _this.root.querySelector("." + MDCListFoundation.cssClasse
9800s.LIST_ITEM_ACTIVATED_CLASS); 9801 if (activeNavItemEl) { 9802 activeNavItemEl.focus(); 9803 } 9804 }, 9805 notifyClose: function () { 9806 return _this.emit(strings$p.CLOSE_EVENT, {}, true /* shouldBubble */); 9807 }, 9808 notifyOpen: function () { 9809 return _this.emit(strings$p.OPEN_EVENT, {}, true /* shouldBubble */); 9810 }, 9811 trapFocus: function () { return _this.focusTrap_.trapFocus(); }, 9812 releaseFocus: function () { return _this.focusTrap_.releaseFocus(); }, 9813 }; 9814 // tslint:enable:object-literal-sort-keys 9815 var DISMISSIBLE = cssClasses$l.DISMISSIBLE, MODAL = cssClasses$l.MODAL; 9816 if (this.root.classList.contains(DISMISSIBLE)) { 9817 return new MDCDismissibleDrawerFoundation(adapter); 9818 } 9819 else if (this.root.classList.contains(MODAL)) { 9820 return new MDCModalDrawerFoundation(adapter); 9821 } 9822 else { 9823 throw new Error("MDCDrawer: Failed to instantiate component. Supported variants are " + DISMISSIBLE + " and " + MODAL + "."); 9824 } 9825 }; 9826 return MDCDrawer; 9827 }(MDCComponent)); 9828 9829 /** 9830 * @license 9831 * Copyright 2019 Google Inc. 9832 * 9833 * Permission is hereby granted, free of charge, to any person obtaining a copy 9834 * of this software and associated documentation files (the "Software"), to deal 9835 * in the Software without restriction, including without limitation the rights 9836 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9837 * copies of the Software, and to permit persons to whom the Software is 9838 * furnished to do so, subject to the following conditions: 9839 * 9840 * The above copyright notice and this permission notice shall be included in 9841 * all copies or substantial portions of the Software. 9842 * 9843 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 9844 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9845 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9846 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9847 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9848 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 9849 * THE SOFTWARE. 9850 */ 9851 9852 /** 9853 * @license 9854 * Copyright 2016 Google Inc. 9855 * 9856 * Permission is hereby granted, free of charge, to any person obtaining a copy 9857 * of this software and associated documentation files (the "Software"), to deal 9858 * in the Software without restriction, including without limitation the rights 9859 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9860 * copies of the Software, and to permit persons to whom the Software is 9861 * furnished to do so, subject to the following conditions: 9862 * 9863 * The above copyright notice and this permission notice shall be included in 9864 * all copies or substantial portions of the Software. 9865 * 9866 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 9867 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9868 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9869 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9870 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9871 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 9872 * THE SOFTWARE. 9873 */ 9874 function createFocusTrapInstance(surfaceEl, focusTrapFactory, initialFocusEl) { 9875 return focusTrapFactory(surfaceEl, { initialFocusEl: initialFocusEl }); 9876 } 9877 function isScrollable(el) { 9878 return el ? el.scrollHeight > el.offsetHeight : false; 9879 } 9880 /** 9881 * For scrollable content, returns true if the content has not been scrolled 9882 * (that is, the scroll content is as the "top"). This is used in full-screen 9883 * dialogs, where the scroll divider is expected only to appear once the 9884 * content has been scrolled "underneath" the header bar. 9885 */ 9886 function isScrollAtTop(el) { 9887 return el ? el.scrollTop === 0 : false;
vendor: 5,122 bytes, lines 9888-10011
9888 } 9889 /** 9890 * For scrollable content, returns true if the content has been scrolled all the 9891 * way to the bottom. This is used in full-screen dialogs, where the footer 9892 * scroll divider is expected only to appear when the content is "cut-off" by 9893 * the footer bar. 9894 */ 9895 function isScrollAtBottom(el) { 9896 return el ? Math.ceil(el.scrollHeight - el.scrollTop) === el.clientHeight : 9897 false; 9898 } 9899 function areTopsMisaligned(els) { 9900 var tops = new Set(); 9901 [].forEach.call(els, function (el) { return tops.add(el.offsetTop); }); 9902 return tops.size > 1; 9903 } 9904 9905 /** 9906 * @license 9907 * Copyright 2020 Google Inc. 9908 * 9909 * Permission is hereby granted, free of charge, to any person obtaining a copy 9910 * of this software and associated documentation files (the "Software"), to deal 9911 * in the Software without restriction, including without limitation the rights 9912 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9913 * copies of the Software, and to permit persons to whom the Software is 9914 * furnished to do so, subject to the following conditions: 9915 * 9916 * The above copyright notice and this permission notice shall be included in 9917 * all copies or substantial portions of the Software. 9918 * 9919 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 9920 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 9921 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9922 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 9923 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 9924 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 9925 * THE SOFTWARE. 9926 */ 9927 /** 9928 * AnimationFrame provides a user-friendly abstraction around requesting 9929 * and canceling animation frames. 9930 */ 9931 var AnimationFrame = /** @class */ (function () { 9932 function AnimationFrame() { 9933 this.rafIDs = new Map(); 9934 } 9935 /** 9936 * Requests an animation frame. Cancels any existing frame with the same key. 9937 * @param {string} key The key for this callback. 9938 * @param {FrameRequestCallback} callback The callback to be executed. 9939 */ 9940 AnimationFrame.prototype.request = function (key, callback) { 9941 var _this = this; 9942 this.cancel(key); 9943 var frameID = requestAnimationFrame(function (frame) { 9944 _this.rafIDs.delete(key); 9945 // Callback must come *after* the key is deleted so that nested calls to 9946 // request with the same key are not deleted. 9947 callback(frame); 9948 }); 9949 this.rafIDs.set(key, frameID); 9950 }; 9951 /** 9952 * Cancels a queued callback with the given key. 9953 * @param {string} key The key for this callback. 9954 */ 9955 AnimationFrame.prototype.cancel = function (key) { 9956 var rafID = this.rafIDs.get(key); 9957 if (rafID) { 9958 cancelAnimationFrame(rafID); 9959 this.rafIDs.delete(key); 9960 } 9961 }; 9962 /** 9963 * Cancels all queued callback. 9964 */ 9965 AnimationFrame.prototype.cancelAll = function () { 9966 var _this = this; 9967 // Need to use forEach because it's the only iteration method supported 9968 // by IE11. Suppress the underscore because we don't need it. 9969 // tslint:disable-next-line:enforce-name-casing 9970 this.rafIDs.forEach(function (_, key) { 9971 _this.cancel(key); 9972 }); 9973 }; 9974 /** 9975 * Returns the queue of unexecuted callback keys. 9976 */ 9977 AnimationFrame.prototype.getQueue = function () { 9978 var queue = []; 9979 // Need to use forEach because it's the only iteration method supported 9980 // by IE11. Suppress the underscore because we don't need it. 9981 // tslint:disable-next-line:enforce-name-casing 9982 this.rafIDs.forEach(function (_, key) { 9983 queue.push(key); 9984 }); 9985 return queue; 9986 }; 9987 return AnimationFrame; 9988 }()); 9989 9990 /** 9991 * @license 9992 * Copyright 2016 Google Inc. 9993 * 9994 * Permission is hereby granted, free of charge, to any person obtaining a copy 9995 * of this software and associated documentation files (the "Software"), to deal 9996 * in the Software without restriction, including without limitation the rights 9997 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9998 * copies of the Software, and to permit persons to whom the Software is 9999 * furnished to do so, subject to the following conditions: 10000 * 10001 * The above copyright notice and this permission notice shall be included in 10002 * all copies or substantial portions of the Software. 10003 * 10004 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10005 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10006 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10007 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10008 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10009 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10010 * THE SOFTWARE. 10011 */
vendor: 6,297 bytes, lines 10012-10151
10012 var cssClasses$k = { 10013 CLOSING: 'mdc-dialog--closing', 10014 OPEN: 'mdc-dialog--open', 10015 OPENING: 'mdc-dialog--opening', 10016 SCROLLABLE: 'mdc-dialog--scrollable', 10017 SCROLL_LOCK: 'mdc-dialog-scroll-lock', 10018 STACKED: 'mdc-dialog--stacked', 10019 FULLSCREEN: 'mdc-dialog--fullscreen', 10020 // Class for showing a scroll divider on full-screen dialog header element. 10021 // Should only be displayed on scrollable content, when the dialog content is 10022 // scrolled "underneath" the header. 10023 SCROLL_DIVIDER_HEADER: 'mdc-dialog-scroll-divider-header', 10024 // Class for showing a scroll divider on a full-screen dialog footer element. 10025 // Should only be displayed on scrolalble content, when the dialog content is 10026 // obscured "underneath" the footer. 10027 SCROLL_DIVIDER_FOOTER: 'mdc-dialog-scroll-divider-footer', 10028 }; 10029 var strings$o = { 10030 ACTION_ATTRIBUTE: 'data-mdc-dialog-action', 10031 BUTTON_DEFAULT_ATTRIBUTE: 'data-mdc-dialog-button-default', 10032 BUTTON_SELECTOR: '.mdc-dialog__button', 10033 CLOSED_EVENT: 'MDCDialog:closed', 10034 CLOSE_ACTION: 'close', 10035 CLOSING_EVENT: 'MDCDialog:closing', 10036 CONTAINER_SELECTOR: '.mdc-dialog__container', 10037 CONTENT_SELECTOR: '.mdc-dialog__content', 10038 DESTROY_ACTION: 'destroy', 10039 INITIAL_FOCUS_ATTRIBUTE: 'data-mdc-dialog-initial-focus', 10040 OPENED_EVENT: 'MDCDialog:opened', 10041 OPENING_EVENT: 'MDCDialog:opening', 10042 SCRIM_SELECTOR: '.mdc-dialog__scrim', 10043 SUPPRESS_DEFAULT_PRESS_SELECTOR: [ 10044 'textarea', 10045 '.mdc-menu .mdc-list-item', 10046 ].join(', '), 10047 SURFACE_SELECTOR: '.mdc-dialog__surface', 10048 }; 10049 var numbers$8 = { 10050 DIALOG_ANIMATION_CLOSE_TIME_MS: 75, 10051 DIALOG_ANIMATION_OPEN_TIME_MS: 150, 10052 }; 10053 10054 /** 10055 * @license 10056 * Copyright 2017 Google Inc. 10057 * 10058 * Permission is hereby granted, free of charge, to any person obtaining a copy 10059 * of this software and associated documentation files (the "Software"), to deal 10060 * in the Software without restriction, including without limitation the rights 10061 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10062 * copies of the Software, and to permit persons to whom the Software is 10063 * furnished to do so, subject to the following conditions: 10064 * 10065 * The above copyright notice and this permission notice shall be included in 10066 * all copies or substantial portions of the Software. 10067 * 10068 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10069 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10070 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10071 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10072 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10073 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10074 * THE SOFTWARE. 10075 */ 10076 var AnimationKeys; 10077 (function (AnimationKeys) { 10078 AnimationKeys["POLL_SCROLL_POS"] = "poll_scroll_position"; 10079 })(AnimationKeys || (AnimationKeys = {})); 10080 var MDCDialogFoundation = /** @class */ (function (_super) { 10081 __extends(MDCDialogFoundation, _super); 10082 function MDCDialogFoundation(adapter) { 10083 var _this = _super.call(this, __assign(__assign({}, MDCDialogFoundation.defaultAdapter), adapter)) || this; 10084 _this.dialogOpen = false; 10085 _this.isFullscreen = false; 10086 _this.animationFrame = 0; 10087 _this.animationTimer = 0; 10088 _this.layoutFrame = 0; 10089 _this.escapeKeyAction = strings$o.CLOSE_ACTION; 10090 _this.scrimClickAction = strings$o.CLOSE_ACTION; 10091 _this.autoStackButtons = true; 10092 _this.areButtonsStacked = false; 10093 _this.suppressDefaultPressSelector = strings$o.SUPPRESS_DEFAULT_PRESS_SELECTOR; 10094 _this.animFrame = new AnimationFrame(); 10095 _this.contentScrollHandler = function () { 10096 _this.handleScrollEvent(); 10097 }; 10098 return _this; 10099 } 10100 Object.defineProperty(MDCDialogFoundation, "cssClasses", { 10101 get: function () { 10102 return cssClasses$k; 10103 }, 10104 enumerable: true, 10105 configurable: true 10106 }); 10107 Object.defineProperty(MDCDialogFoundation, "strings", { 10108 get: function () { 10109 return strings$o; 10110 }, 10111 enumerable: true, 10112 configurable: true 10113 }); 10114 Object.defineProperty(MDCDialogFoundation, "numbers", { 10115 get: function () { 10116 return numbers$8; 10117 }, 10118 enumerable: true, 10119 configurable: true 10120 }); 10121 Object.defineProperty(MDCDialogFoundation, "defaultAdapter", { 10122 get: function () { 10123 return { 10124 addBodyClass: function () { return undefined; }, 10125 addClass: function () { return undefined; }, 10126 areButtonsStacked: function () { return false; }, 10127 clickDefaultButton: function () { return undefined; }, 10128 eventTargetMatches: function () { return false; }, 10129 getActionFromEvent: function () { return ''; }, 10130 getInitialFocusEl: function () { return null; }, 10131 hasClass: function () { return false; }, 10132 isContentScrollable: function () { return false; }, 10133 notifyClosed: function () { return undefined; }, 10134 notifyClosing: function () { return undefined; }, 10135 notifyOpened: function () { return undefined; }, 10136 notifyOpening: function () { return undefined; }, 10137 releaseFocus: function () { return undefined; }, 10138 removeBodyClass: function () { return undefined; }, 10139 removeClass: function () { return undefined; }, 10140 reverseButtons: function () { return undefined; }, 10141 trapFocus: function () { return undefined; }, 10142 registerContentEventHandler: function () { return undefined; }, 10143 deregisterContentEventHandler: function () { return undefined; }, 10144 isScrollableContentAtTop: function () { return false; }, 10145 isScrollableContentAtBottom: function () { return false; }, 10146 }; 10147 }, 10148 enumerable: true, 10149 configurable: true 10150 }); 10151 MDCDialogFoundation.prototype.init = function () {
10152 if (this.adapter.hasClass(cssClasses$k.STACKED)) { 10153 this.setAutoStackButtons(false); 10154 } 10155 this.isFullscreen = this.adapter.hasClass(cssClasses$k.FULLSCREEN); 10156 }; 10157 MDCDialogFoundation.prototype.destroy = function () { 10158 if (this.dialogOpen) { 10159 this.close(strings$o.DESTROY_ACTION); 10160 } 10161 if (this.animationTimer) { 10162 clearTimeout(this.animationTimer); 10163 this.handleAnimationTimerEnd(); 10164 } 10165 if (this.layoutFrame) { 10166 cancelAnimationFrame(this.layoutFrame); 10167 this.layoutFrame = 0; 10168 } 10169 if (this.isFullscreen && this.adapter.isContentScrollable()) { 10170 this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler); 10171 } 10172 }; 10173 MDCDialogFoundation.prototype.open = function () { 10174 var _this = this; 10175 this.dialogOpen = true; 10176 this.adapter.notifyOpening(); 10177 this.adapter.addClass(cssClasses$k.OPENING); 10178 if (this.isFullscreen && this.adapter.isContentScrollable()) { 10179 this.adapter.registerContentEventHandler('scroll', this.contentScrollHandler); 10180 } 10181 // Wait a frame once display is no longer "none", to establish basis for 10182 // animation 10183 this.runNextAnimationFrame(function () { 10184 _this.adapter.addClass(cssClasses$k.OPEN); 10185 _this.adapter.addBodyClass(cssClasses$k.SCROLL_LOCK); 10186 _this.layout(); 10187 _this.animationTimer = setTimeout(function () { 10188 _this.handleAnimationTimerEnd(); 10189 _this.adapter.trapFocus(_this.adapter.getInitialFocusEl()); 10190 _this.adapter.notifyOpened(); 10191 }, numbers$8.DIALOG_ANIMATION_OPEN_TIME_MS); 10192 }); 10193 }; 10194 MDCDialogFoundation.prototype.close = function (action) { 10195 var _this = this; 10196 if (action === void 0) { action = ''; } 10197 if (!this.dialogOpen) { 10198 // Avoid redundant close calls (and events), e.g. from keydown on elements 10199 // that inherently emit click 10200 return; 10201 } 10202 this.dialogOpen = false; 10203 this.adapter.notifyClosing(action); 10204 this.adapter.addClass(cssClasses$k.CLOSING); 10205 this.adapter.removeClass(cssClasses$k.OPEN); 10206 this.adapter.removeBodyClass(cssClasses$k.SCROLL_LOCK); 10207 if (this.isFullscreen && this.adapter.isContentScrollable()) { 10208 this.adapter.deregisterContentEventHandler('scroll', this.contentScrollHandler); 10209 } 10210 cancelAnimationFrame(this.animationFrame); 10211 this.animationFrame = 0; 10212 clearTimeout(this.animationTimer); 10213 this.animationTimer = setTimeout(function () { 10214 _this.adapter.releaseFocus(); 10215 _this.handleAnimationTimerEnd(); 10216 _this.adapter.notifyClosed(action); 10217 }, numbers$8.DIALOG_ANIMATION_CLOSE_TIME_MS); 10218 }; 10219 MDCDialogFoundation.prototype.isOpen = function () { 10220 return this.dialogOpen; 10221 }; 10222 MDCDialogFoundation.prototype.getEscapeKeyAction = function () { 10223 return this.escapeKeyAction; 10224 }; 10225 MDCDialogFoundation.prototype.setEscapeKeyAction = function (action) { 10226 this.escapeKeyAction = action; 10227 }; 10228 MDCDialogFoundation.prototype.getScrimClickAction = function () { 10229 return this.scrimClickAction; 10230 }; 10231 MDCDialogFoundation.prototype.setScrimClickAction = function (action) { 10232 this.scrimClickAction = action; 10233 }; 10234 MDCDialogFoundation.prototype.getAutoStackButtons = function () { 10235 return this.autoStackButtons; 10236 }; 10237 MDCDialogFoundation.prototype.setAutoStackButtons = function (autoStack) { 10238 this.autoStackButtons = autoStack; 10239 }; 10240 MDCDialogFoundation.prototype.getSuppressDefaultPressSelector = function () { 10241 return this.suppressDefaultPressSelector; 10242 }; 10243 MDCDialogFoundation.prototype.setSuppressDefaultPressSelector = function (selector) { 10244 this.suppressDefaultPressSelector = selector; 10245 }; 10246 MDCDialogFoundation.prototype.layout = function () { 10247 var _this = this; 10248 if (this.layoutFrame) { 10249 cancelAnimationFrame(this.layoutFrame); 10250 } 10251 this.layoutFrame = requestAnimationFrame(function () { 10252 _this.layoutInternal(); 10253 _this.layoutFrame = 0; 10254 }); 10255 }; 10256 /** Handles click on the dialog root element. */ 10257 MDCDialogFoundation.prototype.handleClick = function (evt) { 10258 var isScrim = this.adapter.eventTargetMatches(evt.target, strings$o.SCRIM_SELECTOR); 10259 // Check for scrim click first since it doesn't require querying ancestors. 10260 if (isScrim && this.scrimClickAction !== '') { 10261 this.close(this.scrimClickAction); 10262 } 10263 else { 10264 var action = this.adapter.getActionFromEvent(evt); 10265 if (action) { 10266 this.close(action); 10267 } 10268 } 10269 }; 10270 /** Handles keydown on the dialog root element. */ 10271 MDCDialogFoundation.prototype.handleKeydown = function (evt) { 10272 var isEnter = evt.key === 'Enter' || evt.keyCode === 13; 10273 if (!isEnter) { 10274 return; 10275 } 10276 var action = this.adapter.getActionFromEvent(evt); 10277 if (action) { 10278 // Action button callback is handled in `handleClick`, 10279 // since space/enter keydowns on buttons trigger click events. 10280 return; 10281 } 10282 // `composedPath` is used here, when available, to account for use cases 10283 // where a target meant to suppress the default press behaviour 10284 // may exist in a shadow root. 10285 // For example, a textarea inside a web component: 10286 // <mwc-dialog> 10287 // <horizontal-layout> 10288 // #shadow-root (open) 10289 // <mwc-textarea> 10290 // #shadow-root (open) 10291 // <textarea></textarea> 10292 // </mwc-textarea> 10293 // </horizontal-layout> 10294 // </mwc-dialog> 10295 var target = evt.composedPath ? evt.composedPath()[0] : evt.target; 10296 var isDefault = this.suppressDefaultPressSelector ? 10297 !this.adapter.eventTargetMatches(target, this.suppressDefaultPressSelector) : 10298 true; 10299 if (isEnter && isDefault) { 10300 this.adapter.clickDefaultButton(); 10301 } 10302 }; 10303 /** Handles keydown on the document. */ 10304 MDCDialogFoundation.prototype.handleDocumentKeydown = function (evt) { 10305 var isEscape = evt.key === 'Escape' || evt.keyCode === 27; 10306 if (isEscape && this.escapeKeyAction !== '') { 10307 this.close(this.escapeKeyAction); 10308 } 10309 }; 10310 /** 10311 * Handles scroll event on the dialog's content element -- showing a scroll 10312 * divider on the header or footer based on the scroll position. This handler 10313 * should only be registered on full-screen dialogs with scrollable content. 10314 */ 10315 MDCDialogFoundation.prototype.handleScrollEvent = function () { 10316 var _this = this; 10317 // Since scroll events can fire at a high rate, we throttle these events by 10318 // using requestAnimationFrame. 10319 this.animFrame.request(AnimationKeys.POLL_SCROLL_POS, function () { 10320 _this.toggleScrollDividerHeader(); 10321 _this.toggleScrollDividerFooter(); 10322 }); 10323 }; 10324 MDCDialogFoundation.prototype.layoutInternal = function () { 10325 if (this.autoStackButtons) { 10326 this.detectStackedButtons(); 10327 } 10328 this.toggleScrollableClasses(); 10329 }; 10330 MDCDialogFoundation.prototype.handleAnimationTimerEnd = function () { 10331 this.animationTimer = 0;
vendor: 6,193 bytes, lines 10332-10472
10332 this.adapter.removeClass(cssClasses$k.OPENING); 10333 this.adapter.removeClass(cssClasses$k.CLOSING); 10334 }; 10335 /** 10336 * Runs the given logic on the next animation frame, using setTimeout to 10337 * factor in Firefox reflow behavior. 10338 */ 10339 MDCDialogFoundation.prototype.runNextAnimationFrame = function (callback) { 10340 var _this = this; 10341 cancelAnimationFrame(this.animationFrame); 10342 this.animationFrame = requestAnimationFrame(function () { 10343 _this.animationFrame = 0; 10344 clearTimeout(_this.animationTimer); 10345 _this.animationTimer = setTimeout(callback, 0); 10346 }); 10347 }; 10348 MDCDialogFoundation.prototype.detectStackedButtons = function () { 10349 // Remove the class first to let us measure the buttons' natural positions. 10350 this.adapter.removeClass(cssClasses$k.STACKED); 10351 var areButtonsStacked = this.adapter.areButtonsStacked(); 10352 if (areButtonsStacked) { 10353 this.adapter.addClass(cssClasses$k.STACKED); 10354 } 10355 if (areButtonsStacked !== this.areButtonsStacked) { 10356 this.adapter.reverseButtons(); 10357 this.areButtonsStacked = areButtonsStacked; 10358 } 10359 }; 10360 MDCDialogFoundation.prototype.toggleScrollableClasses = function () { 10361 // Remove the class first to let us measure the natural height of the 10362 // content. 10363 this.adapter.removeClass(cssClasses$k.SCROLLABLE); 10364 if (this.adapter.isContentScrollable()) { 10365 this.adapter.addClass(cssClasses$k.SCROLLABLE); 10366 if (this.isFullscreen) { 10367 // If dialog is full-screen and scrollable, check if a scroll divider 10368 // should be shown. 10369 this.toggleScrollDividerHeader(); 10370 this.toggleScrollDividerFooter(); 10371 } 10372 } 10373 }; 10374 MDCDialogFoundation.prototype.toggleScrollDividerHeader = function () { 10375 if (!this.adapter.isScrollableContentAtTop()) { 10376 this.adapter.addClass(cssClasses$k.SCROLL_DIVIDER_HEADER); 10377 } 10378 else if (this.adapter.hasClass(cssClasses$k.SCROLL_DIVIDER_HEADER)) { 10379 this.adapter.removeClass(cssClasses$k.SCROLL_DIVIDER_HEADER); 10380 } 10381 }; 10382 MDCDialogFoundation.prototype.toggleScrollDividerFooter = function () { 10383 if (!this.adapter.isScrollableContentAtBottom()) { 10384 this.adapter.addClass(cssClasses$k.SCROLL_DIVIDER_FOOTER); 10385 } 10386 else if (this.adapter.hasClass(cssClasses$k.SCROLL_DIVIDER_FOOTER)) { 10387 this.adapter.removeClass(cssClasses$k.SCROLL_DIVIDER_FOOTER); 10388 } 10389 }; 10390 return MDCDialogFoundation; 10391 }(MDCFoundation)); 10392 10393 /** 10394 * @license 10395 * Copyright 2017 Google Inc. 10396 * 10397 * Permission is hereby granted, free of charge, to any person obtaining a copy 10398 * of this software and associated documentation files (the "Software"), to deal 10399 * in the Software without restriction, including without limitation the rights 10400 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10401 * copies of the Software, and to permit persons to whom the Software is 10402 * furnished to do so, subject to the following conditions: 10403 * 10404 * The above copyright notice and this permission notice shall be included in 10405 * all copies or substantial portions of the Software. 10406 * 10407 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10408 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10409 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10410 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10411 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10412 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10413 * THE SOFTWARE. 10414 */ 10415 var strings$n = MDCDialogFoundation.strings; 10416 var MDCDialog = /** @class */ (function (_super) { 10417 __extends(MDCDialog, _super); 10418 function MDCDialog() { 10419 return _super !== null && _super.apply(this, arguments) || this; 10420 } 10421 Object.defineProperty(MDCDialog.prototype, "isOpen", { 10422 get: function () { 10423 return this.foundation.isOpen(); 10424 }, 10425 enumerable: true, 10426 configurable: true 10427 }); 10428 Object.defineProperty(MDCDialog.prototype, "escapeKeyAction", { 10429 get: function () { 10430 return this.foundation.getEscapeKeyAction(); 10431 }, 10432 set: function (action) { 10433 this.foundation.setEscapeKeyAction(action); 10434 }, 10435 enumerable: true, 10436 configurable: true 10437 }); 10438 Object.defineProperty(MDCDialog.prototype, "scrimClickAction", { 10439 get: function () { 10440 return this.foundation.getScrimClickAction(); 10441 }, 10442 set: function (action) { 10443 this.foundation.setScrimClickAction(action); 10444 }, 10445 enumerable: true, 10446 configurable: true 10447 }); 10448 Object.defineProperty(MDCDialog.prototype, "autoStackButtons", { 10449 get: function () { 10450 return this.foundation.getAutoStackButtons(); 10451 }, 10452 set: function (autoStack) { 10453 this.foundation.setAutoStackButtons(autoStack); 10454 }, 10455 enumerable: true, 10456 configurable: true 10457 }); 10458 MDCDialog.attachTo = function (root) { 10459 return new MDCDialog(root); 10460 }; 10461 MDCDialog.prototype.initialize = function (focusTrapFactory) { 10462 var e_1, _a; 10463 if (focusTrapFactory === void 0) { focusTrapFactory = function (el, focusOptions) { return new FocusTrap(el, focusOptions); }; } 10464 var container = this.root.querySelector(strings$n.CONTAINER_SELECTOR); 10465 if (!container) { 10466 throw new Error("Dialog component requires a " + strings$n.CONTAINER_SELECTOR + " container element"); 10467 } 10468 this.container = container; 10469 this.content = 10470 this.root.querySelector(strings$n.CONTENT_SELECTOR); 10471 this.buttons = [].slice.call(this.root.querySelectorAll(strings$n.BUTTON_SELECTOR)); 10472 this.defaultButton = this.root.querySelector("[" + strings$n.BUTTON_DEFAULT_ATTRIBUTE + "]");
10473 this.focusTrapFactory = focusTrapFactory; 10474 this.buttonRipples = []; 10475 try { 10476 for (var _b = __values(this.buttons), _c = _b.next(); !_c.done; _c = _b.next()) { 10477 var buttonEl = _c.value; 10478 this.buttonRipples.push(new MDCRipple(buttonEl)); 10479 } 10480 } 10481 catch (e_1_1) { e_1 = { error: e_1_1 }; } 10482 finally { 10483 try { 10484 if (_c && !_c.done && (_a = _b.return)) _a.call(_b); 10485 } 10486 finally { if (e_1) throw e_1.error; } 10487 } 10488 }; 10489 MDCDialog.prototype.initialSyncWithDOM = function () { 10490 var _this = this; 10491 this.focusTrap = createFocusTrapInstance(this.container, this.focusTrapFactory, this.getInitialFocusEl() || undefined); 10492 this.handleClick = this.foundation.handleClick.bind(this.foundation); 10493 this.handleKeydown = this.foundation.handleKeydown.bind(this.foundation); 10494 this.handleDocumentKeydown = 10495 this.foundation.handleDocumentKeydown.bind(this.foundation); 10496 this.handleLayout = this.layout.bind(this); 10497 var LAYOUT_EVENTS = ['resize', 'orientationchange']; 10498 this.handleOpening = function () { 10499 LAYOUT_EVENTS.forEach(function (evtType) { 10500 window.addEventListener(evtType, _this.handleLayout); 10501 }); 10502 document.addEventListener('keydown', _this.handleDocumentKeydown); 10503 }; 10504 this.handleClosing = function () { 10505 LAYOUT_EVENTS.forEach(function (evtType) { 10506 window.removeEventListener(evtType, _this.handleLayout); 10507 }); 10508 document.removeEventListener('keydown', _this.handleDocumentKeydown); 10509 }; 10510 this.listen('click', this.handleClick); 10511 this.listen('keydown', this.handleKeydown); 10512 this.listen(strings$n.OPENING_EVENT, this.handleOpening); 10513 this.listen(strings$n.CLOSING_EVENT, this.handleClosing); 10514 }; 10515 MDCDialog.prototype.destroy = function () { 10516 this.unlisten('click', this.handleClick); 10517 this.unlisten('keydown', this.handleKeydown); 10518 this.unlisten(strings$n.OPENING_EVENT, this.handleOpening); 10519 this.unlisten(strings$n.CLOSING_EVENT, this.handleClosing); 10520 this.handleClosing(); 10521 this.buttonRipples.forEach(function (ripple) { 10522 ripple.destroy(); 10523 }); 10524 _super.prototype.destroy.call(this); 10525 }; 10526 MDCDialog.prototype.layout = function () { 10527 this.foundation.layout(); 10528 }; 10529 MDCDialog.prototype.open = function () { 10530 this.foundation.open(); 10531 }; 10532 MDCDialog.prototype.close = function (action) { 10533 if (action === void 0) { action = ''; } 10534 this.foundation.close(action); 10535 }; 10536 MDCDialog.prototype.getDefaultFoundation = function () { 10537 var _this = this; 10538 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 10539 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 10540 var adapter = { 10541 addBodyClass: function (className) { return document.body.classList.add(className); }, 10542 addClass: function (className) { return _this.root.classList.add(className); }, 10543 areButtonsStacked: function () { return areTopsMisaligned(_this.buttons); }, 10544 clickDefaultButton: function () { 10545 if (_this.defaultButton) { 10546 _this.defaultButton.click(); 10547 } 10548 }, 10549 eventTargetMatches: function (target, selector) { 10550 return target ? matches$1(target, selector) : false; 10551 }, 10552 getActionFromEvent: function (evt) { 10553 if (!evt.target) { 10554 return ''; 10555 } 10556 var element = closest(evt.target, "[" + strings$n.ACTION_ATTRIBUTE + "]"); 10557 return element && element.getAttribute(strings$n.ACTION_ATTRIBUTE); 10558 }, 10559 getInitialFocusEl: function () { return _this.getInitialFocusEl(); }, 10560 hasClass: function (className) { return _this.root.classList.contains(className); }, 10561 isContentScrollable: function () { return isScrollable(_this.content); }, 10562 notifyClosed: function (action) { return _this.emit
vendor: 4,313 bytes, lines 10562-10649
10562(strings$n.CLOSED_EVENT, action ? { action: action } : {}); }, 10563 notifyClosing: function (action) { return _this.emit(strings$n.CLOSING_EVENT, action ? { action: action } : {}); }, 10564 notifyOpened: function () { return _this.emit(strings$n.OPENED_EVENT, {}); }, 10565 notifyOpening: function () { return _this.emit(strings$n.OPENING_EVENT, {}); }, 10566 releaseFocus: function () { 10567 _this.focusTrap.releaseFocus(); 10568 }, 10569 removeBodyClass: function (className) { return document.body.classList.remove(className); }, 10570 removeClass: function (className) { return _this.root.classList.remove(className); }, 10571 reverseButtons: function () { 10572 _this.buttons.reverse(); 10573 _this.buttons.forEach(function (button) { 10574 button.parentElement.appendChild(button); 10575 }); 10576 }, 10577 trapFocus: function () { 10578 _this.focusTrap.trapFocus(); 10579 }, 10580 registerContentEventHandler: function (evt, handler) { 10581 if (_this.content instanceof HTMLElement) { 10582 _this.content.addEventListener(evt, handler); 10583 } 10584 }, 10585 deregisterContentEventHandler: function (evt, handler) { 10586 if (_this.content instanceof HTMLElement) { 10587 _this.content.removeEventListener(evt, handler); 10588 } 10589 }, 10590 isScrollableContentAtTop: function () { 10591 return isScrollAtTop(_this.content); 10592 }, 10593 isScrollableContentAtBottom: function () { 10594 return isScrollAtBottom(_this.content); 10595 }, 10596 }; 10597 return new MDCDialogFoundation(adapter); 10598 }; 10599 MDCDialog.prototype.getInitialFocusEl = function () { 10600 return this.root.querySelector("[" + strings$n.INITIAL_FOCUS_ATTRIBUTE + "]"); 10601 }; 10602 return MDCDialog; 10603 }(MDCComponent)); 10604 10605 /** 10606 * @license 10607 * Copyright 2019 Google Inc. 10608 * 10609 * Permission is hereby granted, free of charge, to any person obtaining a copy 10610 * of this software and associated documentation files (the "Software"), to deal 10611 * in the Software without restriction, including without limitation the rights 10612 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10613 * copies of the Software, and to permit persons to whom the Software is 10614 * furnished to do so, subject to the following conditions: 10615 * 10616 * The above copyright notice and this permission notice shall be included in 10617 * all copies or substantial portions of the Software. 10618 * 10619 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10620 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10621 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10622 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10623 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10624 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10625 * THE SOFTWARE. 10626 */ 10627 10628 /** 10629 * @license 10630 * Copyright 2016 Google Inc. 10631 * 10632 * Permission is hereby granted, free of charge, to any person obtaining a copy 10633 * of this software and associated documentation files (the "Software"), to deal 10634 * in the Software without restriction, including without limitation the rights 10635 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10636 * copies of the Software, and to permit persons to whom the Software is 10637 * furnished to do so, subject to the following conditions: 10638 * 10639 * The above copyright notice and this permission notice shall be included in 10640 * all copies or substantial portions of the Software. 10641 * 10642 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10643 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10644 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10645 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10646 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10647 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10648 * THE SOFTWARE. 10649 */
vendor: 4,166 bytes, lines 10650-10740
10650 var cssClasses$j = { 10651 LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above', 10652 LABEL_REQUIRED: 'mdc-floating-label--required', 10653 LABEL_SHAKE: 'mdc-floating-label--shake', 10654 ROOT: 'mdc-floating-label', 10655 }; 10656 10657 /** 10658 * @license 10659 * Copyright 2016 Google Inc. 10660 * 10661 * Permission is hereby granted, free of charge, to any person obtaining a copy 10662 * of this software and associated documentation files (the "Software"), to deal 10663 * in the Software without restriction, including without limitation the rights 10664 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10665 * copies of the Software, and to permit persons to whom the Software is 10666 * furnished to do so, subject to the following conditions: 10667 * 10668 * The above copyright notice and this permission notice shall be included in 10669 * all copies or substantial portions of the Software. 10670 * 10671 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10672 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10673 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10674 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10675 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10676 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10677 * THE SOFTWARE. 10678 */ 10679 var MDCFloatingLabelFoundation = /** @class */ (function (_super) { 10680 __extends(MDCFloatingLabelFoundation, _super); 10681 function MDCFloatingLabelFoundation(adapter) { 10682 var _this = _super.call(this, __assign(__assign({}, MDCFloatingLabelFoundation.defaultAdapter), adapter)) || this; 10683 _this.shakeAnimationEndHandler_ = function () { return _this.handleShakeAnimationEnd_(); }; 10684 return _this; 10685 } 10686 Object.defineProperty(MDCFloatingLabelFoundation, "cssClasses", { 10687 get: function () { 10688 return cssClasses$j; 10689 }, 10690 enumerable: true, 10691 configurable: true 10692 }); 10693 Object.defineProperty(MDCFloatingLabelFoundation, "defaultAdapter", { 10694 /** 10695 * See {@link MDCFloatingLabelAdapter} for typing information on parameters and return types. 10696 */ 10697 get: function () { 10698 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 10699 return { 10700 addClass: function () { return undefined; }, 10701 removeClass: function () { return undefined; }, 10702 getWidth: function () { return 0; }, 10703 registerInteractionHandler: function () { return undefined; }, 10704 deregisterInteractionHandler: function () { return undefined; }, 10705 }; 10706 // tslint:enable:object-literal-sort-keys 10707 }, 10708 enumerable: true, 10709 configurable: true 10710 }); 10711 MDCFloatingLabelFoundation.prototype.init = function () { 10712 this.adapter.registerInteractionHandler('animationend', this.shakeAnimationEndHandler_); 10713 }; 10714 MDCFloatingLabelFoundation.prototype.destroy = function () { 10715 this.adapter.deregisterInteractionHandler('animationend', this.shakeAnimationEndHandler_); 10716 }; 10717 /** 10718 * Returns the width of the label element. 10719 */ 10720 MDCFloatingLabelFoundation.prototype.getWidth = function () { 10721 return this.adapter.getWidth(); 10722 }; 10723 /** 10724 * Styles the label to produce a shake animation to indicate an error. 10725 * @param shouldShake If true, adds the shake CSS class; otherwise, removes shake class. 10726 */ 10727 MDCFloatingLabelFoundation.prototype.shake = function (shouldShake) { 10728 var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE; 10729 if (shouldShake) { 10730 this.adapter.addClass(LABEL_SHAKE); 10731 } 10732 else { 10733 this.adapter.removeClass(LABEL_SHAKE); 10734 } 10735 }; 10736 /** 10737 * Styles the label to float or dock. 10738 * @param shouldFloat If true, adds the float CSS class; otherwise, removes float and shake classes to dock the label. 10739 */ 10740 MDCFloatingLabelFoundation.prototype.float = function (shouldFloat) {
vendor: 6,179 bytes, lines 10741-10874
10741 var _a = MDCFloatingLabelFoundation.cssClasses, LABEL_FLOAT_ABOVE = _a.LABEL_FLOAT_ABOVE, LABEL_SHAKE = _a.LABEL_SHAKE; 10742 if (shouldFloat) { 10743 this.adapter.addClass(LABEL_FLOAT_ABOVE); 10744 } 10745 else { 10746 this.adapter.removeClass(LABEL_FLOAT_ABOVE); 10747 this.adapter.removeClass(LABEL_SHAKE); 10748 } 10749 }; 10750 /** 10751 * Styles the label as required. 10752 * @param isRequired If true, adds an asterisk to the label, indicating that it is required. 10753 */ 10754 MDCFloatingLabelFoundation.prototype.setRequired = function (isRequired) { 10755 var LABEL_REQUIRED = MDCFloatingLabelFoundation.cssClasses.LABEL_REQUIRED; 10756 if (isRequired) { 10757 this.adapter.addClass(LABEL_REQUIRED); 10758 } 10759 else { 10760 this.adapter.removeClass(LABEL_REQUIRED); 10761 } 10762 }; 10763 MDCFloatingLabelFoundation.prototype.handleShakeAnimationEnd_ = function () { 10764 var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE; 10765 this.adapter.removeClass(LABEL_SHAKE); 10766 }; 10767 return MDCFloatingLabelFoundation; 10768 }(MDCFoundation)); 10769 10770 /** 10771 * @license 10772 * Copyright 2016 Google Inc. 10773 * 10774 * Permission is hereby granted, free of charge, to any person obtaining a copy 10775 * of this software and associated documentation files (the "Software"), to deal 10776 * in the Software without restriction, including without limitation the rights 10777 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10778 * copies of the Software, and to permit persons to whom the Software is 10779 * furnished to do so, subject to the following conditions: 10780 * 10781 * The above copyright notice and this permission notice shall be included in 10782 * all copies or substantial portions of the Software. 10783 * 10784 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10785 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10786 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10787 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10788 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10789 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10790 * THE SOFTWARE. 10791 */ 10792 var MDCFloatingLabel = /** @class */ (function (_super) { 10793 __extends(MDCFloatingLabel, _super); 10794 function MDCFloatingLabel() { 10795 return _super !== null && _super.apply(this, arguments) || this; 10796 } 10797 MDCFloatingLabel.attachTo = function (root) { 10798 return new MDCFloatingLabel(root); 10799 }; 10800 /** 10801 * Styles the label to produce the label shake for errors. 10802 * @param shouldShake If true, shakes the label by adding a CSS class; otherwise, stops shaking by removing the class. 10803 */ 10804 MDCFloatingLabel.prototype.shake = function (shouldShake) { 10805 this.foundation.shake(shouldShake); 10806 }; 10807 /** 10808 * Styles the label to float/dock. 10809 * @param shouldFloat If true, floats the label by adding a CSS class; otherwise, docks it by removing the class. 10810 */ 10811 MDCFloatingLabel.prototype.float = function (shouldFloat) { 10812 this.foundation.float(shouldFloat); 10813 }; 10814 /** 10815 * Styles the label as required. 10816 * @param isRequired If true, adds an asterisk to the label, indicating that it is required. 10817 */ 10818 MDCFloatingLabel.prototype.setRequired = function (isRequired) { 10819 this.foundation.setRequired(isRequired); 10820 }; 10821 MDCFloatingLabel.prototype.getWidth = function () { 10822 return this.foundation.getWidth(); 10823 }; 10824 MDCFloatingLabel.prototype.getDefaultFoundation = function () { 10825 var _this = this; 10826 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 10827 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 10828 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 10829 var adapter = { 10830 addClass: function (className) { return _this.root.classList.add(className); }, 10831 removeClass: function (className) { return _this.root.classList.remove(className); }, 10832 getWidth: function () { return estimateScrollWidth(_this.root); }, 10833 registerInteractionHandler: function (evtType, handler) { 10834 return _this.listen(evtType, handler); 10835 }, 10836 deregisterInteractionHandler: function (evtType, handler) { 10837 return _this.unlisten(evtType, handler); 10838 }, 10839 }; 10840 // tslint:enable:object-literal-sort-keys 10841 return new MDCFloatingLabelFoundation(adapter); 10842 }; 10843 return MDCFloatingLabel; 10844 }(MDCComponent)); 10845 10846 /** 10847 * @license 10848 * Copyright 2018 Google Inc. 10849 * 10850 * Permission is hereby granted, free of charge, to any person obtaining a copy 10851 * of this software and associated documentation files (the "Software"), to deal 10852 * in the Software without restriction, including without limitation the rights 10853 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10854 * copies of the Software, and to permit persons to whom the Software is 10855 * furnished to do so, subject to the following conditions: 10856 * 10857 * The above copyright notice and this permission notice shall be included in 10858 * all copies or substantial portions of the Software. 10859 * 10860 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10861 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10862 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10863 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10864 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10865 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10866 * THE SOFTWARE. 10867 */ 10868 var strings$m = { 10869 NOTCH_ELEMENT_SELECTOR: '.mdc-notched-outline__notch', 10870 }; 10871 var numbers$7 = { 10872 // This should stay in sync with $mdc-notched-outline-padding * 2. 10873 NOTCH_ELEMENT_PADDING: 8, 10874 };
vendor: 5,740 bytes, lines 10875-11001
10875 var cssClasses$i = { 10876 NO_LABEL: 'mdc-notched-outline--no-label', 10877 OUTLINE_NOTCHED: 'mdc-notched-outline--notched', 10878 OUTLINE_UPGRADED: 'mdc-notched-outline--upgraded', 10879 }; 10880 10881 /** 10882 * @license 10883 * Copyright 2017 Google Inc. 10884 * 10885 * Permission is hereby granted, free of charge, to any person obtaining a copy 10886 * of this software and associated documentation files (the "Software"), to deal 10887 * in the Software without restriction, including without limitation the rights 10888 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10889 * copies of the Software, and to permit persons to whom the Software is 10890 * furnished to do so, subject to the following conditions: 10891 * 10892 * The above copyright notice and this permission notice shall be included in 10893 * all copies or substantial portions of the Software. 10894 * 10895 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10896 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10897 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10898 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10899 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10900 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10901 * THE SOFTWARE. 10902 */ 10903 var MDCNotchedOutlineFoundation = /** @class */ (function (_super) { 10904 __extends(MDCNotchedOutlineFoundation, _super); 10905 function MDCNotchedOutlineFoundation(adapter) { 10906 return _super.call(this, __assign(__assign({}, MDCNotchedOutlineFoundation.defaultAdapter), adapter)) || this; 10907 } 10908 Object.defineProperty(MDCNotchedOutlineFoundation, "strings", { 10909 get: function () { 10910 return strings$m; 10911 }, 10912 enumerable: true, 10913 configurable: true 10914 }); 10915 Object.defineProperty(MDCNotchedOutlineFoundation, "cssClasses", { 10916 get: function () { 10917 return cssClasses$i; 10918 }, 10919 enumerable: true, 10920 configurable: true 10921 }); 10922 Object.defineProperty(MDCNotchedOutlineFoundation, "numbers", { 10923 get: function () { 10924 return numbers$7; 10925 }, 10926 enumerable: true, 10927 configurable: true 10928 }); 10929 Object.defineProperty(MDCNotchedOutlineFoundation, "defaultAdapter", { 10930 /** 10931 * See {@link MDCNotchedOutlineAdapter} for typing information on parameters and return types. 10932 */ 10933 get: function () { 10934 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 10935 return { 10936 addClass: function () { return undefined; }, 10937 removeClass: function () { return undefined; }, 10938 setNotchWidthProperty: function () { return undefined; }, 10939 removeNotchWidthProperty: function () { return undefined; }, 10940 }; 10941 // tslint:enable:object-literal-sort-keys 10942 }, 10943 enumerable: true, 10944 configurable: true 10945 }); 10946 /** 10947 * Adds the outline notched selector and updates the notch width calculated based off of notchWidth. 10948 */ 10949 MDCNotchedOutlineFoundation.prototype.notch = function (notchWidth) { 10950 var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED; 10951 if (notchWidth > 0) { 10952 notchWidth += numbers$7.NOTCH_ELEMENT_PADDING; // Add padding from left/right. 10953 } 10954 this.adapter.setNotchWidthProperty(notchWidth); 10955 this.adapter.addClass(OUTLINE_NOTCHED); 10956 }; 10957 /** 10958 * Removes notched outline selector to close the notch in the outline. 10959 */ 10960 MDCNotchedOutlineFoundation.prototype.closeNotch = function () { 10961 var OUTLINE_NOTCHED = MDCNotchedOutlineFoundation.cssClasses.OUTLINE_NOTCHED; 10962 this.adapter.removeClass(OUTLINE_NOTCHED); 10963 this.adapter.removeNotchWidthProperty(); 10964 }; 10965 return MDCNotchedOutlineFoundation; 10966 }(MDCFoundation)); 10967 10968 /** 10969 * @license 10970 * Copyright 2017 Google Inc. 10971 * 10972 * Permission is hereby granted, free of charge, to any person obtaining a copy 10973 * of this software and associated documentation files (the "Software"), to deal 10974 * in the Software without restriction, including without limitation the rights 10975 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10976 * copies of the Software, and to permit persons to whom the Software is 10977 * furnished to do so, subject to the following conditions: 10978 * 10979 * The above copyright notice and this permission notice shall be included in 10980 * all copies or substantial portions of the Software. 10981 * 10982 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10983 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 10984 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 10985 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 10986 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 10987 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 10988 * THE SOFTWARE. 10989 */ 10990 var MDCNotchedOutline = /** @class */ (function (_super) { 10991 __extends(MDCNotchedOutline, _super); 10992 function MDCNotchedOutline() { 10993 return _super !== null && _super.apply(this, arguments) || this; 10994 } 10995 MDCNotchedOutline.attachTo = function (root) { 10996 return new MDCNotchedOutline(root); 10997 }; 10998 MDCNotchedOutline.prototype.initialSyncWithDOM = function () { 10999 this.notchElement_ = 11000 this.root.querySelector(strings$m.NOTCH_ELEMENT_SELECTOR); 11001 var label = this.root.querySelector('.' + MDCFloatingLabelFoundation.cssClasse
11001s.ROOT); 11002 if (label) { 11003 label.style.transitionDuration = '0s'; 11004 this.root.classList.add(cssClasses$i.OUTLINE_UPGRADED); 11005 requestAnimationFrame(function () { 11006 label.style.transitionDuration = ''; 11007 }); 11008 } 11009 else { 11010 this.root.classList.add(cssClasses$i.NO_LABEL); 11011 } 11012 }; 11013 /** 11014 * Updates classes and styles to open the notch to the specified width. 11015 * @param notchWidth The notch width in the outline. 11016 */ 11017 MDCNotchedOutline.prototype.notch = function (notchWidth) { 11018 this.foundation.notch(notchWidth); 11019 }; 11020 /** 11021 * Updates classes and styles to close the notch. 11022 */ 11023 MDCNotchedOutline.prototype.closeNotch = function () { 11024 this.foundation.closeNotch(); 11025 }; 11026 MDCNotchedOutline.prototype.getDefaultFoundation = function () { 11027 var _this = this; 11028 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 11029 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 11030 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 11031 var adapter = { 11032 addClass: function (className) { return _this.root.classList.add(className); }, 11033 removeClass: function (className) { return _this.root.classList.remove(className); }, 11034 setNotchWidthProperty: function (width) { 11035 return _this.notchElement_.style.setProperty('width', width + 'px'); 11036 }, 11037 removeNotchWidthProperty: function () { 11038 return _this.notchElement_.style.removeProperty('width'); 11039 }, 11040 }; 11041 // tslint:enable:object-literal-sort-keys 11042 return new MDCNotchedOutlineFoundation(adapter); 11043 }; 11044 return MDCNotchedOutline; 11045 }(MDCComponent)); 11046 11047 /** 11048 * @license 11049 * Copyright 2019 Google Inc. 11050 * 11051 * Permission is hereby granted, free of charge, to any person obtaining a copy 11052 * of this software and associated documentation files (the "Software"), to deal 11053 * in the Software without restriction, including without limitation the rights 11054 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11055 * copies of the Software, and to permit persons to whom the Software is 11056 * furnished to do so, subject to the following conditions: 11057 * 11058 * The above copyright notice and this permission notice shall be included in 11059 * all copies or substantial portions of the Software. 11060 * 11061 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11062 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11063 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 11064 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11065 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 11066 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 11067 * THE SOFTWARE. 11068 */
vendor: 15,414 bytes, lines 11069-11403
11069 var cssClasses$h = { 11070 ROOT: 'mdc-text-field-character-counter', 11071 }; 11072 var strings$l = { 11073 ROOT_SELECTOR: "." + cssClasses$h.ROOT, 11074 }; 11075 11076 /** 11077 * @license 11078 * Copyright 2019 Google Inc. 11079 * 11080 * Permission is hereby granted, free of charge, to any person obtaining a copy 11081 * of this software and associated documentation files (the "Software"), to deal 11082 * in the Software without restriction, including without limitation the rights 11083 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11084 * copies of the Software, and to permit persons to whom the Software is 11085 * furnished to do so, subject to the following conditions: 11086 * 11087 * The above copyright notice and this permission notice shall be included in 11088 * all copies or substantial portions of the Software. 11089 * 11090 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11091 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11092 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 11093 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11094 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 11095 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 11096 * THE SOFTWARE. 11097 */ 11098 var MDCTextFieldCharacterCounterFoundation = /** @class */ (function (_super) { 11099 __extends(MDCTextFieldCharacterCounterFoundation, _super); 11100 function MDCTextFieldCharacterCounterFoundation(adapter) { 11101 return _super.call(this, __assign(__assign({}, MDCTextFieldCharacterCounterFoundation.defaultAdapter), adapter)) || this; 11102 } 11103 Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "cssClasses", { 11104 get: function () { 11105 return cssClasses$h; 11106 }, 11107 enumerable: true, 11108 configurable: true 11109 }); 11110 Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "strings", { 11111 get: function () { 11112 return strings$l; 11113 }, 11114 enumerable: true, 11115 configurable: true 11116 }); 11117 Object.defineProperty(MDCTextFieldCharacterCounterFoundation, "defaultAdapter", { 11118 /** 11119 * See {@link MDCTextFieldCharacterCounterAdapter} for typing information on parameters and return types. 11120 */ 11121 get: function () { 11122 return { 11123 setContent: function () { return undefined; }, 11124 }; 11125 }, 11126 enumerable: true, 11127 configurable: true 11128 }); 11129 MDCTextFieldCharacterCounterFoundation.prototype.setCounterValue = function (currentLength, maxLength) { 11130 currentLength = Math.min(currentLength, maxLength); 11131 this.adapter.setContent(currentLength + " / " + maxLength); 11132 }; 11133 return MDCTextFieldCharacterCounterFoundation; 11134 }(MDCFoundation)); 11135 11136 /** 11137 * @license 11138 * Copyright 2019 Google Inc. 11139 * 11140 * Permission is hereby granted, free of charge, to any person obtaining a copy 11141 * of this software and associated documentation files (the "Software"), to deal 11142 * in the Software without restriction, including without limitation the rights 11143 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11144 * copies of the Software, and to permit persons to whom the Software is 11145 * furnished to do so, subject to the following conditions: 11146 * 11147 * The above copyright notice and this permission notice shall be included in 11148 * all copies or substantial portions of the Software. 11149 * 11150 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11151 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11152 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 11153 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11154 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 11155 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 11156 * THE SOFTWARE. 11157 */ 11158 var MDCTextFieldCharacterCounter = /** @class */ (function (_super) { 11159 __extends(MDCTextFieldCharacterCounter, _super); 11160 function MDCTextFieldCharacterCounter() { 11161 return _super !== null && _super.apply(this, arguments) || this; 11162 } 11163 MDCTextFieldCharacterCounter.attachTo = function (root) { 11164 return new MDCTextFieldCharacterCounter(root); 11165 }; 11166 Object.defineProperty(MDCTextFieldCharacterCounter.prototype, "foundationForTextField", { 11167 // Provided for access by MDCTextField component 11168 get: function () { 11169 return this.foundation; 11170 }, 11171 enumerable: true, 11172 configurable: true 11173 }); 11174 MDCTextFieldCharacterCounter.prototype.getDefaultFoundation = function () { 11175 var _this = this; 11176 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 11177 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 11178 var adapter = { 11179 setContent: function (content) { 11180 _this.root.textContent = content; 11181 }, 11182 }; 11183 return new MDCTextFieldCharacterCounterFoundation(adapter); 11184 }; 11185 return MDCTextFieldCharacterCounter; 11186 }(MDCComponent)); 11187 11188 /** 11189 * @license 11190 * Copyright 2016 Google Inc. 11191 * 11192 * Permission is hereby granted, free of charge, to any person obtaining a copy 11193 * of this software and associated documentation files (the "Software"), to deal 11194 * in the Software without restriction, including without limitation the rights 11195 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11196 * copies of the Software, and to permit persons to whom the Software is 11197 * furnished to do so, subject to the following conditions: 11198 * 11199 * The above copyright notice and this permission notice shall be included in 11200 * all copies or substantial portions of the Software. 11201 * 11202 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11203 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11204 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 11205 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11206 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 11207 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 11208 * THE SOFTWARE. 11209 */ 11210 var strings$k = { 11211 ARIA_CONTROLS: 'aria-controls', 11212 ARIA_DESCRIBEDBY: 'aria-describedby', 11213 INPUT_SELECTOR: '.mdc-text-field__input', 11214 LABEL_SELECTOR: '.mdc-floating-label', 11215 LEADING_ICON_SELECTOR: '.mdc-text-field__icon--leading', 11216 LINE_RIPPLE_SELECTOR: '.mdc-line-ripple', 11217 OUTLINE_SELECTOR: '.mdc-notched-outline', 11218 PREFIX_SELECTOR: '.mdc-text-field__affix--prefix', 11219 SUFFIX_SELECTOR: '.mdc-text-field__affix--suffix', 11220 TRAILING_ICON_SELECTOR: '.mdc-text-field__icon--trailing' 11221 }; 11222 var cssClasses$g = { 11223 DISABLED: 'mdc-text-field--disabled', 11224 FOCUSED: 'mdc-text-field--focused', 11225 HELPER_LINE: 'mdc-text-field-helper-line', 11226 INVALID: 'mdc-text-field--invalid', 11227 LABEL_FLOATING: 'mdc-text-field--label-floating', 11228 NO_LABEL: 'mdc-text-field--no-label', 11229 OUTLINED: 'mdc-text-field--outlined', 11230 ROOT: 'mdc-text-field', 11231 TEXTAREA: 'mdc-text-field--textarea', 11232 WITH_LEADING_ICON: 'mdc-text-field--with-leading-icon', 11233 WITH_TRAILING_ICON: 'mdc-text-field--with-trailing-icon', 11234 }; 11235 var numbers$6 = { 11236 LABEL_SCALE: 0.75, 11237 }; 11238 /** 11239 * Whitelist based off of https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation 11240 * under the "Validation-related attributes" section. 11241 */ 11242 var VALIDATION_ATTR_WHITELIST = [ 11243 'pattern', 'min', 'max', 'required', 'step', 'minlength', 'maxlength', 11244 ]; 11245 /** 11246 * Label should always float for these types as they show some UI even if value is empty. 11247 */ 11248 var ALWAYS_FLOAT_TYPES = [ 11249 'color', 'date', 'datetime-local', 'month', 'range', 'time', 'week', 11250 ]; 11251 11252 /** 11253 * @license 11254 * Copyright 2016 Google Inc. 11255 * 11256 * Permission is hereby granted, free of charge, to any person obtaining a copy 11257 * of this software and associated documentation files (the "Software"), to deal 11258 * in the Software without restriction, including without limitation the rights 11259 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11260 * copies of the Software, and to permit persons to whom the Software is 11261 * furnished to do so, subject to the following conditions: 11262 * 11263 * The above copyright notice and this permission notice shall be included in 11264 * all copies or substantial portions of the Software. 11265 * 11266 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11267 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11268 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 11269 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11270 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 11271 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 11272 * THE SOFTWARE. 11273 */ 11274 var POINTERDOWN_EVENTS = ['mousedown', 'touchstart']; 11275 var INTERACTION_EVENTS$2 = ['click', 'keydown']; 11276 var MDCTextFieldFoundation = /** @class */ (function (_super) { 11277 __extends(MDCTextFieldFoundation, _super); 11278 /** 11279 * @param adapter 11280 * @param foundationMap Map from subcomponent names to their subfoundations. 11281 */ 11282 function MDCTextFieldFoundation(adapter, foundationMap) { 11283 if (foundationMap === void 0) { foundationMap = {}; } 11284 var _this = _super.call(this, __assign(__assign({}, MDCTextFieldFoundation.defaultAdapter), adapter)) || this; 11285 _this.isFocused_ = false; 11286 _this.receivedUserInput_ = false; 11287 _this.isValid_ = true; 11288 _this.useNativeValidation_ = true; 11289 _this.validateOnValueChange_ = true; 11290 _this.helperText_ = foundationMap.helperText; 11291 _this.characterCounter_ = foundationMap.characterCounter; 11292 _this.leadingIcon_ = foundationMap.leadingIcon; 11293 _this.trailingIcon_ = foundationMap.trailingIcon; 11294 _this.inputFocusHandler_ = function () { return _this.activateFocus(); }; 11295 _this.inputBlurHandler_ = function () { return _this.deactivateFocus(); }; 11296 _this.inputInputHandler_ = function () { return _this.handleInput(); }; 11297 _this.setPointerXOffset_ = function (evt) { return _this.setTransformOrigin(evt); }; 11298 _this.textFieldInteractionHandler_ = function () { return _this.handleTextFieldInteraction(); }; 11299 _this.validationAttributeChangeHandler_ = function (attributesList) { 11300 return _this.handleValidationAttributeChange(attributesList); 11301 }; 11302 return _this; 11303 } 11304 Object.defineProperty(MDCTextFieldFoundation, "cssClasses", { 11305 get: function () { 11306 return cssClasses$g; 11307 }, 11308 enumerable: true, 11309 configurable: true 11310 }); 11311 Object.defineProperty(MDCTextFieldFoundation, "strings", { 11312 get: function () { 11313 return strings$k; 11314 }, 11315 enumerable: true, 11316 configurable: true 11317 }); 11318 Object.defineProperty(MDCTextFieldFoundation, "numbers", { 11319 get: function () { 11320 return numbers$6; 11321 }, 11322 enumerable: true, 11323 configurable: true 11324 }); 11325 Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldAlwaysFloat_", { 11326 get: function () { 11327 var type = this.getNativeInput_().type; 11328 return ALWAYS_FLOAT_TYPES.indexOf(type) >= 0; 11329 }, 11330 enumerable: true, 11331 configurable: true 11332 }); 11333 Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldFloat", { 11334 get: function () { 11335 return this.shouldAlwaysFloat_ || this.isFocused_ || !!this.getValue() || 11336 this.isBadInput_(); 11337 }, 11338 enumerable: true, 11339 configurable: true 11340 }); 11341 Object.defineProperty(MDCTextFieldFoundation.prototype, "shouldShake", { 11342 get: function () { 11343 return !this.isFocused_ && !this.isValid() && !!this.getValue(); 11344 }, 11345 enumerable: true, 11346 configurable: true 11347 }); 11348 Object.defineProperty(MDCTextFieldFoundation, "defaultAdapter", { 11349 /** 11350 * See {@link MDCTextFieldAdapter} for typing information on parameters and 11351 * return types. 11352 */ 11353 get: function () { 11354 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 11355 return { 11356 addClass: function () { return undefined; }, 11357 removeClass: function () { return undefined; }, 11358 hasClass: function () { return true; }, 11359 setInputAttr: function () { return undefined; }, 11360 removeInputAttr: function () { return undefined; }, 11361 registerTextFieldInteractionHandler: function () { return undefined; }, 11362 deregisterTextFieldInteractionHandler: function () { return undefined; }, 11363 registerInputInteractionHandler: function () { return undefined; }, 11364 deregisterInputInteractionHandler: function () { return undefined; }, 11365 registerValidationAttributeChangeHandler: function () { 11366 return new MutationObserver(function () { return undefined; }); 11367 }, 11368 deregisterValidationAttributeChangeHandler: function () { return undefined; }, 11369 getNativeInput: function () { return null; }, 11370 isFocused: function () { return false; }, 11371 activateLineRipple: function () { return undefined; }, 11372 deactivateLineRipple: function () { return undefined; }, 11373 setLineRippleTransformOrigin: function () { return undefined; }, 11374 shakeLabel: function () { return undefined; }, 11375 floatLabel: function () { return undefined; }, 11376 setLabelRequired: function () { return undefined; }, 11377 hasLabel: function () { return false; }, 11378 getLabelWidth: function () { return 0; }, 11379 hasOutline: function () { return false; }, 11380 notchOutline: function () { return undefined; }, 11381 closeOutline: function () { return undefined; }, 11382 }; 11383 // tslint:enable:object-literal-sort-keys 11384 }, 11385 enumerable: true, 11386 configurable: true 11387 }); 11388 MDCTextFieldFoundation.prototype.init = function () { 11389 var _this = this; 11390 if (this.adapter.hasLabel() && this.getNativeInput_().required) { 11391 this.adapter.setLabelRequired(true); 11392 } 11393 if (this.adapter.isFocused()) { 11394 this.inputFocusHandler_(); 11395 } 11396 else if (this.adapter.hasLabel() && this.shouldFloat) { 11397 this.notchOutline(true); 11398 this.adapter.floatLabel(true); 11399 this.styleFloating_(true); 11400 } 11401 this.adapter.registerInputInteractionHandler('focus', this.inputFocusHandler_); 11402 this.adapter.registerInputInteractionHandler('blur', this.inputBlurHandler_); 11403 this.adapter.registerInputInteractionHandler('input', this.inputInputHandler_);
vendor: 5,009 bytes, lines 11404-11522
11404 POINTERDOWN_EVENTS.forEach(function (evtType) { 11405 _this.adapter.registerInputInteractionHandler(evtType, _this.setPointerXOffset_); 11406 }); 11407 INTERACTION_EVENTS$2.forEach(function (evtType) { 11408 _this.adapter.registerTextFieldInteractionHandler(evtType, _this.textFieldInteractionHandler_); 11409 }); 11410 this.validationObserver_ = 11411 this.adapter.registerValidationAttributeChangeHandler(this.validationAttributeChangeHandler_); 11412 this.setCharacterCounter_(this.getValue().length); 11413 }; 11414 MDCTextFieldFoundation.prototype.destroy = function () { 11415 var _this = this; 11416 this.adapter.deregisterInputInteractionHandler('focus', this.inputFocusHandler_); 11417 this.adapter.deregisterInputInteractionHandler('blur', this.inputBlurHandler_); 11418 this.adapter.deregisterInputInteractionHandler('input', this.inputInputHandler_); 11419 POINTERDOWN_EVENTS.forEach(function (evtType) { 11420 _this.adapter.deregisterInputInteractionHandler(evtType, _this.setPointerXOffset_); 11421 }); 11422 INTERACTION_EVENTS$2.forEach(function (evtType) { 11423 _this.adapter.deregisterTextFieldInteractionHandler(evtType, _this.textFieldInteractionHandler_); 11424 }); 11425 this.adapter.deregisterValidationAttributeChangeHandler(this.validationObserver_); 11426 }; 11427 /** 11428 * Handles user interactions with the Text Field. 11429 */ 11430 MDCTextFieldFoundation.prototype.handleTextFieldInteraction = function () { 11431 var nativeInput = this.adapter.getNativeInput(); 11432 if (nativeInput && nativeInput.disabled) { 11433 return; 11434 } 11435 this.receivedUserInput_ = true; 11436 }; 11437 /** 11438 * Handles validation attribute changes 11439 */ 11440 MDCTextFieldFoundation.prototype.handleValidationAttributeChange = function (attributesList) { 11441 var _this = this; 11442 attributesList.some(function (attributeName) { 11443 if (VALIDATION_ATTR_WHITELIST.indexOf(attributeName) > -1) { 11444 _this.styleValidity_(true); 11445 _this.adapter.setLabelRequired(_this.getNativeInput_().required); 11446 return true; 11447 } 11448 return false; 11449 }); 11450 if (attributesList.indexOf('maxlength') > -1) { 11451 this.setCharacterCounter_(this.getValue().length); 11452 } 11453 }; 11454 /** 11455 * Opens/closes the notched outline. 11456 */ 11457 MDCTextFieldFoundation.prototype.notchOutline = function (openNotch) { 11458 if (!this.adapter.hasOutline() || !this.adapter.hasLabel()) { 11459 return; 11460 } 11461 if (openNotch) { 11462 var labelWidth = this.adapter.getLabelWidth() * numbers$6.LABEL_SCALE; 11463 this.adapter.notchOutline(labelWidth); 11464 } 11465 else { 11466 this.adapter.closeOutline(); 11467 } 11468 }; 11469 /** 11470 * Activates the text field focus state. 11471 */ 11472 MDCTextFieldFoundation.prototype.activateFocus = function () { 11473 this.isFocused_ = true; 11474 this.styleFocused_(this.isFocused_); 11475 this.adapter.activateLineRipple(); 11476 if (this.adapter.hasLabel()) { 11477 this.notchOutline(this.shouldFloat); 11478 this.adapter.floatLabel(this.shouldFloat); 11479 this.styleFloating_(this.shouldFloat); 11480 this.adapter.shakeLabel(this.shouldShake); 11481 } 11482 if (this.helperText_ && 11483 (this.helperText_.isPersistent() || !this.helperText_.isValidation() || 11484 !this.isValid_)) { 11485 this.helperText_.showToScreenReader(); 11486 } 11487 }; 11488 /** 11489 * Sets the line ripple's transform origin, so that the line ripple activate 11490 * animation will animate out from the user's click location. 11491 */ 11492 MDCTextFieldFoundation.prototype.setTransformOrigin = function (evt) { 11493 if (this.isDisabled() || this.adapter.hasOutline()) { 11494 return; 11495 } 11496 var touches = evt.touches; 11497 var targetEvent = touches ? touches[0] : evt; 11498 var targetClientRect = targetEvent.target.getBoundingClientRect(); 11499 var normalizedX = targetEvent.clientX - targetClientRect.left; 11500 this.adapter.setLineRippleTransformOrigin(normalizedX); 11501 }; 11502 /** 11503 * Handles input change of text input and text area. 11504 */ 11505 MDCTextFieldFoundation.prototype.handleInput = function () { 11506 this.autoCompleteFocus(); 11507 this.setCharacterCounter_(this.getValue().length); 11508 }; 11509 /** 11510 * Activates the Text Field's focus state in cases when the input value 11511 * changes without user input (e.g. programmatically). 11512 */ 11513 MDCTextFieldFoundation.prototype.autoCompleteFocus = function () { 11514 if (!this.receivedUserInput_) { 11515 this.activateFocus(); 11516 } 11517 }; 11518 /** 11519 * Deactivates the Text Field's focus state. 11520 */ 11521 MDCTextFieldFoundation.prototype.deactivateFocus = function () { 11522 this.isFocused_ = false;
vendor: 5,451 bytes, lines 11523-11669
11523 this.adapter.deactivateLineRipple(); 11524 var isValid = this.isValid(); 11525 this.styleValidity_(isValid); 11526 this.styleFocused_(this.isFocused_); 11527 if (this.adapter.hasLabel()) { 11528 this.notchOutline(this.shouldFloat); 11529 this.adapter.floatLabel(this.shouldFloat); 11530 this.styleFloating_(this.shouldFloat); 11531 this.adapter.shakeLabel(this.shouldShake); 11532 } 11533 if (!this.shouldFloat) { 11534 this.receivedUserInput_ = false; 11535 } 11536 }; 11537 MDCTextFieldFoundation.prototype.getValue = function () { 11538 return this.getNativeInput_().value; 11539 }; 11540 /** 11541 * @param value The value to set on the input Element. 11542 */ 11543 MDCTextFieldFoundation.prototype.setValue = function (value) { 11544 // Prevent Safari from moving the caret to the end of the input when the 11545 // value has not changed. 11546 if (this.getValue() !== value) { 11547 this.getNativeInput_().value = value; 11548 } 11549 this.setCharacterCounter_(value.length); 11550 if (this.validateOnValueChange_) { 11551 var isValid = this.isValid(); 11552 this.styleValidity_(isValid); 11553 } 11554 if (this.adapter.hasLabel()) { 11555 this.notchOutline(this.shouldFloat); 11556 this.adapter.floatLabel(this.shouldFloat); 11557 this.styleFloating_(this.shouldFloat); 11558 if (this.validateOnValueChange_) { 11559 this.adapter.shakeLabel(this.shouldShake); 11560 } 11561 } 11562 }; 11563 /** 11564 * @return The custom validity state, if set; otherwise, the result of a 11565 * native validity check. 11566 */ 11567 MDCTextFieldFoundation.prototype.isValid = function () { 11568 return this.useNativeValidation_ ? this.isNativeInputValid_() : 11569 this.isValid_; 11570 }; 11571 /** 11572 * @param isValid Sets the custom validity state of the Text Field. 11573 */ 11574 MDCTextFieldFoundation.prototype.setValid = function (isValid) { 11575 this.isValid_ = isValid; 11576 this.styleValidity_(isValid); 11577 var shouldShake = !isValid && !this.isFocused_ && !!this.getValue(); 11578 if (this.adapter.hasLabel()) { 11579 this.adapter.shakeLabel(shouldShake); 11580 } 11581 }; 11582 /** 11583 * @param shouldValidate Whether or not validity should be updated on 11584 * value change. 11585 */ 11586 MDCTextFieldFoundation.prototype.setValidateOnValueChange = function (shouldValidate) { 11587 this.validateOnValueChange_ = shouldValidate; 11588 }; 11589 /** 11590 * @return Whether or not validity should be updated on value change. `true` 11591 * by default. 11592 */ 11593 MDCTextFieldFoundation.prototype.getValidateOnValueChange = function () { 11594 return this.validateOnValueChange_; 11595 }; 11596 /** 11597 * Enables or disables the use of native validation. Use this for custom 11598 * validation. 11599 * @param useNativeValidation Set this to false to ignore native input 11600 * validation. 11601 */ 11602 MDCTextFieldFoundation.prototype.setUseNativeValidation = function (useNativeValidation) { 11603 this.useNativeValidation_ = useNativeValidation; 11604 }; 11605 MDCTextFieldFoundation.prototype.isDisabled = function () { 11606 return this.getNativeInput_().disabled; 11607 }; 11608 /** 11609 * @param disabled Sets the text-field disabled or enabled. 11610 */ 11611 MDCTextFieldFoundation.prototype.setDisabled = function (disabled) { 11612 this.getNativeInput_().disabled = disabled; 11613 this.styleDisabled_(disabled); 11614 }; 11615 /** 11616 * @param content Sets the content of the helper text. 11617 */ 11618 MDCTextFieldFoundation.prototype.setHelperTextContent = function (content) { 11619 if (this.helperText_) { 11620 this.helperText_.setContent(content); 11621 } 11622 }; 11623 /** 11624 * Sets the aria label of the leading icon. 11625 */ 11626 MDCTextFieldFoundation.prototype.setLeadingIconAriaLabel = function (label) { 11627 if (this.leadingIcon_) { 11628 this.leadingIcon_.setAriaLabel(label); 11629 } 11630 }; 11631 /** 11632 * Sets the text content of the leading icon. 11633 */ 11634 MDCTextFieldFoundation.prototype.setLeadingIconContent = function (content) { 11635 if (this.leadingIcon_) { 11636 this.leadingIcon_.setContent(content); 11637 } 11638 }; 11639 /** 11640 * Sets the aria label of the trailing icon. 11641 */ 11642 MDCTextFieldFoundation.prototype.setTrailingIconAriaLabel = function (label) { 11643 if (this.trailingIcon_) { 11644 this.trailingIcon_.setAriaLabel(label); 11645 } 11646 }; 11647 /** 11648 * Sets the text content of the trailing icon. 11649 */ 11650 MDCTextFieldFoundation.prototype.setTrailingIconContent = function (content) { 11651 if (this.trailingIcon_) { 11652 this.trailingIcon_.setContent(content); 11653 } 11654 }; 11655 /** 11656 * Sets character counter values that shows characters used and the total 11657 * character limit. 11658 */ 11659 MDCTextFieldFoundation.prototype.setCharacterCounter_ = function (currentLength) { 11660 if (!this.characterCounter_) { 11661 return; 11662 } 11663 var maxLength = this.getNativeInput_().maxLength; 11664 if (maxLength === -1) { 11665 throw new Error('MDCTextFieldFoundation: Expected maxlength html property on text input or textarea.'); 11666 } 11667 this.characterCounter_.setCounterValue(currentLength, maxLength); 11668 }; 11669 /**
vendor: 9,533 bytes, lines 11670-11897
11670 * @return True if the Text Field input fails in converting the user-supplied 11671 * value. 11672 */ 11673 MDCTextFieldFoundation.prototype.isBadInput_ = function () { 11674 // The badInput property is not supported in IE 11 ð©. 11675 return this.getNativeInput_().validity.badInput || false; 11676 }; 11677 /** 11678 * @return The result of native validity checking (ValidityState.valid). 11679 */ 11680 MDCTextFieldFoundation.prototype.isNativeInputValid_ = function () { 11681 return this.getNativeInput_().validity.valid; 11682 }; 11683 /** 11684 * Styles the component based on the validity state. 11685 */ 11686 MDCTextFieldFoundation.prototype.styleValidity_ = function (isValid) { 11687 var INVALID = MDCTextFieldFoundation.cssClasses.INVALID; 11688 if (isValid) { 11689 this.adapter.removeClass(INVALID); 11690 } 11691 else { 11692 this.adapter.addClass(INVALID); 11693 } 11694 if (this.helperText_) { 11695 this.helperText_.setValidity(isValid); 11696 // We dynamically set or unset aria-describedby for validation helper text 11697 // only, based on whether the field is valid 11698 var helperTextValidation = this.helperText_.isValidation(); 11699 if (!helperTextValidation) { 11700 return; 11701 } 11702 var helperTextVisible = this.helperText_.isVisible(); 11703 var helperTextId = this.helperText_.getId(); 11704 if (helperTextVisible && helperTextId) { 11705 this.adapter.setInputAttr(strings$k.ARIA_DESCRIBEDBY, helperTextId); 11706 } 11707 else { 11708 this.adapter.removeInputAttr(strings$k.ARIA_DESCRIBEDBY); 11709 } 11710 } 11711 }; 11712 /** 11713 * Styles the component based on the focused state. 11714 */ 11715 MDCTextFieldFoundation.prototype.styleFocused_ = function (isFocused) { 11716 var FOCUSED = MDCTextFieldFoundation.cssClasses.FOCUSED; 11717 if (isFocused) { 11718 this.adapter.addClass(FOCUSED); 11719 } 11720 else { 11721 this.adapter.removeClass(FOCUSED); 11722 } 11723 }; 11724 /** 11725 * Styles the component based on the disabled state. 11726 */ 11727 MDCTextFieldFoundation.prototype.styleDisabled_ = function (isDisabled) { 11728 var _a = MDCTextFieldFoundation.cssClasses, DISABLED = _a.DISABLED, INVALID = _a.INVALID; 11729 if (isDisabled) { 11730 this.adapter.addClass(DISABLED); 11731 this.adapter.removeClass(INVALID); 11732 } 11733 else { 11734 this.adapter.removeClass(DISABLED); 11735 } 11736 if (this.leadingIcon_) { 11737 this.leadingIcon_.setDisabled(isDisabled); 11738 } 11739 if (this.trailingIcon_) { 11740 this.trailingIcon_.setDisabled(isDisabled); 11741 } 11742 }; 11743 /** 11744 * Styles the component based on the label floating state. 11745 */ 11746 MDCTextFieldFoundation.prototype.styleFloating_ = function (isFloating) { 11747 var LABEL_FLOATING = MDCTextFieldFoundation.cssClasses.LABEL_FLOATING; 11748 if (isFloating) { 11749 this.adapter.addClass(LABEL_FLOATING); 11750 } 11751 else { 11752 this.adapter.removeClass(LABEL_FLOATING); 11753 } 11754 }; 11755 /** 11756 * @return The native text input element from the host environment, or an 11757 * object with the same shape for unit tests. 11758 */ 11759 MDCTextFieldFoundation.prototype.getNativeInput_ = function () { 11760 // this.adapter may be undefined in foundation unit tests. This happens when 11761 // testdouble is creating a mock object and invokes the 11762 // shouldShake/shouldFloat getters (which in turn call getValue(), which 11763 // calls this method) before init() has been called from the MDCTextField 11764 // constructor. To work around that issue, we return a dummy object. 11765 var nativeInput = this.adapter ? this.adapter.getNativeInput() : null; 11766 return nativeInput || { 11767 disabled: false, 11768 maxLength: -1, 11769 required: false, 11770 type: 'input', 11771 validity: { 11772 badInput: false, 11773 valid: true, 11774 }, 11775 value: '', 11776 }; 11777 }; 11778 return MDCTextFieldFoundation; 11779 }(MDCFoundation)); 11780 11781 /** 11782 * @license 11783 * Copyright 2016 Google Inc. 11784 * 11785 * Permission is hereby granted, free of charge, to any person obtaining a copy 11786 * of this software and associated documentation files (the "Software"), to deal 11787 * in the Software without restriction, including without limitation the rights 11788 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11789 * copies of the Software, and to permit persons to whom the Software is 11790 * furnished to do so, subject to the following conditions: 11791 * 11792 * The above copyright notice and this permission notice shall be included in 11793 * all copies or substantial portions of the Software. 11794 * 11795 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11796 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11797 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 11798 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11799 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 11800 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 11801 * THE SOFTWARE. 11802 */ 11803 var cssClasses$f = { 11804 HELPER_TEXT_PERSISTENT: 'mdc-text-field-helper-text--persistent', 11805 HELPER_TEXT_VALIDATION_MSG: 'mdc-text-field-helper-text--validation-msg', 11806 ROOT: 'mdc-text-field-helper-text', 11807 }; 11808 var strings$j = { 11809 ARIA_HIDDEN: 'aria-hidden', 11810 ROLE: 'role', 11811 ROOT_SELECTOR: "." + cssClasses$f.ROOT, 11812 }; 11813 11814 /** 11815 * @license 11816 * Copyright 2017 Google Inc. 11817 * 11818 * Permission is hereby granted, free of charge, to any person obtaining a copy 11819 * of this software and associated documentation files (the "Software"), to deal 11820 * in the Software without restriction, including without limitation the rights 11821 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11822 * copies of the Software, and to permit persons to whom the Software is 11823 * furnished to do so, subject to the following conditions: 11824 * 11825 * The above copyright notice and this permission notice shall be included in 11826 * all copies or substantial portions of the Software. 11827 * 11828 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11829 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11830 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 11831 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11832 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 11833 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 11834 * THE SOFTWARE. 11835 */ 11836 var MDCTextFieldHelperTextFoundation = /** @class */ (function (_super) { 11837 __extends(MDCTextFieldHelperTextFoundation, _super); 11838 function MDCTextFieldHelperTextFoundation(adapter) { 11839 return _super.call(this, __assign(__assign({}, MDCTextFieldHelperTextFoundation.defaultAdapter), adapter)) || this; 11840 } 11841 Object.defineProperty(MDCTextFieldHelperTextFoundation, "cssClasses", { 11842 get: function () { 11843 return cssClasses$f; 11844 }, 11845 enumerable: true, 11846 configurable: true 11847 }); 11848 Object.defineProperty(MDCTextFieldHelperTextFoundation, "strings", { 11849 get: function () { 11850 return strings$j; 11851 }, 11852 enumerable: true, 11853 configurable: true 11854 }); 11855 Object.defineProperty(MDCTextFieldHelperTextFoundation, "defaultAdapter", { 11856 /** 11857 * See {@link MDCTextFieldHelperTextAdapter} for typing information on parameters and return types. 11858 */ 11859 get: function () { 11860 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 11861 return { 11862 addClass: function () { return undefined; }, 11863 removeClass: function () { return undefined; }, 11864 hasClass: function () { return false; }, 11865 getAttr: function () { return null; }, 11866 setAttr: function () { return undefined; }, 11867 removeAttr: function () { return undefined; }, 11868 setContent: function () { return undefined; }, 11869 }; 11870 // tslint:enable:object-literal-sort-keys 11871 }, 11872 enumerable: true, 11873 configurable: true 11874 }); 11875 MDCTextFieldHelperTextFoundation.prototype.getId = function () { 11876 return this.adapter.getAttr('id'); 11877 }; 11878 MDCTextFieldHelperTextFoundation.prototype.isVisible = function () { 11879 return this.adapter.getAttr(strings$j.ARIA_HIDDEN) !== 'true'; 11880 }; 11881 /** 11882 * Sets the content of the helper text field. 11883 */ 11884 MDCTextFieldHelperTextFoundation.prototype.setContent = function (content) { 11885 this.adapter.setContent(content); 11886 }; 11887 MDCTextFieldHelperTextFoundation.prototype.isPersistent = function () { 11888 return this.adapter.hasClass(cssClasses$f.HELPER_TEXT_PERSISTENT); 11889 }; 11890 /** 11891 * @param isPersistent Sets the persistency of the helper text. 11892 */ 11893 MDCTextFieldHelperTextFoundation.prototype.setPersistent = function (isPersistent) { 11894 if (isPersistent) { 11895 this.adapter.addClass(cssClasses$f.HELPER_TEXT_PERSISTENT); 11896 } 11897 else {
vendor: 14,125 bytes, lines 11898-12200
11898 this.adapter.removeClass(cssClasses$f.HELPER_TEXT_PERSISTENT); 11899 } 11900 }; 11901 /** 11902 * @return whether the helper text acts as an error validation message. 11903 */ 11904 MDCTextFieldHelperTextFoundation.prototype.isValidation = function () { 11905 return this.adapter.hasClass(cssClasses$f.HELPER_TEXT_VALIDATION_MSG); 11906 }; 11907 /** 11908 * @param isValidation True to make the helper text act as an error validation message. 11909 */ 11910 MDCTextFieldHelperTextFoundation.prototype.setValidation = function (isValidation) { 11911 if (isValidation) { 11912 this.adapter.addClass(cssClasses$f.HELPER_TEXT_VALIDATION_MSG); 11913 } 11914 else { 11915 this.adapter.removeClass(cssClasses$f.HELPER_TEXT_VALIDATION_MSG); 11916 } 11917 }; 11918 /** 11919 * Makes the helper text visible to the screen reader. 11920 */ 11921 MDCTextFieldHelperTextFoundation.prototype.showToScreenReader = function () { 11922 this.adapter.removeAttr(strings$j.ARIA_HIDDEN); 11923 }; 11924 /** 11925 * Sets the validity of the helper text based on the input validity. 11926 */ 11927 MDCTextFieldHelperTextFoundation.prototype.setValidity = function (inputIsValid) { 11928 var helperTextIsPersistent = this.adapter.hasClass(cssClasses$f.HELPER_TEXT_PERSISTENT); 11929 var helperTextIsValidationMsg = this.adapter.hasClass(cssClasses$f.HELPER_TEXT_VALIDATION_MSG); 11930 var validationMsgNeedsDisplay = helperTextIsValidationMsg && !inputIsValid; 11931 if (validationMsgNeedsDisplay) { 11932 this.showToScreenReader(); 11933 this.adapter.setAttr(strings$j.ROLE, 'alert'); 11934 } 11935 else { 11936 this.adapter.removeAttr(strings$j.ROLE); 11937 } 11938 if (!helperTextIsPersistent && !validationMsgNeedsDisplay) { 11939 this.hide_(); 11940 } 11941 }; 11942 /** 11943 * Hides the help text from screen readers. 11944 */ 11945 MDCTextFieldHelperTextFoundation.prototype.hide_ = function () { 11946 this.adapter.setAttr(strings$j.ARIA_HIDDEN, 'true'); 11947 }; 11948 return MDCTextFieldHelperTextFoundation; 11949 }(MDCFoundation)); 11950 11951 /** 11952 * @license 11953 * Copyright 2017 Google Inc. 11954 * 11955 * Permission is hereby granted, free of charge, to any person obtaining a copy 11956 * of this software and associated documentation files (the "Software"), to deal 11957 * in the Software without restriction, including without limitation the rights 11958 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11959 * copies of the Software, and to permit persons to whom the Software is 11960 * furnished to do so, subject to the following conditions: 11961 * 11962 * The above copyright notice and this permission notice shall be included in 11963 * all copies or substantial portions of the Software. 11964 * 11965 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11966 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11967 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 11968 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 11969 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 11970 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 11971 * THE SOFTWARE. 11972 */ 11973 var MDCTextFieldHelperText = /** @class */ (function (_super) { 11974 __extends(MDCTextFieldHelperText, _super); 11975 function MDCTextFieldHelperText() { 11976 return _super !== null && _super.apply(this, arguments) || this; 11977 } 11978 MDCTextFieldHelperText.attachTo = function (root) { 11979 return new MDCTextFieldHelperText(root); 11980 }; 11981 Object.defineProperty(MDCTextFieldHelperText.prototype, "foundationForTextField", { 11982 // Provided for access by MDCTextField component 11983 get: function () { 11984 return this.foundation; 11985 }, 11986 enumerable: true, 11987 configurable: true 11988 }); 11989 MDCTextFieldHelperText.prototype.getDefaultFoundation = function () { 11990 var _this = this; 11991 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 11992 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 11993 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 11994 var adapter = { 11995 addClass: function (className) { return _this.root.classList.add(className); }, 11996 removeClass: function (className) { return _this.root.classList.remove(className); }, 11997 hasClass: function (className) { return _this.root.classList.contains(className); }, 11998 getAttr: function (attr) { return _this.root.getAttribute(attr); }, 11999 setAttr: function (attr, value) { return _this.root.setAttribute(attr, value); }, 12000 removeAttr: function (attr) { return _this.root.removeAttribute(attr); }, 12001 setContent: function (content) { 12002 _this.root.textContent = content; 12003 }, 12004 }; 12005 // tslint:enable:object-literal-sort-keys 12006 return new MDCTextFieldHelperTextFoundation(adapter); 12007 }; 12008 return MDCTextFieldHelperText; 12009 }(MDCComponent)); 12010 12011 /** 12012 * @license 12013 * Copyright 2016 Google Inc. 12014 * 12015 * Permission is hereby granted, free of charge, to any person obtaining a copy 12016 * of this software and associated documentation files (the "Software"), to deal 12017 * in the Software without restriction, including without limitation the rights 12018 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12019 * copies of the Software, and to permit persons to whom the Software is 12020 * furnished to do so, subject to the following conditions: 12021 * 12022 * The above copyright notice and this permission notice shall be included in 12023 * all copies or substantial portions of the Software. 12024 * 12025 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12026 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12027 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12028 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12029 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12030 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12031 * THE SOFTWARE. 12032 */ 12033 var strings$i = { 12034 ICON_EVENT: 'MDCTextField:icon', 12035 ICON_ROLE: 'button', 12036 }; 12037 var cssClasses$e = { 12038 ROOT: 'mdc-text-field__icon', 12039 }; 12040 12041 /** 12042 * @license 12043 * Copyright 2017 Google Inc. 12044 * 12045 * Permission is hereby granted, free of charge, to any person obtaining a copy 12046 * of this software and associated documentation files (the "Software"), to deal 12047 * in the Software without restriction, including without limitation the rights 12048 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12049 * copies of the Software, and to permit persons to whom the Software is 12050 * furnished to do so, subject to the following conditions: 12051 * 12052 * The above copyright notice and this permission notice shall be included in 12053 * all copies or substantial portions of the Software. 12054 * 12055 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12056 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12057 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12058 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12059 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12060 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12061 * THE SOFTWARE. 12062 */ 12063 var INTERACTION_EVENTS$1 = ['click', 'keydown']; 12064 var MDCTextFieldIconFoundation = /** @class */ (function (_super) { 12065 __extends(MDCTextFieldIconFoundation, _super); 12066 function MDCTextFieldIconFoundation(adapter) { 12067 var _this = _super.call(this, __assign(__assign({}, MDCTextFieldIconFoundation.defaultAdapter), adapter)) || this; 12068 _this.savedTabIndex_ = null; 12069 _this.interactionHandler_ = function (evt) { return _this.handleInteraction(evt); }; 12070 return _this; 12071 } 12072 Object.defineProperty(MDCTextFieldIconFoundation, "strings", { 12073 get: function () { 12074 return strings$i; 12075 }, 12076 enumerable: true, 12077 configurable: true 12078 }); 12079 Object.defineProperty(MDCTextFieldIconFoundation, "cssClasses", { 12080 get: function () { 12081 return cssClasses$e; 12082 }, 12083 enumerable: true, 12084 configurable: true 12085 }); 12086 Object.defineProperty(MDCTextFieldIconFoundation, "defaultAdapter", { 12087 /** 12088 * See {@link MDCTextFieldIconAdapter} for typing information on parameters and return types. 12089 */ 12090 get: function () { 12091 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 12092 return { 12093 getAttr: function () { return null; }, 12094 setAttr: function () { return undefined; }, 12095 removeAttr: function () { return undefined; }, 12096 setContent: function () { return undefined; }, 12097 registerInteractionHandler: function () { return undefined; }, 12098 deregisterInteractionHandler: function () { return undefined; }, 12099 notifyIconAction: function () { return undefined; }, 12100 }; 12101 // tslint:enable:object-literal-sort-keys 12102 }, 12103 enumerable: true, 12104 configurable: true 12105 }); 12106 MDCTextFieldIconFoundation.prototype.init = function () { 12107 var _this = this; 12108 this.savedTabIndex_ = this.adapter.getAttr('tabindex'); 12109 INTERACTION_EVENTS$1.forEach(function (evtType) { 12110 _this.adapter.registerInteractionHandler(evtType, _this.interactionHandler_); 12111 }); 12112 }; 12113 MDCTextFieldIconFoundation.prototype.destroy = function () { 12114 var _this = this; 12115 INTERACTION_EVENTS$1.forEach(function (evtType) { 12116 _this.adapter.deregisterInteractionHandler(evtType, _this.interactionHandler_); 12117 }); 12118 }; 12119 MDCTextFieldIconFoundation.prototype.setDisabled = function (disabled) { 12120 if (!this.savedTabIndex_) { 12121 return; 12122 } 12123 if (disabled) { 12124 this.adapter.setAttr('tabindex', '-1'); 12125 this.adapter.removeAttr('role'); 12126 } 12127 else { 12128 this.adapter.setAttr('tabindex', this.savedTabIndex_); 12129 this.adapter.setAttr('role', strings$i.ICON_ROLE); 12130 } 12131 }; 12132 MDCTextFieldIconFoundation.prototype.setAriaLabel = function (label) { 12133 this.adapter.setAttr('aria-label', label); 12134 }; 12135 MDCTextFieldIconFoundation.prototype.setContent = function (content) { 12136 this.adapter.setContent(content); 12137 }; 12138 MDCTextFieldIconFoundation.prototype.handleInteraction = function (evt) { 12139 var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13; 12140 if (evt.type === 'click' || isEnterKey) { 12141 evt.preventDefault(); // stop click from causing host label to focus 12142 // input 12143 this.adapter.notifyIconAction(); 12144 } 12145 }; 12146 return MDCTextFieldIconFoundation; 12147 }(MDCFoundation)); 12148 12149 /** 12150 * @license 12151 * Copyright 2017 Google Inc. 12152 * 12153 * Permission is hereby granted, free of charge, to any person obtaining a copy 12154 * of this software and associated documentation files (the "Software"), to deal 12155 * in the Software without restriction, including without limitation the rights 12156 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12157 * copies of the Software, and to permit persons to whom the Software is 12158 * furnished to do so, subject to the following conditions: 12159 * 12160 * The above copyright notice and this permission notice shall be included in 12161 * all copies or substantial portions of the Software. 12162 * 12163 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12164 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12165 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12166 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12167 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12168 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12169 * THE SOFTWARE. 12170 */ 12171 var MDCTextFieldIcon = /** @class */ (function (_super) { 12172 __extends(MDCTextFieldIcon, _super); 12173 function MDCTextFieldIcon() { 12174 return _super !== null && _super.apply(this, arguments) || this; 12175 } 12176 MDCTextFieldIcon.attachTo = function (root) { 12177 return new MDCTextFieldIcon(root); 12178 }; 12179 Object.defineProperty(MDCTextFieldIcon.prototype, "foundationForTextField", { 12180 // Provided for access by MDCTextField component 12181 get: function () { 12182 return this.foundation; 12183 }, 12184 enumerable: true, 12185 configurable: true 12186 }); 12187 MDCTextFieldIcon.prototype.getDefaultFoundation = function () { 12188 var _this = this; 12189 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 12190 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 12191 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 12192 var adapter = { 12193 getAttr: function (attr) { return _this.root.getAttribute(attr); }, 12194 setAttr: function (attr, value) { return _this.root.setAttribute(attr, value); }, 12195 removeAttr: function (attr) { return _this.root.removeAttribute(attr); }, 12196 setContent: function (content) { 12197 _this.root.textContent = content; 12198 }, 12199 registerInteractionHandler: function (evtType, handler) { return _this.listen(evtType, handler); }, 12200 deregisterInteractionHandler: function (evtType, handler) { return _this.unlisten(evtType, handler); },
vendor: 12,040 bytes, lines 12201-12501
12201 notifyIconAction: function () { return _this.emit(MDCTextFieldIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */); }, 12202 }; 12203 // tslint:enable:object-literal-sort-keys 12204 return new MDCTextFieldIconFoundation(adapter); 12205 }; 12206 return MDCTextFieldIcon; 12207 }(MDCComponent)); 12208 12209 /** 12210 * @license 12211 * Copyright 2016 Google Inc. 12212 * 12213 * Permission is hereby granted, free of charge, to any person obtaining a copy 12214 * of this software and associated documentation files (the "Software"), to deal 12215 * in the Software without restriction, including without limitation the rights 12216 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12217 * copies of the Software, and to permit persons to whom the Software is 12218 * furnished to do so, subject to the following conditions: 12219 * 12220 * The above copyright notice and this permission notice shall be included in 12221 * all copies or substantial portions of the Software. 12222 * 12223 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12224 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12225 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12226 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12227 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12228 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12229 * THE SOFTWARE. 12230 */ 12231 var MDCTextField = /** @class */ (function (_super) { 12232 __extends(MDCTextField, _super); 12233 function MDCTextField() { 12234 return _super !== null && _super.apply(this, arguments) || this; 12235 } 12236 MDCTextField.attachTo = function (root) { 12237 return new MDCTextField(root); 12238 }; 12239 MDCTextField.prototype.initialize = function (rippleFactory, lineRippleFactory, helperTextFactory, characterCounterFactory, iconFactory, labelFactory, outlineFactory) { 12240 if (rippleFactory === void 0) { rippleFactory = function (el, foundation) { return new MDCRipple(el, foundation); }; } 12241 if (lineRippleFactory === void 0) { lineRippleFactory = function (el) { return new MDCLineRipple(el); }; } 12242 if (helperTextFactory === void 0) { helperTextFactory = function (el) { return new MDCTextFieldHelperText(el); }; } 12243 if (characterCounterFactory === void 0) { characterCounterFactory = function (el) { return new MDCTextFieldCharacterCounter(el); }; } 12244 if (iconFactory === void 0) { iconFactory = function (el) { return new MDCTextFieldIcon(el); }; } 12245 if (labelFactory === void 0) { labelFactory = function (el) { return new MDCFloatingLabel(el); }; } 12246 if (outlineFactory === void 0) { outlineFactory = function (el) { return new MDCNotchedOutline(el); }; } 12247 this.input_ = this.root.querySelector(strings$k.INPUT_SELECTOR); 12248 var labelElement = this.root.querySelector(strings$k.LABEL_SELECTOR); 12249 this.label_ = labelElement ? labelFactory(labelElement) : null; 12250 var lineRippleElement = this.root.querySelector(strings$k.LINE_RIPPLE_SELECTOR); 12251 this.lineRipple_ = lineRippleElement ? lineRippleFactory(lineRippleElement) : null; 12252 var outlineElement = this.root.querySelector(strings$k.OUTLINE_SELECTOR); 12253 this.outline_ = outlineElement ? outlineFactory(outlineElement) : null; 12254 // Helper text 12255 var helperTextStrings = MDCTextFieldHelperTextFoundation.strings; 12256 var nextElementSibling = this.root.nextElementSibling; 12257 var hasHelperLine = (nextElementSibling && nextElementSibling.classList.contains(cssClasses$g.HELPER_LINE)); 12258 var helperTextEl = hasHelperLine && nextElementSibling && nextElementSibling.querySelector(helperTextStrings.ROOT_SELECTOR); 12259 this.helperText_ = helperTextEl ? helperTextFactory(helperTextEl) : null; 12260 // Character counter 12261 var characterCounterStrings = MDCTextFieldCharacterCounterFoundation.strings; 12262 var characterCounterEl = this.root.querySelector(characterCounterStrings.ROOT_SELECTOR); 12263 // If character counter is not found in root element search in sibling element. 12264 if (!characterCounterEl && hasHelperLine && nextElementSibling) { 12265 characterCounterEl = nextElementSibling.querySelector(characterCounterStrings.ROOT_SELECTOR); 12266 } 12267 this.characterCounter_ = characterCounterEl ? characterCounterFactory(characterCounterEl) : null; 12268 // Leading icon 12269 var leadingIconEl = this.root.querySelector(strings$k.LEADING_ICON_SELECTOR); 12270 this.leadingIcon_ = leadingIconEl ? iconFactory(leadingIconEl) : null; 12271 // Trailing icon 12272 var trailingIconEl = this.root.querySelector(strings$k.TRAILING_ICON_SELECTOR); 12273 this.trailingIcon_ = trailingIconEl ? iconFactory(trailingIconEl) : null; 12274 // Prefix and Suffix 12275 this.prefix_ = this.root.querySelector(strings$k.PREFIX_SELECTOR); 12276 this.suffix_ = this.root.querySelector(strings$k.SUFFIX_SELECTOR); 12277 this.ripple = this.createRipple_(rippleFactory); 12278 }; 12279 MDCTextField.prototype.destroy = function () { 12280 if (this.ripple) { 12281 this.ripple.destroy(); 12282 } 12283 if (this.lineRipple_) { 12284 this.lineRipple_.destroy(); 12285 } 12286 if (this.helperText_) { 12287 this.helperText_.destroy(); 12288 } 12289 if (this.characterCounter_) { 12290 this.characterCounter_.destroy(); 12291 } 12292 if (this.leadingIcon_) { 12293 this.leadingIcon_.destroy(); 12294 } 12295 if (this.trailingIcon_) { 12296 this.trailingIcon_.destroy(); 12297 } 12298 if (this.label_) { 12299 this.label_.destroy(); 12300 } 12301 if (this.outline_) { 12302 this.outline_.destroy(); 12303 } 12304 _super.prototype.destroy.call(this); 12305 }; 12306 /** 12307 * Initializes the Text Field's internal state based on the environment's 12308 * state. 12309 */ 12310 MDCTextField.prototype.initialSyncWithDOM = function () { 12311 this.disabled = this.input_.disabled; 12312 }; 12313 Object.defineProperty(MDCTextField.prototype, "value", { 12314 get: function () { 12315 return this.foundation.getValue(); 12316 }, 12317 /** 12318 * @param value The value to set on the input. 12319 */ 12320 set: function (value) { 12321 this.foundation.setValue(value); 12322 }, 12323 enumerable: true, 12324 configurable: true 12325 }); 12326 Object.defineProperty(MDCTextField.prototype, "disabled", { 12327 get: function () { 12328 return this.foundation.isDisabled(); 12329 }, 12330 /** 12331 * @param disabled Sets the Text Field disabled or enabled. 12332 */ 12333 set: function (disabled) { 12334 this.foundation.setDisabled(disabled); 12335 }, 12336 enumerable: true, 12337 configurable: true 12338 }); 12339 Object.defineProperty(MDCTextField.prototype, "valid", { 12340 get: function () { 12341 return this.foundation.isValid(); 12342 }, 12343 /** 12344 * @param valid Sets the Text Field valid or invalid. 12345 */ 12346 set: function (valid) { 12347 this.foundation.setValid(valid); 12348 }, 12349 enumerable: true, 12350 configurable: true 12351 }); 12352 Object.defineProperty(MDCTextField.prototype, "required", { 12353 get: function () { 12354 return this.input_.required; 12355 }, 12356 /** 12357 * @param required Sets the Text Field to required. 12358 */ 12359 set: function (required) { 12360 this.input_.required = required; 12361 }, 12362 enumerable: true, 12363 configurable: true 12364 }); 12365 Object.defineProperty(MDCTextField.prototype, "pattern", { 12366 get: function () { 12367 return this.input_.pattern; 12368 }, 12369 /** 12370 * @param pattern Sets the input element's validation pattern. 12371 */ 12372 set: function (pattern) { 12373 this.input_.pattern = pattern; 12374 }, 12375 enumerable: true, 12376 configurable: true 12377 }); 12378 Object.defineProperty(MDCTextField.prototype, "minLength", { 12379 get: function () { 12380 return this.input_.minLength; 12381 }, 12382 /** 12383 * @param minLength Sets the input element's minLength. 12384 */ 12385 set: function (minLength) { 12386 this.input_.minLength = minLength; 12387 }, 12388 enumerable: true, 12389 configurable: true 12390 }); 12391 Object.defineProperty(MDCTextField.prototype, "maxLength", { 12392 get: function () { 12393 return this.input_.maxLength; 12394 }, 12395 /** 12396 * @param maxLength Sets the input element's maxLength. 12397 */ 12398 set: function (maxLength) { 12399 // Chrome throws exception if maxLength is set to a value less than zero 12400 if (maxLength < 0) { 12401 this.input_.removeAttribute('maxLength'); 12402 } 12403 else { 12404 this.input_.maxLength = maxLength; 12405 } 12406 }, 12407 enumerable: true, 12408 configurable: true 12409 }); 12410 Object.defineProperty(MDCTextField.prototype, "min", { 12411 get: function () { 12412 return this.input_.min; 12413 }, 12414 /** 12415 * @param min Sets the input element's min. 12416 */ 12417 set: function (min) { 12418 this.input_.min = min; 12419 }, 12420 enumerable: true, 12421 configurable: true 12422 }); 12423 Object.defineProperty(MDCTextField.prototype, "max", { 12424 get: function () { 12425 return this.input_.max; 12426 }, 12427 /** 12428 * @param max Sets the input element's max. 12429 */ 12430 set: function (max) { 12431 this.input_.max = max; 12432 }, 12433 enumerable: true, 12434 configurable: true 12435 }); 12436 Object.defineProperty(MDCTextField.prototype, "step", { 12437 get: function () { 12438 return this.input_.step; 12439 }, 12440 /** 12441 * @param step Sets the input element's step. 12442 */ 12443 set: function (step) { 12444 this.input_.step = step; 12445 }, 12446 enumerable: true, 12447 configurable: true 12448 }); 12449 Object.defineProperty(MDCTextField.prototype, "helperTextContent", { 12450 /** 12451 * Sets the helper text element content. 12452 */ 12453 set: function (content) { 12454 this.foundation.setHelperTextContent(content); 12455 }, 12456 enumerable: true, 12457 configurable: true 12458 }); 12459 Object.defineProperty(MDCTextField.prototype, "leadingIconAriaLabel", { 12460 /** 12461 * Sets the aria label of the leading icon. 12462 */ 12463 set: function (label) { 12464 this.foundation.setLeadingIconAriaLabel(label); 12465 }, 12466 enumerable: true, 12467 configurable: true 12468 }); 12469 Object.defineProperty(MDCTextField.prototype, "leadingIconContent", { 12470 /** 12471 * Sets the text content of the leading icon. 12472 */ 12473 set: function (content) { 12474 this.foundation.setLeadingIconContent(content); 12475 }, 12476 enumerable: true, 12477 configurable: true 12478 }); 12479 Object.defineProperty(MDCTextField.prototype, "trailingIconAriaLabel", { 12480 /** 12481 * Sets the aria label of the trailing icon. 12482 */ 12483 set: function (label) { 12484 this.foundation.setTrailingIconAriaLabel(label); 12485 }, 12486 enumerable: true, 12487 configurable: true 12488 }); 12489 Object.defineProperty(MDCTextField.prototype, "trailingIconContent", { 12490 /** 12491 * Sets the text content of the trailing icon. 12492 */ 12493 set: function (content) { 12494 this.foundation.setTrailingIconContent(content); 12495 }, 12496 enumerable: true, 12497 configurable: true 12498 }); 12499 Object.defineProperty(MDCTextField.prototype, "useNativeValidation", { 12500 /** 12501 * Enables or disables the use of native validation. Use this for custom validation.
12502 * @param useNativeValidation Set this to false to ignore native input validation. 12503 */ 12504 set: function (useNativeValidation) { 12505 this.foundation.setUseNativeValidation(useNativeValidation); 12506 }, 12507 enumerable: true, 12508 configurable: true 12509 }); 12510 Object.defineProperty(MDCTextField.prototype, "prefixText", { 12511 /** 12512 * Gets the text content of the prefix, or null if it does not exist. 12513 */ 12514 get: function () { 12515 return this.prefix_ ? this.prefix_.textContent : null; 12516 }, 12517 /** 12518 * Sets the text content of the prefix, if it exists. 12519 */ 12520 set: function (prefixText) { 12521 if (this.prefix_) { 12522 this.prefix_.textContent = prefixText; 12523 } 12524 }, 12525 enumerable: true, 12526 configurable: true 12527 }); 12528 Object.defineProperty(MDCTextField.prototype, "suffixText", { 12529 /** 12530 * Gets the text content of the suffix, or null if it does not exist. 12531 */ 12532 get: function () { 12533 return this.suffix_ ? this.suffix_.textContent : null; 12534 }, 12535 /** 12536 * Sets the text content of the suffix, if it exists. 12537 */ 12538 set: function (suffixText) { 12539 if (this.suffix_) { 12540 this.suffix_.textContent = suffixText; 12541 } 12542 }, 12543 enumerable: true, 12544 configurable: true 12545 }); 12546 /** 12547 * Focuses the input element. 12548 */ 12549 MDCTextField.prototype.focus = function () { 12550 this.input_.focus(); 12551 }; 12552 /** 12553 * Recomputes the outline SVG path for the outline element. 12554 */ 12555 MDCTextField.prototype.layout = function () { 12556 var openNotch = this.foundation.shouldFloat; 12557 this.foundation.notchOutline(openNotch); 12558 }; 12559 MDCTextField.prototype.getDefaultFoundation = function () { 12560 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 12561 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 12562 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 12563 var adapter = __assign(__assign(__assign(__assign(__assign({}, this.getRootAdapterMethods_()), this.getInputAdapterMethods_()), this.getLabelAdapterMethods_()), this.getLineRippleAdapterMethods_()), this.getOutlineAdapterMethods_()); 12564 // tslint:enable:object-literal-sort-keys 12565 return new MDCTextFieldFoundation(adapter, this.getFoundationMap_()); 12566 }; 12567 MDCTextField.prototype.getRootAdapterMethods_ = function () { 12568 var _this = this; 12569 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 12570 return { 12571 addClass: function (className) { return _this.root.classList.add(className); }, 12572 removeClass: function (className) { return _this.root.classList.remove(className); }, 12573 hasClass: function (className) { return _this.root.classList.contains(className); }, 12574 registerTextFieldInteractionHandler: function (evtType, handler) { 12575 _this.listen(evtType, handler); 12576 }, 12577 deregisterTextFieldInteractionHandler: function (evtType, handler) { 12578 _this.unlisten(evtType, handler); 12579 }, 12580 registerValidationAttributeChangeHandler: function (handler) { 12581 var getAttributesList = function (mutationsList) { 12582 return mutationsList 12583 .map(function (mutation) { return mutation.attributeName; }) 12584 .filter(function (attributeName) { return attributeName; }); 12585 }; 12586 var observer = new MutationObserver(function (mutationsList) { return handler(getAttributesList(mutationsList)); }); 12587 var config = { attributes: true }; 12588 observer.observe(_this.input_, config); 12589 return observer; 12590 }, 12591 deregisterValidationAttributeChangeHandler: function (observer) { 12592 observer.disconnect(); 12593 }, 12594 }; 12595 // tslint:enable:object-literal-sort-keys 12596 }; 12597 MDCTextField.prototype.getInputAdapterMethods_ = function () { 12598 var _this = this; 12599 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 12600 return { 12601 getNativeInput: function () { return _this.input_; }, 12602 setInputAttr: function (attr, value) { 12603 _this.input_.setAttribute(attr, value); 12604 }, 12605 removeInputAttr: function (attr) { 12606 _this.input_.removeAttribute(attr); 12607 }, 12608 isFocused: function () { return document.activeElement === _this.input_; }, 12609 registerInputInteractionHandler: function (evtType, handler) { 12610 _this.input_.addEventListener(evtType, handler, applyPassive()); 12611 }, 12612 deregisterInputInteractionHandler: function (evtType, handler) { 12613 _this.input_.removeEventListener(evtType, handler, applyPassive()); 12614 }, 12615 }; 12616 // tslint:enable:object-literal-sort-keys 12617 }; 12618 MDCTextField.prototype.getLabelAdapterMethods_ = function () { 12619 var _this = this; 12620 return { 12621 floatLabel: function (shouldFloat) { return _this.label_ && _this.label_.float(shouldFloat); }, 12622 getLabelWidth: function () { return _this.label_ ? _this.label_.getWidth() : 0; }, 12623 hasLabel: function () { return Boolean(_this.label_); }, 12624 shakeLabel: function (shouldShake) { return _this.label_ && _this.label_.shake(shouldShake); }, 12625 setLabelRequired: function (isRequired) { return _this.label_ && _this.label_.setRequired(isRequired); }, 12626 }; 12627 }; 12628 MDCTextField.prototype.getLineRippleAdapterMethods_ = function () { 12629 var _this = this; 12630 return { 12631 activateLineRipple: function () { 12632 if (_this.lineRipple_) { 12633 _this.lineRipple_.activate(); 12634 } 12635 }, 12636 deactivateLineRipple: function () { 12637 if (_this.lineRipple_) { 12638 _this.lineRipple_.deactivate(); 12639 } 12640 }, 12641 setLineRippleTransformOrigin: function (normalizedX) { 12642 if (_this.lineRipple_) { 12643 _this.lineRipple_.setRippleCenter(normalizedX); 12644 } 12645 }, 12646 }; 12647 }; 12648 MDCTextField.prototype.getOutlineAdapterMethods_ = function () { 12649 var _this = this; 12650 return { 12651 closeOutline: function () { return _this.outline_ && _this.outline_.closeNotch(); }, 12652 hasOutline: function () { return Boolean(_this.outline_); }, 12653 notchOutline: function (labelWidth) { return _this.outline_ && _this.outline_.notch(labelWidth); }, 12654 }; 12655 }; 12656 /** 12657 * @return A map of all subcomponents to subfoundations. 12658 */ 12659 MDCTextField.prototype.getFoundationMap_ = function () { 12660 return { 12661 characterCounter: this.characterCounter_ ? 12662 this.characterCounter_.foundationForTextField : 12663 undefined, 12664 helperText: this.helperText_ ? this.helperText_.foundationForTextField : 12665 undefined, 12666 leadingIcon: this.leadingIcon_ ? 12667 this.leadingIcon_.foundationForTextField : 12668 undefined, 12669 trailingIcon: this.trailingIcon_ ? 12670 this.trailingIcon_.foundationForTextField : 12671 undefined, 12672 }; 12673 }; 12674 MDCTextField.prototype.createRipple_ = function (rippleFactory) { 12675 var _this = this; 12676 var isTextArea = this.root.classList.contains(cssClasse
12676s$g.TEXTAREA); 12677 var isOutlined = this.root.classList.contains(cssClasses$g.OUTLINED); 12678 if (isTextArea || isOutlined) { 12679 return null; 12680 } 12681 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 12682 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 12683 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 12684 var adapter = __assign(__assign({}, MDCRipple.createAdapter(this)), { isSurfaceActive: function () { return matches$1(_this.input_, ':active'); }, registerInteractionHandler: function (evtType, handler) { return _this.input_.addEventListener(evtType, handler, applyPassive()); }, deregisterInteractionHandler: function (evtType, handler) { 12685 return _this.input_.removeEventListener(evtType, handler, applyPassive()); 12686 } }); 12687 // tslint:enable:object-literal-sort-keys 12688 return rippleFactory(this.root, new MDCRippleFoundation(adapter)); 12689 }; 12690 return MDCTextField; 12691 }(MDCComponent)); 12692 12693 /** 12694 * @license 12695 * Copyright 2019 Google Inc. 12696 * 12697 * Permission is hereby granted, free of charge, to any person obtaining a copy 12698 * of this software and associated documentation files (the "Software"), to deal 12699 * in the Software without restriction, including without limitation the rights 12700 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12701 * copies of the Software, and to permit persons to whom the Software is 12702 * furnished to do so, subject to the following conditions: 12703 * 12704 * The above copyright notice and this permission notice shall be included in 12705 * all copies or substantial portions of the Software. 12706 * 12707 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12708 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12709 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12710 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12711 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12712 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12713 * THE SOFTWARE. 12714 */ 12715 12716 /** 12717 * @license 12718 * Copyright 2019 Google Inc. 12719 * 12720 * Permission is hereby granted, free of charge, to any person obtaining a copy 12721 * of this software and associated documentation files (the "Software"), to deal 12722 * in the Software without restriction, including without limitation the rights 12723 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12724 * copies of the Software, and to permit persons to whom the Software is 12725 * furnished to do so, subject to the following conditions: 12726 * 12727 * The above copyright notice and this permission notice shall be included in 12728 * all copies or substantial portions of the Software. 12729 * 12730 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12731 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12732 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12733 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12734 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12735 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12736 * THE SOFTWARE. 12737 */ 12738 12739 /** 12740 * @license 12741 * Copyright 2019 Google Inc. 12742 * 12743 * Permission is hereby granted, free of charge, to any person obtaining a copy 12744 * of this software and associated documentation files (the "Software"), to deal 12745 * in the Software without restriction, including without limitation the rights 12746 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12747 * copies of the Software, and to permit persons to whom the Software is 12748 * furnished to do so, subject to the following conditions: 12749 * 12750 * The above copyright notice and this permission notice shall be included in 12751 * all copies or substantial portions of the Software. 12752 * 12753 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12754 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12755 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12756 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12757 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12758 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12759 * THE SOFTWARE. 12760 */ 12761 12762 /** 12763 * @license 12764 * Copyright 2019 Google Inc. 12765 * 12766 * Permission is hereby granted, free of charge, to any person obtaining a copy 12767 * of this software and associated documentation files (the "Software"), to deal 12768 * in the Software without restriction, including without limitation the rights 12769 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12770 * copies of the Software, and to permit persons to whom the Software is 12771 * furnished to do so, subject to the following conditions: 12772 * 12773 * The above copyright notice and this permission notice shall be included in 12774 * all copies or substantial portions of the Software. 12775 * 12776 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12777 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12778 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12779 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12780 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12781 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12782 * THE SOFTWARE. 12783 */ 12784 12785 /** 12786 * @license 12787 * Copyright 2018 Google Inc. 12788 * 12789 * Permission is hereby granted, free of charge, to any person obtaining a copy 12790 * of this software and associated documentation files (the "Software"), to deal 12791 * in the Software without restriction, including without limitation the rights 12792 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12793 * copies of the Software, and to permit persons to whom the Software is 12794 * furnished to do so, subject to the following conditions: 12795 * 12796 * The above copyright notice and this permission notice shall be included in 12797 * all copies or substantial portions of the Software. 12798 * 12799 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12800 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12801 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12802 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12803 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12804 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12805 * THE SOFTWARE. 12806 */
12807 var cssClasses$d = { 12808 ANCHOR: 'mdc-menu-surface--anchor', 12809 ANIMATING_CLOSED: 'mdc-menu-surface--animating-closed', 12810 ANIMATING_OPEN: 'mdc-menu-surface--animating-open', 12811 FIXED: 'mdc-menu-surface--fixed', 12812 IS_OPEN_BELOW: 'mdc-menu-surface--is-open-below', 12813 OPEN: 'mdc-menu-surface--open', 12814 ROOT: 'mdc-menu-surface', 12815 }; 12816 // tslint:disable:object-literal-sort-keys 12817 var strings$h = { 12818 CLOSED_EVENT: 'MDCMenuSurface:closed', 12819 CLOSING_EVENT: 'MDCMenuSurface:closing', 12820 OPENED_EVENT: 'MDCMenuSurface:opened', 12821 FOCUSABLE_ELEMENTS: [ 12822 'button:not(:disabled)', 12823 '[href]:not([aria-disabled="true"])', 12824 'input:not(:disabled)', 12825 'select:not(:disabled)', 12826 'textarea:not(:disabled)', 12827 '[tabindex]:not([tabindex="-1"]):not([aria-disabled="true"])', 12828 ].join(', '), 12829 }; 12830 // tslint:enable:object-literal-sort-keys 12831 var numbers$5 = { 12832 /** Total duration of menu-surface open animation. */ 12833 TRANSITION_OPEN_DURATION: 120, 12834 /** Total duration of menu-surface close animation. */ 12835 TRANSITION_CLOSE_DURATION: 75, 12836 /** Margin left to the edge of the viewport when menu-surface is at maximum possible height. Also used as a viewport margin. */ 12837 MARGIN_TO_EDGE: 32, 12838 /** Ratio of anchor width to menu-surface width for switching from corner positioning to center positioning. */ 12839 ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO: 0.67, 12840 }; 12841 /** 12842 * Enum for bits in the {@see Corner) bitmap. 12843 */ 12844 var CornerBit; 12845 (function (CornerBit) { 12846 CornerBit[CornerBit["BOTTOM"] = 1] = "BOTTOM"; 12847 CornerBit[CornerBit["CENTER"] = 2] = "CENTER"; 12848 CornerBit[CornerBit["RIGHT"] = 4] = "RIGHT"; 12849 CornerBit[CornerBit["FLIP_RTL"] = 8] = "FLIP_RTL"; 12850 })(CornerBit || (CornerBit = {})); 12851 /** 12852 * Enum for representing an element corner for positioning the menu-surface. 12853 * 12854 * The START constants map to LEFT if element directionality is left 12855 * to right and RIGHT if the directionality is right to left. 12856 * Likewise END maps to RIGHT or LEFT depending on the directionality. 12857 */ 12858 var Corner; 12859 (function (Corner) { 12860 Corner[Corner["TOP_LEFT"] = 0] = "TOP_LEFT"; 12861 Corner[Corner["TOP_RIGHT"] = 4] = "TOP_RIGHT"; 12862 Corner[Corner["BOTTOM_LEFT"] = 1] = "BOTTOM_LEFT"; 12863 Corner[Corner["BOTTOM_RIGHT"] = 5] = "BOTTOM_RIGHT"; 12864 Corner[Corner["TOP_START"] = 8] = "TOP_START"; 12865 Corner[Corner["TOP_END"] = 12] = "TOP_END"; 12866 Corner[Corner["BOTTOM_START"] = 9] = "BOTTOM_START"; 12867 Corner[Corner["BOTTOM_END"] = 13] = "BOTTOM_END"; 12868 })(Corner || (Corner = {})); 12869 12870 /** 12871 * @license 12872 * Copyright 2018 Google Inc. 12873 * 12874 * Permission is hereby granted, free of charge, to any person obtaining a copy 12875 * of this software and associated documentation files (the "Software"), to deal 12876 * in the Software without restriction, including without limitation the rights 12877 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12878 * copies of the Software, and to permit persons to whom the Software is 12879 * furnished to do so, subject to the following conditions: 12880 * 12881 * The above copyright notice and this permission notice shall be included in 12882 * all copies or substantial portions of the Software. 12883 * 12884 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12885 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12886 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 12887 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 12888 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 12889 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 12890 * THE SOFTWARE. 12891 */ 12892 var MDCMenuSurfaceFoundation = /** @class */ (function (_super) { 12893 __extends(MDCMenuSurfaceFoundation, _super); 12894 function MDCMenuSurfaceFoundation(adapter) { 12895 var _this = _super.call(this, __assign(__assign({}, MDCMenuSurfaceFoundation.defaultAdapter), adapter)) || this; 12896 _this.isSurfaceOpen = false; 12897 _this.isQuickOpen = false; 12898 _this.isHoistedElement = false;
vendor: 3,684 bytes, lines 12899-12983
12899 _this.isFixedPosition = false; 12900 _this.openAnimationEndTimerId = 0; 12901 _this.closeAnimationEndTimerId = 0; 12902 _this.animationRequestId = 0; 12903 _this.anchorCorner = Corner.TOP_START; 12904 /** 12905 * Corner of the menu surface to which menu surface is attached to anchor. 12906 * 12907 * Anchor corner --->+----------+ 12908 * | ANCHOR | 12909 * +----------+ 12910 * Origin corner --->+--------------+ 12911 * | | 12912 * | | 12913 * | MENU SURFACE | 12914 * | | 12915 * | | 12916 * +--------------+ 12917 */ 12918 _this.originCorner = Corner.TOP_START; 12919 _this.anchorMargin = { top: 0, right: 0, bottom: 0, left: 0 }; 12920 _this.position = { x: 0, y: 0 }; 12921 return _this; 12922 } 12923 Object.defineProperty(MDCMenuSurfaceFoundation, "cssClasses", { 12924 get: function () { 12925 return cssClasses$d; 12926 }, 12927 enumerable: true, 12928 configurable: true 12929 }); 12930 Object.defineProperty(MDCMenuSurfaceFoundation, "strings", { 12931 get: function () { 12932 return strings$h; 12933 }, 12934 enumerable: true, 12935 configurable: true 12936 }); 12937 Object.defineProperty(MDCMenuSurfaceFoundation, "numbers", { 12938 get: function () { 12939 return numbers$5; 12940 }, 12941 enumerable: true, 12942 configurable: true 12943 }); 12944 Object.defineProperty(MDCMenuSurfaceFoundation, "Corner", { 12945 get: function () { 12946 return Corner; 12947 }, 12948 enumerable: true, 12949 configurable: true 12950 }); 12951 Object.defineProperty(MDCMenuSurfaceFoundation, "defaultAdapter", { 12952 /** 12953 * @see {@link MDCMenuSurfaceAdapter} for typing information on parameters and return types. 12954 */ 12955 get: function () { 12956 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 12957 return { 12958 addClass: function () { return undefined; }, 12959 removeClass: function () { return undefined; }, 12960 hasClass: function () { return false; }, 12961 hasAnchor: function () { return false; }, 12962 isElementInContainer: function () { return false; }, 12963 isFocused: function () { return false; }, 12964 isRtl: function () { return false; }, 12965 getInnerDimensions: function () { return ({ height: 0, width: 0 }); }, 12966 getAnchorDimensions: function () { return null; }, 12967 getWindowDimensions: function () { return ({ height: 0, width: 0 }); }, 12968 getBodyDimensions: function () { return ({ height: 0, width: 0 }); }, 12969 getWindowScroll: function () { return ({ x: 0, y: 0 }); }, 12970 setPosition: function () { return undefined; }, 12971 setMaxHeight: function () { return undefined; }, 12972 setTransformOrigin: function () { return undefined; }, 12973 saveFocus: function () { return undefined; }, 12974 restoreFocus: function () { return undefined; }, 12975 notifyClose: function () { return undefined; }, 12976 notifyOpen: function () { return undefined; }, 12977 notifyClosing: function () { return undefined; }, 12978 }; 12979 // tslint:enable:object-literal-sort-keys 12980 }, 12981 enumerable: true, 12982 configurable: true 12983 });
12984 MDCMenuSurfaceFoundation.prototype.init = function () { 12985 var _a = MDCMenuSurfaceFoundation.cssClasses, ROOT = _a.ROOT, OPEN = _a.OPEN; 12986 if (!this.adapter.hasClass(ROOT)) { 12987 throw new Error(ROOT + " class required in root element."); 12988 } 12989 if (this.adapter.hasClass(OPEN)) { 12990 this.isSurfaceOpen = true; 12991 } 12992 }; 12993 MDCMenuSurfaceFoundation.prototype.destroy = function () { 12994 clearTimeout(this.openAnimationEndTimerId); 12995 clearTimeout(this.closeAnimationEndTimerId); 12996 // Cancel any currently running animations. 12997 cancelAnimationFrame(this.animationRequestId); 12998 }; 12999 /** 13000 * @param corner Default anchor corner alignment of top-left menu surface corner. 13001 */ 13002 MDCMenuSurfaceFoundation.prototype.setAnchorCorner = function (corner) { 13003 this.anchorCorner = corner; 13004 }; 13005 /** 13006 * Flip menu corner horizontally. 13007 */ 13008 MDCMenuSurfaceFoundation.prototype.flipCornerHorizontally = function () { 13009 this.originCorner = this.originCorner ^ CornerBit.RIGHT; 13010 }; 13011 /** 13012 * @param margin Set of margin values from anchor. 13013 */
13014 MDCMenuSurfaceFoundation.prototype.setAnchorMargin = function (margin) { 13015 this.anchorMargin.top = margin.top || 0; 13016 this.anchorMargin.right = margin.right || 0; 13017 this.anchorMargin.bottom = margin.bottom || 0; 13018 this.anchorMargin.left = margin.left || 0; 13019 }; 13020 /** Used to indicate if the menu-surface is hoisted to the body. */ 13021 MDCMenuSurfaceFoundation.prototype.setIsHoisted = function (isHoisted) { 13022 this.isHoistedElement = isHoisted; 13023 }; 13024 /** Used to set the menu-surface calculations based on a fixed position menu. */ 13025 MDCMenuSurfaceFoundation.prototype.setFixedPosition = function (isFixedPosition) { 13026 this.isFixedPosition = isFixedPosition; 13027 }; 13028 /** Sets the menu-surface position on the page. */ 13029 MDCMenuSurfaceFoundation.prototype.setAbsolutePosition = function (x, y) { 13030 this.position.x = this.isFinite(x) ? x : 0; 13031 this.position.y = this.isFinite(y) ? y : 0; 13032 }; 13033 MDCMenuSurfaceFoundation.prototype.setQuickOpen = function (quickOpen) { 13034 this.isQuickOpen = quickOpen; 13035 };
13036 MDCMenuSurfaceFoundation.prototype.isOpen = function () { 13037 return this.isSurfaceOpen; 13038 }; 13039 /** 13040 * Open the menu surface. 13041 */ 13042 MDCMenuSurfaceFoundation.prototype.open = function () { 13043 var _this = this; 13044 if (this.isSurfaceOpen) { 13045 return; 13046 } 13047 this.adapter.saveFocus(); 13048 if (this.isQuickOpen) { 13049 this.isSurfaceOpen = true; 13050 this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN); 13051 this.dimensions = this.adapter.getInnerDimensions(); 13052 this.autoposition(); 13053 this.adapter.notifyOpen(); 13054 } 13055 else { 13056 this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN); 13057 this.animationRequestId = requestAnimationFrame(function () { 13058 _this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.OPEN); 13059 _this.dimensions = _this.adapter.getInnerDimensions(); 13060 _this.autoposition(); 13061 _this.openAnimationEndTimerId = setTimeout(function () { 13062 _this.openAnimationEndTimerId = 0; 13063 _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_OPEN); 13064 _this.adapter.notifyOpen(); 13065 }, numbers$5.TRANSITION_OPEN_DURATION); 13066 }); 13067 this.isSurfaceOpen = true; 13068 } 13069 }; 13070 /** 13071 * Closes the menu surface. 13072 */
vendor: 4,027 bytes, lines 13073-13154
13073 MDCMenuSurfaceFoundation.prototype.close = function (skipRestoreFocus) { 13074 var _this = this; 13075 if (skipRestoreFocus === void 0) { skipRestoreFocus = false; } 13076 if (!this.isSurfaceOpen) { 13077 return; 13078 } 13079 this.adapter.notifyClosing(); 13080 if (this.isQuickOpen) { 13081 this.isSurfaceOpen = false; 13082 if (!skipRestoreFocus) { 13083 this.maybeRestoreFocus(); 13084 } 13085 this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN); 13086 this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW); 13087 this.adapter.notifyClose(); 13088 return; 13089 } 13090 this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED); 13091 requestAnimationFrame(function () { 13092 _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.OPEN); 13093 _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW); 13094 _this.closeAnimationEndTimerId = setTimeout(function () { 13095 _this.closeAnimationEndTimerId = 0; 13096 _this.adapter.removeClass(MDCMenuSurfaceFoundation.cssClasses.ANIMATING_CLOSED); 13097 _this.adapter.notifyClose(); 13098 }, numbers$5.TRANSITION_CLOSE_DURATION); 13099 }); 13100 this.isSurfaceOpen = false; 13101 if (!skipRestoreFocus) { 13102 this.maybeRestoreFocus(); 13103 } 13104 }; 13105 /** Handle clicks and close if not within menu-surface element. */ 13106 MDCMenuSurfaceFoundation.prototype.handleBodyClick = function (evt) { 13107 var el = evt.target; 13108 if (this.adapter.isElementInContainer(el)) { 13109 return; 13110 } 13111 this.close(); 13112 }; 13113 /** Handle keys that close the surface. */ 13114 MDCMenuSurfaceFoundation.prototype.handleKeydown = function (evt) { 13115 var keyCode = evt.keyCode, key = evt.key; 13116 var isEscape = key === 'Escape' || keyCode === 27; 13117 if (isEscape) { 13118 this.close(); 13119 } 13120 }; 13121 MDCMenuSurfaceFoundation.prototype.autoposition = function () { 13122 var _a; 13123 // Compute measurements for autoposition methods reuse. 13124 this.measurements = this.getAutoLayoutmeasurements(); 13125 var corner = this.getoriginCorner(); 13126 var maxMenuSurfaceHeight = this.getMenuSurfaceMaxHeight(corner); 13127 var verticalAlignment = this.hasBit(corner, CornerBit.BOTTOM) ? 'bottom' : 'top'; 13128 var horizontalAlignment = this.hasBit(corner, CornerBit.RIGHT) ? 'right' : 'left'; 13129 var horizontalOffset = this.getHorizontalOriginOffset(corner); 13130 var verticalOffset = this.getVerticalOriginOffset(corner); 13131 var _b = this.measurements, anchorSize = _b.anchorSize, surfaceSize = _b.surfaceSize; 13132 var position = (_a = {}, 13133 _a[horizontalAlignment] = horizontalOffset, 13134 _a[verticalAlignment] = verticalOffset, 13135 _a); 13136 // Center align when anchor width is comparable or greater than menu surface, otherwise keep corner. 13137 if (anchorSize.width / surfaceSize.width > numbers$5.ANCHOR_TO_MENU_SURFACE_WIDTH_RATIO) { 13138 horizontalAlignment = 'center'; 13139 } 13140 // If the menu-surface has been hoisted to the body, it's no longer relative to the anchor element 13141 if (this.isHoistedElement || this.isFixedPosition) { 13142 this.adjustPositionForHoistedElement(position); 13143 } 13144 this.adapter.setTransformOrigin(horizontalAlignment + " " + verticalAlignment); 13145 this.adapter.setPosition(position); 13146 this.adapter.setMaxHeight(maxMenuSurfaceHeight ? maxMenuSurfaceHeight + 'px' : ''); 13147 // If it is opened from the top then add is-open-below class 13148 if (!this.hasBit(corner, CornerBit.BOTTOM)) { 13149 this.adapter.addClass(MDCMenuSurfaceFoundation.cssClasses.IS_OPEN_BELOW); 13150 } 13151 }; 13152 /** 13153 * @return Measurements used to position menu surface popup. 13154 */
13155 MDCMenuSurfaceFoundation.prototype.getAutoLayoutmeasurements = function () { 13156 var anchorRect = this.adapter.getAnchorDimensions(); 13157 var bodySize = this.adapter.getBodyDimensions(); 13158 var viewportSize = this.adapter.getWindowDimensions(); 13159 var windowScroll = this.adapter.getWindowScroll(); 13160 if (!anchorRect) { 13161 // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together 13162 anchorRect = { 13163 top: this.position.y, 13164 right: this.position.x, 13165 bottom: this.position.y, 13166 left: this.position.x, 13167 width: 0, 13168 height: 0, 13169 }; 13170 // tslint:enable:object-literal-sort-keys 13171 } 13172 return { 13173 anchorSize: anchorRect, 13174 bodySize: bodySize, 13175 surfaceSize: this.dimensions, 13176 viewportDistance: { 13177 // tslint:disable:object-literal-sort-keys Positional properties are more readable when they're grouped together 13178 top: anchorRect.top, 13179 right: viewportSize.width - anchorRect.right, 13180 bottom: viewportSize.height - anchorRect.bottom, 13181 left: anchorRect.left, 13182 }, 13183 viewportSize: viewportSize, 13184 windowScroll: windowScroll, 13185 }; 13186 }; 13187 /** 13188 * Computes the corner of the anchor from which to animate and position the 13189 * menu surface. 13190 * 13191 * Only LEFT or RIGHT bit is used to position the menu surface ignoring RTL 13192 * context. E.g., menu surface will be positioned from right side on TOP_END. 13193 */
vendor: 3,493 bytes, lines 13194-13264
13194 MDCMenuSurfaceFoundation.prototype.getoriginCorner = function () { 13195 var corner = this.originCorner; 13196 var _a = this.measurements, viewportDistance = _a.viewportDistance, anchorSize = _a.anchorSize, surfaceSize = _a.surfaceSize; 13197 var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE; 13198 var isAnchoredToBottom = this.hasBit(this.anchorCorner, CornerBit.BOTTOM); 13199 var availableTop; 13200 var availableBottom; 13201 if (isAnchoredToBottom) { 13202 availableTop = 13203 viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.bottom; 13204 availableBottom = 13205 viewportDistance.bottom - MARGIN_TO_EDGE - this.anchorMargin.bottom; 13206 } 13207 else { 13208 availableTop = 13209 viewportDistance.top - MARGIN_TO_EDGE + this.anchorMargin.top; 13210 availableBottom = viewportDistance.bottom - MARGIN_TO_EDGE + 13211 anchorSize.height - this.anchorMargin.top; 13212 } 13213 var isAvailableBottom = availableBottom - surfaceSize.height > 0; 13214 if (!isAvailableBottom && availableTop > availableBottom) { 13215 // Attach bottom side of surface to the anchor. 13216 corner = this.setBit(corner, CornerBit.BOTTOM); 13217 } 13218 var isRtl = this.adapter.isRtl(); 13219 var isFlipRtl = this.hasBit(this.anchorCorner, CornerBit.FLIP_RTL); 13220 var hasRightBit = this.hasBit(this.anchorCorner, CornerBit.RIGHT) || 13221 this.hasBit(corner, CornerBit.RIGHT); 13222 // Whether surface attached to right side of anchor element. 13223 var isAnchoredToRight = false; 13224 // Anchored to start 13225 if (isRtl && isFlipRtl) { 13226 isAnchoredToRight = !hasRightBit; 13227 } 13228 else { 13229 // Anchored to right 13230 isAnchoredToRight = hasRightBit; 13231 } 13232 var availableLeft; 13233 var availableRight; 13234 if (isAnchoredToRight) { 13235 availableLeft = 13236 viewportDistance.left + anchorSize.width + this.anchorMargin.right; 13237 availableRight = viewportDistance.right - this.anchorMargin.right; 13238 } 13239 else { 13240 availableLeft = viewportDistance.left + this.anchorMargin.left; 13241 availableRight = 13242 viewportDistance.right + anchorSize.width - this.anchorMargin.left; 13243 } 13244 var isAvailableLeft = availableLeft - surfaceSize.width > 0; 13245 var isAvailableRight = availableRight - surfaceSize.width > 0; 13246 var isOriginCornerAlignedToEnd = this.hasBit(corner, CornerBit.FLIP_RTL) && 13247 this.hasBit(corner, CornerBit.RIGHT); 13248 if (isAvailableRight && isOriginCornerAlignedToEnd && isRtl || 13249 !isAvailableLeft && isOriginCornerAlignedToEnd) { 13250 // Attach left side of surface to the anchor. 13251 corner = this.unsetBit(corner, CornerBit.RIGHT); 13252 } 13253 else if (isAvailableLeft && isAnchoredToRight && isRtl || 13254 (isAvailableLeft && !isAnchoredToRight && hasRightBit) || 13255 (!isAvailableRight && availableLeft >= availableRight)) { 13256 // Attach right side of surface to the anchor. 13257 corner = this.setBit(corner, CornerBit.RIGHT); 13258 } 13259 return corner; 13260 }; 13261 /** 13262 * @param corner Origin corner of the menu surface. 13263 * @return Maximum height of the menu surface, based on available space. 0 indicates should not be set. 13264 */
vendor: 2,705 bytes, lines 13265-13317
13265 MDCMenuSurfaceFoundation.prototype.getMenuSurfaceMaxHeight = function (corner) { 13266 var viewportDistance = this.measurements.viewportDistance; 13267 var maxHeight = 0; 13268 var isBottomAligned = this.hasBit(corner, CornerBit.BOTTOM); 13269 var isBottomAnchored = this.hasBit(this.anchorCorner, CornerBit.BOTTOM); 13270 var MARGIN_TO_EDGE = MDCMenuSurfaceFoundation.numbers.MARGIN_TO_EDGE; 13271 // When maximum height is not specified, it is handled from CSS. 13272 if (isBottomAligned) { 13273 maxHeight = viewportDistance.top + this.anchorMargin.top - MARGIN_TO_EDGE; 13274 if (!isBottomAnchored) { 13275 maxHeight += this.measurements.anchorSize.height; 13276 } 13277 } 13278 else { 13279 maxHeight = viewportDistance.bottom - this.anchorMargin.bottom + 13280 this.measurements.anchorSize.height - MARGIN_TO_EDGE; 13281 if (isBottomAnchored) { 13282 maxHeight -= this.measurements.anchorSize.height; 13283 } 13284 } 13285 return maxHeight; 13286 }; 13287 /** 13288 * @param corner Origin corner of the menu surface. 13289 * @return Horizontal offset of menu surface origin corner from corresponding anchor corner. 13290 */ 13291 MDCMenuSurfaceFoundation.prototype.getHorizontalOriginOffset = function (corner) { 13292 var anchorSize = this.measurements.anchorSize; 13293 // isRightAligned corresponds to using the 'right' property on the surface. 13294 var isRightAligned = this.hasBit(corner, CornerBit.RIGHT); 13295 var avoidHorizontalOverlap = this.hasBit(this.anchorCorner, CornerBit.RIGHT); 13296 if (isRightAligned) { 13297 var rightOffset = avoidHorizontalOverlap ? 13298 anchorSize.width - this.anchorMargin.left : 13299 this.anchorMargin.right; 13300 // For hoisted or fixed elements, adjust the offset by the difference 13301 // between viewport width and body width so when we calculate the right 13302 // value (`adjustPositionForHoistedElement`) based on the element 13303 // position, the right property is correct. 13304 if (this.isHoistedElement || this.isFixedPosition) { 13305 return rightOffset - 13306 (this.measurements.viewportSize.width - 13307 this.measurements.bodySize.width); 13308 } 13309 return rightOffset; 13310 } 13311 return avoidHorizontalOverlap ? anchorSize.width - this.anchorMargin.right : 13312 this.anchorMargin.left; 13313 }; 13314 /** 13315 * @param corner Origin corner of the menu surface. 13316 * @return Vertical offset of menu surface origin corner from corresponding anchor corner. 13317 */
vendor: 2,762 bytes, lines 13318-13376
13318 MDCMenuSurfaceFoundation.prototype.getVerticalOriginOffset = function (corner) { 13319 var anchorSize = this.measurements.anchorSize; 13320 var isBottomAligned = this.hasBit(corner, CornerBit.BOTTOM); 13321 var avoidVerticalOverlap = this.hasBit(this.anchorCorner, CornerBit.BOTTOM); 13322 var y = 0; 13323 if (isBottomAligned) { 13324 y = avoidVerticalOverlap ? anchorSize.height - this.anchorMargin.top : 13325 -this.anchorMargin.bottom; 13326 } 13327 else { 13328 y = avoidVerticalOverlap ? 13329 (anchorSize.height + this.anchorMargin.bottom) : 13330 this.anchorMargin.top; 13331 } 13332 return y; 13333 }; 13334 /** Calculates the offsets for positioning the menu-surface when the menu-surface has been hoisted to the body. */ 13335 MDCMenuSurfaceFoundation.prototype.adjustPositionForHoistedElement = function (position) { 13336 var e_1, _a; 13337 var _b = this.measurements, windowScroll = _b.windowScroll, viewportDistance = _b.viewportDistance; 13338 var props = Object.keys(position); 13339 try { 13340 for (var props_1 = __values(props), props_1_1 = props_1.next(); !props_1_1.done; props_1_1 = props_1.next()) { 13341 var prop = props_1_1.value; 13342 var value = position[prop] || 0; 13343 // Hoisted surfaces need to have the anchor elements location on the page added to the 13344 // position properties for proper alignment on the body. 13345 value += viewportDistance[prop]; 13346 // Surfaces that are absolutely positioned need to have additional calculations for scroll 13347 // and bottom positioning. 13348 if (!this.isFixedPosition) { 13349 if (prop === 'top') { 13350 value += windowScroll.y; 13351 } 13352 else if (prop === 'bottom') { 13353 value -= windowScroll.y; 13354 } 13355 else if (prop === 'left') { 13356 value += windowScroll.x; 13357 } 13358 else { // prop === 'right' 13359 value -= windowScroll.x; 13360 } 13361 } 13362 position[prop] = value; 13363 } 13364 } 13365 catch (e_1_1) { e_1 = { error: e_1_1 }; } 13366 finally { 13367 try { 13368 if (props_1_1 && !props_1_1.done && (_a = props_1.return)) _a.call(props_1); 13369 } 13370 finally { if (e_1) throw e_1.error; } 13371 } 13372 }; 13373 /** 13374 * The last focused element when the menu surface was opened should regain focus, if the user is 13375 * focused on or within the menu surface when it is closed. 13376 */
13377 MDCMenuSurfaceFoundation.prototype.maybeRestoreFocus = function () { 13378 var isRootFocused = this.adapter.isFocused(); 13379 var childHasFocus = document.activeElement && 13380 this.adapter.isElementInContainer(document.activeElement); 13381 if (isRootFocused || childHasFocus) { 13382 this.adapter.restoreFocus(); 13383 } 13384 }; 13385 MDCMenuSurfaceFoundation.prototype.hasBit = function (corner, bit) { 13386 return Boolean(corner & bit); // tslint:disable-line:no-bitwise 13387 }; 13388 MDCMenuSurfaceFoundation.prototype.setBit = function (corner, bit) { 13389 return corner | bit; // tslint:disable-line:no-bitwise 13390 }; 13391 MDCMenuSurfaceFoundation.prototype.unsetBit = function (corner, bit) { 13392 return corner ^ bit; 13393 }; 13394 /** 13395 * isFinite that doesn't force conversion to number type. 13396 * Equivalent to Number.isFinite in ES2015, which is not supported in IE. 13397 */ 13398 MDCMenuSurfaceFoundation.prototype.isFinite = function (num) { 13399 return typeof num === 'number' && isFinite(num); 13400 }; 13401 return MDCMenuSurfaceFoundation; 13402 }(MDCFoundation)); 13403 13404 /** 13405 * @license 13406 * Copyright 2016 Google Inc. 13407 * 13408 * Permission is hereby granted, free of charge, to any person obtaining a copy 13409 * of this software and associated documentation files (the "Software"), to deal 13410 * in the Software without restriction, including without limitation the rights 13411 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13412 * copies of the Software, and to permit persons to whom the Software is 13413 * furnished to do so, subject to the following conditions: 13414 * 13415 * The above copyright notice and this permission notice shall be included in 13416 * all copies or substantial portions of the Software. 13417 * 13418 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13419 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13420 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13421 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 13422 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 13423 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13424 * THE SOFTWARE. 13425 */ 13426 var cssPropertyNameMap = { 13427 animation: { 13428 prefixed: '-webkit-animation', 13429 standard: 'animation', 13430 }, 13431 transform: { 13432 prefixed: '-webkit-transform', 13433 standard: 'transform', 13434 }, 13435 transition: { 13436 prefixed: '-webkit-transition', 13437 standard: 'transition', 13438 }, 13439 }; 13440 var jsEventTypeMap = { 13441 animationend: { 13442 cssProperty: 'animation', 13443 prefixed: 'webkitAnimationEnd', 13444 standard: 'animationend', 13445 }, 13446 animationiteration: { 13447 cssProperty: 'animation', 13448 prefixed: 'webkitAnimationIteration', 13449 standard: 'animationiteration', 13450 }, 13451 animationstart: { 13452 cssProperty: 'animation', 13453 prefixed: 'webkitAnimationStart', 13454 standard: 'animationstart', 13455 }, 13456 transitionend: { 13457 cssProperty: 'transition', 13458 prefixed: 'webkitTransitionEnd', 13459 standard: 'transitionend', 13460 }, 13461 }; 13462 function isWindow(windowObj) { 13463 return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function'; 13464 } 13465 function getCorrectPropertyName(windowObj, cssProperty) { 13466 if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) { 13467 var el = windowObj.document.createElement('div'); 13468 var _a = cssPropertyNameMap[cssProperty], standard = _a.standard, prefixed = _a.prefixed; 13469 var isStandard = standard in el.style; 13470 return isStandard ? standard : prefixed; 13471 } 13472 return cssProperty; 13473 } 13474 function getCorrectEventName(windowObj, eventType) { 13475 if (isWindow(windowObj) && eventType in jsEventTypeMap) { 13476 var el = windowObj.document.createElement('div'); 13477 var _a = jsEventTypeMap[eventType], standard = _a.standard, prefixed = _a.prefixed, cssProperty = _a.cssProperty; 13478 var isStandard = cssProperty in el.style; 13479 return isStandard ? standard : prefixed; 13480 } 13481 return eventType; 13482 } 13483 13484 /** 13485 * @license 13486 * Copyright 2018 Google Inc. 13487 * 13488 * Permission is hereby granted, free of charge, to any person obtaining a copy 13489 * of this software and associated documentation files (the "Software"), to deal 13490 * in the Software without restriction, including without limitation the rights 13491 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13492 * copies of the Software, and to permit persons to whom the Software is 13493 * furnished to do so, subject to the following conditions: 13494 * 13495 * The above copyright notice and this permission notice shall be included in 13496 * all copies or substantial portions of the Software. 13497 * 13498 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13499 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13500 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13501 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 13502 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 13503 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13504 * THE SOFTWARE. 13505 */
vendor: 1,617 bytes, lines 13506-13538
13506 var MDCMenuSurface = /** @class */ (function (_super) { 13507 __extends(MDCMenuSurface, _super); 13508 function MDCMenuSurface() { 13509 return _super !== null && _super.apply(this, arguments) || this; 13510 } 13511 MDCMenuSurface.attachTo = function (root) { 13512 return new MDCMenuSurface(root); 13513 }; 13514 MDCMenuSurface.prototype.initialSyncWithDOM = function () { 13515 var _this = this; 13516 var parentEl = this.root.parentElement; 13517 this.anchorElement = parentEl && parentEl.classList.contains(cssClasses$d.ANCHOR) ? parentEl : null; 13518 if (this.root.classList.contains(cssClasses$d.FIXED)) { 13519 this.setFixedPosition(true); 13520 } 13521 this.handleKeydown = function (event) { 13522 _this.foundation.handleKeydown(event); 13523 }; 13524 this.handleBodyClick = function (event) { 13525 _this.foundation.handleBodyClick(event); 13526 }; 13527 // capture so that no race between handleBodyClick and quickOpen when 13528 // menusurface opened on button click which registers this listener 13529 this.registerBodyClickListener = function () { 13530 document.body.addEventListener('click', _this.handleBodyClick, { capture: true }); 13531 }; 13532 this.deregisterBodyClickListener = function () { 13533 document.body.removeEventListener('click', _this.handleBodyClick, { capture: true }); 13534 }; 13535 this.listen('keydown', this.handleKeydown); 13536 this.listen(strings$h.OPENED_EVENT, this.registerBodyClickListener); 13537 this.listen(strings$h.CLOSED_EVENT, this.deregisterBodyClickListener); 13538 };
13539 MDCMenuSurface.prototype.destroy = function () { 13540 this.unlisten('keydown', this.handleKeydown); 13541 this.unlisten(strings$h.OPENED_EVENT, this.registerBodyClickListener); 13542 this.unlisten(strings$h.CLOSED_EVENT, this.deregisterBodyClickListener); 13543 _super.prototype.destroy.call(this); 13544 }; 13545 MDCMenuSurface.prototype.isOpen = function () { 13546 return this.foundation.isOpen(); 13547 }; 13548 MDCMenuSurface.prototype.open = function () { 13549 this.foundation.open(); 13550 }; 13551 MDCMenuSurface.prototype.close = function (skipRestoreFocus) { 13552 if (skipRestoreFocus === void 0) { skipRestoreFocus = false; } 13553 this.foundation.close(skipRestoreFocus); 13554 }; 13555 Object.defineProperty(MDCMenuSurface.prototype, "quickOpen", { 13556 set: function (quickOpen) { 13557 this.foundation.setQuickOpen(quickOpen); 13558 }, 13559 enumerable: true, 13560 configurable: true 13561 }); 13562 /** Sets the foundation to use page offsets for an positioning when the menu is hoisted to the body. */
13563 MDCMenuSurface.prototype.setIsHoisted = function (isHoisted) { 13564 this.foundation.setIsHoisted(isHoisted); 13565 }; 13566 /** Sets the element that the menu-surface is anchored to. */ 13567 MDCMenuSurface.prototype.setMenuSurfaceAnchorElement = function (element) { 13568 this.anchorElement = element; 13569 }; 13570 /** Sets the menu-surface to position: fixed. */ 13571 MDCMenuSurface.prototype.setFixedPosition = function (isFixed) { 13572 if (isFixed) { 13573 this.root.classList.add(cssClasses$d.FIXED); 13574 } 13575 else { 13576 this.root.classList.remove(cssClasses$d.FIXED); 13577 } 13578 this.foundation.setFixedPosition(isFixed); 13579 }; 13580 /** Sets the absolute x/y position to position based on. Requires the menu to be hoisted. */ 13581 MDCMenuSurface.prototype.setAbsolutePosition = function (x, y) { 13582 this.foundation.setAbsolutePosition(x, y); 13583 this.setIsHoisted(true); 13584 }; 13585 /** 13586 * @param corner Default anchor corner alignment of top-left surface corner. 13587 */
vendor: 5,222 bytes, lines 13588-13690
13588 MDCMenuSurface.prototype.setAnchorCorner = function (corner) { 13589 this.foundation.setAnchorCorner(corner); 13590 }; 13591 MDCMenuSurface.prototype.setAnchorMargin = function (margin) { 13592 this.foundation.setAnchorMargin(margin); 13593 }; 13594 MDCMenuSurface.prototype.getDefaultFoundation = function () { 13595 var _this = this; 13596 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 13597 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 13598 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 13599 var adapter = { 13600 addClass: function (className) { return _this.root.classList.add(className); }, 13601 removeClass: function (className) { return _this.root.classList.remove(className); }, 13602 hasClass: function (className) { return _this.root.classList.contains(className); }, 13603 hasAnchor: function () { return !!_this.anchorElement; }, 13604 notifyClose: function () { 13605 return _this.emit(MDCMenuSurfaceFoundation.strings.CLOSED_EVENT, {}); 13606 }, 13607 notifyClosing: function () { 13608 _this.emit(MDCMenuSurfaceFoundation.strings.CLOSING_EVENT, {}); 13609 }, 13610 notifyOpen: function () { 13611 return _this.emit(MDCMenuSurfaceFoundation.strings.OPENED_EVENT, {}); 13612 }, 13613 isElementInContainer: function (el) { return _this.root.contains(el); }, 13614 isRtl: function () { 13615 return getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl'; 13616 }, 13617 setTransformOrigin: function (origin) { 13618 var propertyName = getCorrectPropertyName(window, 'transform') + "-origin"; 13619 _this.root.style.setProperty(propertyName, origin); 13620 }, 13621 isFocused: function () { return document.activeElement === _this.root; }, 13622 saveFocus: function () { 13623 _this.previousFocus = 13624 document.activeElement; 13625 }, 13626 restoreFocus: function () { 13627 if (_this.root.contains(document.activeElement)) { 13628 if (_this.previousFocus && _this.previousFocus.focus) { 13629 _this.previousFocus.focus(); 13630 } 13631 } 13632 }, 13633 getInnerDimensions: function () { 13634 return { 13635 width: _this.root.offsetWidth, 13636 height: _this.root.offsetHeight 13637 }; 13638 }, 13639 getAnchorDimensions: function () { return _this.anchorElement ? 13640 _this.anchorElement.getBoundingClientRect() : 13641 null; }, 13642 getWindowDimensions: function () { 13643 return { width: window.innerWidth, height: window.innerHeight }; 13644 }, 13645 getBodyDimensions: function () { 13646 return { width: document.body.clientWidth, height: document.body.clientHeight }; 13647 }, 13648 getWindowScroll: function () { 13649 return { x: window.pageXOffset, y: window.pageYOffset }; 13650 }, 13651 setPosition: function (position) { 13652 var rootHTML = _this.root; 13653 rootHTML.style.left = 'left' in position ? position.left + "px" : ''; 13654 rootHTML.style.right = 'right' in position ? position.right + "px" : ''; 13655 rootHTML.style.top = 'top' in position ? position.top + "px" : ''; 13656 rootHTML.style.bottom = 13657 'bottom' in position ? position.bottom + "px" : ''; 13658 }, 13659 setMaxHeight: function (height) { 13660 _this.root.style.maxHeight = height; 13661 }, 13662 }; 13663 // tslint:enable:object-literal-sort-keys 13664 return new MDCMenuSurfaceFoundation(adapter); 13665 }; 13666 return MDCMenuSurface; 13667 }(MDCComponent)); 13668 13669 /** 13670 * @license 13671 * Copyright 2018 Google Inc. 13672 * 13673 * Permission is hereby granted, free of charge, to any person obtaining a copy 13674 * of this software and associated documentation files (the "Software"), to deal 13675 * in the Software without restriction, including without limitation the rights 13676 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13677 * copies of the Software, and to permit persons to whom the Software is 13678 * furnished to do so, subject to the following conditions: 13679 * 13680 * The above copyright notice and this permission notice shall be included in 13681 * all copies or substantial portions of the Software. 13682 * 13683 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13684 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13685 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13686 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 13687 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 13688 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13689 * THE SOFTWARE. 13690 */
vendor: 4,761 bytes, lines 13691-13798
13691 var cssClasses$c = { 13692 MENU_SELECTED_LIST_ITEM: 'mdc-menu-item--selected', 13693 MENU_SELECTION_GROUP: 'mdc-menu__selection-group', 13694 ROOT: 'mdc-menu', 13695 }; 13696 var strings$g = { 13697 ARIA_CHECKED_ATTR: 'aria-checked', 13698 ARIA_DISABLED_ATTR: 'aria-disabled', 13699 CHECKBOX_SELECTOR: 'input[type="checkbox"]', 13700 LIST_SELECTOR: '.mdc-list', 13701 SELECTED_EVENT: 'MDCMenu:selected', 13702 }; 13703 var numbers$4 = { 13704 FOCUS_ROOT_INDEX: -1, 13705 }; 13706 var DefaultFocusState; 13707 (function (DefaultFocusState) { 13708 DefaultFocusState[DefaultFocusState["NONE"] = 0] = "NONE"; 13709 DefaultFocusState[DefaultFocusState["LIST_ROOT"] = 1] = "LIST_ROOT"; 13710 DefaultFocusState[DefaultFocusState["FIRST_ITEM"] = 2] = "FIRST_ITEM"; 13711 DefaultFocusState[DefaultFocusState["LAST_ITEM"] = 3] = "LAST_ITEM"; 13712 })(DefaultFocusState || (DefaultFocusState = {})); 13713 13714 /** 13715 * @license 13716 * Copyright 2018 Google Inc. 13717 * 13718 * Permission is hereby granted, free of charge, to any person obtaining a copy 13719 * of this software and associated documentation files (the "Software"), to deal 13720 * in the Software without restriction, including without limitation the rights 13721 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13722 * copies of the Software, and to permit persons to whom the Software is 13723 * furnished to do so, subject to the following conditions: 13724 * 13725 * The above copyright notice and this permission notice shall be included in 13726 * all copies or substantial portions of the Software. 13727 * 13728 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13729 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13730 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13731 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 13732 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 13733 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13734 * THE SOFTWARE. 13735 */ 13736 var MDCMenuFoundation = /** @class */ (function (_super) { 13737 __extends(MDCMenuFoundation, _super); 13738 function MDCMenuFoundation(adapter) { 13739 var _this = _super.call(this, __assign(__assign({}, MDCMenuFoundation.defaultAdapter), adapter)) || this; 13740 _this.closeAnimationEndTimerId_ = 0; 13741 _this.defaultFocusState_ = DefaultFocusState.LIST_ROOT; 13742 return _this; 13743 } 13744 Object.defineProperty(MDCMenuFoundation, "cssClasses", { 13745 get: function () { 13746 return cssClasses$c; 13747 }, 13748 enumerable: true, 13749 configurable: true 13750 }); 13751 Object.defineProperty(MDCMenuFoundation, "strings", { 13752 get: function () { 13753 return strings$g; 13754 }, 13755 enumerable: true, 13756 configurable: true 13757 }); 13758 Object.defineProperty(MDCMenuFoundation, "numbers", { 13759 get: function () { 13760 return numbers$4; 13761 }, 13762 enumerable: true, 13763 configurable: true 13764 }); 13765 Object.defineProperty(MDCMenuFoundation, "defaultAdapter", { 13766 /** 13767 * @see {@link MDCMenuAdapter} for typing information on parameters and return types. 13768 */ 13769 get: function () { 13770 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 13771 return { 13772 addClassToElementAtIndex: function () { return undefined; }, 13773 removeClassFromElementAtIndex: function () { return undefined; }, 13774 addAttributeToElementAtIndex: function () { return undefined; }, 13775 removeAttributeFromElementAtIndex: function () { return undefined; }, 13776 elementContainsClass: function () { return false; }, 13777 closeSurface: function () { return undefined; }, 13778 getElementIndex: function () { return -1; }, 13779 notifySelected: function () { return undefined; }, 13780 getMenuItemCount: function () { return 0; }, 13781 focusItemAtIndex: function () { return undefined; }, 13782 focusListRoot: function () { return undefined; }, 13783 getSelectedSiblingOfItemAtIndex: function () { return -1; }, 13784 isSelectableItemAtIndex: function () { return false; }, 13785 }; 13786 // tslint:enable:object-literal-sort-keys 13787 }, 13788 enumerable: true, 13789 configurable: true 13790 }); 13791 MDCMenuFoundation.prototype.destroy = function () { 13792 if (this.closeAnimationEndTimerId_) { 13793 clearTimeout(this.closeAnimationEndTimerId_); 13794 } 13795 this.adapter.closeSurface(); 13796 }; 13797 MDCMenuFoundation.prototype.handleKeydown = function (evt) { 13798 var key = evt.key, keyCode = evt.keyCode;
13799 var isTab = key === 'Tab' || keyCode === 9; 13800 if (isTab) { 13801 this.adapter.closeSurface(/** skipRestoreFocus */ true); 13802 } 13803 }; 13804 MDCMenuFoundation.prototype.handleItemAction = function (listItem) { 13805 var _this = this; 13806 var index = this.adapter.getElementIndex(listItem); 13807 if (index < 0) { 13808 return; 13809 } 13810 this.adapter.notifySelected({ index: index }); 13811 this.adapter.closeSurface(); 13812 // Wait for the menu to close before adding/removing classes that affect styles. 13813 this.closeAnimationEndTimerId_ = setTimeout(function () { 13814 // Recompute the index in case the menu contents have changed. 13815 var recomputedIndex = _this.adapter.getElementIndex(listItem); 13816 if (recomputedIndex >= 0 && 13817 _this.adapter.isSelectableItemAtIndex(recomputedIndex)) { 13818 _this.setSelectedIndex(recomputedIndex); 13819 } 13820 }, MDCMenuSurfaceFoundation.numbers.TRANSITION_CLOSE_DURATION); 13821 }; 13822 MDCMenuFoundation.prototype.handleMenuSurfaceOpened = function () { 13823 switch (this.defaultFocusState_) { 13824 case DefaultFocusState.FIRST_ITEM: 13825 this.adapter.focusItemAtIndex(0); 13826 break; 13827 case DefaultFocusState.LAST_ITEM: 13828 this.adapter.focusItemAtIndex(this.adapter.getMenuItemCount() - 1); 13829 break; 13830 case DefaultFocusState.NONE: 13831 // Do nothing. 13832 break; 13833 default: 13834 this.adapter.focusListRoot(); 13835 break; 13836 } 13837 }; 13838 /** 13839 * Sets default focus state where the menu should focus every time when menu 13840 * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by 13841 * default. 13842 */ 13843 MDCMenuFoundation.prototype.setDefaultFocusState = function (focusState) { 13844 this.defaultFocusState_ = focusState; 13845 }; 13846 /** 13847 * Selects the list item at `index` within the menu. 13848 * @param index Index of list item within the menu. 13849 */ 13850 MDCMenuFoundation.prototype.setSelectedIndex = function (index) { 13851 this.validatedIndex_(index); 13852 if (!this.adapter.isSelectableItemAtIndex(index)) { 13853 throw new Error('MDCMenuFoundation: No selection group at specified index.'); 13854 } 13855 var prevSelectedIndex = this.adapter.getSelectedSiblingOfItemAtIndex(index); 13856 if (prevSelectedIndex >= 0) { 13857 this.adapter.removeAttributeFromElementAtIndex(prevSelectedIndex, strings$g.ARIA_CHECKED_ATTR); 13858 this.adapter.removeClassFromElementAtIndex(prevSelectedIndex, cssClasse
vendor: 5,261 bytes, lines 13858-13973
13858s$c.MENU_SELECTED_LIST_ITEM); 13859 } 13860 this.adapter.addClassToElementAtIndex(index, cssClasses$c.MENU_SELECTED_LIST_ITEM); 13861 this.adapter.addAttributeToElementAtIndex(index, strings$g.ARIA_CHECKED_ATTR, 'true'); 13862 }; 13863 /** 13864 * Sets the enabled state to isEnabled for the menu item at the given index. 13865 * @param index Index of the menu item 13866 * @param isEnabled The desired enabled state of the menu item. 13867 */ 13868 MDCMenuFoundation.prototype.setEnabled = function (index, isEnabled) { 13869 this.validatedIndex_(index); 13870 if (isEnabled) { 13871 this.adapter.removeClassFromElementAtIndex(index, cssClasses$n.LIST_ITEM_DISABLED_CLASS); 13872 this.adapter.addAttributeToElementAtIndex(index, strings$g.ARIA_DISABLED_ATTR, 'false'); 13873 } 13874 else { 13875 this.adapter.addClassToElementAtIndex(index, cssClasses$n.LIST_ITEM_DISABLED_CLASS); 13876 this.adapter.addAttributeToElementAtIndex(index, strings$g.ARIA_DISABLED_ATTR, 'true'); 13877 } 13878 }; 13879 MDCMenuFoundation.prototype.validatedIndex_ = function (index) { 13880 var menuSize = this.adapter.getMenuItemCount(); 13881 var isIndexInRange = index >= 0 && index < menuSize; 13882 if (!isIndexInRange) { 13883 throw new Error('MDCMenuFoundation: No list item at specified index.'); 13884 } 13885 }; 13886 return MDCMenuFoundation; 13887 }(MDCFoundation)); 13888 13889 /** 13890 * @license 13891 * Copyright 2018 Google Inc. 13892 * 13893 * Permission is hereby granted, free of charge, to any person obtaining a copy 13894 * of this software and associated documentation files (the "Software"), to deal 13895 * in the Software without restriction, including without limitation the rights 13896 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13897 * copies of the Software, and to permit persons to whom the Software is 13898 * furnished to do so, subject to the following conditions: 13899 * 13900 * The above copyright notice and this permission notice shall be included in 13901 * all copies or substantial portions of the Software. 13902 * 13903 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 13904 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13905 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13906 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 13907 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 13908 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 13909 * THE SOFTWARE. 13910 */ 13911 var MDCMenu = /** @class */ (function (_super) { 13912 __extends(MDCMenu, _super); 13913 function MDCMenu() { 13914 return _super !== null && _super.apply(this, arguments) || this; 13915 } 13916 MDCMenu.attachTo = function (root) { 13917 return new MDCMenu(root); 13918 }; 13919 MDCMenu.prototype.initialize = function (menuSurfaceFactory, listFactory) { 13920 if (menuSurfaceFactory === void 0) { menuSurfaceFactory = function (el) { return new MDCMenuSurface(el); }; } 13921 if (listFactory === void 0) { listFactory = function (el) { return new MDCList(el); }; } 13922 this.menuSurfaceFactory_ = menuSurfaceFactory; 13923 this.listFactory_ = listFactory; 13924 }; 13925 MDCMenu.prototype.initialSyncWithDOM = function () { 13926 var _this = this; 13927 this.menuSurface_ = this.menuSurfaceFactory_(this.root); 13928 var list = this.root.querySelector(strings$g.LIST_SELECTOR); 13929 if (list) { 13930 this.list_ = this.listFactory_(list); 13931 this.list_.wrapFocus = true; 13932 } 13933 else { 13934 this.list_ = null; 13935 } 13936 this.handleKeydown_ = function (evt) { return _this.foundation.handleKeydown(evt); }; 13937 this.handleItemAction_ = function (evt) { 13938 return _this.foundation.handleItemAction(_this.items[evt.detail.index]); 13939 }; 13940 this.handleMenuSurfaceOpened_ = function () { 13941 return _this.foundation.handleMenuSurfaceOpened(); 13942 }; 13943 this.menuSurface_.listen(MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened_); 13944 this.listen('keydown', this.handleKeydown_); 13945 this.listen(MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction_); 13946 }; 13947 MDCMenu.prototype.destroy = function () { 13948 if (this.list_) { 13949 this.list_.destroy(); 13950 } 13951 this.menuSurface_.destroy(); 13952 this.menuSurface_.unlisten(MDCMenuSurfaceFoundation.strings.OPENED_EVENT, this.handleMenuSurfaceOpened_); 13953 this.unlisten('keydown', this.handleKeydown_); 13954 this.unlisten(MDCListFoundation.strings.ACTION_EVENT, this.handleItemAction_); 13955 _super.prototype.destroy.call(this); 13956 }; 13957 Object.defineProperty(MDCMenu.prototype, "open", { 13958 get: function () { 13959 return this.menuSurface_.isOpen(); 13960 }, 13961 set: function (value) { 13962 if (value) { 13963 this.menuSurface_.open(); 13964 } 13965 else { 13966 this.menuSurface_.close(); 13967 } 13968 }, 13969 enumerable: true, 13970 configurable: true 13971 }); 13972 Object.defineProperty(MDCMenu.prototype, "wrapFocus", { 13973 get: function () {
13974 return this.list_ ? this.list_.wrapFocus : false; 13975 }, 13976 set: function (value) { 13977 if (this.list_) { 13978 this.list_.wrapFocus = value; 13979 } 13980 }, 13981 enumerable: true, 13982 configurable: true 13983 }); 13984 Object.defineProperty(MDCMenu.prototype, "hasTypeahead", { 13985 /** 13986 * Sets whether the menu has typeahead functionality. 13987 * @param value Whether typeahead is enabled. 13988 */ 13989 set: function (value) { 13990 if (this.list_) { 13991 this.list_.hasTypeahead = value; 13992 } 13993 }, 13994 enumerable: true, 13995 configurable: true 13996 }); 13997 Object.defineProperty(MDCMenu.prototype, "typeaheadInProgress", { 13998 /** 13999 * @return Whether typeahead logic is currently matching some user prefix. 14000 */ 14001 get: function () { 14002 return this.list_ ? this.list_.typeaheadInProgress : false; 14003 }, 14004 enumerable: true, 14005 configurable: true 14006 }); 14007 /** 14008 * Given the next desired character from the user, adds it to the typeahead 14009 * buffer. Then, attempts to find the next option matching the buffer. Wraps 14010 * around if at the end of options. 14011 * 14012 * @param nextChar The next character to add to the prefix buffer. 14013 * @param startingIndex The index from which to start matching. Only relevant 14014 * when starting a new match sequence. To start a new match sequence, 14015 * clear the buffer using `clearTypeaheadBuffer`, or wait for the buffer 14016 * to clear after a set interval defined in list foundation. Defaults to 14017 * the currently focused index. 14018 * @return The index of the matched item, or -1 if no match. 14019 */ 14020 MDCMenu.prototype.typeaheadMatchItem = function (nextChar, startingIndex) { 14021 if (this.list_) { 14022 return this.list_.typeaheadMatchItem(nextChar, startingIndex); 14023 } 14024 return -1; 14025 }; 14026 /** 14027 * Layout the underlying list element in the case of any dynamic updates 14028 * to its structure. 14029 */ 14030 MDCMenu.prototype.layout = function () { 14031 if (this.list_) { 14032 this.list_.layout(); 14033 } 14034 }; 14035 Object.defineProperty(MDCMenu.prototype, "items", { 14036 /** 14037 * Return the items within the menu. Note that this only contains the set of elements within 14038 * the items container that are proper list items, and not supplemental / presentational DOM 14039 * elements. 14040 */ 14041 get: function () { 14042 return this.list_ ? this.list_.listElements : []; 14043 }, 14044 enumerable: true, 14045 configurable: true 14046 }); 14047 Object.defineProperty(MDCMenu.prototype, "singleSelection", { 14048 /** 14049 * Turns on/off the underlying list's single selection mode. Used mainly 14050 * by select menu. 14051 * 14052 * @param singleSelection Whether to enable single selection mode. 14053 */ 14054 set: function (singleSelection) { 14055 if (this.list_) { 14056 this.list_.singleSelection = singleSelection; 14057 } 14058 }, 14059 enumerable: true, 14060 configurable: true 14061 }); 14062 Object.defineProperty(MDCMenu.prototype, "selectedIndex", { 14063 /** 14064 * Retrieves the selected index. Only applicable to select menus. 14065 * @return The selected index, which is a number for single selection and 14066 * radio lists, and an array of numbers for checkbox lists. 14067 */ 14068 get: function () { 14069 return this.list_ ? this.list_.selectedIndex : numbers$9.UNSET_INDEX; 14070 }, 14071 /** 14072 * Sets the selected index of the list. Only applicable to select menus. 14073 * @param index The selected index, which is a number for single selection and 14074 * radio lists, and an array of numbers for checkbox lists. 14075 */ 14076 set: function (index) { 14077 if (this.list_) { 14078 this.list_.selectedIndex = index; 14079 } 14080 }, 14081 enumerable: true, 14082 configurable: true 14083 }); 14084 Object.defineProperty(MDCMenu.prototype, "quickOpen", { 14085 set: function (quickOpen) { 14086 this.menuSurface_.quickOpen = quickOpen; 14087 }, 14088 enumerable: true, 14089 configurable: true 14090 }); 14091 /** 14092 * Sets default focus state where the menu should focus every time when menu 14093 * is opened. Focuses the list root (`DefaultFocusState.LIST_ROOT`) element by 14094 * default. 14095 * @param focusState Default focus state. 14096 */ 14097 MDCMenu.prototype.setDefaultFocusState = function (focusState) { 14098 this.foundation.setDefaultFocusState(focusState); 14099 }; 14100 /** 14101 * @param corner Default anchor corner alignment of top-left menu corner. 14102 */
14103 MDCMenu.prototype.setAnchorCorner = function (corner) { 14104 this.menuSurface_.setAnchorCorner(corner); 14105 }; 14106 MDCMenu.prototype.setAnchorMargin = function (margin) { 14107 this.menuSurface_.setAnchorMargin(margin); 14108 }; 14109 /** 14110 * Sets the list item as the selected row at the specified index. 14111 * @param index Index of list item within menu. 14112 */ 14113 MDCMenu.prototype.setSelectedIndex = function (index) { 14114 this.foundation.setSelectedIndex(index); 14115 }; 14116 /** 14117 * Sets the enabled state to isEnabled for the menu item at the given index. 14118 * @param index Index of the menu item 14119 * @param isEnabled The desired enabled state of the menu item. 14120 */ 14121 MDCMenu.prototype.setEnabled = function (index, isEnabled) { 14122 this.foundation.setEnabled(index, isEnabled); 14123 }; 14124 /** 14125 * @return The item within the menu at the index specified. 14126 */ 14127 MDCMenu.prototype.getOptionByIndex = function (index) { 14128 var items = this.items; 14129 if (index < items.length) { 14130 return this.items[index]; 14131 } 14132 else { 14133 return null; 14134 } 14135 }; 14136 /** 14137 * @param index A menu item's index. 14138 * @return The primary text within the menu at the index specified. 14139 */ 14140 MDCMenu.prototype.getPrimaryTextAtIndex = function (index) { 14141 var item = this.getOptionByIndex(index); 14142 if (item && this.list_) { 14143 return this.list_.getPrimaryText(item) || ''; 14144 } 14145 return ''; 14146 }; 14147 MDCMenu.prototype.setFixedPosition = function (isFixed) { 14148 this.menuSurface_.setFixedPosition(isFixed); 14149 }; 14150 MDCMenu.prototype.setIsHoisted = function (isHoisted) { 14151 this.menuSurface_.setIsHoisted(isHoisted); 14152 }; 14153 MDCMenu.prototype.setAbsolutePosition = function (x, y) { 14154 this.menuSurface_.setAbsolutePosition(x, y); 14155 }; 14156 /** 14157 * Sets the element that the menu-surface is anchored to. 14158 */ 14159 MDCMenu.prototype.setAnchorElement = function (element) { 14160 this.menuSurface_.anchorElement = element; 14161 }; 14162 MDCMenu.prototype.getDefaultFoundation = function () { 14163 var _this = this; 14164 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 14165 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 14166 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 14167 var adapter = { 14168 addClassToElementAtIndex: function (index, className) { 14169 var list = _this.items; 14170 list[index].classList.add(className); 14171 }, 14172 removeClassFromElementAtIndex: function (index, className) { 14173 var list = _this.items; 14174 list[index].classList.remove(className); 14175 }, 14176 addAttributeToElementAtIndex: function (index, attr, value) { 14177 var list = _this.items; 14178 list[index].setAttribute(attr, value); 14179 }, 14180 removeAttributeFromElementAtIndex: function (index, attr) { 14181 var list = _this.items; 14182 list[index].removeAttribute(attr); 14183 }, 14184 elementContainsClass: function (element, className) { 14185 return element.classList.contains(className); 14186 }, 14187 closeSurface: function (skipRestoreFocus) { 14188 return _this.menuSurface_.close(skipRestoreFocus); 14189 }, 14190 getElementIndex: function (element) { return _this.items.indexOf(element); }, 14191 notifySelected: function (evtData) { 14192 return _this.emit(strings$g.SELECTED_EVENT, { 14193 index: evtData.index, 14194 item: _this.items[evtData.index], 14195 }); 14196 }, 14197 getMenuItemCount: function () { return _this.items.length; }, 14198 focusItemAtIndex: function (index) { return _this.items[index].focus(); }, 14199 focusListRoot: function () { 14200 return _this.root.querySelector(strings$g.LIST_SELECTOR) 14201 .focus(); 14202 }, 14203 isSelectableItemAtIndex: function (index) { 14204 return !!closest(_this.items[index], "." + cssClasse
14204s$c.MENU_SELECTION_GROUP); 14205 }, 14206 getSelectedSiblingOfItemAtIndex: function (index) { 14207 var selectionGroupEl = closest(_this.items[index], "." + cssClasses$c.MENU_SELECTION_GROUP); 14208 var selectedItemEl = selectionGroupEl.querySelector("." + cssClasses$c.MENU_SELECTED_LIST_ITEM); 14209 return selectedItemEl ? _this.items.indexOf(selectedItemEl) : -1; 14210 }, 14211 }; 14212 // tslint:enable:object-literal-sort-keys 14213 return new MDCMenuFoundation(adapter); 14214 }; 14215 return MDCMenu; 14216 }(MDCComponent)); 14217 14218 /** 14219 * @license 14220 * Copyright 2016 Google Inc. 14221 * 14222 * Permission is hereby granted, free of charge, to any person obtaining a copy 14223 * of this software and associated documentation files (the "Software"), to deal 14224 * in the Software without restriction, including without limitation the rights 14225 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14226 * copies of the Software, and to permit persons to whom the Software is 14227 * furnished to do so, subject to the following conditions: 14228 * 14229 * The above copyright notice and this permission notice shall be included in 14230 * all copies or substantial portions of the Software. 14231 * 14232 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14233 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14234 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14235 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14236 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 14237 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 14238 * THE SOFTWARE. 14239 */
vendor: 6,643 bytes, lines 14240-14379
14240 var cssClasses$b = { 14241 ACTIVATED: 'mdc-select--activated', 14242 DISABLED: 'mdc-select--disabled', 14243 FOCUSED: 'mdc-select--focused', 14244 INVALID: 'mdc-select--invalid', 14245 MENU_INVALID: 'mdc-select__menu--invalid', 14246 OUTLINED: 'mdc-select--outlined', 14247 REQUIRED: 'mdc-select--required', 14248 ROOT: 'mdc-select', 14249 WITH_LEADING_ICON: 'mdc-select--with-leading-icon', 14250 }; 14251 var strings$f = { 14252 ARIA_CONTROLS: 'aria-controls', 14253 ARIA_DESCRIBEDBY: 'aria-describedby', 14254 ARIA_SELECTED_ATTR: 'aria-selected', 14255 CHANGE_EVENT: 'MDCSelect:change', 14256 HIDDEN_INPUT_SELECTOR: 'input[type="hidden"]', 14257 LABEL_SELECTOR: '.mdc-floating-label', 14258 LEADING_ICON_SELECTOR: '.mdc-select__icon', 14259 LINE_RIPPLE_SELECTOR: '.mdc-line-ripple', 14260 MENU_SELECTOR: '.mdc-select__menu', 14261 OUTLINE_SELECTOR: '.mdc-notched-outline', 14262 SELECTED_TEXT_SELECTOR: '.mdc-select__selected-text', 14263 SELECT_ANCHOR_SELECTOR: '.mdc-select__anchor', 14264 VALUE_ATTR: 'data-value', 14265 }; 14266 var numbers$3 = { 14267 LABEL_SCALE: 0.75, 14268 UNSET_INDEX: -1, 14269 CLICK_DEBOUNCE_TIMEOUT_MS: 330, 14270 }; 14271 14272 /** 14273 * @license 14274 * Copyright 2016 Google Inc. 14275 * 14276 * Permission is hereby granted, free of charge, to any person obtaining a copy 14277 * of this software and associated documentation files (the "Software"), to deal 14278 * in the Software without restriction, including without limitation the rights 14279 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14280 * copies of the Software, and to permit persons to whom the Software is 14281 * furnished to do so, subject to the following conditions: 14282 * 14283 * The above copyright notice and this permission notice shall be included in 14284 * all copies or substantial portions of the Software. 14285 * 14286 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14287 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14288 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14289 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14290 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 14291 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 14292 * THE SOFTWARE. 14293 */ 14294 var MDCSelectFoundation = /** @class */ (function (_super) { 14295 __extends(MDCSelectFoundation, _super); 14296 /* istanbul ignore next: optional argument is not a branch statement */ 14297 /** 14298 * @param adapter 14299 * @param foundationMap Map from subcomponent names to their subfoundations. 14300 */ 14301 function MDCSelectFoundation(adapter, foundationMap) { 14302 if (foundationMap === void 0) { foundationMap = {}; } 14303 var _this = _super.call(this, __assign(__assign({}, MDCSelectFoundation.defaultAdapter), adapter)) || this; 14304 // Disabled state 14305 _this.disabled = false; 14306 // isMenuOpen is used to track the state of the menu by listening to the 14307 // MDCMenuSurface:closed event For reference, menu.open will return false if 14308 // the menu is still closing, but isMenuOpen returns false only after the menu 14309 // has closed 14310 _this.isMenuOpen = false; 14311 // By default, select is invalid if it is required but no value is selected. 14312 _this.useDefaultValidation = true; 14313 _this.customValidity = true; 14314 _this.lastSelectedIndex = numbers$3.UNSET_INDEX; 14315 _this.clickDebounceTimeout = 0; 14316 _this.recentlyClicked = false; 14317 _this.leadingIcon = foundationMap.leadingIcon; 14318 _this.helperText = foundationMap.helperText; 14319 return _this; 14320 } 14321 Object.defineProperty(MDCSelectFoundation, "cssClasses", { 14322 get: function () { 14323 return cssClasses$b; 14324 }, 14325 enumerable: true, 14326 configurable: true 14327 }); 14328 Object.defineProperty(MDCSelectFoundation, "numbers", { 14329 get: function () { 14330 return numbers$3; 14331 }, 14332 enumerable: true, 14333 configurable: true 14334 }); 14335 Object.defineProperty(MDCSelectFoundation, "strings", { 14336 get: function () { 14337 return strings$f; 14338 }, 14339 enumerable: true, 14340 configurable: true 14341 }); 14342 Object.defineProperty(MDCSelectFoundation, "defaultAdapter", { 14343 /** 14344 * See {@link MDCSelectAdapter} for typing information on parameters and return types. 14345 */ 14346 get: function () { 14347 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 14348 return { 14349 addClass: function () { return undefined; }, 14350 removeClass: function () { return undefined; }, 14351 hasClass: function () { return false; }, 14352 activateBottomLine: function () { return undefined; }, 14353 deactivateBottomLine: function () { return undefined; }, 14354 getSelectedIndex: function () { return -1; }, 14355 setSelectedIndex: function () { return undefined; }, 14356 hasLabel: function () { return false; }, 14357 floatLabel: function () { return undefined; }, 14358 getLabelWidth: function () { return 0; }, 14359 setLabelRequired: function () { return undefined; }, 14360 hasOutline: function () { return false; }, 14361 notchOutline: function () { return undefined; }, 14362 closeOutline: function () { return undefined; }, 14363 setRippleCenter: function () { return undefined; }, 14364 notifyChange: function () { return undefined; }, 14365 setSelectedText: function () { return undefined; }, 14366 isSelectAnchorFocused: function () { return false; }, 14367 getSelectAnchorAttr: function () { return ''; }, 14368 setSelectAnchorAttr: function () { return undefined; }, 14369 removeSelectAnchorAttr: function () { return undefined; }, 14370 addMenuClass: function () { return undefined; }, 14371 removeMenuClass: function () { return undefined; }, 14372 openMenu: function () { return undefined; }, 14373 closeMenu: function () { return undefined; }, 14374 getAnchorElement: function () { return null; }, 14375 setMenuAnchorElement: function () { return undefined; }, 14376 setMenuAnchorCorner: function () { return undefined; }, 14377 setMenuWrapFocus: function () { return undefined; }, 14378 focusMenuItemAtIndex: function () { return undefined; }, 14379 getMenuItemCount: function () { return 0; },
14380 getMenuItemValues: function () { return []; }, 14381 getMenuItemTextAtIndex: function () { return ''; }, 14382 isTypeaheadInProgress: function () { return false; }, 14383 typeaheadMatchItem: function () { return -1; }, 14384 }; 14385 // tslint:enable:object-literal-sort-keys 14386 }, 14387 enumerable: true, 14388 configurable: true 14389 }); 14390 /** Returns the index of the currently selected menu item, or -1 if none. */ 14391 MDCSelectFoundation.prototype.getSelectedIndex = function () { 14392 return this.adapter.getSelectedIndex(); 14393 }; 14394 MDCSelectFoundation.prototype.setSelectedIndex = function (index, closeMenu, skipNotify) { 14395 if (closeMenu === void 0) { closeMenu = false; } 14396 if (skipNotify === void 0) { skipNotify = false; } 14397 if (index >= this.adapter.getMenuItemCount()) { 14398 return; 14399 } 14400 if (index === numbers$3.UNSET_INDEX) { 14401 this.adapter.setSelectedText(''); 14402 } 14403 else { 14404 this.adapter.setSelectedText(this.adapter.getMenuItemTextAtIndex(index).trim()); 14405 } 14406 this.adapter.setSelectedIndex(index); 14407 if (closeMenu) { 14408 this.adapter.closeMenu(); 14409 } 14410 if (!skipNotify && this.lastSelectedIndex !== index) { 14411 this.handleChange(); 14412 } 14413 this.lastSelectedIndex = index; 14414 }; 14415 MDCSelectFoundation.prototype.setValue = function (value, skipNotify) { 14416 if (skipNotify === void 0) { skipNotify = false; }
14417 var index = this.adapter.getMenuItemValues().indexOf(value); 14418 this.setSelectedIndex(index, /** closeMenu */ false, skipNotify); 14419 }; 14420 MDCSelectFoundation.prototype.getValue = function () { 14421 var index = this.adapter.getSelectedIndex(); 14422 var menuItemValues = this.adapter.getMenuItemValues(); 14423 return index !== numbers$3.UNSET_INDEX ? menuItemValues[index] : ''; 14424 }; 14425 MDCSelectFoundation.prototype.getDisabled = function () { 14426 return this.disabled; 14427 }; 14428 MDCSelectFoundation.prototype.setDisabled = function (isDisabled) { 14429 this.disabled = isDisabled; 14430 if (this.disabled) { 14431 this.adapter.addClass(cssClasses$b.DISABLED); 14432 this.adapter.closeMenu(); 14433 } 14434 else { 14435 this.adapter.removeClass(cssClasses$b.DISABLED); 14436 } 14437 if (this.leadingIcon) { 14438 this.leadingIcon.setDisabled(this.disabled); 14439 } 14440 if (this.disabled) { 14441 // Prevent click events from focusing select. Simply pointer-events: none 14442 // is not enough since screenreader clicks may bypass this. 14443 this.adapter.removeSelectAnchorAttr('tabindex'); 14444 } 14445 else { 14446 this.adapter.setSelectAnchorAttr('tabindex', '0'); 14447 } 14448 this.adapter.setSelectAnchorAttr('aria-disabled', this.disabled.toString()); 14449 }; 14450 /** Opens the menu. */ 14451 MDCSelectFoundation.prototype.openMenu = function () { 14452 this.adapter.addClass(cssClasses$b.ACTIVATED); 14453 this.adapter.openMenu(); 14454 this.isMenuOpen = true; 14455 this.adapter.setSelectAnchorAttr('aria-expanded', 'true'); 14456 }; 14457 /** 14458 * @param content Sets the content of the helper text. 14459 */ 14460 MDCSelectFoundation.prototype.setHelperTextContent = function (content) { 14461 if (this.helperText) { 14462 this.helperText.setContent(content); 14463 } 14464 }; 14465 /** 14466 * Re-calculates if the notched outline should be notched and if the label 14467 * should float. 14468 */ 14469 MDCSelectFoundation.prototype.layout = function () { 14470 if (this.adapter.hasLabel()) { 14471 var optionHasValue = this.getValue().length > 0; 14472 var isFocused = this.adapter.hasClass(cssClasses$b.FOCUSED); 14473 var shouldFloatAndNotch = optionHasValue || isFocused; 14474 var isRequired = this.adapter.hasClass(cssClasses$b.REQUIRED); 14475 this.notchOutline(shouldFloatAndNotch); 14476 this.adapter.floatLabel(shouldFloatAndNotch); 14477 this.adapter.setLabelRequired(isRequired); 14478 } 14479 }; 14480 /** 14481 * Synchronizes the list of options with the state of the foundation. Call 14482 * this whenever menu options are dynamically updated. 14483 */ 14484 MDCSelectFoundation.prototype.layoutOptions = function () {
14485 var menuItemValues = this.adapter.getMenuItemValues(); 14486 var selectedIndex = menuItemValues.indexOf(this.getValue()); 14487 this.setSelectedIndex(selectedIndex, /** closeMenu */ false, /** skipNotify */ true); 14488 }; 14489 MDCSelectFoundation.prototype.handleMenuOpened = function () { 14490 if (this.adapter.getMenuItemValues().length === 0) { 14491 return; 14492 } 14493 // Menu should open to the last selected element, should open to first menu item otherwise. 14494 var selectedIndex = this.getSelectedIndex(); 14495 var focusItemIndex = selectedIndex >= 0 ? selectedIndex : 0; 14496 this.adapter.focusMenuItemAtIndex(focusItemIndex); 14497 }; 14498 MDCSelectFoundation.prototype.handleMenuClosing = function () { 14499 this.adapter.setSelectAnchorAttr('aria-expanded', 'false'); 14500 }; 14501 MDCSelectFoundation.prototype.handleMenuClosed = function () { 14502 this.adapter.removeClass(cssClasses$b.ACTIVATED); 14503 this.isMenuOpen = false; 14504 // Unfocus the select if menu is closed without a selection 14505 if (!this.adapter.isSelectAnchorFocused()) { 14506 this.blur(); 14507 } 14508 }; 14509 /** 14510 * Handles value changes, via change event or programmatic updates. 14511 */ 14512 MDCSelectFoundation.prototype.handleChange = function () { 14513 this.layout(); 14514 this.adapter.notifyChange(this.getValue()); 14515 var isRequired = this.adapter.hasClass(cssClasses$b.REQUIRED); 14516 if (isRequired && this.useDefaultValidation) { 14517 this.setValid(this.isValid()); 14518 } 14519 }; 14520 MDCSelectFoundation.prototype.handleMenuItemAction = function (index) { 14521 this.setSelectedIndex(index, /** closeMenu */ true); 14522 }; 14523 /** 14524 * Handles focus events from select element. 14525 */ 14526 MDCSelectFoundation.prototype.handleFocus = function () { 14527 this.adapter.addClass(cssClasses$b.FOCUSED); 14528 this.layout(); 14529 this.adapter.activateBottomLine(); 14530 }; 14531 /** 14532 * Handles blur events from select element. 14533 */ 14534 MDCSelectFoundation.prototype.handleBlur = function () { 14535 if (this.isMenuOpen) { 14536 return; 14537 } 14538 this.blur(); 14539 }; 14540 MDCSelectFoundation.prototype.handleClick = function (normalizedX) { 14541 if (this.disabled || this.recentlyClicked) { 14542 return; 14543 } 14544 this.setClickDebounceTimeout(); 14545 if (this.isMenuOpen) { 14546 this.adapter.closeMenu(); 14547 return; 14548 } 14549 this.adapter.setRippleCenter(normalizedX); 14550 this.openMenu(); 14551 }; 14552 /** 14553 * Handles keydown events on select element. Depending on the type of 14554 * character typed, does typeahead matching or opens menu. 14555 */ 14556 MDCSelectFoundation.prototype.handleKeydown = function (event) { 14557 if (this.isMenuOpen || !this.adapter.hasClass(cssClasses$b.FOCUSED)) { 14558 return; 14559 } 14560 var isEnter = normalizeKey(event) === KEY.ENTER; 14561 var isSpace = normalizeKey(event) === KEY.SPACEBAR; 14562 var arrowUp = normalizeKey(event) === KEY.ARROW_UP; 14563 var arrowDown = normalizeKey(event) === KEY.ARROW_DOWN; 14564 // Typeahead 14565 if (!isSpace && event.key && event.key.length === 1 || 14566 isSpace && this.adapter.isTypeaheadInProgress()) { 14567 var key = isSpace ? ' ' : event.key; 14568 var typeaheadNextIndex = this.adapter.typeaheadMatchItem(key, this.getSelectedIndex()); 14569 if (typeaheadNextIndex >= 0) { 14570 this.setSelectedIndex(typeaheadNextIndex); 14571 } 14572 event.preventDefault(); 14573 return; 14574 } 14575 if (!isEnter && !isSpace && !arrowUp && !arrowDown) { 14576 return; 14577 } 14578 // Increment/decrement index as necessary and open menu.
14579 if (arrowUp && this.getSelectedIndex() > 0) { 14580 this.setSelectedIndex(this.getSelectedIndex() - 1); 14581 } 14582 else if (arrowDown && 14583 this.getSelectedIndex() < this.adapter.getMenuItemCount() - 1) { 14584 this.setSelectedIndex(this.getSelectedIndex() + 1); 14585 } 14586 this.openMenu(); 14587 event.preventDefault(); 14588 }; 14589 /** 14590 * Opens/closes the notched outline. 14591 */ 14592 MDCSelectFoundation.prototype.notchOutline = function (openNotch) { 14593 if (!this.adapter.hasOutline()) { 14594 return; 14595 } 14596 var isFocused = this.adapter.hasClass(cssClasses$b.FOCUSED); 14597 if (openNotch) { 14598 var labelScale = numbers$3.LABEL_SCALE; 14599 var labelWidth = this.adapter.getLabelWidth() * labelScale; 14600 this.adapter.notchOutline(labelWidth); 14601 } 14602 else if (!isFocused) { 14603 this.adapter.closeOutline(); 14604 } 14605 }; 14606 /** 14607 * Sets the aria label of the leading icon. 14608 */ 14609 MDCSelectFoundation.prototype.setLeadingIconAriaLabel = function (label) { 14610 if (this.leadingIcon) { 14611 this.leadingIcon.setAriaLabel(label); 14612 } 14613 }; 14614 /** 14615 * Sets the text content of the leading icon. 14616 */ 14617 MDCSelectFoundation.prototype.setLeadingIconContent = function (content) { 14618 if (this.leadingIcon) { 14619 this.leadingIcon.setContent(content); 14620 } 14621 }; 14622 MDCSelectFoundation.prototype.setUseDefaultValidation = function (useDefaultValidation) { 14623 this.useDefaultValidation = useDefaultValidation; 14624 }; 14625 MDCSelectFoundation.prototype.setValid = function (isValid) { 14626 if (!this.useDefaultValidation) { 14627 this.customValidity = isValid; 14628 } 14629 this.adapter.setSelectAnchorAttr('aria-invalid', (!isValid).toString()); 14630 if (isValid) { 14631 this.adapter.removeClass(cssClasses$b.INVALID); 14632 this.adapter.removeMenuClass(cssClasses$b.MENU_INVALID); 14633 } 14634 else { 14635 this.adapter.addClass(cssClasses$b.INVALID); 14636 this.adapter.addMenuClass(cssClasses$b.MENU_INVALID); 14637 } 14638 this.syncHelperTextValidity(isValid); 14639 }; 14640 MDCSelectFoundation.prototype.isValid = function () { 14641 if (this.useDefaultValidation && 14642 this.adapter.hasClass(cssClasses$b.REQUIRED) && 14643 !this.adapter.hasClass(cssClasses$b.DISABLED)) { 14644 // See notes for required attribute under https://www.w3.org/TR/html52/sec-forms.html#the-select-element 14645 // TL;DR: Invalid if no index is selected, or if the first index is selected and has an empty value. 14646 return this.getSelectedIndex() !== numbers$3.UNSET_INDEX && 14647 (this.getSelectedIndex() !== 0 || Boolean(this.getValue())); 14648 } 14649 return this.customValidity; 14650 }; 14651 MDCSelectFoundation.prototype.setRequired = function (isRequired) { 14652 if (isRequired) { 14653 this.adapter.addClass(cssClasses$b.REQUIRED); 14654 } 14655 else { 14656 this.adapter.removeClass(cssClasses$b.REQUIRED); 14657 } 14658 this.adapter.setSelectAnchorAttr('aria-required', isRequired.toString()); 14659 this.adapter.setLabelRequired(isRequired); 14660 }; 14661 MDCSelectFoundation.prototype.getRequired = function () { 14662 return this.adapter.getSelectAnchorAttr('aria-required') === 'true'; 14663 }; 14664 MDCSelectFoundation.prototype.init = function () { 14665 var anchorEl = this.adapter.getAnchorElement(); 14666 if (anchorEl) { 14667 this.adapter.setMenuAnchorElement(anchorEl); 14668 this.adapter.setMenuAnchorCorner(Corner.BOTTOM_START); 14669 } 14670 this.adapter.setMenuWrapFocus(false); 14671 this.setDisabled(this.adapter.hasClass(cssClasses$b.DISABLED)); 14672 this.syncHelperTextValidity(!this.adapter.hasClass(cssClasses$b.INVALID)); 14673 this.layout(); 14674 this.layoutOptions(); 14675 }; 14676 /** 14677 * Unfocuses the select component. 14678 */ 14679 MDCSelectFoundation.prototype.blur = function () {
14680 this.adapter.removeClass(cssClasses$b.FOCUSED); 14681 this.layout(); 14682 this.adapter.deactivateBottomLine(); 14683 var isRequired = this.adapter.hasClass(cssClasses$b.REQUIRED); 14684 if (isRequired && this.useDefaultValidation) { 14685 this.setValid(this.isValid()); 14686 } 14687 }; 14688 MDCSelectFoundation.prototype.syncHelperTextValidity = function (isValid) { 14689 if (!this.helperText) { 14690 return; 14691 } 14692 this.helperText.setValidity(isValid); 14693 var helperTextVisible = this.helperText.isVisible(); 14694 var helperTextId = this.helperText.getId(); 14695 if (helperTextVisible && helperTextId) { 14696 this.adapter.setSelectAnchorAttr(strings$f.ARIA_DESCRIBEDBY, helperTextId); 14697 } 14698 else { 14699 // Needed because screenreaders will read labels pointed to by 14700 // `aria-describedby` even if they are `aria-hidden`. 14701 this.adapter.removeSelectAnchorAttr(strings$f.ARIA_DESCRIBEDBY); 14702 } 14703 }; 14704 MDCSelectFoundation.prototype.setClickDebounceTimeout = function () { 14705 var _this = this; 14706 clearTimeout(this.clickDebounceTimeout); 14707 this.clickDebounceTimeout = setTimeout(function () { 14708 _this.recentlyClicked = false; 14709 }, numbers$3.CLICK_DEBOUNCE_TIMEOUT_MS); 14710 this.recentlyClicked = true; 14711 }; 14712 return MDCSelectFoundation; 14713 }(MDCFoundation)); 14714 14715 /** 14716 * @license 14717 * Copyright 2018 Google Inc. 14718 * 14719 * Permission is hereby granted, free of charge, to any person obtaining a copy 14720 * of this software and associated documentation files (the "Software"), to deal 14721 * in the Software without restriction, including without limitation the rights 14722 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14723 * copies of the Software, and to permit persons to whom the Software is 14724 * furnished to do so, subject to the following conditions: 14725 * 14726 * The above copyright notice and this permission notice shall be included in 14727 * all copies or substantial portions of the Software. 14728 * 14729 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14730 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14731 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14732 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14733 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 14734 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 14735 * THE SOFTWARE. 14736 */ 14737 var strings$e = { 14738 ARIA_HIDDEN: 'aria-hidden', 14739 ROLE: 'role', 14740 };
vendor: 4,096 bytes, lines 14741-14834
14741 var cssClasses$a = { 14742 HELPER_TEXT_VALIDATION_MSG: 'mdc-select-helper-text--validation-msg', 14743 HELPER_TEXT_VALIDATION_MSG_PERSISTENT: 'mdc-select-helper-text--validation-msg-persistent', 14744 }; 14745 14746 /** 14747 * @license 14748 * Copyright 2018 Google Inc. 14749 * 14750 * Permission is hereby granted, free of charge, to any person obtaining a copy 14751 * of this software and associated documentation files (the "Software"), to deal 14752 * in the Software without restriction, including without limitation the rights 14753 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14754 * copies of the Software, and to permit persons to whom the Software is 14755 * furnished to do so, subject to the following conditions: 14756 * 14757 * The above copyright notice and this permission notice shall be included in 14758 * all copies or substantial portions of the Software. 14759 * 14760 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14761 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14762 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14763 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14764 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 14765 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 14766 * THE SOFTWARE. 14767 */ 14768 var MDCSelectHelperTextFoundation = /** @class */ (function (_super) { 14769 __extends(MDCSelectHelperTextFoundation, _super); 14770 function MDCSelectHelperTextFoundation(adapter) { 14771 return _super.call(this, __assign(__assign({}, MDCSelectHelperTextFoundation.defaultAdapter), adapter)) || this; 14772 } 14773 Object.defineProperty(MDCSelectHelperTextFoundation, "cssClasses", { 14774 get: function () { 14775 return cssClasses$a; 14776 }, 14777 enumerable: true, 14778 configurable: true 14779 }); 14780 Object.defineProperty(MDCSelectHelperTextFoundation, "strings", { 14781 get: function () { 14782 return strings$e; 14783 }, 14784 enumerable: true, 14785 configurable: true 14786 }); 14787 Object.defineProperty(MDCSelectHelperTextFoundation, "defaultAdapter", { 14788 /** 14789 * See {@link MDCSelectHelperTextAdapter} for typing information on parameters and return types. 14790 */ 14791 get: function () { 14792 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 14793 return { 14794 addClass: function () { return undefined; }, 14795 removeClass: function () { return undefined; }, 14796 hasClass: function () { return false; }, 14797 setAttr: function () { return undefined; }, 14798 getAttr: function () { return null; }, 14799 removeAttr: function () { return undefined; }, 14800 setContent: function () { return undefined; }, 14801 }; 14802 // tslint:enable:object-literal-sort-keys 14803 }, 14804 enumerable: true, 14805 configurable: true 14806 }); 14807 /** 14808 * @return The ID of the helper text, or null if none is set. 14809 */ 14810 MDCSelectHelperTextFoundation.prototype.getId = function () { 14811 return this.adapter.getAttr('id'); 14812 }; 14813 /** 14814 * @return Whether the helper text is currently visible. 14815 */ 14816 MDCSelectHelperTextFoundation.prototype.isVisible = function () { 14817 return this.adapter.getAttr(strings$e.ARIA_HIDDEN) !== 'true'; 14818 }; 14819 /** 14820 * Sets the content of the helper text field. 14821 */ 14822 MDCSelectHelperTextFoundation.prototype.setContent = function (content) { 14823 this.adapter.setContent(content); 14824 }; 14825 /** 14826 * Sets the helper text to act as a validation message. 14827 * By default, validation messages are hidden when the select is valid and 14828 * visible when the select is invalid. 14829 * 14830 * @param isValidation True to make the helper text act as an error validation 14831 * message. 14832 */ 14833 MDCSelectHelperTextFoundation.prototype.setValidation = function (isValidation) { 14834 if (isValidation) {
14835 this.adapter.addClass(cssClasses$a.HELPER_TEXT_VALIDATION_MSG); 14836 } 14837 else { 14838 this.adapter.removeClass(cssClasses$a.HELPER_TEXT_VALIDATION_MSG); 14839 } 14840 }; 14841 /** 14842 * Sets the persistency of the validation helper text. 14843 * This keeps the validation message visible even if the select is valid, 14844 * though it will be displayed in the normal (grey) color. 14845 */ 14846 MDCSelectHelperTextFoundation.prototype.setValidationMsgPersistent = function (isPersistent) { 14847 if (isPersistent) { 14848 this.adapter.addClass(cssClasses$a.HELPER_TEXT_VALIDATION_MSG_PERSISTENT); 14849 } 14850 else { 14851 this.adapter.removeClass(cssClasses$a.HELPER_TEXT_VALIDATION_MSG_PERSISTENT); 14852 } 14853 }; 14854 /** 14855 * When acting as a validation message, shows/hides the helper text and 14856 * triggers alerts as necessary based on the select's validity. 14857 */ 14858 MDCSelectHelperTextFoundation.prototype.setValidity = function (selectIsValid) { 14859 var isValidationMsg = this.adapter.hasClass(cssClasses$a.HELPER_TEXT_VALIDATION_MSG); 14860 if (!isValidationMsg) { 14861 // Non-validating helper-text is always displayed and does not participate 14862 // in validation logic. 14863 return; 14864 } 14865 var isPersistentValidationMsg = this.adapter.hasClass(cssClasses$a.HELPER_TEXT_VALIDATION_MSG_PERSISTENT); 14866 // Validating helper text is displayed if select is invalid, unless it is 14867 // set as persistent, in which case it always displays. 14868 var msgShouldDisplay = !selectIsValid || isPersistentValidationMsg; 14869 if (msgShouldDisplay) { 14870 this.showToScreenReader(); 14871 // In addition to displaying, also trigger an alert if the select 14872 // has become invalid. 14873 if (!selectIsValid) { 14874 this.adapter.setAttr(strings$e.ROLE, 'alert'); 14875 } 14876 else { 14877 this.adapter.removeAttr(strings$e.ROLE); 14878 } 14879 return; 14880 } 14881 // Hide everything. 14882 this.adapter.removeAttr(strings$e.ROLE); 14883 this.hide(); 14884 }; 14885 /** 14886 * Makes the helper text visible to screen readers. 14887 */ 14888 MDCSelectHelperTextFoundation.prototype.showToScreenReader = function () { 14889 this.adapter.removeAttr(strings$e.ARIA_HIDDEN); 14890 }; 14891 /** 14892 * Hides the help text from screen readers. 14893 */ 14894 MDCSelectHelperTextFoundation.prototype.hide = function () { 14895 this.adapter.setAttr(strings$e.ARIA_HIDDEN, 'true'); 14896 }; 14897 return MDCSelectHelperTextFoundation; 14898 }(MDCFoundation)); 14899 14900 /** 14901 * @license 14902 * Copyright 2018 Google Inc. 14903 * 14904 * Permission is hereby granted, free of charge, to any person obtaining a copy 14905 * of this software and associated documentation files (the "Software"), to deal 14906 * in the Software without restriction, including without limitation the rights 14907 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14908 * copies of the Software, and to permit persons to whom the Software is 14909 * furnished to do so, subject to the following conditions: 14910 * 14911 * The above copyright notice and this permission notice shall be included in 14912 * all copies or substantial portions of the Software. 14913 * 14914 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14915 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14916 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14917 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14918 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 14919 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 14920 * THE SOFTWARE. 14921 */ 14922 var MDCSelectHelperText = /** @class */ (function (_super) { 14923 __extends(MDCSelectHelperText, _super); 14924 function MDCSelectHelperText() { 14925 return _super !== null && _super.apply(this, arguments) || this; 14926 } 14927 MDCSelectHelperText.attachTo = function (root) { 14928 return new MDCSelectHelperText(root); 14929 }; 14930 Object.defineProperty(MDCSelectHelperText.prototype, "foundationForSelect", { 14931 // Provided for access by MDCSelect component 14932 get: function () { 14933 return this.foundation; 14934 }, 14935 enumerable: true, 14936 configurable: true 14937 }); 14938 MDCSelectHelperText.prototype.getDefaultFoundation = function () { 14939 var _this = this; 14940 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 14941 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 14942 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 14943 var adapter = { 14944 addClass: function (className) { return _this.root.classList.add(className); }, 14945 removeClass: function (className) { return _this.root.classList.remove(className); }, 14946 hasClass: function (className) { return _this.root.classList.contains(className); }, 14947 getAttr: function (attr) { return _this.root.getAttribute(attr); }, 14948 setAttr: function (attr, value) { return _this.root.setAttribute(attr, value); }, 14949 removeAttr: function (attr) { return _this.root.removeAttribute(attr); }, 14950 setContent: function (content) { 14951 _this.root.textContent = content; 14952 }, 14953 }; 14954 // tslint:enable:object-literal-sort-keys 14955 return new MDCSelectHelperTextFoundation(adapter); 14956 }; 14957 return MDCSelectHelperText; 14958 }(MDCComponent)); 14959 14960 /** 14961 * @license 14962 * Copyright 2018 Google Inc. 14963 * 14964 * Permission is hereby granted, free of charge, to any person obtaining a copy 14965 * of this software and associated documentation files (the "Software"), to deal 14966 * in the Software without restriction, including without limitation the rights 14967 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14968 * copies of the Software, and to permit persons to whom the Software is 14969 * furnished to do so, subject to the following conditions: 14970 * 14971 * The above copyright notice and this permission notice shall be included in 14972 * all copies or substantial portions of the Software. 14973 * 14974 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14975 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14976 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14977 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14978 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 14979 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 14980 * THE SOFTWARE. 14981 */ 14982 var strings$d = { 14983 ICON_EVENT: 'MDCSelect:icon', 14984 ICON_ROLE: 'button', 14985 }; 14986 14987 /** 14988 * @license 14989 * Copyright 2018 Google Inc. 14990 * 14991 * Permission is hereby granted, free of charge, to any person obtaining a copy 14992 * of this software and associated documentation files (the "Software"), to deal 14993 * in the Software without restriction, including without limitation the rights 14994 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14995 * copies of the Software, and to permit persons to whom the Software is 14996 * furnished to do so, subject to the following conditions: 14997 * 14998 * The above copyright notice and this permission notice shall be included in 14999 * all copies or substantial portions of the Software. 15000 * 15001 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15002 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15003 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15004 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15005 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15006 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15007 * THE SOFTWARE. 15008 */ 15009 var INTERACTION_EVENTS = ['click', 'keydown']; 15010 var MDCSelectIconFoundation = /** @class */ (function (_super) { 15011 __extends(MDCSelectIconFoundation, _super); 15012 function MDCSelectIconFoundation(adapter) { 15013 var _this = _super.call(this, __assign(__assign({}, MDCSelectIconFoundation.defaultAdapter), adapter)) || this; 15014 _this.savedTabIndex_ = null; 15015 _this.interactionHandler_ = function (evt) { return _this.handleInteraction(evt); }; 15016 return _this; 15017 } 15018 Object.defineProperty(MDCSelectIconFoundation, "strings", { 15019 get: function () { 15020 return strings$d; 15021 }, 15022 enumerable: true, 15023 configurable: true 15024 }); 15025 Object.defineProperty(MDCSelectIconFoundation, "defaultAdapter", { 15026 /** 15027 * See {@link MDCSelectIconAdapter} for typing information on parameters and return types. 15028 */ 15029 get: function () { 15030 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 15031 return { 15032 getAttr: function () { return null; }, 15033 setAttr: function () { return undefined; }, 15034 removeAttr: function () { return undefined; }, 15035 setContent: function () { return undefined; }, 15036 registerInteractionHandler: function () { return undefined; }, 15037 deregisterInteractionHandler: function () { return undefined; }, 15038 notifyIconAction: function () { return undefined; }, 15039 }; 15040 // tslint:enable:object-literal-sort-keys 15041 }, 15042 enumerable: true, 15043 configurable: true 15044 }); 15045 MDCSelectIconFoundation.prototype.init = function () { 15046 var _this = this; 15047 this.savedTabIndex_ = this.adapter.getAttr('tabindex');
vendor: 4,302 bytes, lines 15048-15141
15048 INTERACTION_EVENTS.forEach(function (evtType) { 15049 _this.adapter.registerInteractionHandler(evtType, _this.interactionHandler_); 15050 }); 15051 }; 15052 MDCSelectIconFoundation.prototype.destroy = function () { 15053 var _this = this; 15054 INTERACTION_EVENTS.forEach(function (evtType) { 15055 _this.adapter.deregisterInteractionHandler(evtType, _this.interactionHandler_); 15056 }); 15057 }; 15058 MDCSelectIconFoundation.prototype.setDisabled = function (disabled) { 15059 if (!this.savedTabIndex_) { 15060 return; 15061 } 15062 if (disabled) { 15063 this.adapter.setAttr('tabindex', '-1'); 15064 this.adapter.removeAttr('role'); 15065 } 15066 else { 15067 this.adapter.setAttr('tabindex', this.savedTabIndex_); 15068 this.adapter.setAttr('role', strings$d.ICON_ROLE); 15069 } 15070 }; 15071 MDCSelectIconFoundation.prototype.setAriaLabel = function (label) { 15072 this.adapter.setAttr('aria-label', label); 15073 }; 15074 MDCSelectIconFoundation.prototype.setContent = function (content) { 15075 this.adapter.setContent(content); 15076 }; 15077 MDCSelectIconFoundation.prototype.handleInteraction = function (evt) { 15078 var isEnterKey = evt.key === 'Enter' || evt.keyCode === 13; 15079 if (evt.type === 'click' || isEnterKey) { 15080 this.adapter.notifyIconAction(); 15081 } 15082 }; 15083 return MDCSelectIconFoundation; 15084 }(MDCFoundation)); 15085 15086 /** 15087 * @license 15088 * Copyright 2018 Google Inc. 15089 * 15090 * Permission is hereby granted, free of charge, to any person obtaining a copy 15091 * of this software and associated documentation files (the "Software"), to deal 15092 * in the Software without restriction, including without limitation the rights 15093 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15094 * copies of the Software, and to permit persons to whom the Software is 15095 * furnished to do so, subject to the following conditions: 15096 * 15097 * The above copyright notice and this permission notice shall be included in 15098 * all copies or substantial portions of the Software. 15099 * 15100 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15101 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15102 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15103 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15104 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15105 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15106 * THE SOFTWARE. 15107 */ 15108 var MDCSelectIcon = /** @class */ (function (_super) { 15109 __extends(MDCSelectIcon, _super); 15110 function MDCSelectIcon() { 15111 return _super !== null && _super.apply(this, arguments) || this; 15112 } 15113 MDCSelectIcon.attachTo = function (root) { 15114 return new MDCSelectIcon(root); 15115 }; 15116 Object.defineProperty(MDCSelectIcon.prototype, "foundationForSelect", { 15117 // Provided for access by MDCSelect component 15118 get: function () { 15119 return this.foundation; 15120 }, 15121 enumerable: true, 15122 configurable: true 15123 }); 15124 MDCSelectIcon.prototype.getDefaultFoundation = function () { 15125 var _this = this; 15126 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 15127 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 15128 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 15129 var adapter = { 15130 getAttr: function (attr) { return _this.root.getAttribute(attr); }, 15131 setAttr: function (attr, value) { return _this.root.setAttribute(attr, value); }, 15132 removeAttr: function (attr) { return _this.root.removeAttribute(attr); }, 15133 setContent: function (content) { 15134 _this.root.textContent = content; 15135 }, 15136 registerInteractionHandler: function (evtType, handler) { 15137 return _this.listen(evtType, handler); 15138 }, 15139 deregisterInteractionHandler: function (evtType, handler) { 15140 return _this.unlisten(evtType, handler); 15141 },
15142 notifyIconAction: function () { return _this.emit(MDCSelectIconFoundation.strings.ICON_EVENT, {} /* evtData */, true /* shouldBubble */); }, 15143 }; 15144 // tslint:enable:object-literal-sort-keys 15145 return new MDCSelectIconFoundation(adapter); 15146 }; 15147 return MDCSelectIcon; 15148 }(MDCComponent)); 15149 15150 /** 15151 * @license 15152 * Copyright 2016 Google Inc. 15153 * 15154 * Permission is hereby granted, free of charge, to any person obtaining a copy 15155 * of this software and associated documentation files (the "Software"), to deal 15156 * in the Software without restriction, including without limitation the rights 15157 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15158 * copies of the Software, and to permit persons to whom the Software is 15159 * furnished to do so, subject to the following conditions: 15160 * 15161 * The above copyright notice and this permission notice shall be included in 15162 * all copies or substantial portions of the Software. 15163 * 15164 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15165 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15166 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15167 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15168 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15169 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15170 * THE SOFTWARE. 15171 */ 15172 var MDCSelect = /** @class */ (function (_super) { 15173 __extends(MDCSelect, _super); 15174 function MDCSelect() { 15175 return _super !== null && _super.apply(this, arguments) || this; 15176 } 15177 MDCSelect.attachTo = function (root) { 15178 return new MDCSelect(root); 15179 }; 15180 MDCSelect.prototype.initialize = function (labelFactory, lineRippleFactory, outlineFactory, menuFactory, iconFactory, helperTextFactory) { 15181 if (labelFactory === void 0) { labelFactory = function (el) { return new MDCFloatingLabel(el); }; } 15182 if (lineRippleFactory === void 0) { lineRippleFactory = function (el) { return new MDCLineRipple(el); }; } 15183 if (outlineFactory === void 0) { outlineFactory = function (el) { return new MDCNotchedOutline(el); }; } 15184 if (menuFactory === void 0) { menuFactory = function (el) { return new MDCMenu(el); }; } 15185 if (iconFactory === void 0) { iconFactory = function (el) { return new MDCSelectIcon(el); }; } 15186 if (helperTextFactory === void 0) { helperTextFactory = function (el) { return new MDCSelectHelperText(el); }; } 15187 this.selectAnchor = 15188 this.root.querySelector(strings$f.SELECT_ANCHOR_SELECTOR); 15189 this.selectedText = 15190 this.root.querySelector(strings$f.SELECTED_TEXT_SELECTOR); 15191 this.hiddenInput = this.root.querySelector(strings$f.HIDDEN_INPUT_SELECTOR); 15192 if (!this.selectedText) { 15193 throw new Error('MDCSelect: Missing required element: The following selector must be present: ' + 15194 ("'" + strings$f.SELECTED_TEXT_SELECTOR + "'")); 15195 } 15196 if (this.selectAnchor.hasAttribute(strings$f.ARIA_CONTROLS)) { 15197 var helperTextElement = document.getElementById(this.selectAnchor.getAttribute(strings$f.ARIA_CONTROLS)); 15198 if (helperTextElement) { 15199 this.helperText = helperTextFactory(helperTextElement); 15200 } 15201 } 15202 this.menuSetup(menuFactory); 15203 var labelElement = this.root.querySelector(strings$f.LABEL_SELECTOR); 15204 this.label = labelElement ? labelFactory(labelElement) : null; 15205 var lineRippleElement = this.root.querySelector(strings$f.LINE_RIPPLE_SELECTOR); 15206 this.lineRipple = 15207 lineRippleElement ? lineRippleFactory(lineRippleElement) : null; 15208 var outlineElement = this.root.querySelector(strings$f.OUTLINE_SELECTOR); 15209 this.outline = outlineElement ? outlineFactory(outlineElement) : null; 15210 var leadingIcon = this.root.querySelector(strings$f.LEADING_ICON_SELECTOR); 15211 if (leadingIcon) { 15212 this.leadingIcon = iconFactory(leadingIcon); 15213 }
15214 if (!this.root.classList.contains(cssClasses$b.OUTLINED)) { 15215 this.ripple = this.createRipple(); 15216 } 15217 }; 15218 /** 15219 * Initializes the select's event listeners and internal state based 15220 * on the environment's state. 15221 */ 15222 MDCSelect.prototype.initialSyncWithDOM = function () { 15223 var _this = this; 15224 this.handleFocus = function () { 15225 _this.foundation.handleFocus(); 15226 }; 15227 this.handleBlur = function () { 15228 _this.foundation.handleBlur(); 15229 }; 15230 this.handleClick = function (evt) { 15231 _this.selectAnchor.focus(); 15232 _this.foundation.handleClick(_this.getNormalizedXCoordinate(evt)); 15233 }; 15234 this.handleKeydown = function (evt) { 15235 _this.foundation.handleKeydown(evt); 15236 }; 15237 this.handleMenuItemAction = function (evt) { 15238 _this.foundation.handleMenuItemAction(evt.detail.index); 15239 }; 15240 this.handleMenuOpened = function () { 15241 _this.foundation.handleMenuOpened(); 15242 }; 15243 this.handleMenuClosed = function () { 15244 _this.foundation.handleMenuClosed(); 15245 }; 15246 this.handleMenuClosing = function () { 15247 _this.foundation.handleMenuClosing(); 15248 }; 15249 this.selectAnchor.addEventListener('focus', this.handleFocus); 15250 this.selectAnchor.addEventListener('blur', this.handleBlur); 15251 this.selectAnchor.addEventListener('click', this.handleClick); 15252 this.selectAnchor.addEventListener('keydown', this.handleKeydown); 15253 this.menu.listen(strings$h.CLOSED_EVENT, this.handleMenuClosed); 15254 this.menu.listen(strings$h.CLOSING_EVENT, this.handleMenuClosing); 15255 this.menu.listen(strings$h.OPENED_EVENT, this.handleMenuOpened); 15256 this.menu.listen(strings$g.SELECTED_EVENT, this.handleMenuItemAction); 15257 if (this.hiddenInput) { 15258 if (this.hiddenInput.value) { 15259 // If the hidden input already has a value, use it to restore the 15260 // select's value. This can happen e.g. if the user goes back or (in 15261 // some browsers) refreshes the page. 15262 this.foundation.setValue(this.hiddenInput.value, /** skipNotify */ true); 15263 this.foundation.layout(); 15264 return; 15265 } 15266 this.hiddenInput.value = this.value; 15267 } 15268 }; 15269 MDCSelect.prototype.destroy = function () { 15270 this.selectAnchor.removeEventListener('focus', this.handleFocus); 15271 this.selectAnchor.removeEventListener('blur', this.handleBlur); 15272 this.selectAnchor.removeEventListener('keydown', this.handleKeydown); 15273 this.selectAnchor.removeEventListener('click', this.handleClick); 15274 this.menu.unlisten(strings$h.CLOSED_EVENT, this.handleMenuClosed); 15275 this.menu.unlisten(strings$h.OPENED_EVENT, this.handleMenuOpened); 15276 this.menu.unlisten(strings$g.SELECTED_EVENT, this.handleMenuItemAction); 15277 this.menu.destroy(); 15278 if (this.ripple) { 15279 this.ripple.destroy(); 15280 } 15281 if (this.outline) { 15282 this.outline.destroy(); 15283 } 15284 if (this.leadingIcon) { 15285 this.leadingIcon.destroy(); 15286 } 15287 if (this.helperText) { 15288 this.helperText.destroy(); 15289 } 15290 _super.prototype.destroy.call(this); 15291 }; 15292 Object.defineProperty(MDCSelect.prototype, "value", { 15293 get: function () { 15294 return this.foundation.getValue(); 15295 }, 15296 set: function (value) { 15297 this.foundation.setValue(value); 15298 }, 15299 enumerable: true, 15300 configurable: true 15301 }); 15302 Object.defineProperty(MDCSelect.prototype, "selectedIndex", { 15303 get: function () { 15304 return this.foundation.getSelectedIndex(); 15305 }, 15306 set: function (selectedIndex) { 15307 this.foundation.setSelectedIndex(selectedIndex, /** closeMenu */ true); 15308 }, 15309 enumerable: true, 15310 configurable: true 15311 }); 15312 Object.defineProperty(MDCSelect.prototype, "disabled", { 15313 get: function () { 15314 return this.foundation.getDisabled(); 15315 }, 15316 set: function (disabled) { 15317 this.foundation.setDisabled(disabled); 15318 if (this.hiddenInput) { 15319 this.hiddenInput.disabled = disabled; 15320 } 15321 }, 15322 enumerable: true, 15323 configurable: true 15324 }); 15325 Object.defineProperty(MDCSelect.prototype, "leadingIconAriaLabel", { 15326 set: function (label) { 15327 this.foundation.setLeadingIconAriaLabel(label); 15328 }, 15329 enumerable: true, 15330 configurable: true 15331 }); 15332 Object.defineProperty(MDCSelect.prototype, "leadingIconContent", { 15333 /** 15334 * Sets the text content of the leading icon. 15335 */ 15336 set: function (content) { 15337 this.foundation.setLeadingIconContent(content); 15338 }, 15339 enumerable: true, 15340 configurable: true 15341 }); 15342 Object.defineProperty(MDCSelect.prototype, "helperTextContent", { 15343 /** 15344 * Sets the text content of the helper text. 15345 */ 15346 set: function (content) { 15347 this.foundation.setHelperTextContent(content); 15348 }, 15349 enumerable: true, 15350 configurable: true 15351 }); 15352 Object.defineProperty(MDCSelect.prototype, "useDefaultValidation", { 15353 /** 15354 * Enables or disables the default validation scheme where a required select 15355 * must be non-empty. Set to false for custom validation.
15356 * @param useDefaultValidation Set this to false to ignore default 15357 * validation scheme. 15358 */ 15359 set: function (useDefaultValidation) { 15360 this.foundation.setUseDefaultValidation(useDefaultValidation); 15361 }, 15362 enumerable: true, 15363 configurable: true 15364 }); 15365 Object.defineProperty(MDCSelect.prototype, "valid", { 15366 /** 15367 * Checks if the select is in a valid state. 15368 */ 15369 get: function () { 15370 return this.foundation.isValid(); 15371 }, 15372 /** 15373 * Sets the current invalid state of the select. 15374 */ 15375 set: function (isValid) { 15376 this.foundation.setValid(isValid); 15377 }, 15378 enumerable: true, 15379 configurable: true 15380 }); 15381 Object.defineProperty(MDCSelect.prototype, "required", { 15382 /** 15383 * Returns whether the select is required. 15384 */ 15385 get: function () { 15386 return this.foundation.getRequired(); 15387 }, 15388 /** 15389 * Sets the control to the required state. 15390 */ 15391 set: function (isRequired) { 15392 this.foundation.setRequired(isRequired); 15393 }, 15394 enumerable: true, 15395 configurable: true 15396 }); 15397 /** 15398 * Re-calculates if the notched outline should be notched and if the label 15399 * should float. 15400 */ 15401 MDCSelect.prototype.layout = function () { 15402 this.foundation.layout(); 15403 }; 15404 /** 15405 * Synchronizes the list of options with the state of the foundation. Call 15406 * this whenever menu options are dynamically updated. 15407 */ 15408 MDCSelect.prototype.layoutOptions = function () { 15409 this.foundation.layoutOptions(); 15410 this.menu.layout(); 15411 // Update cached menuItemValues for adapter. 15412 this.menuItemValues = 15413 this.menu.items.map(function (el) { return el.getAttribute(strings$f.VALUE_ATTR) || ''; }); 15414 if (this.hiddenInput) { 15415 this.hiddenInput.value = this.value; 15416 } 15417 }; 15418 MDCSelect.prototype.getDefaultFoundation = function () { 15419 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 15420 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 15421 var adapter = __assign(__assign(__assign(__assign({}, this.getSelectAdapterMethods()), this.getCommonAdapterMethods()), this.getOutlineAdapterMethods()), this.getLabelAdapterMethods()); 15422 return new MDCSelectFoundation(adapter, this.getFoundationMap()); 15423 }; 15424 /** 15425 * Handles setup for the menu. 15426 */ 15427 MDCSelect.prototype.menuSetup = function (menuFactory) { 15428 this.menuElement = this.root.querySelector(strings$f.MENU_SELECTOR); 15429 this.menu = menuFactory(this.menuElement); 15430 this.menu.hasTypeahead = true; 15431 this.menu.singleSelection = true; 15432 this.menuItemValues = 15433 this.menu.items.map(function (el) { return el.getAttribute(strings$f.VALUE_ATTR) || ''; }); 15434 }; 15435 MDCSelect.prototype.createRipple = function () { 15436 var _this = this; 15437 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 15438 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 15439 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 15440 var adapter = __assign(__assign({}, MDCRipple.createAdapter({ root: this.selectAnchor })), { registerInteractionHandler: function (evtType, handler) { 15441 _this.selectAnchor.addEventListener(evtType, handler); 15442 }, deregisterInteractionHandler: function (evtType, handler) { 15443 _this.selectAnchor.removeEventListener(evtType, handler); 15444 } }); 15445 // tslint:enable:object-literal-sort-keys 15446 return new MDCRipple(this.selectAnchor, new MDCRippleFoundation(adapter)); 15447 }; 15448 MDCSelect.prototype.getSelectAdapterMethods = function () { 15449 var _this = this; 15450 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 15451 return { 15452 getMenuItemAttr: function (menuItem, attr) { 15453 return menuItem.getAttribute(attr); 15454 }, 15455 setSelectedText: function (text) { 15456 _this.selectedText.textContent = text; 15457 }, 15458 isSelectAnchorFocused: function () { return document.activeElement === _this.selectAnchor; }, 15459 getSelectAnchorAttr: function (attr) { 15460 return _this.selectAnchor.getAttribute(attr); 15461 }, 15462 setSelectAnchorAttr: function (attr, value) { 15463 _this.selectAnchor.setAttribute(attr, value); 15464 }, 15465 removeSelectAnchorAttr: function (attr) { 15466 _this.selectAnchor.removeAttribute(attr); 15467 }, 15468 addMenuClass: function (className) { 15469 _this.menuElement.classList.add(className); 15470 }, 15471 removeMenuClass: function (className) { 15472 _this.menuElement.classList.remove(className); 15473 }, 15474 openMenu: function () { 15475 _this.menu.open = true; 15476 }, 15477 closeMenu: function () { 15478 _this.menu.open = false;
15479 }, 15480 getAnchorElement: function () { 15481 return _this.root.querySelector(strings$f.SELECT_ANCHOR_SELECTOR); 15482 }, 15483 setMenuAnchorElement: function (anchorEl) { 15484 _this.menu.setAnchorElement(anchorEl); 15485 }, 15486 setMenuAnchorCorner: function (anchorCorner) { 15487 _this.menu.setAnchorCorner(anchorCorner); 15488 }, 15489 setMenuWrapFocus: function (wrapFocus) { 15490 _this.menu.wrapFocus = wrapFocus; 15491 }, 15492 getSelectedIndex: function () { 15493 var index = _this.menu.selectedIndex; 15494 return index instanceof Array ? index[0] : index; 15495 }, 15496 setSelectedIndex: function (index) { 15497 _this.menu.selectedIndex = index; 15498 }, 15499 focusMenuItemAtIndex: function (index) { 15500 _this.menu.items[index].focus(); 15501 }, 15502 getMenuItemCount: function () { return _this.menu.items.length; }, 15503 // Cache menu item values. layoutOptions() updates this cache.
15504 getMenuItemValues: function () { return _this.menuItemValues; }, 15505 getMenuItemTextAtIndex: function (index) { 15506 return _this.menu.getPrimaryTextAtIndex(index); 15507 }, 15508 isTypeaheadInProgress: function () { return _this.menu.typeaheadInProgress; }, 15509 typeaheadMatchItem: function (nextChar, startingIndex) { 15510 return _this.menu.typeaheadMatchItem(nextChar, startingIndex); 15511 }, 15512 }; 15513 // tslint:enable:object-literal-sort-keys 15514 }; 15515 MDCSelect.prototype.getCommonAdapterMethods = function () { 15516 var _this = this; 15517 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 15518 return { 15519 addClass: function (className) { 15520 _this.root.classList.add(className); 15521 }, 15522 removeClass: function (className) { 15523 _this.root.classList.remove(className); 15524 }, 15525 hasClass: function (className) { return _this.root.classList.contains(className); }, 15526 setRippleCenter: function (normalizedX) { 15527 _this.lineRipple && _this.lineRipple.setRippleCenter(normalizedX); 15528 }, 15529 activateBottomLine: function () { 15530 _this.lineRipple && _this.lineRipple.activate(); 15531 }, 15532 deactivateBottomLine: function () { 15533 _this.lineRipple && _this.lineRipple.deactivate(); 15534 }, 15535 notifyChange: function (value) { 15536 var index = _this.selectedIndex; 15537 _this.emit(strings$f.CHANGE_EVENT, { value: value, index: index }, true /* shouldBubble */); 15538 if (_this.hiddenInput) { 15539 _this.hiddenInput.value = value; 15540 } 15541 }, 15542 }; 15543 // tslint:enable:object-literal-sort-keys 15544 }; 15545 MDCSelect.prototype.getOutlineAdapterMethods = function () { 15546 var _this = this; 15547 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 15548 return { 15549 hasOutline: function () { return Boolean(_this.outline); }, 15550 notchOutline: function (labelWidth) { 15551 _this.outline && _this.outline.notch(labelWidth); 15552 }, 15553 closeOutline: function () { 15554 _this.outline && _this.outline.closeNotch(); 15555 }, 15556 }; 15557 // tslint:enable:object-literal-sort-keys 15558 }; 15559 MDCSelect.prototype.getLabelAdapterMethods = function () { 15560 var _this = this; 15561 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 15562 return { 15563 hasLabel: function () { return !!_this.label; }, 15564 floatLabel: function (shouldFloat) { 15565 _this.label && _this.label.float(shouldFloat); 15566 }, 15567 getLabelWidth: function () { return _this.label ? _this.label.getWidth() : 0; }, 15568 setLabelRequired: function (isRequired) { 15569 _this.label && _this.label.setRequired(isRequired); 15570 }, 15571 }; 15572 // tslint:enable:object-literal-sort-keys 15573 }; 15574 /** 15575 * Calculates where the line ripple should start based on the x coordinate within the component. 15576 */ 15577 MDCSelect.prototype.getNormalizedXCoordinate = function (evt) { 15578 var targetClientRect = evt.target.getBoundingClientRect(); 15579 var xCoordinate = this.isTouchEvent(evt) ? evt.touches[0].clientX : evt.clientX; 15580 return xCoordinate - targetClientRect.left; 15581 }; 15582 MDCSelect.prototype.isTouchEvent = function (evt) { 15583 return Boolean(evt.touches); 15584 }; 15585 /** 15586 * Returns a map of all subcomponents to subfoundations. 15587 */ 15588 MDCSelect.prototype.getFoundationMap = function () { 15589 return { 15590 helperText: this.helperText ? this.helperText.foundationForSelect : 15591 undefined, 15592 leadingIcon: this.leadingIcon ? this.leadingIcon.foundationForSelect : 15593 undefined, 15594 }; 15595 }; 15596 return MDCSelect; 15597 }(MDCComponent)); 15598 15599 /** 15600 * @license 15601 * Copyright 2019 Google Inc. 15602 * 15603 * Permission is hereby granted, free of charge, to any person obtaining a copy 15604 * of this software and associated documentation files (the "Software"), to deal 15605 * in the Software without restriction, including without limitation the rights 15606 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15607 * copies of the Software, and to permit persons to whom the Software is 15608 * furnished to do so, subject to the following conditions: 15609 * 15610 * The above copyright notice and this permission notice shall be included in 15611 * all copies or substantial portions of the Software. 15612 * 15613 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15614 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15615 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15616 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15617 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15618 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15619 * THE SOFTWARE. 15620 */ 15621 15622 /** 15623 * @license 15624 * Copyright 2019 Google Inc. 15625 * 15626 * Permission is hereby granted, free of charge, to any person obtaining a copy 15627 * of this software and associated documentation files (the "Software"), to deal 15628 * in the Software without restriction, including without limitation the rights 15629 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15630 * copies of the Software, and to permit persons to whom the Software is 15631 * furnished to do so, subject to the following conditions: 15632 * 15633 * The above copyright notice and this permission notice shall be included in 15634 * all copies or substantial portions of the Software. 15635 * 15636 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15637 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15638 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15639 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15640 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15641 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15642 * THE SOFTWARE. 15643 */ 15644 15645 /** 15646 * @license 15647 * Copyright 2019 Google Inc. 15648 * 15649 * Permission is hereby granted, free of charge, to any person obtaining a copy 15650 * of this software and associated documentation files (the "Software"), to deal 15651 * in the Software without restriction, including without limitation the rights 15652 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15653 * copies of the Software, and to permit persons to whom the Software is 15654 * furnished to do so, subject to the following conditions: 15655 * 15656 * The above copyright notice and this permission notice shall be included in 15657 * all copies or substantial portions of the Software. 15658 * 15659 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15660 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15661 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15662 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15663 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15664 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15665 * THE SOFTWARE. 15666 */ 15667 15668 /** 15669 * @license 15670 * Copyright 2018 Google Inc. 15671 * 15672 * Permission is hereby granted, free of charge, to any person obtaining a copy 15673 * of this software and associated documentation files (the "Software"), to deal 15674 * in the Software without restriction, including without limitation the rights 15675 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15676 * copies of the Software, and to permit persons to whom the Software is 15677 * furnished to do so, subject to the following conditions: 15678 * 15679 * The above copyright notice and this permission notice shall be included in 15680 * all copies or substantial portions of the Software. 15681 * 15682 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15683 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15684 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15685 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15686 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15687 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15688 * THE SOFTWARE. 15689 */ 15690 /** CSS classes used by the switch. */
15691 var cssClasses$9 = { 15692 /** Class used for a switch that is in the "checked" (on) position. */ 15693 CHECKED: 'mdc-switch--checked', 15694 /** Class used for a switch that is disabled. */ 15695 DISABLED: 'mdc-switch--disabled', 15696 }; 15697 /** String constants used by the switch. */ 15698 var strings$c = { 15699 /** Aria attribute for checked or unchecked state of switch */ 15700 ARIA_CHECKED_ATTR: 'aria-checked', 15701 /** A CSS selector used to locate the native HTML control for the switch. */ 15702 NATIVE_CONTROL_SELECTOR: '.mdc-switch__native-control', 15703 /** A CSS selector used to locate the ripple surface element for the switch. */ 15704 RIPPLE_SURFACE_SELECTOR: '.mdc-switch__thumb-underlay', 15705 }; 15706 15707 /** 15708 * @license 15709 * Copyright 2018 Google Inc. 15710 * 15711 * Permission is hereby granted, free of charge, to any person obtaining a copy 15712 * of this software and associated documentation files (the "Software"), to deal 15713 * in the Software without restriction, including without limitation the rights 15714 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15715 * copies of the Software, and to permit persons to whom the Software is 15716 * furnished to do so, subject to the following conditions: 15717 * 15718 * The above copyright notice and this permission notice shall be included in 15719 * all copies or substantial portions of the Software. 15720 * 15721 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15722 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15723 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15724 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15725 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15726 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15727 * THE SOFTWARE. 15728 */ 15729 var MDCSwitchFoundation = /** @class */ (function (_super) { 15730 __extends(MDCSwitchFoundation, _super); 15731 function MDCSwitchFoundation(adapter) { 15732 return _super.call(this, __assign(__assign({}, MDCSwitchFoundation.defaultAdapter), adapter)) || this; 15733 } 15734 Object.defineProperty(MDCSwitchFoundation, "strings", { 15735 /** The string constants used by the switch. */ 15736 get: function () { 15737 return strings$c; 15738 }, 15739 enumerable: true, 15740 configurable: true 15741 }); 15742 Object.defineProperty(MDCSwitchFoundation, "cssClasses", { 15743 /** The CSS classes used by the switch. */ 15744 get: function () { 15745 return cssClasses$9; 15746 }, 15747 enumerable: true, 15748 configurable: true 15749 }); 15750 Object.defineProperty(MDCSwitchFoundation, "defaultAdapter", { 15751 /** The default Adapter for the switch. */ 15752 get: function () { 15753 return { 15754 addClass: function () { return undefined; }, 15755 removeClass: function () { return undefined; }, 15756 setNativeControlChecked: function () { return undefined; }, 15757 setNativeControlDisabled: function () { return undefined; }, 15758 setNativeControlAttr: function () { return undefined; }, 15759 }; 15760 }, 15761 enumerable: true, 15762 configurable: true 15763 }); 15764 /** Sets the checked state of the switch. */ 15765 MDCSwitchFoundation.prototype.setChecked = function (checked) { 15766 this.adapter.setNativeControlChecked(checked); 15767 this.updateAriaChecked_(checked); 15768 this.updateCheckedStyling_(checked); 15769 }; 15770 /** Sets the disabled state of the switch. */ 15771 MDCSwitchFoundation.prototype.setDisabled = function (disabled) { 15772 this.adapter.setNativeControlDisabled(disabled); 15773 if (disabled) { 15774 this.adapter.addClass(cssClasses$9.DISABLED); 15775 } 15776 else { 15777 this.adapter.removeClass(cssClasses$9.DISABLED); 15778 } 15779 }; 15780 /** Handles the change event for the switch native control. */ 15781 MDCSwitchFoundation.prototype.handleChange = function (evt) { 15782 var nativeControl = evt.target; 15783 this.updateAriaChecked_(nativeControl.checked); 15784 this.updateCheckedStyling_(nativeControl.checked); 15785 }; 15786 /** Updates the styling of the switch based on its checked state. */ 15787 MDCSwitchFoundation.prototype.updateCheckedStyling_ = function (checked) { 15788 if (checked) {
15789 this.adapter.addClass(cssClasses$9.CHECKED); 15790 } 15791 else { 15792 this.adapter.removeClass(cssClasses$9.CHECKED); 15793 } 15794 }; 15795 MDCSwitchFoundation.prototype.updateAriaChecked_ = function (checked) { 15796 this.adapter.setNativeControlAttr(strings$c.ARIA_CHECKED_ATTR, "" + !!checked); 15797 }; 15798 return MDCSwitchFoundation; 15799 }(MDCFoundation)); 15800 15801 /** 15802 * @license 15803 * Copyright 2018 Google Inc. 15804 * 15805 * Permission is hereby granted, free of charge, to any person obtaining a copy 15806 * of this software and associated documentation files (the "Software"), to deal 15807 * in the Software without restriction, including without limitation the rights 15808 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15809 * copies of the Software, and to permit persons to whom the Software is 15810 * furnished to do so, subject to the following conditions: 15811 * 15812 * The above copyright notice and this permission notice shall be included in 15813 * all copies or substantial portions of the Software. 15814 * 15815 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15816 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15817 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15818 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15819 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15820 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15821 * THE SOFTWARE. 15822 */ 15823 var MDCSwitch = /** @class */ (function (_super) { 15824 __extends(MDCSwitch, _super); 15825 function MDCSwitch() { 15826 var _this = _super !== null && _super.apply(this, arguments) || this; 15827 _this.ripple_ = _this.createRipple_(); 15828 return _this; 15829 } 15830 MDCSwitch.attachTo = function (root) { 15831 return new MDCSwitch(root); 15832 }; 15833 MDCSwitch.prototype.destroy = function () { 15834 _super.prototype.destroy.call(this); 15835 this.ripple_.destroy(); 15836 this.nativeControl_.removeEventListener('change', this.changeHandler_); 15837 }; 15838 MDCSwitch.prototype.initialSyncWithDOM = function () { 15839 var _this = this; 15840 this.changeHandler_ = function () { 15841 var _a; 15842 var args = []; 15843 for (var _i = 0; _i < arguments.length; _i++) { 15844 args[_i] = arguments[_i]; 15845 } 15846 return (_a = _this.foundation).handleChange.apply(_a, __spread(args)); 15847 }; 15848 this.nativeControl_.addEventListener('change', this.changeHandler_); 15849 // Sometimes the checked state of the input element is saved in the history. 15850 // The switch styling should match the checked state of the input element. 15851 // Do an initial sync between the native control and the foundation. 15852 this.checked = this.checked; 15853 }; 15854 MDCSwitch.prototype.getDefaultFoundation = function () { 15855 var _this = this; 15856 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 15857 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 15858 var adapter = { 15859 addClass: function (className) { return _this.root.classList.add(className); }, 15860 removeClass: function (className) { return _this.root.classList.remove(className); }, 15861 setNativeControlChecked: function (checked) { return _this.nativeControl_.checked = 15862 checked; }, 15863 setNativeControlDisabled: function (disabled) { return _this.nativeControl_.disabled = 15864 disabled; }, 15865 setNativeControlAttr: function (attr, value) { 15866 return _this.nativeControl_.setAttribute(attr, value); 15867 }, 15868 }; 15869 return new MDCSwitchFoundation(adapter); 15870 }; 15871 Object.defineProperty(MDCSwitch.prototype, "ripple", { 15872 get: function () { 15873 return this.ripple_; 15874 }, 15875 enumerable: true, 15876 configurable: true 15877 }); 15878 Object.defineProperty(MDCSwitch.prototype, "checked", { 15879 get: function () { 15880 return this.nativeControl_.checked; 15881 }, 15882 set: function (checked) { 15883 this.foundation.setChecked(checked); 15884 }, 15885 enumerable: true, 15886 configurable: true 15887 }); 15888 Object.defineProperty(MDCSwitch.prototype, "disabled", { 15889 get: function () { 15890 return this.nativeControl_.disabled; 15891 }, 15892 set: function (disabled) { 15893 this.foundation.setDisabled(disabled); 15894 }, 15895 enumerable: true, 15896 configurable: true 15897 }); 15898 MDCSwitch.prototype.createRipple_ = function () { 15899 var _this = this; 15900 var RIPPLE_SURFACE_SELECTOR = MDCSwitchFoundation.strings.RIPPLE_SURFACE_SELECTOR; 15901 var rippleSurface = this.root.querySelector(RIPPLE_SURFACE_SELECTOR); 15902 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 15903 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 15904 var adapter = __assign(__assign({}, MDCRipple.createAdapter(this)), { addClass: function (className) { return rippleSurface.classList.add(className); }, computeBoundingRect: function () { return rippleSurface.getBoundingClientRect(); }, deregisterInteractionHandler: function (evtType, handler) { 15905 _this.nativeControl_.removeEventListener(evtType, handler, applyPassive()); 15906 }, isSurfaceActive: function () { return matches$1(_this.nativeControl_, ':active'); }, isUnbounded: function () { return true; }, registerInteractionHandler: function (evtType, handler) { 15907 _this.nativeControl_.addEventListener(evtType, handler, applyPassive()); 15908 }, removeClass: function (className) { 15909 rippleSurface.classList.remove(className); 15910 }, updateCssVariable: function (varName, value) { 15911 rippleSurface.style.setProperty(varName, value); 15912 } }); 15913 return new MDCRipple(this.root, new MDCRippleFoundation(adapter)); 15914 };
15915 Object.defineProperty(MDCSwitch.prototype, "nativeControl_", { 15916 get: function () { 15917 var NATIVE_CONTROL_SELECTOR = MDCSwitchFoundation.strings.NATIVE_CONTROL_SELECTOR; 15918 return this.root.querySelector(NATIVE_CONTROL_SELECTOR); 15919 }, 15920 enumerable: true, 15921 configurable: true 15922 }); 15923 return MDCSwitch; 15924 }(MDCComponent)); 15925 15926 /** 15927 * @license 15928 * Copyright 2019 Google Inc. 15929 * 15930 * Permission is hereby granted, free of charge, to any person obtaining a copy 15931 * of this software and associated documentation files (the "Software"), to deal 15932 * in the Software without restriction, including without limitation the rights 15933 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15934 * copies of the Software, and to permit persons to whom the Software is 15935 * furnished to do so, subject to the following conditions: 15936 * 15937 * The above copyright notice and this permission notice shall be included in 15938 * all copies or substantial portions of the Software. 15939 * 15940 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15941 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15942 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15943 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15944 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15945 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15946 * THE SOFTWARE. 15947 */ 15948 15949 /** 15950 * @license 15951 * Copyright 2018 Google Inc. 15952 * 15953 * Permission is hereby granted, free of charge, to any person obtaining a copy 15954 * of this software and associated documentation files (the "Software"), to deal 15955 * in the Software without restriction, including without limitation the rights 15956 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15957 * copies of the Software, and to permit persons to whom the Software is 15958 * furnished to do so, subject to the following conditions: 15959 * 15960 * The above copyright notice and this permission notice shall be included in 15961 * all copies or substantial portions of the Software. 15962 * 15963 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15964 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15965 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 15966 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15967 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15968 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 15969 * THE SOFTWARE. 15970 */
15971 var cssClasses$8 = { 15972 CLOSING: 'mdc-snackbar--closing', 15973 OPEN: 'mdc-snackbar--open', 15974 OPENING: 'mdc-snackbar--opening', 15975 }; 15976 var strings$b = { 15977 ACTION_SELECTOR: '.mdc-snackbar__action', 15978 ARIA_LIVE_LABEL_TEXT_ATTR: 'data-mdc-snackbar-label-text', 15979 CLOSED_EVENT: 'MDCSnackbar:closed', 15980 CLOSING_EVENT: 'MDCSnackbar:closing', 15981 DISMISS_SELECTOR: '.mdc-snackbar__dismiss', 15982 LABEL_SELECTOR: '.mdc-snackbar__label', 15983 OPENED_EVENT: 'MDCSnackbar:opened', 15984 OPENING_EVENT: 'MDCSnackbar:opening', 15985 REASON_ACTION: 'action', 15986 REASON_DISMISS: 'dismiss', 15987 SURFACE_SELECTOR: '.mdc-snackbar__surface', 15988 }; 15989 var numbers$2 = { 15990 DEFAULT_AUTO_DISMISS_TIMEOUT_MS: 5000, 15991 INDETERMINATE: -1, 15992 MAX_AUTO_DISMISS_TIMEOUT_MS: 10000, 15993 MIN_AUTO_DISMISS_TIMEOUT_MS: 4000, 15994 // These variables need to be kept in sync with the values in _variables.scss. 15995 SNACKBAR_ANIMATION_CLOSE_TIME_MS: 75, 15996 SNACKBAR_ANIMATION_OPEN_TIME_MS: 150, 15997 /** 15998 * Number of milliseconds to wait between temporarily clearing the label text 15999 * in the DOM and subsequently restoring it. This is necessary to force IE 11 16000 * to pick up the `aria-live` content change and announce it to the user. 16001 */ 16002 ARIA_LIVE_DELAY_MS: 1000, 16003 }; 16004 16005 /** 16006 * @license 16007 * Copyright 2018 Google Inc. 16008 * 16009 * Permission is hereby granted, free of charge, to any person obtaining a copy 16010 * of this software and associated documentation files (the "Software"), to deal 16011 * in the Software without restriction, including without limitation the rights 16012 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16013 * copies of the Software, and to permit persons to whom the Software is 16014 * furnished to do so, subject to the following conditions: 16015 * 16016 * The above copyright notice and this permission notice shall be included in 16017 * all copies or substantial portions of the Software. 16018 * 16019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16022 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16023 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16024 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16025 * THE SOFTWARE. 16026 */ 16027 var ARIA_LIVE_DELAY_MS = numbers$2.ARIA_LIVE_DELAY_MS; 16028 var ARIA_LIVE_LABEL_TEXT_ATTR = strings$b.ARIA_LIVE_LABEL_TEXT_ATTR; 16029 function announce$1(ariaEl, labelEl) { 16030 if (labelEl === void 0) { labelEl = ariaEl; } 16031 var priority = ariaEl.getAttribute('aria-live'); 16032 // Trim text to ignore ` ` (see below). 16033 // textContent is only null if the node is a document, DOCTYPE, or notation. 16034 var labelText = labelEl.textContent.trim(); 16035 if (!labelText || !priority) { 16036 return; 16037 } 16038 // Temporarily disable `aria-live` to prevent JAWS+Firefox from announcing the message twice. 16039 ariaEl.setAttribute('aria-live', 'off'); 16040 // Temporarily clear `textContent` to force a DOM mutation event that will be detected by screen readers. 16041 // `aria-live` elements are only announced when the element's `textContent` *changes*, so snackbars 16042 // sent to the browser in the initial HTML response won't be read unless we clear the element's `textContent` first. 16043 // Similarly, displaying the same snackbar message twice in a row doesn't trigger a DOM mutation event, 16044 // so screen readers won't announce the second message unless we first clear `textContent`. 16045 // 16046 // We have to clear the label text two different ways to make it work in all browsers and screen readers: 16047 // 16048 // 1. `textContent = ''` is required for IE11 + JAWS 16049 // 2. `innerHTML = ' '` is required for Chrome + JAWS and NVDA 16050 // 16051 // All other browser/screen reader combinations support both methods. 16052 // 16053 // The wrapper `<span>` visually hides the space character so that it doesn't cause jank when added/removed. 16054 // N.B.: Setting `position: absolute`, `opacity: 0`, or `height: 0` prevents Chrome from detecting the DOM change. 16055 // 16056 // This technique has been tested in: 16057 // 16058 // * JAWS 2019: 16059 // - Chrome 70 16060 // - Firefox 60 (ESR) 16061 // - IE 11 16062 // * NVDA 2018: 16063 // - Chrome 70 16064 // - Firefox 60 (ESR) 16065 // - IE 11 16066 // * ChromeVox 53 16067 labelEl.textContent = ''; 16068 labelEl.innerHTML = '<span style="display: inline-block; width: 0; height: 1px;"> </span>'; 16069 // Prevent visual jank by temporarily displaying the label text in the ::before pseudo-element. 16070 // CSS generated content is normally announced by screen readers 16071 // (except in IE 11; see https://tink.uk/accessibility-support-for-css-generated-content/);
vendor: 6,005 bytes, lines 16072-16204
16072 // however, `aria-live` is turned off, so this DOM update will be ignored by screen readers. 16073 labelEl.setAttribute(ARIA_LIVE_LABEL_TEXT_ATTR, labelText); 16074 setTimeout(function () { 16075 // Allow screen readers to announce changes to the DOM again. 16076 ariaEl.setAttribute('aria-live', priority); 16077 // Remove the message from the ::before pseudo-element. 16078 labelEl.removeAttribute(ARIA_LIVE_LABEL_TEXT_ATTR); 16079 // Restore the original label text, which will be announced by screen readers. 16080 labelEl.textContent = labelText; 16081 }, ARIA_LIVE_DELAY_MS); 16082 } 16083 16084 /** 16085 * @license 16086 * Copyright 2018 Google Inc. 16087 * 16088 * Permission is hereby granted, free of charge, to any person obtaining a copy 16089 * of this software and associated documentation files (the "Software"), to deal 16090 * in the Software without restriction, including without limitation the rights 16091 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16092 * copies of the Software, and to permit persons to whom the Software is 16093 * furnished to do so, subject to the following conditions: 16094 * 16095 * The above copyright notice and this permission notice shall be included in 16096 * all copies or substantial portions of the Software. 16097 * 16098 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16099 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16100 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16101 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16102 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16103 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16104 * THE SOFTWARE. 16105 */ 16106 var OPENING = cssClasses$8.OPENING, OPEN = cssClasses$8.OPEN, CLOSING = cssClasses$8.CLOSING; 16107 var REASON_ACTION = strings$b.REASON_ACTION, REASON_DISMISS = strings$b.REASON_DISMISS; 16108 var MDCSnackbarFoundation = /** @class */ (function (_super) { 16109 __extends(MDCSnackbarFoundation, _super); 16110 function MDCSnackbarFoundation(adapter) { 16111 var _this = _super.call(this, __assign(__assign({}, MDCSnackbarFoundation.defaultAdapter), adapter)) || this; 16112 _this.isOpen_ = false; 16113 _this.animationFrame_ = 0; 16114 _this.animationTimer_ = 0; 16115 _this.autoDismissTimer_ = 0; 16116 _this.autoDismissTimeoutMs_ = numbers$2.DEFAULT_AUTO_DISMISS_TIMEOUT_MS; 16117 _this.closeOnEscape_ = true; 16118 return _this; 16119 } 16120 Object.defineProperty(MDCSnackbarFoundation, "cssClasses", { 16121 get: function () { 16122 return cssClasses$8; 16123 }, 16124 enumerable: true, 16125 configurable: true 16126 }); 16127 Object.defineProperty(MDCSnackbarFoundation, "strings", { 16128 get: function () { 16129 return strings$b; 16130 }, 16131 enumerable: true, 16132 configurable: true 16133 }); 16134 Object.defineProperty(MDCSnackbarFoundation, "numbers", { 16135 get: function () { 16136 return numbers$2; 16137 }, 16138 enumerable: true, 16139 configurable: true 16140 }); 16141 Object.defineProperty(MDCSnackbarFoundation, "defaultAdapter", { 16142 get: function () { 16143 return { 16144 addClass: function () { return undefined; }, 16145 announce: function () { return undefined; }, 16146 notifyClosed: function () { return undefined; }, 16147 notifyClosing: function () { return undefined; }, 16148 notifyOpened: function () { return undefined; }, 16149 notifyOpening: function () { return undefined; }, 16150 removeClass: function () { return undefined; }, 16151 }; 16152 }, 16153 enumerable: true, 16154 configurable: true 16155 }); 16156 MDCSnackbarFoundation.prototype.destroy = function () { 16157 this.clearAutoDismissTimer_(); 16158 cancelAnimationFrame(this.animationFrame_); 16159 this.animationFrame_ = 0; 16160 clearTimeout(this.animationTimer_); 16161 this.animationTimer_ = 0; 16162 this.adapter.removeClass(OPENING); 16163 this.adapter.removeClass(OPEN); 16164 this.adapter.removeClass(CLOSING); 16165 }; 16166 MDCSnackbarFoundation.prototype.open = function () { 16167 var _this = this; 16168 this.clearAutoDismissTimer_(); 16169 this.isOpen_ = true; 16170 this.adapter.notifyOpening(); 16171 this.adapter.removeClass(CLOSING); 16172 this.adapter.addClass(OPENING); 16173 this.adapter.announce(); 16174 // Wait a frame once display is no longer "none", to establish basis for animation 16175 this.runNextAnimationFrame_(function () { 16176 _this.adapter.addClass(OPEN); 16177 _this.animationTimer_ = setTimeout(function () { 16178 var timeoutMs = _this.getTimeoutMs(); 16179 _this.handleAnimationTimerEnd_(); 16180 _this.adapter.notifyOpened(); 16181 if (timeoutMs !== numbers$2.INDETERMINATE) { 16182 _this.autoDismissTimer_ = setTimeout(function () { 16183 _this.close(REASON_DISMISS); 16184 }, timeoutMs); 16185 } 16186 }, numbers$2.SNACKBAR_ANIMATION_OPEN_TIME_MS); 16187 }); 16188 }; 16189 /** 16190 * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the 16191 * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom 16192 * client-specific values may also be used if desired. 16193 */ 16194 MDCSnackbarFoundation.prototype.close = function (reason) { 16195 var _this = this; 16196 if (reason === void 0) { reason = ''; } 16197 if (!this.isOpen_) { 16198 // Avoid redundant close calls (and events), e.g. repeated interactions as the snackbar is animating closed 16199 return; 16200 } 16201 cancelAnimationFrame(this.animationFrame_); 16202 this.animationFrame_ = 0; 16203 this.clearAutoDismissTimer_(); 16204 this.isOpen_ = false;
vendor: 10,399 bytes, lines 16205-16424
16205 this.adapter.notifyClosing(reason); 16206 this.adapter.addClass(cssClasses$8.CLOSING); 16207 this.adapter.removeClass(cssClasses$8.OPEN); 16208 this.adapter.removeClass(cssClasses$8.OPENING); 16209 clearTimeout(this.animationTimer_); 16210 this.animationTimer_ = setTimeout(function () { 16211 _this.handleAnimationTimerEnd_(); 16212 _this.adapter.notifyClosed(reason); 16213 }, numbers$2.SNACKBAR_ANIMATION_CLOSE_TIME_MS); 16214 }; 16215 MDCSnackbarFoundation.prototype.isOpen = function () { 16216 return this.isOpen_; 16217 }; 16218 MDCSnackbarFoundation.prototype.getTimeoutMs = function () { 16219 return this.autoDismissTimeoutMs_; 16220 }; 16221 MDCSnackbarFoundation.prototype.setTimeoutMs = function (timeoutMs) { 16222 // Use shorter variable names to make the code more readable 16223 var minValue = numbers$2.MIN_AUTO_DISMISS_TIMEOUT_MS; 16224 var maxValue = numbers$2.MAX_AUTO_DISMISS_TIMEOUT_MS; 16225 var indeterminateValue = numbers$2.INDETERMINATE; 16226 if (timeoutMs === numbers$2.INDETERMINATE || (timeoutMs <= maxValue && timeoutMs >= minValue)) { 16227 this.autoDismissTimeoutMs_ = timeoutMs; 16228 } 16229 else { 16230 throw new Error("\n timeoutMs must be an integer in the range " + minValue + "\u2013" + maxValue + "\n (or " + indeterminateValue + " to disable), but got '" + timeoutMs + "'"); 16231 } 16232 }; 16233 MDCSnackbarFoundation.prototype.getCloseOnEscape = function () { 16234 return this.closeOnEscape_; 16235 }; 16236 MDCSnackbarFoundation.prototype.setCloseOnEscape = function (closeOnEscape) { 16237 this.closeOnEscape_ = closeOnEscape; 16238 }; 16239 MDCSnackbarFoundation.prototype.handleKeyDown = function (evt) { 16240 var isEscapeKey = evt.key === 'Escape' || evt.keyCode === 27; 16241 if (isEscapeKey && this.getCloseOnEscape()) { 16242 this.close(REASON_DISMISS); 16243 } 16244 }; 16245 MDCSnackbarFoundation.prototype.handleActionButtonClick = function (_evt) { 16246 this.close(REASON_ACTION); 16247 }; 16248 MDCSnackbarFoundation.prototype.handleActionIconClick = function (_evt) { 16249 this.close(REASON_DISMISS); 16250 }; 16251 MDCSnackbarFoundation.prototype.clearAutoDismissTimer_ = function () { 16252 clearTimeout(this.autoDismissTimer_); 16253 this.autoDismissTimer_ = 0; 16254 }; 16255 MDCSnackbarFoundation.prototype.handleAnimationTimerEnd_ = function () { 16256 this.animationTimer_ = 0; 16257 this.adapter.removeClass(cssClasses$8.OPENING); 16258 this.adapter.removeClass(cssClasses$8.CLOSING); 16259 }; 16260 /** 16261 * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior. 16262 */ 16263 MDCSnackbarFoundation.prototype.runNextAnimationFrame_ = function (callback) { 16264 var _this = this; 16265 cancelAnimationFrame(this.animationFrame_); 16266 this.animationFrame_ = requestAnimationFrame(function () { 16267 _this.animationFrame_ = 0; 16268 clearTimeout(_this.animationTimer_); 16269 _this.animationTimer_ = setTimeout(callback, 0); 16270 }); 16271 }; 16272 return MDCSnackbarFoundation; 16273 }(MDCFoundation)); 16274 16275 /** 16276 * @license 16277 * Copyright 2018 Google Inc. 16278 * 16279 * Permission is hereby granted, free of charge, to any person obtaining a copy 16280 * of this software and associated documentation files (the "Software"), to deal 16281 * in the Software without restriction, including without limitation the rights 16282 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16283 * copies of the Software, and to permit persons to whom the Software is 16284 * furnished to do so, subject to the following conditions: 16285 * 16286 * The above copyright notice and this permission notice shall be included in 16287 * all copies or substantial portions of the Software. 16288 * 16289 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16290 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16291 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16292 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16293 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16294 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16295 * THE SOFTWARE. 16296 */ 16297 var SURFACE_SELECTOR = strings$b.SURFACE_SELECTOR, LABEL_SELECTOR = strings$b.LABEL_SELECTOR, ACTION_SELECTOR = strings$b.ACTION_SELECTOR, DISMISS_SELECTOR = strings$b.DISMISS_SELECTOR, OPENING_EVENT = strings$b.OPENING_EVENT, OPENED_EVENT = strings$b.OPENED_EVENT, CLOSING_EVENT = strings$b.CLOSING_EVENT, CLOSED_EVENT = strings$b.CLOSED_EVENT; 16298 var MDCSnackbar = /** @class */ (function (_super) { 16299 __extends(MDCSnackbar, _super); 16300 function MDCSnackbar() { 16301 return _super !== null && _super.apply(this, arguments) || this; 16302 } 16303 MDCSnackbar.attachTo = function (root) { 16304 return new MDCSnackbar(root); 16305 }; 16306 MDCSnackbar.prototype.initialize = function (announcerFactory) { 16307 if (announcerFactory === void 0) { announcerFactory = function () { return announce$1; }; } 16308 this.announce_ = announcerFactory(); 16309 }; 16310 MDCSnackbar.prototype.initialSyncWithDOM = function () { 16311 var _this = this; 16312 this.surfaceEl_ = this.root.querySelector(SURFACE_SELECTOR); 16313 this.labelEl_ = this.root.querySelector(LABEL_SELECTOR); 16314 this.actionEl_ = this.root.querySelector(ACTION_SELECTOR); 16315 this.handleKeyDown_ = function (evt) { return _this.foundation.handleKeyDown(evt); }; 16316 this.handleSurfaceClick_ = function (evt) { 16317 var target = evt.target; 16318 if (_this.isActionButton_(target)) { 16319 _this.foundation.handleActionButtonClick(evt); 16320 } 16321 else if (_this.isActionIcon_(target)) { 16322 _this.foundation.handleActionIconClick(evt); 16323 } 16324 }; 16325 this.registerKeyDownHandler_(this.handleKeyDown_); 16326 this.registerSurfaceClickHandler_(this.handleSurfaceClick_); 16327 }; 16328 MDCSnackbar.prototype.destroy = function () { 16329 _super.prototype.destroy.call(this); 16330 this.deregisterKeyDownHandler_(this.handleKeyDown_); 16331 this.deregisterSurfaceClickHandler_(this.handleSurfaceClick_); 16332 }; 16333 MDCSnackbar.prototype.open = function () { 16334 this.foundation.open(); 16335 }; 16336 /** 16337 * @param reason Why the snackbar was closed. Value will be passed to CLOSING_EVENT and CLOSED_EVENT via the 16338 * `event.detail.reason` property. Standard values are REASON_ACTION and REASON_DISMISS, but custom 16339 * client-specific values may also be used if desired. 16340 */ 16341 MDCSnackbar.prototype.close = function (reason) { 16342 if (reason === void 0) { reason = ''; } 16343 this.foundation.close(reason); 16344 }; 16345 MDCSnackbar.prototype.getDefaultFoundation = function () { 16346 var _this = this; 16347 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 16348 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 16349 var adapter = { 16350 addClass: function (className) { return _this.root.classList.add(className); }, 16351 announce: function () { return _this.announce_(_this.labelEl_); }, 16352 notifyClosed: function (reason) { return _this.emit(CLOSED_EVENT, reason ? { reason: reason } : {}); }, 16353 notifyClosing: function (reason) { return _this.emit(CLOSING_EVENT, reason ? { reason: reason } : {}); }, 16354 notifyOpened: function () { return _this.emit(OPENED_EVENT, {}); }, 16355 notifyOpening: function () { return _this.emit(OPENING_EVENT, {}); }, 16356 removeClass: function (className) { return _this.root.classList.remove(className); }, 16357 }; 16358 return new MDCSnackbarFoundation(adapter); 16359 }; 16360 Object.defineProperty(MDCSnackbar.prototype, "timeoutMs", { 16361 get: function () { 16362 return this.foundation.getTimeoutMs(); 16363 }, 16364 set: function (timeoutMs) { 16365 this.foundation.setTimeoutMs(timeoutMs); 16366 }, 16367 enumerable: true, 16368 configurable: true 16369 }); 16370 Object.defineProperty(MDCSnackbar.prototype, "closeOnEscape", { 16371 get: function () { 16372 return this.foundation.getCloseOnEscape(); 16373 }, 16374 set: function (closeOnEscape) { 16375 this.foundation.setCloseOnEscape(closeOnEscape); 16376 }, 16377 enumerable: true, 16378 configurable: true 16379 }); 16380 Object.defineProperty(MDCSnackbar.prototype, "isOpen", { 16381 get: function () { 16382 return this.foundation.isOpen(); 16383 }, 16384 enumerable: true, 16385 configurable: true 16386 }); 16387 Object.defineProperty(MDCSnackbar.prototype, "labelText", { 16388 get: function () { 16389 // This property only returns null if the node is a document, DOCTYPE, or notation. 16390 // On Element nodes, it always returns a string. 16391 return this.labelEl_.textContent; 16392 }, 16393 set: function (labelText) { 16394 this.labelEl_.textContent = labelText; 16395 }, 16396 enumerable: true, 16397 configurable: true 16398 }); 16399 Object.defineProperty(MDCSnackbar.prototype, "actionButtonText", { 16400 get: function () { 16401 return this.actionEl_.textContent; 16402 }, 16403 set: function (actionButtonText) { 16404 this.actionEl_.textContent = actionButtonText; 16405 }, 16406 enumerable: true, 16407 configurable: true 16408 }); 16409 MDCSnackbar.prototype.registerKeyDownHandler_ = function (handler) { 16410 this.listen('keydown', handler); 16411 }; 16412 MDCSnackbar.prototype.deregisterKeyDownHandler_ = function (handler) { 16413 this.unlisten('keydown', handler); 16414 }; 16415 MDCSnackbar.prototype.registerSurfaceClickHandler_ = function (handler) { 16416 this.surfaceEl_.addEventListener('click', handler); 16417 }; 16418 MDCSnackbar.prototype.deregisterSurfaceClickHandler_ = function (handler) { 16419 this.surfaceEl_.removeEventListener('click', handler); 16420 }; 16421 MDCSnackbar.prototype.isActionButton_ = function (target) { 16422 return Boolean(closest(target, ACTION_SELECTOR)); 16423 }; 16424 MDCSnackbar.prototype.isActionIcon_ = function (target) {
16425 return Boolean(closest(target, DISMISS_SELECTOR)); 16426 }; 16427 return MDCSnackbar; 16428 }(MDCComponent)); 16429 16430 /** 16431 * @license 16432 * Copyright 2019 Google Inc. 16433 * 16434 * Permission is hereby granted, free of charge, to any person obtaining a copy 16435 * of this software and associated documentation files (the "Software"), to deal 16436 * in the Software without restriction, including without limitation the rights 16437 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16438 * copies of the Software, and to permit persons to whom the Software is 16439 * furnished to do so, subject to the following conditions: 16440 * 16441 * The above copyright notice and this permission notice shall be included in 16442 * all copies or substantial portions of the Software. 16443 * 16444 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16445 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16446 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16447 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16448 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16449 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16450 * THE SOFTWARE. 16451 */ 16452 16453 /** 16454 * @license 16455 * Copyright 2017 Google Inc. 16456 * 16457 * Permission is hereby granted, free of charge, to any person obtaining a copy 16458 * of this software and associated documentation files (the "Software"), to deal 16459 * in the Software without restriction, including without limitation the rights 16460 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16461 * copies of the Software, and to permit persons to whom the Software is 16462 * furnished to do so, subject to the following conditions: 16463 * 16464 * The above copyright notice and this permission notice shall be included in 16465 * all copies or substantial portions of the Software. 16466 * 16467 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16468 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16469 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16470 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16471 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16472 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16473 * THE SOFTWARE. 16474 */
16475 var cssClasses$7 = { 16476 ROOT: 'mdc-form-field', 16477 }; 16478 var strings$a = { 16479 LABEL_SELECTOR: '.mdc-form-field > label', 16480 }; 16481 16482 /** 16483 * @license 16484 * Copyright 2017 Google Inc. 16485 * 16486 * Permission is hereby granted, free of charge, to any person obtaining a copy 16487 * of this software and associated documentation files (the "Software"), to deal 16488 * in the Software without restriction, including without limitation the rights 16489 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16490 * copies of the Software, and to permit persons to whom the Software is 16491 * furnished to do so, subject to the following conditions: 16492 * 16493 * The above copyright notice and this permission notice shall be included in 16494 * all copies or substantial portions of the Software. 16495 * 16496 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16497 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16498 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16499 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16500 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16501 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16502 * THE SOFTWARE. 16503 */ 16504 var MDCFormFieldFoundation = /** @class */ (function (_super) { 16505 __extends(MDCFormFieldFoundation, _super); 16506 function MDCFormFieldFoundation(adapter) { 16507 var _this = _super.call(this, __assign(__assign({}, MDCFormFieldFoundation.defaultAdapter), adapter)) || this; 16508 _this.click = function () { 16509 _this.handleClick(); 16510 }; 16511 return _this; 16512 } 16513 Object.defineProperty(MDCFormFieldFoundation, "cssClasses", { 16514 get: function () { 16515 return cssClasses$7; 16516 }, 16517 enumerable: true, 16518 configurable: true 16519 }); 16520 Object.defineProperty(MDCFormFieldFoundation, "strings", { 16521 get: function () { 16522 return strings$a; 16523 }, 16524 enumerable: true, 16525 configurable: true 16526 }); 16527 Object.defineProperty(MDCFormFieldFoundation, "defaultAdapter", { 16528 get: function () { 16529 return { 16530 activateInputRipple: function () { return undefined; }, 16531 deactivateInputRipple: function () { return undefined; }, 16532 deregisterInteractionHandler: function () { return undefined; }, 16533 registerInteractionHandler: function () { return undefined; }, 16534 }; 16535 }, 16536 enumerable: true, 16537 configurable: true 16538 }); 16539 MDCFormFieldFoundation.prototype.init = function () { 16540 this.adapter.registerInteractionHandler('click', this.click); 16541 }; 16542 MDCFormFieldFoundation.prototype.destroy = function () { 16543 this.adapter.deregisterInteractionHandler('click', this.click); 16544 }; 16545 MDCFormFieldFoundation.prototype.handleClick = function () { 16546 var _this = this; 16547 this.adapter.activateInputRipple(); 16548 requestAnimationFrame(function () { 16549 _this.adapter.deactivateInputRipple(); 16550 }); 16551 }; 16552 return MDCFormFieldFoundation; 16553 }(MDCFoundation)); 16554 16555 /** 16556 * @license 16557 * Copyright 2017 Google Inc. 16558 * 16559 * Permission is hereby granted, free of charge, to any person obtaining a copy 16560 * of this software and associated documentation files (the "Software"), to deal 16561 * in the Software without restriction, including without limitation the rights 16562 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16563 * copies of the Software, and to permit persons to whom the Software is 16564 * furnished to do so, subject to the following conditions: 16565 * 16566 * The above copyright notice and this permission notice shall be included in 16567 * all copies or substantial portions of the Software. 16568 * 16569 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16570 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16571 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16572 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16573 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16574 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16575 * THE SOFTWARE. 16576 */ 16577 var MDCFormField = /** @class */ (function (_super) { 16578 __extends(MDCFormField, _super); 16579 function MDCFormField() { 16580 return _super !== null && _super.apply(this, arguments) || this; 16581 } 16582 MDCFormField.attachTo = function (root) { 16583 return new MDCFormField(root); 16584 }; 16585 MDCFormField.prototype.labelEl = function () {
16586 var LABEL_SELECTOR = MDCFormFieldFoundation.strings.LABEL_SELECTOR; 16587 return this.root.querySelector(LABEL_SELECTOR); 16588 }; 16589 MDCFormField.prototype.getDefaultFoundation = function () { 16590 var _this = this; 16591 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 16592 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 16593 var adapter = { 16594 activateInputRipple: function () { 16595 if (_this.input && _this.input.ripple) { 16596 _this.input.ripple.activate(); 16597 } 16598 }, 16599 deactivateInputRipple: function () { 16600 if (_this.input && _this.input.ripple) { 16601 _this.input.ripple.deactivate(); 16602 } 16603 }, 16604 deregisterInteractionHandler: function (evtType, handler) { 16605 var labelEl = _this.labelEl(); 16606 if (labelEl) { 16607 labelEl.removeEventListener(evtType, handler); 16608 } 16609 }, 16610 registerInteractionHandler: function (evtType, handler) { 16611 var labelEl = _this.labelEl(); 16612 if (labelEl) { 16613 labelEl.addEventListener(evtType, handler); 16614 } 16615 }, 16616 }; 16617 return new MDCFormFieldFoundation(adapter); 16618 }; 16619 return MDCFormField; 16620 }(MDCComponent)); 16621 16622 /** 16623 * @license 16624 * Copyright 2019 Google Inc. 16625 * 16626 * Permission is hereby granted, free of charge, to any person obtaining a copy 16627 * of this software and associated documentation files (the "Software"), to deal 16628 * in the Software without restriction, including without limitation the rights 16629 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16630 * copies of the Software, and to permit persons to whom the Software is 16631 * furnished to do so, subject to the following conditions: 16632 * 16633 * The above copyright notice and this permission notice shall be included in 16634 * all copies or substantial portions of the Software. 16635 * 16636 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16637 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16638 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16639 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16640 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16641 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16642 * THE SOFTWARE. 16643 */ 16644 16645 /** 16646 * @license 16647 * Copyright 2016 Google Inc. 16648 * 16649 * Permission is hereby granted, free of charge, to any person obtaining a copy 16650 * of this software and associated documentation files (the "Software"), to deal 16651 * in the Software without restriction, including without limitation the rights 16652 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16653 * copies of the Software, and to permit persons to whom the Software is 16654 * furnished to do so, subject to the following conditions: 16655 * 16656 * The above copyright notice and this permission notice shall be included in 16657 * all copies or substantial portions of the Software. 16658 * 16659 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16660 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16661 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16662 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16663 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16664 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16665 * THE SOFTWARE. 16666 */
16667 var cssClasses$6 = { 16668 ANIM_CHECKED_INDETERMINATE: 'mdc-checkbox--anim-checked-indeterminate', 16669 ANIM_CHECKED_UNCHECKED: 'mdc-checkbox--anim-checked-unchecked', 16670 ANIM_INDETERMINATE_CHECKED: 'mdc-checkbox--anim-indeterminate-checked', 16671 ANIM_INDETERMINATE_UNCHECKED: 'mdc-checkbox--anim-indeterminate-unchecked', 16672 ANIM_UNCHECKED_CHECKED: 'mdc-checkbox--anim-unchecked-checked', 16673 ANIM_UNCHECKED_INDETERMINATE: 'mdc-checkbox--anim-unchecked-indeterminate', 16674 BACKGROUND: 'mdc-checkbox__background', 16675 CHECKED: 'mdc-checkbox--checked', 16676 CHECKMARK: 'mdc-checkbox__checkmark', 16677 CHECKMARK_PATH: 'mdc-checkbox__checkmark-path', 16678 DISABLED: 'mdc-checkbox--disabled', 16679 INDETERMINATE: 'mdc-checkbox--indeterminate', 16680 MIXEDMARK: 'mdc-checkbox__mixedmark', 16681 NATIVE_CONTROL: 'mdc-checkbox__native-control', 16682 ROOT: 'mdc-checkbox', 16683 SELECTED: 'mdc-checkbox--selected', 16684 UPGRADED: 'mdc-checkbox--upgraded', 16685 }; 16686 var strings$9 = { 16687 ARIA_CHECKED_ATTR: 'aria-checked', 16688 ARIA_CHECKED_INDETERMINATE_VALUE: 'mixed', 16689 DATA_INDETERMINATE_ATTR: 'data-indeterminate', 16690 NATIVE_CONTROL_SELECTOR: '.mdc-checkbox__native-control', 16691 TRANSITION_STATE_CHECKED: 'checked', 16692 TRANSITION_STATE_INDETERMINATE: 'indeterminate', 16693 TRANSITION_STATE_INIT: 'init', 16694 TRANSITION_STATE_UNCHECKED: 'unchecked', 16695 }; 16696 var numbers$1 = { 16697 ANIM_END_LATCH_MS: 250, 16698 }; 16699 16700 /** 16701 * @license 16702 * Copyright 2016 Google Inc. 16703 * 16704 * Permission is hereby granted, free of charge, to any person obtaining a copy 16705 * of this software and associated documentation files (the "Software"), to deal 16706 * in the Software without restriction, including without limitation the rights 16707 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16708 * copies of the Software, and to permit persons to whom the Software is 16709 * furnished to do so, subject to the following conditions: 16710 * 16711 * The above copyright notice and this permission notice shall be included in 16712 * all copies or substantial portions of the Software. 16713 * 16714 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16715 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16716 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16717 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16718 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16719 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16720 * THE SOFTWARE. 16721 */ 16722 var MDCCheckboxFoundation = /** @class */ (function (_super) { 16723 __extends(MDCCheckboxFoundation, _super); 16724 function MDCCheckboxFoundation(adapter) { 16725 var _this = _super.call(this, __assign(__assign({}, MDCCheckboxFoundation.defaultAdapter), adapter)) || this; 16726 _this.currentCheckState_ = strings$9.TRANSITION_STATE_INIT; 16727 _this.currentAnimationClass_ = ''; 16728 _this.animEndLatchTimer_ = 0; 16729 _this.enableAnimationEndHandler_ = false; 16730 return _this; 16731 } 16732 Object.defineProperty(MDCCheckboxFoundation, "cssClasses", { 16733 get: function () { 16734 return cssClasses$6; 16735 }, 16736 enumerable: true, 16737 configurable: true 16738 }); 16739 Object.defineProperty(MDCCheckboxFoundation, "strings", { 16740 get: function () { 16741 return strings$9; 16742 }, 16743 enumerable: true, 16744 configurable: true 16745 }); 16746 Object.defineProperty(MDCCheckboxFoundation, "numbers", { 16747 get: function () { 16748 return numbers$1; 16749 }, 16750 enumerable: true, 16751 configurable: true 16752 }); 16753 Object.defineProperty(MDCCheckboxFoundation, "defaultAdapter", { 16754 get: function () { 16755 return { 16756 addClass: function () { return undefined; }, 16757 forceLayout: function () { return undefined; }, 16758 hasNativeControl: function () { return false; }, 16759 isAttachedToDOM: function () { return false; }, 16760 isChecked: function () { return false; }, 16761 isIndeterminate: function () { return false; }, 16762 removeClass: function () { return undefined; }, 16763 removeNativeControlAttr: function () { return undefined; }, 16764 setNativeControlAttr: function () { return undefined; }, 16765 setNativeControlDisabled: function () { return undefined; }, 16766 }; 16767 }, 16768 enumerable: true, 16769 configurable: true 16770 }); 16771 MDCCheckboxFoundation.prototype.init = function () { 16772 this.currentCheckState_ = this.determineCheckState_(); 16773 this.updateAriaChecked_();
vendor: 12,303 bytes, lines 16774-17019
16774 this.adapter.addClass(cssClasses$6.UPGRADED); 16775 }; 16776 MDCCheckboxFoundation.prototype.destroy = function () { 16777 clearTimeout(this.animEndLatchTimer_); 16778 }; 16779 MDCCheckboxFoundation.prototype.setDisabled = function (disabled) { 16780 this.adapter.setNativeControlDisabled(disabled); 16781 if (disabled) { 16782 this.adapter.addClass(cssClasses$6.DISABLED); 16783 } 16784 else { 16785 this.adapter.removeClass(cssClasses$6.DISABLED); 16786 } 16787 }; 16788 /** 16789 * Handles the animationend event for the checkbox 16790 */ 16791 MDCCheckboxFoundation.prototype.handleAnimationEnd = function () { 16792 var _this = this; 16793 if (!this.enableAnimationEndHandler_) { 16794 return; 16795 } 16796 clearTimeout(this.animEndLatchTimer_); 16797 this.animEndLatchTimer_ = setTimeout(function () { 16798 _this.adapter.removeClass(_this.currentAnimationClass_); 16799 _this.enableAnimationEndHandler_ = false; 16800 }, numbers$1.ANIM_END_LATCH_MS); 16801 }; 16802 /** 16803 * Handles the change event for the checkbox 16804 */ 16805 MDCCheckboxFoundation.prototype.handleChange = function () { 16806 this.transitionCheckState_(); 16807 }; 16808 MDCCheckboxFoundation.prototype.transitionCheckState_ = function () { 16809 if (!this.adapter.hasNativeControl()) { 16810 return; 16811 } 16812 var oldState = this.currentCheckState_; 16813 var newState = this.determineCheckState_(); 16814 if (oldState === newState) { 16815 return; 16816 } 16817 this.updateAriaChecked_(); 16818 var TRANSITION_STATE_UNCHECKED = strings$9.TRANSITION_STATE_UNCHECKED; 16819 var SELECTED = cssClasses$6.SELECTED; 16820 if (newState === TRANSITION_STATE_UNCHECKED) { 16821 this.adapter.removeClass(SELECTED); 16822 } 16823 else { 16824 this.adapter.addClass(SELECTED); 16825 } 16826 // Check to ensure that there isn't a previously existing animation class, in case for example 16827 // the user interacted with the checkbox before the animation was finished. 16828 if (this.currentAnimationClass_.length > 0) { 16829 clearTimeout(this.animEndLatchTimer_); 16830 this.adapter.forceLayout(); 16831 this.adapter.removeClass(this.currentAnimationClass_); 16832 } 16833 this.currentAnimationClass_ = this.getTransitionAnimationClass_(oldState, newState); 16834 this.currentCheckState_ = newState; 16835 // Check for parentNode so that animations are only run when the element is attached 16836 // to the DOM. 16837 if (this.adapter.isAttachedToDOM() && 16838 this.currentAnimationClass_.length > 0) { 16839 this.adapter.addClass(this.currentAnimationClass_); 16840 this.enableAnimationEndHandler_ = true; 16841 } 16842 }; 16843 MDCCheckboxFoundation.prototype.determineCheckState_ = function () { 16844 var TRANSITION_STATE_INDETERMINATE = strings$9.TRANSITION_STATE_INDETERMINATE, TRANSITION_STATE_CHECKED = strings$9.TRANSITION_STATE_CHECKED, TRANSITION_STATE_UNCHECKED = strings$9.TRANSITION_STATE_UNCHECKED; 16845 if (this.adapter.isIndeterminate()) { 16846 return TRANSITION_STATE_INDETERMINATE; 16847 } 16848 return this.adapter.isChecked() ? TRANSITION_STATE_CHECKED : 16849 TRANSITION_STATE_UNCHECKED; 16850 }; 16851 MDCCheckboxFoundation.prototype.getTransitionAnimationClass_ = function (oldState, newState) { 16852 var TRANSITION_STATE_INIT = strings$9.TRANSITION_STATE_INIT, TRANSITION_STATE_CHECKED = strings$9.TRANSITION_STATE_CHECKED, TRANSITION_STATE_UNCHECKED = strings$9.TRANSITION_STATE_UNCHECKED; 16853 var _a = MDCCheckboxFoundation.cssClasses, ANIM_UNCHECKED_CHECKED = _a.ANIM_UNCHECKED_CHECKED, ANIM_UNCHECKED_INDETERMINATE = _a.ANIM_UNCHECKED_INDETERMINATE, ANIM_CHECKED_UNCHECKED = _a.ANIM_CHECKED_UNCHECKED, ANIM_CHECKED_INDETERMINATE = _a.ANIM_CHECKED_INDETERMINATE, ANIM_INDETERMINATE_CHECKED = _a.ANIM_INDETERMINATE_CHECKED, ANIM_INDETERMINATE_UNCHECKED = _a.ANIM_INDETERMINATE_UNCHECKED; 16854 switch (oldState) { 16855 case TRANSITION_STATE_INIT: 16856 if (newState === TRANSITION_STATE_UNCHECKED) { 16857 return ''; 16858 } 16859 return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED; 16860 case TRANSITION_STATE_UNCHECKED: 16861 return newState === TRANSITION_STATE_CHECKED ? ANIM_UNCHECKED_CHECKED : ANIM_UNCHECKED_INDETERMINATE; 16862 case TRANSITION_STATE_CHECKED: 16863 return newState === TRANSITION_STATE_UNCHECKED ? ANIM_CHECKED_UNCHECKED : ANIM_CHECKED_INDETERMINATE; 16864 default: // TRANSITION_STATE_INDETERMINATE 16865 return newState === TRANSITION_STATE_CHECKED ? ANIM_INDETERMINATE_CHECKED : ANIM_INDETERMINATE_UNCHECKED; 16866 } 16867 }; 16868 MDCCheckboxFoundation.prototype.updateAriaChecked_ = function () { 16869 // Ensure aria-checked is set to mixed if checkbox is in indeterminate state. 16870 if (this.adapter.isIndeterminate()) { 16871 this.adapter.setNativeControlAttr(strings$9.ARIA_CHECKED_ATTR, strings$9.ARIA_CHECKED_INDETERMINATE_VALUE); 16872 } 16873 else { 16874 // The on/off state does not need to keep track of aria-checked, since 16875 // the screenreader uses the checked property on the checkbox element. 16876 this.adapter.removeNativeControlAttr(strings$9.ARIA_CHECKED_ATTR); 16877 } 16878 }; 16879 return MDCCheckboxFoundation; 16880 }(MDCFoundation)); 16881 16882 /** 16883 * @license 16884 * Copyright 2016 Google Inc. 16885 * 16886 * Permission is hereby granted, free of charge, to any person obtaining a copy 16887 * of this software and associated documentation files (the "Software"), to deal 16888 * in the Software without restriction, including without limitation the rights 16889 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16890 * copies of the Software, and to permit persons to whom the Software is 16891 * furnished to do so, subject to the following conditions: 16892 * 16893 * The above copyright notice and this permission notice shall be included in 16894 * all copies or substantial portions of the Software. 16895 * 16896 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16897 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16898 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16899 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16900 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16901 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16902 * THE SOFTWARE. 16903 */ 16904 var CB_PROTO_PROPS = ['checked', 'indeterminate']; 16905 var MDCCheckbox = /** @class */ (function (_super) { 16906 __extends(MDCCheckbox, _super); 16907 function MDCCheckbox() { 16908 var _this = _super !== null && _super.apply(this, arguments) || this; 16909 _this.ripple_ = _this.createRipple_(); 16910 return _this; 16911 } 16912 MDCCheckbox.attachTo = function (root) { 16913 return new MDCCheckbox(root); 16914 }; 16915 Object.defineProperty(MDCCheckbox.prototype, "ripple", { 16916 get: function () { 16917 return this.ripple_; 16918 }, 16919 enumerable: true, 16920 configurable: true 16921 }); 16922 Object.defineProperty(MDCCheckbox.prototype, "checked", { 16923 get: function () { 16924 return this.nativeControl_.checked; 16925 }, 16926 set: function (checked) { 16927 this.nativeControl_.checked = checked; 16928 }, 16929 enumerable: true, 16930 configurable: true 16931 }); 16932 Object.defineProperty(MDCCheckbox.prototype, "indeterminate", { 16933 get: function () { 16934 return this.nativeControl_.indeterminate; 16935 }, 16936 set: function (indeterminate) { 16937 this.nativeControl_.indeterminate = indeterminate; 16938 }, 16939 enumerable: true, 16940 configurable: true 16941 }); 16942 Object.defineProperty(MDCCheckbox.prototype, "disabled", { 16943 get: function () { 16944 return this.nativeControl_.disabled; 16945 }, 16946 set: function (disabled) { 16947 this.foundation.setDisabled(disabled); 16948 }, 16949 enumerable: true, 16950 configurable: true 16951 }); 16952 Object.defineProperty(MDCCheckbox.prototype, "value", { 16953 get: function () { 16954 return this.nativeControl_.value; 16955 }, 16956 set: function (value) { 16957 this.nativeControl_.value = value; 16958 }, 16959 enumerable: true, 16960 configurable: true 16961 }); 16962 MDCCheckbox.prototype.initialize = function () { 16963 var DATA_INDETERMINATE_ATTR = strings$9.DATA_INDETERMINATE_ATTR; 16964 this.nativeControl_.indeterminate = 16965 this.nativeControl_.getAttribute(DATA_INDETERMINATE_ATTR) === 'true'; 16966 this.nativeControl_.removeAttribute(DATA_INDETERMINATE_ATTR); 16967 }; 16968 MDCCheckbox.prototype.initialSyncWithDOM = function () { 16969 var _this = this; 16970 this.handleChange_ = function () { return _this.foundation.handleChange(); }; 16971 this.handleAnimationEnd_ = function () { return _this.foundation.handleAnimationEnd(); }; 16972 this.nativeControl_.addEventListener('change', this.handleChange_); 16973 this.listen(getCorrectEventName(window, 'animationend'), this.handleAnimationEnd_); 16974 this.installPropertyChangeHooks_(); 16975 }; 16976 MDCCheckbox.prototype.destroy = function () { 16977 this.ripple_.destroy(); 16978 this.nativeControl_.removeEventListener('change', this.handleChange_); 16979 this.unlisten(getCorrectEventName(window, 'animationend'), this.handleAnimationEnd_); 16980 this.uninstallPropertyChangeHooks_(); 16981 _super.prototype.destroy.call(this); 16982 }; 16983 MDCCheckbox.prototype.getDefaultFoundation = function () { 16984 var _this = this; 16985 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 16986 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 16987 var adapter = { 16988 addClass: function (className) { return _this.root.classList.add(className); }, 16989 forceLayout: function () { return _this.root.offsetWidth; }, 16990 hasNativeControl: function () { return !!_this.nativeControl_; }, 16991 isAttachedToDOM: function () { return Boolean(_this.root.parentNode); }, 16992 isChecked: function () { return _this.checked; }, 16993 isIndeterminate: function () { return _this.indeterminate; }, 16994 removeClass: function (className) { 16995 _this.root.classList.remove(className); 16996 }, 16997 removeNativeControlAttr: function (attr) { 16998 _this.nativeControl_.removeAttribute(attr); 16999 }, 17000 setNativeControlAttr: function (attr, value) { 17001 _this.nativeControl_.setAttribute(attr, value); 17002 }, 17003 setNativeControlDisabled: function (disabled) { 17004 _this.nativeControl_.disabled = disabled; 17005 }, 17006 }; 17007 return new MDCCheckboxFoundation(adapter); 17008 }; 17009 MDCCheckbox.prototype.createRipple_ = function () { 17010 var _this = this; 17011 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 17012 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 17013 var adapter = __assign(__assign({}, MDCRipple.createAdapter(this)), { deregisterInteractionHandler: function (evtType, handler) { return _this.nativeControl_.removeEventListener(evtType, handler, applyPassive()); }, isSurfaceActive: function () { return matches$1(_this.nativeControl_, ':active'); }, isUnbounded: function () { return true; }, registerInteractionHandler: function (evtType, handler) { return _this.nativeControl_.addEventListener(evtType, handler, applyPassive()); } }); 17014 return new MDCRipple(this.root, new MDCRippleFoundation(adapter)); 17015 }; 17016 MDCCheckbox.prototype.installPropertyChangeHooks_ = function () { 17017 var _this = this; 17018 var nativeCb = this.nativeControl_; 17019 var cbProto = Object.getPrototypeOf(nativeCb);
17020 CB_PROTO_PROPS.forEach(function (controlState) { 17021 var desc = Object.getOwnPropertyDescriptor(cbProto, controlState); 17022 // We have to check for this descriptor, since some browsers (Safari) don't support its return. 17023 // See: https://bugs.webkit.org/show_bug.cgi?id=49739 17024 if (!validDescriptor(desc)) { 17025 return; 17026 } 17027 // Type cast is needed for compatibility with Closure Compiler. 17028 var nativeGetter = desc.get; 17029 var nativeCbDesc = { 17030 configurable: desc.configurable, 17031 enumerable: desc.enumerable, 17032 get: nativeGetter, 17033 set: function (state) { 17034 desc.set.call(nativeCb, state); 17035 _this.foundation.handleChange(); 17036 }, 17037 }; 17038 Object.defineProperty(nativeCb, controlState, nativeCbDesc); 17039 }); 17040 }; 17041 MDCCheckbox.prototype.uninstallPropertyChangeHooks_ = function () { 17042 var nativeCb = this.nativeControl_; 17043 var cbProto = Object.getPrototypeOf(nativeCb); 17044 CB_PROTO_PROPS.forEach(function (controlState) { 17045 var desc = Object.getOwnPropertyDescriptor(cbProto, controlState); 17046 if (!validDescriptor(desc)) { 17047 return; 17048 } 17049 Object.defineProperty(nativeCb, controlState, desc); 17050 }); 17051 }; 17052 Object.defineProperty(MDCCheckbox.prototype, "nativeControl_", { 17053 get: function () { 17054 var NATIVE_CONTROL_SELECTOR = strings$9.NATIVE_CONTROL_SELECTOR; 17055 var el = this.root.querySelector(NATIVE_CONTROL_SELECTOR); 17056 if (!el) { 17057 throw new Error("Checkbox component requires a " + NATIVE_CONTROL_SELECTOR + " element"); 17058 } 17059 return el; 17060 }, 17061 enumerable: true, 17062 configurable: true 17063 }); 17064 return MDCCheckbox; 17065 }(MDCComponent)); 17066 function validDescriptor(inputPropDesc) { 17067 return !!inputPropDesc && typeof inputPropDesc.set === 'function'; 17068 } 17069 17070 /** 17071 * @license 17072 * Copyright 2019 Google Inc. 17073 * 17074 * Permission is hereby granted, free of charge, to any person obtaining a copy 17075 * of this software and associated documentation files (the "Software"), to deal 17076 * in the Software without restriction, including without limitation the rights 17077 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17078 * copies of the Software, and to permit persons to whom the Software is 17079 * furnished to do so, subject to the following conditions: 17080 * 17081 * The above copyright notice and this permission notice shall be included in 17082 * all copies or substantial portions of the Software. 17083 * 17084 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17085 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17086 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17087 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17088 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17089 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17090 * THE SOFTWARE. 17091 */ 17092 17093 /** 17094 * @license 17095 * Copyright 2017 Google Inc. 17096 * 17097 * Permission is hereby granted, free of charge, to any person obtaining a copy 17098 * of this software and associated documentation files (the "Software"), to deal 17099 * in the Software without restriction, including without limitation the rights 17100 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17101 * copies of the Software, and to permit persons to whom the Software is 17102 * furnished to do so, subject to the following conditions: 17103 * 17104 * The above copyright notice and this permission notice shall be included in 17105 * all copies or substantial portions of the Software. 17106 * 17107 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17108 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17109 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17110 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17111 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17112 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17113 * THE SOFTWARE. 17114 */
vendor: 5,237 bytes, lines 17115-17234
17115 var cssClasses$5 = { 17116 CLOSED_CLASS: 'mdc-linear-progress--closed', 17117 CLOSED_ANIMATION_OFF_CLASS: 'mdc-linear-progress--closed-animation-off', 17118 INDETERMINATE_CLASS: 'mdc-linear-progress--indeterminate', 17119 REVERSED_CLASS: 'mdc-linear-progress--reversed', 17120 ANIMATION_READY_CLASS: 'mdc-linear-progress--animation-ready', 17121 }; 17122 var strings$8 = { 17123 ARIA_VALUEMAX: 'aria-valuemax', 17124 ARIA_VALUEMIN: 'aria-valuemin', 17125 ARIA_VALUENOW: 'aria-valuenow', 17126 BUFFER_BAR_SELECTOR: '.mdc-linear-progress__buffer-bar', 17127 FLEX_BASIS: 'flex-basis', 17128 PRIMARY_BAR_SELECTOR: '.mdc-linear-progress__primary-bar', 17129 }; 17130 // these are percentages pulled from keyframes.scss 17131 var animationDimensionPercentages = { 17132 PRIMARY_HALF: .8367142, 17133 PRIMARY_FULL: 2.00611057, 17134 SECONDARY_QUARTER: .37651913, 17135 SECONDARY_HALF: .84386165, 17136 SECONDARY_FULL: 1.60277782, 17137 }; 17138 17139 /** 17140 * @license 17141 * Copyright 2017 Google Inc. 17142 * 17143 * Permission is hereby granted, free of charge, to any person obtaining a copy 17144 * of this software and associated documentation files (the "Software"), to deal 17145 * in the Software without restriction, including without limitation the rights 17146 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17147 * copies of the Software, and to permit persons to whom the Software is 17148 * furnished to do so, subject to the following conditions: 17149 * 17150 * The above copyright notice and this permission notice shall be included in 17151 * all copies or substantial portions of the Software. 17152 * 17153 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17154 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17155 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17156 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17157 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17158 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17159 * THE SOFTWARE. 17160 */ 17161 var MDCLinearProgressFoundation = /** @class */ (function (_super) { 17162 __extends(MDCLinearProgressFoundation, _super); 17163 function MDCLinearProgressFoundation(adapter) { 17164 var _this = _super.call(this, __assign(__assign({}, MDCLinearProgressFoundation.defaultAdapter), adapter)) || this; 17165 _this.observer = null; 17166 return _this; 17167 } 17168 Object.defineProperty(MDCLinearProgressFoundation, "cssClasses", { 17169 get: function () { 17170 return cssClasses$5; 17171 }, 17172 enumerable: true, 17173 configurable: true 17174 }); 17175 Object.defineProperty(MDCLinearProgressFoundation, "strings", { 17176 get: function () { 17177 return strings$8; 17178 }, 17179 enumerable: true, 17180 configurable: true 17181 }); 17182 Object.defineProperty(MDCLinearProgressFoundation, "defaultAdapter", { 17183 get: function () { 17184 return { 17185 addClass: function () { return undefined; }, 17186 attachResizeObserver: function () { return null; }, 17187 forceLayout: function () { return undefined; }, 17188 getWidth: function () { return 0; }, 17189 hasClass: function () { return false; }, 17190 setBufferBarStyle: function () { return null; }, 17191 setPrimaryBarStyle: function () { return null; }, 17192 setStyle: function () { return undefined; }, 17193 removeAttribute: function () { return undefined; }, 17194 removeClass: function () { return undefined; }, 17195 setAttribute: function () { return undefined; }, 17196 }; 17197 }, 17198 enumerable: true, 17199 configurable: true 17200 }); 17201 MDCLinearProgressFoundation.prototype.init = function () { 17202 var _this = this; 17203 this.isDeterminate = !this.adapter.hasClass(cssClasses$5.INDETERMINATE_CLASS); 17204 this.adapter.addClass(cssClasses$5.ANIMATION_READY_CLASS); 17205 this.progress = 0; 17206 this.buffer = 1; 17207 this.observer = this.adapter.attachResizeObserver(function (entries) { 17208 var e_1, _a; 17209 if (_this.isDeterminate) { 17210 return; 17211 } 17212 try { 17213 for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) { 17214 var entry = entries_1_1.value; 17215 if (entry.contentRect) { 17216 _this.calculateAndSetDimensions(entry.contentRect.width); 17217 } 17218 } 17219 } 17220 catch (e_1_1) { e_1 = { error: e_1_1 }; } 17221 finally { 17222 try { 17223 if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1); 17224 } 17225 finally { if (e_1) throw e_1.error; } 17226 } 17227 }); 17228 if (!this.isDeterminate && this.observer) { 17229 this.calculateAndSetDimensions(this.adapter.getWidth()); 17230 } 17231 }; 17232 MDCLinearProgressFoundation.prototype.setDeterminate = function (isDeterminate) { 17233 this.isDeterminate = isDeterminate; 17234 if (this.isDeterminate) {
17235 this.adapter.removeClass(cssClasses$5.INDETERMINATE_CLASS); 17236 this.adapter.setAttribute(strings$8.ARIA_VALUENOW, this.progress.toString()); 17237 this.adapter.setAttribute(strings$8.ARIA_VALUEMAX, '1'); 17238 this.adapter.setAttribute(strings$8.ARIA_VALUEMIN, '0'); 17239 this.setPrimaryBarProgress(this.progress); 17240 this.setBufferBarProgress(this.buffer); 17241 return; 17242 } 17243 if (this.observer) { 17244 this.calculateAndSetDimensions(this.adapter.getWidth()); 17245 } 17246 this.adapter.addClass(cssClasses$5.INDETERMINATE_CLASS); 17247 this.adapter.removeAttribute(strings$8.ARIA_VALUENOW); 17248 this.adapter.removeAttribute(strings$8.ARIA_VALUEMAX); 17249 this.adapter.removeAttribute(strings$8.ARIA_VALUEMIN); 17250 this.setPrimaryBarProgress(1); 17251 this.setBufferBarProgress(1); 17252 }; 17253 MDCLinearProgressFoundation.prototype.getDeterminate = function () { 17254 return this.isDeterminate; 17255 }; 17256 MDCLinearProgressFoundation.prototype.setProgress = function (value) { 17257 this.progress = value; 17258 if (this.isDeterminate) { 17259 this.setPrimaryBarProgress(value); 17260 this.adapter.setAttribute(strings$8.ARIA_VALUENOW, value.toString()); 17261 } 17262 }; 17263 MDCLinearProgressFoundation.prototype.getProgress = function () { 17264 return this.progress; 17265 }; 17266 MDCLinearProgressFoundation.prototype.setBuffer = function (value) { 17267 this.buffer = value; 17268 if (this.isDeterminate) { 17269 this.setBufferBarProgress(value); 17270 } 17271 }; 17272 MDCLinearProgressFoundation.prototype.open = function () { 17273 this.adapter.removeClass(cssClasses$5.CLOSED_CLASS); 17274 this.adapter.removeClass(cssClasses$5.CLOSED_ANIMATION_OFF_CLASS); 17275 }; 17276 MDCLinearProgressFoundation.prototype.close = function () { 17277 this.adapter.addClass(cssClasses$5.CLOSED_CLASS); 17278 }; 17279 /** 17280 * Handles the transitionend event emitted after `close()` is called and the 17281 * opacity fades out. This is so that animations are removed only after the 17282 * progress indicator is completely hidden. 17283 */ 17284 MDCLinearProgressFoundation.prototype.handleTransitionEnd = function () { 17285 if (this.adapter.hasClass(cssClasses$5.CLOSED_CLASS)) { 17286 this.adapter.addClass(cssClasses$5.CLOSED_ANIMATION_OFF_CLASS); 17287 } 17288 }; 17289 MDCLinearProgressFoundation.prototype.destroy = function () { 17290 _super.prototype.destroy.call(this); 17291 if (this.observer) { 17292 this.observer.disconnect(); 17293 } 17294 }; 17295 MDCLinearProgressFoundation.prototype.restartAnimation = function () { 17296 this.adapter.removeClass(cssClasses$5.ANIMATION_READY_CLASS); 17297 this.adapter.forceLayout(); 17298 this.adapter.addClass(cssClasses$5.ANIMATION_READY_CLASS); 17299 }; 17300 MDCLinearProgressFoundation.prototype.setPrimaryBarProgress = function (progressValue) { 17301 var value = "scaleX(" + progressValue + ")"; 17302 // Accessing `window` without a `typeof` check will throw on Node 17303 // environments. 17304 var transformProp = typeof window !== 'undefined' ? 17305 getCorrectPropertyName(window, 'transform') : 17306 'transform'; 17307 this.adapter.setPrimaryBarStyle(transformProp, value); 17308 }; 17309 MDCLinearProgressFoundation.prototype.setBufferBarProgress = function (progressValue) { 17310 var value = progressValue * 100 + "%"; 17311 this.adapter.setBufferBarStyle(strings$8.FLEX_BASIS, value); 17312 }; 17313 MDCLinearProgressFoundation.prototype.calculateAndSetDimensions = function (width) { 17314 var primaryHalf = width * animationDimensionPercentages.PRIMARY_HALF; 17315 var primaryFull = width * animationDimensionPercentages.PRIMARY_FULL; 17316 var secondaryQuarter = width * animationDimensionPercentages.SECONDARY_QUARTER; 17317 var secondaryHalf = width * animationDimensionPercentages.SECONDARY_HALF; 17318 var secondaryFull = width * animationDimensionPercentages.SECONDARY_FULL; 17319 this.adapter.setStyle('--mdc-linear-progress-primary-half', primaryHalf + "px"); 17320 this.adapter.setStyle('--mdc-linear-progress-primary-half-neg', -primaryHalf + "px"); 17321 this.adapter.setStyle('--mdc-linear-progress-primary-full', primaryFull + "px"); 17322 this.adapter.setStyle('--mdc-linear-progress-primary-full-neg', -primaryFull + "px"); 17323 this.adapter.setStyle('--mdc-linear-progress-secondary-quarter', secondaryQuarter + "px"); 17324 this.adapter.setStyle('--mdc-linear-progress-secondary-quarter-neg', -secondaryQuarter + "px"); 17325 this.adapter.setStyle('--mdc-linear-progress-secondary-half', secondaryHalf + "px"); 17326 this.adapter.setStyle('--mdc-linear-progress-secondary-half-neg', -secondaryHalf + "px"); 17327 this.adapter.setStyle('--mdc-linear-progress-secondary-full', secondaryFull + "px"); 17328 this.adapter.setStyle('--mdc-linear-progress-secondary-full-neg', -secondaryFull + "px"); 17329 // need to restart animation for custom props to apply to keyframes 17330 this.restartAnimation(); 17331 }; 17332 return MDCLinearProgressFoundation; 17333 }(MDCFoundation)); 17334 17335 /** 17336 * @license 17337 * Copyright 2017 Google Inc. 17338 * 17339 * Permission is hereby granted, free of charge, to any person obtaining a copy 17340 * of this software and associated documentation files (the "Software"), to deal 17341 * in the Software without restriction, including without limitation the rights 17342 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17343 * copies of the Software, and to permit persons to whom the Software is 17344 * furnished to do so, subject to the following conditions: 17345 * 17346 * The above copyright notice and this permission notice shall be included in 17347 * all copies or substantial portions of the Software. 17348 * 17349 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17350 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17351 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17352 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17353 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17354 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17355 * THE SOFTWARE. 17356 */ 17357 var MDCLinearProgress = /** @class */ (function (_super) { 17358 __extends(MDCLinearProgress, _super); 17359 function MDCLinearProgress() { 17360 return _super !== null && _super.apply(this, arguments) || this; 17361 } 17362 MDCLinearProgress.attachTo = function (root) { 17363 return new MDCLinearProgress(root); 17364 }; 17365 Object.defineProperty(MDCLinearProgress.prototype, "determinate", { 17366 set: function (value) { 17367 this.foundation.setDeterminate(value); 17368 }, 17369 enumerable: true, 17370 configurable: true 17371 }); 17372 Object.defineProperty(MDCLinearProgress.prototype, "progress", { 17373 set: function (value) { 17374 this.foundation.setProgress(value); 17375 }, 17376 enumerable: true, 17377 configurable: true 17378 }); 17379 Object.defineProperty(MDCLinearProgress.prototype, "buffer", { 17380 set: function (value) { 17381 this.foundation.setBuffer(value); 17382 }, 17383 enumerable: true, 17384 configurable: true 17385 }); 17386 MDCLinearProgress.prototype.open = function () { 17387 this.foundation.open(); 17388 }; 17389 MDCLinearProgress.prototype.close = function () { 17390 this.foundation.close(); 17391 }; 17392 MDCLinearProgress.prototype.initialSyncWithDOM = function () { 17393 var _this = this; 17394 this.root.addEventListener('transitionend', function () { 17395 _this.foundation.handleTransitionEnd(); 17396 }); 17397 }; 17398 MDCLinearProgress.prototype.getDefaultFoundation = function () { 17399 var _this = this; 17400 // DO NOT INLINE this variable. For backward compatibility, foundations take 17401 // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any 17402 // methods, we need a separate, strongly typed adapter variable. 17403 var adapter = { 17404 addClass: function (className) { 17405 _this.root.classList.add(className); 17406 }, 17407 forceLayout: function () { 17408 _this.root.getBoundingClientRect(); 17409 }, 17410 setBufferBarStyle: function (styleProperty, value) { 17411 var bufferBar = _this.root.querySelector(MDCLinearProgressFoundation.strings.BUFFER_BAR_SELECTOR); 17412 if (bufferBar) { 17413 bufferBar.style.setProperty(styleProperty, value); 17414 } 17415 }, 17416 setPrimaryBarStyle: function (styleProperty, value) { 17417 var primaryBar = _this.root.querySelector(MDCLinearProgressFoundation.strings.PRIMARY_BAR_SELECTOR); 17418 if (primaryBar) { 17419 primaryBar.style.setProperty(styleProperty, value); 17420 } 17421 }, 17422 hasClass: function (className) { return _this.root.classList.contains(className); }, 17423 removeAttribute: function (attributeName) { 17424 _this.root.removeAttribute(attributeName); 17425 }, 17426 removeClass: function (className) { 17427 _this.root.classList.remove(className); 17428 }, 17429 setAttribute: function (attributeName, value) { 17430 _this.root.setAttribute(attributeName, value); 17431 }, 17432 setStyle: function (name, value) { 17433 _this.root.style.setProperty(name, value); 17434 }, 17435 attachResizeObserver: function (callback) { 17436 var RO = window.ResizeObserver; 17437 if (RO) { 17438 var ro = new RO(callback); 17439 ro.observe(_this.root); 17440 return ro; 17441 } 17442 return null; 17443 }, 17444 getWidth: function () { return _this.root.offsetWidth; }, 17445 }; 17446 return new MDCLinearProgressFoundation(adapter); 17447 }; 17448 return MDCLinearProgress; 17449 }(MDCComponent)); 17450 17451 /** 17452 * @license 17453 * Copyright 2019 Google Inc. 17454 * 17455 * Permission is hereby granted, free of charge, to any person obtaining a copy 17456 * of this software and associated documentation files (the "Software"), to deal 17457 * in the Software without restriction, including without limitation the rights 17458 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17459 * copies of the Software, and to permit persons to whom the Software is 17460 * furnished to do so, subject to the following conditions: 17461 * 17462 * The above copyright notice and this permission notice shall be included in 17463 * all copies or substantial portions of the Software. 17464 * 17465 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17466 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17467 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17468 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17469 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17470 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17471 * THE SOFTWARE. 17472 */ 17473 17474 /** 17475 * @license 17476 * Copyright 2020 Google Inc. 17477 * 17478 * Permission is hereby granted, free of charge, to any person obtaining a copy 17479 * of this software and associated documentation files (the "Software"), to deal 17480 * in the Software without restriction, including without limitation the rights 17481 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17482 * copies of the Software, and to permit persons to whom the Software is 17483 * furnished to do so, subject to the following conditions: 17484 * 17485 * The above copyright notice and this permission notice shall be included in 17486 * all copies or substantial portions of the Software. 17487 * 17488 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17489 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17490 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17491 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17492 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17493 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17494 * THE SOFTWARE. 17495 */ 17496 var InteractionTrigger; 17497 (function (InteractionTrigger) { 17498 InteractionTrigger[InteractionTrigger["UNSPECIFIED"] = 0] = "UNSPECIFIED"; 17499 InteractionTrigger[InteractionTrigger["CLICK"] = 1] = "CLICK"; 17500 InteractionTrigger[InteractionTrigger["BACKSPACE_KEY"] = 2] = "BACKSPACE_KEY"; 17501 InteractionTrigger[InteractionTrigger["DELETE_KEY"] = 3] = "DELETE_KEY"; 17502 InteractionTrigger[InteractionTrigger["SPACEBAR_KEY"] = 4] = "SPACEBAR_KEY"; 17503 InteractionTrigger[InteractionTrigger["ENTER_KEY"] = 5] = "ENTER_KEY"; 17504 })(InteractionTrigger || (InteractionTrigger = {})); 17505 var strings$7 = { 17506 ARIA_HIDDEN: 'aria-hidden', 17507 INTERACTION_EVENT: 'MDCChipTrailingAction:interaction', 17508 NAVIGATION_EVENT: 'MDCChipTrailingAction:navigation', 17509 TAB_INDEX: 'tabindex', 17510 }; 17511 17512 /** 17513 * @license 17514 * Copyright 2020 Google Inc. 17515 * 17516 * Permission is hereby granted, free of charge, to any person obtaining a copy 17517 * of this software and associated documentation files (the "Software"), to deal 17518 * in the Software without restriction, including without limitation the rights 17519 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17520 * copies of the Software, and to permit persons to whom the Software is 17521 * furnished to do so, subject to the following conditions: 17522 * 17523 * The above copyright notice and this permission notice shall be included in 17524 * all copies or substantial portions of the Software. 17525 * 17526 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17527 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17528 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17529 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17530 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17531 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17532 * THE SOFTWARE. 17533 */ 17534 var MDCChipTrailingActionFoundation = /** @class */ (function (_super) { 17535 __extends(MDCChipTrailingActionFoundation, _super); 17536 function MDCChipTrailingActionFoundation(adapter) { 17537 return _super.call(this, __assign(__assign({}, MDCChipTrailingActionFoundation.defaultAdapter), adapter)) || this; 17538 } 17539 Object.defineProperty(MDCChipTrailingActionFoundation, "strings", { 17540 get: function () { 17541 return strings$7; 17542 }, 17543 enumerable: true, 17544 configurable: true 17545 }); 17546 Object.defineProperty(MDCChipTrailingActionFoundation, "defaultAdapter", { 17547 get: function () { 17548 return { 17549 focus: function () { return undefined; }, 17550 getAttribute: function () { return null; }, 17551 setAttribute: function () { return undefined; }, 17552 notifyInteraction: function () { return undefined; }, 17553 notifyNavigation: function () { return undefined; }, 17554 }; 17555 }, 17556 enumerable: true, 17557 configurable: true 17558 }); 17559 MDCChipTrailingActionFoundation.prototype.handleClick = function (evt) { 17560 evt.stopPropagation(); 17561 this.adapter.notifyInteraction(InteractionTrigger.CLICK); 17562 }; 17563 MDCChipTrailingActionFoundation.prototype.handleKeydown = function (evt) { 17564 evt.stopPropagation(); 17565 var key = normalizeKey(evt); 17566 if (this.shouldNotifyInteractionFromKey_(key)) { 17567 var trigger = this.getTriggerFromKey_(key); 17568 this.adapter.notifyInteraction(trigger); 17569 return; 17570 } 17571 if (isNavigationEvent(evt)) { 17572 this.adapter.notifyNavigation(key); 17573 return; 17574 } 17575 }; 17576 MDCChipTrailingActionFoundation.prototype.removeFocus = function () { 17577 this.adapter.setAttribute(strings$7.TAB_INDEX, '-1'); 17578 };
17579 MDCChipTrailingActionFoundation.prototype.focus = function () { 17580 this.adapter.setAttribute(strings$7.TAB_INDEX, '0'); 17581 this.adapter.focus(); 17582 }; 17583 MDCChipTrailingActionFoundation.prototype.isNavigable = function () { 17584 return this.adapter.getAttribute(strings$7.ARIA_HIDDEN) !== 'true'; 17585 }; 17586 MDCChipTrailingActionFoundation.prototype.shouldNotifyInteractionFromKey_ = function (key) { 17587 var isFromActionKey = key === KEY.ENTER || key === KEY.SPACEBAR; 17588 var isFromDeleteKey = key === KEY.BACKSPACE || key === KEY.DELETE; 17589 return isFromActionKey || isFromDeleteKey; 17590 }; 17591 MDCChipTrailingActionFoundation.prototype.getTriggerFromKey_ = function (key) { 17592 if (key === KEY.SPACEBAR) { 17593 return InteractionTrigger.SPACEBAR_KEY; 17594 } 17595 if (key === KEY.ENTER) { 17596 return InteractionTrigger.ENTER_KEY; 17597 } 17598 if (key === KEY.DELETE) { 17599 return InteractionTrigger.DELETE_KEY; 17600 } 17601 if (key === KEY.BACKSPACE) { 17602 return InteractionTrigger.BACKSPACE_KEY; 17603 } 17604 // Default case, should never be returned 17605 return InteractionTrigger.UNSPECIFIED; 17606 }; 17607 return MDCChipTrailingActionFoundation; 17608 }(MDCFoundation)); 17609 17610 /** 17611 * @license 17612 * Copyright 2020 Google Inc. 17613 * 17614 * Permission is hereby granted, free of charge, to any person obtaining a copy 17615 * of this software and associated documentation files (the "Software"), to deal 17616 * in the Software without restriction, including without limitation the rights 17617 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17618 * copies of the Software, and to permit persons to whom the Software is 17619 * furnished to do so, subject to the following conditions: 17620 * 17621 * The above copyright notice and this permission notice shall be included in 17622 * all copies or substantial portions of the Software. 17623 * 17624 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17625 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17626 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17627 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17628 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17629 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17630 * THE SOFTWARE. 17631 */ 17632 var MDCChipTrailingAction = /** @class */ (function (_super) { 17633 __extends(MDCChipTrailingAction, _super); 17634 function MDCChipTrailingAction() { 17635 return _super !== null && _super.apply(this, arguments) || this; 17636 } 17637 Object.defineProperty(MDCChipTrailingAction.prototype, "ripple", { 17638 get: function () { 17639 return this.ripple_; 17640 }, 17641 enumerable: true, 17642 configurable: true 17643 }); 17644 MDCChipTrailingAction.attachTo = function (root) { 17645 return new MDCChipTrailingAction(root); 17646 }; 17647 MDCChipTrailingAction.prototype.initialize = function (rippleFactory) { 17648 if (rippleFactory === void 0) { rippleFactory = function (el, foundation) { 17649 return new MDCRipple(el, foundation); 17650 }; } 17651 // DO NOT INLINE this variable. For backward compatibility, foundations take 17652 // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any 17653 // methods, we need a separate, strongly typed adapter variable. 17654 var rippleAdapter = MDCRipple.createAdapter(this); 17655 this.ripple_ = 17656 rippleFactory(this.root, new MDCRippleFoundation(rippleAdapter)); 17657 }; 17658 MDCChipTrailingAction.prototype.initialSyncWithDOM = function () { 17659 var _this = this; 17660 this.handleClick_ = function (evt) { 17661 _this.foundation.handleClick(evt); 17662 }; 17663 this.handleKeydown_ = function (evt) { 17664 _this.foundation.handleKeydown(evt); 17665 }; 17666 this.listen('click', this.handleClick_); 17667 this.listen('keydown', this.handleKeydown_); 17668 }; 17669 MDCChipTrailingAction.prototype.destroy = function () { 17670 this.ripple_.destroy(); 17671 this.unlisten('click', this.handleClick_); 17672 this.unlisten('keydown', this.handleKeydown_); 17673 _super.prototype.destroy.call(this); 17674 }; 17675 MDCChipTrailingAction.prototype.getDefaultFoundation = function () { 17676 var _this = this; 17677 // DO NOT INLINE this variable. For backward compatibility, foundations take 17678 // a Partial<MDCFooAdapter>. To ensure we don't accidentally omit any 17679 // methods, we need a separate, strongly typed adapter variable. 17680 var adapter = { 17681 focus: function () { 17682 // TODO(b/157231863): Migate MDCComponent#root to HTMLElement 17683 _this.root.focus(); 17684 }, 17685 getAttribute: function (attr) { return _this.root.getAttribute(attr); }, 17686 notifyInteraction: function (trigger) {
17687 return _this.emit(strings$7.INTERACTION_EVENT, { trigger: trigger }, true /* shouldBubble */); 17688 }, 17689 notifyNavigation: function (key) { 17690 _this.emit(strings$7.NAVIGATION_EVENT, { key: key }, true /* shouldBubble */); 17691 }, 17692 setAttribute: function (attr, value) { 17693 _this.root.setAttribute(attr, value); 17694 }, 17695 }; 17696 return new MDCChipTrailingActionFoundation(adapter); 17697 }; 17698 MDCChipTrailingAction.prototype.isNavigable = function () { 17699 return this.foundation.isNavigable(); 17700 }; 17701 MDCChipTrailingAction.prototype.focus = function () { 17702 this.foundation.focus(); 17703 }; 17704 MDCChipTrailingAction.prototype.removeFocus = function () { 17705 this.foundation.removeFocus(); 17706 }; 17707 return MDCChipTrailingAction; 17708 }(MDCComponent)); 17709 17710 /** 17711 * @license 17712 * Copyright 2020 Google Inc. 17713 * 17714 * Permission is hereby granted, free of charge, to any person obtaining a copy 17715 * of this software and associated documentation files (the "Software"), to deal 17716 * in the Software without restriction, including without limitation the rights 17717 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17718 * copies of the Software, and to permit persons to whom the Software is 17719 * furnished to do so, subject to the following conditions: 17720 * 17721 * The above copyright notice and this permission notice shall be included in 17722 * all copies or substantial portions of the Software. 17723 * 17724 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17725 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17726 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17727 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17728 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17729 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17730 * THE SOFTWARE. 17731 */ 17732 17733 /** 17734 * @license 17735 * Copyright 2016 Google Inc. 17736 * 17737 * Permission is hereby granted, free of charge, to any person obtaining a copy 17738 * of this software and associated documentation files (the "Software"), to deal 17739 * in the Software without restriction, including without limitation the rights 17740 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17741 * copies of the Software, and to permit persons to whom the Software is 17742 * furnished to do so, subject to the following conditions: 17743 * 17744 * The above copyright notice and this permission notice shall be included in 17745 * all copies or substantial portions of the Software. 17746 * 17747 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17748 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17749 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17750 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17751 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17752 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17753 * THE SOFTWARE. 17754 */ 17755 var Direction; 17756 (function (Direction) { 17757 Direction["LEFT"] = "left"; 17758 Direction["RIGHT"] = "right"; 17759 })(Direction || (Direction = {})); 17760 var EventSource; 17761 (function (EventSource) { 17762 EventSource["PRIMARY"] = "primary"; 17763 EventSource["TRAILING"] = "trailing"; 17764 EventSource["NONE"] = "none"; 17765 })(EventSource || (EventSource = {})); 17766 var strings$6 = { 17767 ADDED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-added-announcement', 17768 ARIA_CHECKED: 'aria-checked', 17769 ARROW_DOWN_KEY: 'ArrowDown', 17770 ARROW_LEFT_KEY: 'ArrowLeft', 17771 ARROW_RIGHT_KEY: 'ArrowRight', 17772 ARROW_UP_KEY: 'ArrowUp', 17773 BACKSPACE_KEY: 'Backspace', 17774 CHECKMARK_SELECTOR: '.mdc-chip__checkmark', 17775 DELETE_KEY: 'Delete', 17776 END_KEY: 'End', 17777 ENTER_KEY: 'Enter', 17778 ENTRY_ANIMATION_NAME: 'mdc-chip-entry', 17779 HOME_KEY: 'Home', 17780 IE_ARROW_DOWN_KEY: 'Down', 17781 IE_ARROW_LEFT_KEY: 'Left', 17782 IE_ARROW_RIGHT_KEY: 'Right', 17783 IE_ARROW_UP_KEY: 'Up', 17784 IE_DELETE_KEY: 'Del', 17785 INTERACTION_EVENT: 'MDCChip:interaction', 17786 LEADING_ICON_SELECTOR: '.mdc-chip__icon--leading', 17787 NAVIGATION_EVENT: 'MDCChip:navigation', 17788 PRIMARY_ACTION_SELECTOR: '.mdc-chip__primary-action', 17789 REMOVED_ANNOUNCEMENT_ATTRIBUTE: 'data-mdc-chip-removed-announcement', 17790 REMOVAL_EVENT: 'MDCChip:removal', 17791 SELECTION_EVENT: 'MDCChip:selection', 17792 SPACEBAR_KEY: ' ', 17793 TAB_INDEX: 'tabindex', 17794 TRAILING_ACTION_SELECTOR: '.mdc-chip-trailing-action', 17795 TRAILING_ICON_INTERACTION_EVENT: 'MDCChip:trailingIconInteraction', 17796 TRAILING_ICON_SELECTOR: '.mdc-chip__icon--trailing', 17797 };
17798 var cssClasses$4 = { 17799 CHECKMARK: 'mdc-chip__checkmark', 17800 CHIP_EXIT: 'mdc-chip--exit', 17801 DELETABLE: 'mdc-chip--deletable', 17802 EDITABLE: 'mdc-chip--editable', 17803 EDITING: 'mdc-chip--editing', 17804 HIDDEN_LEADING_ICON: 'mdc-chip__icon--leading-hidden', 17805 LEADING_ICON: 'mdc-chip__icon--leading', 17806 PRIMARY_ACTION: 'mdc-chip__primary-action', 17807 PRIMARY_ACTION_FOCUSED: 'mdc-chip--primary-action-focused', 17808 SELECTED: 'mdc-chip--selected', 17809 TEXT: 'mdc-chip__text', 17810 TRAILING_ACTION: 'mdc-chip__trailing-action', 17811 TRAILING_ICON: 'mdc-chip__icon--trailing', 17812 }; 17813 var navigationKeys = new Set(); 17814 // IE11 has no support for new Set with iterable so we need to initialize this by hand 17815 navigationKeys.add(strings$6.ARROW_LEFT_KEY); 17816 navigationKeys.add(strings$6.ARROW_RIGHT_KEY); 17817 navigationKeys.add(strings$6.ARROW_DOWN_KEY); 17818 navigationKeys.add(strings$6.ARROW_UP_KEY); 17819 navigationKeys.add(strings$6.END_KEY); 17820 navigationKeys.add(strings$6.HOME_KEY); 17821 navigationKeys.add(strings$6.IE_ARROW_LEFT_KEY); 17822 navigationKeys.add(strings$6.IE_ARROW_RIGHT_KEY); 17823 navigationKeys.add(strings$6.IE_ARROW_DOWN_KEY); 17824 navigationKeys.add(strings$6.IE_ARROW_UP_KEY); 17825 var jumpChipKeys = new Set(); 17826 // IE11 has no support for new Set with iterable so we need to initialize this by hand 17827 jumpChipKeys.add(strings$6.ARROW_UP_KEY); 17828 jumpChipKeys.add(strings$6.ARROW_DOWN_KEY); 17829 jumpChipKeys.add(strings$6.HOME_KEY); 17830 jumpChipKeys.add(strings$6.END_KEY); 17831 jumpChipKeys.add(strings$6.IE_ARROW_UP_KEY); 17832 jumpChipKeys.add(strings$6.IE_ARROW_DOWN_KEY); 17833 17834 /** 17835 * @license 17836 * Copyright 2016 Google Inc. 17837 * 17838 * Permission is hereby granted, free of charge, to any person obtaining a copy 17839 * of this software and associated documentation files (the "Software"), to deal 17840 * in the Software without restriction, including without limitation the rights 17841 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17842 * copies of the Software, and to permit persons to whom the Software is 17843 * furnished to do so, subject to the following conditions: 17844 * 17845 * The above copyright notice and this permission notice shall be included in 17846 * all copies or substantial portions of the Software. 17847 * 17848 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17849 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17850 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17851 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17852 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 17853 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17854 * THE SOFTWARE. 17855 */ 17856 var emptyClientRect = { 17857 bottom: 0, 17858 height: 0, 17859 left: 0, 17860 right: 0, 17861 top: 0, 17862 width: 0, 17863 }; 17864 var FocusBehavior; 17865 (function (FocusBehavior) { 17866 FocusBehavior[FocusBehavior["SHOULD_FOCUS"] = 0] = "SHOULD_FOCUS"; 17867 FocusBehavior[FocusBehavior["SHOULD_NOT_FOCUS"] = 1] = "SHOULD_NOT_FOCUS"; 17868 })(FocusBehavior || (FocusBehavior = {})); 17869 var MDCChipFoundation = /** @class */ (function (_super) { 17870 __extends(MDCChipFoundation, _super); 17871 function MDCChipFoundation(adapter) { 17872 var _this = _super.call(this, __assign(__assign({}, MDCChipFoundation.defaultAdapter), adapter)) || this; 17873 /** Whether a trailing icon click should immediately trigger exit/removal of the chip. */ 17874 _this.shouldRemoveOnTrailingIconClick_ = true; 17875 /** 17876 * Whether the primary action should receive focus on click. Should only be 17877 * set to true for clients who programmatically give focus to a different 17878 * element on the page when a chip is clicked (like a menu). 17879 */ 17880 _this.shouldFocusPrimaryActionOnClick_ = true; 17881 return _this; 17882 } 17883 Object.defineProperty(MDCChipFoundation, "strings", { 17884 get: function () { 17885 return strings$6; 17886 }, 17887 enumerable: true, 17888 configurable: true 17889 }); 17890 Object.defineProperty(MDCChipFoundation, "cssClasses", { 17891 get: function () {
17892 return cssClasses$4; 17893 }, 17894 enumerable: true, 17895 configurable: true 17896 }); 17897 Object.defineProperty(MDCChipFoundation, "defaultAdapter", { 17898 get: function () { 17899 return { 17900 addClass: function () { return undefined; }, 17901 addClassToLeadingIcon: function () { return undefined; }, 17902 eventTargetHasClass: function () { return false; }, 17903 focusPrimaryAction: function () { return undefined; }, 17904 focusTrailingAction: function () { return undefined; }, 17905 getAttribute: function () { return null; }, 17906 getCheckmarkBoundingClientRect: function () { return emptyClientRect; }, 17907 getComputedStyleValue: function () { return ''; }, 17908 getRootBoundingClientRect: function () { return emptyClientRect; }, 17909 hasClass: function () { return false; }, 17910 hasLeadingIcon: function () { return false; }, 17911 isRTL: function () { return false; }, 17912 isTrailingActionNavigable: function () { return false; }, 17913 notifyEditFinish: function () { return undefined; }, 17914 notifyEditStart: function () { return undefined; }, 17915 notifyInteraction: function () { return undefined; }, 17916 notifyNavigation: function () { return undefined; }, 17917 notifyRemoval: function () { return undefined; }, 17918 notifySelection: function () { return undefined; }, 17919 notifyTrailingIconInteraction: function () { return undefined; }, 17920 removeClass: function () { return undefined; }, 17921 removeClassFromLeadingIcon: function () { return undefined; }, 17922 removeTrailingActionFocus: function () { return undefined; }, 17923 setPrimaryActionAttr: function () { return undefined; }, 17924 setStyleProperty: function () { return undefined; }, 17925 }; 17926 }, 17927 enumerable: true, 17928 configurable: true 17929 }); 17930 MDCChipFoundation.prototype.isSelected = function () { 17931 return this.adapter.hasClass(cssClasses$4.SELECTED); 17932 }; 17933 MDCChipFoundation.prototype.isEditable = function () { 17934 return this.adapter.hasClass(cssClasses$4.EDITABLE); 17935 }; 17936 MDCChipFoundation.prototype.isEditing = function () { 17937 return this.adapter.hasClass(cssClasses$4.EDITING); 17938 }; 17939 MDCChipFoundation.prototype.setSelected = function (selected) { 17940 this.setSelected_(selected); 17941 this.notifySelection_(selected); 17942 }; 17943 MDCChipFoundation.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) { 17944 this.setSelected_(selected); 17945 if (shouldNotifyClients) { 17946 this.notifyIgnoredSelection_(selected); 17947 } 17948 }; 17949 MDCChipFoundation.prototype.getShouldRemoveOnTrailingIconClick = function () { 17950 return this.shouldRemoveOnTrailingIconClick_; 17951 }; 17952 MDCChipFoundation.prototype.setShouldRemoveOnTrailingIconClick = function (shouldRemove) { 17953 this.shouldRemoveOnTrailingIconClick_ = shouldRemove; 17954 }; 17955 MDCChipFoundation.prototype.setShouldFocusPrimaryActionOnClick = function (shouldFocus) { 17956 this.shouldFocusPrimaryActionOnClick_ = shouldFocus; 17957 }; 17958 MDCChipFoundation.prototype.getDimensions = function () { 17959 var _this = this; 17960 var getRootRect = function () { return _this.adapter.getRootBoundingClientRect(); }; 17961 var getCheckmarkRect = function () { 17962 return _this.adapter.getCheckmarkBoundingClientRect(); 17963 }; 17964 // When a chip has a checkmark and not a leading icon, the bounding rect changes in size depending on the current 17965 // size of the checkmark. 17966 if (!this.adapter.hasLeadingIcon()) { 17967 var checkmarkRect = getCheckmarkRect(); 17968 if (checkmarkRect) { 17969 var rootRect = getRootRect(); 17970 // Checkmark is a square, meaning the client rect's width and height are identical once the animation completes. 17971 // However, the checkbox is initially hidden by setting the width to 0. 17972 // To account for an initial width of 0, we use the checkbox's height instead (which equals the end-state width) 17973 // when adding it to the root client rect's width. 17974 return { 17975 bottom: rootRect.bottom, 17976 height: rootRect.height, 17977 left: rootRect.left, 17978 right: rootRect.right, 17979 top: rootRect.top, 17980 width: rootRect.width + checkmarkRect.height, 17981 }; 17982 } 17983 } 17984 return getRootRect(); 17985 }; 17986 /** 17987 * Begins the exit animation which leads to removal of the chip. 17988 */ 17989 MDCChipFoundation.prototype.beginExit = function () {
17990 this.adapter.addClass(cssClasses$4.CHIP_EXIT); 17991 }; 17992 MDCChipFoundation.prototype.handleClick = function () { 17993 this.adapter.notifyInteraction(); 17994 this.setPrimaryActionFocusable_(this.getFocusBehavior_()); 17995 }; 17996 MDCChipFoundation.prototype.handleDoubleClick = function () { 17997 if (this.isEditable()) { 17998 this.startEditing(); 17999 } 18000 }; 18001 /** 18002 * Handles a transition end event on the root element. 18003 */ 18004 MDCChipFoundation.prototype.handleTransitionEnd = function (evt) { 18005 var _this = this; 18006 // Handle transition end event on the chip when it is about to be removed. 18007 var shouldHandle = this.adapter.eventTargetHasClass(evt.target, cssClasses$4.CHIP_EXIT); 18008 var widthIsAnimating = evt.propertyName === 'width'; 18009 var opacityIsAnimating = evt.propertyName === 'opacity'; 18010 if (shouldHandle && opacityIsAnimating) { 18011 // See: https://css-tricks.com/using-css-transitions-auto-dimensions/#article-header-id-5 18012 var chipWidth_1 = this.adapter.getComputedStyleValue('width'); 18013 // On the next frame (once we get the computed width), explicitly set the chip's width 18014 // to its current pixel width, so we aren't transitioning out of 'auto'. 18015 requestAnimationFrame(function () { 18016 _this.adapter.setStyleProperty('width', chipWidth_1); 18017 // To mitigate jitter, start transitioning padding and margin before width. 18018 _this.adapter.setStyleProperty('padding', '0'); 18019 _this.adapter.setStyleProperty('margin', '0'); 18020 // On the next frame (once width is explicitly set), transition width to 0. 18021 requestAnimationFrame(function () { 18022 _this.adapter.setStyleProperty('width', '0'); 18023 }); 18024 }); 18025 return; 18026 } 18027 if (shouldHandle && widthIsAnimating) { 18028 this.removeFocus(); 18029 var removedAnnouncement = this.adapter.getAttribute(strings$6.REMOVED_ANNOUNCEMENT_ATTRIBUTE); 18030 this.adapter.notifyRemoval(removedAnnouncement); 18031 } 18032 // Handle a transition end event on the leading icon or checkmark, since the transition end event bubbles. 18033 if (!opacityIsAnimating) { 18034 return; 18035 } 18036 var shouldHideLeadingIcon = this.adapter.eventTargetHasClass(evt.target, cssClasses$4.LEADING_ICON) && 18037 this.adapter.hasClass(cssClasses$4.SELECTED); 18038 var shouldShowLeadingIcon = this.adapter.eventTargetHasClass(evt.target, cssClasses$4.CHECKMARK) && 18039 !this.adapter.hasClass(cssClasses$4.SELECTED); 18040 if (shouldHideLeadingIcon) { 18041 this.adapter.addClassToLeadingIcon(cssClasses$4.HIDDEN_LEADING_ICON); 18042 return; 18043 } 18044 if (shouldShowLeadingIcon) { 18045 this.adapter.removeClassFromLeadingIcon(cssClasses$4.HIDDEN_LEADING_ICON); 18046 return; 18047 } 18048 }; 18049 MDCChipFoundation.prototype.handleFocusIn = function (evt) { 18050 // Early exit if the event doesn't come from the primary action 18051 if (!this.eventFromPrimaryAction_(evt)) { 18052 return; 18053 } 18054 this.adapter.addClass(cssClasses$4.PRIMARY_ACTION_FOCUSED); 18055 }; 18056 MDCChipFoundation.prototype.handleFocusOut = function (evt) { 18057 // Early exit if the event doesn't come from the primary action 18058 if (!this.eventFromPrimaryAction_(evt)) { 18059 return; 18060 } 18061 if (this.isEditing()) { 18062 this.finishEditing(); 18063 } 18064 this.adapter.removeClass(cssClasses$4.PRIMARY_ACTION_FOCUSED); 18065 }; 18066 /** 18067 * Handles an interaction event on the trailing icon element. This is used to 18068 * prevent the ripple from activating on interaction with the trailing icon. 18069 */ 18070 MDCChipFoundation.prototype.handleTrailingActionInteraction = function () { 18071 this.adapter.notifyTrailingIconInteraction(); 18072 this.removeChip_(); 18073 }; 18074 /** 18075 * Handles a keydown event from the root element. 18076 */ 18077 MDCChipFoundation.prototype.handleKeydown = function (evt) { 18078 if (this.isEditing()) { 18079 if (this.shouldFinishEditing(evt)) { 18080 evt.preventDefault(); 18081 this.finishEditing(); 18082 } 18083 // When editing, the foundation should only handle key events that finish 18084 // the editing process. 18085 return; 18086 } 18087 if (this.isEditable()) { 18088 if (this.shouldStartEditing(evt)) { 18089 evt.preventDefault(); 18090 this.startEditing(); 18091 } 18092 } 18093 if (this.shouldNotifyInteraction_(evt)) { 18094 this.adapter.notifyInteraction(); 18095 this.setPrimaryActionFocusable_(this.getFocusBehavior_()); 18096 return; 18097 } 18098 if (this.isDeleteAction_(evt)) { 18099 evt.preventDefault(); 18100 this.removeChip_(); 18101 return; 18102 } 18103 // Early exit if the key is not usable 18104 if (!navigationKeys.has(evt.key)) { 18105 return; 18106 } 18107 // Prevent default behavior for movement keys which could include scrolling 18108 evt.preventDefault(); 18109 this.focusNextAction_(evt.key, EventSource.PRIMARY); 18110 }; 18111 MDCChipFoundation.prototype.handleTrailingActionNavigation = function (evt) {
18112 return this.focusNextAction_(evt.detail.key, EventSource.TRAILING); 18113 }; 18114 /** 18115 * Called by the chip set to remove focus from the chip actions. 18116 */ 18117 MDCChipFoundation.prototype.removeFocus = function () { 18118 this.adapter.setPrimaryActionAttr(strings$6.TAB_INDEX, '-1'); 18119 this.adapter.removeTrailingActionFocus(); 18120 }; 18121 /** 18122 * Called by the chip set to focus the primary action. 18123 * 18124 */ 18125 MDCChipFoundation.prototype.focusPrimaryAction = function () { 18126 this.setPrimaryActionFocusable_(FocusBehavior.SHOULD_FOCUS); 18127 }; 18128 /** 18129 * Called by the chip set to focus the trailing action (if present), otherwise 18130 * gives focus to the trailing action. 18131 */ 18132 MDCChipFoundation.prototype.focusTrailingAction = function () { 18133 var trailingActionIsNavigable = this.adapter.isTrailingActionNavigable(); 18134 if (trailingActionIsNavigable) { 18135 this.adapter.setPrimaryActionAttr(strings$6.TAB_INDEX, '-1'); 18136 this.adapter.focusTrailingAction(); 18137 return; 18138 } 18139 this.focusPrimaryAction(); 18140 }; 18141 MDCChipFoundation.prototype.setPrimaryActionFocusable_ = function (focusBehavior) { 18142 this.adapter.setPrimaryActionAttr(strings$6.TAB_INDEX, '0'); 18143 if (focusBehavior === FocusBehavior.SHOULD_FOCUS) { 18144 this.adapter.focusPrimaryAction(); 18145 } 18146 this.adapter.removeTrailingActionFocus(); 18147 }; 18148 MDCChipFoundation.prototype.getFocusBehavior_ = function () { 18149 if (this.shouldFocusPrimaryActionOnClick_) { 18150 return FocusBehavior.SHOULD_FOCUS; 18151 } 18152 return FocusBehavior.SHOULD_NOT_FOCUS; 18153 }; 18154 MDCChipFoundation.prototype.focusNextAction_ = function (key, source) { 18155 var isTrailingActionNavigable = this.adapter.isTrailingActionNavigable(); 18156 var dir = this.getDirection_(key); 18157 // Early exit if the key should jump chips 18158 if (jumpChipKeys.has(key) || !isTrailingActionNavigable) { 18159 return this.adapter.notifyNavigation(key, source); 18160 } 18161 if (source === EventSource.PRIMARY && dir === Direction.RIGHT) { 18162 return this.focusTrailingAction(); 18163 } 18164 if (source === EventSource.TRAILING && dir === Direction.LEFT) { 18165 return this.focusPrimaryAction(); 18166 } 18167 this.adapter.notifyNavigation(key, EventSource.NONE); 18168 }; 18169 MDCChipFoundation.prototype.getDirection_ = function (key) { 18170 var isRTL = this.adapter.isRTL(); 18171 var isLeftKey = key === strings$6.ARROW_LEFT_KEY || key === strings$6.IE_ARROW_LEFT_KEY; 18172 var isRightKey = key === strings$6.ARROW_RIGHT_KEY || key === strings$6.IE_ARROW_RIGHT_KEY; 18173 if (!isRTL && isLeftKey || isRTL && isRightKey) { 18174 return Direction.LEFT; 18175 } 18176 return Direction.RIGHT; 18177 }; 18178 MDCChipFoundation.prototype.removeChip_ = function () { 18179 if (this.shouldRemoveOnTrailingIconClick_) { 18180 this.beginExit(); 18181 } 18182 }; 18183 MDCChipFoundation.prototype.shouldStartEditing = function (evt) { 18184 return this.eventFromPrimaryAction_(evt) && evt.key === strings$6.ENTER_KEY; 18185 }; 18186 MDCChipFoundation.prototype.shouldFinishEditing = function (evt) { 18187 return evt.key === strings$6.ENTER_KEY; 18188 }; 18189 MDCChipFoundation.prototype.shouldNotifyInteraction_ = function (evt) { 18190 return evt.key === strings$6.ENTER_KEY || evt.key === strings$6.SPACEBAR_KEY; 18191 }; 18192 MDCChipFoundation.prototype.isDeleteAction_ = function (evt) { 18193 var isDeletable = this.adapter.hasClass(cssClasses$4.DELETABLE); 18194 return isDeletable && 18195 (evt.key === strings$6.BACKSPACE_KEY || evt.key === strings$6.DELETE_KEY || 18196 evt.key === strings$6.IE_DELETE_KEY); 18197 }; 18198 MDCChipFoundation.prototype.setSelected_ = function (selected) { 18199 if (selected) { 18200 this.adapter.addClass(cssClasses$4.SELECTED); 18201 this.adapter.setPrimaryActionAttr(strings$6.ARIA_CHECKED, 'true'); 18202 } 18203 else {
18204 this.adapter.removeClass(cssClasses$4.SELECTED); 18205 this.adapter.setPrimaryActionAttr(strings$6.ARIA_CHECKED, 'false'); 18206 } 18207 }; 18208 MDCChipFoundation.prototype.notifySelection_ = function (selected) { 18209 this.adapter.notifySelection(selected, false); 18210 }; 18211 MDCChipFoundation.prototype.notifyIgnoredSelection_ = function (selected) { 18212 this.adapter.notifySelection(selected, true); 18213 }; 18214 MDCChipFoundation.prototype.eventFromPrimaryAction_ = function (evt) { 18215 return this.adapter.eventTargetHasClass(evt.target, cssClasses$4.PRIMARY_ACTION); 18216 }; 18217 MDCChipFoundation.prototype.startEditing = function () { 18218 this.adapter.addClass(cssClasses$4.EDITING); 18219 this.adapter.notifyEditStart(); 18220 }; 18221 MDCChipFoundation.prototype.finishEditing = function () { 18222 this.adapter.removeClass(cssClasses$4.EDITING); 18223 this.adapter.notifyEditFinish(); 18224 }; 18225 return MDCChipFoundation; 18226 }(MDCFoundation)); 18227 18228 /** 18229 * @license 18230 * Copyright 2016 Google Inc. 18231 * 18232 * Permission is hereby granted, free of charge, to any person obtaining a copy 18233 * of this software and associated documentation files (the "Software"), to deal 18234 * in the Software without restriction, including without limitation the rights 18235 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18236 * copies of the Software, and to permit persons to whom the Software is 18237 * furnished to do so, subject to the following conditions: 18238 * 18239 * The above copyright notice and this permission notice shall be included in 18240 * all copies or substantial portions of the Software. 18241 * 18242 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18243 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18244 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18245 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18246 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18247 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 18248 * THE SOFTWARE. 18249 */ 18250 var MDCChip = /** @class */ (function (_super) { 18251 __extends(MDCChip, _super); 18252 function MDCChip() { 18253 return _super !== null && _super.apply(this, arguments) || this; 18254 } 18255 Object.defineProperty(MDCChip.prototype, "selected", { 18256 /** 18257 * @return Whether the chip is selected. 18258 */ 18259 get: function () { 18260 return this.foundation.isSelected(); 18261 }, 18262 /** 18263 * Sets selected state on the chip. 18264 */ 18265 set: function (selected) { 18266 this.foundation.setSelected(selected); 18267 }, 18268 enumerable: true, 18269 configurable: true 18270 }); 18271 Object.defineProperty(MDCChip.prototype, "shouldRemoveOnTrailingIconClick", { 18272 /** 18273 * @return Whether a trailing icon click should trigger exit/removal of the chip. 18274 */ 18275 get: function () { 18276 return this.foundation.getShouldRemoveOnTrailingIconClick(); 18277 }, 18278 /** 18279 * Sets whether a trailing icon click should trigger exit/removal of the chip. 18280 */ 18281 set: function (shouldRemove) { 18282 this.foundation.setShouldRemoveOnTrailingIconClick(shouldRemove); 18283 }, 18284 enumerable: true, 18285 configurable: true 18286 }); 18287 Object.defineProperty(MDCChip.prototype, "setShouldFocusPrimaryActionOnClick", { 18288 /** 18289 * Sets whether a clicking on the chip should focus the primary action. 18290 */ 18291 set: function (shouldFocus) { 18292 this.foundation.setShouldFocusPrimaryActionOnClick(shouldFocus); 18293 }, 18294 enumerable: true, 18295 configurable: true 18296 }); 18297 Object.defineProperty(MDCChip.prototype, "ripple", { 18298 get: function () { 18299 return this.ripple_; 18300 }, 18301 enumerable: true, 18302 configurable: true 18303 }); 18304 Object.defineProperty(MDCChip.prototype, "id", { 18305 get: function () { 18306 return this.root.id; 18307 }, 18308 enumerable: true, 18309 configurable: true 18310 }); 18311 MDCChip.attachTo = function (root) { 18312 return new MDCChip(root); 18313 }; 18314 MDCChip.prototype.initialize = function (rippleFactory, trailingActionFactory) { 18315 var _this = this; 18316 if (rippleFactory === void 0) { rippleFactory = function (el, foundation) { return new MDCRipple(el, foundation); }; } 18317 if (trailingActionFactory === void 0) { trailingActionFactory = function (el) { return new MDCChipTrailingAction(el); }; } 18318 this.leadingIcon_ = this.root.querySelector(strings$6.LEADING_ICON_SELECTOR); 18319 this.checkmark_ = this.root.querySelector(strings$6.CHECKMARK_SELECTOR); 18320 this.primaryAction_ = 18321 this.root.querySelector(strings$6.PRIMARY_ACTION_SELECTOR); 18322 var trailingActionEl = this.root.querySelector(strings$6.TRAILING_ACTION_SELECTOR); 18323 if (trailingActionEl) { 18324 this.trailingAction_ = trailingActionFactory(trailingActionEl); 18325 } 18326 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 18327 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 18328 var rippleAdapter = __assign(__assign({}, MDCRipple.createAdapter(this)), { computeBoundingRect: function () { return _this.foundation.getDimensions(); } }); 18329 this.ripple_ = 18330 rippleFactory(this.root, new MDCRippleFoundation(rippleAdapter)); 18331 }; 18332 MDCChip.prototype.initialSyncWithDOM = function () { 18333 var _this = this; 18334 // Custom events 18335 this.handleTrailingActionInteraction_ = function () { 18336 _this.foundation.handleTrailingActionInteraction(); 18337 }; 18338 this.handleTrailingActionNavigation_ = 18339 function (evt) { 18340 _this.foundation.handleTrailingActionNavigation(evt); 18341 }; 18342 // Native events 18343 this.handleClick_ = function () { 18344 _this.foundation.handleClick(); 18345 }; 18346 this.handleKeydown_ = function (evt) { 18347 _this.foundation.handleKeydown(evt); 18348 }; 18349 this.handleTransitionEnd_ = function (evt) { 18350 _this.foundation.handleTransitionEnd(evt); 18351 }; 18352 this.handleFocusIn_ = function (evt) { 18353 _this.foundation.handleFocusIn(evt); 18354 }; 18355 this.handleFocusOut_ = function (evt) { 18356 _this.foundation.handleFocusOut(evt); 18357 }; 18358 this.listen('transitionend', this.handleTransitionEnd_); 18359 this.listen('click', this.handleClick_); 18360 this.listen('keydown', this.handleKeydown_); 18361 this.listen('focusin', this.handleFocusIn_); 18362 this.listen('focusout', this.handleFocusOut_); 18363 if (this.trailingAction_) { 18364 this.listen(strings$7.INTERACTION_EVENT, this.handleTrailingActionInteraction_); 18365 this.listen(strings$7.NAVIGATION_EVENT, this.handleTrailingActionNavigation_); 18366 } 18367 }; 18368 MDCChip.prototype.destroy = function () { 18369 this.ripple_.destroy(); 18370 this.unlisten('transitionend', this.handleTransitionEnd_); 18371 this.unlisten('keydown', this.handleKeydown_); 18372 this.unlisten('click', this.handleClick_); 18373 this.unlisten('focusin', this.handleFocusIn_); 18374 this.unlisten('focusout', this.handleFocusOut_); 18375 if (this.trailingAction_) { 18376 this.unlisten(strings$7.INTERACTION_EVENT, this.handleTrailingActionInteraction_); 18377 this.unlisten(strings$7.NAVIGATION_EVENT, this.handleTrailingActionNavigation_); 18378 } 18379 _super.prototype.destroy.call(this); 18380 }; 18381 /** 18382 * Begins the exit animation which leads to removal of the chip. 18383 */ 18384 MDCChip.prototype.beginExit = function () { 18385 this.foundation.beginExit(); 18386 }; 18387 MDCChip.prototype.getDefaultFoundation = function () { 18388 var _this = this; 18389 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 18390 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 18391 var adapter = { 18392 addClass: function (className) { return _this.root.classList.add(className); }, 18393 addClassToLeadingIcon: function (className) { 18394 if (_this.leadingIcon_) { 18395 _this.leadingIcon_.classList.add(className); 18396 } 18397 }, 18398 eventTargetHasClass: function (target, className) { 18399 return target ? target.classList.contains(className) : false;
18400 }, 18401 focusPrimaryAction: function () { 18402 if (_this.primaryAction_) { 18403 _this.primaryAction_.focus(); 18404 } 18405 }, 18406 focusTrailingAction: function () { 18407 if (_this.trailingAction_) { 18408 _this.trailingAction_.focus(); 18409 } 18410 }, 18411 getAttribute: function (attr) { return _this.root.getAttribute(attr); }, 18412 getCheckmarkBoundingClientRect: function () { 18413 return _this.checkmark_ ? _this.checkmark_.getBoundingClientRect() : null; 18414 }, 18415 getComputedStyleValue: function (propertyName) { 18416 return window.getComputedStyle(_this.root).getPropertyValue(propertyName); 18417 }, 18418 getRootBoundingClientRect: function () { return _this.root.getBoundingClientRect(); }, 18419 hasClass: function (className) { return _this.root.classList.contains(className); }, 18420 hasLeadingIcon: function () { return !!_this.leadingIcon_; }, 18421 isRTL: function () { return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl'; }, 18422 isTrailingActionNavigable: function () { 18423 if (_this.trailingAction_) { 18424 return _this.trailingAction_.isNavigable(); 18425 } 18426 return false; 18427 }, 18428 notifyInteraction: function () { return _this.emit(strings$6.INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */); }, 18429 notifyNavigation: function (key, source) { 18430 return _this.emit(strings$6.NAVIGATION_EVENT, { chipId: _this.id, key: key, source: source }, true /* shouldBubble */); 18431 }, 18432 notifyRemoval: function (removedAnnouncement) { 18433 _this.emit(strings$6.REMOVAL_EVENT, { chipId: _this.id, removedAnnouncement: removedAnnouncement }, true /* shouldBubble */); 18434 }, 18435 notifySelection: function (selected, shouldIgnore) { 18436 return _this.emit(strings$6.SELECTION_EVENT, { chipId: _this.id, selected: selected, shouldIgnore: shouldIgnore }, true /* shouldBubble */); 18437 }, 18438 notifyTrailingIconInteraction: function () { 18439 return _this.emit(strings$6.TRAILING_ICON_INTERACTION_EVENT, { chipId: _this.id }, true /* shouldBubble */); 18440 }, 18441 notifyEditStart: function () { }, 18442 notifyEditFinish: function () { }, 18443 removeClass: function (className) { return _this.root.classList.remove(className); }, 18444 removeClassFromLeadingIcon: function (className) { 18445 if (_this.leadingIcon_) { 18446 _this.leadingIcon_.classList.remove(className); 18447 } 18448 }, 18449 removeTrailingActionFocus: function () { 18450 if (_this.trailingAction_) { 18451 _this.trailingAction_.removeFocus(); 18452 } 18453 }, 18454 setPrimaryActionAttr: function (attr, value) { 18455 if (_this.primaryAction_) { 18456 _this.primaryAction_.setAttribute(attr, value); 18457 } 18458 }, 18459 setStyleProperty: function (propertyName, value) { 18460 return _this.root.style.setProperty(propertyName, value); 18461 }, 18462 }; 18463 return new MDCChipFoundation(adapter); 18464 }; 18465 MDCChip.prototype.setSelectedFromChipSet = function (selected, shouldNotifyClients) { 18466 this.foundation.setSelectedFromChipSet(selected, shouldNotifyClients); 18467 }; 18468 MDCChip.prototype.focusPrimaryAction = function () { 18469 this.foundation.focusPrimaryAction(); 18470 }; 18471 MDCChip.prototype.focusTrailingAction = function () { 18472 this.foundation.focusTrailingAction(); 18473 }; 18474 MDCChip.prototype.removeFocus = function () { 18475 this.foundation.removeFocus(); 18476 }; 18477 MDCChip.prototype.remove = function () { 18478 var parent = this.root.parentNode; 18479 if (parent !== null) { 18480 parent.removeChild(this.root); 18481 } 18482 }; 18483 return MDCChip; 18484 }(MDCComponent)); 18485 18486 /** 18487 * @license 18488 * Copyright 2019 Google Inc. 18489 * 18490 * Permission is hereby granted, free of charge, to any person obtaining a copy 18491 * of this software and associated documentation files (the "Software"), to deal 18492 * in the Software without restriction, including without limitation the rights 18493 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18494 * copies of the Software, and to permit persons to whom the Software is 18495 * furnished to do so, subject to the following conditions: 18496 * 18497 * The above copyright notice and this permission notice shall be included in 18498 * all copies or substantial portions of the Software. 18499 * 18500 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18501 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18502 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18503 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18504 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18505 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 18506 * THE SOFTWARE. 18507 */ 18508 18509 /** 18510 * @license 18511 * Copyright 2020 Google Inc. 18512 * 18513 * Permission is hereby granted, free of charge, to any person obtaining a copy 18514 * of this software and associated documentation files (the "Software"), to deal 18515 * in the Software without restriction, including without limitation the rights 18516 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18517 * copies of the Software, and to permit persons to whom the Software is 18518 * furnished to do so, subject to the following conditions: 18519 * 18520 * The above copyright notice and this permission notice shall be included in 18521 * all copies or substantial portions of the Software. 18522 * 18523 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18524 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18525 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18526 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18527 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18528 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 18529 * THE SOFTWARE. 18530 */ 18531 /** 18532 * Priorities for the announce function 18533 */ 18534 var AnnouncerPriority; 18535 (function (AnnouncerPriority) { 18536 AnnouncerPriority["POLITE"] = "polite";
18537 AnnouncerPriority["ASSERTIVE"] = "assertive"; 18538 })(AnnouncerPriority || (AnnouncerPriority = {})); 18539 /** 18540 * Data attribute added to live region element. 18541 */ 18542 var DATA_MDC_DOM_ANNOUNCE = 'data-mdc-dom-announce'; 18543 /** 18544 * Announces the given message with optional priority, defaulting to "polite" 18545 */ 18546 function announce(message, priority) { 18547 Announcer.getInstance().say(message, priority); 18548 } 18549 var Announcer = /** @class */ (function () { 18550 // Constructor made private to ensure only the singleton is used 18551 function Announcer() { 18552 this.liveRegions = new Map(); 18553 } 18554 Announcer.getInstance = function () { 18555 if (!Announcer.instance) { 18556 Announcer.instance = new Announcer(); 18557 } 18558 return Announcer.instance; 18559 }; 18560 Announcer.prototype.say = function (message, priority) { 18561 if (priority === void 0) { priority = AnnouncerPriority.POLITE; } 18562 var liveRegion = this.getLiveRegion(priority); 18563 // Reset the region to pick up the message, even if the message is the 18564 // exact same as before. 18565 liveRegion.textContent = ''; 18566 // Timeout is necessary for screen readers like NVDA and VoiceOver. 18567 setTimeout(function () { 18568 liveRegion.textContent = message; 18569 document.addEventListener('click', clearLiveRegion); 18570 }, 1); 18571 function clearLiveRegion() { 18572 liveRegion.textContent = ''; 18573 document.removeEventListener('click', clearLiveRegion); 18574 } 18575 }; 18576 Announcer.prototype.getLiveRegion = function (priority) { 18577 var existingLiveRegion = this.liveRegions.get(priority); 18578 if (existingLiveRegion && 18579 document.body.contains(existingLiveRegion)) { 18580 return existingLiveRegion; 18581 } 18582 var liveRegion = this.createLiveRegion(priority); 18583 this.liveRegions.set(priority, liveRegion); 18584 return liveRegion; 18585 }; 18586 Announcer.prototype.createLiveRegion = function (priority) { 18587 var el = document.createElement('div'); 18588 el.style.position = 'absolute'; 18589 el.style.top = '-9999px'; 18590 el.style.left = '-9999px'; 18591 el.style.height = '1px'; 18592 el.style.overflow = 'hidden'; 18593 el.setAttribute('aria-atomic', 'true'); 18594 el.setAttribute('aria-live', priority); 18595 el.setAttribute(DATA_MDC_DOM_ANNOUNCE, 'true'); 18596 document.body.appendChild(el); 18597 return el; 18598 }; 18599 return Announcer; 18600 }()); 18601 18602 /** 18603 * @license 18604 * Copyright 2016 Google Inc. 18605 * 18606 * Permission is hereby granted, free of charge, to any person obtaining a copy 18607 * of this software and associated documentation files (the "Software"), to deal 18608 * in the Software without restriction, including without limitation the rights 18609 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18610 * copies of the Software, and to permit persons to whom the Software is 18611 * furnished to do so, subject to the following conditions: 18612 * 18613 * The above copyright notice and this permission notice shall be included in 18614 * all copies or substantial portions of the Software. 18615 * 18616 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18617 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18618 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18619 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18620 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18621 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 18622 * THE SOFTWARE. 18623 */ 18624 var strings$5 = { 18625 CHIP_SELECTOR: '.mdc-chip', 18626 };
18627 var cssClasses$3 = { 18628 CHOICE: 'mdc-chip-set--choice', 18629 FILTER: 'mdc-chip-set--filter', 18630 }; 18631 18632 /** 18633 * @license 18634 * Copyright 2017 Google Inc. 18635 * 18636 * Permission is hereby granted, free of charge, to any person obtaining a copy 18637 * of this software and associated documentation files (the "Software"), to deal 18638 * in the Software without restriction, including without limitation the rights 18639 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18640 * copies of the Software, and to permit persons to whom the Software is 18641 * furnished to do so, subject to the following conditions: 18642 * 18643 * The above copyright notice and this permission notice shall be included in 18644 * all copies or substantial portions of the Software. 18645 * 18646 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18647 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18648 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18649 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18650 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18651 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 18652 * THE SOFTWARE. 18653 */ 18654 var MDCChipSetFoundation = /** @class */ (function (_super) { 18655 __extends(MDCChipSetFoundation, _super); 18656 function MDCChipSetFoundation(adapter) { 18657 var _this = _super.call(this, __assign(__assign({}, MDCChipSetFoundation.defaultAdapter), adapter)) || this; 18658 /** 18659 * The ids of the selected chips in the set. Only used for choice chip set or filter chip set. 18660 */ 18661 _this.selectedChipIds_ = []; 18662 return _this; 18663 } 18664 Object.defineProperty(MDCChipSetFoundation, "strings", { 18665 get: function () { 18666 return strings$5; 18667 }, 18668 enumerable: true, 18669 configurable: true 18670 }); 18671 Object.defineProperty(MDCChipSetFoundation, "cssClasses", { 18672 get: function () { 18673 return cssClasses$3; 18674 }, 18675 enumerable: true, 18676 configurable: true 18677 }); 18678 Object.defineProperty(MDCChipSetFoundation, "defaultAdapter", { 18679 get: function () { 18680 return { 18681 announceMessage: function () { return undefined; }, 18682 focusChipPrimaryActionAtIndex: function () { return undefined; }, 18683 focusChipTrailingActionAtIndex: function () { return undefined; }, 18684 getChipListCount: function () { return -1; }, 18685 getIndexOfChipById: function () { return -1; }, 18686 hasClass: function () { return false; }, 18687 isRTL: function () { return false; }, 18688 removeChipAtIndex: function () { return undefined; }, 18689 removeFocusFromChipAtIndex: function () { return undefined; }, 18690 selectChipAtIndex: function () { return undefined; }, 18691 }; 18692 }, 18693 enumerable: true, 18694 configurable: true 18695 }); 18696 /** 18697 * Returns an array of the IDs of all selected chips. 18698 */ 18699 MDCChipSetFoundation.prototype.getSelectedChipIds = function () { 18700 return this.selectedChipIds_.slice(); 18701 }; 18702 /** 18703 * Selects the chip with the given id. Deselects all other chips if the chip set is of the choice variant. 18704 * Does not notify clients of the updated selection state. 18705 */ 18706 MDCChipSetFoundation.prototype.select = function (chipId) { 18707 this.select_(chipId, false); 18708 }; 18709 /** 18710 * Handles a chip interaction event 18711 */ 18712 MDCChipSetFoundation.prototype.handleChipInteraction = function (_a) { 18713 var chipId = _a.chipId; 18714 var index = this.adapter.getIndexOfChipById(chipId); 18715 this.removeFocusFromChipsExcept_(index); 18716 if (this.adapter.hasClass(cssClasses$3.CHOICE) || 18717 this.adapter.hasClass(cssClasses$3.FILTER)) { 18718 this.toggleSelect_(chipId); 18719 } 18720 }; 18721 /** 18722 * Handles a chip selection event, used to handle discrepancy when selection state is set directly on the Chip. 18723 */ 18724 MDCChipSetFoundation.prototype.handleChipSelection = function (_a) { 18725 var chipId = _a.chipId, selected = _a.selected, shouldIgnore = _a.shouldIgnore; 18726 // Early exit if we should ignore the event 18727 if (shouldIgnore) { 18728 return; 18729 } 18730 var chipIsSelected = this.selectedChipIds_.indexOf(chipId) >= 0; 18731 if (selected && !chipIsSelected) { 18732 this.select(chipId); 18733 } 18734 else if (!selected && chipIsSelected) { 18735 this.deselect_(chipId); 18736 } 18737 }; 18738 /** 18739 * Handles the event when a chip is removed. 18740 */ 18741 MDCChipSetFoundation.prototype.handleChipRemoval = function (_a) { 18742 var chipId = _a.chipId, removedAnnouncement = _a.removedAnnouncement; 18743 if (removedAnnouncement) { 18744 this.adapter.announceMessage(removedAnnouncement); 18745 } 18746 var index = this.adapter.getIndexOfChipById(chipId); 18747 this.deselectAndNotifyClients_(chipId); 18748 this.adapter.removeChipAtIndex(index); 18749 var maxIndex = this.adapter.getChipListCount() - 1; 18750 if (maxIndex < 0) { 18751 return; 18752 } 18753 var nextIndex = Math.min(index, maxIndex); 18754 this.removeFocusFromChipsExcept_(nextIndex);
18755 // After removing a chip, we should focus the trailing action for the next chip. 18756 this.adapter.focusChipTrailingActionAtIndex(nextIndex); 18757 }; 18758 /** 18759 * Handles a chip navigation event. 18760 */ 18761 MDCChipSetFoundation.prototype.handleChipNavigation = function (_a) { 18762 var chipId = _a.chipId, key = _a.key, source = _a.source; 18763 var maxIndex = this.adapter.getChipListCount() - 1; 18764 var index = this.adapter.getIndexOfChipById(chipId); 18765 // Early exit if the index is out of range or the key is unusable 18766 if (index === -1 || !navigationKeys.has(key)) { 18767 return; 18768 } 18769 var isRTL = this.adapter.isRTL(); 18770 var isLeftKey = key === strings$6.ARROW_LEFT_KEY || 18771 key === strings$6.IE_ARROW_LEFT_KEY; 18772 var isRightKey = key === strings$6.ARROW_RIGHT_KEY || 18773 key === strings$6.IE_ARROW_RIGHT_KEY; 18774 var isDownKey = key === strings$6.ARROW_DOWN_KEY || 18775 key === strings$6.IE_ARROW_DOWN_KEY; 18776 var shouldIncrement = !isRTL && isRightKey || isRTL && isLeftKey || isDownKey; 18777 var isHome = key === strings$6.HOME_KEY; 18778 var isEnd = key === strings$6.END_KEY; 18779 if (shouldIncrement) { 18780 index++; 18781 } 18782 else if (isHome) { 18783 index = 0; 18784 } 18785 else if (isEnd) { 18786 index = maxIndex; 18787 } 18788 else { 18789 index--; 18790 } 18791 // Early exit if the index is out of bounds 18792 if (index < 0 || index > maxIndex) { 18793 return; 18794 } 18795 this.removeFocusFromChipsExcept_(index); 18796 this.focusChipAction_(index, key, source); 18797 }; 18798 MDCChipSetFoundation.prototype.focusChipAction_ = function (index, key, source) { 18799 var shouldJumpChips = jumpChipKeys.has(key); 18800 if (shouldJumpChips && source === EventSource.PRIMARY) { 18801 return this.adapter.focusChipPrimaryActionAtIndex(index); 18802 } 18803 if (shouldJumpChips && source === EventSource.TRAILING) { 18804 return this.adapter.focusChipTrailingActionAtIndex(index); 18805 } 18806 var dir = this.getDirection_(key); 18807 if (dir === Direction.LEFT) { 18808 return this.adapter.focusChipTrailingActionAtIndex(index); 18809 } 18810 if (dir === Direction.RIGHT) { 18811 return this.adapter.focusChipPrimaryActionAtIndex(index); 18812 } 18813 }; 18814 MDCChipSetFoundation.prototype.getDirection_ = function (key) { 18815 var isRTL = this.adapter.isRTL(); 18816 var isLeftKey = key === strings$6.ARROW_LEFT_KEY || 18817 key === strings$6.IE_ARROW_LEFT_KEY; 18818 var isRightKey = key === strings$6.ARROW_RIGHT_KEY || 18819 key === strings$6.IE_ARROW_RIGHT_KEY; 18820 if (!isRTL && isLeftKey || isRTL && isRightKey) { 18821 return Direction.LEFT; 18822 } 18823 return Direction.RIGHT; 18824 }; 18825 /** 18826 * Deselects the chip with the given id and optionally notifies clients. 18827 */ 18828 MDCChipSetFoundation.prototype.deselect_ = function (chipId, shouldNotifyClients) { 18829 if (shouldNotifyClients === void 0) { shouldNotifyClients = false; } 18830 var index = this.selectedChipIds_.indexOf(chipId); 18831 if (index >= 0) { 18832 this.selectedChipIds_.splice(index, 1); 18833 var chipIndex = this.adapter.getIndexOfChipById(chipId); 18834 this.adapter.selectChipAtIndex(chipIndex, /** isSelected */ false, shouldNotifyClients); 18835 } 18836 }; 18837 /** 18838 * Deselects the chip with the given id and notifies clients. 18839 */ 18840 MDCChipSetFoundation.prototype.deselectAndNotifyClients_ = function (chipId) { 18841 this.deselect_(chipId, true); 18842 }; 18843 /** 18844 * Toggles selection of the chip with the given id. 18845 */ 18846 MDCChipSetFoundation.prototype.toggleSelect_ = function (chipId) { 18847 if (this.selectedChipIds_.indexOf(chipId) >= 0) { 18848 this.deselectAndNotifyClients_(chipId); 18849 } 18850 else { 18851 this.selectAndNotifyClients_(chipId); 18852 } 18853 }; 18854 MDCChipSetFoundation.prototype.removeFocusFromChipsExcept_ = function (index) { 18855 var chipCount = this.adapter.getChipListCount(); 18856 for (var i = 0; i < chipCount; i++) { 18857 if (i !== index) { 18858 this.adapter.removeFocusFromChipAtIndex(i); 18859 } 18860 } 18861 }; 18862 MDCChipSetFoundation.prototype.selectAndNotifyClients_ = function (chipId) { 18863 this.select_(chipId, true); 18864 }; 18865 MDCChipSetFoundation.prototype.select_ = function (chipId, shouldNotifyClients) { 18866 if (this.selectedChipIds_.indexOf(chipId) >= 0) { 18867 return; 18868 }
18869 if (this.adapter.hasClass(cssClasses$3.CHOICE) && 18870 this.selectedChipIds_.length > 0) { 18871 var previouslySelectedChip = this.selectedChipIds_[0]; 18872 var previouslySelectedIndex = this.adapter.getIndexOfChipById(previouslySelectedChip); 18873 this.selectedChipIds_ = []; 18874 this.adapter.selectChipAtIndex(previouslySelectedIndex, /** isSelected */ false, shouldNotifyClients); 18875 } 18876 this.selectedChipIds_.push(chipId); 18877 var index = this.adapter.getIndexOfChipById(chipId); 18878 this.adapter.selectChipAtIndex(index, /** isSelected */ true, shouldNotifyClients); 18879 }; 18880 return MDCChipSetFoundation; 18881 }(MDCFoundation)); 18882 18883 /** 18884 * @license 18885 * Copyright 2016 Google Inc. 18886 * 18887 * Permission is hereby granted, free of charge, to any person obtaining a copy 18888 * of this software and associated documentation files (the "Software"), to deal 18889 * in the Software without restriction, including without limitation the rights 18890 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 18891 * copies of the Software, and to permit persons to whom the Software is 18892 * furnished to do so, subject to the following conditions: 18893 * 18894 * The above copyright notice and this permission notice shall be included in 18895 * all copies or substantial portions of the Software. 18896 * 18897 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18898 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18899 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18900 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18901 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18902 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 18903 * THE SOFTWARE. 18904 */ 18905 var _a = MDCChipFoundation.strings, INTERACTION_EVENT = _a.INTERACTION_EVENT, SELECTION_EVENT = _a.SELECTION_EVENT, REMOVAL_EVENT = _a.REMOVAL_EVENT, NAVIGATION_EVENT = _a.NAVIGATION_EVENT; 18906 var CHIP_SELECTOR = MDCChipSetFoundation.strings.CHIP_SELECTOR; 18907 var idCounter = 0; 18908 var MDCChipSet = /** @class */ (function (_super) { 18909 __extends(MDCChipSet, _super); 18910 function MDCChipSet() { 18911 return _super !== null && _super.apply(this, arguments) || this; 18912 } 18913 MDCChipSet.attachTo = function (root) { 18914 return new MDCChipSet(root); 18915 }; 18916 Object.defineProperty(MDCChipSet.prototype, "chips", { 18917 get: function () { 18918 return this.chips_.slice(); 18919 }, 18920 enumerable: true, 18921 configurable: true 18922 }); 18923 Object.defineProperty(MDCChipSet.prototype, "selectedChipIds", { 18924 /** 18925 * @return An array of the IDs of all selected chips. 18926 */ 18927 get: function () { 18928 return this.foundation.getSelectedChipIds(); 18929 }, 18930 enumerable: true, 18931 configurable: true 18932 }); 18933 /** 18934 * @param chipFactory A function which creates a new MDCChip. 18935 */ 18936 MDCChipSet.prototype.initialize = function (chipFactory) { 18937 if (chipFactory === void 0) { chipFactory = function (el) { return new MDCChip(el); }; } 18938 this.chipFactory_ = chipFactory; 18939 this.chips_ = this.instantiateChips_(this.chipFactory_); 18940 }; 18941 MDCChipSet.prototype.initialSyncWithDOM = function () { 18942 var _this = this; 18943 this.chips_.forEach(function (chip) { 18944 if (chip.id && chip.selected) { 18945 _this.foundation.select(chip.id); 18946 } 18947 }); 18948 this.handleChipInteraction_ = function (evt) { 18949 return _this.foundation.handleChipInteraction(evt.detail); 18950 }; 18951 this.handleChipSelection_ = function (evt) { 18952 return _this.foundation.handleChipSelection(evt.detail); 18953 }; 18954 this.handleChipRemoval_ = function (evt) { 18955 return _this.foundation.handleChipRemoval(evt.detail); 18956 }; 18957 this.handleChipNavigation_ = function (evt) { 18958 return _this.foundation.handleChipNavigation(evt.detail); 18959 }; 18960 this.listen(INTERACTION_EVENT, this.handleChipInteraction_); 18961 this.listen(SELECTION_EVENT, this.handleChipSelection_); 18962 this.listen(REMOVAL_EVENT, this.handleChipRemoval_); 18963 this.listen(NAVIGATION_EVENT, this.handleChipNavigation_); 18964 }; 18965 MDCChipSet.prototype.destroy = function () { 18966 this.chips_.forEach(function (chip) { 18967 chip.destroy(); 18968 }); 18969 this.unlisten(INTERACTION_EVENT, this.handleChipInteraction_); 18970 this.unlisten(SELECTION_EVENT, this.handleChipSelection_); 18971 this.unlisten(REMOVAL_EVENT, this.handleChipRemoval_); 18972 this.unlisten(NAVIGATION_EVENT, this.handleChipNavigation_); 18973 _super.prototype.destroy.call(this); 18974 }; 18975 /**
18976 * Adds a new chip object to the chip set from the given chip element. 18977 */ 18978 MDCChipSet.prototype.addChip = function (chipEl) { 18979 chipEl.id = chipEl.id || "mdc-chip-" + ++idCounter; 18980 this.chips_.push(this.chipFactory_(chipEl)); 18981 }; 18982 MDCChipSet.prototype.getDefaultFoundation = function () { 18983 var _this = this; 18984 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 18985 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 18986 var adapter = { 18987 announceMessage: function (message) { 18988 announce(message); 18989 }, 18990 focusChipPrimaryActionAtIndex: function (index) { 18991 _this.chips_[index].focusPrimaryAction(); 18992 }, 18993 focusChipTrailingActionAtIndex: function (index) { 18994 _this.chips_[index].focusTrailingAction(); 18995 }, 18996 getChipListCount: function () { return _this.chips_.length; }, 18997 getIndexOfChipById: function (chipId) { 18998 return _this.findChipIndex_(chipId); 18999 }, 19000 hasClass: function (className) { return _this.root.classList.contains(className); }, 19001 isRTL: function () { return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl'; }, 19002 removeChipAtIndex: function (index) { 19003 if (index >= 0 && index < _this.chips_.length) { 19004 _this.chips_[index].destroy(); 19005 _this.chips_[index].remove(); 19006 _this.chips_.splice(index, 1); 19007 } 19008 }, 19009 removeFocusFromChipAtIndex: function (index) { 19010 _this.chips_[index].removeFocus(); 19011 }, 19012 selectChipAtIndex: function (index, selected, shouldNotifyClients) { 19013 if (index >= 0 && index < _this.chips_.length) { 19014 _this.chips_[index].setSelectedFromChipSet(selected, shouldNotifyClients); 19015 } 19016 }, 19017 }; 19018 return new MDCChipSetFoundation(adapter); 19019 }; 19020 /** 19021 * Instantiates chip components on all of the chip set's child chip elements. 19022 */ 19023 MDCChipSet.prototype.instantiateChips_ = function (chipFactory) { 19024 var chipElements = [].slice.call(this.root.querySelectorAll(CHIP_SELECTOR)); 19025 return chipElements.map(function (el) { 19026 el.id = el.id || "mdc-chip-" + ++idCounter; 19027 return chipFactory(el); 19028 }); 19029 }; 19030 /** 19031 * Returns the index of the chip with the given id, or -1 if the chip does not exist. 19032 */ 19033 MDCChipSet.prototype.findChipIndex_ = function (chipId) { 19034 for (var i = 0; i < this.chips_.length; i++) { 19035 if (this.chips_[i].id === chipId) { 19036 return i; 19037 } 19038 } 19039 return -1; 19040 }; 19041 return MDCChipSet; 19042 }(MDCComponent)); 19043 19044 /** 19045 * @license 19046 * Copyright 2019 Google Inc. 19047 * 19048 * Permission is hereby granted, free of charge, to any person obtaining a copy 19049 * of this software and associated documentation files (the "Software"), to deal 19050 * in the Software without restriction, including without limitation the rights 19051 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19052 * copies of the Software, and to permit persons to whom the Software is 19053 * furnished to do so, subject to the following conditions: 19054 * 19055 * The above copyright notice and this permission notice shall be included in 19056 * all copies or substantial portions of the Software. 19057 * 19058 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19059 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19060 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19061 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19062 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19063 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19064 * THE SOFTWARE. 19065 */ 19066 19067 /** 19068 * @license 19069 * Copyright 2019 Google Inc. 19070 * 19071 * Permission is hereby granted, free of charge, to any person obtaining a copy 19072 * of this software and associated documentation files (the "Software"), to deal 19073 * in the Software without restriction, including without limitation the rights 19074 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19075 * copies of the Software, and to permit persons to whom the Software is 19076 * furnished to do so, subject to the following conditions: 19077 * 19078 * The above copyright notice and this permission notice shall be included in 19079 * all copies or substantial portions of the Software. 19080 * 19081 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19082 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19083 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19084 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19085 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19086 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19087 * THE SOFTWARE. 19088 */ 19089 19090 /** 19091 * @license 19092 * Copyright 2018 Google Inc. 19093 * 19094 * Permission is hereby granted, free of charge, to any person obtaining a copy 19095 * of this software and associated documentation files (the "Software"), to deal 19096 * in the Software without restriction, including without limitation the rights 19097 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19098 * copies of the Software, and to permit persons to whom the Software is 19099 * furnished to do so, subject to the following conditions: 19100 * 19101 * The above copyright notice and this permission notice shall be included in 19102 * all copies or substantial portions of the Software. 19103 * 19104 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19105 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19106 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19107 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19108 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19109 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19110 * THE SOFTWARE. 19111 */
vendor: 10,762 bytes, lines 19112-19335
19112 var cssClasses$2 = { 19113 ANIMATING: 'mdc-tab-scroller--animating', 19114 SCROLL_AREA_SCROLL: 'mdc-tab-scroller__scroll-area--scroll', 19115 SCROLL_TEST: 'mdc-tab-scroller__test', 19116 }; 19117 var strings$4 = { 19118 AREA_SELECTOR: '.mdc-tab-scroller__scroll-area', 19119 CONTENT_SELECTOR: '.mdc-tab-scroller__scroll-content', 19120 }; 19121 19122 /** 19123 * @license 19124 * Copyright 2018 Google Inc. 19125 * 19126 * Permission is hereby granted, free of charge, to any person obtaining a copy 19127 * of this software and associated documentation files (the "Software"), to deal 19128 * in the Software without restriction, including without limitation the rights 19129 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19130 * copies of the Software, and to permit persons to whom the Software is 19131 * furnished to do so, subject to the following conditions: 19132 * 19133 * The above copyright notice and this permission notice shall be included in 19134 * all copies or substantial portions of the Software. 19135 * 19136 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19137 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19138 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19139 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19140 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19141 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19142 * THE SOFTWARE. 19143 */ 19144 var MDCTabScrollerRTL = /** @class */ (function () { 19145 function MDCTabScrollerRTL(adapter) { 19146 this.adapter = adapter; 19147 } 19148 return MDCTabScrollerRTL; 19149 }()); 19150 19151 /** 19152 * @license 19153 * Copyright 2018 Google Inc. 19154 * 19155 * Permission is hereby granted, free of charge, to any person obtaining a copy 19156 * of this software and associated documentation files (the "Software"), to deal 19157 * in the Software without restriction, including without limitation the rights 19158 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19159 * copies of the Software, and to permit persons to whom the Software is 19160 * furnished to do so, subject to the following conditions: 19161 * 19162 * The above copyright notice and this permission notice shall be included in 19163 * all copies or substantial portions of the Software. 19164 * 19165 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19166 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19167 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19168 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19169 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19170 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19171 * THE SOFTWARE. 19172 */ 19173 var MDCTabScrollerRTLDefault = /** @class */ (function (_super) { 19174 __extends(MDCTabScrollerRTLDefault, _super); 19175 function MDCTabScrollerRTLDefault() { 19176 return _super !== null && _super.apply(this, arguments) || this; 19177 } 19178 MDCTabScrollerRTLDefault.prototype.getScrollPositionRTL = function () { 19179 var currentScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19180 var right = this.calculateScrollEdges_().right; 19181 // Scroll values on most browsers are ints instead of floats so we round 19182 return Math.round(right - currentScrollLeft); 19183 }; 19184 MDCTabScrollerRTLDefault.prototype.scrollToRTL = function (scrollX) { 19185 var edges = this.calculateScrollEdges_(); 19186 var currentScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19187 var clampedScrollLeft = this.clampScrollValue_(edges.right - scrollX); 19188 return { 19189 finalScrollPosition: clampedScrollLeft, 19190 scrollDelta: clampedScrollLeft - currentScrollLeft, 19191 }; 19192 }; 19193 MDCTabScrollerRTLDefault.prototype.incrementScrollRTL = function (scrollX) { 19194 var currentScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19195 var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX); 19196 return { 19197 finalScrollPosition: clampedScrollLeft, 19198 scrollDelta: clampedScrollLeft - currentScrollLeft, 19199 }; 19200 }; 19201 MDCTabScrollerRTLDefault.prototype.getAnimatingScrollPosition = function (scrollX) { 19202 return scrollX; 19203 }; 19204 MDCTabScrollerRTLDefault.prototype.calculateScrollEdges_ = function () { 19205 var contentWidth = this.adapter.getScrollContentOffsetWidth(); 19206 var rootWidth = this.adapter.getScrollAreaOffsetWidth(); 19207 return { 19208 left: 0, 19209 right: contentWidth - rootWidth, 19210 }; 19211 }; 19212 MDCTabScrollerRTLDefault.prototype.clampScrollValue_ = function (scrollX) { 19213 var edges = this.calculateScrollEdges_(); 19214 return Math.min(Math.max(edges.left, scrollX), edges.right); 19215 }; 19216 return MDCTabScrollerRTLDefault; 19217 }(MDCTabScrollerRTL)); 19218 19219 /** 19220 * @license 19221 * Copyright 2018 Google Inc. 19222 * 19223 * Permission is hereby granted, free of charge, to any person obtaining a copy 19224 * of this software and associated documentation files (the "Software"), to deal 19225 * in the Software without restriction, including without limitation the rights 19226 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19227 * copies of the Software, and to permit persons to whom the Software is 19228 * furnished to do so, subject to the following conditions: 19229 * 19230 * The above copyright notice and this permission notice shall be included in 19231 * all copies or substantial portions of the Software. 19232 * 19233 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19234 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19235 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19236 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19237 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19238 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19239 * THE SOFTWARE. 19240 */ 19241 var MDCTabScrollerRTLNegative = /** @class */ (function (_super) { 19242 __extends(MDCTabScrollerRTLNegative, _super); 19243 function MDCTabScrollerRTLNegative() { 19244 return _super !== null && _super.apply(this, arguments) || this; 19245 } 19246 MDCTabScrollerRTLNegative.prototype.getScrollPositionRTL = function (translateX) { 19247 var currentScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19248 return Math.round(translateX - currentScrollLeft); 19249 }; 19250 MDCTabScrollerRTLNegative.prototype.scrollToRTL = function (scrollX) { 19251 var currentScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19252 var clampedScrollLeft = this.clampScrollValue_(-scrollX); 19253 return { 19254 finalScrollPosition: clampedScrollLeft, 19255 scrollDelta: clampedScrollLeft - currentScrollLeft, 19256 }; 19257 }; 19258 MDCTabScrollerRTLNegative.prototype.incrementScrollRTL = function (scrollX) { 19259 var currentScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19260 var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft - scrollX); 19261 return { 19262 finalScrollPosition: clampedScrollLeft, 19263 scrollDelta: clampedScrollLeft - currentScrollLeft, 19264 }; 19265 }; 19266 MDCTabScrollerRTLNegative.prototype.getAnimatingScrollPosition = function (scrollX, translateX) { 19267 return scrollX - translateX; 19268 }; 19269 MDCTabScrollerRTLNegative.prototype.calculateScrollEdges_ = function () { 19270 var contentWidth = this.adapter.getScrollContentOffsetWidth(); 19271 var rootWidth = this.adapter.getScrollAreaOffsetWidth(); 19272 return { 19273 left: rootWidth - contentWidth, 19274 right: 0, 19275 }; 19276 }; 19277 MDCTabScrollerRTLNegative.prototype.clampScrollValue_ = function (scrollX) { 19278 var edges = this.calculateScrollEdges_(); 19279 return Math.max(Math.min(edges.right, scrollX), edges.left); 19280 }; 19281 return MDCTabScrollerRTLNegative; 19282 }(MDCTabScrollerRTL)); 19283 19284 /** 19285 * @license 19286 * Copyright 2018 Google Inc. 19287 * 19288 * Permission is hereby granted, free of charge, to any person obtaining a copy 19289 * of this software and associated documentation files (the "Software"), to deal 19290 * in the Software without restriction, including without limitation the rights 19291 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19292 * copies of the Software, and to permit persons to whom the Software is 19293 * furnished to do so, subject to the following conditions: 19294 * 19295 * The above copyright notice and this permission notice shall be included in 19296 * all copies or substantial portions of the Software. 19297 * 19298 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19299 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19300 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19301 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19302 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19303 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19304 * THE SOFTWARE. 19305 */ 19306 var MDCTabScrollerRTLReverse = /** @class */ (function (_super) { 19307 __extends(MDCTabScrollerRTLReverse, _super); 19308 function MDCTabScrollerRTLReverse() { 19309 return _super !== null && _super.apply(this, arguments) || this; 19310 } 19311 MDCTabScrollerRTLReverse.prototype.getScrollPositionRTL = function (translateX) { 19312 var currentScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19313 // Scroll values on most browsers are ints instead of floats so we round 19314 return Math.round(currentScrollLeft - translateX); 19315 }; 19316 MDCTabScrollerRTLReverse.prototype.scrollToRTL = function (scrollX) { 19317 var currentScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19318 var clampedScrollLeft = this.clampScrollValue_(scrollX); 19319 return { 19320 finalScrollPosition: clampedScrollLeft, 19321 scrollDelta: currentScrollLeft - clampedScrollLeft, 19322 }; 19323 }; 19324 MDCTabScrollerRTLReverse.prototype.incrementScrollRTL = function (scrollX) { 19325 var currentScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19326 var clampedScrollLeft = this.clampScrollValue_(currentScrollLeft + scrollX); 19327 return { 19328 finalScrollPosition: clampedScrollLeft, 19329 scrollDelta: currentScrollLeft - clampedScrollLeft, 19330 }; 19331 }; 19332 MDCTabScrollerRTLReverse.prototype.getAnimatingScrollPosition = function (scrollX, translateX) { 19333 return scrollX + translateX; 19334 }; 19335 MDCTabScrollerRTLReverse.prototype.calculateScrollEdges_ = function () {
vendor: 3,159 bytes, lines 19336-19404
19336 var contentWidth = this.adapter.getScrollContentOffsetWidth(); 19337 var rootWidth = this.adapter.getScrollAreaOffsetWidth(); 19338 return { 19339 left: contentWidth - rootWidth, 19340 right: 0, 19341 }; 19342 }; 19343 MDCTabScrollerRTLReverse.prototype.clampScrollValue_ = function (scrollX) { 19344 var edges = this.calculateScrollEdges_(); 19345 return Math.min(Math.max(edges.right, scrollX), edges.left); 19346 }; 19347 return MDCTabScrollerRTLReverse; 19348 }(MDCTabScrollerRTL)); 19349 19350 /** 19351 * @license 19352 * Copyright 2018 Google Inc. 19353 * 19354 * Permission is hereby granted, free of charge, to any person obtaining a copy 19355 * of this software and associated documentation files (the "Software"), to deal 19356 * in the Software without restriction, including without limitation the rights 19357 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19358 * copies of the Software, and to permit persons to whom the Software is 19359 * furnished to do so, subject to the following conditions: 19360 * 19361 * The above copyright notice and this permission notice shall be included in 19362 * all copies or substantial portions of the Software. 19363 * 19364 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19365 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19366 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19367 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19368 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19369 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19370 * THE SOFTWARE. 19371 */ 19372 var MDCTabScrollerFoundation = /** @class */ (function (_super) { 19373 __extends(MDCTabScrollerFoundation, _super); 19374 function MDCTabScrollerFoundation(adapter) { 19375 var _this = _super.call(this, __assign(__assign({}, MDCTabScrollerFoundation.defaultAdapter), adapter)) || this; 19376 /** 19377 * Controls whether we should handle the transitionend and interaction events during the animation. 19378 */ 19379 _this.isAnimating_ = false; 19380 return _this; 19381 } 19382 Object.defineProperty(MDCTabScrollerFoundation, "cssClasses", { 19383 get: function () { 19384 return cssClasses$2; 19385 }, 19386 enumerable: true, 19387 configurable: true 19388 }); 19389 Object.defineProperty(MDCTabScrollerFoundation, "strings", { 19390 get: function () { 19391 return strings$4; 19392 }, 19393 enumerable: true, 19394 configurable: true 19395 }); 19396 Object.defineProperty(MDCTabScrollerFoundation, "defaultAdapter", { 19397 get: function () { 19398 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 19399 return { 19400 eventTargetMatchesSelector: function () { return false; }, 19401 addClass: function () { return undefined; }, 19402 removeClass: function () { return undefined; }, 19403 addScrollAreaClass: function () { return undefined; }, 19404 setScrollAreaStyleProperty: function () { return undefined; },
vendor: 8,998 bytes, lines 19405-19602
19405 setScrollContentStyleProperty: function () { return undefined; }, 19406 getScrollContentStyleValue: function () { return ''; }, 19407 setScrollAreaScrollLeft: function () { return undefined; }, 19408 getScrollAreaScrollLeft: function () { return 0; }, 19409 getScrollContentOffsetWidth: function () { return 0; }, 19410 getScrollAreaOffsetWidth: function () { return 0; }, 19411 computeScrollAreaClientRect: function () { return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 }); }, 19412 computeScrollContentClientRect: function () { return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 }); }, 19413 computeHorizontalScrollbarHeight: function () { return 0; }, 19414 }; 19415 // tslint:enable:object-literal-sort-keys 19416 }, 19417 enumerable: true, 19418 configurable: true 19419 }); 19420 MDCTabScrollerFoundation.prototype.init = function () { 19421 // Compute horizontal scrollbar height on scroller with overflow initially hidden, then update overflow to scroll 19422 // and immediately adjust bottom margin to avoid the scrollbar initially appearing before JS runs. 19423 var horizontalScrollbarHeight = this.adapter.computeHorizontalScrollbarHeight(); 19424 this.adapter.setScrollAreaStyleProperty('margin-bottom', -horizontalScrollbarHeight + 'px'); 19425 this.adapter.addScrollAreaClass(MDCTabScrollerFoundation.cssClasses.SCROLL_AREA_SCROLL); 19426 }; 19427 /** 19428 * Computes the current visual scroll position 19429 */ 19430 MDCTabScrollerFoundation.prototype.getScrollPosition = function () { 19431 if (this.isRTL_()) { 19432 return this.computeCurrentScrollPositionRTL_(); 19433 } 19434 var currentTranslateX = this.calculateCurrentTranslateX_(); 19435 var scrollLeft = this.adapter.getScrollAreaScrollLeft(); 19436 return scrollLeft - currentTranslateX; 19437 }; 19438 /** 19439 * Handles interaction events that occur during transition 19440 */ 19441 MDCTabScrollerFoundation.prototype.handleInteraction = function () { 19442 // Early exit if we aren't animating 19443 if (!this.isAnimating_) { 19444 return; 19445 } 19446 // Prevent other event listeners from handling this event 19447 this.stopScrollAnimation_(); 19448 }; 19449 /** 19450 * Handles the transitionend event 19451 */ 19452 MDCTabScrollerFoundation.prototype.handleTransitionEnd = function (evt) { 19453 // Early exit if we aren't animating or the event was triggered by a different element. 19454 var evtTarget = evt.target; 19455 if (!this.isAnimating_ || 19456 !this.adapter.eventTargetMatchesSelector(evtTarget, MDCTabScrollerFoundation.strings.CONTENT_SELECTOR)) { 19457 return; 19458 } 19459 this.isAnimating_ = false; 19460 this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING); 19461 }; 19462 /** 19463 * Increment the scroll value by the scrollXIncrement using animation. 19464 * @param scrollXIncrement The value by which to increment the scroll position 19465 */ 19466 MDCTabScrollerFoundation.prototype.incrementScroll = function (scrollXIncrement) { 19467 // Early exit for non-operational increment values 19468 if (scrollXIncrement === 0) { 19469 return; 19470 } 19471 this.animate_(this.getIncrementScrollOperation_(scrollXIncrement)); 19472 }; 19473 /** 19474 * Increment the scroll value by the scrollXIncrement without animation. 19475 * @param scrollXIncrement The value by which to increment the scroll position 19476 */ 19477 MDCTabScrollerFoundation.prototype.incrementScrollImmediate = function (scrollXIncrement) { 19478 // Early exit for non-operational increment values 19479 if (scrollXIncrement === 0) { 19480 return; 19481 } 19482 var operation = this.getIncrementScrollOperation_(scrollXIncrement); 19483 if (operation.scrollDelta === 0) { 19484 return; 19485 } 19486 this.stopScrollAnimation_(); 19487 this.adapter.setScrollAreaScrollLeft(operation.finalScrollPosition); 19488 }; 19489 /** 19490 * Scrolls to the given scrollX value 19491 */ 19492 MDCTabScrollerFoundation.prototype.scrollTo = function (scrollX) { 19493 if (this.isRTL_()) { 19494 return this.scrollToRTL_(scrollX); 19495 } 19496 this.scrollTo_(scrollX); 19497 }; 19498 /** 19499 * @return Browser-specific {@link MDCTabScrollerRTL} instance. 19500 */ 19501 MDCTabScrollerFoundation.prototype.getRTLScroller = function () { 19502 if (!this.rtlScrollerInstance_) { 19503 this.rtlScrollerInstance_ = this.rtlScrollerFactory_(); 19504 } 19505 return this.rtlScrollerInstance_; 19506 }; 19507 /** 19508 * @return translateX value from a CSS matrix transform function string. 19509 */ 19510 MDCTabScrollerFoundation.prototype.calculateCurrentTranslateX_ = function () { 19511 var transformValue = this.adapter.getScrollContentStyleValue('transform'); 19512 // Early exit if no transform is present 19513 if (transformValue === 'none') { 19514 return 0; 19515 } 19516 // The transform value comes back as a matrix transformation in the form 19517 // of `matrix(a, b, c, d, tx, ty)`. We only care about tx (translateX) so 19518 // we're going to grab all the parenthesized values, strip out tx, and 19519 // parse it. 19520 var match = /\((.+?)\)/.exec(transformValue); 19521 if (!match) { 19522 return 0; 19523 } 19524 var matrixParams = match[1]; 19525 // tslint:disable-next-line:ban-ts-ignore "Unused vars" should be a linter warning, not a compiler error. 19526 // @ts-ignore These unused variables should retain their semantic names for clarity. 19527 var _a = __read(matrixParams.split(','), 6), a = _a[0], b = _a[1], c = _a[2], d = _a[3], tx = _a[4], ty = _a[5]; 19528 return parseFloat(tx); // tslint:disable-line:ban 19529 }; 19530 /** 19531 * Calculates a safe scroll value that is > 0 and < the max scroll value 19532 * @param scrollX The distance to scroll 19533 */ 19534 MDCTabScrollerFoundation.prototype.clampScrollValue_ = function (scrollX) { 19535 var edges = this.calculateScrollEdges_(); 19536 return Math.min(Math.max(edges.left, scrollX), edges.right); 19537 }; 19538 MDCTabScrollerFoundation.prototype.computeCurrentScrollPositionRTL_ = function () { 19539 var translateX = this.calculateCurrentTranslateX_(); 19540 return this.getRTLScroller().getScrollPositionRTL(translateX); 19541 }; 19542 MDCTabScrollerFoundation.prototype.calculateScrollEdges_ = function () { 19543 var contentWidth = this.adapter.getScrollContentOffsetWidth(); 19544 var rootWidth = this.adapter.getScrollAreaOffsetWidth(); 19545 return { 19546 left: 0, 19547 right: contentWidth - rootWidth, 19548 }; 19549 }; 19550 /** 19551 * Internal scroll method 19552 * @param scrollX The new scroll position 19553 */ 19554 MDCTabScrollerFoundation.prototype.scrollTo_ = function (scrollX) { 19555 var currentScrollX = this.getScrollPosition(); 19556 var safeScrollX = this.clampScrollValue_(scrollX); 19557 var scrollDelta = safeScrollX - currentScrollX; 19558 this.animate_({ 19559 finalScrollPosition: safeScrollX, 19560 scrollDelta: scrollDelta, 19561 }); 19562 }; 19563 /** 19564 * Internal RTL scroll method 19565 * @param scrollX The new scroll position 19566 */ 19567 MDCTabScrollerFoundation.prototype.scrollToRTL_ = function (scrollX) { 19568 var animation = this.getRTLScroller().scrollToRTL(scrollX); 19569 this.animate_(animation); 19570 }; 19571 /** 19572 * Internal method to compute the increment scroll operation values. 19573 * @param scrollX The desired scroll position increment 19574 * @return MDCTabScrollerAnimation with the sanitized values for performing the scroll operation. 19575 */ 19576 MDCTabScrollerFoundation.prototype.getIncrementScrollOperation_ = function (scrollX) { 19577 if (this.isRTL_()) { 19578 return this.getRTLScroller().incrementScrollRTL(scrollX); 19579 } 19580 var currentScrollX = this.getScrollPosition(); 19581 var targetScrollX = scrollX + currentScrollX; 19582 var safeScrollX = this.clampScrollValue_(targetScrollX); 19583 var scrollDelta = safeScrollX - currentScrollX; 19584 return { 19585 finalScrollPosition: safeScrollX, 19586 scrollDelta: scrollDelta, 19587 }; 19588 }; 19589 /** 19590 * Animates the tab scrolling 19591 * @param animation The animation to apply 19592 */ 19593 MDCTabScrollerFoundation.prototype.animate_ = function (animation) { 19594 var _this = this; 19595 // Early exit if translateX is 0, which means there's no animation to perform 19596 if (animation.scrollDelta === 0) { 19597 return; 19598 } 19599 this.stopScrollAnimation_(); 19600 // This animation uses the FLIP approach. 19601 // Read more here: https://aerotwist.com/blog/flip-your-animations/ 19602 this.adapter.setScrollAreaScrollLeft(animation.finalScrollPosition);
vendor: 5,783 bytes, lines 19603-19720
19603 this.adapter.setScrollContentStyleProperty('transform', "translateX(" + animation.scrollDelta + "px)"); 19604 // Force repaint 19605 this.adapter.computeScrollAreaClientRect(); 19606 requestAnimationFrame(function () { 19607 _this.adapter.addClass(MDCTabScrollerFoundation.cssClasses.ANIMATING); 19608 _this.adapter.setScrollContentStyleProperty('transform', 'none'); 19609 }); 19610 this.isAnimating_ = true; 19611 }; 19612 /** 19613 * Stops scroll animation 19614 */ 19615 MDCTabScrollerFoundation.prototype.stopScrollAnimation_ = function () { 19616 this.isAnimating_ = false; 19617 var currentScrollPosition = this.getAnimatingScrollPosition_(); 19618 this.adapter.removeClass(MDCTabScrollerFoundation.cssClasses.ANIMATING); 19619 this.adapter.setScrollContentStyleProperty('transform', 'translateX(0px)'); 19620 this.adapter.setScrollAreaScrollLeft(currentScrollPosition); 19621 }; 19622 /** 19623 * Gets the current scroll position during animation 19624 */ 19625 MDCTabScrollerFoundation.prototype.getAnimatingScrollPosition_ = function () { 19626 var currentTranslateX = this.calculateCurrentTranslateX_(); 19627 var scrollLeft = this.adapter.getScrollAreaScrollLeft(); 19628 if (this.isRTL_()) { 19629 return this.getRTLScroller().getAnimatingScrollPosition(scrollLeft, currentTranslateX); 19630 } 19631 return scrollLeft - currentTranslateX; 19632 }; 19633 /** 19634 * Determines the RTL Scroller to use 19635 */ 19636 MDCTabScrollerFoundation.prototype.rtlScrollerFactory_ = function () { 19637 // Browsers have three different implementations of scrollLeft in RTL mode, 19638 // dependent on the browser. The behavior is based off the max LTR 19639 // scrollLeft value and 0. 19640 // 19641 // * Default scrolling in RTL * 19642 // - Left-most value: 0 19643 // - Right-most value: Max LTR scrollLeft value 19644 // 19645 // * Negative scrolling in RTL * 19646 // - Left-most value: Negated max LTR scrollLeft value 19647 // - Right-most value: 0 19648 // 19649 // * Reverse scrolling in RTL * 19650 // - Left-most value: Max LTR scrollLeft value 19651 // - Right-most value: 0 19652 // 19653 // We use those principles below to determine which RTL scrollLeft 19654 // behavior is implemented in the current browser. 19655 var initialScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19656 this.adapter.setScrollAreaScrollLeft(initialScrollLeft - 1); 19657 var newScrollLeft = this.adapter.getScrollAreaScrollLeft(); 19658 // If the newScrollLeft value is negative,then we know that the browser has 19659 // implemented negative RTL scrolling, since all other implementations have 19660 // only positive values. 19661 if (newScrollLeft < 0) { 19662 // Undo the scrollLeft test check 19663 this.adapter.setScrollAreaScrollLeft(initialScrollLeft); 19664 return new MDCTabScrollerRTLNegative(this.adapter); 19665 } 19666 var rootClientRect = this.adapter.computeScrollAreaClientRect(); 19667 var contentClientRect = this.adapter.computeScrollContentClientRect(); 19668 var rightEdgeDelta = Math.round(contentClientRect.right - rootClientRect.right); 19669 // Undo the scrollLeft test check 19670 this.adapter.setScrollAreaScrollLeft(initialScrollLeft); 19671 // By calculating the clientRect of the root element and the clientRect of 19672 // the content element, we can determine how much the scroll value changed 19673 // when we performed the scrollLeft subtraction above. 19674 if (rightEdgeDelta === newScrollLeft) { 19675 return new MDCTabScrollerRTLReverse(this.adapter); 19676 } 19677 return new MDCTabScrollerRTLDefault(this.adapter); 19678 }; 19679 MDCTabScrollerFoundation.prototype.isRTL_ = function () { 19680 return this.adapter.getScrollContentStyleValue('direction') === 'rtl'; 19681 }; 19682 return MDCTabScrollerFoundation; 19683 }(MDCFoundation)); 19684 19685 /** 19686 * @license 19687 * Copyright 2018 Google Inc. 19688 * 19689 * Permission is hereby granted, free of charge, to any person obtaining a copy 19690 * of this software and associated documentation files (the "Software"), to deal 19691 * in the Software without restriction, including without limitation the rights 19692 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19693 * copies of the Software, and to permit persons to whom the Software is 19694 * furnished to do so, subject to the following conditions: 19695 * 19696 * The above copyright notice and this permission notice shall be included in 19697 * all copies or substantial portions of the Software. 19698 * 19699 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19700 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19701 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19702 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19703 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19704 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19705 * THE SOFTWARE. 19706 */ 19707 /** 19708 * Stores result from computeHorizontalScrollbarHeight to avoid redundant processing. 19709 */ 19710 var horizontalScrollbarHeight_; 19711 /** 19712 * Computes the height of browser-rendered horizontal scrollbars using a self-created test element. 19713 * May return 0 (e.g. on OS X browsers under default configuration). 19714 */ 19715 function computeHorizontalScrollbarHeight(documentObj, shouldCacheResult) { 19716 if (shouldCacheResult === void 0) { shouldCacheResult = true; } 19717 if (shouldCacheResult && typeof horizontalScrollbarHeight_ !== 'undefined') { 19718 return horizontalScrollbarHeight_; 19719 } 19720 var el = documentObj.createElement('div');
vendor: 4,628 bytes, lines 19721-19799
19721 el.classList.add(cssClasses$2.SCROLL_TEST); 19722 documentObj.body.appendChild(el); 19723 var horizontalScrollbarHeight = el.offsetHeight - el.clientHeight; 19724 documentObj.body.removeChild(el); 19725 if (shouldCacheResult) { 19726 horizontalScrollbarHeight_ = horizontalScrollbarHeight; 19727 } 19728 return horizontalScrollbarHeight; 19729 } 19730 19731 /** 19732 * @license 19733 * Copyright 2018 Google Inc. 19734 * 19735 * Permission is hereby granted, free of charge, to any person obtaining a copy 19736 * of this software and associated documentation files (the "Software"), to deal 19737 * in the Software without restriction, including without limitation the rights 19738 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19739 * copies of the Software, and to permit persons to whom the Software is 19740 * furnished to do so, subject to the following conditions: 19741 * 19742 * The above copyright notice and this permission notice shall be included in 19743 * all copies or substantial portions of the Software. 19744 * 19745 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19746 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19747 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19748 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19749 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19750 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19751 * THE SOFTWARE. 19752 */ 19753 var MDCTabScroller = /** @class */ (function (_super) { 19754 __extends(MDCTabScroller, _super); 19755 function MDCTabScroller() { 19756 return _super !== null && _super.apply(this, arguments) || this; 19757 } 19758 MDCTabScroller.attachTo = function (root) { 19759 return new MDCTabScroller(root); 19760 }; 19761 MDCTabScroller.prototype.initialize = function () { 19762 this.area_ = this.root.querySelector(MDCTabScrollerFoundation.strings.AREA_SELECTOR); 19763 this.content_ = this.root.querySelector(MDCTabScrollerFoundation.strings.CONTENT_SELECTOR); 19764 }; 19765 MDCTabScroller.prototype.initialSyncWithDOM = function () { 19766 var _this = this; 19767 this.handleInteraction_ = function () { return _this.foundation.handleInteraction(); }; 19768 this.handleTransitionEnd_ = function (evt) { return _this.foundation.handleTransitionEnd(evt); }; 19769 this.area_.addEventListener('wheel', this.handleInteraction_, applyPassive()); 19770 this.area_.addEventListener('touchstart', this.handleInteraction_, applyPassive()); 19771 this.area_.addEventListener('pointerdown', this.handleInteraction_, applyPassive()); 19772 this.area_.addEventListener('mousedown', this.handleInteraction_, applyPassive()); 19773 this.area_.addEventListener('keydown', this.handleInteraction_, applyPassive()); 19774 this.content_.addEventListener('transitionend', this.handleTransitionEnd_); 19775 }; 19776 MDCTabScroller.prototype.destroy = function () { 19777 _super.prototype.destroy.call(this); 19778 this.area_.removeEventListener('wheel', this.handleInteraction_, applyPassive()); 19779 this.area_.removeEventListener('touchstart', this.handleInteraction_, applyPassive()); 19780 this.area_.removeEventListener('pointerdown', this.handleInteraction_, applyPassive()); 19781 this.area_.removeEventListener('mousedown', this.handleInteraction_, applyPassive()); 19782 this.area_.removeEventListener('keydown', this.handleInteraction_, applyPassive()); 19783 this.content_.removeEventListener('transitionend', this.handleTransitionEnd_); 19784 }; 19785 MDCTabScroller.prototype.getDefaultFoundation = function () { 19786 var _this = this; 19787 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 19788 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 19789 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 19790 var adapter = { 19791 eventTargetMatchesSelector: function (evtTarget, selector) { 19792 return matches$1(evtTarget, selector); 19793 }, 19794 addClass: function (className) { return _this.root.classList.add(className); }, 19795 removeClass: function (className) { return _this.root.classList.remove(className); }, 19796 addScrollAreaClass: function (className) { return _this.area_.classList.add(className); }, 19797 setScrollAreaStyleProperty: function (prop, value) { 19798 return _this.area_.style.setProperty(prop, value); 19799 },
19800 setScrollContentStyleProperty: function (prop, value) { 19801 return _this.content_.style.setProperty(prop, value); 19802 }, 19803 getScrollContentStyleValue: function (propName) { 19804 return window.getComputedStyle(_this.content_).getPropertyValue(propName); 19805 }, 19806 setScrollAreaScrollLeft: function (scrollX) { return _this.area_.scrollLeft = scrollX; }, 19807 getScrollAreaScrollLeft: function () { return _this.area_.scrollLeft; }, 19808 getScrollContentOffsetWidth: function () { return _this.content_.offsetWidth; }, 19809 getScrollAreaOffsetWidth: function () { return _this.area_.offsetWidth; }, 19810 computeScrollAreaClientRect: function () { return _this.area_.getBoundingClientRect(); }, 19811 computeScrollContentClientRect: function () { 19812 return _this.content_.getBoundingClientRect(); 19813 }, 19814 computeHorizontalScrollbarHeight: function () { 19815 return computeHorizontalScrollbarHeight(document); 19816 }, 19817 }; 19818 // tslint:enable:object-literal-sort-keys 19819 return new MDCTabScrollerFoundation(adapter); 19820 }; 19821 /** 19822 * Returns the current visual scroll position 19823 */ 19824 MDCTabScroller.prototype.getScrollPosition = function () { 19825 return this.foundation.getScrollPosition(); 19826 }; 19827 /** 19828 * Returns the width of the scroll content 19829 */ 19830 MDCTabScroller.prototype.getScrollContentWidth = function () { 19831 return this.content_.offsetWidth; 19832 }; 19833 /** 19834 * Increments the scroll value by the given amount 19835 * @param scrollXIncrement The pixel value by which to increment the scroll value 19836 */ 19837 MDCTabScroller.prototype.incrementScroll = function (scrollXIncrement) { 19838 this.foundation.incrementScroll(scrollXIncrement); 19839 }; 19840 /** 19841 * Scrolls to the given pixel position 19842 * @param scrollX The pixel value to scroll to 19843 */ 19844 MDCTabScroller.prototype.scrollTo = function (scrollX) { 19845 this.foundation.scrollTo(scrollX); 19846 }; 19847 return MDCTabScroller; 19848 }(MDCComponent)); 19849 19850 /** 19851 * @license 19852 * Copyright 2018 Google Inc. 19853 * 19854 * Permission is hereby granted, free of charge, to any person obtaining a copy 19855 * of this software and associated documentation files (the "Software"), to deal 19856 * in the Software without restriction, including without limitation the rights 19857 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19858 * copies of the Software, and to permit persons to whom the Software is 19859 * furnished to do so, subject to the following conditions: 19860 * 19861 * The above copyright notice and this permission notice shall be included in 19862 * all copies or substantial portions of the Software. 19863 * 19864 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19865 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19866 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19867 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19868 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19869 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19870 * THE SOFTWARE. 19871 */
vendor: 4,635 bytes, lines 19872-19971
19872 var cssClasses$1 = { 19873 ACTIVE: 'mdc-tab-indicator--active', 19874 FADE: 'mdc-tab-indicator--fade', 19875 NO_TRANSITION: 'mdc-tab-indicator--no-transition', 19876 }; 19877 var strings$3 = { 19878 CONTENT_SELECTOR: '.mdc-tab-indicator__content', 19879 }; 19880 19881 /** 19882 * @license 19883 * Copyright 2018 Google Inc. 19884 * 19885 * Permission is hereby granted, free of charge, to any person obtaining a copy 19886 * of this software and associated documentation files (the "Software"), to deal 19887 * in the Software without restriction, including without limitation the rights 19888 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19889 * copies of the Software, and to permit persons to whom the Software is 19890 * furnished to do so, subject to the following conditions: 19891 * 19892 * The above copyright notice and this permission notice shall be included in 19893 * all copies or substantial portions of the Software. 19894 * 19895 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19896 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19897 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19898 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19899 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19900 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19901 * THE SOFTWARE. 19902 */ 19903 var MDCTabIndicatorFoundation = /** @class */ (function (_super) { 19904 __extends(MDCTabIndicatorFoundation, _super); 19905 function MDCTabIndicatorFoundation(adapter) { 19906 return _super.call(this, __assign(__assign({}, MDCTabIndicatorFoundation.defaultAdapter), adapter)) || this; 19907 } 19908 Object.defineProperty(MDCTabIndicatorFoundation, "cssClasses", { 19909 get: function () { 19910 return cssClasses$1; 19911 }, 19912 enumerable: true, 19913 configurable: true 19914 }); 19915 Object.defineProperty(MDCTabIndicatorFoundation, "strings", { 19916 get: function () { 19917 return strings$3; 19918 }, 19919 enumerable: true, 19920 configurable: true 19921 }); 19922 Object.defineProperty(MDCTabIndicatorFoundation, "defaultAdapter", { 19923 get: function () { 19924 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 19925 return { 19926 addClass: function () { return undefined; }, 19927 removeClass: function () { return undefined; }, 19928 computeContentClientRect: function () { return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 }); }, 19929 setContentStyleProperty: function () { return undefined; }, 19930 }; 19931 // tslint:enable:object-literal-sort-keys 19932 }, 19933 enumerable: true, 19934 configurable: true 19935 }); 19936 MDCTabIndicatorFoundation.prototype.computeContentClientRect = function () { 19937 return this.adapter.computeContentClientRect(); 19938 }; 19939 return MDCTabIndicatorFoundation; 19940 }(MDCFoundation)); 19941 19942 /** 19943 * @license 19944 * Copyright 2018 Google Inc. 19945 * 19946 * Permission is hereby granted, free of charge, to any person obtaining a copy 19947 * of this software and associated documentation files (the "Software"), to deal 19948 * in the Software without restriction, including without limitation the rights 19949 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19950 * copies of the Software, and to permit persons to whom the Software is 19951 * furnished to do so, subject to the following conditions: 19952 * 19953 * The above copyright notice and this permission notice shall be included in 19954 * all copies or substantial portions of the Software. 19955 * 19956 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19957 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19958 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19959 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19960 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19961 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19962 * THE SOFTWARE. 19963 */ 19964 /* istanbul ignore next: subclass is not a branch statement */ 19965 var MDCFadingTabIndicatorFoundation = /** @class */ (function (_super) { 19966 __extends(MDCFadingTabIndicatorFoundation, _super); 19967 function MDCFadingTabIndicatorFoundation() { 19968 return _super !== null && _super.apply(this, arguments) || this; 19969 } 19970 MDCFadingTabIndicatorFoundation.prototype.activate = function () { 19971 this.adapter.addClass(MDCTabIndicatorFoundation.cssClasse
vendor: 6,273 bytes, lines 19971-20084
19971s.ACTIVE); 19972 }; 19973 MDCFadingTabIndicatorFoundation.prototype.deactivate = function () { 19974 this.adapter.removeClass(MDCTabIndicatorFoundation.cssClasses.ACTIVE); 19975 }; 19976 return MDCFadingTabIndicatorFoundation; 19977 }(MDCTabIndicatorFoundation)); 19978 19979 /** 19980 * @license 19981 * Copyright 2018 Google Inc. 19982 * 19983 * Permission is hereby granted, free of charge, to any person obtaining a copy 19984 * of this software and associated documentation files (the "Software"), to deal 19985 * in the Software without restriction, including without limitation the rights 19986 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 19987 * copies of the Software, and to permit persons to whom the Software is 19988 * furnished to do so, subject to the following conditions: 19989 * 19990 * The above copyright notice and this permission notice shall be included in 19991 * all copies or substantial portions of the Software. 19992 * 19993 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19994 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19995 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19996 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19997 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19998 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19999 * THE SOFTWARE. 20000 */ 20001 /* istanbul ignore next: subclass is not a branch statement */ 20002 var MDCSlidingTabIndicatorFoundation = /** @class */ (function (_super) { 20003 __extends(MDCSlidingTabIndicatorFoundation, _super); 20004 function MDCSlidingTabIndicatorFoundation() { 20005 return _super !== null && _super.apply(this, arguments) || this; 20006 } 20007 MDCSlidingTabIndicatorFoundation.prototype.activate = function (previousIndicatorClientRect) { 20008 // Early exit if no indicator is present to handle cases where an indicator 20009 // may be activated without a prior indicator state 20010 if (!previousIndicatorClientRect) { 20011 this.adapter.addClass(MDCTabIndicatorFoundation.cssClasses.ACTIVE); 20012 return; 20013 } 20014 // This animation uses the FLIP approach. You can read more about it at the link below: 20015 // https://aerotwist.com/blog/flip-your-animations/ 20016 // Calculate the dimensions based on the dimensions of the previous indicator 20017 var currentClientRect = this.computeContentClientRect(); 20018 var widthDelta = previousIndicatorClientRect.width / currentClientRect.width; 20019 var xPosition = previousIndicatorClientRect.left - currentClientRect.left; 20020 this.adapter.addClass(MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION); 20021 this.adapter.setContentStyleProperty('transform', "translateX(" + xPosition + "px) scaleX(" + widthDelta + ")"); 20022 // Force repaint before updating classes and transform to ensure the transform properly takes effect 20023 this.computeContentClientRect(); 20024 this.adapter.removeClass(MDCTabIndicatorFoundation.cssClasses.NO_TRANSITION); 20025 this.adapter.addClass(MDCTabIndicatorFoundation.cssClasses.ACTIVE); 20026 this.adapter.setContentStyleProperty('transform', ''); 20027 }; 20028 MDCSlidingTabIndicatorFoundation.prototype.deactivate = function () { 20029 this.adapter.removeClass(MDCTabIndicatorFoundation.cssClasses.ACTIVE); 20030 }; 20031 return MDCSlidingTabIndicatorFoundation; 20032 }(MDCTabIndicatorFoundation)); 20033 20034 /** 20035 * @license 20036 * Copyright 2018 Google Inc. 20037 * 20038 * Permission is hereby granted, free of charge, to any person obtaining a copy 20039 * of this software and associated documentation files (the "Software"), to deal 20040 * in the Software without restriction, including without limitation the rights 20041 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20042 * copies of the Software, and to permit persons to whom the Software is 20043 * furnished to do so, subject to the following conditions: 20044 * 20045 * The above copyright notice and this permission notice shall be included in 20046 * all copies or substantial portions of the Software. 20047 * 20048 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20049 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20050 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20051 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20052 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20053 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20054 * THE SOFTWARE. 20055 */ 20056 var MDCTabIndicator = /** @class */ (function (_super) { 20057 __extends(MDCTabIndicator, _super); 20058 function MDCTabIndicator() { 20059 return _super !== null && _super.apply(this, arguments) || this; 20060 } 20061 MDCTabIndicator.attachTo = function (root) { 20062 return new MDCTabIndicator(root); 20063 }; 20064 MDCTabIndicator.prototype.initialize = function () { 20065 this.content_ = this.root.querySelector(MDCTabIndicatorFoundation.strings.CONTENT_SELECTOR); 20066 }; 20067 MDCTabIndicator.prototype.computeContentClientRect = function () { 20068 return this.foundation.computeContentClientRect(); 20069 }; 20070 MDCTabIndicator.prototype.getDefaultFoundation = function () { 20071 var _this = this; 20072 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 20073 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 20074 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 20075 var adapter = { 20076 addClass: function (className) { return _this.root.classList.add(className); }, 20077 removeClass: function (className) { return _this.root.classList.remove(className); }, 20078 computeContentClientRect: function () { return _this.content_.getBoundingClientRect(); }, 20079 setContentStyleProperty: function (prop, value) { 20080 return _this.content_.style.setProperty(prop, value); 20081 }, 20082 }; 20083 // tslint:enable:object-literal-sort-keys 20084 if (this.root.classList.contains(MDCTabIndicatorFoundation.cssClasse
20084s.FADE)) { 20085 return new MDCFadingTabIndicatorFoundation(adapter); 20086 } 20087 // Default to the sliding indicator 20088 return new MDCSlidingTabIndicatorFoundation(adapter); 20089 }; 20090 MDCTabIndicator.prototype.activate = function (previousIndicatorClientRect) { 20091 this.foundation.activate(previousIndicatorClientRect); 20092 }; 20093 MDCTabIndicator.prototype.deactivate = function () { 20094 this.foundation.deactivate(); 20095 }; 20096 return MDCTabIndicator; 20097 }(MDCComponent)); 20098 20099 /** 20100 * @license 20101 * Copyright 2018 Google Inc. 20102 * 20103 * Permission is hereby granted, free of charge, to any person obtaining a copy 20104 * of this software and associated documentation files (the "Software"), to deal 20105 * in the Software without restriction, including without limitation the rights 20106 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20107 * copies of the Software, and to permit persons to whom the Software is 20108 * furnished to do so, subject to the following conditions: 20109 * 20110 * The above copyright notice and this permission notice shall be included in 20111 * all copies or substantial portions of the Software. 20112 * 20113 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20114 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20115 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20116 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20117 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20118 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20119 * THE SOFTWARE. 20120 */
vendor: 4,069 bytes, lines 20121-20215
20121 var cssClasses = { 20122 ACTIVE: 'mdc-tab--active', 20123 }; 20124 var strings$2 = { 20125 ARIA_SELECTED: 'aria-selected', 20126 CONTENT_SELECTOR: '.mdc-tab__content', 20127 INTERACTED_EVENT: 'MDCTab:interacted', 20128 RIPPLE_SELECTOR: '.mdc-tab__ripple', 20129 TABINDEX: 'tabIndex', 20130 TAB_INDICATOR_SELECTOR: '.mdc-tab-indicator', 20131 }; 20132 20133 /** 20134 * @license 20135 * Copyright 2018 Google Inc. 20136 * 20137 * Permission is hereby granted, free of charge, to any person obtaining a copy 20138 * of this software and associated documentation files (the "Software"), to deal 20139 * in the Software without restriction, including without limitation the rights 20140 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20141 * copies of the Software, and to permit persons to whom the Software is 20142 * furnished to do so, subject to the following conditions: 20143 * 20144 * The above copyright notice and this permission notice shall be included in 20145 * all copies or substantial portions of the Software. 20146 * 20147 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20148 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20149 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20150 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20151 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20152 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20153 * THE SOFTWARE. 20154 */ 20155 var MDCTabFoundation = /** @class */ (function (_super) { 20156 __extends(MDCTabFoundation, _super); 20157 function MDCTabFoundation(adapter) { 20158 var _this = _super.call(this, __assign(__assign({}, MDCTabFoundation.defaultAdapter), adapter)) || this; 20159 _this.focusOnActivate_ = true; 20160 return _this; 20161 } 20162 Object.defineProperty(MDCTabFoundation, "cssClasses", { 20163 get: function () { 20164 return cssClasses; 20165 }, 20166 enumerable: true, 20167 configurable: true 20168 }); 20169 Object.defineProperty(MDCTabFoundation, "strings", { 20170 get: function () { 20171 return strings$2; 20172 }, 20173 enumerable: true, 20174 configurable: true 20175 }); 20176 Object.defineProperty(MDCTabFoundation, "defaultAdapter", { 20177 get: function () { 20178 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 20179 return { 20180 addClass: function () { return undefined; }, 20181 removeClass: function () { return undefined; }, 20182 hasClass: function () { return false; }, 20183 setAttr: function () { return undefined; }, 20184 activateIndicator: function () { return undefined; }, 20185 deactivateIndicator: function () { return undefined; }, 20186 notifyInteracted: function () { return undefined; }, 20187 getOffsetLeft: function () { return 0; }, 20188 getOffsetWidth: function () { return 0; }, 20189 getContentOffsetLeft: function () { return 0; }, 20190 getContentOffsetWidth: function () { return 0; }, 20191 focus: function () { return undefined; }, 20192 }; 20193 // tslint:enable:object-literal-sort-keys 20194 }, 20195 enumerable: true, 20196 configurable: true 20197 }); 20198 MDCTabFoundation.prototype.handleClick = function () { 20199 // It's up to the parent component to keep track of the active Tab and 20200 // ensure we don't activate a Tab that's already active. 20201 this.adapter.notifyInteracted(); 20202 }; 20203 MDCTabFoundation.prototype.isActive = function () { 20204 return this.adapter.hasClass(cssClasses.ACTIVE); 20205 }; 20206 /** 20207 * Sets whether the tab should focus itself when activated 20208 */ 20209 MDCTabFoundation.prototype.setFocusOnActivate = function (focusOnActivate) { 20210 this.focusOnActivate_ = focusOnActivate; 20211 }; 20212 /** 20213 * Activates the Tab 20214 */ 20215 MDCTabFoundation.prototype.activate = function (previousIndicatorClientRect) {
vendor: 5,585 bytes, lines 20216-20320
20216 this.adapter.addClass(cssClasses.ACTIVE); 20217 this.adapter.setAttr(strings$2.ARIA_SELECTED, 'true'); 20218 this.adapter.setAttr(strings$2.TABINDEX, '0'); 20219 this.adapter.activateIndicator(previousIndicatorClientRect); 20220 if (this.focusOnActivate_) { 20221 this.adapter.focus(); 20222 } 20223 }; 20224 /** 20225 * Deactivates the Tab 20226 */ 20227 MDCTabFoundation.prototype.deactivate = function () { 20228 // Early exit 20229 if (!this.isActive()) { 20230 return; 20231 } 20232 this.adapter.removeClass(cssClasses.ACTIVE); 20233 this.adapter.setAttr(strings$2.ARIA_SELECTED, 'false'); 20234 this.adapter.setAttr(strings$2.TABINDEX, '-1'); 20235 this.adapter.deactivateIndicator(); 20236 }; 20237 /** 20238 * Returns the dimensions of the Tab 20239 */ 20240 MDCTabFoundation.prototype.computeDimensions = function () { 20241 var rootWidth = this.adapter.getOffsetWidth(); 20242 var rootLeft = this.adapter.getOffsetLeft(); 20243 var contentWidth = this.adapter.getContentOffsetWidth(); 20244 var contentLeft = this.adapter.getContentOffsetLeft(); 20245 return { 20246 contentLeft: rootLeft + contentLeft, 20247 contentRight: rootLeft + contentLeft + contentWidth, 20248 rootLeft: rootLeft, 20249 rootRight: rootLeft + rootWidth, 20250 }; 20251 }; 20252 return MDCTabFoundation; 20253 }(MDCFoundation)); 20254 20255 /** 20256 * @license 20257 * Copyright 2018 Google Inc. 20258 * 20259 * Permission is hereby granted, free of charge, to any person obtaining a copy 20260 * of this software and associated documentation files (the "Software"), to deal 20261 * in the Software without restriction, including without limitation the rights 20262 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20263 * copies of the Software, and to permit persons to whom the Software is 20264 * furnished to do so, subject to the following conditions: 20265 * 20266 * The above copyright notice and this permission notice shall be included in 20267 * all copies or substantial portions of the Software. 20268 * 20269 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20270 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20271 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20272 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20273 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20274 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20275 * THE SOFTWARE. 20276 */ 20277 var MDCTab = /** @class */ (function (_super) { 20278 __extends(MDCTab, _super); 20279 function MDCTab() { 20280 return _super !== null && _super.apply(this, arguments) || this; 20281 } 20282 MDCTab.attachTo = function (root) { 20283 return new MDCTab(root); 20284 }; 20285 MDCTab.prototype.initialize = function (rippleFactory, tabIndicatorFactory) { 20286 if (rippleFactory === void 0) { rippleFactory = function (el, foundation) { return new MDCRipple(el, foundation); }; } 20287 if (tabIndicatorFactory === void 0) { tabIndicatorFactory = function (el) { return new MDCTabIndicator(el); }; } 20288 this.id = this.root.id; 20289 var rippleSurface = this.root.querySelector(MDCTabFoundation.strings.RIPPLE_SELECTOR); 20290 var rippleAdapter = __assign(__assign({}, MDCRipple.createAdapter(this)), { addClass: function (className) { return rippleSurface.classList.add(className); }, removeClass: function (className) { return rippleSurface.classList.remove(className); }, updateCssVariable: function (varName, value) { return rippleSurface.style.setProperty(varName, value); } }); 20291 var rippleFoundation = new MDCRippleFoundation(rippleAdapter); 20292 this.ripple_ = rippleFactory(this.root, rippleFoundation); 20293 var tabIndicatorElement = this.root.querySelector(MDCTabFoundation.strings.TAB_INDICATOR_SELECTOR); 20294 this.tabIndicator_ = tabIndicatorFactory(tabIndicatorElement); 20295 this.content_ = this.root.querySelector(MDCTabFoundation.strings.CONTENT_SELECTOR); 20296 }; 20297 MDCTab.prototype.initialSyncWithDOM = function () { 20298 var _this = this; 20299 this.handleClick_ = function () { return _this.foundation.handleClick(); }; 20300 this.listen('click', this.handleClick_); 20301 }; 20302 MDCTab.prototype.destroy = function () { 20303 this.unlisten('click', this.handleClick_); 20304 this.ripple_.destroy(); 20305 _super.prototype.destroy.call(this); 20306 }; 20307 MDCTab.prototype.getDefaultFoundation = function () { 20308 var _this = this; 20309 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 20310 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 20311 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 20312 var adapter = { 20313 setAttr: function (attr, value) { return _this.root.setAttribute(attr, value); }, 20314 addClass: function (className) { return _this.root.classList.add(className); }, 20315 removeClass: function (className) { return _this.root.classList.remove(className); }, 20316 hasClass: function (className) { return _this.root.classList.contains(className); }, 20317 activateIndicator: function (previousIndicatorClientRect) { 20318 return _this.tabIndicator_.activate(previousIndicatorClientRect); 20319 }, 20320 deactivateIndicator: function () { return _this.tabIndicator_.deactivate(); },
vendor: 6,027 bytes, lines 20321-20463
20321 notifyInteracted: function () { return _this.emit(MDCTabFoundation.strings.INTERACTED_EVENT, { tabId: _this.id }, true /* bubble */); }, 20322 getOffsetLeft: function () { return _this.root.offsetLeft; }, 20323 getOffsetWidth: function () { return _this.root.offsetWidth; }, 20324 getContentOffsetLeft: function () { return _this.content_.offsetLeft; }, 20325 getContentOffsetWidth: function () { return _this.content_.offsetWidth; }, 20326 focus: function () { return _this.root.focus(); }, 20327 }; 20328 // tslint:enable:object-literal-sort-keys 20329 return new MDCTabFoundation(adapter); 20330 }; 20331 Object.defineProperty(MDCTab.prototype, "active", { 20332 /** 20333 * Getter for the active state of the tab 20334 */ 20335 get: function () { 20336 return this.foundation.isActive(); 20337 }, 20338 enumerable: true, 20339 configurable: true 20340 }); 20341 Object.defineProperty(MDCTab.prototype, "focusOnActivate", { 20342 set: function (focusOnActivate) { 20343 this.foundation.setFocusOnActivate(focusOnActivate); 20344 }, 20345 enumerable: true, 20346 configurable: true 20347 }); 20348 /** 20349 * Activates the tab 20350 */ 20351 MDCTab.prototype.activate = function (computeIndicatorClientRect) { 20352 this.foundation.activate(computeIndicatorClientRect); 20353 }; 20354 /** 20355 * Deactivates the tab 20356 */ 20357 MDCTab.prototype.deactivate = function () { 20358 this.foundation.deactivate(); 20359 }; 20360 /** 20361 * Returns the indicator's client rect 20362 */ 20363 MDCTab.prototype.computeIndicatorClientRect = function () { 20364 return this.tabIndicator_.computeContentClientRect(); 20365 }; 20366 MDCTab.prototype.computeDimensions = function () { 20367 return this.foundation.computeDimensions(); 20368 }; 20369 /** 20370 * Focuses the tab 20371 */ 20372 MDCTab.prototype.focus = function () { 20373 this.root.focus(); 20374 }; 20375 return MDCTab; 20376 }(MDCComponent)); 20377 20378 /** 20379 * @license 20380 * Copyright 2018 Google Inc. 20381 * 20382 * Permission is hereby granted, free of charge, to any person obtaining a copy 20383 * of this software and associated documentation files (the "Software"), to deal 20384 * in the Software without restriction, including without limitation the rights 20385 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20386 * copies of the Software, and to permit persons to whom the Software is 20387 * furnished to do so, subject to the following conditions: 20388 * 20389 * The above copyright notice and this permission notice shall be included in 20390 * all copies or substantial portions of the Software. 20391 * 20392 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20393 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20394 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20395 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20396 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20397 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20398 * THE SOFTWARE. 20399 */ 20400 var strings$1 = { 20401 ARROW_LEFT_KEY: 'ArrowLeft', 20402 ARROW_RIGHT_KEY: 'ArrowRight', 20403 END_KEY: 'End', 20404 ENTER_KEY: 'Enter', 20405 HOME_KEY: 'Home', 20406 SPACE_KEY: 'Space', 20407 TAB_ACTIVATED_EVENT: 'MDCTabBar:activated', 20408 TAB_SCROLLER_SELECTOR: '.mdc-tab-scroller', 20409 TAB_SELECTOR: '.mdc-tab', 20410 }; 20411 var numbers = { 20412 ARROW_LEFT_KEYCODE: 37, 20413 ARROW_RIGHT_KEYCODE: 39, 20414 END_KEYCODE: 35, 20415 ENTER_KEYCODE: 13, 20416 EXTRA_SCROLL_AMOUNT: 20, 20417 HOME_KEYCODE: 36, 20418 SPACE_KEYCODE: 32, 20419 }; 20420 20421 /** 20422 * @license 20423 * Copyright 2018 Google Inc. 20424 * 20425 * Permission is hereby granted, free of charge, to any person obtaining a copy 20426 * of this software and associated documentation files (the "Software"), to deal 20427 * in the Software without restriction, including without limitation the rights 20428 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20429 * copies of the Software, and to permit persons to whom the Software is 20430 * furnished to do so, subject to the following conditions: 20431 * 20432 * The above copyright notice and this permission notice shall be included in 20433 * all copies or substantial portions of the Software. 20434 * 20435 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20436 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20437 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20438 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20439 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20440 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20441 * THE SOFTWARE. 20442 */ 20443 var ACCEPTABLE_KEYS = new Set(); 20444 // IE11 has no support for new Set with iterable so we need to initialize this by hand 20445 ACCEPTABLE_KEYS.add(strings$1.ARROW_LEFT_KEY); 20446 ACCEPTABLE_KEYS.add(strings$1.ARROW_RIGHT_KEY); 20447 ACCEPTABLE_KEYS.add(strings$1.END_KEY); 20448 ACCEPTABLE_KEYS.add(strings$1.HOME_KEY); 20449 ACCEPTABLE_KEYS.add(strings$1.ENTER_KEY); 20450 ACCEPTABLE_KEYS.add(strings$1.SPACE_KEY); 20451 var KEYCODE_MAP = new Map(); 20452 // IE11 has no support for new Map with iterable so we need to initialize this by hand 20453 KEYCODE_MAP.set(numbers.ARROW_LEFT_KEYCODE, strings$1.ARROW_LEFT_KEY); 20454 KEYCODE_MAP.set(numbers.ARROW_RIGHT_KEYCODE, strings$1.ARROW_RIGHT_KEY); 20455 KEYCODE_MAP.set(numbers.END_KEYCODE, strings$1.END_KEY); 20456 KEYCODE_MAP.set(numbers.HOME_KEYCODE, strings$1.HOME_KEY); 20457 KEYCODE_MAP.set(numbers.ENTER_KEYCODE, strings$1.ENTER_KEY); 20458 KEYCODE_MAP.set(numbers.SPACE_KEYCODE, strings$1.SPACE_KEY); 20459 var MDCTabBarFoundation = /** @class */ (function (_super) { 20460 __extends(MDCTabBarFoundation, _super); 20461 function MDCTabBarFoundation(adapter) { 20462 var _this = _super.call(this, __assign(__assign({}, MDCTabBarFoundation.defaultAdapter), adapter)) || this; 20463 _this.useAutomaticActivation_ = false;
20464 return _this; 20465 } 20466 Object.defineProperty(MDCTabBarFoundation, "strings", { 20467 get: function () { 20468 return strings$1; 20469 }, 20470 enumerable: true, 20471 configurable: true 20472 }); 20473 Object.defineProperty(MDCTabBarFoundation, "numbers", { 20474 get: function () { 20475 return numbers; 20476 }, 20477 enumerable: true, 20478 configurable: true 20479 }); 20480 Object.defineProperty(MDCTabBarFoundation, "defaultAdapter", { 20481 get: function () { 20482 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 20483 return { 20484 scrollTo: function () { return undefined; }, 20485 incrementScroll: function () { return undefined; }, 20486 getScrollPosition: function () { return 0; }, 20487 getScrollContentWidth: function () { return 0; }, 20488 getOffsetWidth: function () { return 0; }, 20489 isRTL: function () { return false; },
vendor: 18,450 bytes, lines 20490-20874
20490 setActiveTab: function () { return undefined; }, 20491 activateTabAtIndex: function () { return undefined; }, 20492 deactivateTabAtIndex: function () { return undefined; }, 20493 focusTabAtIndex: function () { return undefined; }, 20494 getTabIndicatorClientRectAtIndex: function () { return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 }); }, 20495 getTabDimensionsAtIndex: function () { return ({ rootLeft: 0, rootRight: 0, contentLeft: 0, contentRight: 0 }); }, 20496 getPreviousActiveTabIndex: function () { return -1; }, 20497 getFocusedTabIndex: function () { return -1; }, 20498 getIndexOfTabById: function () { return -1; }, 20499 getTabListLength: function () { return 0; }, 20500 notifyTabActivated: function () { return undefined; }, 20501 }; 20502 // tslint:enable:object-literal-sort-keys 20503 }, 20504 enumerable: true, 20505 configurable: true 20506 }); 20507 /** 20508 * Switches between automatic and manual activation modes. 20509 * See https://www.w3.org/TR/wai-aria-practices/#tabpanel for examples. 20510 */ 20511 MDCTabBarFoundation.prototype.setUseAutomaticActivation = function (useAutomaticActivation) { 20512 this.useAutomaticActivation_ = useAutomaticActivation; 20513 }; 20514 MDCTabBarFoundation.prototype.activateTab = function (index) { 20515 var previousActiveIndex = this.adapter.getPreviousActiveTabIndex(); 20516 if (!this.indexIsInRange_(index) || index === previousActiveIndex) { 20517 return; 20518 } 20519 var previousClientRect; 20520 if (previousActiveIndex !== -1) { 20521 this.adapter.deactivateTabAtIndex(previousActiveIndex); 20522 previousClientRect = 20523 this.adapter.getTabIndicatorClientRectAtIndex(previousActiveIndex); 20524 } 20525 this.adapter.activateTabAtIndex(index, previousClientRect); 20526 this.scrollIntoView(index); 20527 this.adapter.notifyTabActivated(index); 20528 }; 20529 MDCTabBarFoundation.prototype.handleKeyDown = function (evt) { 20530 // Get the key from the event 20531 var key = this.getKeyFromEvent_(evt); 20532 // Early exit if the event key isn't one of the keyboard navigation keys 20533 if (key === undefined) { 20534 return; 20535 } 20536 // Prevent default behavior for movement keys, but not for activation keys, since :active is used to apply ripple 20537 if (!this.isActivationKey_(key)) { 20538 evt.preventDefault(); 20539 } 20540 if (this.useAutomaticActivation_) { 20541 if (this.isActivationKey_(key)) { 20542 return; 20543 } 20544 var index = this.determineTargetFromKey_(this.adapter.getPreviousActiveTabIndex(), key); 20545 this.adapter.setActiveTab(index); 20546 this.scrollIntoView(index); 20547 } 20548 else { 20549 var focusedTabIndex = this.adapter.getFocusedTabIndex(); 20550 if (this.isActivationKey_(key)) { 20551 this.adapter.setActiveTab(focusedTabIndex); 20552 } 20553 else { 20554 var index = this.determineTargetFromKey_(focusedTabIndex, key); 20555 this.adapter.focusTabAtIndex(index); 20556 this.scrollIntoView(index); 20557 } 20558 } 20559 }; 20560 /** 20561 * Handles the MDCTab:interacted event 20562 */ 20563 MDCTabBarFoundation.prototype.handleTabInteraction = function (evt) { 20564 this.adapter.setActiveTab(this.adapter.getIndexOfTabById(evt.detail.tabId)); 20565 }; 20566 /** 20567 * Scrolls the tab at the given index into view 20568 * @param index The tab index to make visible 20569 */ 20570 MDCTabBarFoundation.prototype.scrollIntoView = function (index) { 20571 // Early exit if the index is out of range 20572 if (!this.indexIsInRange_(index)) { 20573 return; 20574 } 20575 // Always scroll to 0 if scrolling to the 0th index 20576 if (index === 0) { 20577 return this.adapter.scrollTo(0); 20578 } 20579 // Always scroll to the max value if scrolling to the Nth index 20580 // MDCTabScroller.scrollTo() will never scroll past the max possible value 20581 if (index === this.adapter.getTabListLength() - 1) { 20582 return this.adapter.scrollTo(this.adapter.getScrollContentWidth()); 20583 } 20584 if (this.isRTL_()) { 20585 return this.scrollIntoViewRTL_(index); 20586 } 20587 this.scrollIntoView_(index); 20588 }; 20589 /** 20590 * Private method for determining the index of the destination tab based on what key was pressed 20591 * @param origin The original index from which to determine the destination 20592 * @param key The name of the key 20593 */ 20594 MDCTabBarFoundation.prototype.determineTargetFromKey_ = function (origin, key) { 20595 var isRTL = this.isRTL_(); 20596 var maxIndex = this.adapter.getTabListLength() - 1; 20597 var shouldGoToEnd = key === strings$1.END_KEY; 20598 var shouldDecrement = key === strings$1.ARROW_LEFT_KEY && !isRTL || key === strings$1.ARROW_RIGHT_KEY && isRTL; 20599 var shouldIncrement = key === strings$1.ARROW_RIGHT_KEY && !isRTL || key === strings$1.ARROW_LEFT_KEY && isRTL; 20600 var index = origin; 20601 if (shouldGoToEnd) { 20602 index = maxIndex; 20603 } 20604 else if (shouldDecrement) { 20605 index -= 1; 20606 } 20607 else if (shouldIncrement) { 20608 index += 1; 20609 } 20610 else { 20611 index = 0; 20612 } 20613 if (index < 0) { 20614 index = maxIndex; 20615 } 20616 else if (index > maxIndex) { 20617 index = 0; 20618 } 20619 return index; 20620 }; 20621 /** 20622 * Calculates the scroll increment that will make the tab at the given index visible 20623 * @param index The index of the tab 20624 * @param nextIndex The index of the next tab 20625 * @param scrollPosition The current scroll position 20626 * @param barWidth The width of the Tab Bar 20627 */ 20628 MDCTabBarFoundation.prototype.calculateScrollIncrement_ = function (index, nextIndex, scrollPosition, barWidth) { 20629 var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex); 20630 var relativeContentLeft = nextTabDimensions.contentLeft - scrollPosition - barWidth; 20631 var relativeContentRight = nextTabDimensions.contentRight - scrollPosition; 20632 var leftIncrement = relativeContentRight - numbers.EXTRA_SCROLL_AMOUNT; 20633 var rightIncrement = relativeContentLeft + numbers.EXTRA_SCROLL_AMOUNT; 20634 if (nextIndex < index) { 20635 return Math.min(leftIncrement, 0); 20636 } 20637 return Math.max(rightIncrement, 0); 20638 }; 20639 /** 20640 * Calculates the scroll increment that will make the tab at the given index visible in RTL 20641 * @param index The index of the tab 20642 * @param nextIndex The index of the next tab 20643 * @param scrollPosition The current scroll position 20644 * @param barWidth The width of the Tab Bar 20645 * @param scrollContentWidth The width of the scroll content 20646 */ 20647 MDCTabBarFoundation.prototype.calculateScrollIncrementRTL_ = function (index, nextIndex, scrollPosition, barWidth, scrollContentWidth) { 20648 var nextTabDimensions = this.adapter.getTabDimensionsAtIndex(nextIndex); 20649 var relativeContentLeft = scrollContentWidth - nextTabDimensions.contentLeft - scrollPosition; 20650 var relativeContentRight = scrollContentWidth - nextTabDimensions.contentRight - scrollPosition - barWidth; 20651 var leftIncrement = relativeContentRight + numbers.EXTRA_SCROLL_AMOUNT; 20652 var rightIncrement = relativeContentLeft - numbers.EXTRA_SCROLL_AMOUNT; 20653 if (nextIndex > index) { 20654 return Math.max(leftIncrement, 0); 20655 } 20656 return Math.min(rightIncrement, 0); 20657 }; 20658 /** 20659 * Determines the index of the adjacent tab closest to either edge of the Tab Bar 20660 * @param index The index of the tab 20661 * @param tabDimensions The dimensions of the tab 20662 * @param scrollPosition The current scroll position 20663 * @param barWidth The width of the tab bar 20664 */ 20665 MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdge_ = function (index, tabDimensions, scrollPosition, barWidth) { 20666 /** 20667 * Tabs are laid out in the Tab Scroller like this: 20668 * 20669 * Scroll Position 20670 * +---+ 20671 * | | Bar Width 20672 * | +-----------------------------------+ 20673 * | | | 20674 * | V V 20675 * | +-----------------------------------+ 20676 * V | Tab Scroller | 20677 * +------------+--------------+-------------------+ 20678 * | Tab | Tab | Tab | 20679 * +------------+--------------+-------------------+ 20680 * | | 20681 * +-----------------------------------+ 20682 * 20683 * To determine the next adjacent index, we look at the Tab root left and 20684 * Tab root right, both relative to the scroll position. If the Tab root 20685 * left is less than 0, then we know it's out of view to the left. If the 20686 * Tab root right minus the bar width is greater than 0, we know the Tab is 20687 * out of view to the right. From there, we either increment or decrement 20688 * the index. 20689 */ 20690 var relativeRootLeft = tabDimensions.rootLeft - scrollPosition; 20691 var relativeRootRight = tabDimensions.rootRight - scrollPosition - barWidth; 20692 var relativeRootDelta = relativeRootLeft + relativeRootRight; 20693 var leftEdgeIsCloser = relativeRootLeft < 0 || relativeRootDelta < 0; 20694 var rightEdgeIsCloser = relativeRootRight > 0 || relativeRootDelta > 0; 20695 if (leftEdgeIsCloser) { 20696 return index - 1; 20697 } 20698 if (rightEdgeIsCloser) { 20699 return index + 1; 20700 } 20701 return -1; 20702 }; 20703 /** 20704 * Determines the index of the adjacent tab closest to either edge of the Tab Bar in RTL 20705 * @param index The index of the tab 20706 * @param tabDimensions The dimensions of the tab 20707 * @param scrollPosition The current scroll position 20708 * @param barWidth The width of the tab bar 20709 * @param scrollContentWidth The width of the scroller content 20710 */ 20711 MDCTabBarFoundation.prototype.findAdjacentTabIndexClosestToEdgeRTL_ = function (index, tabDimensions, scrollPosition, barWidth, scrollContentWidth) { 20712 var rootLeft = scrollContentWidth - tabDimensions.rootLeft - barWidth - scrollPosition; 20713 var rootRight = scrollContentWidth - tabDimensions.rootRight - scrollPosition; 20714 var rootDelta = rootLeft + rootRight; 20715 var leftEdgeIsCloser = rootLeft > 0 || rootDelta > 0; 20716 var rightEdgeIsCloser = rootRight < 0 || rootDelta < 0; 20717 if (leftEdgeIsCloser) { 20718 return index + 1; 20719 } 20720 if (rightEdgeIsCloser) { 20721 return index - 1; 20722 } 20723 return -1; 20724 }; 20725 /** 20726 * Returns the key associated with a keydown event 20727 * @param evt The keydown event 20728 */ 20729 MDCTabBarFoundation.prototype.getKeyFromEvent_ = function (evt) { 20730 if (ACCEPTABLE_KEYS.has(evt.key)) { 20731 return evt.key; 20732 } 20733 return KEYCODE_MAP.get(evt.keyCode); 20734 }; 20735 MDCTabBarFoundation.prototype.isActivationKey_ = function (key) { 20736 return key === strings$1.SPACE_KEY || key === strings$1.ENTER_KEY; 20737 }; 20738 /** 20739 * Returns whether a given index is inclusively between the ends 20740 * @param index The index to test 20741 */ 20742 MDCTabBarFoundation.prototype.indexIsInRange_ = function (index) { 20743 return index >= 0 && index < this.adapter.getTabListLength(); 20744 }; 20745 /** 20746 * Returns the view's RTL property 20747 */ 20748 MDCTabBarFoundation.prototype.isRTL_ = function () { 20749 return this.adapter.isRTL(); 20750 }; 20751 /** 20752 * Scrolls the tab at the given index into view for left-to-right user agents. 20753 * @param index The index of the tab to scroll into view 20754 */ 20755 MDCTabBarFoundation.prototype.scrollIntoView_ = function (index) { 20756 var scrollPosition = this.adapter.getScrollPosition(); 20757 var barWidth = this.adapter.getOffsetWidth(); 20758 var tabDimensions = this.adapter.getTabDimensionsAtIndex(index); 20759 var nextIndex = this.findAdjacentTabIndexClosestToEdge_(index, tabDimensions, scrollPosition, barWidth); 20760 if (!this.indexIsInRange_(nextIndex)) { 20761 return; 20762 } 20763 var scrollIncrement = this.calculateScrollIncrement_(index, nextIndex, scrollPosition, barWidth); 20764 this.adapter.incrementScroll(scrollIncrement); 20765 }; 20766 /** 20767 * Scrolls the tab at the given index into view in RTL 20768 * @param index The tab index to make visible 20769 */ 20770 MDCTabBarFoundation.prototype.scrollIntoViewRTL_ = function (index) { 20771 var scrollPosition = this.adapter.getScrollPosition(); 20772 var barWidth = this.adapter.getOffsetWidth(); 20773 var tabDimensions = this.adapter.getTabDimensionsAtIndex(index); 20774 var scrollWidth = this.adapter.getScrollContentWidth(); 20775 var nextIndex = this.findAdjacentTabIndexClosestToEdgeRTL_(index, tabDimensions, scrollPosition, barWidth, scrollWidth); 20776 if (!this.indexIsInRange_(nextIndex)) { 20777 return; 20778 } 20779 var scrollIncrement = this.calculateScrollIncrementRTL_(index, nextIndex, scrollPosition, barWidth, scrollWidth); 20780 this.adapter.incrementScroll(scrollIncrement); 20781 }; 20782 return MDCTabBarFoundation; 20783 }(MDCFoundation)); 20784 20785 /** 20786 * @license 20787 * Copyright 2018 Google Inc. 20788 * 20789 * Permission is hereby granted, free of charge, to any person obtaining a copy 20790 * of this software and associated documentation files (the "Software"), to deal 20791 * in the Software without restriction, including without limitation the rights 20792 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20793 * copies of the Software, and to permit persons to whom the Software is 20794 * furnished to do so, subject to the following conditions: 20795 * 20796 * The above copyright notice and this permission notice shall be included in 20797 * all copies or substantial portions of the Software. 20798 * 20799 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20800 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20801 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20802 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20803 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20804 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20805 * THE SOFTWARE. 20806 */ 20807 var strings = MDCTabBarFoundation.strings; 20808 var tabIdCounter = 0; 20809 var MDCTabBar = /** @class */ (function (_super) { 20810 __extends(MDCTabBar, _super); 20811 function MDCTabBar() { 20812 return _super !== null && _super.apply(this, arguments) || this; 20813 } 20814 MDCTabBar.attachTo = function (root) { 20815 return new MDCTabBar(root); 20816 }; 20817 Object.defineProperty(MDCTabBar.prototype, "focusOnActivate", { 20818 set: function (focusOnActivate) { 20819 this.tabList_.forEach(function (tab) { return tab.focusOnActivate = focusOnActivate; }); 20820 }, 20821 enumerable: true, 20822 configurable: true 20823 }); 20824 Object.defineProperty(MDCTabBar.prototype, "useAutomaticActivation", { 20825 set: function (useAutomaticActivation) { 20826 this.foundation.setUseAutomaticActivation(useAutomaticActivation); 20827 }, 20828 enumerable: true, 20829 configurable: true 20830 }); 20831 MDCTabBar.prototype.initialize = function (tabFactory, tabScrollerFactory) { 20832 if (tabFactory === void 0) { tabFactory = function (el) { return new MDCTab(el); }; } 20833 if (tabScrollerFactory === void 0) { tabScrollerFactory = function (el) { return new MDCTabScroller(el); }; } 20834 this.tabList_ = this.instantiateTabs_(tabFactory); 20835 this.tabScroller_ = this.instantiateTabScroller_(tabScrollerFactory); 20836 }; 20837 MDCTabBar.prototype.initialSyncWithDOM = function () { 20838 var _this = this; 20839 this.handleTabInteraction_ = function (evt) { 20840 return _this.foundation.handleTabInteraction(evt); 20841 }; 20842 this.handleKeyDown_ = function (evt) { return _this.foundation.handleKeyDown(evt); }; 20843 this.listen(MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_); 20844 this.listen('keydown', this.handleKeyDown_); 20845 for (var i = 0; i < this.tabList_.length; i++) { 20846 if (this.tabList_[i].active) { 20847 this.scrollIntoView(i); 20848 break; 20849 } 20850 } 20851 }; 20852 MDCTabBar.prototype.destroy = function () { 20853 _super.prototype.destroy.call(this); 20854 this.unlisten(MDCTabFoundation.strings.INTERACTED_EVENT, this.handleTabInteraction_); 20855 this.unlisten('keydown', this.handleKeyDown_); 20856 this.tabList_.forEach(function (tab) { return tab.destroy(); }); 20857 if (this.tabScroller_) { 20858 this.tabScroller_.destroy(); 20859 } 20860 }; 20861 MDCTabBar.prototype.getDefaultFoundation = function () { 20862 var _this = this; 20863 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. 20864 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. 20865 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface. 20866 var adapter = { 20867 scrollTo: function (scrollX) { return _this.tabScroller_.scrollTo(scrollX); }, 20868 incrementScroll: function (scrollXIncrement) { 20869 return _this.tabScroller_.incrementScroll(scrollXIncrement); 20870 }, 20871 getScrollPosition: function () { return _this.tabScroller_.getScrollPosition(); }, 20872 getScrollContentWidth: function () { return _this.tabScroller_.getScrollContentWidth(); }, 20873 getOffsetWidth: function () { return _this.root.offsetWidth; }, 20874 isRTL: function () { return window.getComputedStyle(_this.root).getPropertyValue('direction') === 'rtl'; },
20875 setActiveTab: function (index) { return _this.foundation.activateTab(index); }, 20876 activateTabAtIndex: function (index, clientRect) { 20877 return _this.tabList_[index].activate(clientRect); 20878 }, 20879 deactivateTabAtIndex: function (index) { return _this.tabList_[index].deactivate(); }, 20880 focusTabAtIndex: function (index) { return _this.tabList_[index].focus(); }, 20881 getTabIndicatorClientRectAtIndex: function (index) { 20882 return _this.tabList_[index].computeIndicatorClientRect(); 20883 }, 20884 getTabDimensionsAtIndex: function (index) { 20885 return _this.tabList_[index].computeDimensions(); 20886 }, 20887 getPreviousActiveTabIndex: function () { 20888 for (var i = 0; i < _this.tabList_.length; i++) { 20889 if (_this.tabList_[i].active) { 20890 return i; 20891 } 20892 } 20893 return -1; 20894 }, 20895 getFocusedTabIndex: function () { 20896 var tabElements = _this.getTabElements_(); 20897 var activeElement = document.activeElement; 20898 return tabElements.indexOf(activeElement); 20899 }, 20900 getIndexOfTabById: function (id) { 20901 for (var i = 0; i < _this.tabList_.length; i++) { 20902 if (_this.tabList_[i].id === id) { 20903 return i; 20904 } 20905 } 20906 return -1; 20907 }, 20908 getTabListLength: function () { return _this.tabList_.length; }, 20909 notifyTabActivated: function (index) { return _this.emit(strings.TAB_ACTIVATED_EVENT, { index: index }, true); }, 20910 }; 20911 // tslint:enable:object-literal-sort-keys 20912 return new MDCTabBarFoundation(adapter); 20913 }; 20914 /** 20915 * Activates the tab at the given index 20916 * @param index The index of the tab 20917 */ 20918 MDCTabBar.prototype.activateTab = function (index) { 20919 this.foundation.activateTab(index); 20920 }; 20921 /** 20922 * Scrolls the tab at the given index into view 20923 * @param index THe index of the tab 20924 */ 20925 MDCTabBar.prototype.scrollIntoView = function (index) { 20926 this.foundation.scrollIntoView(index); 20927 }; 20928 /** 20929 * Returns all the tab elements in a nice clean array 20930 */ 20931 MDCTabBar.prototype.getTabElements_ = function () { 20932 return [].slice.call(this.root.querySelectorAll(strings.TAB_SELECTOR)); 20933 }; 20934 /** 20935 * Instantiates tab components on all child tab elements 20936 */ 20937 MDCTabBar.prototype.instantiateTabs_ = function (tabFactory) { 20938 return this.getTabElements_().map(function (el) { 20939 el.id = el.id || "mdc-tab-" + ++tabIdCounter; 20940 return tabFactory(el); 20941 }); 20942 }; 20943 /** 20944 * Instantiates tab scroller component on the child tab scroller element 20945 */ 20946 MDCTabBar.prototype.instantiateTabScroller_ = function (tabScrollerFactory) { 20947 var tabScrollerElement = this.root.querySelector(strings.TAB_SCROLLER_SELECTOR); 20948 if (tabScrollerElement) { 20949 return tabScrollerFactory(tabScrollerElement); 20950 } 20951 return null; 20952 }; 20953 return MDCTabBar; 20954 }(MDCComponent)); 20955 20956 /** 20957 * @license 20958 * Copyright 2019 Google Inc. 20959 * 20960 * Permission is hereby granted, free of charge, to any person obtaining a copy 20961 * of this software and associated documentation files (the "Software"), to deal 20962 * in the Software without restriction, including without limitation the rights 20963 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20964 * copies of the Software, and to permit persons to whom the Software is 20965 * furnished to do so, subject to the following conditions: 20966 * 20967 * The above copyright notice and this permission notice shall be included in 20968 * all copies or substantial portions of the Software. 20969 * 20970 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20971 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20972 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20973 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20974 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20975 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20976 * THE SOFTWARE. 20977 */ 20978 20979 /** 20980 * @license 20981 * Copyright 2019 Google Inc. 20982 * 20983 * Permission is hereby granted, free of charge, to any person obtaining a copy 20984 * of this software and associated documentation files (the "Software"), to deal 20985 * in the Software without restriction, including without limitation the rights 20986 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20987 * copies of the Software, and to permit persons to whom the Software is 20988 * furnished to do so, subject to the following conditions: 20989 * 20990 * The above copyright notice and this permission notice shall be included in 20991 * all copies or substantial portions of the Software. 20992 * 20993 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20994 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20995 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20996 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20997 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20998 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20999 * THE SOFTWARE. 21000 */ 21001 21002 /* TODO ?? 21003 21004 MDCTextFieldIcon, 21005 MDCTextFieldHelperText, 21006 21007 import { 21008 MDCTextFieldIcon 21009 } 21010 from '@material/textfield/icon'; 21011 21012 import { 21013 MDCTextFieldHelperText 21014 } 21015 from '@material/textfield/helper-text'; 21016 */ 21017 21018 class Reaper extends Sargasso { 21019 constructor (element, options) { 21020 super(element, options); 21021 this.setMetaData(this.options.MDCThing.constructor.name, this.options.MDCThing); 21022 } 21023 21024 destroy () { 21025 this.setMetaData(this.options.MDCThing.constructor.name, null); 21026 if (this.options.MDCThing && this.options.MDCThing.destroy) { 21027 this.options.MDCThing.destroy(); 21028 } 21029 super.destroy(); 21030 } 21031 } 21032 21033 utils$1.registerSargassoClass('Reaper', Reaper); 21034 21035 class TropicBird extends Sargasso { 21036 constructor (element, options = {}) { 21037 options.watchDOM = true; 21038 super(element, options); 21039 this.topAppBar = null; 21040 this.drawer = null; 21041 this.snackBar = null; 21042 this.snackBarTimer = null; 21043 this.snackBarQueue = []; 21044 this.linearProgress = null; 21045 this.linearProgressTimer = null; 21046 this.linearProgressOpen = false;
21047 this.manageMDCInstances(); 21048 } 21049 21050 DOMChanged () { 21051 this.manageMDCInstances(); 21052 } 21053 21054 makeEphemeral () { 21055 if (!document.getElementById('ephemeral')) { 21056 const ephemeral = document.createElement('div'); 21057 ephemeral.setAttribute('id', 'ephemeral'); 21058 document.body.append(ephemeral); 21059 } 21060 } 21061 21062 dialog (target, title, content, canCancel) { 21063 this.makeEphemeral(); 21064 const template = document.querySelector(target).outerHTML; 21065 document.getElementById('ephemeral').innerHTML = template; 21066 const dialogContainer = document.getElementById('ephemeral').getElementsByClassName('mdc-dialog')[0]; 21067 const titleContainer = dialogContainer.getElementsByClassName('mdc-dialog__title')[0]; 21068 const contentContainer = dialogContainer.getElementsByClassName('mdc-dialog__content')[0]; 21069 const cancelButton = dialogContainer.getElementsByClassName('mdc-dialog-cancel')[0]; 21070 21071 titleContainer.textContent = title; 21072 contentContainer.textContent = content; 21073 if (canCancel) { 21074 cancelButton.style.display = 'flex'; 21075 } else { 21076 cancelButton.style.display = 'none'; 21077 } 21078 21079 return new Promise((resolve, reject) => { 21080 this.mdcDialog = new MDCDialog(dialogContainer); 21081 this.mdcDialog.listen('MDCDialog:closed', (e) => { 21082 utils$1.elementTools.removeClass(document.body, 'modal-open'); 21083 document.getElementById('ephemeral').getElementsByClassName('mdc-dialog')[0].remove(); 21084 resolve(e.detail.action); 21085 }); 21086 utils$1.elementTools.addClass(document.body, 'modal-open'); 21087 this.mdcDialog.open(); 21088 }) 21089 } 21090 21091 progressBar (show, delay = 500) { 21092 if (show === true) { 21093 if (this.linearProgressTimer) { 21094 clearTimeout(this.linearProgressTimer); 21095 this.linearProgressTimer = null; 21096 } 21097 this.linearProgressTimer = setTimeout(() => { 21098 this.linearProgressTimer = null; 21099 this.linearProgress.open(); 21100 this.linearProgressOpen = true; 21101 }, delay); 21102 } else { 21103 if (this.linearProgressTimer) { 21104 clearTimeout(this.linearProgressTimer); 21105 this.linearProgressTimer = null; 21106 } 21107 if (this.linearProgressOpen) { 21108 this.linearProgress.close(); 21109 this.linearProgressOpen = false; 21110 } 21111 } 21112 } 21113 21114 pushSnackBar (level, message, timer = 6000) { 21115 this.snackBarQueue.push({ 21116 level: level, 21117 message: message, 21118 timer: timer 21119 }); 21120 21121 if (!this.snackBarTimer) { 21122 this.popSnackBar(); 21123 } 21124 } 21125 21126 popSnackBar () { 21127 const item = this.snackBarQueue.shift(); 21128 21129 const elem = document.querySelector('.mdc-snackbar__label'); 21130 if (!elem || !this.snackBar) { 21131 confirm(item.message); 21132 if (this.snackBarQueue.length) { 21133 this.popSnackBar(); 21134 } 21135 } else { 21136 elem.innerText = item.message; 21137 21138 this.snackBar.open(); 21139 21140 this.snackBarTimer = setTimeout(() => { 21141 this.snackBarTimer = null; 21142 this.snackBar.close(); 21143 if (this.snackBarQueue.length) { 21144 this.popSnackBar(); 21145 } 21146 }, item.timer); 21147 } 21148 } 21149 21150 manageMDCInstances () { 21151 const managedClasses = [ 21152 '.mdc-top-app-bar', 21153 '.mdc-drawer', 21154 '.mdc-snackbar', 21155 '.mdc-linear-progress', 21156 '.mdc-text-field', 21157 '.mdc-select', 21158 '.mdc-switch', 21159 '.mdc-chip-set', 21160 '.mdc-fab', 21161 '.mdc-button', 21162 '.mdc-icon-button', 21163 '.mdc-card__primary-action', 21164 '.mdc-tab-bar', 21165 '.mdc-tab-scroller' 21166 ]; 21167 21168 const wantRipple = [ 21169 'mdc-fab', 21170 'mdc-button', 21171 'mdc-icon-button', 21172 'mdc-card__primary-action' 21173 ]; 21174 21175 const elements = document.querySelectorAll(managedClasses.join(',')); 21176 for (let i = 0; i < elements.length; i++) { 21177 const element = elements[i]; 21178 if (!utils$1.elementTools.hasClass(element, 'mdc-instantiated')) { 21179 utils$1.elementTools.addClass(element, 'mdc-instantiated'); 21180 21181 if (utils$1.elementTools.hasClass(element, 'mdc-top-app-bar')) { 21182 this.topAppBar = new MDCTopAppBar(element); 21183 new Reaper(element, { 21184 MDCThing: this.topAppBar 21185 }); 21186 } 21187 21188 if (utils$1.elementTools.hasClass(element, 'mdc-drawer')) { 21189 this.drawer = new MDCDrawer(element); 21190 new Reaper(element, { 21191 MDCThing: this.drawer 21192 }); 21193 21194 // close the drawer on any click 21195 element.onclick = (e) => { 21196 this.drawer.open = !this.drawer.open; 21197 }; 21198 21199 // close the drawer when click outside drawer 21200 const scrim = document.querySelector('.mdc-drawer-scrim'); 21201 if (scrim) { 21202 scrim.onclick = (e) => { 21203 e.preventDefault(); 21204 this.drawer.open = !this.drawer.open; 21205 }; 21206 } 21207 } 21208 21209 if (utils$1.elementTools.hasClass(element, 'mdc-snackbar')) { 21210 this.snackBar = new MDCSnackbar(element); 21211 new Reaper(element, { 21212 MDCThing: this.snackBar 21213 }); 21214 } 21215 21216 if (utils$1.elementTools.hasClass(element, 'mdc-linear-progress')) { 21217 this.linearProgress = new MDCLinearProgress(element); 21218 new Reaper(element, { 21219 MDCThing: this.linearProgress 21220 }); 21221 } 21222 21223 if (utils$1.elementTools.hasClass(element, 'mdc-text-field')) { 21224 const thing = new MDCTextField(element); 21225 new Reaper(element, { 21226 MDCThing: thing 21227 }); 21228 } 21229 21230 if (utils$1.elementTools.hasClass(element, 'mdc-select')) { 21231 const thing = new MDCSelect(element); 21232 new Reaper(element, { 21233 MDCThing: thing 21234 }); 21235 } 21236 21237 if (utils$1.elementTools.hasClass(element, 'mdc-switch')) { 21238 const thing = new MDCSwitch(element); 21239 new Reaper(element, { 21240 MDCThing: thing 21241 }); 21242 } 21243 21244 if (utils$1.elementTools.hasClass(element, 'mdc-chip-set')) { 21245 const thing = new MDCChipSet(element); 21246 new Reaper(element, { 21247 MDCThing: thing 21248 }); 21249 } 21250 21251 if (utils$1.elementTools.hasClass(element, 'mdc-tab-bar')) { 21252 const thing = new MDCTabBar(element); 21253 new Reaper(element, { 21254 MDCThing: thing 21255 }); 21256 } 21257 21258 if (utils$1.elementTools.hasClass(element, 'mdc-tab-scroller')) { 21259 const thing = new MDCTabScroller(element); 21260 new Reaper(element, { 21261 MDCThing: thing 21262 }); 21263 } 21264 21265 for (let j = 0;
21265 j < wantRipple.length; j++) { 21266 if (utils$1.elementTools.hasClass(element, wantRipple[j])) { 21267 const thing = new MDCRipple(element); 21268 new Reaper(element, { 21269 MDCThing: thing 21270 }); 21271 } 21272 } 21273 } 21274 } 21275 21276 // toggle the drawer when hamburger clicked 21277 const hamburger = document.querySelector('.hamburger'); 21278 if (hamburger) { 21279 hamburger.onclick = (e) => { 21280 e.preventDefault(); 21281 this.drawer.open = !this.drawer.open; 21282 }; 21283 } 21284 } 21285 } 21286 21287 utils$1.registerSargassoClass('TropicBird', TropicBird); 21288 21289 const MDC = { 21290 MDCRipple: MDCRipple, 21291 MDCLineRipple: MDCLineRipple, 21292 MDCTopAppBar: MDCTopAppBar, 21293 MDCDrawer: MDCDrawer, 21294 MDCDialog: MDCDialog, 21295 MDCTextField: MDCTextField, 21296 MDCSnackbar: MDCSnackbar, 21297 MDCFormField: MDCFormField, 21298 MDCCheckbox: MDCCheckbox, 21299 MDCSelect: MDCSelect, 21300 MDCSwitch: MDCSwitch, 21301 MDCLinearProgress: MDCLinearProgress, 21302 MDCChipSet: MDCChipSet, 21303 MDCTabBar: MDCTabBar, 21304 MDCTabScroller: MDCTabScroller 21305 }; 21306 21307 /* Made in Barbados ð§ð§ Copyright © 2020-2021 Michael Rhodes */ 21308 21309 class FlyingFish extends Sargasso { 21310 constructor (element, options = {}) { 21311 super(element, { 21312 watchViewport: true 21313 }); 21314 this.triggered = false; 21315 } 21316 21317 enterViewport () { 21318 if (!this.triggered) { 21319 this.triggered = true; 21320 21321 const offload = `onmessage = async (e) => { 21322 const response = await fetch(e.data.url) 21323 const contentType = response.headers.get('content-type'); 21324 const blob = await response.blob() 21325 self.postMessage({ uid: e.data.uid, blob: blob, contentType: contentType}) 21326 }`; 21327 21328 this.workerStart('FlyingFish', offload); 21329 21330 let imgUrl = this.element.getAttribute('data-src'); 21331 21332 // not fully qualified... 21333 if (!imgUrl.match(/^http/)) { 21334 imgUrl = new URL(imgUrl, location.href).href; 21335 } 21336 21337 // hand the url to the worker for loading 21338 this.workerPostMessage('FlyingFish', { 21339 url: imgUrl 21340 }); 21341 } 21342 } 21343 21344 // we got a message back from a worker 21345 workerOnMessage (id, data) { 21346 if (id === 'FlyingFish') { 21347 this.blobURL = URL.createObjectURL(data.blob); 21348 const frame = () => { 21349 if (this.element.tagName === 'IMG') { 21350 this.element.setAttribute('src', this.blobURL); 21351 } else { 21352 this.element.style.backgroundImage = 'url(' + this.blobURL + ')'; 21353 } 21354 this.addClass('flying-fish-loaded'); 21355 this.sleep(); // We're done. That was easy. 21356 }; 21357 this.queueFrame(frame); 21358 } 21359 super.workerOnMessage(id, data); 21360 } 21361 21362 destroy () { 21363 if (this.blobURL) { 21364 URL.revokeObjectURL(this.blobURL); 21365 } 21366 super.destroy(); 21367 } 21368 } 21369 21370 utils$1.registerSargassoClass('FlyingFish', FlyingFish); 21371 21372 /** 21373 @PelagicCreatures/FlyingFish 21374 21375 Sargasso class that implements lazy loaded images using background-image 21376 css properties or the src attribute on an IMG tag. Image is loaded using 21377 a web worker and the DOM is updated in an Animation Frame for optimal 21378 performance. 21379 21380 @author Michael Rhodes 21381 @license MIT 21382 Made in Barbados ð§ð§ Copyright © 2020-2021 Michael Rhodes 21383 21384 **/ 21385 21386 /** 21387 @PelagicCreatures/MolaMola 21388 21389 @author Michael Rhodes 21390 @license MIT 21391 Made in Barbados ð§ð§ Copyright © 2020-2021 Michael Rhodes 21392 **/ 21393 21394 const registeredHelperClasses = {}; 21395 const registerHelperClass = (className, object) => { 21396 registeredHelperClasses[className] = object; 21397 }; 21398 21399 class MolaMolaHelper { 21400 constructor (form) { 21401 this.form = form; 21402 } 21403 21404 // override these methods as needed 21405 pose () {} // pose form 21406 21407 /* 21408 preFlight: about to submit this.form.payload to endpoint 21409 return a promise for any async behavior (like recAPTCHA defined in MolaMolaHelpers.hs) 21410 throw an error to prevent submit 21411 */ 21412 preFlight () {} 21413 21414 // 200 or 422 response all is well deal with response payload 21415 success (data) {} 21416 21417 // can be result of preFlight or from endpoint 21418 error (err) {} 21419 21420 // cleanup 21421 destroy () {} 21422 } 21423 21424 /** 21425 @PelagicCreatures/MolaMola 21426 21427 @author Michael Rhodes 21428 @license MIT 21429 Made in Barbados ð§ð§ Copyright © 2020-2021 Michael Rhodes 21430 **/ 21431 21432 class ReCAPTCHAv3Helper extends MolaMolaHelper { 21433 constructor (form) { 21434 super(form); 21435 this.recaptcha = this.form.element.getAttribute('data-recaptcha'); 21436 } 21437 21438 pose () { 21439 utils$1.elementTools.addClass(document.body, 'show-recaptcha', this); 21440 } 21441 21442 preFlight () { 21443 return new Promise((resolve, reject) => { 21444 try { 21445 grecaptcha.execute(this.recaptcha, { 21446 action: 'social' 21447 }).then((token) => { 21448 this.form.payload['g-recaptcha-response'] = token; 21449 resolve(); 21450 }); 21451 } catch (err) { 21452 reject(err || new Error('reCaptchaV3 network error')); // OK google... network errors come back empty. 21453 } 21454 }) 21455 } 21456 21457 destroy () { 21458 utils$1.elementTools.removeClass(document.body, 'show-recaptcha'); 21459 } 21460 } 21461 21462 registerHelperClass('ReCAPTCHAv3Helper', ReCAPTCHAv3Helper); 21463 21464 class SubmitterHelper extends MolaMolaHelper { 21465 constructor (form) { 21466 super(form); 21467 this.submitter = this.form.element.querySelector(this.form.element.getAttribute('data-submitter')); 21468 this.submitterContent = this.submitter.innerHTML; 21469 this.submitter.style.width = this.submitter.width; 21470 this.submitter.setAttribute('disabled', true); 21471 } 21472 21473 preFlight () { 21474 this.disableSubmit(); 21475 } 21476 21477 success (data) { 21478 this.enableSubmit(); 21479 } 21480 21481 error (err) { 21482 this.enableSubmit(); 21483 } 21484 21485 disableSubmit () { 21486 this.submitter.setAttribute('disabled', true); 21487 this.submitter.innerHTML = 'working...'; 21488 } 21489 21490 enableSubmit () { 21491 this.submitter.removeAttribute('disabled'); 21492 this.submitter.innerHTML = this.submitterContent; 21493 } 21494 } 21495 21496 registerHelperClass('SubmitterHelper', SubmitterHelper); 21497 21498 class StatusHelper extends MolaMolaHelper { 21499 constructor (form) { 21500 super(form); 21501 this.status = this.form.element.querySelector(this.form.element.getAttribute('data-status')); 21502 } 21503 21504 error (err) { 21505 const errors = []; 21506 if (err) { 21507 errors.push(err.message); 21508 } 21509 if (err.statusCode) { 21510 errors.push('http status ' + err.statusCode); 21511 } 21512 this.status.innerHTML = errors.join(','); 21513 } 21514 } 21515 21516 registerHelperClass('StatusHelper', StatusHelper); 21517 21518 var assertString_1 = createCommonjsModule(function (module, exports
21518) { 21519 "use strict"; 21520 21521 Object.defineProperty(exports, "__esModule", { 21522 value: true 21523 }); 21524 exports.default = assertString; 21525 21526 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 21527 21528 function assertString(input) { 21529 var isString = typeof input === 'string' || input instanceof String; 21530 21531 if (!isString) { 21532 var invalidType = _typeof(input); 21533 21534 if (input === null) invalidType = 'null';else if (invalidType === 'object') invalidType = input.constructor.name; 21535 throw new TypeError("Expected a string but received a ".concat(invalidType)); 21536 } 21537 } 21538 21539 module.exports = exports.default; 21540 module.exports.default = exports.default; 21541 }); 21542 21543 var assertString = /*@__PURE__*/getDefaultExportFromCjs(assertString_1); 21544 21545 var toDate_1 = createCommonjsModule(function (module, exports) { 21546 "use strict"; 21547 21548 Object.defineProperty(exports, "__esModule", { 21549 value: true 21550 }); 21551 exports.default = toDate; 21552 21553 var _assertString = _interopRequireDefault(assertString_1); 21554 21555 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21556 21557 function toDate(date) { 21558 (0, _assertString.default)(date); 21559 date = Date.parse(date); 21560 return !isNaN(date) ? new Date(date) : null; 21561 } 21562 21563 module.exports = exports.default; 21564 module.exports.default = exports.default; 21565 }); 21566 21567 var toDate = /*@__PURE__*/getDefaultExportFromCjs(toDate_1); 21568 21569 var alpha_1 = createCommonjsModule(function (module, exports) { 21570 "use strict"; 21571 21572 Object.defineProperty(exports, "__esModule", { 21573 value: true 21574 }); 21575 exports.commaDecimal = exports.dotDecimal = exports.farsiLocales = exports.arabicLocales = exports.englishLocales = exports.decimal = exports.alphanumeric = exports.alpha = void 0; 21576 var alpha = { 21577 'en-US': /^[A-Z]+$/i, 21578 'az-AZ': /^[A-VXYZÃÆÄİıÃÅÃ]+$/i, 21579 'bg-BG': /^[Ð-Я]+$/i, 21580 'cs-CZ': /^[A-ZÃÄÄÃÄÃÅÃÅŠŤÃŮÎ]+$/i, 21581 'da-DK': /^[A-ZÃÃà ]+$/i, 21582 'de-DE': /^[A-ZÃÃÃÃ]+$/i, 21583 'el-GR': /^[Î-Ï]+$/i, 21584 'es-ES': /^[A-ZÃÃÃÃÃÃÃ]+$/i, 21585 'fa-IR': /^[Ø§Ø¨Ù¾ØªØ«Ø¬ÚØØ®Ø¯Ø°Ø±Ø²ÚØ³Ø´ØµØ¶Ø·Ø¸Ø¹ØºÙÙÚ©Ú¯ÙÙ ÙÙÙÛ]+$/i, 21586 'fr-FR': /^[A-ZÃÃÃÃÃÃÃÃÃÃÃÅÃÃß]+$/i, 21587 'it-IT': /^[A-ZÃÃÃÃÃÃÃÃ]+$/i, 21588 'nb-NO': /^[A-ZÃÃà ]+$/i, 21589 'nl-NL': /^[A-ZÃÃÃÃÃÃÃÃ]+$/i, 21590 'nn-NO': /^[A-ZÃÃà ]+$/i, 21591 'hu-HU': /^[A-ZÃÃÃÃÃÅÃÃŰ]+$/i, 21592 'pl-PL': /^[A-ZÄÄÄÅÅÅÃŻŹ]+$/i, 21593 'pt-PT': /^[A-ZÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ]+$/i, 21594 'ru-RU': /^[Ð-ЯÐ]+$/i, 21595 'sl-SI': /^[A-ZÄÄÄŠŽ]+$/i, 21596 'sk-SK': /^[A-ZÃÄÄÃÃÅÊŤÃÃŽĹÅĽÃÃ]+$/i, 21597 'sr-RS@latin': /^[A-ZÄÄŽŠÄ]+$/i, 21598 'sr-RS': /^[Ð-ЯÐÐÐÐÐÐ]+$/i, 21599 'sv-SE': /^[A-Zà ÃÃ]+$/i, 21600 'th-TH': /^[à¸-à¹\s]+$/i, 21601 'tr-TR': /^[A-ZÃÄİıÃÅÃ]+$/i, 21602 'uk-UA': /^[Ð-ЩЬЮЯÐIÐÒÑ]+$/i, 21603 'vi-VN': /^[A-ZÃÃẠẢÃÃẦẤẬẨẪÄẰẮẶẲẴÄÃÃẸẺẼÃá»áº¾á»á»á»ÃÃá»á»Ä¨ÃÃá»á»ÃÃá»á»á»á»á»Æ á»á»á»¢á»á» ÃÃỤỦŨƯỪỨỰỬỮỲÃỴỶỸ]+$/i, 21604 'ku-IQ': /^[Ø¦Ø§Ø¨Ù¾ØªØ¬ÚØØ®Ø¯Ø±ÚØ²ÚسشعغÙÚ¤ÙÚ©Ú¯ÙÚµÙ ÙÙÛÚ¾ÛÛÛÙØ·Ø¤Ø«Ø¢Ø¥Ø£Ùضصةظذ]+$/i, 21605 ar: /^[Ø¡Ø¢Ø£Ø¤Ø¥Ø¦Ø§Ø¨Ø©ØªØ«Ø¬ØØ®Ø¯Ø°Ø±Ø²Ø³Ø´ØµØ¶Ø·Ø¸Ø¹ØºÙÙÙÙÙ ÙÙÙÙÙÙÙÙÙÙÙÙÙÙ°]+$/, 21606 he: /^[×-ת]+$/, 21607 fa: /^['Ø¢Ø§Ø¡Ø£Ø¤Ø¦Ø¨Ù¾ØªØ«Ø¬ÚØØ®Ø¯Ø°Ø±Ø²ÚØ³Ø´ØµØ¶Ø·Ø¸Ø¹ØºÙÙÚ©Ú¯ÙÙ ÙÙÙØ©Û']+$/i 21608 }; 21609 exports.alpha = alpha; 21610 var alphanumeric = { 21611 'en-US': /^[0-9A-Z]+$/i, 21612 'az-AZ': /^[0-9A-VXYZÃÆÄİıÃÅÃ]+$/i, 21613 'bg-BG': /^[0-9Ð-Я]+$/i, 21614 'cs-CZ': /^[0-9A-ZÃÄÄÃÄÃÅÃÅŠŤÃŮÎ]+$/i, 21615 'da-DK': /^[0-9A-ZÃÃà ]+$/i, 21616 'de-DE': /^[0-9A-ZÃÃÃÃ]+$/i, 21617 'el-GR': /^[0-9Î-Ï]+$/i, 21618 'es-ES': /^[0-9A-ZÃÃÃÃÃÃÃ]+$/i, 21619 'fr-FR': /^[0-9A-ZÃÃÃÃÃÃÃÃÃÃÃÅÃÃß]+$/i, 21620 'it-IT': /^[0-9A-ZÃÃÃÃÃÃÃÃ]+$/i, 21621 'hu-HU': /^[0-9A-ZÃÃÃÃÃÅÃÃŰ]+$/i, 21622 'nb-NO': /^[0-9A-ZÃÃà ]+$/i, 21623 'nl-NL': /^[0-9A-ZÃÃÃÃÃÃÃÃ]+$/i, 21624 'nn-NO': /^[0-9A-ZÃÃà ]+$/i, 21625 'pl-PL': /^[0-9A-ZÄÄÄÅÅÅÃŻŹ]+$/i, 21626 'pt-PT': /^[0-9A-ZÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃ]+$/i, 21627 'ru-RU': /^[0-9Ð-ЯÐ]+$/i, 21628 'sl-SI': /^[0-9A-ZÄÄÄŠŽ]+$/i, 21629 'sk-SK': /^[0-9A-ZÃÄÄÃÃÅÊŤÃÃŽĹÅĽÃÃ]+$/i, 21630 'sr-RS@latin': /^[0-9A-ZÄÄŽŠÄ]+$/i, 21631 'sr-RS': /^[0-9Ð-ЯÐÐÐÐÐÐ]+$/i, 21632 'sv-SE': /^[0-9A-Zà ÃÃ]+$/i, 21633 'th-TH': /^[à¸-à¹\s]+$/i, 21634 'tr-TR': /^[0-9A-ZÃÄİıÃÅÃ]+$/i, 21635 'uk-UA': /^[0-9Ð-ЩЬЮЯÐIÐÒÑ]+$/i, 21636 'ku-IQ': /^[٠١٢٣٤٥٦٧٨٩0-9Ø¦Ø§Ø¨Ù¾ØªØ¬ÚØØ®Ø¯Ø±ÚØ²ÚسشعغÙÚ¤ÙÚ©Ú¯ÙÚµÙ ÙÙÛÚ¾ÛÛÛÙØ·Ø¤Ø«Ø¢Ø¥Ø£Ùضصةظذ]+$/i, 21637 'vi-VN': /^[0-9A-ZÃÃẠẢÃÃẦẤẬẨẪÄẰẮẶẲẴÄÃÃẸẺẼÃá»áº¾á»á»á»ÃÃá»á»Ä¨ÃÃá»á»ÃÃá»á»á»á»á»Æ á»á»á»¢á»á» ÃÃỤỦŨƯỪỨỰỬỮỲÃỴỶỸ]+$/i, 21638 ar: /^[٠١٢٣٤٥٦٧٨٩0-9Ø¡Ø¢Ø£Ø¤Ø¥Ø¦Ø§Ø¨Ø©ØªØ«Ø¬ØØ®Ø¯Ø°Ø±Ø²Ø³Ø´ØµØ¶Ø·Ø¸Ø¹ØºÙÙÙÙÙ ÙÙÙÙÙÙÙÙÙÙÙÙÙÙ°]+$/, 21639 he: /^[0-9×-ת]+$/, 21640 fa: /^['0-9Ø¢Ø§Ø¡Ø£Ø¤Ø¦Ø¨Ù¾ØªØ«Ø¬ÚØØ®Ø¯Ø°Ø±Ø²ÚØ³Ø´ØµØ¶Ø·Ø¸Ø¹ØºÙÙÚ©Ú¯ÙÙ ÙÙÙØ©ÛÛ±Û²Û³Û´ÛµÛ¶Û·Û¸Û¹Û°']+$/i 21641 };
21642 exports.alphanumeric = alphanumeric; 21643 var decimal = { 21644 'en-US': '.', 21645 ar: 'Ù«' 21646 }; 21647 exports.decimal = decimal; 21648 var englishLocales = ['AU', 'GB', 'HK', 'IN', 'NZ', 'ZA', 'ZM']; 21649 exports.englishLocales = englishLocales; 21650 21651 for (var locale, i = 0; i < englishLocales.length; i++) { 21652 locale = "en-".concat(englishLocales[i]); 21653 alpha[locale] = alpha['en-US']; 21654 alphanumeric[locale] = alphanumeric['en-US']; 21655 decimal[locale] = decimal['en-US']; 21656 } // Source: http://www.localeplanet.com/java/ 21657 21658 21659 var arabicLocales = ['AE', 'BH', 'DZ', 'EG', 'IQ', 'JO', 'KW', 'LB', 'LY', 'MA', 'QM', 'QA', 'SA', 'SD', 'SY', 'TN', 'YE']; 21660 exports.arabicLocales = arabicLocales; 21661 21662 for (var _locale, _i = 0; _i < arabicLocales.length; _i++) { 21663 _locale = "ar-".concat(arabicLocales[_i]); 21664 alpha[_locale] = alpha.ar; 21665 alphanumeric[_locale] = alphanumeric.ar; 21666 decimal[_locale] = decimal.ar; 21667 } 21668 21669 var farsiLocales = ['IR', 'AF']; 21670 exports.farsiLocales = farsiLocales; 21671 21672 for (var _locale2, _i2 = 0; _i2 < farsiLocales.length; _i2++) { 21673 _locale2 = "fa-".concat(farsiLocales[_i2]); 21674 alphanumeric[_locale2] = alphanumeric.fa; 21675 decimal[_locale2] = decimal.ar; 21676 } // Source: https://en.wikipedia.org/wiki/Decimal_mark 21677 21678 21679 var dotDecimal = ['ar-EG', 'ar-LB', 'ar-LY']; 21680 exports.dotDecimal = dotDecimal; 21681 var commaDecimal = ['bg-BG', 'cs-CZ', 'da-DK', 'de-DE', 'el-GR', 'en-ZM', 'es-ES', 'fr-CA', 'fr-FR', 'id-ID', 'it-IT', 'ku-IQ', 'hu-HU', 'nb-NO', 'nn-NO', 'nl-NL', 'pl-PL', 'pt-PT', 'ru-RU', 'sl-SI', 'sr-RS@latin', 'sr-RS', 'sv-SE', 'tr-TR', 'uk-UA', 'vi-VN']; 21682 exports.commaDecimal = commaDecimal; 21683 21684 for (var _i3 = 0; _i3 < dotDecimal.length; _i3++) { 21685 decimal[dotDecimal[_i3]] = decimal['en-US']; 21686 } 21687 21688 for (var _i4 = 0; _i4 < commaDecimal.length; _i4++) { 21689 decimal[commaDecimal[_i4]] = ','; 21690 } 21691 21692 alpha['fr-CA'] = alpha['fr-FR']; 21693 alphanumeric['fr-CA'] = alphanumeric['fr-FR']; 21694 alpha['pt-BR'] = alpha['pt-PT']; 21695 alphanumeric['pt-BR'] = alphanumeric['pt-PT']; 21696 decimal['pt-BR'] = decimal['pt-PT']; // see #862 21697 21698 alpha['pl-Pl'] = alpha['pl-PL']; 21699 alphanumeric['pl-Pl'] = alphanumeric['pl-PL']; 21700 decimal['pl-Pl'] = decimal['pl-PL']; // see #1455 21701 21702 alpha['fa-AF'] = alpha.fa; 21703 }); 21704 21705 var alpha = /*@__PURE__*/getDefaultExportFromCjs(alpha_1); 21706 21707 var isFloat_1 = createCommonjsModule(function (module, exports) { 21708 "use strict"; 21709 21710 Object.defineProperty(exports, "__esModule", { 21711 value: true 21712 }); 21713 exports.default = isFloat; 21714 exports.locales = void 0; 21715 21716 var _assertString = _interopRequireDefault(assertString_1); 21717 21718 21719 21720 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21721 21722 function isFloat(str, options) { 21723 (0, _assertString.default)(str); 21724 options = options || {}; 21725 var float = new RegExp("^(?:[-+])?(?:[0-9]+)?(?:\\".concat(options.locale ? alpha_1.decimal[options.locale] : '.', "[0-9]*)?(?:[eE][\\+\\-]?(?:[0-9]+))?$")); 21726 21727 if (str === '' || str === '.' || str === '-' || str === '+') { 21728 return false; 21729 } 21730 21731 var value = parseFloat(str.replace(',', '.')); 21732 return float.test(str) && (!options.hasOwnProperty('min') || value >= options.min) && (!options.hasOwnProperty('max') || value <= options.max) && (!options.hasOwnProperty('lt') || value < options.lt) && (!options.hasOwnProperty('gt') || value > options.gt); 21733 } 21734 21735 var locales = Object.keys(alpha_1.decimal); 21736 exports.locales = locales; 21737 }); 21738 21739 var isFloat = /*@__PURE__*/getDefaultExportFromCjs(isFloat_1); 21740 21741 var toFloat_1 = createCommonjsModule(function (module, exports) { 21742 "use strict"; 21743 21744 Object.defineProperty(exports, "__esModule", { 21745 value: true 21746 }); 21747 exports.default = toFloat; 21748 21749 var _isFloat = _interopRequireDefault(isFloat_1); 21750 21751 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21752 21753 function toFloat(str) { 21754 if (!(0, _isFloat.default)(str)) return NaN; 21755 return parseFloat(str); 21756 } 21757 21758 module.exports = exports.default; 21759 module.exports.default = exports.default; 21760 }); 21761 21762 var toFloat = /*@__PURE__*/getDefaultExportFromCjs(toFloat_1); 21763 21764 var toInt_1 = createCommonjsModule(function (module, exports) { 21765 "use strict"; 21766 21767 Object.defineProperty(exports, "__esModule", { 21768 value: true 21769 }); 21770 exports.default = toInt; 21771 21772 var _assertString = _interopRequireDefault(assertString_1); 21773 21774 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21775 21776 function toInt(str, radix) { 21777 (0, _assertString.default)(str); 21778 return parseInt(str, radix || 10); 21779 } 21780 21781 module.exports = exports.default; 21782 module.exports.default = exports.default; 21783 }); 21784 21785 var toInt = /*@__PURE__*/getDefaultExportFromCjs(toInt_1); 21786 21787 var toBoolean_1 = createCommonjsModule(function (module, exports
21787) { 21788 "use strict"; 21789 21790 Object.defineProperty(exports, "__esModule", { 21791 value: true 21792 }); 21793 exports.default = toBoolean; 21794 21795 var _assertString = _interopRequireDefault(assertString_1); 21796 21797 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21798 21799 function toBoolean(str, strict) { 21800 (0, _assertString.default)(str); 21801 21802 if (strict) { 21803 return str === '1' || /^true$/i.test(str); 21804 } 21805 21806 return str !== '0' && !/^false$/i.test(str) && str !== ''; 21807 } 21808 21809 module.exports = exports.default; 21810 module.exports.default = exports.default; 21811 }); 21812 21813 var toBoolean = /*@__PURE__*/getDefaultExportFromCjs(toBoolean_1); 21814 21815 var equals_1 = createCommonjsModule(function (module, exports) { 21816 "use strict"; 21817 21818 Object.defineProperty(exports, "__esModule", { 21819 value: true 21820 }); 21821 exports.default = equals; 21822 21823 var _assertString = _interopRequireDefault(assertString_1); 21824 21825 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21826 21827 function equals(str, comparison) { 21828 (0, _assertString.default)(str); 21829 return str === comparison; 21830 } 21831 21832 module.exports = exports.default; 21833 module.exports.default = exports.default; 21834 }); 21835 21836 var equals = /*@__PURE__*/getDefaultExportFromCjs(equals_1); 21837 21838 var toString_1 = createCommonjsModule(function (module, exports) { 21839 "use strict"; 21840 21841 Object.defineProperty(exports, "__esModule", { 21842 value: true 21843 }); 21844 exports.default = toString; 21845 21846 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 21847 21848 function toString(input) { 21849 if (_typeof(input) === 'object' && input !== null) { 21850 if (typeof input.toString === 'function') { 21851 input = input.toString(); 21852 } else { 21853 input = '[object Object]'; 21854 } 21855 } else if (input === null || typeof input === 'undefined' || isNaN(input) && !input.length) { 21856 input = ''; 21857 } 21858 21859 return String(input); 21860 } 21861 21862 module.exports = exports.default; 21863 module.exports.default = exports.default; 21864 }); 21865 21866 var toString$1 = /*@__PURE__*/getDefaultExportFromCjs(toString_1); 21867 21868 var merge_1 = createCommonjsModule(function (module, exports) { 21869 "use strict"; 21870 21871 Object.defineProperty(exports, "__esModule", { 21872 value: true 21873 }); 21874 exports.default = merge; 21875 21876 function merge() { 21877 var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; 21878 var defaults = arguments.length > 1 ? arguments[1] : undefined; 21879 21880 for (var key in defaults) { 21881 if (typeof obj[key] === 'undefined') { 21882 obj[key] = defaults[key]; 21883 } 21884 } 21885 21886 return obj; 21887 } 21888 21889 module.exports = exports.default; 21890 module.exports.default = exports.default; 21891 }); 21892 21893 var merge = /*@__PURE__*/getDefaultExportFromCjs(merge_1); 21894 21895 var contains_1 = createCommonjsModule(function (module, exports) { 21896 "use strict"; 21897 21898 Object.defineProperty(exports, "__esModule", { 21899 value: true 21900 }); 21901 exports.default = contains; 21902 21903 var _assertString = _interopRequireDefault(assertString_1); 21904 21905 var _toString = _interopRequireDefault(toString_1); 21906 21907 var _merge = _interopRequireDefault(merge_1); 21908 21909 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21910 21911 var defaulContainsOptions = { 21912 ignoreCase: false 21913 }; 21914 21915 function contains(str, elem, options) { 21916 (0, _assertString.default)(str); 21917 options = (0, _merge.default)(options, defaulContainsOptions); 21918 return options.ignoreCase ? str.toLowerCase().indexOf((0, _toString.default)(elem).toLowerCase()) >= 0 : str.indexOf((0, _toString.default)(elem)) >= 0; 21919 } 21920 21921 module.exports = exports.default; 21922 module.exports.default = exports.default; 21923 }); 21924 21925 var contains = /*@__PURE__*/getDefaultExportFromCjs(contains_1); 21926 21927 var matches_1 = createCommonjsModule(function (module, exports) { 21928 "use strict"; 21929 21930 Object.defineProperty(exports, "__esModule", { 21931 value: true 21932 }); 21933 exports.default = matches; 21934 21935 var _assertString = _interopRequireDefault(assertString_1); 21936 21937 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21938 21939 function matches(str, pattern, modifiers) { 21940 (0, _assertString.default)(str); 21941 21942 if (Object.prototype.toString.call(pattern) !== '[object RegExp]') { 21943 pattern = new RegExp(pattern, modifiers); 21944 } 21945 21946 return pattern.test(str); 21947 } 21948 21949 module.exports = exports.default; 21950 module.exports.default = exports.default; 21951 }); 21952 21953 var matches = /*@__PURE__*/getDefaultExportFromCjs(matches_1); 21954 21955 var isByteLength_1 = createCommonjsModule(function (module, exports
21955) { 21956 "use strict"; 21957 21958 Object.defineProperty(exports, "__esModule", { 21959 value: true 21960 }); 21961 exports.default = isByteLength; 21962 21963 var _assertString = _interopRequireDefault(assertString_1); 21964 21965 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 21966 21967 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 21968 21969 /* eslint-disable prefer-rest-params */ 21970 function isByteLength(str, options) { 21971 (0, _assertString.default)(str); 21972 var min; 21973 var max; 21974 21975 if (_typeof(options) === 'object') { 21976 min = options.min || 0; 21977 max = options.max; 21978 } else { 21979 // backwards compatibility: isByteLength(str, min [, max]) 21980 min = arguments[1]; 21981 max = arguments[2]; 21982 } 21983 21984 var len = encodeURI(str).split(/%..|./).length - 1; 21985 return len >= min && (typeof max === 'undefined' || len <= max); 21986 } 21987 21988 module.exports = exports.default; 21989 module.exports.default = exports.default; 21990 }); 21991 21992 var isByteLength = /*@__PURE__*/getDefaultExportFromCjs(isByteLength_1); 21993 21994 var isFQDN_1 = createCommonjsModule(function (module, exports) { 21995 "use strict"; 21996 21997 Object.defineProperty(exports, "__esModule", { 21998 value: true 21999 }); 22000 exports.default = isFQDN; 22001 22002 var _assertString = _interopRequireDefault(assertString_1); 22003 22004 var _merge = _interopRequireDefault(merge_1); 22005 22006 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22007 22008 var default_fqdn_options = { 22009 require_tld: true, 22010 allow_underscores: false, 22011 allow_trailing_dot: false, 22012 allow_numeric_tld: false 22013 }; 22014 22015 function isFQDN(str, options) { 22016 (0, _assertString.default)(str); 22017 options = (0, _merge.default)(options, default_fqdn_options); 22018 /* Remove the optional trailing dot before checking validity */ 22019 22020 if (options.allow_trailing_dot && str[str.length - 1] === '.') { 22021 str = str.substring(0, str.length - 1); 22022 } 22023 22024 var parts = str.split('.'); 22025 var tld = parts[parts.length - 1]; 22026 22027 if (options.require_tld) { 22028 // disallow fqdns without tld 22029 if (parts.length < 2) { 22030 return false; 22031 } 22032 22033 if (!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(tld)) { 22034 return false; 22035 } // disallow spaces && special characers 22036 22037 22038 if (/[\s\u2002-\u200B\u202F\u205F\u3000\uFEFF\uDB40\uDC20\u00A9\uFFFD]/.test(tld)) { 22039 return false; 22040 } 22041 } // reject numeric TLDs 22042 22043 22044 if (!options.allow_numeric_tld && /^\d+$/.test(tld)) { 22045 return false; 22046 } 22047 22048 return parts.every(function (part) { 22049 if (part.length > 63) { 22050 return false; 22051 } 22052 22053 if (!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(part)) { 22054 return false; 22055 } // disallow full-width chars 22056 22057 22058 if (/[\uff01-\uff5e]/.test(part)) { 22059 return false; 22060 } // disallow parts starting or ending with hyphen 22061 22062 22063 if (/^-|-$/.test(part)) { 22064 return false; 22065 } 22066 22067 if (!options.allow_underscores && /_/.test(part)) { 22068 return false; 22069 } 22070 22071 return true; 22072 }); 22073 } 22074 22075 module.exports = exports.default; 22076 module.exports.default = exports.default; 22077 }); 22078 22079 var isFQDN = /*@__PURE__*/getDefaultExportFromCjs(isFQDN_1); 22080 22081 var isIP_1 = createCommonjsModule(function (module, exports) { 22082 "use strict"; 22083 22084 Object.defineProperty(exports, "__esModule", { 22085 value: true 22086 }); 22087 exports.default = isIP; 22088 22089 var _assertString = _interopRequireDefault(assertString_1); 22090 22091 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22092 22093 /** 22094 11.3. Examples 22095 22096 The following addresses 22097 22098 fe80::1234 (on the 1st link of the node) 22099 ff02::5678 (on the 5th link of the node) 22100 ff08::9abc (on the 10th organization of the node) 22101 22102 would be represented as follows: 22103 22104 fe80::1234%1 22105 ff02::5678%5 22106 ff08::9abc%10 22107 22108 (Here we assume a natural translation from a zone index to the 22109 <zone_id> part, where the Nth zone of any scope is translated into 22110 "N".) 22111 22112 If we use interface names as <zone_id>, those addresses could also be 22113 represented as follows: 22114 22115 fe80::1234%ne0 22116 ff02::5678%pvc1.3 22117 ff08::9abc%interface10 22118 22119 where the interface "ne0" belongs to the 1st link, "pvc1.3" belongs 22120 to the 5th link, and "interface10" belongs to the 10th organization. 22121 * * */ 22122 var ipv4Maybe = /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/; 22123 var ipv6Block = /^[0-9A-F]{1,4}$/i; 22124 22125 function isIP(str) { 22126 var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 22127 (0, _assertString.default)(str); 22128 version = String(version); 22129 22130 if (!version) { 22131 return isIP(str, 4) || isIP(str, 6); 22132 } else if (version === '4') { 22133 if (!ipv4Maybe.test(str)) { 22134 return false;
22135 } 22136 22137 var parts = str.split('.').sort(function (a, b) { 22138 return a - b; 22139 }); 22140 return parts[3] <= 255; 22141 } else if (version === '6') { 22142 var addressAndZone = [str]; // ipv6 addresses could have scoped architecture 22143 // according to https://tools.ietf.org/html/rfc4007#section-11 22144 22145 if (str.includes('%')) { 22146 addressAndZone = str.split('%'); 22147 22148 if (addressAndZone.length !== 2) { 22149 // it must be just two parts 22150 return false; 22151 } 22152 22153 if (!addressAndZone[0].includes(':')) { 22154 // the first part must be the address 22155 return false; 22156 } 22157 22158 if (addressAndZone[1] === '') { 22159 // the second part must not be empty 22160 return false; 22161 } 22162 } 22163 22164 var blocks = addressAndZone[0].split(':'); 22165 var foundOmissionBlock = false; // marker to indicate :: 22166 // At least some OS accept the last 32 bits of an IPv6 address 22167 // (i.e. 2 of the blocks) in IPv4 notation, and RFC 3493 says 22168 // that '::ffff:a.b.c.d' is valid for IPv4-mapped IPv6 addresses, 22169 // and '::a.b.c.d' is deprecated, but also valid. 22170 22171 var foundIPv4TransitionBlock = isIP(blocks[blocks.length - 1], 4); 22172 var expectedNumberOfBlocks = foundIPv4TransitionBlock ? 7 : 8; 22173 22174 if (blocks.length > expectedNumberOfBlocks) { 22175 return false; 22176 } // initial or final :: 22177 22178 22179 if (str === '::') { 22180 return true; 22181 } else if (str.substr(0, 2) === '::') { 22182 blocks.shift(); 22183 blocks.shift(); 22184 foundOmissionBlock = true; 22185 } else if (str.substr(str.length - 2) === '::') { 22186 blocks.pop(); 22187 blocks.pop(); 22188 foundOmissionBlock = true; 22189 } 22190 22191 for (var i = 0; i < blocks.length; ++i) { 22192 // test for a :: which can not be at the string start/end 22193 // since those cases have been handled above 22194 if (blocks[i] === '' && i > 0 && i < blocks.length - 1) { 22195 if (foundOmissionBlock) { 22196 return false; // multiple :: in address 22197 } 22198 22199 foundOmissionBlock = true; 22200 } else if (foundIPv4TransitionBlock && i === blocks.length - 1) {// it has been checked before that the last 22201 // block is a valid IPv4 address 22202 } else if (!ipv6Block.test(blocks[i])) { 22203 return false; 22204 } 22205 } 22206 22207 if (foundOmissionBlock) { 22208 return blocks.length >= 1; 22209 } 22210 22211 return blocks.length === expectedNumberOfBlocks; 22212 } 22213 22214 return false; 22215 } 22216 22217 module.exports = exports.default; 22218 module.exports.default = exports.default; 22219 }); 22220 22221 var isIP = /*@__PURE__*/getDefaultExportFromCjs(isIP_1); 22222 22223 var isEmail_1 = createCommonjsModule(function (module, exports) { 22224 "use strict"; 22225 22226 Object.defineProperty(exports, "__esModule", { 22227 value: true 22228 }); 22229 exports.default = isEmail; 22230 22231 var _assertString = _interopRequireDefault(assertString_1); 22232 22233 var _merge = _interopRequireDefault(merge_1); 22234 22235 var _isByteLength = _interopRequireDefault(isByteLength_1); 22236 22237 var _isFQDN = _interopRequireDefault(isFQDN_1); 22238 22239 var _isIP = _interopRequireDefault(isIP_1); 22240 22241 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22242 22243 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } 22244 22245 function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } 22246 22247 function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 22248 22249 function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } 22250 22251 function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } 22252 22253 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 22254 22255 var default_email_options = { 22256 allow_display_name: false, 22257 require_display_name: false, 22258 allow_utf8_local_part: true, 22259 require_tld: true, 22260 blacklisted_chars: '', 22261 ignore_max_length: false 22262 }; 22263 /* eslint-disable max-len */ 22264 22265 /* eslint-disable no-control-regex */ 22266 22267 var splitNameAddress = /^([^\x00-\x1F\x7F-\x9F\cX]+)<(.+)>$/i; 22268 var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i; 22269 var gmailUserPart = /^[a-z\d]+$/; 22270 var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i; 22271 var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i; 22272 var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i; 22273 var defaultMaxEmailLength = 254; 22274 /* eslint-enable max-len */ 22275 22276 /* eslint-enable no-control-regex */ 22277 22278 /** 22279 * Validate display name according to the RFC2822: https://tools.ietf.org/html/rfc2822#appendix-A.1.2 22280 * @param {String} display_name 22281 */ 22282 22283 function validateDisplayName(display_name) { 22284 var trim_quotes = display_name.match(/^"(.+)"$/i); 22285 var display_name_without_quotes = trim_quotes ? trim_quotes[1] : display_name;
22285 // display name with only spaces is not valid 22286 22287 if (!display_name_without_quotes.trim()) { 22288 return false; 22289 } // check whether display name contains illegal character 22290 22291 22292 var contains_illegal = /[\.";<>]/.test(display_name_without_quotes); 22293 22294 if (contains_illegal) { 22295 // if contains illegal characters, 22296 // must to be enclosed in double-quotes, otherwise it's not a valid display name 22297 if (!trim_quotes) { 22298 return false; 22299 } // the quotes in display name must start with character symbol \ 22300 22301 22302 var all_start_with_back_slash = display_name_without_quotes.split('"').length === display_name_without_quotes.split('\\"').length; 22303 22304 if (!all_start_with_back_slash) { 22305 return false; 22306 } 22307 } 22308 22309 return true; 22310 } 22311 22312 function isEmail(str, options) { 22313 (0, _assertString.default)(str); 22314 options = (0, _merge.default)(options, default_email_options); 22315 22316 if (options.require_display_name || options.allow_display_name) { 22317 var display_email = str.match(splitNameAddress); 22318 22319 if (display_email) { 22320 var display_name; 22321 22322 var _display_email = _slicedToArray(display_email, 3); 22323 22324 display_name = _display_email[1]; 22325 str = _display_email[2]; 22326 22327 // sometimes need to trim the last space to get the display name 22328 // because there may be a space between display name and email address 22329 // eg. myname <[email protected]> 22330 // the display name is `myname` instead of `myname `, so need to trim the last space 22331 if (display_name.endsWith(' ')) { 22332 display_name = display_name.substr(0, display_name.length - 1); 22333 } 22334 22335 if (!validateDisplayName(display_name)) { 22336 return false; 22337 } 22338 } else if (options.require_display_name) { 22339 return false; 22340 } 22341 } 22342 22343 if (!options.ignore_max_length && str.length > defaultMaxEmailLength) { 22344 return false; 22345 } 22346 22347 var parts = str.split('@'); 22348 var domain = parts.pop(); 22349 var user = parts.join('@'); 22350 var lower_domain = domain.toLowerCase(); 22351 22352 if (options.domain_specific_validation && (lower_domain === 'gmail.com' || lower_domain === 'googlemail.com')) { 22353 /* 22354 Previously we removed dots for gmail addresses before validating. 22355 This was removed because it allows `[email protected]` 22356 to be reported as valid, but it is not. 22357 Gmail only normalizes single dots, removing them from here is pointless, 22358 should be done in normalizeEmail 22359 */ 22360 user = user.toLowerCase(); // Removing sub-address from username before gmail validation 22361 22362 var username = user.split('+')[0]; // Dots are not included in gmail length restriction 22363 22364 if (!(0, _isByteLength.default)(username.replace('.', ''), { 22365 min: 6, 22366 max: 30 22367 })) { 22368 return false; 22369 } 22370 22371 var _user_parts = username.split('.'); 22372 22373 for (var i = 0; i < _user_parts.length; i++) { 22374 if (!gmailUserPart.test(_user_parts[i])) { 22375 return false; 22376 } 22377 } 22378 } 22379 22380 if (options.ignore_max_length === false && (!(0, _isByteLength.default)(user, { 22381 max: 64 22382 }) || !(0, _isByteLength.default)(domain, { 22383 max: 254 22384 }))) { 22385 return false; 22386 } 22387 22388 if (!(0, _isFQDN.default)(domain, { 22389 require_tld: options.require_tld 22390 })) { 22391 if (!options.allow_ip_domain) { 22392 return false; 22393 } 22394 22395 if (!(0, _isIP.default)(domain)) { 22396 if (!domain.startsWith('[') || !domain.endsWith(']')) { 22397 return false; 22398 } 22399 22400 var noBracketdomain = domain.substr(1, domain.length - 2); 22401 22402 if (noBracketdomain.length === 0 || !(0, _isIP.default)(noBracketdomain)) { 22403 return false; 22404 } 22405 } 22406 } 22407 22408 if (user[0] === '"') { 22409 user = user.slice(1, user.length - 1); 22410 return options.allow_utf8_local_part ? quotedEmailUserUtf8.test(user) : quotedEmailUser.test(user); 22411 } 22412 22413 var pattern = options.allow_utf8_local_part ? emailUserUtf8Part : emailUserPart; 22414 var user_parts = user.split('.'); 22415 22416 for (var _i2 = 0; _i2 < user_parts.length; _i2++) { 22417 if (!pattern.test(user_parts[_i2])) { 22418 return false; 22419 } 22420 } 22421
22422 if (options.blacklisted_chars) { 22423 if (user.search(new RegExp("[".concat(options.blacklisted_chars, "]+"), 'g')) !== -1) return false; 22424 } 22425 22426 return true; 22427 } 22428 22429 module.exports = exports.default; 22430 module.exports.default = exports.default; 22431 }); 22432 22433 var isEmail = /*@__PURE__*/getDefaultExportFromCjs(isEmail_1); 22434 22435 var isURL_1 = createCommonjsModule(function (module, exports) { 22436 "use strict"; 22437 22438 Object.defineProperty(exports, "__esModule", { 22439 value: true 22440 }); 22441 exports.default = isURL; 22442 22443 var _assertString = _interopRequireDefault(assertString_1); 22444 22445 var _isFQDN = _interopRequireDefault(isFQDN_1); 22446 22447 var _isIP = _interopRequireDefault(isIP_1); 22448 22449 var _merge = _interopRequireDefault(merge_1); 22450 22451 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22452 22453 /* 22454 options for isURL method 22455 22456 require_protocol - if set as true isURL will return false if protocol is not present in the URL 22457 require_valid_protocol - isURL will check if the URL's protocol is present in the protocols option 22458 protocols - valid protocols can be modified with this option 22459 require_host - if set as false isURL will not check if host is present in the URL 22460 require_port - if set as true isURL will check if port is present in the URL 22461 allow_protocol_relative_urls - if set as true protocol relative URLs will be allowed 22462 validate_length - if set as false isURL will skip string length validation (IE maximum is 2083) 22463 22464 */ 22465 var default_url_options = { 22466 protocols: ['http', 'https', 'ftp'], 22467 require_tld: true, 22468 require_protocol: false, 22469 require_host: true, 22470 require_port: false, 22471 require_valid_protocol: true, 22472 allow_underscores: false, 22473 allow_trailing_dot: false, 22474 allow_protocol_relative_urls: false, 22475 validate_length: true 22476 }; 22477 var wrapped_ipv6 = /^\[([^\]]+)\](?::([0-9]+))?$/; 22478 22479 function isRegExp(obj) { 22480 return Object.prototype.toString.call(obj) === '[object RegExp]'; 22481 } 22482 22483 function checkHost(host, matches) { 22484 for (var i = 0; i < matches.length; i++) { 22485 var match = matches[i]; 22486 22487 if (host === match || isRegExp(match) && match.test(host)) { 22488 return true; 22489 } 22490 } 22491 22492 return false; 22493 } 22494 22495 function isURL(url, options) { 22496 (0, _assertString.default)(url); 22497 22498 if (!url || /[\s<>]/.test(url)) { 22499 return false; 22500 } 22501 22502 if (url.indexOf('mailto:') === 0) { 22503 return false; 22504 } 22505 22506 options = (0, _merge.default)(options, default_url_options); 22507 22508 if (options.validate_length && url.length >= 2083) { 22509 return false; 22510 } 22511 22512 var protocol, auth, host, hostname, port, port_str, split, ipv6; 22513 split = url.split('#'); 22514 url = split.shift(); 22515 split = url.split('?'); 22516 url = split.shift(); 22517 split = url.split('://'); 22518 22519 if (split.length > 1) { 22520 protocol = split.shift().toLowerCase(); 22521 22522 if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) { 22523 return false; 22524 } 22525 } else if (options.require_protocol) { 22526 return false; 22527 } else if (url.substr(0, 2) === '//') { 22528 if (!options.allow_protocol_relative_urls) { 22529 return false; 22530 } 22531 22532 split[0] = url.substr(2); 22533 } 22534 22535 url = split.join('://'); 22536 22537 if (url === '') { 22538 return false; 22539 } 22540 22541 split = url.split('/'); 22542 url = split.shift(); 22543 22544 if (url === '' && !options.require_host) { 22545 return true; 22546 } 22547 22548 split = url.split('@'); 22549 22550 if (split.length > 1) { 22551 if (options.disallow_auth) { 22552 return false; 22553 } 22554 22555 auth = split.shift(); 22556 22557 if (auth.indexOf(':') === -1 || auth.indexOf(':') >= 0 && auth.split(':').length > 2) { 22558 return false; 22559 } 22560 } 22561 22562 hostname = split.join('@'); 22563 port_str = null; 22564 ipv6 = null; 22565 var ipv6_match = hostname.match(wrapped_ipv6); 22566 22567 if (ipv6_match) { 22568 host = ''; 22569 ipv6 = ipv6_match[1]; 22570 port_str = ipv6_match[2] || null; 22571 } else { 22572 split = hostname.split(':'); 22573 host = split.shift(); 22574 22575 if (split.length) { 22576 port_str = split.join(':'); 22577 } 22578 } 22579 22580 if (port_str !== null) { 22581 port = parseInt(port_str, 10); 22582 22583 if (!/^[0-9]+$/.test(port_str) || port <= 0 || port > 65535) { 22584 return false; 22585 } 22586 } else if (options.require_port) { 22587 return false;
22588 } 22589 22590 if (!(0, _isIP.default)(host) && !(0, _isFQDN.default)(host, options) && (!ipv6 || !(0, _isIP.default)(ipv6, 6))) { 22591 return false; 22592 } 22593 22594 host = host || ipv6; 22595 22596 if (options.host_whitelist && !checkHost(host, options.host_whitelist)) { 22597 return false; 22598 } 22599 22600 if (options.host_blacklist && checkHost(host, options.host_blacklist)) { 22601 return false; 22602 } 22603 22604 return true; 22605 } 22606 22607 module.exports = exports.default; 22608 module.exports.default = exports.default; 22609 }); 22610 22611 var isURL = /*@__PURE__*/getDefaultExportFromCjs(isURL_1); 22612 22613 var isMACAddress_1 = createCommonjsModule(function (module, exports) { 22614 "use strict"; 22615 22616 Object.defineProperty(exports, "__esModule", { 22617 value: true 22618 }); 22619 exports.default = isMACAddress; 22620 22621 var _assertString = _interopRequireDefault(assertString_1); 22622 22623 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22624 22625 var macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/; 22626 var macAddressNoColons = /^([0-9a-fA-F]){12}$/; 22627 var macAddressWithHyphen = /^([0-9a-fA-F][0-9a-fA-F]-){5}([0-9a-fA-F][0-9a-fA-F])$/; 22628 var macAddressWithSpaces = /^([0-9a-fA-F][0-9a-fA-F]\s){5}([0-9a-fA-F][0-9a-fA-F])$/; 22629 var macAddressWithDots = /^([0-9a-fA-F]{4}).([0-9a-fA-F]{4}).([0-9a-fA-F]{4})$/; 22630 22631 function isMACAddress(str, options) { 22632 (0, _assertString.default)(str); 22633 22634 if (options && options.no_colons) { 22635 return macAddressNoColons.test(str); 22636 } 22637 22638 return macAddress.test(str) || macAddressWithHyphen.test(str) || macAddressWithSpaces.test(str) || macAddressWithDots.test(str); 22639 } 22640 22641 module.exports = exports.default; 22642 module.exports.default = exports.default; 22643 }); 22644 22645 var isMACAddress = /*@__PURE__*/getDefaultExportFromCjs(isMACAddress_1); 22646 22647 var isIPRange_1 = createCommonjsModule(function (module, exports) { 22648 "use strict"; 22649 22650 Object.defineProperty(exports, "__esModule", { 22651 value: true 22652 }); 22653 exports.default = isIPRange; 22654 22655 var _assertString = _interopRequireDefault(assertString_1); 22656 22657 var _isIP = _interopRequireDefault(isIP_1); 22658 22659 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22660 22661 var subnetMaybe = /^\d{1,2}$/; 22662 22663 function isIPRange(str) { 22664 (0, _assertString.default)(str); 22665 var parts = str.split('/'); // parts[0] -> ip, parts[1] -> subnet 22666 22667 if (parts.length !== 2) { 22668 return false; 22669 } 22670 22671 if (!subnetMaybe.test(parts[1])) { 22672 return false; 22673 } // Disallow preceding 0 i.e. 01, 02, ... 22674 22675 22676 if (parts[1].length > 1 && parts[1].startsWith('0')) { 22677 return false; 22678 } 22679 22680 return (0, _isIP.default)(parts[0], 4) && parts[1] <= 32 && parts[1] >= 0; 22681 } 22682 22683 module.exports = exports.default; 22684 module.exports.default = exports.default; 22685 }); 22686 22687 var isIPRange = /*@__PURE__*/getDefaultExportFromCjs(isIPRange_1); 22688 22689 var isDate_1 = createCommonjsModule(function (module, exports) { 22690 "use strict"; 22691 22692 Object.defineProperty(exports, "__esModule", { 22693 value: true 22694 }); 22695 exports.default = isDate; 22696 22697 var _merge = _interopRequireDefault(merge_1); 22698 22699 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22700 22701 function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } 22702 22703 function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } 22704 22705 function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } 22706 22707 function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } 22708 22709 function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } 22710 22711 function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 22712 22713 function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } 22714 22715 var default_date_options = { 22716 format: 'YYYY/MM/DD', 22717 delimiters: ['/', '-'], 22718 strictMode: false 22719 }; 22720 22721 function isValidFormat(format) { 22722 return /(^(y{4}|y{2})[\/-](m{1,2}
22722)[\/-](d{1,2})$)|(^(m{1,2})[\/-](d{1,2})[\/-]((y{4}|y{2})$))|(^(d{1,2})[\/-](m{1,2})[\/-]((y{4}|y{2})$))/gi.test(format); 22723 } 22724 22725 function zip(date, format) { 22726 var zippedArr = [], 22727 len = Math.min(date.length, format.length); 22728 22729 for (var i = 0; i < len; i++) { 22730 zippedArr.push([date[i], format[i]]); 22731 } 22732 22733 return zippedArr; 22734 } 22735 22736 function isDate(input, options) { 22737 if (typeof options === 'string') { 22738 // Allow backward compatbility for old format isDate(input [, format]) 22739 options = (0, _merge.default)({ 22740 format: options 22741 }, default_date_options); 22742 } else { 22743 options = (0, _merge.default)(options, default_date_options); 22744 } 22745 22746 if (typeof input === 'string' && isValidFormat(options.format)) { 22747 var formatDelimiter = options.delimiters.find(function (delimiter) { 22748 return options.format.indexOf(delimiter) !== -1; 22749 }); 22750 var dateDelimiter = options.strictMode ? formatDelimiter : options.delimiters.find(function (delimiter) { 22751 return input.indexOf(delimiter) !== -1; 22752 }); 22753 var dateAndFormat = zip(input.split(dateDelimiter), options.format.toLowerCase().split(formatDelimiter)); 22754 var dateObj = {}; 22755 22756 var _iterator = _createForOfIteratorHelper(dateAndFormat), 22757 _step; 22758 22759 try { 22760 for (_iterator.s(); !(_step = _iterator.n()).done;) { 22761 var _step$value = _slicedToArray(_step.value, 2), 22762 dateWord = _step$value[0], 22763 formatWord = _step$value[1]; 22764 22765 if (dateWord.length !== formatWord.length) { 22766 return false; 22767 } 22768 22769 dateObj[formatWord.charAt(0)] = dateWord; 22770 } 22771 } catch (err) { 22772 _iterator.e(err); 22773 } finally { 22774 _iterator.f(); 22775 } 22776 22777 return new Date("".concat(dateObj.m, "/").concat(dateObj.d, "/").concat(dateObj.y)).getDate() === +dateObj.d; 22778 } 22779 22780 if (!options.strictMode) { 22781 return Object.prototype.toString.call(input) === '[object Date]' && isFinite(input); 22782 } 22783 22784 return false; 22785 } 22786 22787 module.exports = exports.default; 22788 module.exports.default = exports.default; 22789 }); 22790 22791 var isDate = /*@__PURE__*/getDefaultExportFromCjs(isDate_1); 22792 22793 var isBoolean_1 = createCommonjsModule(function (module, exports) { 22794 "use strict"; 22795 22796 Object.defineProperty(exports, "__esModule", { 22797 value: true 22798 }); 22799 exports.default = isBoolean; 22800 22801 var _assertString = _interopRequireDefault(assertString_1); 22802 22803 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22804 22805 function isBoolean(str) { 22806 (0, _assertString.default)(str); 22807 return ['true', 'false', '1', '0'].indexOf(str) >= 0; 22808 } 22809 22810 module.exports = exports.default; 22811 module.exports.default = exports.default; 22812 }); 22813 22814 var isBoolean = /*@__PURE__*/getDefaultExportFromCjs(isBoolean_1); 22815 22816 var isLocale_1 = createCommonjsModule(function (module, exports) { 22817 "use strict"; 22818 22819 Object.defineProperty(exports, "__esModule", { 22820 value: true 22821 }); 22822 exports.default = isLocale; 22823 22824 var _assertString = _interopRequireDefault(assertString_1); 22825 22826 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22827 22828 var localeReg = /^[A-z]{2,4}([_-]([A-z]{4}|[\d]{3}))?([_-]([A-z]{2}|[\d]{3}))?$/; 22829 22830 function isLocale(str) { 22831 (0, _assertString.default)(str); 22832 22833 if (str === 'en_US_POSIX' || str === 'ca_ES_VALENCIA') { 22834 return true; 22835 } 22836 22837 return localeReg.test(str); 22838 } 22839 22840 module.exports = exports.default; 22841 module.exports.default = exports.default; 22842 }); 22843 22844 var isLocale = /*@__PURE__*/getDefaultExportFromCjs(isLocale_1); 22845 22846 var isAlpha_1 = createCommonjsModule(function (module, exports) { 22847 "use strict"; 22848 22849 Object.defineProperty(exports, "__esModule", { 22850 value: true 22851 }); 22852 exports.default = isAlpha; 22853 exports.locales = void 0; 22854 22855 var _assertString = _interopRequireDefault(assertString_1); 22856 22857 22858 22859 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22860 22861 function isAlpha(_str) { 22862 var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US'; 22863 var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; 22864 (0, _assertString.default)(_str); 22865 var str = _str; 22866 var ignore = options.ignore; 22867 22868 if (ignore) { 22869 if (ignore instanceof RegExp) { 22870 str = str.replace(ignore, ''); 22871 } else if (typeof ignore === 'string') { 22872 str = str.replace(new RegExp("[".concat(ignore.replace(/[-[\]{}()*+?.,\\^$|#\\s]/g, '\\$&'), "]"), 'g'), ''); // escape regex for ignore 22873 } else { 22874 throw new Error('ignore should be instance of a String or RegExp'); 22875 } 22876 } 22877 22878 if (locale in alpha_1.alpha) { 22879 return alpha_1.alpha[locale].test(str); 22880 } 22881 22882 throw new Error("Invalid locale '".concat(locale, "'")); 22883 } 22884 22885 var locales = Object.keys(alpha_1.alpha); 22886 exports.locales = locales; 22887 }); 22888 22889 var isAlpha = /*@__PURE__*/getDefaultExportFromCjs(isAlpha_1); 22890 22891 var isAlphanumeric_1 = createCommonjsModule(function (module, exports
22891) { 22892 "use strict"; 22893 22894 Object.defineProperty(exports, "__esModule", { 22895 value: true 22896 }); 22897 exports.default = isAlphanumeric; 22898 exports.locales = void 0; 22899 22900 var _assertString = _interopRequireDefault(assertString_1); 22901 22902 22903 22904 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22905 22906 function isAlphanumeric(str) { 22907 var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US'; 22908 (0, _assertString.default)(str); 22909 22910 if (locale in alpha_1.alphanumeric) { 22911 return alpha_1.alphanumeric[locale].test(str); 22912 } 22913 22914 throw new Error("Invalid locale '".concat(locale, "'")); 22915 } 22916 22917 var locales = Object.keys(alpha_1.alphanumeric); 22918 exports.locales = locales; 22919 }); 22920 22921 var isAlphanumeric = /*@__PURE__*/getDefaultExportFromCjs(isAlphanumeric_1); 22922 22923 var isNumeric_1 = createCommonjsModule(function (module, exports) { 22924 "use strict"; 22925 22926 Object.defineProperty(exports, "__esModule", { 22927 value: true 22928 }); 22929 exports.default = isNumeric; 22930 22931 var _assertString = _interopRequireDefault(assertString_1); 22932 22933 22934 22935 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22936 22937 var numericNoSymbols = /^[0-9]+$/; 22938 22939 function isNumeric(str, options) { 22940 (0, _assertString.default)(str); 22941 22942 if (options && options.no_symbols) { 22943 return numericNoSymbols.test(str); 22944 } 22945 22946 return new RegExp("^[+-]?([0-9]*[".concat((options || {}).locale ? alpha_1.decimal[options.locale] : '.', "])?[0-9]+$")).test(str); 22947 } 22948 22949 module.exports = exports.default; 22950 module.exports.default = exports.default; 22951 }); 22952 22953 var isNumeric = /*@__PURE__*/getDefaultExportFromCjs(isNumeric_1); 22954 22955 var isPassportNumber_1 = createCommonjsModule(function (module, exports) { 22956 "use strict"; 22957 22958 Object.defineProperty(exports, "__esModule", { 22959 value: true 22960 }); 22961 exports.default = isPassportNumber; 22962 22963 var _assertString = _interopRequireDefault(assertString_1); 22964 22965 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 22966 22967 /** 22968 * Reference: 22969 * https://en.wikipedia.org/ -- Wikipedia 22970 * https://docs.microsoft.com/en-us/microsoft-365/compliance/eu-passport-number -- EU Passport Number 22971 * https://countrycode.org/ -- Country Codes 22972 */ 22973 var passportRegexByCountryCode = { 22974 AM: /^[A-Z]{2}\d{7}$/, 22975 // ARMENIA 22976 AR: /^[A-Z]{3}\d{6}$/, 22977 // ARGENTINA 22978 AT: /^[A-Z]\d{7}$/, 22979 // AUSTRIA 22980 AU: /^[A-Z]\d{7}$/, 22981 // AUSTRALIA 22982 BE: /^[A-Z]{2}\d{6}$/, 22983 // BELGIUM 22984 BG: /^\d{9}$/, 22985 // BULGARIA 22986 BY: /^[A-Z]{2}\d{7}$/, 22987 // BELARUS 22988 CA: /^[A-Z]{2}\d{6}$/, 22989 // CANADA 22990 CH: /^[A-Z]\d{7}$/, 22991 // SWITZERLAND 22992 CN: /^[GE]\d{8}$/, 22993 // CHINA [G=Ordinary, E=Electronic] followed by 8-digits 22994 CY: /^[A-Z](\d{6}|\d{8})$/, 22995 // CYPRUS 22996 CZ: /^\d{8}$/, 22997 // CZECH REPUBLIC 22998 DE: /^[CFGHJKLMNPRTVWXYZ0-9]{9}$/, 22999 // GERMANY 23000 DK: /^\d{9}$/, 23001 // DENMARK 23002 DZ: /^\d{9}$/, 23003 // ALGERIA 23004 EE: /^([A-Z]\d{7}|[A-Z]{2}\d{7})$/, 23005 // ESTONIA (K followed by 7-digits), e-passports have 2 UPPERCASE followed by 7 digits 23006 ES: /^[A-Z0-9]{2}([A-Z0-9]?)\d{6}$/, 23007 // SPAIN 23008 FI: /^[A-Z]{2}\d{7}$/, 23009 // FINLAND 23010 FR: /^\d{2}[A-Z]{2}\d{5}$/, 23011 // FRANCE 23012 GB: /^\d{9}$/, 23013 // UNITED KINGDOM 23014 GR: /^[A-Z]{2}\d{7}$/, 23015 // GREECE 23016 HR: /^\d{9}$/, 23017 // CROATIA 23018 HU: /^[A-Z]{2}(\d{6}|\d{7})$/, 23019 // HUNGARY 23020 IE: /^[A-Z0-9]{2}\d{7}$/, 23021 // IRELAND 23022 IN: /^[A-Z]{1}-?\d{7}$/, 23023 // INDIA 23024 IS: /^(A)\d{7}$/, 23025 // ICELAND 23026 IT: /^[A-Z0-9]{2}\d{7}$/, 23027 // ITALY 23028 JP: /^[A-Z]{2}\d{7}$/, 23029 // JAPAN 23030 KR: /^[MS]\d{8}$/, 23031 // SOUTH KOREA, REPUBLIC OF KOREA, [S=PS Passports, M=PM Passports] 23032 LT: /^[A-Z0-9]{8}$/, 23033 // LITHUANIA 23034 LU: /^[A-Z0-9]{8}$/, 23035 // LUXEMBURG 23036 LV: /^[A-Z0-9]{2}\d{7}$/, 23037 // LATVIA 23038 MT: /^\d{7}$/, 23039 // MALTA 23040 NL: /^[A-Z]{2}[A-Z0-9]{6}\d$/, 23041 // NETHERLANDS 23042 PO: /^[A-Z]{2}\d{7}$/, 23043 // POLAND 23044 PT: /^[A-Z]\d{6}$/, 23045 // PORTUGAL 23046 RO: /^\d{8,9}$/, 23047 // ROMANIA 23048 RU: /^\d{2}\d{2}\d{6}$/, 23049 // RUSSIAN FEDERATION 23050 SE: /^\d{8}$/, 23051 // SWEDEN 23052 SL: /^(P)[A-Z]\d{7}$/, 23053 // SLOVANIA 23054 SK: /^[0-9A-Z]\d{7}$/, 23055 // SLOVAKIA 23056 TR: /^[A-Z]\d{8}$/, 23057 // TURKEY 23058 UA: /^[A-Z]{2}\d{6}$/, 23059 // UKRAINE 23060 US: /^\d{9}$/ // UNITED STATES 23061 23062 }; 23063 /** 23064 * Check if str is a valid passport number 23065 * relative to provided ISO Country Code. 23066 * 23067 * @param {string} str 23068 * @param {string} countryCode 23069 * @return {boolean} 23070 */ 23071 23072 function isPassportNumber(str, countryCode) { 23073 (0, _assertString.default)(str);
23074 /** Remove All Whitespaces, Convert to UPPERCASE */ 23075 23076 var normalizedStr = str.replace(/\s/g, '').toUpperCase(); 23077 return countryCode.toUpperCase() in passportRegexByCountryCode && passportRegexByCountryCode[countryCode].test(normalizedStr); 23078 } 23079 23080 module.exports = exports.default; 23081 module.exports.default = exports.default; 23082 }); 23083 23084 var isPassportNumber = /*@__PURE__*/getDefaultExportFromCjs(isPassportNumber_1); 23085 23086 var isInt_1 = createCommonjsModule(function (module, exports) { 23087 "use strict"; 23088 23089 Object.defineProperty(exports, "__esModule", { 23090 value: true 23091 }); 23092 exports.default = isInt; 23093 23094 var _assertString = _interopRequireDefault(assertString_1); 23095 23096 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23097 23098 var int = /^(?:[-+]?(?:0|[1-9][0-9]*))$/; 23099 var intLeadingZeroes = /^[-+]?[0-9]+$/; 23100 23101 function isInt(str, options) { 23102 (0, _assertString.default)(str); 23103 options = options || {}; // Get the regex to use for testing, based on whether 23104 // leading zeroes are allowed or not. 23105 23106 var regex = options.hasOwnProperty('allow_leading_zeroes') && !options.allow_leading_zeroes ? int : intLeadingZeroes; // Check min/max/lt/gt 23107 23108 var minCheckPassed = !options.hasOwnProperty('min') || str >= options.min; 23109 var maxCheckPassed = !options.hasOwnProperty('max') || str <= options.max; 23110 var ltCheckPassed = !options.hasOwnProperty('lt') || str < options.lt; 23111 var gtCheckPassed = !options.hasOwnProperty('gt') || str > options.gt; 23112 return regex.test(str) && minCheckPassed && maxCheckPassed && ltCheckPassed && gtCheckPassed; 23113 } 23114 23115 module.exports = exports.default; 23116 module.exports.default = exports.default; 23117 }); 23118 23119 var isInt = /*@__PURE__*/getDefaultExportFromCjs(isInt_1); 23120 23121 var isPort_1 = createCommonjsModule(function (module, exports) { 23122 "use strict"; 23123 23124 Object.defineProperty(exports, "__esModule", { 23125 value: true 23126 }); 23127 exports.default = isPort; 23128 23129 var _isInt = _interopRequireDefault(isInt_1); 23130 23131 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23132 23133 function isPort(str) { 23134 return (0, _isInt.default)(str, { 23135 min: 0, 23136 max: 65535 23137 }); 23138 } 23139 23140 module.exports = exports.default; 23141 module.exports.default = exports.default; 23142 }); 23143 23144 var isPort = /*@__PURE__*/getDefaultExportFromCjs(isPort_1); 23145 23146 var isLowercase_1 = createCommonjsModule(function (module, exports) { 23147 "use strict"; 23148 23149 Object.defineProperty(exports, "__esModule", { 23150 value: true 23151 }); 23152 exports.default = isLowercase; 23153 23154 var _assertString = _interopRequireDefault(assertString_1); 23155 23156 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23157 23158 function isLowercase(str) { 23159 (0, _assertString.default)(str); 23160 return str === str.toLowerCase(); 23161 } 23162 23163 module.exports = exports.default; 23164 module.exports.default = exports.default; 23165 }); 23166 23167 var isLowercase = /*@__PURE__*/getDefaultExportFromCjs(isLowercase_1); 23168 23169 var isUppercase_1 = createCommonjsModule(function (module, exports) { 23170 "use strict"; 23171 23172 Object.defineProperty(exports, "__esModule", { 23173 value: true 23174 }); 23175 exports.default = isUppercase; 23176 23177 var _assertString = _interopRequireDefault(assertString_1); 23178 23179 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23180 23181 function isUppercase(str) { 23182 (0, _assertString.default)(str); 23183 return str === str.toUpperCase(); 23184 } 23185 23186 module.exports = exports.default; 23187 module.exports.default = exports.default; 23188 }); 23189 23190 var isUppercase = /*@__PURE__*/getDefaultExportFromCjs(isUppercase_1); 23191 23192 var isIMEI_1 = createCommonjsModule(function (module, exports) { 23193 "use strict"; 23194 23195 Object.defineProperty(exports, "__esModule", { 23196 value: true 23197 }); 23198 exports.default = isIMEI; 23199 23200 var _assertString = _interopRequireDefault(assertString_1); 23201 23202 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23203 23204 var imeiRegexWithoutHypens = /^[0-9]{15}$/; 23205 var imeiRegexWithHypens = /^\d{2}-\d{6}-\d{6}-\d{1}$/; 23206 23207 function isIMEI(str, options) { 23208 (0, _assertString.default)(str); 23209 options = options || {}; // default regex for checking imei is the one without hyphens 23210 23211 var imeiRegex = imeiRegexWithoutHypens; 23212 23213 if (options.allow_hyphens) { 23214 imeiRegex = imeiRegexWithHypens; 23215 } 23216 23217 if (!imeiRegex.test(str)) { 23218 return false;
23219 } 23220 23221 str = str.replace(/-/g, ''); 23222 var sum = 0, 23223 mul = 2, 23224 l = 14; 23225 23226 for (var i = 0; i < l; i++) { 23227 var digit = str.substring(l - i - 1, l - i); 23228 var tp = parseInt(digit, 10) * mul; 23229 23230 if (tp >= 10) { 23231 sum += tp % 10 + 1; 23232 } else { 23233 sum += tp; 23234 } 23235 23236 if (mul === 1) { 23237 mul += 1; 23238 } else { 23239 mul -= 1; 23240 } 23241 } 23242 23243 var chk = (10 - sum % 10) % 10; 23244 23245 if (chk !== parseInt(str.substring(14, 15), 10)) { 23246 return false; 23247 } 23248 23249 return true; 23250 } 23251 23252 module.exports = exports.default; 23253 module.exports.default = exports.default; 23254 }); 23255 23256 var isIMEI = /*@__PURE__*/getDefaultExportFromCjs(isIMEI_1); 23257 23258 var isAscii_1 = createCommonjsModule(function (module, exports) { 23259 "use strict"; 23260 23261 Object.defineProperty(exports, "__esModule", { 23262 value: true 23263 }); 23264 exports.default = isAscii; 23265 23266 var _assertString = _interopRequireDefault(assertString_1); 23267 23268 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23269 23270 /* eslint-disable no-control-regex */ 23271 var ascii = /^[\x00-\x7F]+$/; 23272 /* eslint-enable no-control-regex */ 23273 23274 function isAscii(str) { 23275 (0, _assertString.default)(str); 23276 return ascii.test(str); 23277 } 23278 23279 module.exports = exports.default; 23280 module.exports.default = exports.default; 23281 }); 23282 23283 var isAscii = /*@__PURE__*/getDefaultExportFromCjs(isAscii_1); 23284 23285 var isFullWidth_1 = createCommonjsModule(function (module, exports) { 23286 "use strict"; 23287 23288 Object.defineProperty(exports, "__esModule", { 23289 value: true 23290 }); 23291 exports.default = isFullWidth; 23292 exports.fullWidth = void 0; 23293 23294 var _assertString = _interopRequireDefault(assertString_1); 23295 23296 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23297 23298 var fullWidth = /[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/; 23299 exports.fullWidth = fullWidth; 23300 23301 function isFullWidth(str) { 23302 (0, _assertString.default)(str); 23303 return fullWidth.test(str); 23304 } 23305 }); 23306 23307 var isFullWidth = /*@__PURE__*/getDefaultExportFromCjs(isFullWidth_1); 23308 23309 var isHalfWidth_1 = createCommonjsModule(function (module, exports) { 23310 "use strict"; 23311 23312 Object.defineProperty(exports, "__esModule", { 23313 value: true 23314 }); 23315 exports.default = isHalfWidth; 23316 exports.halfWidth = void 0; 23317 23318 var _assertString = _interopRequireDefault(assertString_1); 23319 23320 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23321 23322 var halfWidth = /[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/; 23323 exports.halfWidth = halfWidth; 23324 23325 function isHalfWidth(str) { 23326 (0, _assertString.default)(str); 23327 return halfWidth.test(str); 23328 } 23329 }); 23330 23331 var isHalfWidth = /*@__PURE__*/getDefaultExportFromCjs(isHalfWidth_1); 23332 23333 var isVariableWidth_1 = createCommonjsModule(function (module, exports) { 23334 "use strict"; 23335 23336 Object.defineProperty(exports, "__esModule", { 23337 value: true 23338 }); 23339 exports.default = isVariableWidth; 23340 23341 var _assertString = _interopRequireDefault(assertString_1); 23342 23343 23344 23345 23346 23347 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23348 23349 function isVariableWidth(str) { 23350 (0, _assertString.default)(str); 23351 return isFullWidth_1.fullWidth.test(str) && isHalfWidth_1.halfWidth.test(str); 23352 } 23353 23354 module.exports = exports.default; 23355 module.exports.default = exports.default; 23356 }); 23357 23358 var isVariableWidth = /*@__PURE__*/getDefaultExportFromCjs(isVariableWidth_1); 23359 23360 var isMultibyte_1 = createCommonjsModule(function (module, exports) { 23361 "use strict"; 23362 23363 Object.defineProperty(exports, "__esModule", { 23364 value: true 23365 }); 23366 exports.default = isMultibyte; 23367 23368 var _assertString = _interopRequireDefault(assertString_1); 23369 23370 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23371 23372 /* eslint-disable no-control-regex */ 23373 var multibyte = /[^\x00-\x7F]/; 23374 /* eslint-enable no-control-regex */ 23375 23376 function isMultibyte(str) { 23377 (0, _assertString.default)(str); 23378 return multibyte.test(str); 23379 } 23380 23381 module.exports = exports.default; 23382 module.exports.default = exports.default; 23383 }); 23384 23385 var isMultibyte = /*@__PURE__*/getDefaultExportFromCjs(isMultibyte_1); 23386 23387 var multilineRegex = createCommonjsModule(function (module, exports
23387) { 23388 "use strict"; 23389 23390 Object.defineProperty(exports, "__esModule", { 23391 value: true 23392 }); 23393 exports.default = multilineRegexp; 23394 23395 /** 23396 * Build RegExp object from an array 23397 * of multiple/multi-line regexp parts 23398 * 23399 * @param {string[]} parts 23400 * @param {string} flags 23401 * @return {object} - RegExp object 23402 */ 23403 function multilineRegexp(parts, flags) { 23404 var regexpAsStringLiteral = parts.join(''); 23405 return new RegExp(regexpAsStringLiteral, flags); 23406 } 23407 23408 module.exports = exports.default; 23409 module.exports.default = exports.default; 23410 }); 23411 23412 var multilineRegex$1 = /*@__PURE__*/getDefaultExportFromCjs(multilineRegex); 23413 23414 var isSemVer_1 = createCommonjsModule(function (module, exports) { 23415 "use strict"; 23416 23417 Object.defineProperty(exports, "__esModule", { 23418 value: true 23419 }); 23420 exports.default = isSemVer; 23421 23422 var _assertString = _interopRequireDefault(assertString_1); 23423 23424 var _multilineRegex = _interopRequireDefault(multilineRegex); 23425 23426 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23427 23428 /** 23429 * Regular Expression to match 23430 * semantic versioning (SemVer) 23431 * built from multi-line, multi-parts regexp 23432 * Reference: https://semver.org/ 23433 */ 23434 var semanticVersioningRegex = (0, _multilineRegex.default)(['^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)', '(?:-((?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-z-][0-9a-z-]*))*))', '?(?:\\+([0-9a-z-]+(?:\\.[0-9a-z-]+)*))?$'], 'i'); 23435 23436 function isSemVer(str) { 23437 (0, _assertString.default)(str); 23438 return semanticVersioningRegex.test(str); 23439 } 23440 23441 module.exports = exports.default; 23442 module.exports.default = exports.default; 23443 }); 23444 23445 var isSemVer = /*@__PURE__*/getDefaultExportFromCjs(isSemVer_1); 23446 23447 var isSurrogatePair_1 = createCommonjsModule(function (module, exports) { 23448 "use strict"; 23449 23450 Object.defineProperty(exports, "__esModule", { 23451 value: true 23452 }); 23453 exports.default = isSurrogatePair; 23454 23455 var _assertString = _interopRequireDefault(assertString_1); 23456 23457 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23458 23459 var surrogatePair = /[\uD800-\uDBFF][\uDC00-\uDFFF]/; 23460 23461 function isSurrogatePair(str) { 23462 (0, _assertString.default)(str); 23463 return surrogatePair.test(str); 23464 } 23465 23466 module.exports = exports.default; 23467 module.exports.default = exports.default; 23468 }); 23469 23470 var isSurrogatePair = /*@__PURE__*/getDefaultExportFromCjs(isSurrogatePair_1); 23471 23472 var includes_1 = createCommonjsModule(function (module, exports) { 23473 "use strict"; 23474 23475 Object.defineProperty(exports, "__esModule", { 23476 value: true 23477 }); 23478 exports.default = void 0; 23479 23480 var includes = function includes(arr, val) { 23481 return arr.some(function (arrVal) { 23482 return val === arrVal; 23483 }); 23484 }; 23485 23486 var _default = includes; 23487 exports.default = _default; 23488 module.exports = exports.default; 23489 module.exports.default = exports.default; 23490 }); 23491 23492 var includes = /*@__PURE__*/getDefaultExportFromCjs(includes_1); 23493 23494 var isDecimal_1 = createCommonjsModule(function (module, exports) { 23495 "use strict"; 23496 23497 Object.defineProperty(exports, "__esModule", { 23498 value: true 23499 }); 23500 exports.default = isDecimal; 23501 23502 var _merge = _interopRequireDefault(merge_1); 23503 23504 var _assertString = _interopRequireDefault(assertString_1); 23505 23506 var _includes = _interopRequireDefault(includes_1); 23507 23508 23509 23510 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23511 23512 function decimalRegExp(options) { 23513 var regExp = new RegExp("^[-+]?([0-9]+)?(\\".concat(alpha_1.decimal[options.locale], "[0-9]{").concat(options.decimal_digits, "})").concat(options.force_decimal ? '' : '?', "$")); 23514 return regExp; 23515 } 23516 23517 var default_decimal_options = { 23518 force_decimal: false, 23519 decimal_digits: '1,', 23520 locale: 'en-US' 23521 }; 23522 var blacklist = ['', '-', '+']; 23523 23524 function isDecimal(str, options) { 23525 (0, _assertString.default)(str); 23526 options = (0, _merge.default)(options, default_decimal_options); 23527 23528 if (options.locale in alpha_1.decimal) { 23529 return !(0, _includes.default)(blacklist, str.replace(/ /g, '')) && decimalRegExp(options).test(str); 23530 } 23531 23532 throw new Error("Invalid locale '".concat(options.locale, "'")); 23533 } 23534 23535 module.exports = exports.default; 23536 module.exports.default = exports.default; 23537 }); 23538 23539 var isDecimal = /*@__PURE__*/getDefaultExportFromCjs(isDecimal_1); 23540 23541 var isHexadecimal_1 = createCommonjsModule(function (module, exports
23541) { 23542 "use strict"; 23543 23544 Object.defineProperty(exports, "__esModule", { 23545 value: true 23546 }); 23547 exports.default = isHexadecimal; 23548 23549 var _assertString = _interopRequireDefault(assertString_1); 23550 23551 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23552 23553 var hexadecimal = /^(0x|0h)?[0-9A-F]+$/i; 23554 23555 function isHexadecimal(str) { 23556 (0, _assertString.default)(str); 23557 return hexadecimal.test(str); 23558 } 23559 23560 module.exports = exports.default; 23561 module.exports.default = exports.default; 23562 }); 23563 23564 var isHexadecimal = /*@__PURE__*/getDefaultExportFromCjs(isHexadecimal_1); 23565 23566 var isOctal_1 = createCommonjsModule(function (module, exports) { 23567 "use strict"; 23568 23569 Object.defineProperty(exports, "__esModule", { 23570 value: true 23571 }); 23572 exports.default = isOctal; 23573 23574 var _assertString = _interopRequireDefault(assertString_1); 23575 23576 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23577 23578 var octal = /^(0o)?[0-7]+$/i; 23579 23580 function isOctal(str) { 23581 (0, _assertString.default)(str); 23582 return octal.test(str); 23583 } 23584 23585 module.exports = exports.default; 23586 module.exports.default = exports.default; 23587 }); 23588 23589 var isOctal = /*@__PURE__*/getDefaultExportFromCjs(isOctal_1); 23590 23591 var isDivisibleBy_1 = createCommonjsModule(function (module, exports) { 23592 "use strict"; 23593 23594 Object.defineProperty(exports, "__esModule", { 23595 value: true 23596 }); 23597 exports.default = isDivisibleBy; 23598 23599 var _assertString = _interopRequireDefault(assertString_1); 23600 23601 var _toFloat = _interopRequireDefault(toFloat_1); 23602 23603 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23604 23605 function isDivisibleBy(str, num) { 23606 (0, _assertString.default)(str); 23607 return (0, _toFloat.default)(str) % parseInt(num, 10) === 0; 23608 } 23609 23610 module.exports = exports.default; 23611 module.exports.default = exports.default; 23612 }); 23613 23614 var isDivisibleBy = /*@__PURE__*/getDefaultExportFromCjs(isDivisibleBy_1); 23615 23616 var isHexColor_1 = createCommonjsModule(function (module, exports) { 23617 "use strict"; 23618 23619 Object.defineProperty(exports, "__esModule", { 23620 value: true 23621 }); 23622 exports.default = isHexColor; 23623 23624 var _assertString = _interopRequireDefault(assertString_1); 23625 23626 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23627 23628 var hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{4}|[0-9A-F]{6}|[0-9A-F]{8})$/i; 23629 23630 function isHexColor(str) { 23631 (0, _assertString.default)(str); 23632 return hexcolor.test(str); 23633 } 23634 23635 module.exports = exports.default; 23636 module.exports.default = exports.default; 23637 }); 23638 23639 var isHexColor = /*@__PURE__*/getDefaultExportFromCjs(isHexColor_1); 23640 23641 var isRgbColor_1 = createCommonjsModule(function (module, exports) { 23642 "use strict"; 23643 23644 Object.defineProperty(exports, "__esModule", { 23645 value: true 23646 }); 23647 exports.default = isRgbColor; 23648 23649 var _assertString = _interopRequireDefault(assertString_1); 23650 23651 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23652 23653 var rgbColor = /^rgb\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){2}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\)$/; 23654 var rgbaColor = /^rgba\((([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)$/; 23655 var rgbColorPercent = /^rgb\((([0-9]%|[1-9][0-9]%|100%),){2}([0-9]%|[1-9][0-9]%|100%)\)/; 23656 var rgbaColorPercent = /^rgba\((([0-9]%|[1-9][0-9]%|100%),){3}(0?\.\d|1(\.0)?|0(\.0)?)\)/; 23657 23658 function isRgbColor(str) { 23659 var includePercentValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; 23660 (0, _assertString.default)(str); 23661 23662 if (!includePercentValues) { 23663 return rgbColor.test(str) || rgbaColor.test(str); 23664 } 23665 23666 return rgbColor.test(str) || rgbaColor.test(str) || rgbColorPercent.test(str) || rgbaColorPercent.test(str); 23667 } 23668 23669 module.exports = exports.default; 23670 module.exports.default = exports.default; 23671 }); 23672 23673 var isRgbColor = /*@__PURE__*/getDefaultExportFromCjs(isRgbColor_1); 23674 23675 var isHSL_1 = createCommonjsModule(function (module, exports) { 23676 "use strict"; 23677 23678 Object.defineProperty(exports, "__esModule", { 23679 value: true 23680 }); 23681 exports.default = isHSL; 23682 23683 var _assertString = _interopRequireDefault(assertString_1); 23684 23685 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23686 23687 var hslcomma = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s*)(\s*,\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(,\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i; 23688 var hslspace = /^(hsl)a?\(\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?))(deg|grad|rad|turn|\s)(\s*(\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%){2}\s*(\/\s*((\+|\-)?([0-9]+(\.[0-9]+)?(e(\+|\-)?[0-9]+)?|\.[0-9]+(e(\+|\-)?[0-9]+)?)%?)\s*)?\)$/i; 23689 23690 function isHSL(str) { 23691 (0, _assertString.default)(str); 23692 return hslcomma.test(str) || hslspace.test(str); 23693 } 23694 23695 module.exports = exports.default; 23696 module.exports.default = exports.default; 23697 }); 23698 23699 var isHSL = /*@__PURE__*/getDefaultExportFromCjs(isHSL_1); 23700
23701 var isISRC_1 = createCommonjsModule(function (module, exports) { 23702 "use strict"; 23703 23704 Object.defineProperty(exports, "__esModule", { 23705 value: true 23706 }); 23707 exports.default = isISRC; 23708 23709 var _assertString = _interopRequireDefault(assertString_1); 23710 23711 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23712 23713 // see http://isrc.ifpi.org/en/isrc-standard/code-syntax 23714 var isrc = /^[A-Z]{2}[0-9A-Z]{3}\d{2}\d{5}$/; 23715 23716 function isISRC(str) { 23717 (0, _assertString.default)(str); 23718 return isrc.test(str); 23719 } 23720 23721 module.exports = exports.default; 23722 module.exports.default = exports.default; 23723 }); 23724 23725 var isISRC = /*@__PURE__*/getDefaultExportFromCjs(isISRC_1); 23726 23727 var isIBAN_1 = createCommonjsModule(function (module, exports) { 23728 "use strict"; 23729 23730 Object.defineProperty(exports, "__esModule", { 23731 value: true 23732 }); 23733 exports.default = isIBAN; 23734 23735 var _assertString = _interopRequireDefault(assertString_1); 23736 23737 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23738 23739 /** 23740 * List of country codes with 23741 * corresponding IBAN regular expression 23742 * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number 23743 */ 23744 var ibanRegexThroughCountryCode = { 23745 AD: /^(AD[0-9]{2})\d{8}[A-Z0-9]{12}$/, 23746 AE: /^(AE[0-9]{2})\d{3}\d{16}$/, 23747 AL: /^(AL[0-9]{2})\d{8}[A-Z0-9]{16}$/, 23748 AT: /^(AT[0-9]{2})\d{16}$/, 23749 AZ: /^(AZ[0-9]{2})[A-Z0-9]{4}\d{20}$/, 23750 BA: /^(BA[0-9]{2})\d{16}$/, 23751 BE: /^(BE[0-9]{2})\d{12}$/, 23752 BG: /^(BG[0-9]{2})[A-Z]{4}\d{6}[A-Z0-9]{8}$/, 23753 BH: /^(BH[0-9]{2})[A-Z]{4}[A-Z0-9]{14}$/, 23754 BR: /^(BR[0-9]{2})\d{23}[A-Z]{1}[A-Z0-9]{1}$/, 23755 BY: /^(BY[0-9]{2})[A-Z0-9]{4}\d{20}$/, 23756 CH: /^(CH[0-9]{2})\d{5}[A-Z0-9]{12}$/, 23757 CR: /^(CR[0-9]{2})\d{18}$/, 23758 CY: /^(CY[0-9]{2})\d{8}[A-Z0-9]{16}$/, 23759 CZ: /^(CZ[0-9]{2})\d{20}$/, 23760 DE: /^(DE[0-9]{2})\d{18}$/, 23761 DK: /^(DK[0-9]{2})\d{14}$/, 23762 DO: /^(DO[0-9]{2})[A-Z]{4}\d{20}$/, 23763 EE: /^(EE[0-9]{2})\d{16}$/, 23764 EG: /^(EG[0-9]{2})\d{25}$/, 23765 ES: /^(ES[0-9]{2})\d{20}$/, 23766 FI: /^(FI[0-9]{2})\d{14}$/, 23767 FO: /^(FO[0-9]{2})\d{14}$/, 23768 FR: /^(FR[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/, 23769 GB: /^(GB[0-9]{2})[A-Z]{4}\d{14}$/, 23770 GE: /^(GE[0-9]{2})[A-Z0-9]{2}\d{16}$/, 23771 GI: /^(GI[0-9]{2})[A-Z]{4}[A-Z0-9]{15}$/, 23772 GL: /^(GL[0-9]{2})\d{14}$/, 23773 GR: /^(GR[0-9]{2})\d{7}[A-Z0-9]{16}$/, 23774 GT: /^(GT[0-9]{2})[A-Z0-9]{4}[A-Z0-9]{20}$/, 23775 HR: /^(HR[0-9]{2})\d{17}$/, 23776 HU: /^(HU[0-9]{2})\d{24}$/, 23777 IE: /^(IE[0-9]{2})[A-Z0-9]{4}\d{14}$/, 23778 IL: /^(IL[0-9]{2})\d{19}$/, 23779 IQ: /^(IQ[0-9]{2})[A-Z]{4}\d{15}$/, 23780 IR: /^(IR[0-9]{2})0\d{2}0\d{18}$/, 23781 IS: /^(IS[0-9]{2})\d{22}$/, 23782 IT: /^(IT[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/, 23783 JO: /^(JO[0-9]{2})[A-Z]{4}\d{22}$/, 23784 KW: /^(KW[0-9]{2})[A-Z]{4}[A-Z0-9]{22}$/, 23785 KZ: /^(KZ[0-9]{2})\d{3}[A-Z0-9]{13}$/, 23786 LB: /^(LB[0-9]{2})\d{4}[A-Z0-9]{20}$/, 23787 LC: /^(LC[0-9]{2})[A-Z]{4}[A-Z0-9]{24}$/, 23788 LI: /^(LI[0-9]{2})\d{5}[A-Z0-9]{12}$/, 23789 LT: /^(LT[0-9]{2})\d{16}$/, 23790 LU: /^(LU[0-9]{2})\d{3}[A-Z0-9]{13}$/, 23791 LV: /^(LV[0-9]{2})[A-Z]{4}[A-Z0-9]{13}$/, 23792 MC: /^(MC[0-9]{2})\d{10}[A-Z0-9]{11}\d{2}$/, 23793 MD: /^(MD[0-9]{2})[A-Z0-9]{20}$/, 23794 ME: /^(ME[0-9]{2})\d{18}$/, 23795 MK: /^(MK[0-9]{2})\d{3}[A-Z0-9]{10}\d{2}$/, 23796 MR: /^(MR[0-9]{2})\d{23}$/, 23797 MT: /^(MT[0-9]{2})[A-Z]{4}\d{5}[A-Z0-9]{18}$/, 23798 MU: /^(MU[0-9]{2})[A-Z]{4}\d{19}[A-Z]{3}$/, 23799 NL: /^(NL[0-9]{2})[A-Z]{4}\d{10}$/, 23800 NO: /^(NO[0-9]{2})\d{11}$/, 23801 PK: /^(PK[0-9]{2})[A-Z0-9]{4}\d{16}$/, 23802 PL: /^(PL[0-9]{2})\d{24}$/, 23803 PS: /^(PS[0-9]{2})[A-Z0-9]{4}\d{21}$/, 23804 PT: /^(PT[0-9]{2})\d{21}$/, 23805 QA: /^(QA[0-9]{2})[A-Z]{4}[A-Z0-9]{21}$/, 23806 RO: /^(RO[0-9]{2})[A-Z]{4}[A-Z0-9]{16}$/, 23807 RS: /^(RS[0-9]{2})\d{18}$/, 23808 SA: /^(SA[0-9]{2})\d{2}[A-Z0-9]{18}$/, 23809 SC: /^(SC[0-9]{2})[A-Z]{4}\d{20}[A-Z]{3}$/, 23810 SE: /^(SE[0-9]{2})\d{20}$/, 23811 SI: /^(SI[0-9]{2})\d{15}$/, 23812 SK: /^(SK[0-9]{2})\d{20}$/, 23813 SM: /^(SM[0-9]{2})[A-Z]{1}\d{10}[A-Z0-9]{12}$/, 23814 SV: /^(SV[0-9]{2})[A-Z0-9]{4}\d{20}$/, 23815 TL: /^(TL[0-9]{2})\d{19}$/, 23816 TN: /^(TN[0-9]{2})\d{20}$/, 23817 TR: /^(TR[0-9]{2})\d{5}[A-Z0-9]{17}$/, 23818 UA: /^(UA[0-9]{2})\d{6}[A-Z0-9]{19}$/, 23819 VA: /^(VA[0-9]{2})\d{18}$/, 23820 VG: /^(VG[0-9]{2})[A-Z0-9]{4}\d{16}$/, 23821 XK: /^(XK[0-9]{2})\d{16}$/ 23822 }; 23823 /** 23824 * Check whether string has correct universal IBAN format 23825 * The IBAN consists of up to 34 alphanumeric characters, as follows: 23826 * Country Code using ISO 3166-1 alpha-2, two letters 23827 * check digits, two digits and 23828 * Basic Bank Account Number (BBAN), up to 30 alphanumeric characters. 23829 * NOTE: Permitted IBAN characters are: digits [0-9] and the 26 latin alphabetic [A-Z] 23830 * 23831 * @param {string} str - string under validation 23832 * @return {boolean} 23833 */ 23834 23835 function hasValidIbanFormat(str) {
23836 // Strip white spaces and hyphens 23837 var strippedStr = str.replace(/[\s\-]+/gi, '').toUpperCase(); 23838 var isoCountryCode = strippedStr.slice(0, 2).toUpperCase(); 23839 return isoCountryCode in ibanRegexThroughCountryCode && ibanRegexThroughCountryCode[isoCountryCode].test(strippedStr); 23840 } 23841 /** 23842 * Check whether string has valid IBAN Checksum 23843 * by performing basic mod-97 operation and 23844 * the remainder should equal 1 23845 * -- Start by rearranging the IBAN by moving the four initial characters to the end of the string 23846 * -- Replace each letter in the string with two digits, A -> 10, B = 11, Z = 35 23847 * -- Interpret the string as a decimal integer and 23848 * -- compute the remainder on division by 97 (mod 97) 23849 * Reference: https://en.wikipedia.org/wiki/International_Bank_Account_Number 23850 * 23851 * @param {string} str 23852 * @return {boolean} 23853 */ 23854 23855 23856 function hasValidIbanChecksum(str) { 23857 var strippedStr = str.replace(/[^A-Z0-9]+/gi, '').toUpperCase(); // Keep only digits and A-Z latin alphabetic 23858 23859 var rearranged = strippedStr.slice(4) + strippedStr.slice(0, 4); 23860 var alphaCapsReplacedWithDigits = rearranged.replace(/[A-Z]/g, function (char) { 23861 return char.charCodeAt(0) - 55; 23862 }); 23863 var remainder = alphaCapsReplacedWithDigits.match(/\d{1,7}/g).reduce(function (acc, value) { 23864 return Number(acc + value) % 97; 23865 }, ''); 23866 return remainder === 1; 23867 } 23868 23869 function isIBAN(str) { 23870 (0, _assertString.default)(str); 23871 return hasValidIbanFormat(str) && hasValidIbanChecksum(str); 23872 } 23873 23874 module.exports = exports.default; 23875 module.exports.default = exports.default; 23876 }); 23877 23878 var isIBAN = /*@__PURE__*/getDefaultExportFromCjs(isIBAN_1); 23879 23880 var isBIC_1 = createCommonjsModule(function (module, exports) { 23881 "use strict"; 23882 23883 Object.defineProperty(exports, "__esModule", { 23884 value: true 23885 }); 23886 exports.default = isBIC; 23887 23888 var _assertString = _interopRequireDefault(assertString_1); 23889 23890 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23891 23892 var isBICReg = /^[A-z]{4}[A-z]{2}\w{2}(\w{3})?$/; 23893 23894 function isBIC(str) { 23895 (0, _assertString.default)(str); 23896 return isBICReg.test(str); 23897 } 23898 23899 module.exports = exports.default; 23900 module.exports.default = exports.default; 23901 }); 23902 23903 var isBIC = /*@__PURE__*/getDefaultExportFromCjs(isBIC_1); 23904 23905 var isMD5_1 = createCommonjsModule(function (module, exports) { 23906 "use strict"; 23907 23908 Object.defineProperty(exports, "__esModule", { 23909 value: true 23910 }); 23911 exports.default = isMD5; 23912 23913 var _assertString = _interopRequireDefault(assertString_1); 23914 23915 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23916 23917 var md5 = /^[a-f0-9]{32}$/; 23918 23919 function isMD5(str) { 23920 (0, _assertString.default)(str); 23921 return md5.test(str); 23922 } 23923 23924 module.exports = exports.default; 23925 module.exports.default = exports.default; 23926 }); 23927 23928 var isMD5 = /*@__PURE__*/getDefaultExportFromCjs(isMD5_1); 23929 23930 var isHash_1 = createCommonjsModule(function (module, exports) { 23931 "use strict"; 23932 23933 Object.defineProperty(exports, "__esModule", { 23934 value: true 23935 }); 23936 exports.default = isHash; 23937 23938 var _assertString = _interopRequireDefault(assertString_1); 23939 23940 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23941 23942 var lengths = { 23943 md5: 32, 23944 md4: 32, 23945 sha1: 40, 23946 sha256: 64, 23947 sha384: 96, 23948 sha512: 128, 23949 ripemd128: 32, 23950 ripemd160: 40, 23951 tiger128: 32, 23952 tiger160: 40, 23953 tiger192: 48, 23954 crc32: 8, 23955 crc32b: 8 23956 }; 23957 23958 function isHash(str, algorithm) { 23959 (0, _assertString.default)(str); 23960 var hash = new RegExp("^[a-fA-F0-9]{".concat(lengths[algorithm], "}$")); 23961 return hash.test(str); 23962 } 23963 23964 module.exports = exports.default; 23965 module.exports.default = exports.default; 23966 }); 23967 23968 var isHash = /*@__PURE__*/getDefaultExportFromCjs(isHash_1); 23969 23970 var isBase64_1 = createCommonjsModule(function (module, exports) { 23971 "use strict"; 23972 23973 Object.defineProperty(exports, "__esModule", { 23974 value: true 23975 }); 23976 exports.default = isBase64; 23977 23978 var _assertString = _interopRequireDefault(assertString_1); 23979 23980 var _merge = _interopRequireDefault(merge_1); 23981 23982 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 23983 23984 var notBase64 = /[^A-Z0-9+\/=]/i; 23985 var urlSafeBase64 = /^[A-Z0-9_\-]*$/i; 23986 var defaultBase64Options = { 23987 urlSafe: false 23988 }; 23989 23990 function isBase64(str, options) { 23991 (0, _assertString.default)(str); 23992 options = (0, _merge.default)(options, defaultBase64Options); 23993 var len = str.length; 23994 23995 if (options.urlSafe) { 23996 return urlSafeBase64.test(str); 23997 } 23998 23999 if (len % 4 !== 0 || notBase64.test(str)) { 24000 return false;
24001 } 24002 24003 var firstPaddingChar = str.indexOf('='); 24004 return firstPaddingChar === -1 || firstPaddingChar === len - 1 || firstPaddingChar === len - 2 && str[len - 1] === '='; 24005 } 24006 24007 module.exports = exports.default; 24008 module.exports.default = exports.default; 24009 }); 24010 24011 var isBase64 = /*@__PURE__*/getDefaultExportFromCjs(isBase64_1); 24012 24013 var isJWT_1 = createCommonjsModule(function (module, exports) { 24014 "use strict"; 24015 24016 Object.defineProperty(exports, "__esModule", { 24017 value: true 24018 }); 24019 exports.default = isJWT; 24020 24021 var _assertString = _interopRequireDefault(assertString_1); 24022 24023 var _isBase = _interopRequireDefault(isBase64_1); 24024 24025 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24026 24027 function isJWT(str) { 24028 (0, _assertString.default)(str); 24029 var dotSplit = str.split('.'); 24030 var len = dotSplit.length; 24031 24032 if (len > 3 || len < 2) { 24033 return false; 24034 } 24035 24036 return dotSplit.reduce(function (acc, currElem) { 24037 return acc && (0, _isBase.default)(currElem, { 24038 urlSafe: true 24039 }); 24040 }, true); 24041 } 24042 24043 module.exports = exports.default; 24044 module.exports.default = exports.default; 24045 }); 24046 24047 var isJWT = /*@__PURE__*/getDefaultExportFromCjs(isJWT_1); 24048 24049 var isJSON_1 = createCommonjsModule(function (module, exports) { 24050 "use strict"; 24051 24052 Object.defineProperty(exports, "__esModule", { 24053 value: true 24054 }); 24055 exports.default = isJSON; 24056 24057 var _assertString = _interopRequireDefault(assertString_1); 24058 24059 var _merge = _interopRequireDefault(merge_1); 24060 24061 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24062 24063 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 24064 24065 var default_json_options = { 24066 allow_primitives: false 24067 }; 24068 24069 function isJSON(str, options) { 24070 (0, _assertString.default)(str); 24071 24072 try { 24073 options = (0, _merge.default)(options, default_json_options); 24074 var primitives = []; 24075 24076 if (options.allow_primitives) { 24077 primitives = [null, false, true]; 24078 } 24079 24080 var obj = JSON.parse(str); 24081 return primitives.includes(obj) || !!obj && _typeof(obj) === 'object'; 24082 } catch (e) { 24083 /* ignore */ 24084 } 24085 24086 return false; 24087 } 24088 24089 module.exports = exports.default; 24090 module.exports.default = exports.default; 24091 }); 24092 24093 var isJSON = /*@__PURE__*/getDefaultExportFromCjs(isJSON_1); 24094 24095 var isEmpty_1 = createCommonjsModule(function (module, exports) { 24096 "use strict"; 24097 24098 Object.defineProperty(exports, "__esModule", { 24099 value: true 24100 }); 24101 exports.default = isEmpty; 24102 24103 var _assertString = _interopRequireDefault(assertString_1); 24104 24105 var _merge = _interopRequireDefault(merge_1); 24106 24107 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24108 24109 var default_is_empty_options = { 24110 ignore_whitespace: false 24111 }; 24112 24113 function isEmpty(str, options) { 24114 (0, _assertString.default)(str); 24115 options = (0, _merge.default)(options, default_is_empty_options); 24116 return (options.ignore_whitespace ? str.trim().length : str.length) === 0; 24117 } 24118 24119 module.exports = exports.default; 24120 module.exports.default = exports.default; 24121 }); 24122 24123 var isEmpty = /*@__PURE__*/getDefaultExportFromCjs(isEmpty_1); 24124 24125 var isLength_1 = createCommonjsModule(function (module, exports) { 24126 "use strict"; 24127 24128 Object.defineProperty(exports, "__esModule", { 24129 value: true 24130 }); 24131 exports.default = isLength; 24132 24133 var _assertString = _interopRequireDefault(assertString_1); 24134 24135 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24136 24137 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 24138 24139 /* eslint-disable prefer-rest-params */ 24140 function isLength(str, options) { 24141 (0, _assertString.default)(str); 24142 var min; 24143 var max; 24144 24145 if (_typeof(options) === 'object') { 24146 min = options.min || 0; 24147 max = options.max; 24148 } else { 24149 // backwards compatibility: isLength(str, min [, max]) 24150 min = arguments[1] || 0; 24151 max = arguments[2]; 24152 } 24153 24154 var surrogatePairs = str.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g) || []; 24155 var len = str.length - surrogatePairs.length; 24156 return len >= min && (typeof max === 'undefined' || len <= max); 24157 } 24158 24159 module.exports = exports.default; 24160 module.exports.default = exports.default; 24161 }); 24162 24163 var isLength = /*@__PURE__*/getDefaultExportFromCjs(isLength_1); 24164
24165 var isUUID_1 = createCommonjsModule(function (module, exports) { 24166 "use strict"; 24167 24168 Object.defineProperty(exports, "__esModule", { 24169 value: true 24170 }); 24171 exports.default = isUUID; 24172 24173 var _assertString = _interopRequireDefault(assertString_1); 24174 24175 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24176 24177 var uuid = { 24178 3: /^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i, 24179 4: /^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, 24180 5: /^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i, 24181 all: /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i 24182 }; 24183 24184 function isUUID(str) { 24185 var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'all'; 24186 (0, _assertString.default)(str); 24187 var pattern = uuid[version]; 24188 return pattern && pattern.test(str); 24189 } 24190 24191 module.exports = exports.default; 24192 module.exports.default = exports.default; 24193 }); 24194 24195 var isUUID = /*@__PURE__*/getDefaultExportFromCjs(isUUID_1); 24196 24197 var isMongoId_1 = createCommonjsModule(function (module, exports) { 24198 "use strict"; 24199 24200 Object.defineProperty(exports, "__esModule", { 24201 value: true 24202 }); 24203 exports.default = isMongoId; 24204 24205 var _assertString = _interopRequireDefault(assertString_1); 24206 24207 var _isHexadecimal = _interopRequireDefault(isHexadecimal_1); 24208 24209 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24210 24211 function isMongoId(str) { 24212 (0, _assertString.default)(str); 24213 return (0, _isHexadecimal.default)(str) && str.length === 24; 24214 } 24215 24216 module.exports = exports.default; 24217 module.exports.default = exports.default; 24218 }); 24219 24220 var isMongoId = /*@__PURE__*/getDefaultExportFromCjs(isMongoId_1); 24221 24222 var isAfter_1 = createCommonjsModule(function (module, exports) { 24223 "use strict"; 24224 24225 Object.defineProperty(exports, "__esModule", { 24226 value: true 24227 }); 24228 exports.default = isAfter; 24229 24230 var _assertString = _interopRequireDefault(assertString_1); 24231 24232 var _toDate = _interopRequireDefault(toDate_1); 24233 24234 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24235 24236 function isAfter(str) { 24237 var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date()); 24238 (0, _assertString.default)(str); 24239 var comparison = (0, _toDate.default)(date); 24240 var original = (0, _toDate.default)(str); 24241 return !!(original && comparison && original > comparison); 24242 } 24243 24244 module.exports = exports.default; 24245 module.exports.default = exports.default; 24246 }); 24247 24248 var isAfter = /*@__PURE__*/getDefaultExportFromCjs(isAfter_1); 24249 24250 var isBefore_1 = createCommonjsModule(function (module, exports) { 24251 "use strict"; 24252 24253 Object.defineProperty(exports, "__esModule", { 24254 value: true 24255 }); 24256 exports.default = isBefore; 24257 24258 var _assertString = _interopRequireDefault(assertString_1); 24259 24260 var _toDate = _interopRequireDefault(toDate_1); 24261 24262 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24263 24264 function isBefore(str) { 24265 var date = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : String(new Date()); 24266 (0, _assertString.default)(str); 24267 var comparison = (0, _toDate.default)(date); 24268 var original = (0, _toDate.default)(str); 24269 return !!(original && comparison && original < comparison); 24270 } 24271 24272 module.exports = exports.default; 24273 module.exports.default = exports.default; 24274 }); 24275 24276 var isBefore = /*@__PURE__*/getDefaultExportFromCjs(isBefore_1); 24277 24278 var isIn_1 = createCommonjsModule(function (module, exports) { 24279 "use strict"; 24280 24281 Object.defineProperty(exports, "__esModule", { 24282 value: true 24283 }); 24284 exports.default = isIn; 24285 24286 var _assertString = _interopRequireDefault(assertString_1); 24287 24288 var _toString = _interopRequireDefault(toString_1); 24289 24290 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24291 24292 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 24293 24294 function isIn(str, options) { 24295 (0, _assertString.default)(str); 24296 var i; 24297 24298 if (Object.prototype.toString.call(options) === '[object Array]') { 24299 var array = []; 24300 24301 for (i in options) { 24302 // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes 24303 // istanbul ignore else 24304 if ({}
24304.hasOwnProperty.call(options, i)) { 24305 array[i] = (0, _toString.default)(options[i]); 24306 } 24307 } 24308 24309 return array.indexOf(str) >= 0; 24310 } else if (_typeof(options) === 'object') { 24311 return options.hasOwnProperty(str); 24312 } else if (options && typeof options.indexOf === 'function') { 24313 return options.indexOf(str) >= 0; 24314 } 24315 24316 return false; 24317 } 24318 24319 module.exports = exports.default; 24320 module.exports.default = exports.default; 24321 }); 24322 24323 var isIn = /*@__PURE__*/getDefaultExportFromCjs(isIn_1); 24324 24325 var isCreditCard_1 = createCommonjsModule(function (module, exports) { 24326 "use strict"; 24327 24328 Object.defineProperty(exports, "__esModule", { 24329 value: true 24330 }); 24331 exports.default = isCreditCard; 24332 24333 var _assertString = _interopRequireDefault(assertString_1); 24334 24335 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24336 24337 /* eslint-disable max-len */ 24338 var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14})$/; 24339 /* eslint-enable max-len */ 24340 24341 function isCreditCard(str) { 24342 (0, _assertString.default)(str); 24343 var sanitized = str.replace(/[- ]+/g, ''); 24344 24345 if (!creditCard.test(sanitized)) { 24346 return false; 24347 } 24348 24349 var sum = 0; 24350 var digit; 24351 var tmpNum; 24352 var shouldDouble; 24353 24354 for (var i = sanitized.length - 1; i >= 0; i--) { 24355 digit = sanitized.substring(i, i + 1); 24356 tmpNum = parseInt(digit, 10); 24357 24358 if (shouldDouble) { 24359 tmpNum *= 2; 24360 24361 if (tmpNum >= 10) { 24362 sum += tmpNum % 10 + 1; 24363 } else { 24364 sum += tmpNum; 24365 } 24366 } else { 24367 sum += tmpNum; 24368 } 24369 24370 shouldDouble = !shouldDouble; 24371 } 24372 24373 return !!(sum % 10 === 0 ? sanitized : false); 24374 } 24375 24376 module.exports = exports.default; 24377 module.exports.default = exports.default; 24378 }); 24379 24380 var isCreditCard = /*@__PURE__*/getDefaultExportFromCjs(isCreditCard_1); 24381 24382 var isIdentityCard_1 = createCommonjsModule(function (module, exports) { 24383 "use strict"; 24384 24385 Object.defineProperty(exports, "__esModule", { 24386 value: true 24387 }); 24388 exports.default = isIdentityCard; 24389 24390 var _assertString = _interopRequireDefault(assertString_1); 24391 24392 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24393 24394 var validators = { 24395 ES: function ES(str) { 24396 (0, _assertString.default)(str); 24397 var DNI = /^[0-9X-Z][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$/; 24398 var charsValue = { 24399 X: 0, 24400 Y: 1, 24401 Z: 2 24402 }; 24403 var controlDigits = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E']; // sanitize user input 24404 24405 var sanitized = str.trim().toUpperCase(); // validate the data structure 24406 24407 if (!DNI.test(sanitized)) { 24408 return false; 24409 } // validate the control digit 24410 24411 24412 var number = sanitized.slice(0, -1).replace(/[X,Y,Z]/g, function (char) { 24413 return charsValue[char]; 24414 }); 24415 return sanitized.endsWith(controlDigits[number % 23]); 24416 }, 24417 IN: function IN(str) { 24418 var DNI = /^[1-9]\d{3}\s?\d{4}\s?\d{4}$/; // multiplication table 24419 24420 var d = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]; // permutation table 24421 24422 var p = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]]; // sanitize user input 24423 24424 var sanitized = str.trim(); // validate the data structure 24425 24426 if (!DNI.test(sanitized)) { 24427 return false; 24428 } 24429 24430 var c = 0; 24431 var invertedArray = sanitized.replace(/\s/g, '').split('').map(Number).reverse(); 24432 invertedArray.forEach(function (val, i) { 24433 c = d[c][p[i % 8][val]]; 24434 }); 24435 return c === 0; 24436 }, 24437 IT: function IT(str) { 24438 if (str.length !== 9) return false;
vendor: 4,208 bytes, lines 24439-24570
24439 if (str === 'CA00000AA') return false; // https://it.wikipedia.org/wiki/Carta_d%27identit%C3%A0_elettronica_italiana 24440 24441 return str.search(/C[A-Z][0-9]{5}[A-Z]{2}/i) > -1; 24442 }, 24443 NO: function NO(str) { 24444 var sanitized = str.trim(); 24445 if (isNaN(Number(sanitized))) return false; 24446 if (sanitized.length !== 11) return false; 24447 if (sanitized === '00000000000') return false; // https://no.wikipedia.org/wiki/F%C3%B8dselsnummer 24448 24449 var f = sanitized.split('').map(Number); 24450 var k1 = (11 - (3 * f[0] + 7 * f[1] + 6 * f[2] + 1 * f[3] + 8 * f[4] + 9 * f[5] + 4 * f[6] + 5 * f[7] + 2 * f[8]) % 11) % 11; 24451 var k2 = (11 - (5 * f[0] + 4 * f[1] + 3 * f[2] + 2 * f[3] + 7 * f[4] + 6 * f[5] + 5 * f[6] + 4 * f[7] + 3 * f[8] + 2 * k1) % 11) % 11; 24452 if (k1 !== f[9] || k2 !== f[10]) return false; 24453 return true; 24454 }, 24455 'he-IL': function heIL(str) { 24456 var DNI = /^\d{9}$/; // sanitize user input 24457 24458 var sanitized = str.trim(); // validate the data structure 24459 24460 if (!DNI.test(sanitized)) { 24461 return false; 24462 } 24463 24464 var id = sanitized; 24465 var sum = 0, 24466 incNum; 24467 24468 for (var i = 0; i < id.length; i++) { 24469 incNum = Number(id[i]) * (i % 2 + 1); // Multiply number by 1 or 2 24470 24471 sum += incNum > 9 ? incNum - 9 : incNum; // Sum the digits up and add to total 24472 } 24473 24474 return sum % 10 === 0; 24475 }, 24476 'ar-TN': function arTN(str) { 24477 var DNI = /^\d{8}$/; // sanitize user input 24478 24479 var sanitized = str.trim(); // validate the data structure 24480 24481 if (!DNI.test(sanitized)) { 24482 return false; 24483 } 24484 24485 return true; 24486 }, 24487 'zh-CN': function zhCN(str) { 24488 var provincesAndCities = ['11', // å京 24489 '12', // 天津 24490 '13', // æ²³å 24491 '14', // 山西 24492 '15', // å èå¤ 24493 '21', // è¾½å® 24494 '22', // åæ 24495 '23', // é»é¾æ± 24496 '31', // 䏿µ· 24497 '32', // æ±è 24498 '33', // æµæ± 24499 '34', // å®å¾½ 24500 '35', // ç¦å»º 24501 '36', // æ±è¥¿ 24502 '37', // å±±ä¸ 24503 '41', // æ²³å 24504 '42', // æ¹å 24505 '43', // æ¹å 24506 '44', // å¹¿ä¸ 24507 '45', // 广西 24508 '46', // æµ·å 24509 '50', // éåº 24510 '51', // åå· 24511 '52', // è´µå· 24512 '53', // äºå 24513 '54', // 西è 24514 '61', // é西 24515 '62', // çè 24516 '63', // éæµ· 24517 '64', // å®å¤ 24518 '65', // æ°ç 24519 '71', // å°æ¹¾ 24520 '81', // 馿¸¯ 24521 '82', // æ¾³é¨ 24522 '91' // å½å¤ 24523 ]; 24524 var powers = ['7', '9', '10', '5', '8', '4', '2', '1', '6', '3', '7', '9', '10', '5', '8', '4', '2']; 24525 var parityBit = ['1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2']; 24526 24527 var checkAddressCode = function checkAddressCode(addressCode) { 24528 return provincesAndCities.includes(addressCode); 24529 }; 24530 24531 var checkBirthDayCode = function checkBirthDayCode(birDayCode) { 24532 var yyyy = parseInt(birDayCode.substring(0, 4), 10); 24533 var mm = parseInt(birDayCode.substring(4, 6), 10); 24534 var dd = parseInt(birDayCode.substring(6), 10); 24535 var xdata = new Date(yyyy, mm - 1, dd); 24536 24537 if (xdata > new Date()) { 24538 return false; // eslint-disable-next-line max-len 24539 } else if (xdata.getFullYear() === yyyy && xdata.getMonth() === mm - 1 && xdata.getDate() === dd) { 24540 return true; 24541 } 24542 24543 return false; 24544 }; 24545 24546 var getParityBit = function getParityBit(idCardNo) { 24547 var id17 = idCardNo.substring(0, 17); 24548 var power = 0; 24549 24550 for (var i = 0; i < 17; i++) { 24551 power += parseInt(id17.charAt(i), 10) * parseInt(powers[i], 10); 24552 } 24553 24554 var mod = power % 11; 24555 return parityBit[mod]; 24556 }; 24557 24558 var checkParityBit = function checkParityBit(idCardNo) { 24559 return getParityBit(idCardNo) === idCardNo.charAt(17).toUpperCase(); 24560 }; 24561 24562 var check15IdCardNo = function check15IdCardNo(idCardNo) { 24563 var check = /^[1-9]\d{7}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}$/.test(idCardNo); 24564 if (!check) return false; 24565 var addressCode = idCardNo.substring(0, 2); 24566 check = checkAddressCode(addressCode); 24567 if (!check) return false; 24568 var birDayCode = "19".concat(idCardNo.substring(6, 12)); 24569 check = checkBirthDayCode(birDayCode); 24570 if (!check) return false;
24571 return true; 24572 }; 24573 24574 var check18IdCardNo = function check18IdCardNo(idCardNo) { 24575 var check = /^[1-9]\d{5}[1-9]\d{3}((0[1-9])|(1[0-2]))((0[1-9])|([1-2][0-9])|(3[0-1]))\d{3}(\d|x|X)$/.test(idCardNo); 24576 if (!check) return false; 24577 var addressCode = idCardNo.substring(0, 2); 24578 check = checkAddressCode(addressCode); 24579 if (!check) return false; 24580 var birDayCode = idCardNo.substring(6, 14); 24581 check = checkBirthDayCode(birDayCode); 24582 if (!check) return false; 24583 return checkParityBit(idCardNo); 24584 }; 24585 24586 var checkIdCardNo = function checkIdCardNo(idCardNo) { 24587 var check = /^\d{15}|(\d{17}(\d|x|X))$/.test(idCardNo); 24588 if (!check) return false; 24589 24590 if (idCardNo.length === 15) { 24591 return check15IdCardNo(idCardNo); 24592 } 24593 24594 return check18IdCardNo(idCardNo); 24595 }; 24596 24597 return checkIdCardNo(str); 24598 }, 24599 'zh-TW': function zhTW(str) { 24600 var ALPHABET_CODES = { 24601 A: 10, 24602 B: 11, 24603 C: 12, 24604 D: 13, 24605 E: 14, 24606 F: 15, 24607 G: 16, 24608 H: 17, 24609 I: 34, 24610 J: 18, 24611 K: 19, 24612 L: 20, 24613 M: 21, 24614 N: 22, 24615 O: 35, 24616 P: 23, 24617 Q: 24, 24618 R: 25, 24619 S: 26, 24620 T: 27, 24621 U: 28, 24622 V: 29, 24623 W: 32, 24624 X: 30, 24625 Y: 31, 24626 Z: 33 24627 }; 24628 var sanitized = str.trim().toUpperCase(); 24629 if (!/^[A-Z][0-9]{9}$/.test(sanitized)) return false; 24630 return Array.from(sanitized).reduce(function (sum, number, index) { 24631 if (index === 0) { 24632 var code = ALPHABET_CODES[number]; 24633 return code % 10 * 9 + Math.floor(code / 10); 24634 } 24635 24636 if (index === 9) { 24637 return (10 - sum % 10 - Number(number)) % 10 === 0; 24638 } 24639 24640 return sum + Number(number) * (9 - index); 24641 }, 0); 24642 } 24643 }; 24644 24645 function isIdentityCard(str, locale) { 24646 (0, _assertString.default)(str); 24647 24648 if (locale in validators) { 24649 return validators[locale](str); 24650 } else if (locale === 'any') { 24651 for (var key in validators) { 24652 // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes 24653 // istanbul ignore else 24654 if (validators.hasOwnProperty(key)) { 24655 var validator = validators[key]; 24656 24657 if (validator(str)) { 24658 return true; 24659 } 24660 } 24661 } 24662 24663 return false; 24664 } 24665 24666 throw new Error("Invalid locale '".concat(locale, "'")); 24667 } 24668 24669 module.exports = exports.default; 24670 module.exports.default = exports.default; 24671 }); 24672 24673 var isIdentityCard = /*@__PURE__*/getDefaultExportFromCjs(isIdentityCard_1); 24674 24675 var isEAN_1 = createCommonjsModule(function (module, exports) { 24676 "use strict"; 24677 24678 Object.defineProperty(exports, "__esModule", { 24679 value: true 24680 }); 24681 exports.default = isEAN; 24682 24683 var _assertString = _interopRequireDefault(assertString_1); 24684 24685 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24686 24687 /** 24688 * The most commonly used EAN standard is 24689 * the thirteen-digit EAN-13, while the 24690 * less commonly used 8-digit EAN-8 barcode was 24691 * introduced for use on small packages. 24692 * EAN consists of: 24693 * GS1 prefix, manufacturer code, product code and check digit 24694 * Reference: https://en.wikipedia.org/wiki/International_Article_Number 24695 */ 24696 24697 /** 24698 * Define EAN Lenghts; 8 for EAN-8; 13 for EAN-13 24699 * and Regular Expression for valid EANs (EAN-8, EAN-13), 24700 * with exact numberic matching of 8 or 13 digits [0-9] 24701 */ 24702 var LENGTH_EAN_8 = 8; 24703 var validEanRegex = /^(\d{8}|\d{13})$/; 24704 /** 24705 * Get position weight given: 24706 * EAN length and digit index/position 24707 * 24708 * @param {number} length 24709 * @param {number} index 24710 * @return {number} 24711 */ 24712 24713 function getPositionWeightThroughLengthAndIndex(length, index) { 24714 if (length === LENGTH_EAN_8) { 24715 return index % 2 === 0 ? 3 : 1; 24716 } 24717 24718 return index % 2 === 0 ? 1 : 3; 24719 } 24720 /** 24721 * Calculate EAN Check Digit 24722 * Reference: https://en.wikipedia.org/wiki/International_Article_Number#Calculation_of_checksum_digit 24723 * 24724 * @param {string} ean 24725 * @return {number} 24726 */ 24727 24728 24729 function calculateCheckDigit(ean) { 24730 var checksum = ean.slice(0, -1).split('').map(function (char, index) { 24731 return Number(char) * getPositionWeightThroughLengthAndIndex(ean.length, index); 24732 }).reduce(function (acc, partialSum) { 24733 return acc + partialSum; 24734 }, 0); 24735 var remainder = 10 - checksum % 10; 24736 return remainder < 10 ? remainder : 0; 24737 } 24738 /** 24739 * Check if string is valid EAN: 24740 * Matches EAN-8/EAN-13 regex 24741 * Has valid check digit. 24742 * 24743 * @param {string} str 24744 * @return {boolean} 24745 */ 24746 24747 24748 function isEAN(str) { 24749 (0, _assertString.default)(str); 24750 var actualCheckDigit = Number(str.slice(-1)); 24751 return validEanRegex.test(str) && actualCheckDigit === calculateCheckDigit(str); 24752 } 24753 24754 module.exports = exports.default; 24755 module.exports.default = exports.default; 24756 }); 24757 24758 var isEAN = /*@__PURE__*/getDefaultExportFromCjs(isEAN_1); 24759
24760 var isISIN_1 = createCommonjsModule(function (module, exports) { 24761 "use strict"; 24762 24763 Object.defineProperty(exports, "__esModule", { 24764 value: true 24765 }); 24766 exports.default = isISIN; 24767 24768 var _assertString = _interopRequireDefault(assertString_1); 24769 24770 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24771 24772 var isin = /^[A-Z]{2}[0-9A-Z]{9}[0-9]$/; 24773 24774 function isISIN(str) { 24775 (0, _assertString.default)(str); 24776 24777 if (!isin.test(str)) { 24778 return false; 24779 } 24780 24781 var checksumStr = str.replace(/[A-Z]/g, function (character) { 24782 return parseInt(character, 36); 24783 }); 24784 var sum = 0; 24785 var digit; 24786 var tmpNum; 24787 var shouldDouble = true; 24788 24789 for (var i = checksumStr.length - 2; i >= 0; i--) { 24790 digit = checksumStr.substring(i, i + 1); 24791 tmpNum = parseInt(digit, 10); 24792 24793 if (shouldDouble) { 24794 tmpNum *= 2; 24795 24796 if (tmpNum >= 10) { 24797 sum += tmpNum + 1; 24798 } else { 24799 sum += tmpNum; 24800 } 24801 } else { 24802 sum += tmpNum; 24803 } 24804 24805 shouldDouble = !shouldDouble; 24806 } 24807 24808 return parseInt(str.substr(str.length - 1), 10) === (10000 - sum) % 10; 24809 } 24810 24811 module.exports = exports.default; 24812 module.exports.default = exports.default; 24813 }); 24814 24815 var isISIN = /*@__PURE__*/getDefaultExportFromCjs(isISIN_1); 24816 24817 var isISBN_1 = createCommonjsModule(function (module, exports) { 24818 "use strict"; 24819 24820 Object.defineProperty(exports, "__esModule", { 24821 value: true 24822 }); 24823 exports.default = isISBN; 24824 24825 var _assertString = _interopRequireDefault(assertString_1); 24826 24827 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24828 24829 var isbn10Maybe = /^(?:[0-9]{9}X|[0-9]{10})$/; 24830 var isbn13Maybe = /^(?:[0-9]{13})$/; 24831 var factor = [1, 3]; 24832 24833 function isISBN(str) { 24834 var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; 24835 (0, _assertString.default)(str); 24836 version = String(version); 24837 24838 if (!version) { 24839 return isISBN(str, 10) || isISBN(str, 13); 24840 } 24841 24842 var sanitized = str.replace(/[\s-]+/g, ''); 24843 var checksum = 0; 24844 var i; 24845 24846 if (version === '10') { 24847 if (!isbn10Maybe.test(sanitized)) { 24848 return false; 24849 } 24850 24851 for (i = 0; i < 9; i++) { 24852 checksum += (i + 1) * sanitized.charAt(i); 24853 } 24854 24855 if (sanitized.charAt(9) === 'X') { 24856 checksum += 10 * 10; 24857 } else { 24858 checksum += 10 * sanitized.charAt(9); 24859 } 24860 24861 if (checksum % 11 === 0) { 24862 return !!sanitized; 24863 } 24864 } else if (version === '13') { 24865 if (!isbn13Maybe.test(sanitized)) { 24866 return false; 24867 } 24868 24869 for (i = 0; i < 12; i++) { 24870 checksum += factor[i % 2] * sanitized.charAt(i); 24871 } 24872 24873 if (sanitized.charAt(12) - (10 - checksum % 10) % 10 === 0) { 24874 return !!sanitized; 24875 } 24876 } 24877 24878 return false; 24879 } 24880 24881 module.exports = exports.default; 24882 module.exports.default = exports.default; 24883 }); 24884 24885 var isISBN = /*@__PURE__*/getDefaultExportFromCjs(isISBN_1); 24886 24887 var isISSN_1 = createCommonjsModule(function (module, exports) { 24888 "use strict"; 24889 24890 Object.defineProperty(exports, "__esModule", { 24891 value: true 24892 }); 24893 exports.default = isISSN; 24894 24895 var _assertString = _interopRequireDefault(assertString_1); 24896 24897 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 24898 24899 var issn = '^\\d{4}-?\\d{3}[\\dX]$'; 24900 24901 function isISSN(str) { 24902 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 24903 (0, _assertString.default)(str); 24904 var testIssn = issn; 24905 testIssn = options.require_hyphen ? testIssn.replace('?', '') : testIssn; 24906 testIssn = options.case_sensitive ? new RegExp(testIssn) : new RegExp(testIssn, 'i'); 24907 24908 if (!testIssn.test(str)) { 24909 return false; 24910 } 24911 24912 var digits = str.replace('-', '').toUpperCase(); 24913 var checksum = 0; 24914 24915 for (var i = 0; i < digits.length; i++) { 24916 var digit = digits[i]; 24917 checksum += (digit === 'X' ? 10 : +digit) * (8 - i); 24918 } 24919 24920 return checksum % 11 === 0; 24921 } 24922 24923 module.exports = exports.default; 24924 module.exports.default = exports.default; 24925 }); 24926 24927 var isISSN = /*@__PURE__*/getDefaultExportFromCjs(isISSN_1); 24928 24929 "use strict"; 24930 24931 24932 var iso7064Check_1 = iso7064Check; 24933 var luhnCheck_1 = luhnCheck; 24934 var reverseMultiplyAndSum_1 = reverseMultiplyAndSum; 24935 var verhoeffCheck_1 = verhoeffCheck; 24936 24937 /** 24938 * Algorithmic validation functions 24939 * May be used as is or implemented in the workflow of other validators. 24940 */ 24941 24942 /* 24943 * ISO 7064 validation function 24944 * Called with a string of numbers (incl. check digit) 24945 * to validate according to ISO 7064 (MOD 11, 10). 24946 */ 24947 function iso7064Check(str) { 24948 var checkvalue = 10; 24949 24950 for (var i = 0; i < str.length - 1; i++) { 24951 checkvalue = (parseInt(str[i], 10) + checkvalue) % 10 === 0 ? 10 * 2 % 11 : (parseInt(str[i], 10) + checkvalue) % 10 * 2 % 11; 24952 } 24953 24954 checkvalue = checkvalue === 1 ? 0 : 11 - checkvalue; 24955 return checkvalue === parseInt(str[10], 10); 24956 } 24957 /* 24958 * Luhn (mod 10) validation function 24959 * Called with a string of numbers (incl. check digit) 24960 * to validate according to the Luhn algorithm. 24961 */ 24962 24963 24964 function luhnCheck(str) { 24965 var checksum = 0; 24966 var second = false;
24967 24968 for (var i = str.length - 1; i >= 0; i--) { 24969 if (second) { 24970 var product = parseInt(str[i], 10) * 2; 24971 24972 if (product > 9) { 24973 // sum digits of product and add to checksum 24974 checksum += product.toString().split('').map(function (a) { 24975 return parseInt(a, 10); 24976 }).reduce(function (a, b) { 24977 return a + b; 24978 }, 0); 24979 } else { 24980 checksum += product; 24981 } 24982 } else { 24983 checksum += parseInt(str[i], 10); 24984 } 24985 24986 second = !second; 24987 } 24988 24989 return checksum % 10 === 0; 24990 } 24991 /* 24992 * Reverse TIN multiplication and summation helper function 24993 * Called with an array of single-digit integers and a base multiplier 24994 * to calculate the sum of the digits multiplied in reverse. 24995 * Normally used in variations of MOD 11 algorithmic checks. 24996 */ 24997 24998 24999 function reverseMultiplyAndSum(digits, base) { 25000 var total = 0; 25001 25002 for (var i = 0; i < digits.length; i++) { 25003 total += digits[i] * (base - i); 25004 } 25005 25006 return total; 25007 } 25008 /* 25009 * Verhoeff validation helper function 25010 * Called with a string of numbers 25011 * to validate according to the Verhoeff algorithm. 25012 */ 25013 25014 25015 function verhoeffCheck(str) { 25016 var d_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 0, 6, 7, 8, 9, 5], [2, 3, 4, 0, 1, 7, 8, 9, 5, 6], [3, 4, 0, 1, 2, 8, 9, 5, 6, 7], [4, 0, 1, 2, 3, 9, 5, 6, 7, 8], [5, 9, 8, 7, 6, 0, 4, 3, 2, 1], [6, 5, 9, 8, 7, 1, 0, 4, 3, 2], [7, 6, 5, 9, 8, 2, 1, 0, 4, 3], [8, 7, 6, 5, 9, 3, 2, 1, 0, 4], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]; 25017 var p_table = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 5, 7, 6, 2, 8, 3, 0, 9, 4], [5, 8, 0, 3, 7, 9, 6, 1, 4, 2], [8, 9, 1, 6, 0, 4, 3, 5, 2, 7], [9, 4, 5, 3, 1, 2, 6, 8, 7, 0], [4, 2, 8, 6, 5, 7, 3, 9, 0, 1], [2, 7, 9, 3, 8, 0, 6, 4, 1, 5], [7, 0, 4, 6, 9, 1, 3, 2, 5, 8]]; // Copy (to prevent replacement) and reverse 25018 25019 var str_copy = str.split('').reverse().join(''); 25020 var checksum = 0; 25021 25022 for (var i = 0; i < str_copy.length; i++) { 25023 checksum = d_table[checksum][p_table[i % 8][parseInt(str_copy[i], 10)]]; 25024 } 25025 25026 return checksum === 0; 25027 } 25028 25029 var algorithms = /*#__PURE__*/Object.defineProperty({ 25030 iso7064Check: iso7064Check_1, 25031 luhnCheck: luhnCheck_1, 25032 reverseMultiplyAndSum: reverseMultiplyAndSum_1, 25033 verhoeffCheck: verhoeffCheck_1 25034 }, '__esModule', {value: true}); 25035 25036 var isTaxID_1 = createCommonjsModule(function (module, exports) { 25037 "use strict"; 25038 25039 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 25040 25041 Object.defineProperty(exports, "__esModule", { 25042 value: true 25043 }); 25044 exports.default = isTaxID; 25045 25046 var _assertString = _interopRequireDefault(assertString_1); 25047 25048 var algorithms$1 = _interopRequireWildcard(algorithms); 25049 25050 var _isDate = _interopRequireDefault(isDate_1); 25051 25052 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } 25053 25054 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 25055 25056 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 25057 25058 function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } 25059 25060 function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } 25061 25062 function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 25063 25064 function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } 25065 25066 function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } 25067 25068 function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } 25069 25070 /** 25071 * TIN Validation 25072 * Validates Tax Identification Numbers (TINs) from the US, EU member states and the United Kingdom. 25073 * 25074 * EU-UK: 25075 * National TIN validity is calculated using public algorithms as made available by DG TAXUD. 25076 * 25077 * See `https://ec.europa.eu/taxation_customs/tin/specs/FS-TIN%20Algorithms-Public.docx` for more information. 25078 * 25079 * US: 25080 * An Employer Identification Number (EIN), also known as a Federal Tax Identification Number, 25081 * is used to identify a business entity. 25082 * 25083 * NOTES: 25084 * - Prefix 47 is being reserved for future use 25085 * - Prefixes 26, 27, 45, 46 and 47 were previously assigned by the Philadelphia campus. 25086 * 25087 * See `http://www.irs.gov/Businesses/Small-Businesses-&-Self-Employed/How-EINs-are-Assigned-and-Valid-EIN-Prefixes` 25088 * for more information. 25089 */ 25090 // Locale functions 25091 25092 /* 25093 * bg-BG validation function 25094 * (Edinen graždanski nomer (EGN/ÐÐÐ), persons only) 25095 * Checks if birth date (first six digits) is valid and calculates check (last) digit 25096 */ 25097 function bgBgCheck(tin) { 25098 // Extract full year, normalize month and check birth date validity 25099 var century_year = tin.slice(0, 2);
vendor: 33,647 bytes, lines 25100-26392
25100 var month = parseInt(tin.slice(2, 4), 10); 25101 25102 if (month > 40) { 25103 month -= 40; 25104 century_year = "20".concat(century_year); 25105 } else if (month > 20) { 25106 month -= 20; 25107 century_year = "18".concat(century_year); 25108 } else { 25109 century_year = "19".concat(century_year); 25110 } 25111 25112 if (month < 10) { 25113 month = "0".concat(month); 25114 } 25115 25116 var date = "".concat(century_year, "/").concat(month, "/").concat(tin.slice(4, 6)); 25117 25118 if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 25119 return false; 25120 } // split digits into an array for further processing 25121 25122 25123 var digits = tin.split('').map(function (a) { 25124 return parseInt(a, 10); 25125 }); // Calculate checksum by multiplying digits with fixed values 25126 25127 var multip_lookup = [2, 4, 8, 5, 10, 9, 7, 3, 6]; 25128 var checksum = 0; 25129 25130 for (var i = 0; i < multip_lookup.length; i++) { 25131 checksum += digits[i] * multip_lookup[i]; 25132 } 25133 25134 checksum = checksum % 11 === 10 ? 0 : checksum % 11; 25135 return checksum === digits[9]; 25136 } 25137 /* 25138 * cs-CZ validation function 25139 * (Rodné ÄÃslo (RÄ), persons only) 25140 * Checks if birth date (first six digits) is valid and divisibility by 11 25141 * Material not in DG TAXUD document sourced from: 25142 * -`https://lorenc.info/3MA381/overeni-spravnosti-rodneho-cisla.htm` 25143 * -`https://www.mvcr.cz/clanek/rady-a-sluzby-dokumenty-rodne-cislo.aspx` 25144 */ 25145 25146 25147 function csCzCheck(tin) { 25148 tin = tin.replace(/\W/, ''); // Extract full year from TIN length 25149 25150 var full_year = parseInt(tin.slice(0, 2), 10); 25151 25152 if (tin.length === 10) { 25153 if (full_year < 54) { 25154 full_year = "20".concat(full_year); 25155 } else { 25156 full_year = "19".concat(full_year); 25157 } 25158 } else { 25159 if (tin.slice(6) === '000') { 25160 return false; 25161 } // Three-zero serial not assigned before 1954 25162 25163 25164 if (full_year < 54) { 25165 full_year = "19".concat(full_year); 25166 } else { 25167 return false; // No 18XX years seen in any of the resources 25168 } 25169 } // Add missing zero if needed 25170 25171 25172 if (full_year.length === 3) { 25173 full_year = [full_year.slice(0, 2), '0', full_year.slice(2)].join(''); 25174 } // Extract month from TIN and normalize 25175 25176 25177 var month = parseInt(tin.slice(2, 4), 10); 25178 25179 if (month > 50) { 25180 month -= 50; 25181 } 25182 25183 if (month > 20) { 25184 // Month-plus-twenty was only introduced in 2004 25185 if (parseInt(full_year, 10) < 2004) { 25186 return false; 25187 } 25188 25189 month -= 20; 25190 } 25191 25192 if (month < 10) { 25193 month = "0".concat(month); 25194 } // Check date validity 25195 25196 25197 var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6)); 25198 25199 if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 25200 return false; 25201 } // Verify divisibility by 11 25202 25203 25204 if (tin.length === 10) { 25205 if (parseInt(tin, 10) % 11 !== 0) { 25206 // Some numbers up to and including 1985 are still valid if 25207 // check (last) digit equals 0 and modulo of first 9 digits equals 10 25208 var checkdigit = parseInt(tin.slice(0, 9), 10) % 11; 25209 25210 if (parseInt(full_year, 10) < 1986 && checkdigit === 10) { 25211 if (parseInt(tin.slice(9), 10) !== 0) { 25212 return false; 25213 } 25214 } else { 25215 return false; 25216 } 25217 } 25218 } 25219 25220 return true; 25221 } 25222 /* 25223 * de-AT validation function 25224 * (Abgabenkontonummer, persons/entities) 25225 * Verify TIN validity by calling luhnCheck() 25226 */ 25227 25228 25229 function deAtCheck(tin) { 25230 return algorithms$1.luhnCheck(tin); 25231 } 25232 /* 25233 * de-DE validation function 25234 * (Steueridentifikationsnummer (Steuer-IdNr.), persons only) 25235 * Tests for single duplicate/triplicate value, then calculates ISO 7064 check (last) digit 25236 * Partial implementation of spec (same result with both algorithms always) 25237 */ 25238 25239 25240 function deDeCheck(tin) { 25241 // Split digits into an array for further processing 25242 var digits = tin.split('').map(function (a) { 25243 return parseInt(a, 10); 25244 }); // Fill array with strings of number positions 25245 25246 var occurences = []; 25247 25248 for (var i = 0; i < digits.length - 1; i++) { 25249 occurences.push(''); 25250 25251 for (var j = 0; j < digits.length - 1; j++) { 25252 if (digits[i] === digits[j]) { 25253 occurences[i] += j; 25254 } 25255 } 25256 } // Remove digits with one occurence and test for only one duplicate/triplicate 25257 25258 25259 occurences = occurences.filter(function (a) { 25260 return a.length > 1; 25261 }); 25262 25263 if (occurences.length !== 2 && occurences.length !== 3) { 25264 return false; 25265 } // In case of triplicate value only two digits are allowed next to each other 25266 25267 25268 if (occurences[0].length === 3) { 25269 var trip_locations = occurences[0].split('').map(function (a) { 25270 return parseInt(a, 10); 25271 }); 25272 var recurrent = 0; // Amount of neighbour occurences 25273 25274 for (var _i = 0; _i < trip_locations.length - 1; _i++) { 25275 if (trip_locations[_i] + 1 === trip_locations[_i + 1]) { 25276 recurrent += 1; 25277 } 25278 } 25279 25280 if (recurrent === 2) { 25281 return false; 25282 } 25283 } 25284 25285 return algorithms$1.iso7064Check(tin); 25286 } 25287 /* 25288 * dk-DK validation function 25289 * (CPR-nummer (personnummer), persons only) 25290 * Checks if birth date (first six digits) is valid and assigned to century (seventh) digit, 25291 * and calculates check (last) digit 25292 */ 25293 25294 25295 function dkDkCheck(tin) { 25296 tin = tin.replace(/\W/, ''); // Extract year, check if valid for given century digit and add century 25297 25298 var year = parseInt(tin.slice(4, 6), 10); 25299 var century_digit = tin.slice(6, 7); 25300 25301 switch (century_digit) { 25302 case '0': 25303 case '1': 25304 case '2': 25305 case '3': 25306 year = "19".concat(year); 25307 break; 25308 25309 case '4': 25310 case '9': 25311 if (year < 37) { 25312 year = "20".concat(year); 25313 } else { 25314 year = "19".concat(year); 25315 } 25316 25317 break; 25318 25319 default: 25320 if (year < 37) { 25321 year = "20".concat(year); 25322 } else if (year > 58) { 25323 year = "18".concat(year); 25324 } else { 25325 return false; 25326 } 25327 25328 break; 25329 } // Add missing zero if needed 25330 25331 25332 if (year.length === 3) { 25333 year = [year.slice(0, 2), '0', year.slice(2)].join(''); 25334 } // Check date validity 25335 25336 25337 var date = "".concat(year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2)); 25338 25339 if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 25340 return false; 25341 } // Split digits into an array for further processing 25342 25343 25344 var digits = tin.split('').map(function (a) { 25345 return parseInt(a, 10); 25346 }); 25347 var checksum = 0; 25348 var weight = 4; // Multiply by weight and add to checksum 25349 25350 for (var i = 0; i < 9; i++) { 25351 checksum += digits[i] * weight; 25352 weight -= 1; 25353 25354 if (weight === 1) { 25355 weight = 7; 25356 } 25357 } 25358 25359 checksum %= 11; 25360 25361 if (checksum === 1) { 25362 return false; 25363 } 25364 25365 return checksum === 0 ? digits[9] === 0 : digits[9] === 11 - checksum; 25366 } 25367 /* 25368 * el-CY validation function 25369 * (Arithmos Forologikou Mitroou (AFM/ÎΦÎ), persons only) 25370 * Verify TIN validity by calculating ASCII value of check (last) character 25371 */ 25372 25373 25374 function elCyCheck(tin) { 25375 // split digits into an array for further processing 25376 var digits = tin.slice(0, 8).split('').map(function (a) { 25377 return parseInt(a, 10); 25378 }); 25379 var checksum = 0; // add digits in even places 25380 25381 for (var i = 1; i < digits.length; i += 2) { 25382 checksum += digits[i]; 25383 } // add digits in odd places 25384 25385 25386 for (var _i2 = 0; _i2 < digits.length; _i2 += 2) { 25387 if (digits[_i2] < 2) { 25388 checksum += 1 - digits[_i2]; 25389 } else { 25390 checksum += 2 * (digits[_i2] - 2) + 5; 25391 25392 if (digits[_i2] > 4) { 25393 checksum += 2; 25394 } 25395 } 25396 } 25397 25398 return String.fromCharCode(checksum % 26 + 65) === tin.charAt(8); 25399 } 25400 /* 25401 * el-GR validation function 25402 * (Arithmos Forologikou Mitroou (AFM/ÎΦÎ), persons/entities) 25403 * Verify TIN validity by calculating check (last) digit 25404 * Algorithm not in DG TAXUD document- sourced from: 25405 * - `http://epixeirisi.gr/%CE%9A%CE%A1%CE%99%CE%A3%CE%99%CE%9C%CE%91-%CE%98%CE%95%CE%9C%CE%91%CE%A4%CE%91-%CE%A6%CE%9F%CE%A1%CE%9F%CE%9B%CE%9F%CE%93%CE%99%CE%91%CE%A3-%CE%9A%CE%91%CE%99-%CE%9B%CE%9F%CE%93%CE%99%CE%A3%CE%A4%CE%99%CE%9A%CE%97%CE%A3/23791/%CE%91%CF%81%CE%B9%CE%B8%CE%BC%CF%8C%CF%82-%CE%A6%CE%BF%CF%81%CE%BF%CE%BB%CE%BF%CE%B3%CE%B9%CE%BA%CE%BF%CF%8D-%CE%9C%CE%B7%CF%84%CF%81%CF%8E%CE%BF%CF%85` 25406 */ 25407 25408 25409 function elGrCheck(tin) { 25410 // split digits into an array for further processing 25411 var digits = tin.split('').map(function (a) { 25412 return parseInt(a, 10); 25413 }); 25414 var checksum = 0; 25415 25416 for (var i = 0; i < 8; i++) { 25417 checksum += digits[i] * Math.pow(2, 8 - i); 25418 } 25419 25420 return checksum % 11 === digits[8]; 25421 } 25422 /* 25423 * en-GB validation function (should go here if needed) 25424 * (National Insurance Number (NINO) or Unique Taxpayer Reference (UTR), 25425 * persons/entities respectively) 25426 */ 25427 25428 /* 25429 * en-IE validation function 25430 * (Personal Public Service Number (PPS No), persons only) 25431 * Verify TIN validity by calculating check (second to last) character 25432 */ 25433 25434 25435 function enIeCheck(tin) { 25436 var checksum = algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) { 25437 return parseInt(a, 10); 25438 }), 8); 25439 25440 if (tin.length === 9 && tin[8] !== 'W') { 25441 checksum += (tin[8].charCodeAt(0) - 64) * 9; 25442 } 25443 25444 checksum %= 23; 25445 25446 if (checksum === 0) { 25447 return tin[7].toUpperCase() === 'W'; 25448 } 25449 25450 return tin[7].toUpperCase() === String.fromCharCode(64 + checksum); 25451 } // Valid US IRS campus prefixes 25452 25453 25454 var enUsCampusPrefix = { 25455 andover: ['10', '12'], 25456 atlanta: ['60', '67'], 25457 austin: ['50', '53'], 25458 brookhaven: ['01', '02', '03', '04', '05', '06', '11', '13', '14', '16', '21', '22', '23', '25', '34', '51', '52', '54', '55', '56', '57', '58', '59', '65'], 25459 cincinnati: ['30', '32', '35', '36', '37', '38', '61'], 25460 fresno: ['15', '24'], 25461 internet: ['20', '26', '27', '45', '46', '47'], 25462 kansas: ['40', '44'], 25463 memphis: ['94', '95'], 25464 ogden: ['80', '90'], 25465 philadelphia: ['33', '39', '41', '42', '43', '46', '48', '62', '63', '64', '66', '68', '71', '72', '73', '74', '75', '76', '77', '81', '82', '83', '84', '85', '86', '87', '88', '91', '92', '93', '98', '99'], 25466 sba: ['31'] 25467 }; // Return an array of all US IRS campus prefixes 25468 25469 function enUsGetPrefixes() { 25470 var prefixes = []; 25471 25472 for (var location in enUsCampusPrefix) { 25473 // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes 25474 // istanbul ignore else 25475 if (enUsCampusPrefix.hasOwnProperty(location)) { 25476 prefixes.push.apply(prefixes, _toConsumableArray(enUsCampusPrefix[location])); 25477 } 25478 } 25479 25480 return prefixes; 25481 } 25482 /* 25483 * en-US validation function 25484 * Verify that the TIN starts with a valid IRS campus prefix 25485 */ 25486 25487 25488 function enUsCheck(tin) { 25489 return enUsGetPrefixes().indexOf(tin.substr(0, 2)) !== -1; 25490 } 25491 /* 25492 * es-ES validation function 25493 * (Documento Nacional de Identidad (DNI) 25494 * or Número de Identificación de Extranjero (NIE), persons only) 25495 * Verify TIN validity by calculating check (last) character 25496 */ 25497 25498 25499 function esEsCheck(tin) { 25500 // Split characters into an array for further processing 25501 var chars = tin.toUpperCase().split(''); // Replace initial letter if needed 25502 25503 if (isNaN(parseInt(chars[0], 10)) && chars.length > 1) { 25504 var lead_replace = 0; 25505 25506 switch (chars[0]) { 25507 case 'Y': 25508 lead_replace = 1; 25509 break; 25510 25511 case 'Z': 25512 lead_replace = 2; 25513 break; 25514 25515 default: 25516 } 25517 25518 chars.splice(0, 1, lead_replace); // Fill with zeros if smaller than proper 25519 } else { 25520 while (chars.length < 9) { 25521 chars.unshift(0); 25522 } 25523 } // Calculate checksum and check according to lookup 25524 25525 25526 var lookup = ['T', 'R', 'W', 'A', 'G', 'M', 'Y', 'F', 'P', 'D', 'X', 'B', 'N', 'J', 'Z', 'S', 'Q', 'V', 'H', 'L', 'C', 'K', 'E']; 25527 chars = chars.join(''); 25528 var checksum = parseInt(chars.slice(0, 8), 10) % 23; 25529 return chars[8] === lookup[checksum]; 25530 } 25531 /* 25532 * et-EE validation function 25533 * (Isikukood (IK), persons only) 25534 * Checks if birth date (century digit and six following) is valid and calculates check (last) digit 25535 * Material not in DG TAXUD document sourced from: 25536 * - `https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/Estonia-TIN.pdf` 25537 */ 25538 25539 25540 function etEeCheck(tin) { 25541 // Extract year and add century 25542 var full_year = tin.slice(1, 3); 25543 var century_digit = tin.slice(0, 1); 25544 25545 switch (century_digit) { 25546 case '1': 25547 case '2': 25548 full_year = "18".concat(full_year); 25549 break; 25550 25551 case '3': 25552 case '4': 25553 full_year = "19".concat(full_year); 25554 break; 25555 25556 default: 25557 full_year = "20".concat(full_year); 25558 break; 25559 } // Check date validity 25560 25561 25562 var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7)); 25563 25564 if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 25565 return false; 25566 } // Split digits into an array for further processing 25567 25568 25569 var digits = tin.split('').map(function (a) { 25570 return parseInt(a, 10); 25571 }); 25572 var checksum = 0; 25573 var weight = 1; // Multiply by weight and add to checksum 25574 25575 for (var i = 0; i < 10; i++) { 25576 checksum += digits[i] * weight; 25577 weight += 1; 25578 25579 if (weight === 10) { 25580 weight = 1; 25581 } 25582 } // Do again if modulo 11 of checksum is 10 25583 25584 25585 if (checksum % 11 === 10) { 25586 checksum = 0; 25587 weight = 3; 25588 25589 for (var _i3 = 0; _i3 < 10; _i3++) { 25590 checksum += digits[_i3] * weight; 25591 weight += 1; 25592 25593 if (weight === 10) { 25594 weight = 1; 25595 } 25596 } 25597 25598 if (checksum % 11 === 10) { 25599 return digits[10] === 0; 25600 } 25601 } 25602 25603 return checksum % 11 === digits[10]; 25604 } 25605 /* 25606 * fi-FI validation function 25607 * (Henkilötunnus (HETU), persons only) 25608 * Checks if birth date (first six digits plus century symbol) is valid 25609 * and calculates check (last) digit 25610 */ 25611 25612 25613 function fiFiCheck(tin) { 25614 // Extract year and add century 25615 var full_year = tin.slice(4, 6); 25616 var century_symbol = tin.slice(6, 7); 25617 25618 switch (century_symbol) { 25619 case '+': 25620 full_year = "18".concat(full_year); 25621 break; 25622 25623 case '-': 25624 full_year = "19".concat(full_year); 25625 break; 25626 25627 default: 25628 full_year = "20".concat(full_year); 25629 break; 25630 } // Check date validity 25631 25632 25633 var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(tin.slice(0, 2)); 25634 25635 if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 25636 return false; 25637 } // Calculate check character 25638 25639 25640 var checksum = parseInt(tin.slice(0, 6) + tin.slice(7, 10), 10) % 31; 25641 25642 if (checksum < 10) { 25643 return checksum === parseInt(tin.slice(10), 10); 25644 } 25645 25646 checksum -= 10; 25647 var letters_lookup = ['A', 'B', 'C', 'D', 'E', 'F', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y']; 25648 return letters_lookup[checksum] === tin.slice(10); 25649 } 25650 /* 25651 * fr/nl-BE validation function 25652 * (Numéro national (N.N.), persons only) 25653 * Checks if birth date (first six digits) is valid and calculates check (last two) digits 25654 */ 25655 25656 25657 function frBeCheck(tin) { 25658 // Zero month/day value is acceptable 25659 if (tin.slice(2, 4) !== '00' || tin.slice(4, 6) !== '00') { 25660 // Extract date from first six digits of TIN 25661 var date = "".concat(tin.slice(0, 2), "/").concat(tin.slice(2, 4), "/").concat(tin.slice(4, 6)); 25662 25663 if (!(0, _isDate.default)(date, 'YY/MM/DD')) { 25664 return false; 25665 } 25666 } 25667 25668 var checksum = 97 - parseInt(tin.slice(0, 9), 10) % 97; 25669 var checkdigits = parseInt(tin.slice(9, 11), 10); 25670 25671 if (checksum !== checkdigits) { 25672 checksum = 97 - parseInt("2".concat(tin.slice(0, 9)), 10) % 97; 25673 25674 if (checksum !== checkdigits) { 25675 return false; 25676 } 25677 } 25678 25679 return true; 25680 } 25681 /* 25682 * fr-FR validation function 25683 * (Numéro fiscal de référence (numéro SPI), persons only) 25684 * Verify TIN validity by calculating check (last three) digits 25685 */ 25686 25687 25688 function frFrCheck(tin) { 25689 tin = tin.replace(/\s/g, ''); 25690 var checksum = parseInt(tin.slice(0, 10), 10) % 511; 25691 var checkdigits = parseInt(tin.slice(10, 13), 10); 25692 return checksum === checkdigits; 25693 } 25694 /* 25695 * fr/lb-LU validation function 25696 * (numéro dâidentification personnelle, persons only) 25697 * Verify birth date validity and run Luhn and Verhoeff checks 25698 */ 25699 25700 25701 function frLuCheck(tin) { 25702 // Extract date and check validity 25703 var date = "".concat(tin.slice(0, 4), "/").concat(tin.slice(4, 6), "/").concat(tin.slice(6, 8)); 25704 25705 if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 25706 return false; 25707 } // Run Luhn check 25708 25709 25710 if (!algorithms$1.luhnCheck(tin.slice(0, 12))) { 25711 return false; 25712 } // Remove Luhn check digit and run Verhoeff check 25713 25714 25715 return algorithms$1.verhoeffCheck("".concat(tin.slice(0, 11)).concat(tin[12])); 25716 } 25717 /* 25718 * hr-HR validation function 25719 * (Osobni identifikacijski broj (OIB), persons/entities) 25720 * Verify TIN validity by calling iso7064Check(digits) 25721 */ 25722 25723 25724 function hrHrCheck(tin) { 25725 return algorithms$1.iso7064Check(tin); 25726 } 25727 /* 25728 * hu-HU validation function 25729 * (AdóazonosÃtó jel, persons only) 25730 * Verify TIN validity by calculating check (last) digit 25731 */ 25732 25733 25734 function huHuCheck(tin) { 25735 // split digits into an array for further processing 25736 var digits = tin.split('').map(function (a) { 25737 return parseInt(a, 10); 25738 }); 25739 var checksum = 8; 25740 25741 for (var i = 1; i < 9; i++) { 25742 checksum += digits[i] * (i + 1); 25743 } 25744 25745 return checksum % 11 === digits[9]; 25746 } 25747 /* 25748 * lt-LT validation function (should go here if needed) 25749 * (Asmens kodas, persons/entities respectively) 25750 * Current validation check is alias of etEeCheck- same format applies 25751 */ 25752 25753 /* 25754 * it-IT first/last name validity check 25755 * Accepts it-IT TIN-encoded names as a three-element character array and checks their validity 25756 * Due to lack of clarity between resources ("Are only Italian consonants used? 25757 * What happens if a person has X in their name?" etc.) only two test conditions 25758 * have been implemented: 25759 * Vowels may only be followed by other vowels or an X character 25760 * and X characters after vowels may only be followed by other X characters. 25761 */ 25762 25763 25764 function itItNameCheck(name) { 25765 // true at the first occurence of a vowel 25766 var vowelflag = false; // true at the first occurence of an X AFTER vowel 25767 // (to properly handle last names with X as consonant) 25768 25769 var xflag = false; 25770 25771 for (var i = 0; i < 3; i++) { 25772 if (!vowelflag && /[AEIOU]/.test(name[i])) { 25773 vowelflag = true; 25774 } else if (!xflag && vowelflag && name[i] === 'X') { 25775 xflag = true; 25776 } else if (i > 0) { 25777 if (vowelflag && !xflag) { 25778 if (!/[AEIOU]/.test(name[i])) { 25779 return false; 25780 } 25781 } 25782 25783 if (xflag) { 25784 if (!/X/.test(name[i])) { 25785 return false; 25786 } 25787 } 25788 } 25789 } 25790 25791 return true; 25792 } 25793 /* 25794 * it-IT validation function 25795 * (Codice fiscale (TIN-IT), persons only) 25796 * Verify name, birth date and codice catastale validity 25797 * and calculate check character. 25798 * Material not in DG-TAXUD document sourced from: 25799 * `https://en.wikipedia.org/wiki/Italian_fiscal_code` 25800 */ 25801 25802 25803 function itItCheck(tin) { 25804 // Capitalize and split characters into an array for further processing 25805 var chars = tin.toUpperCase().split(''); // Check first and last name validity calling itItNameCheck() 25806 25807 if (!itItNameCheck(chars.slice(0, 3))) { 25808 return false; 25809 } 25810 25811 if (!itItNameCheck(chars.slice(3, 6))) { 25812 return false; 25813 } // Convert letters in number spaces back to numbers if any 25814 25815 25816 var number_locations = [6, 7, 9, 10, 12, 13, 14]; 25817 var number_replace = { 25818 L: '0', 25819 M: '1', 25820 N: '2', 25821 P: '3', 25822 Q: '4', 25823 R: '5', 25824 S: '6', 25825 T: '7', 25826 U: '8', 25827 V: '9' 25828 }; 25829 25830 for (var _i4 = 0, _number_locations = number_locations; _i4 < _number_locations.length; _i4++) { 25831 var i = _number_locations[_i4]; 25832 25833 if (chars[i] in number_replace) { 25834 chars.splice(i, 1, number_replace[chars[i]]); 25835 } 25836 } // Extract month and day, and check date validity 25837 25838 25839 var month_replace = { 25840 A: '01', 25841 B: '02', 25842 C: '03', 25843 D: '04', 25844 E: '05', 25845 H: '06', 25846 L: '07', 25847 M: '08', 25848 P: '09', 25849 R: '10', 25850 S: '11', 25851 T: '12' 25852 }; 25853 var month = month_replace[chars[8]]; 25854 var day = parseInt(chars[9] + chars[10], 10); 25855 25856 if (day > 40) { 25857 day -= 40; 25858 } 25859 25860 if (day < 10) { 25861 day = "0".concat(day); 25862 } 25863 25864 var date = "".concat(chars[6]).concat(chars[7], "/").concat(month, "/").concat(day); 25865 25866 if (!(0, _isDate.default)(date, 'YY/MM/DD')) { 25867 return false; 25868 } // Calculate check character by adding up even and odd characters as numbers 25869 25870 25871 var checksum = 0; 25872 25873 for (var _i5 = 1; _i5 < chars.length - 1; _i5 += 2) { 25874 var char_to_int = parseInt(chars[_i5], 10); 25875 25876 if (isNaN(char_to_int)) { 25877 char_to_int = chars[_i5].charCodeAt(0) - 65; 25878 } 25879 25880 checksum += char_to_int; 25881 } 25882 25883 var odd_convert = { 25884 // Maps of characters at odd places 25885 A: 1, 25886 B: 0, 25887 C: 5, 25888 D: 7, 25889 E: 9, 25890 F: 13, 25891 G: 15, 25892 H: 17, 25893 I: 19, 25894 J: 21, 25895 K: 2, 25896 L: 4, 25897 M: 18, 25898 N: 20, 25899 O: 11, 25900 P: 3, 25901 Q: 6, 25902 R: 8, 25903 S: 12, 25904 T: 14, 25905 U: 16, 25906 V: 10, 25907 W: 22, 25908 X: 25, 25909 Y: 24, 25910 Z: 23, 25911 0: 1, 25912 1: 0 25913 }; 25914 25915 for (var _i6 = 0; _i6 < chars.length - 1; _i6 += 2) { 25916 var _char_to_int = 0; 25917 25918 if (chars[_i6] in odd_convert) { 25919 _char_to_int = odd_convert[chars[_i6]]; 25920 } else { 25921 var multiplier = parseInt(chars[_i6], 10); 25922 _char_to_int = 2 * multiplier + 1; 25923 25924 if (multiplier > 4) { 25925 _char_to_int += 2; 25926 } 25927 } 25928 25929 checksum += _char_to_int; 25930 } 25931 25932 if (String.fromCharCode(65 + checksum % 26) !== chars[15]) { 25933 return false; 25934 } 25935 25936 return true; 25937 } 25938 /* 25939 * lv-LV validation function 25940 * (Personas kods (PK), persons only) 25941 * Check validity of birth date and calculate check (last) digit 25942 * Support only for old format numbers (not starting with '32', issued before 2017/07/01) 25943 * Material not in DG TAXUD document sourced from: 25944 * `https://boot.ritakafija.lv/forums/index.php?/topic/88314-personas-koda-algoritms-%C4%8Deksumma/` 25945 */ 25946 25947 25948 function lvLvCheck(tin) { 25949 tin = tin.replace(/\W/, ''); // Extract date from TIN 25950 25951 var day = tin.slice(0, 2); 25952 25953 if (day !== '32') { 25954 // No date/checksum check if new format 25955 var month = tin.slice(2, 4); 25956 25957 if (month !== '00') { 25958 // No date check if unknown month 25959 var full_year = tin.slice(4, 6); 25960 25961 switch (tin[6]) { 25962 case '0': 25963 full_year = "18".concat(full_year); 25964 break; 25965 25966 case '1': 25967 full_year = "19".concat(full_year); 25968 break; 25969 25970 default: 25971 full_year = "20".concat(full_year); 25972 break; 25973 } // Check date validity 25974 25975 25976 var date = "".concat(full_year, "/").concat(tin.slice(2, 4), "/").concat(day); 25977 25978 if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 25979 return false; 25980 } 25981 } // Calculate check digit 25982 25983 25984 var checksum = 1101; 25985 var multip_lookup = [1, 6, 3, 7, 9, 10, 5, 8, 4, 2]; 25986 25987 for (var i = 0; i < tin.length - 1; i++) { 25988 checksum -= parseInt(tin[i], 10) * multip_lookup[i]; 25989 } 25990 25991 return parseInt(tin[10], 10) === checksum % 11; 25992 } 25993 25994 return true; 25995 } 25996 /* 25997 * mt-MT validation function 25998 * (Identity Card Number or Unique Taxpayer Reference, persons/entities) 25999 * Verify Identity Card Number structure (no other tests found) 26000 */ 26001 26002 26003 function mtMtCheck(tin) { 26004 if (tin.length !== 9) { 26005 // No tests for UTR 26006 var chars = tin.toUpperCase().split(''); // Fill with zeros if smaller than proper 26007 26008 while (chars.length < 8) { 26009 chars.unshift(0); 26010 } // Validate format according to last character 26011 26012 26013 switch (tin[7]) { 26014 case 'A': 26015 case 'P': 26016 if (parseInt(chars[6], 10) === 0) { 26017 return false; 26018 } 26019 26020 break; 26021 26022 default: 26023 { 26024 var first_part = parseInt(chars.join('').slice(0, 5), 10); 26025 26026 if (first_part > 32000) { 26027 return false; 26028 } 26029 26030 var second_part = parseInt(chars.join('').slice(5, 7), 10); 26031 26032 if (first_part === second_part) { 26033 return false; 26034 } 26035 } 26036 } 26037 } 26038 26039 return true; 26040 } 26041 /* 26042 * nl-NL validation function 26043 * (Burgerservicenummer (BSN) or Rechtspersonen Samenwerkingsverbanden Informatie Nummer (RSIN), 26044 * persons/entities respectively) 26045 * Verify TIN validity by calculating check (last) digit (variant of MOD 11) 26046 */ 26047 26048 26049 function nlNlCheck(tin) { 26050 return algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) { 26051 return parseInt(a, 10); 26052 }), 9) % 11 === parseInt(tin[8], 10); 26053 } 26054 /* 26055 * pl-PL validation function 26056 * (Powszechny Elektroniczny System Ewidencji LudnoÅci (PESEL) 26057 * or Numer identyfikacji podatkowej (NIP), persons/entities) 26058 * Verify TIN validity by validating birth date (PESEL) and calculating check (last) digit 26059 */ 26060 26061 26062 function plPlCheck(tin) { 26063 // NIP 26064 if (tin.length === 10) { 26065 // Calculate last digit by multiplying with lookup 26066 var lookup = [6, 5, 7, 2, 3, 4, 5, 6, 7]; 26067 var _checksum = 0; 26068 26069 for (var i = 0; i < lookup.length; i++) { 26070 _checksum += parseInt(tin[i], 10) * lookup[i]; 26071 } 26072 26073 _checksum %= 11; 26074 26075 if (_checksum === 10) { 26076 return false; 26077 } 26078 26079 return _checksum === parseInt(tin[9], 10); 26080 } // PESEL 26081 // Extract full year using month 26082 26083 26084 var full_year = tin.slice(0, 2); 26085 var month = parseInt(tin.slice(2, 4), 10); 26086 26087 if (month > 80) { 26088 full_year = "18".concat(full_year); 26089 month -= 80; 26090 } else if (month > 60) { 26091 full_year = "22".concat(full_year); 26092 month -= 60; 26093 } else if (month > 40) { 26094 full_year = "21".concat(full_year); 26095 month -= 40; 26096 } else if (month > 20) { 26097 full_year = "20".concat(full_year); 26098 month -= 20; 26099 } else { 26100 full_year = "19".concat(full_year); 26101 } // Add leading zero to month if needed 26102 26103 26104 if (month < 10) { 26105 month = "0".concat(month); 26106 } // Check date validity 26107 26108 26109 var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6)); 26110 26111 if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 26112 return false; 26113 } // Calculate last digit by mulitplying with odd one-digit numbers except 5 26114 26115 26116 var checksum = 0; 26117 var multiplier = 1; 26118 26119 for (var _i7 = 0; _i7 < tin.length - 1; _i7++) { 26120 checksum += parseInt(tin[_i7], 10) * multiplier % 10; 26121 multiplier += 2; 26122 26123 if (multiplier > 10) { 26124 multiplier = 1; 26125 } else if (multiplier === 5) { 26126 multiplier += 2; 26127 } 26128 } 26129 26130 checksum = 10 - checksum % 10; 26131 return checksum === parseInt(tin[10], 10); 26132 } 26133 /* 26134 * pt-PT validation function 26135 * (Número de identificação fiscal (NIF), persons/entities) 26136 * Verify TIN validity by calculating check (last) digit (variant of MOD 11) 26137 */ 26138 26139 26140 function ptPtCheck(tin) { 26141 var checksum = 11 - algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 8).map(function (a) { 26142 return parseInt(a, 10); 26143 }), 9) % 11; 26144 26145 if (checksum > 9) { 26146 return parseInt(tin[8], 10) === 0; 26147 } 26148 26149 return checksum === parseInt(tin[8], 10); 26150 } 26151 /* 26152 * ro-RO validation function 26153 * (Cod Numeric Personal (CNP) or Cod de înregistrare fiscalÄ (CIF), 26154 * persons only) 26155 * Verify CNP validity by calculating check (last) digit (test not found for CIF) 26156 * Material not in DG TAXUD document sourced from: 26157 * `https://en.wikipedia.org/wiki/National_identification_number#Romania` 26158 */ 26159 26160 26161 function roRoCheck(tin) { 26162 if (tin.slice(0, 4) !== '9000') { 26163 // No test found for this format 26164 // Extract full year using century digit if possible 26165 var full_year = tin.slice(1, 3); 26166 26167 switch (tin[0]) { 26168 case '1': 26169 case '2': 26170 full_year = "19".concat(full_year); 26171 break; 26172 26173 case '3': 26174 case '4': 26175 full_year = "18".concat(full_year); 26176 break; 26177 26178 case '5': 26179 case '6': 26180 full_year = "20".concat(full_year); 26181 break; 26182 26183 default: 26184 } // Check date validity 26185 26186 26187 var date = "".concat(full_year, "/").concat(tin.slice(3, 5), "/").concat(tin.slice(5, 7)); 26188 26189 if (date.length === 8) { 26190 if (!(0, _isDate.default)(date, 'YY/MM/DD')) { 26191 return false; 26192 } 26193 } else if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 26194 return false; 26195 } // Calculate check digit 26196 26197 26198 var digits = tin.split('').map(function (a) { 26199 return parseInt(a, 10); 26200 }); 26201 var multipliers = [2, 7, 9, 1, 4, 6, 3, 5, 8, 2, 7, 9]; 26202 var checksum = 0; 26203 26204 for (var i = 0; i < multipliers.length; i++) { 26205 checksum += digits[i] * multipliers[i]; 26206 } 26207 26208 if (checksum % 11 === 10) { 26209 return digits[12] === 1; 26210 } 26211 26212 return digits[12] === checksum % 11; 26213 } 26214 26215 return true; 26216 } 26217 /* 26218 * sk-SK validation function 26219 * (Rodné ÄÃslo (RÄ) or bezvýznamové identifikaÄné ÄÃslo (BIÄ), persons only) 26220 * Checks validity of pre-1954 birth numbers (rodné ÄÃslo) only 26221 * Due to the introduction of the pseudo-random BIÄ it is not possible to test 26222 * post-1954 birth numbers without knowing whether they are BIÄ or RÄ beforehand 26223 */ 26224 26225 26226 function skSkCheck(tin) { 26227 if (tin.length === 9) { 26228 tin = tin.replace(/\W/, ''); 26229 26230 if (tin.slice(6) === '000') { 26231 return false; 26232 } // Three-zero serial not assigned before 1954 26233 // Extract full year from TIN length 26234 26235 26236 var full_year = parseInt(tin.slice(0, 2), 10); 26237 26238 if (full_year > 53) { 26239 return false; 26240 } 26241 26242 if (full_year < 10) { 26243 full_year = "190".concat(full_year); 26244 } else { 26245 full_year = "19".concat(full_year); 26246 } // Extract month from TIN and normalize 26247 26248 26249 var month = parseInt(tin.slice(2, 4), 10); 26250 26251 if (month > 50) { 26252 month -= 50; 26253 } 26254 26255 if (month < 10) { 26256 month = "0".concat(month); 26257 } // Check date validity 26258 26259 26260 var date = "".concat(full_year, "/").concat(month, "/").concat(tin.slice(4, 6)); 26261 26262 if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 26263 return false; 26264 } 26265 } 26266 26267 return true; 26268 } 26269 /* 26270 * sl-SI validation function 26271 * (DavÄna Å¡tevilka, persons/entities) 26272 * Verify TIN validity by calculating check (last) digit (variant of MOD 11) 26273 */ 26274 26275 26276 function slSiCheck(tin) { 26277 var checksum = 11 - algorithms$1.reverseMultiplyAndSum(tin.split('').slice(0, 7).map(function (a) { 26278 return parseInt(a, 10); 26279 }), 8) % 11; 26280 26281 if (checksum === 10) { 26282 return parseInt(tin[7], 10) === 0; 26283 } 26284 26285 return checksum === parseInt(tin[7], 10); 26286 } 26287 /* 26288 * sv-SE validation function 26289 * (Personnummer or samordningsnummer, persons only) 26290 * Checks validity of birth date and calls luhnCheck() to validate check (last) digit 26291 */ 26292 26293 26294 function svSeCheck(tin) { 26295 // Make copy of TIN and normalize to two-digit year form 26296 var tin_copy = tin.slice(0); 26297 26298 if (tin.length > 11) { 26299 tin_copy = tin_copy.slice(2); 26300 } // Extract date of birth 26301 26302 26303 var full_year = ''; 26304 var month = tin_copy.slice(2, 4); 26305 var day = parseInt(tin_copy.slice(4, 6), 10); 26306 26307 if (tin.length > 11) { 26308 full_year = tin.slice(0, 4); 26309 } else { 26310 full_year = tin.slice(0, 2); 26311 26312 if (tin.length === 11 && day < 60) { 26313 // Extract full year from centenarian symbol 26314 // Should work just fine until year 10000 or so 26315 var current_year = new Date().getFullYear().toString(); 26316 var current_century = parseInt(current_year.slice(0, 2), 10); 26317 current_year = parseInt(current_year, 10); 26318 26319 if (tin[6] === '-') { 26320 if (parseInt("".concat(current_century).concat(full_year), 10) > current_year) { 26321 full_year = "".concat(current_century - 1).concat(full_year); 26322 } else { 26323 full_year = "".concat(current_century).concat(full_year); 26324 } 26325 } else { 26326 full_year = "".concat(current_century - 1).concat(full_year); 26327 26328 if (current_year - parseInt(full_year, 10) < 100) { 26329 return false; 26330 } 26331 } 26332 } 26333 } // Normalize day and check date validity 26334 26335 26336 if (day > 60) { 26337 day -= 60; 26338 } 26339 26340 if (day < 10) { 26341 day = "0".concat(day); 26342 } 26343 26344 var date = "".concat(full_year, "/").concat(month, "/").concat(day); 26345 26346 if (date.length === 8) { 26347 if (!(0, _isDate.default)(date, 'YY/MM/DD')) { 26348 return false; 26349 } 26350 } else if (!(0, _isDate.default)(date, 'YYYY/MM/DD')) { 26351 return false; 26352 } 26353 26354 return algorithms$1.luhnCheck(tin.replace(/\W/, '')); 26355 } // Locale lookup objects 26356 26357 /* 26358 * Tax id regex formats for various locales 26359 * 26360 * Where not explicitly specified in DG-TAXUD document both 26361 * uppercase and lowercase letters are acceptable. 26362 */ 26363 26364 26365 var taxIdFormat = { 26366 'bg-BG': /^\d{10}$/, 26367 'cs-CZ': /^\d{6}\/{0,1}\d{3,4}$/, 26368 'de-AT': /^\d{9}$/, 26369 'de-DE': /^[1-9]\d{10}$/, 26370 'dk-DK': /^\d{6}-{0,1}\d{4}$/, 26371 'el-CY': /^[09]\d{7}[A-Z]$/, 26372 'el-GR': /^([0-4]|[7-9])\d{8}$/, 26373 'en-GB': /^\d{10}$|^(?!GB|NK|TN|ZZ)(?![DFIQUV])[A-Z](?![DFIQUVO])[A-Z]\d{6}[ABCD ]$/i, 26374 'en-IE': /^\d{7}[A-W][A-IW]{0,1}$/i, 26375 'en-US': /^\d{2}[- ]{0,1}\d{7}$/, 26376 'es-ES': /^(\d{0,8}|[XYZKLM]\d{7})[A-HJ-NP-TV-Z]$/i, 26377 'et-EE': /^[1-6]\d{6}(00[1-9]|0[1-9][0-9]|[1-6][0-9]{2}|70[0-9]|710)\d$/, 26378 'fi-FI': /^\d{6}[-+A]\d{3}[0-9A-FHJ-NPR-Y]$/i, 26379 'fr-BE': /^\d{11}$/, 26380 'fr-FR': /^[0-3]\d{12}$|^[0-3]\d\s\d{2}(\s\d{3}){3}$/, 26381 // Conforms both to official spec and provided example 26382 'fr-LU': /^\d{13}$/, 26383 'hr-HR': /^\d{11}$/, 26384 'hu-HU': /^8\d{9}$/, 26385 'it-IT': /^[A-Z]{6}[L-NP-V0-9]{2}[A-EHLMPRST][L-NP-V0-9]{2}[A-ILMZ][L-NP-V0-9]{3}[A-Z]$/i, 26386 'lv-LV': /^\d{6}-{0,1}\d{5}$/, 26387 // Conforms both to DG TAXUD spec and original research 26388 'mt-MT': /^\d{3,7}[APMGLHBZ]$|^([1-8])\1\d{7}$/i, 26389 'nl-NL': /^\d{9}$/, 26390 'pl-PL': /^\d{10,11}$/, 26391 'pt-PT': /^\d{9}$/, 26392 'ro-RO': /^\d{13}$/,
26393 'sk-SK': /^\d{6}\/{0,1}\d{3,4}$/, 26394 'sl-SI': /^[1-9]\d{7}$/, 26395 'sv-SE': /^(\d{6}[-+]{0,1}\d{4}|(18|19|20)\d{6}[-+]{0,1}\d{4})$/ 26396 }; // taxIdFormat locale aliases 26397 26398 taxIdFormat['lb-LU'] = taxIdFormat['fr-LU']; 26399 taxIdFormat['lt-LT'] = taxIdFormat['et-EE']; 26400 taxIdFormat['nl-BE'] = taxIdFormat['fr-BE']; // Algorithmic tax id check functions for various locales 26401 26402 var taxIdCheck = { 26403 'bg-BG': bgBgCheck, 26404 'cs-CZ': csCzCheck, 26405 'de-AT': deAtCheck, 26406 'de-DE': deDeCheck, 26407 'dk-DK': dkDkCheck, 26408 'el-CY': elCyCheck, 26409 'el-GR': elGrCheck, 26410 'en-IE': enIeCheck, 26411 'en-US': enUsCheck, 26412 'es-ES': esEsCheck, 26413 'et-EE': etEeCheck, 26414 'fi-FI': fiFiCheck, 26415 'fr-BE': frBeCheck, 26416 'fr-FR': frFrCheck, 26417 'fr-LU': frLuCheck, 26418 'hr-HR': hrHrCheck, 26419 'hu-HU': huHuCheck, 26420 'it-IT': itItCheck, 26421 'lv-LV': lvLvCheck, 26422 'mt-MT': mtMtCheck, 26423 'nl-NL': nlNlCheck, 26424 'pl-PL': plPlCheck, 26425 'pt-PT': ptPtCheck, 26426 'ro-RO': roRoCheck, 26427 'sk-SK': skSkCheck, 26428 'sl-SI': slSiCheck, 26429 'sv-SE': svSeCheck 26430 }; // taxIdCheck locale aliases 26431 26432 taxIdCheck['lb-LU'] = taxIdCheck['fr-LU']; 26433 taxIdCheck['lt-LT'] = taxIdCheck['et-EE']; 26434 taxIdCheck['nl-BE'] = taxIdCheck['fr-BE']; // Regexes for locales where characters should be omitted before checking format 26435 26436 var allsymbols = /[-\\\/!@#$%\^&\*\(\)\+\=\[\]]+/g; 26437 var sanitizeRegexes = { 26438 'de-AT': allsymbols, 26439 'de-DE': /[\/\\]/g, 26440 'fr-BE': allsymbols 26441 }; // sanitizeRegexes locale aliases 26442 26443 sanitizeRegexes['nl-BE'] = sanitizeRegexes['fr-BE']; 26444 /* 26445 * Validator function 26446 * Return true if the passed string is a valid tax identification number 26447 * for the specified locale. 26448 * Throw an error exception if the locale is not supported. 26449 */ 26450 26451 function isTaxID(str) { 26452 var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'en-US'; 26453 (0, _assertString.default)(str); // Copy TIN to avoid replacement if sanitized 26454 26455 var strcopy = str.slice(0); 26456 26457 if (locale in taxIdFormat) { 26458 if (locale in sanitizeRegexes) { 26459 strcopy = strcopy.replace(sanitizeRegexes[locale], ''); 26460 } 26461 26462 if (!taxIdFormat[locale].test(strcopy)) { 26463 return false; 26464 } 26465 26466 if (locale in taxIdCheck) { 26467 return taxIdCheck[locale](strcopy); 26468 } // Fallthrough; not all locales have algorithmic checks 26469 26470 26471 return true; 26472 } 26473 26474 throw new Error("Invalid locale '".concat(locale, "'")); 26475 } 26476 26477 module.exports = exports.default; 26478 module.exports.default = exports.default; 26479 }); 26480 26481 var isTaxID = /*@__PURE__*/getDefaultExportFromCjs(isTaxID_1); 26482 26483 var isMobilePhone_1 = createCommonjsModule(function (module, exports) { 26484 "use strict"; 26485 26486 Object.defineProperty(exports, "__esModule", { 26487 value: true 26488 }); 26489 exports.default = isMobilePhone; 26490 exports.locales = void 0; 26491 26492 var _assertString = _interopRequireDefault(assertString_1); 26493 26494 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 26495 26496 /* eslint-disable max-len */ 26497 var phones = { 26498 'am-AM': /^(\+?374|0)((10|[9|7][0-9])\d{6}$|[2-4]\d{7}$)/, 26499 'ar-AE': /^((\+?971)|0)?5[024568]\d{7}$/, 26500 'ar-BH': /^(\+?973)?(3|6)\d{7}$/, 26501 'ar-DZ': /^(\+?213|0)(5|6|7)\d{8}$/, 26502 'ar-LB': /^(\+?961)?((3|81)\d{6}|7\d{7})$/, 26503 'ar-EG': /^((\+?20)|0)?1[0125]\d{8}$/, 26504 'ar-IQ': /^(\+?964|0)?7[0-9]\d{8}$/, 26505 'ar-JO': /^(\+?962|0)?7[789]\d{7}$/, 26506 'ar-KW': /^(\+?965)[569]\d{7}$/, 26507 'ar-LY': /^((\+?218)|0)?(9[1-6]\d{7}|[1-8]\d{7,9})$/, 26508 'ar-MA': /^(?:(?:\+|00)212|0)[5-7]\d{8}$/, 26509 'ar-SA': /^(!?(\+?966)|0)?5\d{8}$/, 26510 'ar-SY': /^(!?(\+?963)|0)?9\d{8}$/, 26511 'ar-TN': /^(\+?216)?[2459]\d{7}$/, 26512 'az-AZ': /^(\+994|0)(5[015]|7[07]|99)\d{7}$/, 26513 'bs-BA': /^((((\+|00)3876)|06))((([0-3]|[5-6])\d{6})|(4\d{7}))$/, 26514 'be-BY': /^(\+?375)?(24|25|29|33|44)\d{7}$/, 26515 'bg-BG': /^(\+?359|0)?8[789]\d{7}$/, 26516 'bn-BD': /^(\+?880|0)1[13456789][0-9]{8}$/, 26517 'ca-AD': /^(\+376)?[346]\d{5}$/, 26518 'cs-CZ': /^(\+?420)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, 26519 'da-DK': /^(\+?45)?\s?\d{2}\s?\d{2}\s?\d{2}\s?\d{2}$/, 26520 'de-DE': /^(\+49)?0?[1|3]([0|5][0-45-9]\d|6([23]|0\d?)|7([0-57-9]|6\d))\d{7}$/, 26521 'de-AT': /^(\+43|0)\d{1,4}\d{3,12}$/, 26522 'de-CH': /^(\+41|0)(7[5-9])\d{1,7}$/, 26523 'de-LU': /^(\+352)?((6\d1)\d{6})$/, 26524 'el-GR': /^(\+?30|0)?(69\d{8})$/, 26525 'en-AU': /^(\+?61|0)4\d{8}$/, 26526 'en-GB': /^(\+?44|0)7\d{9}$/, 26527 'en-GG': /^(\+?44|0)1481\d{6}$/, 26528 'en-GH': /^(\+233|0)(20|50|24|54|27|57|26|56|23|28)\d{7}$/, 26529 'en-HK': /^(\+?852[-\s]?)?[456789]\d{3}[-\s]?\d{4}$/, 26530 'en-MO': /^(\+?853[-\s]?)?[6]\d{3}[-\s]?\d{4}$/, 26531 'en-IE': /^(\+?353|0)8[356789]\d{7}$/, 26532 'en-IN': /^(\+?91|0)?[6789]\d{9}$/,
26533 'en-KE': /^(\+?254|0)(7|1)\d{8}$/, 26534 'en-MT': /^(\+?356|0)?(99|79|77|21|27|22|25)[0-9]{6}$/, 26535 'en-MU': /^(\+?230|0)?\d{8}$/, 26536 'en-NG': /^(\+?234|0)?[789]\d{9}$/, 26537 'en-NZ': /^(\+?64|0)[28]\d{7,9}$/, 26538 'en-PK': /^((\+92)|(0092))-{0,1}\d{3}-{0,1}\d{7}$|^\d{11}$|^\d{4}-\d{7}$/, 26539 'en-PH': /^(09|\+639)\d{9}$/, 26540 'en-RW': /^(\+?250|0)?[7]\d{8}$/, 26541 'en-SG': /^(\+65)?[689]\d{7}$/, 26542 'en-SL': /^(?:0|94|\+94)?(7(0|1|2|5|6|7|8)( |-)?\d)\d{6}$/, 26543 'en-TZ': /^(\+?255|0)?[67]\d{8}$/, 26544 'en-UG': /^(\+?256|0)?[7]\d{8}$/, 26545 'en-US': /^((\+1|1)?( |-)?)?(\([2-9][0-9]{2}\)|[2-9][0-9]{2})( |-)?([2-9][0-9]{2}( |-)?[0-9]{4})$/, 26546 'en-ZA': /^(\+?27|0)\d{9}$/, 26547 'en-ZM': /^(\+?26)?09[567]\d{7}$/, 26548 'en-ZW': /^(\+263)[0-9]{9}$/, 26549 'es-AR': /^\+?549(11|[2368]\d)\d{8}$/, 26550 'es-BO': /^(\+?591)?(6|7)\d{7}$/, 26551 'es-CO': /^(\+?57)?([1-8]{1}|3[0-9]{2})?[2-9]{1}\d{6}$/, 26552 'es-CL': /^(\+?56|0)[2-9]\d{1}\d{7}$/, 26553 'es-CR': /^(\+506)?[2-8]\d{7}$/, 26554 'es-DO': /^(\+?1)?8[024]9\d{7}$/, 26555 'es-HN': /^(\+?504)?[9|8]\d{7}$/, 26556 'es-EC': /^(\+?593|0)([2-7]|9[2-9])\d{7}$/, 26557 'es-ES': /^(\+?34)?[6|7]\d{8}$/, 26558 'es-PE': /^(\+?51)?9\d{8}$/, 26559 'es-MX': /^(\+?52)?(1|01)?\d{10,11}$/, 26560 'es-PA': /^(\+?507)\d{7,8}$/, 26561 'es-PY': /^(\+?595|0)9[9876]\d{7}$/, 26562 'es-UY': /^(\+598|0)9[1-9][\d]{6}$/, 26563 'et-EE': /^(\+?372)?\s?(5|8[1-4])\s?([0-9]\s?){6,7}$/, 26564 'fa-IR': /^(\+?98[\-\s]?|0)9[0-39]\d[\-\s]?\d{3}[\-\s]?\d{4}$/, 26565 'fi-FI': /^(\+?358|0)\s?(4(0|1|2|4|5|6)?|50)\s?(\d\s?){4,8}\d$/, 26566 'fj-FJ': /^(\+?679)?\s?\d{3}\s?\d{4}$/, 26567 'fo-FO': /^(\+?298)?\s?\d{2}\s?\d{2}\s?\d{2}$/, 26568 'fr-FR': /^(\+?33|0)[67]\d{8}$/, 26569 'fr-GF': /^(\+?594|0|00594)[67]\d{8}$/, 26570 'fr-GP': /^(\+?590|0|00590)[67]\d{8}$/, 26571 'fr-MQ': /^(\+?596|0|00596)[67]\d{8}$/, 26572 'fr-RE': /^(\+?262|0|00262)[67]\d{8}$/, 26573 'he-IL': /^(\+972|0)([23489]|5[012345689]|77)[1-9]\d{6}$/, 26574 'hu-HU': /^(\+?36)(20|30|70)\d{7}$/, 26575 'id-ID': /^(\+?62|0)8(1[123456789]|2[1238]|3[1238]|5[12356789]|7[78]|9[56789]|8[123456789])([\s?|\d]{5,11})$/, 26576 'it-IT': /^(\+?39)?\s?3\d{2} ?\d{6,7}$/, 26577 'it-SM': /^((\+378)|(0549)|(\+390549)|(\+3780549))?6\d{5,9}$/, 26578 'ja-JP': /^(\+81[ \-]?(\(0\))?|0)[6789]0[ \-]?\d{4}[ \-]?\d{4}$/, 26579 'ka-GE': /^(\+?995)?(5|79)\d{7}$/, 26580 'kk-KZ': /^(\+?7|8)?7\d{9}$/, 26581 'kl-GL': /^(\+?299)?\s?\d{2}\s?\d{2}\s?\d{2}$/, 26582 'ko-KR': /^((\+?82)[ \-]?)?0?1([0|1|6|7|8|9]{1})[ \-]?\d{3,4}[ \-]?\d{4}$/, 26583 'lt-LT': /^(\+370|8)\d{8}$/, 26584 'ms-MY': /^(\+?6?01){1}(([0145]{1}(\-|\s)?\d{7,8})|([236789]{1}(\s|\-)?\d{7}))$/, 26585 'nb-NO': /^(\+?47)?[49]\d{7}$/, 26586 'ne-NP': /^(\+?977)?9[78]\d{8}$/, 26587 'nl-BE': /^(\+?32|0)4?\d{8}$/, 26588 'nl-NL': /^(((\+|00)?31\(0\))|((\+|00)?31)|0)6{1}\d{8}$/, 26589 'nn-NO': /^(\+?47)?[49]\d{7}$/, 26590 'pl-PL': /^(\+?48)? ?[5-8]\d ?\d{3} ?\d{2} ?\d{2}$/, 26591 'pt-BR': /^((\+?55\ ?[1-9]{2}\ ?)|(\+?55\ ?\([1-9]{2}\)\ ?)|(0[1-9]{2}\ ?)|(\([1-9]{2}\)\ ?)|([1-9]{2}\ ?))((\d{4}\-?\d{4})|(9[2-9]{1}\d{3}\-?\d{4}))$/, 26592 'pt-PT': /^(\+?351)?9[1236]\d{7}$/, 26593 'ro-RO': /^(\+?4?0)\s?7\d{2}(\/|\s|\.|\-)?\d{3}(\s|\.|\-)?\d{3}$/, 26594 'ru-RU': /^(\+?7|8)?9\d{9}$/, 26595 'sl-SI': /^(\+386\s?|0)(\d{1}\s?\d{3}\s?\d{2}\s?\d{2}|\d{2}\s?\d{3}\s?\d{3})$/, 26596 'sk-SK': /^(\+?421)? ?[1-9][0-9]{2} ?[0-9]{3} ?[0-9]{3}$/, 26597 'sq-AL': /^(\+355|0)6[789]\d{6}$/, 26598 'sr-RS': /^(\+3816|06)[- \d]{5,9}$/, 26599 'sv-SE': /^(\+?46|0)[\s\-]?7[\s\-]?[02369]([\s\-]?\d){7}$/, 26600 'th-TH': /^(\+66|66|0)\d{9}$/, 26601 'tr-TR': /^(\+?90|0)?5\d{9}$/, 26602 'uk-UA': /^(\+?38|8)?0\d{9}$/, 26603 'uz-UZ': /^(\+?998)?(6[125-79]|7[1-69]|88|9\d)\d{7}$/, 26604 'vi-VN': /^(\+?84|0)((3([2-9]))|(5([2689]))|(7([0|6-9]))|(8([1-6|89]))|(9([0-9])))([0-9]{7})$/, 26605 'zh-CN': /^((\+|00)86)?1([3568][0-9]|4[579]|6[67]|7[01235678]|9[012356789])[0-9]{8}$/, 26606 'zh-TW': /^(\+?886\-?|0)?9\d{8}$/ 26607 }; 26608 /* eslint-enable max-len */ 26609 // aliases 26610 26611 phones['en-CA'] = phones['en-US']; 26612 phones['fr-CA'] = phones['en-CA']; 26613 phones['fr-BE'] = phones['nl-BE']; 26614 phones['zh-HK'] = phones['en-HK']; 26615 phones['zh-MO'] = phones['en-MO']; 26616 phones['ga-IE'] = phones['en-IE']; 26617 26618 function isMobilePhone(str, locale, options) { 26619 (0, _assertString.default)(str); 26620 26621 if (options && options.strictMode && !str.startsWith('+')) { 26622 return false;
26623 } 26624 26625 if (Array.isArray(locale)) { 26626 return locale.some(function (key) { 26627 // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes 26628 // istanbul ignore else 26629 if (phones.hasOwnProperty(key)) { 26630 var phone = phones[key]; 26631 26632 if (phone.test(str)) { 26633 return true; 26634 } 26635 } 26636 26637 return false; 26638 }); 26639 } else if (locale in phones) { 26640 return phones[locale].test(str); // alias falsey locale as 'any' 26641 } else if (!locale || locale === 'any') { 26642 for (var key in phones) { 26643 // istanbul ignore else 26644 if (phones.hasOwnProperty(key)) { 26645 var phone = phones[key]; 26646 26647 if (phone.test(str)) { 26648 return true; 26649 } 26650 } 26651 } 26652 26653 return false; 26654 } 26655 26656 throw new Error("Invalid locale '".concat(locale, "'")); 26657 } 26658 26659 var locales = Object.keys(phones); 26660 exports.locales = locales; 26661 }); 26662 26663 var isMobilePhone = /*@__PURE__*/getDefaultExportFromCjs(isMobilePhone_1); 26664 26665 var isEthereumAddress_1 = createCommonjsModule(function (module, exports) { 26666 "use strict"; 26667 26668 Object.defineProperty(exports, "__esModule", { 26669 value: true 26670 }); 26671 exports.default = isEthereumAddress; 26672 26673 var _assertString = _interopRequireDefault(assertString_1); 26674 26675 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 26676 26677 var eth = /^(0x)[0-9a-f]{40}$/i; 26678 26679 function isEthereumAddress(str) { 26680 (0, _assertString.default)(str); 26681 return eth.test(str); 26682 } 26683 26684 module.exports = exports.default; 26685 module.exports.default = exports.default; 26686 }); 26687 26688 var isEthereumAddress = /*@__PURE__*/getDefaultExportFromCjs(isEthereumAddress_1); 26689 26690 var isCurrency_1 = createCommonjsModule(function (module, exports) { 26691 "use strict"; 26692 26693 Object.defineProperty(exports, "__esModule", { 26694 value: true 26695 }); 26696 exports.default = isCurrency; 26697 26698 var _merge = _interopRequireDefault(merge_1); 26699 26700 var _assertString = _interopRequireDefault(assertString_1); 26701 26702 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 26703 26704 function currencyRegex(options) { 26705 var decimal_digits = "\\d{".concat(options.digits_after_decimal[0], "}"); 26706 options.digits_after_decimal.forEach(function (digit, index) { 26707 if (index !== 0) decimal_digits = "".concat(decimal_digits, "|\\d{").concat(digit, "}"); 26708 }); 26709 var symbol = "(".concat(options.symbol.replace(/\W/, function (m) { 26710 return "\\".concat(m); 26711 }), ")").concat(options.require_symbol ? '' : '?'), 26712 negative = '-?', 26713 whole_dollar_amount_without_sep = '[1-9]\\d*', 26714 whole_dollar_amount_with_sep = "[1-9]\\d{0,2}(\\".concat(options.thousands_separator, "\\d{3})*"), 26715 valid_whole_dollar_amounts = ['0', whole_dollar_amount_without_sep, whole_dollar_amount_with_sep], 26716 whole_dollar_amount = "(".concat(valid_whole_dollar_amounts.join('|'), ")?"), 26717 decimal_amount = "(\\".concat(options.decimal_separator, "(").concat(decimal_digits, "))").concat(options.require_decimal ? '' : '?'); 26718 var pattern = whole_dollar_amount + (options.allow_decimal || options.require_decimal ? decimal_amount : ''); // default is negative sign before symbol, but there are two other options (besides parens) 26719 26720 if (options.allow_negatives && !options.parens_for_negatives) { 26721 if (options.negative_sign_after_digits) { 26722 pattern += negative; 26723 } else if (options.negative_sign_before_digits) { 26724 pattern = negative + pattern; 26725 } 26726 } // South African Rand, for example, uses R 123 (space) and R-123 (no space) 26727 26728 26729 if (options.allow_negative_sign_placeholder) { 26730 pattern = "( (?!\\-))?".concat(pattern); 26731 } else if (options.allow_space_after_symbol) { 26732 pattern = " ?".concat(pattern); 26733 } else if (options.allow_space_after_digits) { 26734 pattern += '( (?!$))?'; 26735 } 26736 26737 if (options.symbol_after_digits) { 26738 pattern += symbol; 26739 } else { 26740 pattern = symbol + pattern; 26741 } 26742 26743 if (options.allow_negatives) { 26744 if (options.parens_for_negatives) { 26745 pattern = "(\\(".concat(pattern, "\\)|").concat(pattern, ")"); 26746 } else if (!(options.negative_sign_before_digits || options.negative_sign_after_digits)) { 26747 pattern = negative + pattern; 26748 } 26749 } // ensure there's a dollar and/or decimal amount, and that 26750 // it doesn't start with a space or a negative sign followed by a space 26751 26752 26753 return new RegExp("^(?!-? )(?=.*\\d)".concat(pattern, "$")); 26754 } 26755 26756 var default_currency_options = { 26757 symbol: '$', 26758 require_symbol: false, 26759 allow_space_after_symbol: false, 26760 symbol_after_digits: false, 26761 allow_negatives: true, 26762 parens_for_negatives: false, 26763 negative_sign_before_digits: false, 26764 negative_sign_after_digits: false, 26765 allow_negative_sign_placeholder: false, 26766 thousands_separator: ',', 26767 decimal_separator: '.', 26768 allow_decimal: true,
26769 require_decimal: false, 26770 digits_after_decimal: [2], 26771 allow_space_after_digits: false 26772 }; 26773 26774 function isCurrency(str, options) { 26775 (0, _assertString.default)(str); 26776 options = (0, _merge.default)(options, default_currency_options); 26777 return currencyRegex(options).test(str); 26778 } 26779 26780 module.exports = exports.default; 26781 module.exports.default = exports.default; 26782 }); 26783 26784 var isCurrency = /*@__PURE__*/getDefaultExportFromCjs(isCurrency_1); 26785 26786 var isBtcAddress_1 = createCommonjsModule(function (module, exports) { 26787 "use strict"; 26788 26789 Object.defineProperty(exports, "__esModule", { 26790 value: true 26791 }); 26792 exports.default = isBtcAddress; 26793 26794 var _assertString = _interopRequireDefault(assertString_1); 26795 26796 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 26797 26798 // supports Bech32 addresses 26799 var btc = /^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/; 26800 26801 function isBtcAddress(str) { 26802 (0, _assertString.default)(str); 26803 return btc.test(str); 26804 } 26805 26806 module.exports = exports.default; 26807 module.exports.default = exports.default; 26808 }); 26809 26810 var isBtcAddress = /*@__PURE__*/getDefaultExportFromCjs(isBtcAddress_1); 26811 26812 var isISO8601_1 = createCommonjsModule(function (module, exports) { 26813 "use strict"; 26814 26815 Object.defineProperty(exports, "__esModule", { 26816 value: true 26817 }); 26818 exports.default = isISO8601; 26819 26820 var _assertString = _interopRequireDefault(assertString_1); 26821 26822 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 26823 26824 /* eslint-disable max-len */ 26825 // from http://goo.gl/0ejHHW 26826 var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; // same as above, except with a strict 'T' separator between date and time 26827 26828 var iso8601StrictSeparator = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; 26829 /* eslint-enable max-len */ 26830 26831 var isValidDate = function isValidDate(str) { 26832 // str must have passed the ISO8601 check 26833 // this check is meant to catch invalid dates 26834 // like 2009-02-31 26835 // first check for ordinal dates 26836 var ordinalMatch = str.match(/^(\d{4})-?(\d{3})([ T]{1}\.*|$)/); 26837 26838 if (ordinalMatch) { 26839 var oYear = Number(ordinalMatch[1]); 26840 var oDay = Number(ordinalMatch[2]); // if is leap year 26841 26842 if (oYear % 4 === 0 && oYear % 100 !== 0 || oYear % 400 === 0) return oDay <= 366; 26843 return oDay <= 365; 26844 } 26845 26846 var match = str.match(/(\d{4})-?(\d{0,2})-?(\d*)/).map(Number); 26847 var year = match[1]; 26848 var month = match[2]; 26849 var day = match[3]; 26850 var monthString = month ? "0".concat(month).slice(-2) : month; 26851 var dayString = day ? "0".concat(day).slice(-2) : day; // create a date object and compare 26852 26853 var d = new Date("".concat(year, "-").concat(monthString || '01', "-").concat(dayString || '01')); 26854 26855 if (month && day) { 26856 return d.getUTCFullYear() === year && d.getUTCMonth() + 1 === month && d.getUTCDate() === day; 26857 } 26858 26859 return true; 26860 }; 26861 26862 function isISO8601(str) { 26863 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 26864 (0, _assertString.default)(str); 26865 var check = options.strictSeparator ? iso8601StrictSeparator.test(str) : iso8601.test(str); 26866 if (check && options.strict) return isValidDate(str); 26867 return check; 26868 } 26869 26870 module.exports = exports.default; 26871 module.exports.default = exports.default; 26872 }); 26873 26874 var isISO8601 = /*@__PURE__*/getDefaultExportFromCjs(isISO8601_1); 26875 26876 var isRFC3339_1 = createCommonjsModule(function (module, exports) { 26877 "use strict"; 26878 26879 Object.defineProperty(exports, "__esModule", { 26880 value: true 26881 }); 26882 exports.default = isRFC3339; 26883 26884 var _assertString = _interopRequireDefault(assertString_1); 26885 26886 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 26887 26888 /* Based on https://tools.ietf.org/html/rfc3339#section-5.6 */ 26889 var dateFullYear = /[0-9]{4}/; 26890 var dateMonth = /(0[1-9]|1[0-2])/; 26891 var dateMDay = /([12]\d|0[1-9]|3[01])/; 26892 var timeHour = /([01][0-9]|2[0-3])/; 26893 var timeMinute = /[0-5][0-9]/; 26894 var timeSecond = /([0-5][0-9]|60)/; 26895 var timeSecFrac = /(\.[0-9]+)?/; 26896 var timeNumOffset = new RegExp("[-+]".concat(timeHour.source, ":").concat(timeMinute.source)); 26897 var timeOffset = new RegExp("([zZ]|".concat(timeNumOffset.source, ")")); 26898 var partialTime = new RegExp("".concat(timeHour.source, ":").concat(timeMinute.source, ":").concat(timeSecond.source).concat(timeSecFrac.source)); 26899 var fullDate = new RegExp("".concat(dateFullYear.source, "-").concat(dateMonth.source, "-").concat(dateMDay.source)); 26900 var fullTime = new RegExp("".concat(partialTime.source).concat(timeOffset.source)); 26901 var rfc3339 = new RegExp("".concat(fullDate.source, "[ tT]").concat(fullTime.source)); 26902 26903 function isRFC3339(str) { 26904 (0, _assertString.default)(str); 26905 return rfc3339.test(str); 26906 } 26907 26908 module.exports = exports.default; 26909 module.exports.default = exports.default; 26910 }); 26911 26912 var isRFC3339 = /*@__PURE__*/getDefaultExportFromCjs(isRFC3339_1); 26913 26914 var isISO31661Alpha2_1 = createCommonjsModule(function (module, exports
26914) { 26915 "use strict"; 26916 26917 Object.defineProperty(exports, "__esModule", { 26918 value: true 26919 }); 26920 exports.default = isISO31661Alpha2; 26921 26922 var _assertString = _interopRequireDefault(assertString_1); 26923 26924 var _includes = _interopRequireDefault(includes_1); 26925 26926 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 26927 26928 // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 26929 var validISO31661Alpha2CountriesCodes = ['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW']; 26930 26931 function isISO31661Alpha2(str) { 26932 (0, _assertString.default)(str); 26933 return (0, _includes.default)(validISO31661Alpha2CountriesCodes, str.toUpperCase()); 26934 } 26935 26936 module.exports = exports.default; 26937 module.exports.default = exports.default; 26938 }); 26939 26940 var isISO31661Alpha2 = /*@__PURE__*/getDefaultExportFromCjs(isISO31661Alpha2_1); 26941 26942 var isISO31661Alpha3_1 = createCommonjsModule(function (module, exports) { 26943 "use strict"; 26944 26945 Object.defineProperty(exports, "__esModule", { 26946 value: true 26947 }); 26948 exports.default = isISO31661Alpha3; 26949 26950 var _assertString = _interopRequireDefault(assertString_1); 26951 26952 var _includes = _interopRequireDefault(includes_1); 26953 26954 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 26955 26956 // from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3 26957 var validISO31661Alpha3CountriesCodes = ['AFG', 'ALA', 'ALB', 'DZA', 'ASM', 'AND', 'AGO', 'AIA', 'ATA', 'ATG', 'ARG', 'ARM', 'ABW', 'AUS', 'AUT', 'AZE', 'BHS', 'BHR', 'BGD', 'BRB', 'BLR', 'BEL', 'BLZ', 'BEN', 'BMU', 'BTN', 'BOL', 'BES', 'BIH', 'BWA', 'BVT', 'BRA', 'IOT', 'BRN', 'BGR', 'BFA', 'BDI', 'KHM', 'CMR', 'CAN', 'CPV', 'CYM', 'CAF', 'TCD', 'CHL', 'CHN', 'CXR', 'CCK', 'COL', 'COM', 'COG', 'COD', 'COK', 'CRI', 'CIV', 'HRV', 'CUB', 'CUW', 'CYP', 'CZE', 'DNK', 'DJI', 'DMA', 'DOM', 'ECU', 'EGY', 'SLV', 'GNQ', 'ERI', 'EST', 'ETH', 'FLK', 'FRO', 'FJI', 'FIN', 'FRA', 'GUF', 'PYF', 'ATF', 'GAB', 'GMB', 'GEO', 'DEU', 'GHA', 'GIB', 'GRC', 'GRL', 'GRD', 'GLP', 'GUM', 'GTM', 'GGY', 'GIN', 'GNB', 'GUY', 'HTI', 'HMD', 'VAT', 'HND', 'HKG', 'HUN', 'ISL', 'IND', 'IDN', 'IRN', 'IRQ', 'IRL', 'IMN', 'ISR', 'ITA', 'JAM', 'JPN', 'JEY', 'JOR', 'KAZ', 'KEN', 'KIR', 'PRK', 'KOR', 'KWT', 'KGZ', 'LAO', 'LVA', 'LBN', 'LSO', 'LBR', 'LBY', 'LIE', 'LTU', 'LUX', 'MAC', 'MKD', 'MDG', 'MWI', 'MYS', 'MDV', 'MLI', 'MLT', 'MHL', 'MTQ', 'MRT', 'MUS', 'MYT', 'MEX', 'FSM', 'MDA', 'MCO', 'MNG', 'MNE', 'MSR', 'MAR', 'MOZ', 'MMR', 'NAM', 'NRU', 'NPL', 'NLD', 'NCL', 'NZL', 'NIC', 'NER', 'NGA', 'NIU', 'NFK', 'MNP', 'NOR', 'OMN', 'PAK', 'PLW', 'PSE', 'PAN', 'PNG', 'PRY', 'PER', 'PHL', 'PCN', 'POL', 'PRT', 'PRI', 'QAT', 'REU', 'ROU', 'RUS', 'RWA', 'BLM', 'SHN', 'KNA', 'LCA', 'MAF', 'SPM', 'VCT', 'WSM', 'SMR', 'STP', 'SAU', 'SEN', 'SRB', 'SYC', 'SLE', 'SGP', 'SXM', 'SVK', 'SVN', 'SLB', 'SOM', 'ZAF', '
26957SGS', 'SSD', 'ESP', 'LKA', 'SDN', 'SUR', 'SJM', 'SWZ', 'SWE', 'CHE', 'SYR', 'TWN', 'TJK', 'TZA', 'THA', 'TLS', 'TGO', 'TKL', 'TON', 'TTO', 'TUN', 'TUR', 'TKM', 'TCA', 'TUV', 'UGA', 'UKR', 'ARE', 'GBR', 'USA', 'UMI', 'URY', 'UZB', 'VUT', 'VEN', 'VNM', 'VGB', 'VIR', 'WLF', 'ESH', 'YEM', 'ZMB', 'ZWE']; 26958 26959 function isISO31661Alpha3(str) { 26960 (0, _assertString.default)(str); 26961 return (0, _includes.default)(validISO31661Alpha3CountriesCodes, str.toUpperCase()); 26962 } 26963 26964 module.exports = exports.default; 26965 module.exports.default = exports.default; 26966 }); 26967 26968 var isISO31661Alpha3 = /*@__PURE__*/getDefaultExportFromCjs(isISO31661Alpha3_1); 26969 26970 var isBase32_1 = createCommonjsModule(function (module, exports) { 26971 "use strict"; 26972 26973 Object.defineProperty(exports, "__esModule", { 26974 value: true 26975 }); 26976 exports.default = isBase32; 26977 26978 var _assertString = _interopRequireDefault(assertString_1); 26979 26980 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 26981 26982 var base32 = /^[A-Z2-7]+=*$/; 26983 26984 function isBase32(str) { 26985 (0, _assertString.default)(str); 26986 var len = str.length; 26987 26988 if (len % 8 === 0 && base32.test(str)) { 26989 return true; 26990 } 26991 26992 return false; 26993 } 26994 26995 module.exports = exports.default; 26996 module.exports.default = exports.default; 26997 }); 26998 26999 var isBase32 = /*@__PURE__*/getDefaultExportFromCjs(isBase32_1); 27000 27001 var isBase58_1 = createCommonjsModule(function (module, exports) { 27002 "use strict"; 27003 27004 Object.defineProperty(exports, "__esModule", { 27005 value: true 27006 }); 27007 exports.default = isBase58; 27008 27009 var _assertString = _interopRequireDefault(assertString_1); 27010 27011 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27012 27013 // Accepted chars - 123456789ABCDEFGH JKLMN PQRSTUVWXYZabcdefghijk mnopqrstuvwxyz 27014 var base58Reg = /^[A-HJ-NP-Za-km-z1-9]*$/; 27015 27016 function isBase58(str) { 27017 (0, _assertString.default)(str); 27018 27019 if (base58Reg.test(str)) { 27020 return true; 27021 } 27022 27023 return false; 27024 } 27025 27026 module.exports = exports.default; 27027 module.exports.default = exports.default; 27028 }); 27029 27030 var isBase58 = /*@__PURE__*/getDefaultExportFromCjs(isBase58_1); 27031 27032 var isDataURI_1 = createCommonjsModule(function (module, exports) { 27033 "use strict"; 27034 27035 Object.defineProperty(exports, "__esModule", { 27036 value: true 27037 }); 27038 exports.default = isDataURI; 27039 27040 var _assertString = _interopRequireDefault(assertString_1); 27041 27042 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27043 27044 var validMediaType = /^[a-z]+\/[a-z0-9\-\+]+$/i; 27045 var validAttribute = /^[a-z\-]+=[a-z0-9\-]+$/i; 27046 var validData = /^[a-z0-9!\$&'\(\)\*\+,;=\-\._~:@\/\?%\s]*$/i; 27047 27048 function isDataURI(str) { 27049 (0, _assertString.default)(str); 27050 var data = str.split(','); 27051 27052 if (data.length < 2) { 27053 return false; 27054 } 27055 27056 var attributes = data.shift().trim().split(';'); 27057 var schemeAndMediaType = attributes.shift(); 27058 27059 if (schemeAndMediaType.substr(0, 5) !== 'data:') { 27060 return false; 27061 } 27062 27063 var mediaType = schemeAndMediaType.substr(5); 27064 27065 if (mediaType !== '' && !validMediaType.test(mediaType)) { 27066 return false; 27067 } 27068 27069 for (var i = 0; i < attributes.length; i++) { 27070 if (i === attributes.length - 1 && attributes[i].toLowerCase() === 'base64') {// ok 27071 } else if (!validAttribute.test(attributes[i])) { 27072 return false; 27073 } 27074 } 27075 27076 for (var _i = 0; _i < data.length; _i++) { 27077 if (!validData.test(data[_i])) { 27078 return false; 27079 } 27080 } 27081 27082 return true; 27083 } 27084 27085 module.exports = exports.default; 27086 module.exports.default = exports.default; 27087 }); 27088 27089 var isDataURI = /*@__PURE__*/getDefaultExportFromCjs(isDataURI_1); 27090 27091 var isMagnetURI_1 = createCommonjsModule(function (module, exports) { 27092 "use strict"; 27093 27094 Object.defineProperty(exports, "__esModule", { 27095 value: true 27096 }); 27097 exports.default = isMagnetURI; 27098 27099 var _assertString = _interopRequireDefault(assertString_1); 27100 27101 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27102 27103 var magnetURI = /^magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32,40}&dn=.+&tr=.+$/i; 27104 27105 function isMagnetURI(url) { 27106 (0, _assertString.default)(url); 27107 return magnetURI.test(url.trim()); 27108 } 27109 27110 module.exports = exports.default; 27111 module.exports.default = exports.default; 27112 }); 27113 27114 var isMagnetURI = /*@__PURE__*/getDefaultExportFromCjs(isMagnetURI_1); 27115 27116 var isMimeType_1 = createCommonjsModule(function (module, exports
27116) { 27117 "use strict"; 27118 27119 Object.defineProperty(exports, "__esModule", { 27120 value: true 27121 }); 27122 exports.default = isMimeType; 27123 27124 var _assertString = _interopRequireDefault(assertString_1); 27125 27126 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27127 27128 /* 27129 Checks if the provided string matches to a correct Media type format (MIME type) 27130 27131 This function only checks is the string format follows the 27132 etablished rules by the according RFC specifications. 27133 This function supports 'charset' in textual media types 27134 (https://tools.ietf.org/html/rfc6657). 27135 27136 This function does not check against all the media types listed 27137 by the IANA (https://www.iana.org/assignments/media-types/media-types.xhtml) 27138 because of lightness purposes : it would require to include 27139 all these MIME types in this librairy, which would weigh it 27140 significantly. This kind of effort maybe is not worth for the use that 27141 this function has in this entire librairy. 27142 27143 More informations in the RFC specifications : 27144 - https://tools.ietf.org/html/rfc2045 27145 - https://tools.ietf.org/html/rfc2046 27146 - https://tools.ietf.org/html/rfc7231#section-3.1.1.1 27147 - https://tools.ietf.org/html/rfc7231#section-3.1.1.5 27148 */ 27149 // Match simple MIME types 27150 // NB : 27151 // Subtype length must not exceed 100 characters. 27152 // This rule does not comply to the RFC specs (what is the max length ?). 27153 var mimeTypeSimple = /^(application|audio|font|image|message|model|multipart|text|video)\/[a-zA-Z0-9\.\-\+]{1,100}$/i; // eslint-disable-line max-len 27154 // Handle "charset" in "text/*" 27155 27156 var mimeTypeText = /^text\/[a-zA-Z0-9\.\-\+]{1,100};\s?charset=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?$/i; // eslint-disable-line max-len 27157 // Handle "boundary" in "multipart/*" 27158 27159 var mimeTypeMultipart = /^multipart\/[a-zA-Z0-9\.\-\+]{1,100}(;\s?(boundary|charset)=("[a-zA-Z0-9\.\-\+\s]{0,70}"|[a-zA-Z0-9\.\-\+]{0,70})(\s?\([a-zA-Z0-9\.\-\+\s]{1,20}\))?){0,2}$/i; // eslint-disable-line max-len 27160 27161 function isMimeType(str) { 27162 (0, _assertString.default)(str); 27163 return mimeTypeSimple.test(str) || mimeTypeText.test(str) || mimeTypeMultipart.test(str); 27164 } 27165 27166 module.exports = exports.default; 27167 module.exports.default = exports.default; 27168 }); 27169 27170 var isMimeType = /*@__PURE__*/getDefaultExportFromCjs(isMimeType_1); 27171 27172 var isLatLong_1 = createCommonjsModule(function (module, exports) { 27173 "use strict"; 27174 27175 Object.defineProperty(exports, "__esModule", { 27176 value: true 27177 }); 27178 exports.default = isLatLong; 27179 27180 var _assertString = _interopRequireDefault(assertString_1); 27181 27182 var _merge = _interopRequireDefault(merge_1); 27183 27184 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27185 27186 var lat = /^\(?[+-]?(90(\.0+)?|[1-8]?\d(\.\d+)?)$/; 27187 var long = /^\s?[+-]?(180(\.0+)?|1[0-7]\d(\.\d+)?|\d{1,2}(\.\d+)?)\)?$/; 27188 var latDMS = /^(([1-8]?\d)\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|90\D+0\D+0)\D+[NSns]?$/i; 27189 var longDMS = /^\s*([1-7]?\d{1,2}\D+([1-5]?\d|60)\D+([1-5]?\d|60)(\.\d+)?|180\D+0\D+0)\D+[EWew]?$/i; 27190 var defaultLatLongOptions = { 27191 checkDMS: false 27192 }; 27193 27194 function isLatLong(str, options) { 27195 (0, _assertString.default)(str); 27196 options = (0, _merge.default)(options, defaultLatLongOptions); 27197 if (!str.includes(',')) return false; 27198 var pair = str.split(','); 27199 if (pair[0].startsWith('(') && !pair[1].endsWith(')') || pair[1].endsWith(')') && !pair[0].startsWith('(')) return false; 27200 27201 if (options.checkDMS) { 27202 return latDMS.test(pair[0]) && longDMS.test(pair[1]); 27203 } 27204 27205 return lat.test(pair[0]) && long.test(pair[1]); 27206 } 27207 27208 module.exports = exports.default; 27209 module.exports.default = exports.default; 27210 }); 27211 27212 var isLatLong = /*@__PURE__*/getDefaultExportFromCjs(isLatLong_1); 27213 27214 var isPostalCode_1 = createCommonjsModule(function (module, exports) { 27215 "use strict"; 27216 27217 Object.defineProperty(exports, "__esModule", { 27218 value: true 27219 }); 27220 exports.default = isPostalCode; 27221 exports.locales = void 0; 27222 27223 var _assertString = _interopRequireDefault(assertString_1); 27224 27225 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27226 27227 // common patterns 27228 var threeDigit = /^\d{3}$/; 27229 var fourDigit = /^\d{4}$/; 27230 var fiveDigit = /^\d{5}
27230$/; 27231 var sixDigit = /^\d{6}$/; 27232 var patterns = { 27233 AD: /^AD\d{3}$/, 27234 AT: fourDigit, 27235 AU: fourDigit, 27236 AZ: /^AZ\d{4}$/, 27237 BE: fourDigit, 27238 BG: fourDigit, 27239 BR: /^\d{5}-\d{3}$/, 27240 BY: /2[1-4]{1}\d{4}$/, 27241 CA: /^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJ-NPRSTV-Z][\s\-]?\d[ABCEGHJ-NPRSTV-Z]\d$/i, 27242 CH: fourDigit, 27243 CN: /^(0[1-7]|1[012356]|2[0-7]|3[0-6]|4[0-7]|5[1-7]|6[1-7]|7[1-5]|8[1345]|9[09])\d{4}$/, 27244 CZ: /^\d{3}\s?\d{2}$/, 27245 DE: fiveDigit, 27246 DK: fourDigit, 27247 DO: fiveDigit, 27248 DZ: fiveDigit, 27249 EE: fiveDigit, 27250 ES: /^(5[0-2]{1}|[0-4]{1}\d{1})\d{3}$/, 27251 FI: fiveDigit, 27252 FR: /^\d{2}\s?\d{3}$/, 27253 GB: /^(gir\s?0aa|[a-z]{1,2}\d[\da-z]?\s?(\d[a-z]{2})?)$/i, 27254 GR: /^\d{3}\s?\d{2}$/, 27255 HR: /^([1-5]\d{4}$)/, 27256 HT: /^HT\d{4}$/, 27257 HU: fourDigit, 27258 ID: fiveDigit, 27259 IE: /^(?!.*(?:o))[A-z]\d[\dw]\s\w{4}$/i, 27260 IL: /^(\d{5}|\d{7})$/, 27261 IN: /^((?!10|29|35|54|55|65|66|86|87|88|89)[1-9][0-9]{5})$/, 27262 IR: /\b(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}\b/, 27263 IS: threeDigit, 27264 IT: fiveDigit, 27265 JP: /^\d{3}\-\d{4}$/, 27266 KE: fiveDigit, 27267 LI: /^(948[5-9]|949[0-7])$/, 27268 LT: /^LT\-\d{5}$/, 27269 LU: fourDigit, 27270 LV: /^LV\-\d{4}$/, 27271 MX: fiveDigit, 27272 MT: /^[A-Za-z]{3}\s{0,1}\d{4}$/, 27273 MY: fiveDigit, 27274 NL: /^\d{4}\s?[a-z]{2}$/i, 27275 NO: fourDigit, 27276 NP: /^(10|21|22|32|33|34|44|45|56|57)\d{3}$|^(977)$/i, 27277 NZ: fourDigit, 27278 PL: /^\d{2}\-\d{3}$/, 27279 PR: /^00[679]\d{2}([ -]\d{4})?$/, 27280 PT: /^\d{4}\-\d{3}?$/, 27281 RO: sixDigit, 27282 RU: sixDigit, 27283 SA: fiveDigit, 27284 SE: /^[1-9]\d{2}\s?\d{2}$/, 27285 SG: sixDigit, 27286 SI: fourDigit, 27287 SK: /^\d{3}\s?\d{2}$/, 27288 TH: fiveDigit, 27289 TN: fourDigit, 27290 TW: /^\d{3}(\d{2})?$/, 27291 UA: fiveDigit, 27292 US: /^\d{5}(-\d{4})?$/, 27293 ZA: fourDigit, 27294 ZM: fiveDigit 27295 }; 27296 var locales = Object.keys(patterns); 27297 exports.locales = locales; 27298 27299 function isPostalCode(str, locale) { 27300 (0, _assertString.default)(str); 27301 27302 if (locale in patterns) { 27303 return patterns[locale].test(str); 27304 } else if (locale === 'any') { 27305 for (var key in patterns) { 27306 // https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md#ignoring-code-for-coverage-purposes 27307 // istanbul ignore else 27308 if (patterns.hasOwnProperty(key)) { 27309 var pattern = patterns[key]; 27310 27311 if (pattern.test(str)) { 27312 return true; 27313 } 27314 } 27315 } 27316 27317 return false; 27318 } 27319 27320 throw new Error("Invalid locale '".concat(locale, "'")); 27321 } 27322 }); 27323 27324 var isPostalCode = /*@__PURE__*/getDefaultExportFromCjs(isPostalCode_1); 27325 27326 var ltrim_1 = createCommonjsModule(function (module, exports) { 27327 "use strict"; 27328 27329 Object.defineProperty(exports, "__esModule", { 27330 value: true 27331 }); 27332 exports.default = ltrim; 27333 27334 var _assertString = _interopRequireDefault(assertString_1); 27335 27336 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27337 27338 function ltrim(str, chars) { 27339 (0, _assertString.default)(str); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping 27340 27341 var pattern = chars ? new RegExp("^[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+"), 'g') : /^\s+/g; 27342 return str.replace(pattern, ''); 27343 } 27344 27345 module.exports = exports.default; 27346 module.exports.default = exports.default; 27347 }); 27348 27349 var ltrim = /*@__PURE__*/getDefaultExportFromCjs(ltrim_1); 27350 27351 var rtrim_1 = createCommonjsModule(function (module, exports) { 27352 "use strict"; 27353 27354 Object.defineProperty(exports, "__esModule", { 27355 value: true 27356 }); 27357 exports.default = rtrim; 27358 27359 var _assertString = _interopRequireDefault(assertString_1); 27360 27361 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27362 27363 function rtrim(str, chars) { 27364 (0, _assertString.default)(str); // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Escaping 27365 27366 var pattern = chars ? new RegExp("[".concat(chars.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), "]+$"), 'g') : /\s+$/g; 27367 return str.replace(pattern, ''); 27368 } 27369 27370 module.exports = exports.default; 27371 module.exports.default = exports.default; 27372 }); 27373 27374 var rtrim = /*@__PURE__*/getDefaultExportFromCjs(rtrim_1); 27375
27376 var trim_1 = createCommonjsModule(function (module, exports) { 27377 "use strict"; 27378 27379 Object.defineProperty(exports, "__esModule", { 27380 value: true 27381 }); 27382 exports.default = trim; 27383 27384 var _rtrim = _interopRequireDefault(rtrim_1); 27385 27386 var _ltrim = _interopRequireDefault(ltrim_1); 27387 27388 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27389 27390 function trim(str, chars) { 27391 return (0, _rtrim.default)((0, _ltrim.default)(str, chars), chars); 27392 } 27393 27394 module.exports = exports.default; 27395 module.exports.default = exports.default; 27396 }); 27397 27398 var trim = /*@__PURE__*/getDefaultExportFromCjs(trim_1); 27399 27400 var _escape = createCommonjsModule(function (module, exports) { 27401 "use strict"; 27402 27403 Object.defineProperty(exports, "__esModule", { 27404 value: true 27405 }); 27406 exports.default = escape; 27407 27408 var _assertString = _interopRequireDefault(assertString_1); 27409 27410 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27411 27412 function escape(str) { 27413 (0, _assertString.default)(str); 27414 return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>').replace(/\//g, '/').replace(/\\/g, '\').replace(/`/g, '`'); 27415 } 27416 27417 module.exports = exports.default; 27418 module.exports.default = exports.default; 27419 }); 27420 27421 var _escape$1 = /*@__PURE__*/getDefaultExportFromCjs(_escape); 27422 27423 var _unescape = createCommonjsModule(function (module, exports) { 27424 "use strict"; 27425 27426 Object.defineProperty(exports, "__esModule", { 27427 value: true 27428 }); 27429 exports.default = unescape; 27430 27431 var _assertString = _interopRequireDefault(assertString_1); 27432 27433 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27434 27435 function unescape(str) { 27436 (0, _assertString.default)(str); 27437 return str.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(///g, '/').replace(/\/g, '\\').replace(/`/g, '`'); 27438 } 27439 27440 module.exports = exports.default; 27441 module.exports.default = exports.default; 27442 }); 27443 27444 var _unescape$1 = /*@__PURE__*/getDefaultExportFromCjs(_unescape); 27445 27446 var blacklist_1 = createCommonjsModule(function (module, exports) { 27447 "use strict"; 27448 27449 Object.defineProperty(exports, "__esModule", { 27450 value: true 27451 }); 27452 exports.default = blacklist; 27453 27454 var _assertString = _interopRequireDefault(assertString_1); 27455 27456 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27457 27458 function blacklist(str, chars) { 27459 (0, _assertString.default)(str); 27460 return str.replace(new RegExp("[".concat(chars, "]+"), 'g'), ''); 27461 } 27462 27463 module.exports = exports.default; 27464 module.exports.default = exports.default; 27465 }); 27466 27467 var blacklist = /*@__PURE__*/getDefaultExportFromCjs(blacklist_1); 27468 27469 var stripLow_1 = createCommonjsModule(function (module, exports) { 27470 "use strict"; 27471 27472 Object.defineProperty(exports, "__esModule", { 27473 value: true 27474 }); 27475 exports.default = stripLow; 27476 27477 var _assertString = _interopRequireDefault(assertString_1); 27478 27479 var _blacklist = _interopRequireDefault(blacklist_1); 27480 27481 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27482 27483 function stripLow(str, keep_new_lines) { 27484 (0, _assertString.default)(str); 27485 var chars = keep_new_lines ? '\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F' : '\\x00-\\x1F\\x7F'; 27486 return (0, _blacklist.default)(str, chars); 27487 } 27488 27489 module.exports = exports.default; 27490 module.exports.default = exports.default; 27491 }); 27492 27493 var stripLow = /*@__PURE__*/getDefaultExportFromCjs(stripLow_1); 27494 27495 var whitelist_1 = createCommonjsModule(function (module, exports) { 27496 "use strict"; 27497 27498 Object.defineProperty(exports, "__esModule", { 27499 value: true 27500 }); 27501 exports.default = whitelist; 27502 27503 var _assertString = _interopRequireDefault(assertString_1); 27504 27505 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27506 27507 function whitelist(str, chars) { 27508 (0, _assertString.default)(str); 27509 return str.replace(new RegExp("[^".concat(chars, "]+"), 'g'), ''); 27510 } 27511 27512 module.exports = exports.default; 27513 module.exports.default = exports.default; 27514 }); 27515 27516 var whitelist = /*@__PURE__*/getDefaultExportFromCjs(whitelist_1); 27517 27518 var isWhitelisted_1 = createCommonjsModule(function (module, exports
27518) { 27519 "use strict"; 27520 27521 Object.defineProperty(exports, "__esModule", { 27522 value: true 27523 }); 27524 exports.default = isWhitelisted; 27525 27526 var _assertString = _interopRequireDefault(assertString_1); 27527 27528 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27529 27530 function isWhitelisted(str, chars) { 27531 (0, _assertString.default)(str); 27532 27533 for (var i = str.length - 1; i >= 0; i--) { 27534 if (chars.indexOf(str[i]) === -1) { 27535 return false; 27536 } 27537 } 27538 27539 return true; 27540 } 27541 27542 module.exports = exports.default; 27543 module.exports.default = exports.default; 27544 }); 27545 27546 var isWhitelisted = /*@__PURE__*/getDefaultExportFromCjs(isWhitelisted_1); 27547 27548 var normalizeEmail_1 = createCommonjsModule(function (module, exports) { 27549 "use strict"; 27550 27551 Object.defineProperty(exports, "__esModule", { 27552 value: true 27553 }); 27554 exports.default = normalizeEmail; 27555 27556 var _merge = _interopRequireDefault(merge_1); 27557 27558 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27559 27560 var default_normalize_email_options = { 27561 // The following options apply to all email addresses 27562 // Lowercases the local part of the email address. 27563 // Please note this may violate RFC 5321 as per http://stackoverflow.com/a/9808332/192024). 27564 // The domain is always lowercased, as per RFC 1035 27565 all_lowercase: true, 27566 // The following conversions are specific to GMail 27567 // Lowercases the local part of the GMail address (known to be case-insensitive) 27568 gmail_lowercase: true, 27569 // Removes dots from the local part of the email address, as that's ignored by GMail 27570 gmail_remove_dots: true, 27571 // Removes the subaddress (e.g. "+foo") from the email address 27572 gmail_remove_subaddress: true, 27573 // Conversts the googlemail.com domain to gmail.com 27574 gmail_convert_googlemaildotcom: true, 27575 // The following conversions are specific to Outlook.com / Windows Live / Hotmail 27576 // Lowercases the local part of the Outlook.com address (known to be case-insensitive) 27577 outlookdotcom_lowercase: true, 27578 // Removes the subaddress (e.g. "+foo") from the email address 27579 outlookdotcom_remove_subaddress: true, 27580 // The following conversions are specific to Yahoo 27581 // Lowercases the local part of the Yahoo address (known to be case-insensitive) 27582 yahoo_lowercase: true, 27583 // Removes the subaddress (e.g. "-foo") from the email address 27584 yahoo_remove_subaddress: true, 27585 // The following conversions are specific to Yandex 27586 // Lowercases the local part of the Yandex address (known to be case-insensitive) 27587 yandex_lowercase: true, 27588 // The following conversions are specific to iCloud 27589 // Lowercases the local part of the iCloud address (known to be case-insensitive) 27590 icloud_lowercase: true, 27591 // Removes the subaddress (e.g. "+foo") from the email address 27592 icloud_remove_subaddress: true 27593 }; // List of domains used by iCloud 27594 27595 var icloud_domains = ['icloud.com', 'me.com']; // List of domains used by Outlook.com and its predecessors 27596 // This list is likely incomplete. 27597 // Partial reference: 27598 // https://blogs.office.com/2013/04/17/outlook-com-gets-two-step-verification-sign-in-by-alias-and-new-international-domains/ 27599 27600 var outlookdotcom_domains = ['hotmail.at', 'hotmail.be', 'hotmail.ca', 'hotmail.cl', 'hotmail.co.il', 'hotmail.co.nz', 'hotmail.co.th', 'hotmail.co.uk', 'hotmail.com', 'hotmail.com.ar', 'hotmail.com.au', 'hotmail.com.br', 'hotmail.com.gr', 'hotmail.com.mx', 'hotmail.com.pe', 'hotmail.com.tr', 'hotmail.com.vn', 'hotmail.cz', 'hotmail.de', 'hotmail.dk', 'hotmail.es', 'hotmail.fr', 'hotmail.hu', 'hotmail.id', 'hotmail.ie', 'hotmail.in', 'hotmail.it', 'hotmail.jp', 'hotmail.kr', 'hotmail.lv', 'hotmail.my', 'hotmail.ph', 'hotmail.pt', 'hotmail.sa', 'hotmail.sg', 'hotmail.sk', 'live.be', 'live.co.uk', 'live.com', 'live.com.ar', 'live.com.mx', 'live.de', 'live.es', 'live.eu', 'live.fr', 'live.it', 'live.nl', 'msn.com', 'outlook.at', 'outlook.be', 'outlook.cl', 'outlook.co.il', 'outlook.co.nz', 'outlook.co.th', 'outlook.com', 'outlook.com.ar', 'outlook.com.au', 'outlook.com.br', 'outlook.com.gr', 'outlook.com.pe', 'outlook.com.tr', 'outlook.com.vn', 'outlook.cz', 'outlook.de', 'outlook.dk', 'outlook.es', 'outlook.fr', 'outlook.hu', 'outlook.id', 'outlook.ie', 'outlook.in', 'outlook.it', 'outlook.jp', 'outlook.kr', 'outlook.lv', 'outlook.my', 'outlook.ph', 'outlook.pt', 'outlook.sa', 'outlook.sg', 'outlook.sk', 'passport.com']; // List of domains used by Yahoo Mail 27601 // This list is likely incomplete 27602
27603 var yahoo_domains = ['rocketmail.com', 'yahoo.ca', 'yahoo.co.uk', 'yahoo.com', 'yahoo.de', 'yahoo.fr', 'yahoo.in', 'yahoo.it', 'ymail.com']; // List of domains used by yandex.ru 27604 27605 var yandex_domains = ['yandex.ru', 'yandex.ua', 'yandex.kz', 'yandex.com', 'yandex.by', 'ya.ru']; // replace single dots, but not multiple consecutive dots 27606 27607 function dotsReplacer(match) { 27608 if (match.length > 1) { 27609 return match; 27610 } 27611 27612 return ''; 27613 } 27614 27615 function normalizeEmail(email, options) { 27616 options = (0, _merge.default)(options, default_normalize_email_options); 27617 var raw_parts = email.split('@'); 27618 var domain = raw_parts.pop(); 27619 var user = raw_parts.join('@'); 27620 var parts = [user, domain]; // The domain is always lowercased, as it's case-insensitive per RFC 1035 27621 27622 parts[1] = parts[1].toLowerCase(); 27623 27624 if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') { 27625 // Address is GMail 27626 if (options.gmail_remove_subaddress) { 27627 parts[0] = parts[0].split('+')[0]; 27628 } 27629 27630 if (options.gmail_remove_dots) { 27631 // this does not replace consecutive dots like [email protected] 27632 parts[0] = parts[0].replace(/\.+/g, dotsReplacer); 27633 } 27634 27635 if (!parts[0].length) { 27636 return false; 27637 } 27638 27639 if (options.all_lowercase || options.gmail_lowercase) { 27640 parts[0] = parts[0].toLowerCase(); 27641 } 27642 27643 parts[1] = options.gmail_convert_googlemaildotcom ? 'gmail.com' : parts[1]; 27644 } else if (icloud_domains.indexOf(parts[1]) >= 0) { 27645 // Address is iCloud 27646 if (options.icloud_remove_subaddress) { 27647 parts[0] = parts[0].split('+')[0]; 27648 } 27649 27650 if (!parts[0].length) { 27651 return false; 27652 } 27653 27654 if (options.all_lowercase || options.icloud_lowercase) { 27655 parts[0] = parts[0].toLowerCase(); 27656 } 27657 } else if (outlookdotcom_domains.indexOf(parts[1]) >= 0) { 27658 // Address is Outlook.com 27659 if (options.outlookdotcom_remove_subaddress) { 27660 parts[0] = parts[0].split('+')[0]; 27661 } 27662 27663 if (!parts[0].length) { 27664 return false; 27665 } 27666 27667 if (options.all_lowercase || options.outlookdotcom_lowercase) { 27668 parts[0] = parts[0].toLowerCase(); 27669 } 27670 } else if (yahoo_domains.indexOf(parts[1]) >= 0) { 27671 // Address is Yahoo 27672 if (options.yahoo_remove_subaddress) { 27673 var components = parts[0].split('-'); 27674 parts[0] = components.length > 1 ? components.slice(0, -1).join('-') : components[0]; 27675 } 27676 27677 if (!parts[0].length) { 27678 return false; 27679 } 27680 27681 if (options.all_lowercase || options.yahoo_lowercase) { 27682 parts[0] = parts[0].toLowerCase(); 27683 } 27684 } else if (yandex_domains.indexOf(parts[1]) >= 0) { 27685 if (options.all_lowercase || options.yandex_lowercase) { 27686 parts[0] = parts[0].toLowerCase(); 27687 } 27688 27689 parts[1] = 'yandex.ru'; // all yandex domains are equal, 1st preferred 27690 } else if (options.all_lowercase) { 27691 // Any other address 27692 parts[0] = parts[0].toLowerCase(); 27693 } 27694 27695 return parts.join('@'); 27696 } 27697 27698 module.exports = exports.default; 27699 module.exports.default = exports.default; 27700 }); 27701 27702 var normalizeEmail = /*@__PURE__*/getDefaultExportFromCjs(normalizeEmail_1); 27703 27704 var isSlug_1 = createCommonjsModule(function (module, exports) { 27705 "use strict"; 27706 27707 Object.defineProperty(exports, "__esModule", { 27708 value: true 27709 }); 27710 exports.default = isSlug; 27711 27712 var _assertString = _interopRequireDefault(assertString_1); 27713 27714 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27715 27716 var charsetRegex = /^[^\s-_](?!.*?[-_]{2,})([a-z0-9-\\]{1,})[^\s]*[^-_\s]$/; 27717 27718 function isSlug(str) { 27719 (0, _assertString.default)(str); 27720 return charsetRegex.test(str); 27721 } 27722 27723 module.exports = exports.default; 27724 module.exports.default = exports.default; 27725 }); 27726 27727 var isSlug = /*@__PURE__*/getDefaultExportFromCjs(isSlug_1); 27728 27729 var isStrongPassword_1 = createCommonjsModule(function (module, exports) { 27730 "use strict"; 27731 27732 Object.defineProperty(exports, "__esModule", { 27733 value: true 27734 }); 27735 exports.default = isStrongPassword; 27736 27737 var _merge = _interopRequireDefault(merge_1); 27738 27739 var _assertString = _interopRequireDefault(assertString_1); 27740 27741 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27742 27743 var upperCaseRegex = /^[A-Z]$/; 27744 var lowerCaseRegex = /^[a-z]$/; 27745 var numberRegex = /^[0-9]$/; 27746 var symbolRegex = /^[-#!$%^&*()_+|~=`{}\[\]:";'<>?,.\/ ]$/; 27747 var defaultOptions = { 27748 minLength: 8, 27749 minLowercase: 1, 27750 minUppercase: 1, 27751 minNumbers: 1, 27752 minSymbols: 1, 27753 returnScore: false, 27754 pointsPerUnique: 1, 27755 pointsPerRepeat: 0.5, 27756 pointsForContainingLower: 10, 27757 pointsForContainingUpper: 10, 27758 pointsForContainingNumber: 10, 27759 pointsForContainingSymbol: 10 27760 }; 27761 /* Counts number of occurrences of each char in a string 27762 * could be moved to util/ ? 27763 */ 27764 27765 function countChars(str) { 27766 var result = {}; 27767 Array.from(str).forEach(function (char) { 27768 var curVal = result[char]; 27769 27770 if (curVal) { 27771 result[char] += 1; 27772 } else { 27773 result[char] = 1; 27774 } 27775 }); 27776 return result; 27777 } 27778 /* Return information about a password */ 27779 27780 27781 function analyzePassword(password) { 27782 var charMap = countChars(password);
27783 var analysis = { 27784 length: password.length, 27785 uniqueChars: Object.keys(charMap).length, 27786 uppercaseCount: 0, 27787 lowercaseCount: 0, 27788 numberCount: 0, 27789 symbolCount: 0 27790 }; 27791 Object.keys(charMap).forEach(function (char) { 27792 if (upperCaseRegex.test(char)) { 27793 analysis.uppercaseCount += charMap[char]; 27794 } else if (lowerCaseRegex.test(char)) { 27795 analysis.lowercaseCount += charMap[char]; 27796 } else if (numberRegex.test(char)) { 27797 analysis.numberCount += charMap[char]; 27798 } else if (symbolRegex.test(char)) { 27799 analysis.symbolCount += charMap[char]; 27800 } 27801 }); 27802 return analysis; 27803 } 27804 27805 function scorePassword(analysis, scoringOptions) { 27806 var points = 0; 27807 points += analysis.uniqueChars * scoringOptions.pointsPerUnique; 27808 points += (analysis.length - analysis.uniqueChars) * scoringOptions.pointsPerRepeat; 27809 27810 if (analysis.lowercaseCount > 0) { 27811 points += scoringOptions.pointsForContainingLower; 27812 } 27813 27814 if (analysis.uppercaseCount > 0) { 27815 points += scoringOptions.pointsForContainingUpper; 27816 } 27817 27818 if (analysis.numberCount > 0) { 27819 points += scoringOptions.pointsForContainingNumber; 27820 } 27821 27822 if (analysis.symbolCount > 0) { 27823 points += scoringOptions.pointsForContainingSymbol; 27824 } 27825 27826 return points; 27827 } 27828 27829 function isStrongPassword(str) { 27830 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; 27831 (0, _assertString.default)(str); 27832 var analysis = analyzePassword(str); 27833 options = (0, _merge.default)(options || {}, defaultOptions); 27834 27835 if (options.returnScore) { 27836 return scorePassword(analysis, options); 27837 } 27838 27839 return analysis.length >= options.minLength && analysis.lowercaseCount >= options.minLowercase && analysis.uppercaseCount >= options.minUppercase && analysis.numberCount >= options.minNumbers && analysis.symbolCount >= options.minSymbols; 27840 } 27841 27842 module.exports = exports.default; 27843 module.exports.default = exports.default; 27844 }); 27845 27846 var isStrongPassword = /*@__PURE__*/getDefaultExportFromCjs(isStrongPassword_1); 27847 27848 var isVAT_1 = createCommonjsModule(function (module, exports) { 27849 "use strict"; 27850 27851 Object.defineProperty(exports, "__esModule", { 27852 value: true 27853 }); 27854 exports.default = isVAT; 27855 exports.vatMatchers = void 0; 27856 27857 var _assertString = _interopRequireDefault(assertString_1); 27858 27859 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 27860 27861 var vatMatchers = { 27862 GB: /^GB((\d{3} \d{4} ([0-8][0-9]|9[0-6]))|(\d{9} \d{3})|(((GD[0-4])|(HA[5-9]))[0-9]{2}))$/ 27863 }; 27864 exports.vatMatchers = vatMatchers; 27865 27866 function isVAT(str, countryCode) { 27867 (0, _assertString.default)(str); 27868 (0, _assertString.default)(countryCode); 27869 27870 if (countryCode in vatMatchers) { 27871 return vatMatchers[countryCode].test(str); 27872 } 27873 27874 throw new Error("Invalid country code: '".concat(countryCode, "'")); 27875 } 27876 }); 27877 27878 var isVAT = /*@__PURE__*/getDefaultExportFromCjs(isVAT_1); 27879 27880 var validator_1 = createCommonjsModule(function (module, exports) { 27881 "use strict"; 27882 27883 function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 27884 27885 Object.defineProperty(exports, "__esModule", { 27886 value: true 27887 }); 27888 exports.default = void 0; 27889 27890 var _toDate = _interopRequireDefault(toDate_1); 27891 27892 var _toFloat = _interopRequireDefault(toFloat_1); 27893 27894 var _toInt = _interopRequireDefault(toInt_1); 27895
27896 var _toBoolean = _interopRequireDefault(toBoolean_1); 27897 27898 var _equals = _interopRequireDefault(equals_1); 27899 27900 var _contains = _interopRequireDefault(contains_1); 27901 27902 var _matches = _interopRequireDefault(matches_1); 27903 27904 var _isEmail = _interopRequireDefault(isEmail_1); 27905 27906 var _isURL = _interopRequireDefault(isURL_1); 27907 27908 var _isMACAddress = _interopRequireDefault(isMACAddress_1); 27909 27910 var _isIP = _interopRequireDefault(isIP_1); 27911 27912 var _isIPRange = _interopRequireDefault(isIPRange_1); 27913 27914 var _isFQDN = _interopRequireDefault(isFQDN_1); 27915 27916 var _isDate = _interopRequireDefault(isDate_1); 27917 27918 var _isBoolean = _interopRequireDefault(isBoolean_1); 27919 27920 var _isLocale = _interopRequireDefault(isLocale_1); 27921 27922 var _isAlpha = _interopRequireWildcard(isAlpha_1); 27923 27924 var _isAlphanumeric = _interopRequireWildcard(isAlphanumeric_1); 27925 27926 var _isNumeric = _interopRequireDefault(isNumeric_1); 27927 27928 var _isPassportNumber = _interopRequireDefault(isPassportNumber_1); 27929 27930 var _isPort = _interopRequireDefault(isPort_1); 27931 27932 var _isLowercase = _interopRequireDefault(isLowercase_1); 27933 27934 var _isUppercase = _interopRequireDefault(isUppercase_1); 27935 27936 var _isIMEI = _interopRequireDefault(isIMEI_1); 27937 27938 var _isAscii = _interopRequireDefault(isAscii_1); 27939 27940 var _isFullWidth = _interopRequireDefault(isFullWidth_1); 27941 27942 var _isHalfWidth = _interopRequireDefault(isHalfWidth_1); 27943 27944 var _isVariableWidth = _interopRequireDefault(isVariableWidth_1); 27945 27946 var _isMultibyte = _interopRequireDefault(isMultibyte_1); 27947 27948 var _isSemVer = _interopRequireDefault(isSemVer_1); 27949 27950 var _isSurrogatePair = _interopRequireDefault(isSurrogatePair_1); 27951 27952 var _isInt = _interopRequireDefault(isInt_1); 27953 27954 var _isFloat = _interopRequireWildcard(isFloat_1); 27955 27956 var _isDecimal = _interopRequireDefault(isDecimal_1); 27957 27958 var _isHexadecimal = _interopRequireDefault(isHexadecimal_1); 27959 27960 var _isOctal = _interopRequireDefault(isOctal_1); 27961 27962 var _isDivisibleBy = _interopRequireDefault(isDivisibleBy_1); 27963 27964 var _isHexColor = _interopRequireDefault(isHexColor_1); 27965 27966 var _isRgbColor = _interopRequireDefault(isRgbColor_1); 27967 27968 var _isHSL = _interopRequireDefault(isHSL_1); 27969 27970 var _isISRC = _interopRequireDefault(isISRC_1); 27971 27972 var _isIBAN = _interopRequireDefault(isIBAN_1); 27973 27974 var _isBIC = _interopRequireDefault(isBIC_1); 27975 27976 var _isMD = _interopRequireDefault(isMD5_1); 27977 27978 var _isHash = _interopRequireDefault(isHash_1); 27979 27980 var _isJWT = _interopRequireDefault(isJWT_1); 27981 27982 var _isJSON = _interopRequireDefault(isJSON_1); 27983 27984 var _isEmpty = _interopRequireDefault(isEmpty_1); 27985 27986 var _isLength = _interopRequireDefault(isLength_1); 27987 27988 var _isByteLength = _interopRequireDefault(isByteLength_1); 27989 27990 var _isUUID = _interopRequireDefault(isUUID_1); 27991 27992 var _isMongoId = _interopRequireDefault(isMongoId_1); 27993 27994 var _isAfter = _interopRequireDefault(isAfter_1); 27995 27996 var _isBefore = _interopRequireDefault(isBefore_1); 27997 27998 var _isIn = _interopRequireDefault(isIn_1); 27999 28000 var _isCreditCard = _interopRequireDefault(isCreditCard_1); 28001 28002 var _isIdentityCard = _interopRequireDefault(isIdentityCard_1); 28003 28004 var _isEAN = _interopRequireDefault(isEAN_1); 28005 28006 var _isISIN = _interopRequireDefault(isISIN_1); 28007 28008 var _isISBN = _interopRequireDefault(isISBN_1); 28009 28010 var _isISSN = _interopRequireDefault(isISSN_1); 28011 28012 var _isTaxID = _interopRequireDefault(isTaxID_1); 28013 28014 var _isMobilePhone = _interopRequireWildcard(isMobilePhone_1); 28015 28016 var _isEthereumAddress = _interopRequireDefault(isEthereumAddress_1); 28017 28018 var _isCurrency = _interopRequireDefault(isCurrency_1); 28019 28020 var _isBtcAddress = _interopRequireDefault(isBtcAddress_1); 28021 28022 var _isISO = _interopRequireDefault(isISO8601_1); 28023 28024 var _isRFC = _interopRequireDefault(isRFC3339_1); 28025 28026 var _isISO31661Alpha = _interopRequireDefault(isISO31661Alpha2_1); 28027 28028 var _isISO31661Alpha2 = _interopRequireDefault(isISO31661Alpha3_1); 28029 28030 var _isBase = _interopRequireDefault(isBase32_1); 28031 28032 var _isBase2 = _interopRequireDefault(isBase58_1); 28033 28034 var _isBase3 = _interopRequireDefault(isBase64_1); 28035 28036 var _isDataURI = _interopRequireDefault(isDataURI_1); 28037 28038 var _isMagnetURI = _interopRequireDefault(isMagnetURI_1); 28039 28040 var _isMimeType = _interopRequireDefault(isMimeType_1); 28041 28042 var _isLatLong = _interopRequireDefault(isLatLong_1); 28043 28044 var _isPostalCode = _interopRequireWildcard(isPostalCode_1); 28045 28046 var _ltrim = _interopRequireDefault(ltrim_1); 28047 28048 var _rtrim = _interopRequireDefault(rtrim_1); 28049 28050 var _trim = _interopRequireDefault(trim_1); 28051 28052 var _escape$1 = _interopRequireDefault(_escape); 28053 28054 var _unescape$1 = _interopRequireDefault(_unescape); 28055 28056 var _stripLow = _interopRequireDefault(stripLow_1); 28057 28058 var _whitelist = _interopRequireDefault(whitelist_1); 28059 28060 var _blacklist = _interopRequireDefault(blacklist_1); 28061 28062 var _isWhitelisted = _interopRequireDefault(isWhitelisted_1); 28063 28064 var _normalizeEmail = _interopRequireDefault(normalizeEmail_1); 28065 28066 var _isSlug = _interopRequireDefault(isSlug_1); 28067 28068 var _isStrongPassword = _interopRequireDefault(isStrongPassword_1); 28069 28070 var _isVAT = _interopRequireDefault(isVAT_1); 28071 28072 function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; } 28073 28074 function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
28074 if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } 28075 28076 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 28077 28078 var version = '13.5.2'; 28079 var validator = { 28080 version: version, 28081 toDate: _toDate.default, 28082 toFloat: _toFloat.default, 28083 toInt: _toInt.default, 28084 toBoolean: _toBoolean.default, 28085 equals: _equals.default, 28086 contains: _contains.default, 28087 matches: _matches.default, 28088 isEmail: _isEmail.default, 28089 isURL: _isURL.default, 28090 isMACAddress: _isMACAddress.default, 28091 isIP: _isIP.default, 28092 isIPRange: _isIPRange.default, 28093 isFQDN: _isFQDN.default, 28094 isBoolean: _isBoolean.default, 28095 isIBAN: _isIBAN.default, 28096 isBIC: _isBIC.default, 28097 isAlpha: _isAlpha.default, 28098 isAlphaLocales: _isAlpha.locales, 28099 isAlphanumeric: _isAlphanumeric.default, 28100 isAlphanumericLocales: _isAlphanumeric.locales, 28101 isNumeric: _isNumeric.default, 28102 isPassportNumber: _isPassportNumber.default, 28103 isPort: _isPort.default, 28104 isLowercase: _isLowercase.default, 28105 isUppercase: _isUppercase.default, 28106 isAscii: _isAscii.default, 28107 isFullWidth: _isFullWidth.default, 28108 isHalfWidth: _isHalfWidth.default, 28109 isVariableWidth: _isVariableWidth.default, 28110 isMultibyte: _isMultibyte.default, 28111 isSemVer: _isSemVer.default, 28112 isSurrogatePair: _isSurrogatePair.default, 28113 isInt: _isInt.default, 28114 isIMEI: _isIMEI.default, 28115 isFloat: _isFloat.default, 28116 isFloatLocales: _isFloat.locales, 28117 isDecimal: _isDecimal.default, 28118 isHexadecimal: _isHexadecimal.default, 28119 isOctal: _isOctal.default, 28120 isDivisibleBy: _isDivisibleBy.default, 28121 isHexColor: _isHexColor.default, 28122 isRgbColor: _isRgbColor.default, 28123 isHSL: _isHSL.default, 28124 isISRC: _isISRC.default, 28125 isMD5: _isMD.default, 28126 isHash: _isHash.default, 28127 isJWT: _isJWT.default, 28128 isJSON: _isJSON.default, 28129 isEmpty: _isEmpty.default, 28130 isLength: _isLength.default, 28131 isLocale: _isLocale.default, 28132 isByteLength: _isByteLength.default, 28133 isUUID: _isUUID.default, 28134 isMongoId: _isMongoId.default, 28135 isAfter: _isAfter.default, 28136 isBefore: _isBefore.default, 28137 isIn: _isIn.default, 28138 isCreditCard: _isCreditCard.default, 28139 isIdentityCard: _isIdentityCard.default, 28140 isEAN: _isEAN.default, 28141 isISIN: _isISIN.default, 28142 isISBN: _isISBN.default, 28143 isISSN: _isISSN.default, 28144 isMobilePhone: _isMobilePhone.default, 28145 isMobilePhoneLocales: _isMobilePhone.locales, 28146 isPostalCode: _isPostalCode.default, 28147 isPostalCodeLocales: _isPostalCode.locales, 28148 isEthereumAddress: _isEthereumAddress.default, 28149 isCurrency: _isCurrency.default, 28150 isBtcAddress: _isBtcAddress.default, 28151 isISO8601: _isISO.default, 28152 isRFC3339: _isRFC.default, 28153 isISO31661Alpha2: _isISO31661Alpha.default, 28154 isISO31661Alpha3: _isISO31661Alpha2.default, 28155 isBase32: _isBase.default, 28156 isBase58: _isBase2.default, 28157 isBase64: _isBase3.default, 28158 isDataURI: _isDataURI.default, 28159 isMagnetURI: _isMagnetURI.default, 28160 isMimeType: _isMimeType.default, 28161 isLatLong: _isLatLong.default, 28162 ltrim: _ltrim.default, 28163 rtrim: _rtrim.default, 28164 trim: _trim.default, 28165 escape: _escape$1.default, 28166 unescape: _unescape$1.default, 28167 stripLow: _stripLow.default, 28168 whitelist: _whitelist.default, 28169 blacklist: _blacklist.default, 28170 isWhitelisted: _isWhitelisted.default, 28171 normalizeEmail: _normalizeEmail.default, 28172 toString: toString, 28173 isSlug: _isSlug.default, 28174 isStrongPassword: _isStrongPassword.default, 28175 isTaxID: _isTaxID.default, 28176 isDate: _isDate.default, 28177 isVAT: _isVAT.default 28178 }; 28179 var _default = validator; 28180 exports.default = _default; 28181 module.exports = exports.default; 28182 module.exports.default = exports.default; 28183 }); 28184 28185 var Validator = /*@__PURE__*/getDefaultExportFromCjs(validator_1); 28186 28187 /** 28188 * A specialized version of `_.forEach` for arrays without support for 28189 * iteratee shorthands. 28190 * 28191 * @private 28192 * @param {Array} [array] The array to iterate over. 28193 * @param {Function} iteratee The function invoked per iteration. 28194 * @returns {Array} Returns `array`. 28195 */ 28196 function arrayEach(array, iteratee) { 28197 var index = -1, 28198 length = array == null ? 0 : array.length; 28199 28200 while (++index < length) { 28201 if (iteratee(array[index], index, array) === false) { 28202 break; 28203 } 28204 } 28205 return array; 28206 } 28207 28208 var _arrayEach = arrayEach; 28209 28210 var defineProperty = (function() { 28211 try { 28212 var func = _getNative(Object, 'defineProperty'); 28213 func({}, '', {}); 28214 return func; 28215 } catch (e) {} 28216 }()); 28217 28218 var _defineProperty = defineProperty; 28219 28220 /** 28221 * The base implementation of `assignValue` and `assignMergeValue` without 28222 * value checks. 28223 * 28224 * @private 28225 * @param {Object} object The object to modify. 28226 * @param {string} key The key of the property to assign. 28227 * @param {*} value The value to assign. 28228 */ 28229 function baseAssignValue(object, key, value) { 28230 if (key == '__proto__' && _defineProperty) { 28231 _defineProperty(object, key, { 28232 'configurable': true, 28233 'enumerable': true, 28234 'value': value, 28235 'writable': true 28236 }); 28237 } else { 28238 object[key] = value; 28239 } 28240 } 28241 28242 var _baseAssignValue = baseAssignValue; 28243 28244 /** Used for built-in method references. */ 28245 var objectProto$2 = Object.prototype; 28246 28247 /** Used to check objects for own properties. */ 28248 var hasOwnProperty$2 = objectProto$2.hasOwnProperty; 28249 28250 /** 28251 * Assigns `value` to `key` of `object` if the existing value is not equivalent 28252 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) 28253 * for equality comparisons. 28254 * 28255 * @private 28256 * @param {Object} object The object to modify. 28257 * @param {string} key The key of the property to assign. 28258 * @param {*} value The value to assign. 28259 */ 28260 function assignValue(object, key, value) { 28261 var objValue = object[key]; 28262 if (!(hasOwnProperty$2.call(object, key) && eq_1(objValue, value)) || 28263 (value === undefined && !(key in object))) { 28264 _baseAssignValue(object, key, value); 28265 } 28266 } 28267 28268 var _assignValue = assignValue; 28269 28270 /** 28271 * Copies properties of `source` to `object`. 28272 * 28273 * @private 28274 * @param {Object} source The object to copy properties from. 28275 * @param {Array} props The property identifiers to copy. 28276 * @param {Object} [object={}] The object to copy properties to. 28277 * @param {Function} [customizer] The function to customize copied values. 28278 * @returns {Object} Returns `object`. 28279 */ 28280 function copyObject(source, props, object, customizer) { 28281 var isNew = !object; 28282 object || (object = {}); 28283 28284 var index = -1, 28285 length = props.length; 28286 28287 while (++index < length) { 28288 var key = props[index]; 28289 28290 var newValue = customizer 28291 ? customizer(object[key], source[key], key, object, source) 28292 : undefined; 28293 28294 if (newValue === undefined) { 28295 newValue = source[key]; 28296 } 28297 if (isNew) { 28298 _baseAssignValue(object, key, newValue); 28299 } else { 28300 _assignValue(object, key, newValue); 28301 } 28302 } 28303 return object; 28304 } 28305 28306 var _copyObject = copyObject; 28307 28308 /** 28309 * The base implementation of `_.assign` without support for multiple sources 28310 * or `customizer` functions. 28311 * 28312 * @private 28313 * @param {Object} object The destination object. 28314 * @param {Object} source The source object. 28315 * @returns {Object} Returns `object`. 28316 */ 28317 function baseAssign(object, source) { 28318 return object && _copyObject(source, keys_1(source), object); 28319 } 28320 28321 var _baseAssign = baseAssign; 28322 28323 /** 28324 * This function is like 28325 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) 28326 * except that it includes inherited enumerable properties. 28327 * 28328 * @private 28329 * @param {Object} object The object to query. 28330 * @returns {Array} Returns the array of property names. 28331 */ 28332 function nativeKeysIn(object) { 28333 var result = []; 28334 if (object != null) { 28335 for (var key in Object(object)) { 28336 result.push(key); 28337 } 28338 } 28339 return result; 28340 } 28341 28342 var _nativeKeysIn = nativeKeysIn; 28343 28344 /** Used for built-in method references. */ 28345 var objectProto$1 = Object.prototype; 28346 28347 /** Used to check objects for own properties. */ 28348 var hasOwnProperty$1 = objectProto$1.hasOwnProperty; 28349 28350 /** 28351 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. 28352 * 28353 * @private 28354 * @param {Object} object The object to query. 28355 * @returns {Array} Returns the array of property names. 28356 */ 28357 function baseKeysIn(object) { 28358 if (!isObject_1(object)) { 28359 return _nativeKeysIn(object); 28360 } 28361 var isProto = _isPrototype(object), 28362 result = []; 28363 28364 for (var key in object) { 28365 if (!(key == 'constructor' && (isProto || !hasOwnProperty$1.call(object, key)))) { 28366 result.push(key); 28367 } 28368 } 28369 return result; 28370 } 28371 28372 var _baseKeysIn = baseKeysIn; 28373 28374 /** 28375 * Creates an array of the own and inherited enumerable property names of `object`. 28376 * 28377 * **Note:** Non-object values are coerced to objects. 28378 * 28379 * @static 28380 * @memberOf _ 28381 * @since 3.0.0 28382 * @category Object 28383 * @param {Object} object The object to query. 28384 * @returns {Array} Returns the array of property names. 28385 * @example 28386 * 28387 * function Foo() { 28388 * this.a = 1; 28389 * this.b = 2; 28390 * } 28391 * 28392 * Foo.prototype.c = 3; 28393 * 28394 * _.keysIn(new Foo); 28395 * // => ['a', 'b', 'c'] (iteration order is not guaranteed) 28396 */ 28397 function keysIn(object) { 28398 return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object); 28399 } 28400 28401 var keysIn_1 = keysIn; 28402 28403 /** 28404 * The base implementation of `_.assignIn` without support for multiple sources 28405 * or `customizer` functions. 28406 * 28407 * @private 28408 * @param {Object} object The destination object. 28409 * @param {Object} source The source object. 28410 * @returns {Object} Returns `object`. 28411 */ 28412 function baseAssignIn(object, source) { 28413 return object && _copyObject(source, keysIn_1(source), object); 28414 } 28415 28416 var _baseAssignIn = baseAssignIn; 28417 28418 var _cloneBuffer = createCommonjsModule(function (module, exports
vendor: 12,878 bytes, lines 28418-28882
28418) { 28419 /** Detect free variable `exports`. */ 28420 var freeExports = 'object' == 'object' && exports && !exports.nodeType && exports; 28421 28422 /** Detect free variable `module`. */ 28423 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module; 28424 28425 /** Detect the popular CommonJS extension `module.exports`. */ 28426 var moduleExports = freeModule && freeModule.exports === freeExports; 28427 28428 /** Built-in value references. */ 28429 var Buffer = moduleExports ? _root.Buffer : undefined, 28430 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined; 28431 28432 /** 28433 * Creates a clone of `buffer`. 28434 * 28435 * @private 28436 * @param {Buffer} buffer The buffer to clone. 28437 * @param {boolean} [isDeep] Specify a deep clone. 28438 * @returns {Buffer} Returns the cloned buffer. 28439 */ 28440 function cloneBuffer(buffer, isDeep) { 28441 if (isDeep) { 28442 return buffer.slice(); 28443 } 28444 var length = buffer.length, 28445 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length); 28446 28447 buffer.copy(result); 28448 return result; 28449 } 28450 28451 module.exports = cloneBuffer; 28452 }); 28453 28454 /** 28455 * Copies the values of `source` to `array`. 28456 * 28457 * @private 28458 * @param {Array} source The array to copy values from. 28459 * @param {Array} [array=[]] The array to copy values to. 28460 * @returns {Array} Returns `array`. 28461 */ 28462 function copyArray(source, array) { 28463 var index = -1, 28464 length = source.length; 28465 28466 array || (array = Array(length)); 28467 while (++index < length) { 28468 array[index] = source[index]; 28469 } 28470 return array; 28471 } 28472 28473 var _copyArray = copyArray; 28474 28475 /** 28476 * Copies own symbols of `source` to `object`. 28477 * 28478 * @private 28479 * @param {Object} source The object to copy symbols from. 28480 * @param {Object} [object={}] The object to copy symbols to. 28481 * @returns {Object} Returns `object`. 28482 */ 28483 function copySymbols(source, object) { 28484 return _copyObject(source, _getSymbols(source), object); 28485 } 28486 28487 var _copySymbols = copySymbols; 28488 28489 /** Built-in value references. */ 28490 var getPrototype = _overArg(Object.getPrototypeOf, Object); 28491 28492 var _getPrototype = getPrototype; 28493 28494 /* Built-in method references for those with the same name as other `lodash` methods. */ 28495 var nativeGetSymbols = Object.getOwnPropertySymbols; 28496 28497 /** 28498 * Creates an array of the own and inherited enumerable symbols of `object`. 28499 * 28500 * @private 28501 * @param {Object} object The object to query. 28502 * @returns {Array} Returns the array of symbols. 28503 */ 28504 var getSymbolsIn = !nativeGetSymbols ? stubArray_1 : function(object) { 28505 var result = []; 28506 while (object) { 28507 _arrayPush(result, _getSymbols(object)); 28508 object = _getPrototype(object); 28509 } 28510 return result; 28511 }; 28512 28513 var _getSymbolsIn = getSymbolsIn; 28514 28515 /** 28516 * Copies own and inherited symbols of `source` to `object`. 28517 * 28518 * @private 28519 * @param {Object} source The object to copy symbols from. 28520 * @param {Object} [object={}] The object to copy symbols to. 28521 * @returns {Object} Returns `object`. 28522 */ 28523 function copySymbolsIn(source, object) { 28524 return _copyObject(source, _getSymbolsIn(source), object); 28525 } 28526 28527 var _copySymbolsIn = copySymbolsIn; 28528 28529 /** 28530 * Creates an array of own and inherited enumerable property names and 28531 * symbols of `object`. 28532 * 28533 * @private 28534 * @param {Object} object The object to query. 28535 * @returns {Array} Returns the array of property names and symbols. 28536 */ 28537 function getAllKeysIn(object) { 28538 return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn); 28539 } 28540 28541 var _getAllKeysIn = getAllKeysIn; 28542 28543 /** Used for built-in method references. */ 28544 var objectProto = Object.prototype; 28545 28546 /** Used to check objects for own properties. */ 28547 var hasOwnProperty = objectProto.hasOwnProperty; 28548 28549 /** 28550 * Initializes an array clone. 28551 * 28552 * @private 28553 * @param {Array} array The array to clone. 28554 * @returns {Array} Returns the initialized clone. 28555 */ 28556 function initCloneArray(array) { 28557 var length = array.length, 28558 result = new array.constructor(length); 28559 28560 // Add properties assigned by `RegExp#exec`. 28561 if (length && typeof array[0] == 'string' && hasOwnProperty.call(array, 'index')) { 28562 result.index = array.index; 28563 result.input = array.input; 28564 } 28565 return result; 28566 } 28567 28568 var _initCloneArray = initCloneArray; 28569 28570 /** 28571 * Creates a clone of `arrayBuffer`. 28572 * 28573 * @private 28574 * @param {ArrayBuffer} arrayBuffer The array buffer to clone. 28575 * @returns {ArrayBuffer} Returns the cloned array buffer. 28576 */ 28577 function cloneArrayBuffer(arrayBuffer) { 28578 var result = new arrayBuffer.constructor(arrayBuffer.byteLength); 28579 new _Uint8Array(result).set(new _Uint8Array(arrayBuffer)); 28580 return result; 28581 } 28582 28583 var _cloneArrayBuffer = cloneArrayBuffer; 28584 28585 /** 28586 * Creates a clone of `dataView`. 28587 * 28588 * @private 28589 * @param {Object} dataView The data view to clone. 28590 * @param {boolean} [isDeep] Specify a deep clone. 28591 * @returns {Object} Returns the cloned data view. 28592 */ 28593 function cloneDataView(dataView, isDeep) { 28594 var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer; 28595 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength); 28596 } 28597 28598 var _cloneDataView = cloneDataView; 28599 28600 /** Used to match `RegExp` flags from their coerced string values. */ 28601 var reFlags = /\w*$/; 28602 28603 /** 28604 * Creates a clone of `regexp`. 28605 * 28606 * @private 28607 * @param {Object} regexp The regexp to clone. 28608 * @returns {Object} Returns the cloned regexp. 28609 */ 28610 function cloneRegExp(regexp) { 28611 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp)); 28612 result.lastIndex = regexp.lastIndex; 28613 return result; 28614 } 28615 28616 var _cloneRegExp = cloneRegExp; 28617 28618 /** Used to convert symbols to primitives and strings. */ 28619 var symbolProto = _Symbol ? _Symbol.prototype : undefined, 28620 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined; 28621 28622 /** 28623 * Creates a clone of the `symbol` object. 28624 * 28625 * @private 28626 * @param {Object} symbol The symbol object to clone. 28627 * @returns {Object} Returns the cloned symbol object. 28628 */ 28629 function cloneSymbol(symbol) { 28630 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {}; 28631 } 28632 28633 var _cloneSymbol = cloneSymbol; 28634 28635 /** 28636 * Creates a clone of `typedArray`. 28637 * 28638 * @private 28639 * @param {Object} typedArray The typed array to clone. 28640 * @param {boolean} [isDeep] Specify a deep clone. 28641 * @returns {Object} Returns the cloned typed array. 28642 */ 28643 function cloneTypedArray(typedArray, isDeep) { 28644 var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer; 28645 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length); 28646 } 28647 28648 var _cloneTypedArray = cloneTypedArray; 28649 28650 /** `Object#toString` result references. */ 28651 var boolTag$1 = '[object Boolean]', 28652 dateTag$1 = '[object Date]', 28653 mapTag$2 = '[object Map]', 28654 numberTag$1 = '[object Number]', 28655 regexpTag$1 = '[object RegExp]', 28656 setTag$2 = '[object Set]', 28657 stringTag$1 = '[object String]', 28658 symbolTag$1 = '[object Symbol]'; 28659 28660 var arrayBufferTag$1 = '[object ArrayBuffer]', 28661 dataViewTag$1 = '[object DataView]', 28662 float32Tag$1 = '[object Float32Array]', 28663 float64Tag$1 = '[object Float64Array]', 28664 int8Tag$1 = '[object Int8Array]', 28665 int16Tag$1 = '[object Int16Array]', 28666 int32Tag$1 = '[object Int32Array]', 28667 uint8Tag$1 = '[object Uint8Array]', 28668 uint8ClampedTag$1 = '[object Uint8ClampedArray]', 28669 uint16Tag$1 = '[object Uint16Array]', 28670 uint32Tag$1 = '[object Uint32Array]'; 28671 28672 /** 28673 * Initializes an object clone based on its `toStringTag`. 28674 * 28675 * **Note:** This function only supports cloning values with tags of 28676 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`. 28677 * 28678 * @private 28679 * @param {Object} object The object to clone. 28680 * @param {string} tag The `toStringTag` of the object to clone. 28681 * @param {boolean} [isDeep] Specify a deep clone. 28682 * @returns {Object} Returns the initialized clone. 28683 */ 28684 function initCloneByTag(object, tag, isDeep) { 28685 var Ctor = object.constructor; 28686 switch (tag) { 28687 case arrayBufferTag$1: 28688 return _cloneArrayBuffer(object); 28689 28690 case boolTag$1: 28691 case dateTag$1: 28692 return new Ctor(+object); 28693 28694 case dataViewTag$1: 28695 return _cloneDataView(object, isDeep); 28696 28697 case float32Tag$1: case float64Tag$1: 28698 case int8Tag$1: case int16Tag$1: case int32Tag$1: 28699 case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1: 28700 return _cloneTypedArray(object, isDeep); 28701 28702 case mapTag$2: 28703 return new Ctor; 28704 28705 case numberTag$1: 28706 case stringTag$1: 28707 return new Ctor(object); 28708 28709 case regexpTag$1: 28710 return _cloneRegExp(object); 28711 28712 case setTag$2: 28713 return new Ctor; 28714 28715 case symbolTag$1: 28716 return _cloneSymbol(object); 28717 } 28718 } 28719 28720 var _initCloneByTag = initCloneByTag; 28721 28722 /** Built-in value references. */ 28723 var objectCreate = Object.create; 28724 28725 /** 28726 * The base implementation of `_.create` without support for assigning 28727 * properties to the created object. 28728 * 28729 * @private 28730 * @param {Object} proto The object to inherit from. 28731 * @returns {Object} Returns the new object. 28732 */ 28733 var baseCreate = (function() { 28734 function object() {} 28735 return function(proto) { 28736 if (!isObject_1(proto)) { 28737 return {}; 28738 } 28739 if (objectCreate) { 28740 return objectCreate(proto); 28741 } 28742 object.prototype = proto; 28743 var result = new object; 28744 object.prototype = undefined; 28745 return result; 28746 }; 28747 }()); 28748 28749 var _baseCreate = baseCreate; 28750 28751 /** 28752 * Initializes an object clone. 28753 * 28754 * @private 28755 * @param {Object} object The object to clone. 28756 * @returns {Object} Returns the initialized clone. 28757 */ 28758 function initCloneObject(object) { 28759 return (typeof object.constructor == 'function' && !_isPrototype(object)) 28760 ? _baseCreate(_getPrototype(object)) 28761 : {}; 28762 } 28763 28764 var _initCloneObject = initCloneObject; 28765 28766 /** `Object#toString` result references. */ 28767 var mapTag$1 = '[object Map]'; 28768 28769 /** 28770 * The base implementation of `_.isMap` without Node.js optimizations. 28771 * 28772 * @private 28773 * @param {*} value The value to check. 28774 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 28775 */ 28776 function baseIsMap(value) { 28777 return isObjectLike_1(value) && _getTag(value) == mapTag$1; 28778 } 28779 28780 var _baseIsMap = baseIsMap; 28781 28782 /* Node.js helper references. */ 28783 var nodeIsMap = _nodeUtil && _nodeUtil.isMap; 28784 28785 /** 28786 * Checks if `value` is classified as a `Map` object. 28787 * 28788 * @static 28789 * @memberOf _ 28790 * @since 4.3.0 28791 * @category Lang 28792 * @param {*} value The value to check. 28793 * @returns {boolean} Returns `true` if `value` is a map, else `false`. 28794 * @example 28795 * 28796 * _.isMap(new Map); 28797 * // => true 28798 * 28799 * _.isMap(new WeakMap); 28800 * // => false 28801 */ 28802 var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap; 28803 28804 var isMap_1 = isMap; 28805 28806 /** `Object#toString` result references. */ 28807 var setTag$1 = '[object Set]'; 28808 28809 /** 28810 * The base implementation of `_.isSet` without Node.js optimizations. 28811 * 28812 * @private 28813 * @param {*} value The value to check. 28814 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 28815 */ 28816 function baseIsSet(value) { 28817 return isObjectLike_1(value) && _getTag(value) == setTag$1; 28818 } 28819 28820 var _baseIsSet = baseIsSet; 28821 28822 /* Node.js helper references. */ 28823 var nodeIsSet = _nodeUtil && _nodeUtil.isSet; 28824 28825 /** 28826 * Checks if `value` is classified as a `Set` object. 28827 * 28828 * @static 28829 * @memberOf _ 28830 * @since 4.3.0 28831 * @category Lang 28832 * @param {*} value The value to check. 28833 * @returns {boolean} Returns `true` if `value` is a set, else `false`. 28834 * @example 28835 * 28836 * _.isSet(new Set); 28837 * // => true 28838 * 28839 * _.isSet(new WeakSet); 28840 * // => false 28841 */ 28842 var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet; 28843 28844 var isSet_1 = isSet; 28845 28846 /** Used to compose bitmasks for cloning. */ 28847 var CLONE_DEEP_FLAG$1 = 1, 28848 CLONE_FLAT_FLAG = 2, 28849 CLONE_SYMBOLS_FLAG$1 = 4; 28850 28851 /** `Object#toString` result references. */ 28852 var argsTag = '[object Arguments]', 28853 arrayTag = '[object Array]', 28854 boolTag = '[object Boolean]', 28855 dateTag = '[object Date]', 28856 errorTag = '[object Error]', 28857 funcTag = '[object Function]', 28858 genTag = '[object GeneratorFunction]', 28859 mapTag = '[object Map]', 28860 numberTag = '[object Number]', 28861 objectTag = '[object Object]', 28862 regexpTag = '[object RegExp]', 28863 setTag = '[object Set]', 28864 stringTag = '[object String]', 28865 symbolTag = '[object Symbol]', 28866 weakMapTag = '[object WeakMap]'; 28867 28868 var arrayBufferTag = '[object ArrayBuffer]', 28869 dataViewTag = '[object DataView]', 28870 float32Tag = '[object Float32Array]', 28871 float64Tag = '[object Float64Array]', 28872 int8Tag = '[object Int8Array]', 28873 int16Tag = '[object Int16Array]', 28874 int32Tag = '[object Int32Array]', 28875 uint8Tag = '[object Uint8Array]', 28876 uint8ClampedTag = '[object Uint8ClampedArray]', 28877 uint16Tag = '[object Uint16Array]', 28878 uint32Tag = '[object Uint32Array]'; 28879 28880 /** Used to identify `toStringTag` values supported by `_.clone`. */ 28881 var cloneableTags = {}; 28882 cloneableTags[argsTag] = cloneableTags[arrayTag] =
vendor: 2,116 bytes, lines 28883-28941
28883 cloneableTags[arrayBufferTag] = cloneableTags[dataViewTag] = 28884 cloneableTags[boolTag] = cloneableTags[dateTag] = 28885 cloneableTags[float32Tag] = cloneableTags[float64Tag] = 28886 cloneableTags[int8Tag] = cloneableTags[int16Tag] = 28887 cloneableTags[int32Tag] = cloneableTags[mapTag] = 28888 cloneableTags[numberTag] = cloneableTags[objectTag] = 28889 cloneableTags[regexpTag] = cloneableTags[setTag] = 28890 cloneableTags[stringTag] = cloneableTags[symbolTag] = 28891 cloneableTags[uint8Tag] = cloneableTags[uint8ClampedTag] = 28892 cloneableTags[uint16Tag] = cloneableTags[uint32Tag] = true; 28893 cloneableTags[errorTag] = cloneableTags[funcTag] = 28894 cloneableTags[weakMapTag] = false; 28895 28896 /** 28897 * The base implementation of `_.clone` and `_.cloneDeep` which tracks 28898 * traversed objects. 28899 * 28900 * @private 28901 * @param {*} value The value to clone. 28902 * @param {boolean} bitmask The bitmask flags. 28903 * 1 - Deep clone 28904 * 2 - Flatten inherited properties 28905 * 4 - Clone symbols 28906 * @param {Function} [customizer] The function to customize cloning. 28907 * @param {string} [key] The key of `value`. 28908 * @param {Object} [object] The parent object of `value`. 28909 * @param {Object} [stack] Tracks traversed objects and their clone counterparts. 28910 * @returns {*} Returns the cloned value. 28911 */ 28912 function baseClone(value, bitmask, customizer, key, object, stack) { 28913 var result, 28914 isDeep = bitmask & CLONE_DEEP_FLAG$1, 28915 isFlat = bitmask & CLONE_FLAT_FLAG, 28916 isFull = bitmask & CLONE_SYMBOLS_FLAG$1; 28917 28918 if (customizer) { 28919 result = object ? customizer(value, key, object, stack) : customizer(value); 28920 } 28921 if (result !== undefined) { 28922 return result; 28923 } 28924 if (!isObject_1(value)) { 28925 return value; 28926 } 28927 var isArr = isArray_1(value); 28928 if (isArr) { 28929 result = _initCloneArray(value); 28930 if (!isDeep) { 28931 return _copyArray(value, result); 28932 } 28933 } else { 28934 var tag = _getTag(value), 28935 isFunc = tag == funcTag || tag == genTag; 28936 28937 if (isBuffer_1(value)) { 28938 return _cloneBuffer(value, isDeep); 28939 } 28940 if (tag == objectTag || tag == argsTag || (isFunc && !object)) { 28941 result = (isFlat || isFunc) ? {}
vendor: 6,887 bytes, lines 28941-29185
28941 : _initCloneObject(value); 28942 if (!isDeep) { 28943 return isFlat 28944 ? _copySymbolsIn(value, _baseAssignIn(result, value)) 28945 : _copySymbols(value, _baseAssign(result, value)); 28946 } 28947 } else { 28948 if (!cloneableTags[tag]) { 28949 return object ? value : {}; 28950 } 28951 result = _initCloneByTag(value, tag, isDeep); 28952 } 28953 } 28954 // Check for circular references and return its corresponding clone. 28955 stack || (stack = new _Stack); 28956 var stacked = stack.get(value); 28957 if (stacked) { 28958 return stacked; 28959 } 28960 stack.set(value, result); 28961 28962 if (isSet_1(value)) { 28963 value.forEach(function(subValue) { 28964 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack)); 28965 }); 28966 } else if (isMap_1(value)) { 28967 value.forEach(function(subValue, key) { 28968 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack)); 28969 }); 28970 } 28971 28972 var keysFunc = isFull 28973 ? (isFlat ? _getAllKeysIn : _getAllKeys) 28974 : (isFlat ? keysIn_1 : keys_1); 28975 28976 var props = isArr ? undefined : keysFunc(value); 28977 _arrayEach(props || value, function(subValue, key) { 28978 if (props) { 28979 key = subValue; 28980 subValue = value[key]; 28981 } 28982 // Recursively populate clone (susceptible to call stack limits). 28983 _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack)); 28984 }); 28985 return result; 28986 } 28987 28988 var _baseClone = baseClone; 28989 28990 /** Used to compose bitmasks for cloning. */ 28991 var CLONE_DEEP_FLAG = 1, 28992 CLONE_SYMBOLS_FLAG = 4; 28993 28994 /** 28995 * This method is like `_.clone` except that it recursively clones `value`. 28996 * 28997 * @static 28998 * @memberOf _ 28999 * @since 1.0.0 29000 * @category Lang 29001 * @param {*} value The value to recursively clone. 29002 * @returns {*} Returns the deep cloned value. 29003 * @see _.clone 29004 * @example 29005 * 29006 * var objects = [{ 'a': 1 }, { 'b': 2 }]; 29007 * 29008 * var deep = _.cloneDeep(objects); 29009 * console.log(deep[0] === objects[0]); 29010 * // => false 29011 */ 29012 function cloneDeep(value) { 29013 return _baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG); 29014 } 29015 29016 var cloneDeep_1 = cloneDeep; 29017 29018 /** 29019 * Creates a base function for methods like `_.forIn` and `_.forOwn`. 29020 * 29021 * @private 29022 * @param {boolean} [fromRight] Specify iterating from right to left. 29023 * @returns {Function} Returns the new base function. 29024 */ 29025 function createBaseFor(fromRight) { 29026 return function(object, iteratee, keysFunc) { 29027 var index = -1, 29028 iterable = Object(object), 29029 props = keysFunc(object), 29030 length = props.length; 29031 29032 while (length--) { 29033 var key = props[fromRight ? length : ++index]; 29034 if (iteratee(iterable[key], key, iterable) === false) { 29035 break; 29036 } 29037 } 29038 return object; 29039 }; 29040 } 29041 29042 var _createBaseFor = createBaseFor; 29043 29044 /** 29045 * The base implementation of `baseForOwn` which iterates over `object` 29046 * properties returned by `keysFunc` and invokes `iteratee` for each property. 29047 * Iteratee functions may exit iteration early by explicitly returning `false`. 29048 * 29049 * @private 29050 * @param {Object} object The object to iterate over. 29051 * @param {Function} iteratee The function invoked per iteration. 29052 * @param {Function} keysFunc The function to get the keys of `object`. 29053 * @returns {Object} Returns `object`. 29054 */ 29055 var baseFor = _createBaseFor(); 29056 29057 var _baseFor = baseFor; 29058 29059 /** 29060 * The base implementation of `_.forOwn` without support for iteratee shorthands. 29061 * 29062 * @private 29063 * @param {Object} object The object to iterate over. 29064 * @param {Function} iteratee The function invoked per iteration. 29065 * @returns {Object} Returns `object`. 29066 */ 29067 function baseForOwn(object, iteratee) { 29068 return object && _baseFor(object, iteratee, keys_1); 29069 } 29070 29071 var _baseForOwn = baseForOwn; 29072 29073 /** 29074 * Creates a `baseEach` or `baseEachRight` function. 29075 * 29076 * @private 29077 * @param {Function} eachFunc The function to iterate over a collection. 29078 * @param {boolean} [fromRight] Specify iterating from right to left. 29079 * @returns {Function} Returns the new base function. 29080 */ 29081 function createBaseEach(eachFunc, fromRight) { 29082 return function(collection, iteratee) { 29083 if (collection == null) { 29084 return collection; 29085 } 29086 if (!isArrayLike_1(collection)) { 29087 return eachFunc(collection, iteratee); 29088 } 29089 var length = collection.length, 29090 index = fromRight ? length : -1, 29091 iterable = Object(collection); 29092 29093 while ((fromRight ? index-- : ++index < length)) { 29094 if (iteratee(iterable[index], index, iterable) === false) { 29095 break; 29096 } 29097 } 29098 return collection; 29099 }; 29100 } 29101 29102 var _createBaseEach = createBaseEach; 29103 29104 /** 29105 * The base implementation of `_.forEach` without support for iteratee shorthands. 29106 * 29107 * @private 29108 * @param {Array|Object} collection The collection to iterate over. 29109 * @param {Function} iteratee The function invoked per iteration. 29110 * @returns {Array|Object} Returns `collection`. 29111 */ 29112 var baseEach = _createBaseEach(_baseForOwn); 29113 29114 var _baseEach = baseEach; 29115 29116 /** 29117 * This method returns the first argument it receives. 29118 * 29119 * @static 29120 * @since 0.1.0 29121 * @memberOf _ 29122 * @category Util 29123 * @param {*} value Any value. 29124 * @returns {*} Returns `value`. 29125 * @example 29126 * 29127 * var object = { 'a': 1 }; 29128 * 29129 * console.log(_.identity(object) === object); 29130 * // => true 29131 */ 29132 function identity(value) { 29133 return value; 29134 } 29135 29136 var identity_1 = identity; 29137 29138 /** 29139 * Casts `value` to `identity` if it's not a function. 29140 * 29141 * @private 29142 * @param {*} value The value to inspect. 29143 * @returns {Function} Returns cast function. 29144 */ 29145 function castFunction(value) { 29146 return typeof value == 'function' ? value : identity_1; 29147 } 29148 29149 var _castFunction = castFunction; 29150 29151 /** 29152 * Iterates over elements of `collection` and invokes `iteratee` for each element. 29153 * The iteratee is invoked with three arguments: (value, index|key, collection). 29154 * Iteratee functions may exit iteration early by explicitly returning `false`. 29155 * 29156 * **Note:** As with other "Collections" methods, objects with a "length" 29157 * property are iterated like arrays. To avoid this behavior use `_.forIn` 29158 * or `_.forOwn` for object iteration. 29159 * 29160 * @static 29161 * @memberOf _ 29162 * @since 0.1.0 29163 * @alias each 29164 * @category Collection 29165 * @param {Array|Object} collection The collection to iterate over. 29166 * @param {Function} [iteratee=_.identity] The function invoked per iteration. 29167 * @returns {Array|Object} Returns `collection`. 29168 * @see _.forEachRight 29169 * @example 29170 * 29171 * _.forEach([1, 2], function(value) { 29172 * console.log(value); 29173 * }); 29174 * // => Logs `1` then `2`. 29175 * 29176 * _.forEach({ 'a': 1, 'b': 2 }, function(value, key) { 29177 * console.log(key); 29178 * }); 29179 * // => Logs 'a' then 'b' (iteration order is not guaranteed). 29180 */ 29181 function forEach(collection, iteratee) { 29182 var func = isArray_1(collection) ? _arrayEach : _baseEach; 29183 return func(collection, _castFunction(iteratee)); 29184 } 29185
29186 var forEach_1 = forEach; 29187 29188 /** 29189 @PelagicCreatures/MolaMola 29190 29191 @author Michael Rhodes 29192 @license MIT 29193 Made in Barbados ð§ð§ Copyright © 2020-2021 Michael Rhodes 29194 **/ 29195 29196 const ExtendedValidator = cloneDeep_1(Validator); 29197 29198 const extensions = { 29199 extend (name, fn) { 29200 this[name] = fn; 29201 return this 29202 }, 29203 notEmpty (str) { 29204 return !str.match(/^[\s\t\r\n]*$/) 29205 }, 29206 len (str, min, max) { 29207 return this.isLength(str, min, max) 29208 }, 29209 isUrl (str) { 29210 return this.isURL(str) 29211 }, 29212 isIPv6 (str) { 29213 return this.isIP(str, 6) 29214 }, 29215 isIPv4 (str) { 29216 return this.isIP(str, 4) 29217 }, 29218 notIn (str, values) { 29219 return !this.isIn(str, values) 29220 }, 29221 regex (str, pattern, modifiers) { 29222 str += ''; 29223 if (Object.prototype.toString.call(pattern).slice(8, -1) !== 'RegExp') { 29224 pattern = new RegExp(pattern, modifiers); 29225 } 29226 return str.match(pattern) 29227 }, 29228 notRegex (str, pattern, modifiers) { 29229 return !this.regex(str, pattern, modifiers) 29230 }, 29231 isDecimal (str) { 29232 return str !== '' && !!str.match(/^(?:-?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][+-]?(?:[0-9]+))?$/) 29233 }, 29234 min (str, val) { 29235 const number = parseFloat(str); 29236 return isNaN(number) || number >= val 29237 }, 29238 max (str, val) { 29239 const number = parseFloat(str); 29240 return isNaN(number) || number <= val 29241 }, 29242 not (str, pattern, modifiers) { 29243 return this.notRegex(str, pattern, modifiers) 29244 }, 29245 contains (str, elem) { 29246 return !!elem && str.includes(elem) 29247 }, 29248 notContains (str, elem) { 29249 return !this.contains(str, elem) 29250 }, 29251 is (str, pattern, modifiers) { 29252 return this.regex(str, pattern, modifiers) 29253 }, 29254 notNull (str) { 29255 return str !== null && str !== undefined 29256 }, 29257 isPassword (str) { 29258 return this.notEmpty(str) && this.len(str, 8, 20) && this.is(str, '(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])', '') 29259 }, 29260 notHTML (str) { 29261 return !str.match(/<\s*[^>]*>(.*?)<\s*\/[^>]*>/) && !str.match(/<[^>]*>/) 29262 } 29263 }; 29264 29265 forEach_1(extensions, (extend, key) => { 29266 ExtendedValidator[key] = extend; 29267 }); 29268 29269 /* 29270 Normalize value from an input. 29271 returns an array of values for groups and <select multiple> 29272 */ 29273 const getRealVal = (element) => { 29274 let value = ''; 29275 29276 // collection of checkboxes or other inputs results in array of values 29277 if (element.getAttribute('data-group')) { 29278 const group = element.closest('.input-group').querySelectorAll(element.getAttribute('data-group')); 29279 const values = []; 29280 for (let i = 0; i < group.length; i++) { 29281 if (getRealVal(group[i])) { 29282 values.push(getRealVal(group[i])); 29283 } 29284 if (element.hasAttribute('multiple')) { 29285 value = values; 29286 } else { 29287 value = values.length ? values[0] : ''; 29288 } 29289 } 29290 } else { 29291 if (element.getAttribute('type') === 'checkbox' || element.getAttribute('type') === 'radio') { 29292 if (element.checked) { 29293 const v = element.getAttribute('value'); 29294 if (v) { 29295 value = v; 29296 } else { 29297 value = !!element.checked; 29298 } 29299 } 29300 } else if (element.tagName === 'SELECT') { 29301 const selected = element.querySelectorAll('option:checked'); 29302 const values = Array.from(selected).map(el => el.value); 29303 if (element.hasAttribute('multiple')) { 29304 value = Array.from(values); 29305 } else { 29306 value = values[0]; 29307 } 29308 } else { 29309 value = element.value; 29310 } 29311 } 29312 29313 return value 29314 }; 29315 29316 /** 29317 @PelagicCreatures/MolaMola 29318 29319 @author Michael Rhodes 29320 @license MIT 29321 Made in Barbados ð§ð§ Copyright © 2020-2021 Michael Rhodes 29322 **/ 29323 29324 const validationMessages = { 29325 isLength: 'Length between %s and %s', 29326 isEmail: 'Email address', 29327 notEmpty: 'Required', 29328 isPassword: 'At least one uppercase, one lowercase, and one number' 29329 }; 29330 29331 class ValidateHelper extends MolaMolaHelper { 29332 constructor (form) { 29333 super(form); 29334 29335 this.valid = false; 29336 this.submitter = this.form.element.querySelector(this.form.element.getAttribute('data-submitter')); 29337 this.uniqueDebounce = null; 29338 this.lookupDebounce = null; 29339 29340 this.inputs = Array.from(this.form.element.querySelectorAll('[data-validate]')); 29341 29342 this.changeHandler = debounce_1((e) => { 29343 this.handleChange(e); 29344 }, 500); 29345 29346 this.initInput(this.form.element); 29347 if (this.form.element.querySelector('[data-autofocus="true"]')) { 29348 this.form.element.querySelector('[data-autofocus="true"]').focus(); 29349 } 29350 29351 this.allInputs = Array.from(this.form.element.querySelectorAll('input, select, textarea, button')); 29352 for (let i = 0; i < this.allInputs.length; i++) { 29353 const input = this.allInputs[i]; 29354 input.addEventListener('blur', this.changeHandler, true); 29355 input.addEventListener('focus', this.changeHandler, true); 29356 input.addEventListener('keyup', this.changeHandler, true); 29357 input.addEventListener('input', this.changeHandler, true); 29358 input.addEventListener('change', this.changeHandler, true); 29359 } 29360 29361 this.handleChange(); 29362 } 29363 29364 destroy () { 29365 for (let i = 0; i < this.allInputs.length; i++) { 29366 const input = this.allInputs[i]; 29367 input.removeEventListener('blur', this.changeHandler); 29368 input.removeEventListener('focus', this.changeHandler); 29369 input.removeEventListener('keyup', this.changeHandler); 29370 input.removeEventListener('input', this.changeHandler); 29371 input.removeEventListener('change', this.changeHandler); 29372 } 29373 } 29374 29375 initInput (element) { 29376 for (let i = 0; i < this.inputs.length; i++) { 29377 const input = this.inputs[i]; 29378 input.setAttribute('data-touched', false); 29379 input.setAttribute('data-last-value', getRealVal(input).toString()); 29380 if (input.getAttribute('checked')) { 29381 input.checked = true; 29382 } 29383 } 29384 } 29385 29386 handleChange (e) { 29387 if (e && e.srcElement && e.srcElement !== window) { 29388 const elem = e.srcElement; 29389 utils$1.elementTools.addClass(elem.closest('form'), 'touched'); 29390 const isDirty = elem.getAttribute('data-last-value') !== getRealVal(elem); 29391 elem.setAttribute('data-touched', true); 29392 elem.setAttribute('data-dirty', isDirty); 29393 } 29394 const errors = this.inputs.map(this.validateField.bind(this)); 29395 Promise.all(errors).then((errors) => { 29396 let errorCount = 0; 29397 for (let i = 0; i < errors.length; i++) { 29398 if (errors[i] && errors[i].length) { 29399 errorCount += errors[i].length; 29400 } 29401 } 29402 29403 if (errorCount) { 29404 this.valid = false;
29405 this.disableSubmit(); 29406 } else { 29407 this.valid = true; 29408 this.enableSubmit(); 29409 } 29410 }); 29411 } 29412 29413 getMessage (test, opts, overrideMessage) { 29414 let message = overrideMessage || validationMessages[test]; 29415 if (!message) { // build a message 29416 message = test; 29417 if (opts) { 29418 if (Array.isArray[opts]) { 29419 for (let i = 0; i < opts.length; i++) { 29420 message += ' %s'; 29421 } 29422 } 29423 } 29424 } 29425 if (!opts) { 29426 return message 29427 } 29428 29429 if (!Array.isArray(opts)) { 29430 const tmp = []; 29431 for (const prop in opts) { 29432 tmp.push(opts[prop]); 29433 } 29434 opts = tmp; 29435 } 29436 29437 let c = 0; 29438 return message.replace(/%s/g, function () { 29439 const opt = opts[c++]; 29440 return opt ? opt.toString() : '' 29441 }) 29442 } 29443 29444 validateField (element) { 29445 return new Promise((resolve, reject) => { 29446 const val = getRealVal(element).toString(); 29447 let validations = {}; 29448 let validationMessage = {}; 29449 let errors = []; 29450 29451 try { 29452 validations = JSON.parse(element.getAttribute('data-validate') || '{}'); 29453 validationMessage = JSON.parse(element.getAttribute('data-validate-message') || '{}'); 29454 } catch (e) { 29455 errors = ['data-validation attribute parse error']; 29456 } 29457 29458 if (!validations.notEmpty && !val && !errors.length) { 29459 return resolve() 29460 } 29461 29462 for (const test in validations) { 29463 const opts = validations[test]; 29464 if (typeof opts === 'boolean') { 29465 if (!ExtendedValidator[test](val)) { 29466 errors.push(this.getMessage(test, undefined, validationMessage[test])); 29467 } 29468 } else if (Array.isArray(opts)) { 29469 const myopts = opts.slice(); 29470 myopts.unshift(val); 29471 if (!ExtendedValidator[test].apply(ExtendedValidator, myopts)) { 29472 errors.push(this.getMessage(test, opts, validationMessage[test])); 29473 } 29474 } else { 29475 if (!ExtendedValidator[test](val, opts)) { 29476 errors.push(this.getMessage(test, opts, validationMessage[test])); 29477 } 29478 } 29479 } 29480 29481 const matchSelector = element.getAttribute('data-match'); 29482 if (matchSelector && getRealVal(this.form.element.querySelector(matchSelector)).toString() !== getRealVal(element).toString()) { 29483 errors.push('Does not match'); 29484 } 29485 29486 if (!element.getAttribute('data-lookup-endpoint')) { 29487 this.showErrors(element, errors); 29488 return resolve(errors) 29489 } 29490 29491 if (val.length > 2 && !errors.length) { 29492 // show last error if unchanged 29493 if (element.getAttribute('data-last-lookup-val') === val) { 29494 if (element.getAttribute('data-last-lookup-result')) { 29495 errors.push(element.getAttribute('data-last-lookup-result')); 29496 } 29497 this.showErrors(element, errors); 29498 return resolve(errors) 29499 } else { 29500 element.setAttribute('data-last-lookup-val', val); 29501 this.lookup(element.getAttribute('data-lookup-endpoint'), val, element.hasAttribute('data-unique')) 29502 .then((e) => { 29503 if (e) { 29504 element.setAttribute('data-last-lookup-result', e); 29505 errors.push(e); 29506 } else { 29507 element.removeAttribute('data-last-lookup-result'); 29508 } 29509 this.showErrors(element, errors); 29510 return resolve(errors) 29511 }); 29512 } 29513 } 29514 }) 29515 } 29516 29517 showErrors (element, errors) { 29518 const inputGroup = element.closest('.input-group'); 29519 if (inputGroup) { 29520 if (errors.length) { 29521 utils$1.elementTools.removeClass(inputGroup, 'input-ok'); 29522 utils$1.elementTools.addClass(inputGroup, 'error'); 29523 inputGroup.getElementsByClassName('validation-help')[0].innerHTML = errors.join(', '); 29524 } else { 29525 utils$1.elementTools.removeClass(inputGroup, 'error'); 29526 utils$1.elementTools.addClass(inputGroup, 'input-ok'); 29527 inputGroup.getElementsByClassName('validation-help')[0].innerHTML = ''; 29528 } 29529 } 29530 } 29531 29532 lookup (endpoint, val, unique) { 29533 return new Promise((resolve, reject) => { 29534 const options = { 29535 method: 'POST', 29536 dataType: 'json', 29537 headers: { 29538 'Content-Type': 'application/json' 29539 }, 29540 body: JSON.stringify({ 29541 value: val 29542 }) 29543 };
29544 try { 29545 fetch(endpoint, options) 29546 .then((response) => { 29547 if (response.status !== 200) { 29548 const e = new Error(response.statusText); 29549 e.errorCode = response.status; 29550 return Promise.reject(e) 29551 } 29552 return Promise.resolve(response) 29553 }) 29554 .then((response) => { 29555 return response.json() 29556 }) 29557 .then((data) => { 29558 let e = null; 29559 if (unique) { 29560 e = data.found ? 'Already exists' : null; 29561 } else { 29562 e = !data.found ? 'Not Found' : null; 29563 } 29564 resolve(e); 29565 }) 29566 .catch((err, response) => { 29567 resolve('error checking unique ' + err.message); 29568 }); 29569 } catch (err) { 29570 resolve('error checking unique' + err.message); 29571 } 29572 }) 29573 } 29574 29575 preFlight () {} 29576 29577 disableSubmit () { 29578 this.submitter.setAttribute('disabled', true); 29579 } 29580 29581 enableSubmit () { 29582 this.submitter.removeAttribute('disabled'); 29583 } 29584 } 29585 29586 registerHelperClass('ValidateHelper', ValidateHelper); 29587 29588 /** 29589 @PelagicCreatures/MolaMola 29590 29591 @author Michael Rhodes 29592 @license MIT 29593 Made in Barbados ð§ð§ Copyright © 2020-2021 Michael Rhodes 29594 **/ 29595 29596 class MolaMola extends Sargasso { 29597 constructor (elem, options) { 29598 super(elem, options); 29599 29600 this.formId = this.element.getAttribute('id'); 29601 this.endpoint = this.element.getAttribute('action'); 29602 this.method = this.element.getAttribute('method') || 'POST'; 29603 this.formHandlers = []; 29604 29605 if (this.element.getAttribute('data-helpers')) { 29606 const helperClasses = this.element.getAttribute('data-helpers').split(/\s*,\s*/); 29607 for (let i = 0; i < helperClasses.length; i++) { 29608 try { 29609 this.registerHelper(registeredHelperClasses[helperClasses[i]]); 29610 } catch (e) { 29611 console.log('error instantiating ' + helperClasses[i], e, registeredHelperClasses); 29612 } 29613 } 29614 } 29615 if (this.element.getAttribute('data-recaptcha')) { 29616 this.registerHelper(ReCAPTCHAv3Helper); 29617 } 29618 29619 if (this.element.getAttribute('data-submitter')) { 29620 this.registerHelper(SubmitterHelper); 29621 } 29622 29623 if (this.element.getAttribute('data-status')) { 29624 this.registerHelper(StatusHelper); 29625 } 29626 29627 if (this.element.querySelectorAll('[data-validate]').length) { 29628 this.registerHelper(ValidateHelper); 29629 } 29630 } 29631 29632 start () { 29633 super.start(); 29634 29635 this.submitHandler = (e) => { 29636 e.preventDefault(); 29637 29638 this.serializeForm(); 29639 29640 Promise.all(this.tellHelpers('preFlight')).then(() => { 29641 this.submit(); 29642 }).catch((err) => { 29643 this.tellHelpers('error', [err]); 29644 }); 29645 }; 29646 29647 this.element.addEventListener('submit', this.submitHandler); 29648 29649 this.tellHelpers('pose'); 29650 } 29651 29652 registerHelper (HelperClass) { 29653 this.formHandlers.push(new HelperClass(this)); 29654 } 29655 29656 getHelpersForEvent (event, params) { 29657 const handlers = []; 29658 for (let i = 0; i < this.formHandlers.length; i++) { 29659 if (this.formHandlers[i][event]) { 29660 const p = this.formHandlers[i][event].apply(this.formHandlers[i], params); 29661 handlers.push(p); 29662 } 29663 } 29664 return handlers 29665 } 29666 29667 serializeForm () { 29668 this.payload = {}; 29669 const elements = this.element.querySelectorAll('[data-payload]'); 29670 for (let i = 0; i < elements.length; i++) { 29671 const element = elements[i]; 29672 const k = element.getAttribute('name'); 29673 if (k) { // must be named 29674 const v = getRealVal(element); 29675 this.payload[k] = v; 29676 } 29677 } 29678 } 29679 29680 submit () { 29681 let url = this.endpoint; 29682 29683 const options = { 29684 method: this.method, 29685 dataType: 'json', 29686 headers: { 29687 'Content-Type': 'application/json' 29688 } 29689 }; 29690 29691 if (this.payload) { 29692 if (this.method.match(/^(POST|PUT|PATCH)$/i)) { 29693 options.body = JSON.stringify(this.payload); 29694 } else { 29695 url += '?' + Object.keys(this.payload).map((key) => { 29696 return encodeURIComponent(key) + '=' + encodeURIComponent(this.payload[key]) 29697 }).join('&'); 29698 } 29699 } 29700 29701 try { 29702 fetch(url, options) 29703 .then((response) => { 29704 if (response.status !== 200 && response.status !== 422) { 29705 const e = new Error(response.statusText); 29706 e.errorCode = response.status; 29707 return Promise.reject(e) 29708 } 29709 return Promise.resolve(response) 29710 }) 29711 .then((response) => { 29712 return response.json() 29713 }) 29714 .then((data) => { 29715 this.tellHelpers('success', [data]); 29716 }) 29717 .catch((error, response) => { 29718 this.tellHelpers('error', [error]); 29719 }); 29720 } catch (err) { 29721 this.tellHelpers('error', [err]); 29722 } 29723 } 29724 29725 sleep () { 29726 this.tellHelpers('destroy'); 29727 this.element.removeEventListener('submit', this.submitHandler); 29728 super.sleep(); 29729 } 29730 29731 tellHelpers (event, params) { 29732 return this.getHelpersForEvent(event, params) 29733 } 29734 } 29735 29736 utils$1.registerSargassoClass('MolaMola', MolaMola); 29737 29738 /** 29739 @PelagicCreatures/MolaMola 29740 29741 @author Michael Rhodes 29742 @license MIT 29743 Made in Barbados ð§ð§ Copyright © 2020-2021 Michael Rhodes 29744 29745 Form ID: an application unique identifier for the form EG: 'login', 'register' 29746 29747 <form 29748 id="login" 29749 method="GET" 29750 action="/endpoint" 29751 data-sargasso-class="MolaMola" 29752 data-helpers="MyForm" 29753 data-submitter=".submit-button" 29754 data-status=".status"> 29755 </form> 29756 29757 Form helpers are used for handling form events. 29758 29759 The following events can be handled by the handlers: 29760 29761 class MyForm extends MolaMolaHelper { 29762 success (response) {}, 29763 error (statusCode, response) {} 29764 } 29765 registerFormHandler('MyForm',MyForm) 29766 29767 the API for the endpoint: 29768 200 (ok) & 422 (unprocessable entity) are expected to return json 29769 Use 422 for server side validation errors, the reponse payload is 29770 up to implementor and should be handled with a helper success method. 29771 29772 Other http errors such as 401 (unauthorized) are handed to the helper 29773 error method 29774 */ 29775 29776 const molaMolaUtils = { 29777 registerHelperClass: registerHelperClass, 29778 ReCAPTCHAv3Helper: ReCAPTCHAv3Helper, 29779 SubmitterHelper: SubmitterHelper, 29780 StatusHelper: StatusHelper, 29781 ValidateHelper: ValidateHelper 29782 }; 29783 29784 let loadPage, reloadPage, tropicBird; 29785 29786 const bootCMS = () => { 29787 tropicBird = new TropicBird(document.body, {}); 29788 tropicBird.start(); 29789 29790 loadPage = (url) => { 29791 loadPageHandler(url); 29792 }; 29793 29794 reloadPage = () => { 29795 loadPageHandler(document.location.href, true); 29796 }; 29797 29798 if (js_cookie.get('have-account')) { 29799 utils$1.elementTools.addClass(document.body, 'have-account'); 29800 } else { 29801 utils$1.elementTools.addClass(document.body, 'dont-have-account'); 29802 } 29803 29804 // Set initial login state css show/hide behavior 29805 if (js_cookie.get('logged-in')) { 29806 didLogIn(); 29807 } else { 29808 didLogOut(); 29809 } 29810 29811 window.setTimeout(function () { 29812 utils$1.elementTools.addClass(document.querySelector('#splash'), 'animate__animated'); 29813 utils$1.elementTools.addClass(document.querySelector('#splash'), 'animate__fadeOut'); 29814 }, 500); 29815 29816 utils$1.elementTools.on('notifications-button', document.body, 'click', '.show-notifications-button', (e) => { 29817 if (utils$1.elementTools.hasClass(e.target, 'highlight')) { 29818 utils$1.elementTools.removeClass(e.target, 'highlight'); 29819 utils$1.elementTools.removeClass(document.querySelector('#user-alerts'), 'open'); 29820 } else { 29821 utils$1.elementTools.addClass(e.target, 'highlight'); 29822 utils$1.elementTools.addClass(document.querySelector('#user-alerts'), 'open'); 29823 } 29824 }); 29825 }; 29826 29827 // call whenever login occurs 29828 function didLogIn () { 29829 checkSubscription(); 29830 js_cookie.set('have-account', 1, cookieOptions); 29831 flashAjaxStatus('success', 'Logged in'); 29832 utils$1.elementTools.removeClass(document.body, 'is-logged-out'); 29833 utils$1.elementTools.addClass(document.body, 'is-logged-in'); 29834 utils$1.elementTools.addClass(document.body, 'have-account'); 29835 } 29836 29837 // call whenever logout occurs 29838 const didLogOut = () => { 29839 checkSubscription(); 29840 if (js_cookie.get('have-account')) { 29841 flashAjaxStatus('success', 'Logged out'); 29842 } 29843 utils$1.elementTools.removeClass(document.body, 'is-logged-in'); 29844 utils$1.elementTools.addClass(document.body, 'is-logged-out'); 29845 js_cookie.remove('access_token', cookieOptions); 29846 }; 29847 29848 const checkSubscription = () => { 29849 if (js_cookie.get('subscriber')) { 29850 utils$1.elementTools.removeClass(document.body, 'not-subscriber'); 29851 utils$1.elementTools.addClass(document.body, 'is-subscriber'); 29852 } else { 29853 utils$1.elementTools.removeClass(document.body, 'is-subscriber'); 29854 utils$1.elementTools.addClass(document.body, 'not-subscriber'); 29855 } 29856 29857 if (js_cookie.get('admin')) { 29858 utils$1.elementTools.removeClass(document.body, 'not-admin'); 29859 utils$1.elementTools.addClass(document.body, 'is-admin'); 29860 } else { 29861 utils$1.elementTools.removeClass(document.body, 'is-admin'); 29862 utils$1.elementTools.addClass(document.body, 'not-admin'); 29863 } 29864 29865 if (js_cookie.get('superuser')) { 29866 utils$1.elementTools.removeClass(document.body, 'not-superuser'); 29867 utils$1.elementTools.addClass(document.body, 'is-superuser'); 29868 } else { 29869 utils$1.elementTools.removeClass(document.body, 'is-superuser'); 29870 utils$1.elementTools.addClass(document.body, 'not-superuser'); 29871 } 29872 }; 29873 29874 // call to show the Material Design "snackbar" for user notifications 29875 const flashAjaxStatus = (level, message) => { 29876 tropicBird.pushSnackBar(level, message); 29877 }; 29878 29879 var utils = { 29880 __proto__: null, 29881 bootCMS: bootCMS, 29882 didLogIn: didLogIn, 29883 didLogOut: didLogOut, 29884 checkSubscription: checkSubscription, 29885 flashAjaxStatus: flashAjaxStatus, 29886 get loadPage () { return loadPage; }, 29887 get reloadPage () { return reloadPage; }, 29888 get tropicBird () { return tropicBird; } 29889 }; 29890 29891 class InstallPWA extends Sargasso { 29892 constructor (element, options) { 29893 super(element, options); 29894 29895 this.deferredPrompt = null; 29896 } 29897 29898 start () { 29899 super.start(); 29900 this.handler = (e) => { 29901 this.setup(e); 29902 }; 29903 window.addEventListener('beforeinstallprompt', this.handler); 29904 } 29905 29906 setup (deferredPrompt) { 29907 this.addClass('shown'); 29908 this.deferredPrompt = deferredPrompt; 29909 29910 this.clickHandler = (e) => { 29911 this.deferredPrompt.prompt(); 29912 this.deferredPrompt.userChoice 29913 .then((choiceResult) => { 29914 if (choiceResult.outcome === 'accepted') { 29915 flashAjaxStatus('info', 'App Installed'); 29916 this.removeClass('shown'); 29917 } else { 29918 flashAjaxStatus('info', 'Cancelled'); 29919 } 29920 this.deferredPrompt = null; 29921 }); 29922 }; 29923 this.element.addEventListener('click', this.clickHandler); 29924 } 29925 29926 sleep () { 29927 window.removeEventListener('beforeinstallprompt', this.handler); 29928 if (this.clickHandler) { 29929 this.element.removeEventListener('click', this.clickHandler); 29930 } 29931 super.sleep(); 29932 } 29933 } 29934 29935 utils$1.registerSargassoClass('InstallPWA', InstallPWA); 29936 29937 const saveSubscription = async subscription => { 29938 const response = await fetch('/notifications/subscribe', { 29939 method: 'post', 29940 headers: { 29941 'Content-Type': 'application/json' 29942 }, 29943 body: JSON.stringify(subscription) 29944 }); 29945 29946 const res = await response.json(); 29947 29948 return res 29949 }; 29950 29951 class NotificationsSubscribe extends Sargasso { 29952 constructor (element, options) { 29953 super(element, options); 29954 this.notificationService = null; 29955 29956 this.enabled = false;
29957 } 29958 29959 start () { 29960 super.start(); 29961 if ('serviceWorker' in navigator) { 29962 navigator.serviceWorker.ready.then(async (reg) => { 29963 if (reg && reg.pushManager) { 29964 if (window.Notification.permission !== 'granted' && window.Notification.permission !== 'denied') { 29965 await this.setup(reg); 29966 } 29967 } 29968 }); 29969 } 29970 } 29971 29972 setup (reg) { 29973 this.addClass('shown'); 29974 this.clickHandler = async (e) => { 29975 const permission = await window.Notification.requestPermission(); 29976 if (permission === 'granted') { 29977 reg.pushManager.subscribe({ 29978 userVisibleOnly: true, 29979 applicationServerKey: publicOptions.NOTIFICATIONS_PK 29980 }).then((sub) => { 29981 try { 29982 saveSubscription(sub).then((response) => { 29983 console.log(response); 29984 flashAjaxStatus('info', 'Notifications Enabled'); 29985 }).catch((err) => { 29986 console.log(err); 29987 flashAjaxStatus('info', 'Could not save subscription'); 29988 }); 29989 } catch (err) { 29990 console.log(err); 29991 flashAjaxStatus('info', 'Could not Subscribe'); 29992 } 29993 }); 29994 } else { 29995 flashAjaxStatus('info', 'Notifications Disabled'); 29996 } 29997 }; 29998 this.element.addEventListener('click', this.clickHandler); 29999 } 30000 30001 sleep () { 30002 if (this.clickHandler) { 30003 this.element.removeEventListener('click', this.clickHandler); 30004 } 30005 super.sleep(); 30006 } 30007 } 30008 30009 utils$1.registerSargassoClass('NotificationsSubscribe', NotificationsSubscribe); 30010 30011 class ajaxButton extends Sargasso { 30012 constructor (elem, options) { 30013 super(elem, options); 30014 30015 this.endpoint = this.element.getAttribute('data-endpoint'); 30016 this.redirect = this.element.getAttribute('data-redirect') ? this.element.getAttribute('data-redirect') : '/users/home'; 30017 this.method = this.element.getAttribute('data-method') ? this.element.getAttribute('data-method') : 'POST'; 30018 this.confirm = this.element.getAttribute('data-confirm') ? this.element.getAttribute('data-confirm') : false; 30019 this.confirmPrompt = this.element.getAttribute('data-confirm-prompt') ? this.element.getAttribute('data-confirm-prompt') : 'Are you sure?'; 30020 } 30021 30022 start () { 30023 super.start(); 30024 this.on('click', '', async (e) => { 30025 e.preventDefault(); 30026 if (this.confirm) { 30027 tropicBird.dialog('#confirm-dialog', 'Please Confirm', this.confirmPrompt, true).then(async (action) => { 30028 if (action === 'accept') { 30029 await this.doIt(); 30030 } 30031 }); 30032 } else { 30033 await this.doIt(); 30034 } 30035 }); 30036 }; 30037 30038 sleep () { 30039 this.off('click', ''); 30040 super.sleep(); 30041 }; 30042 30043 async doIt () { 30044 try { 30045 const response = await fetch(this.endpoint, { 30046 method: this.method, 30047 headers: { 30048 'Content-Type': 'application/json', 30049 'Sargasso-Hijax': 'true' 30050 } 30051 }); 30052 30053 const data = await response.json(); 30054 const flashLevel = response.headers['Sargasso-Flash-Level'] ? response.headers['Sargasso-Flash-Level'] : data.flashLevel; 30055 const flashMessage = response.headers['Sargasso-Flash-Message'] ? response.headers['Sargasso-Flash-Message'] : data.flashMessage; 30056 const loggedIn = response.headers['Sargasso-Did-Login'] ? response.headers['Sargasso-Did-Login'] : data.didLogin; 30057 const loggedOut = response.headers['Sargasso-Did-Logout'] ? response.headers['Sargasso-Did-Logout'] : data.didLogout; 30058 30059 if (loggedIn) { 30060 didLogIn(); 30061 } 30062 30063 if (loggedOut) { 30064 didLogOut(); 30065 } 30066 30067 if (data.status === 'ok') { 30068 flashAjaxStatus('success', flashMessage); 30069 if (this.redirect === location.pathname) { 30070 reloadPage(); 30071 } else { 30072 loadPage(this.redirect); 30073 } 30074 } else { 30075 flashAjaxStatus(flashLevel, flashMessage); 30076 } 30077 } catch (e) { 30078 const message = 'error'; 30079 flashAjaxStatus('error', message); 30080 } 30081 } 30082 } 30083 30084 utils$1.registerSargassoClass('ajaxButton', ajaxButton); 30085 30086 class paginationController extends Sargasso { 30087 constructor (elem, options) { 30088 super(elem, options); 30089 } 30090 30091 start () { 30092 let index; 30093 const pages = this.element.querySelector('.pagination-page'); 30094 const selipsis = this.element.querySelector('.pagination-elipsis-start'); 30095 const eelipsis = this.element.querySelector('.pagination-elipsis-end'); 30096 if (pages.length > 9) { 30097 for (let i = 0; i < pages.length; i++) { 30098 if (utils$1.elementTools.hasClass(pages[i], 'active')) { 30099 index = i; 30100 } 30101 } 30102 let start = index - 4; 30103 let end = index + 4; 30104 30105 if (start < 0) { 30106 end = -start + end; 30107 start = 0; 30108 } 30109 if (end > pages.length) { 30110 start = start + pages.length - end; 30111 end = pages.length; 30112 } 30113 for (let i = 0; i < pages.length; i++) { 30114 if (i < start || i > end) { 30115 pages[i].remove(); 30116 } 30117 } 30118 if (start === 0) { 30119 selipsis.remove(); 30120 } 30121 if (end + 2 > pages.length) { 30122 eelipsis.remove(); 30123 } 30124 } else { 30125 selipsis.remove(); 30126 eelipsis.remove(); 30127 } 30128 }; 30129 } 30130 30131 utils$1.registerSargassoClass('paginationController', paginationController); 30132 30133 class adminController extends Sargasso { 30134 constructor (elem, options) { 30135 super(elem, options); 30136 this.mountpoint = this.element.getAttribute('data-mountpoint'); 30137 this.model = this.element.getAttribute('data-model'); 30138 this.id = this.element.getAttribute('data-id'); 30139 this.redirect = this.element.getAttribute('data-redirect'); 30140 } 30141 30142 start () { 30143 super.start(); 30144 30145 this.on('click', '.add-button', (e, elem) => { 30146 e.preventDefault(); 30147 const target = elem.getAttribute('data-target'); 30148 if (target) { 30149 const belongsTo = elem.getAttribute('data-belongs-to'); 30150 const fk = elem.getAttribute('data-fk'); 30151 loadPage(this.mountpoint + '/' + target + '/create?fk=' + fk + '&belongs-to=' + belongsTo); 30152 } else { 30153 loadPage(this.mountpoint + '/' + this.model + '/create'); 30154 } 30155 }); 30156 30157 this.on('click', '.edit-button', (e, elem) => { 30158 e.preventDefault(); 30159 loadPage(this.mountpoint + '/' + this.model + '/' + this.id + '/edit'); 30160 }); 30161 30162 this.on('click', '.delete-button', (e, elem) => { 30163 e.preventDefault(); 30164 tropicBird.dialog('#confirm-dialog', 'Delete this row?', this.confirmPrompt, true).then((action) => { 30165 if (action === 'accept') { 30166 const endpoint = this.mountpoint + '/' + this.model + '/' + this.id; 30167 this.API('DELETE', endpoint); 30168 } 30169 }); 30170 }); 30171 30172 this.on('click', '.search-button', (e, elem) => { 30173 e.preventDefault(); 30174 const q = elem.closest('.input-group').find('input[name="q"]').val(); 30175 const prop = elem.closest('.input-group').find('select[name="property"]').val(); 30176 if (q && prop) { 30177 loadPage(location.pathname + '?q=' + encodeURIComponent(q) + '&property=' + encodeURIComponent(prop)); 30178 } 30179 }); 30180 30181 this.on('mouseover', '.select-row', (e, elem) => { 30182 utils$1.elementTools.addClass(elem, 'hovering'); 30183 }); 30184 30185 this.on('mouseout', '.select-row', (e, elem) => { 30186 utils$1.elementTools.removeClass(elem, 'hovering'); 30187 }); 30188 30189 this.on('click', '.select-row', (e, elem) => { 30190 e.preventDefault(); 30191 var id = parseInt(elem.getAttribute('data-row')); 30192 loadPage(this.mountpoint + '/' + this.model + '/' + id); 30193 }); 30194 } 30195 30196 sleep () { 30197 this.off('click', '.flextable-row'); 30198 this.off('click', '.add-button'); 30199 this.off('click', '.edit-button'); 30200 this.off('click', '.delete-button'); 30201 this.off('click', '.search-button'); 30202 this.off('mouseover', '.select-row'); 30203 this.off('mouseout', '.select-row'); 30204 this.off('click', '.select-row'); 30205 super.sleep(); 30206 } 30207 30208 API (method, endpoint, data) { 30209 fetch(endpoint, { 30210 method: method, 30211 body: JSON.stringify(data), 30212 headers: { 30213 'Content-Type': 'application/json', 30214 'Sargasso-Hijax': 'true' 30215 } 30216 }).then((response) => { 30217 return response.json() 30218 }).then((data) => { 30219 var flashLevel = data.flashLevel; 30220 var flashMessage = data.flashMessage; 30221 if (data.status === 'ok') { 30222 flashAjaxStatus('success', flashMessage); 30223 let redir = this.redirect; 30224 if (data.id && !redir.match(/\/\d+$/)) { 30225 redir += '/' + data.id; 30226 } 30227 loadPage(redir); 30228 } else { 30229 let message; 30230 if (data.errors) { 30231 for (var i = 0; i < data.errors.length; i++) { 30232 if (message) { 30233 message += ', '; 30234 } 30235 message += data.errors[i]; 30236 } 30237 } else { 30238 message = data.status; 30239 } 30240 this.element.querySelector('.ajax-errors').innerHTML = '<div class="ajax-message ajax-message-' + flashLevel + '"><i class="material-icons">info</i> ' + flashMessage + '</div>'; 30241 } 30242 }).catch((e) => { 30243 var message = 'error'; 30244 this.element.querySelector('.ajax-errors').innerHTML = '<div class="ajax-message ajax-message-error"><i class="material-icons">error</i> ' + message + '</div>'; 30245 }); 30246 } 30247 } 30248 30249 utils$1.registerSargassoClass('adminController', adminController); 30250 30251 class uploadableImage extends Sargasso { 30252 constructor (elem, options) { 30253 super(elem, options); 30254 this.columnName = this.element.getAttribute('data-column-name'); 30255 this.maxHeight = this.element.getAttribute('data-max-height') ? this.element.getAttribute('data-max-height') : 200; 30256 this.maxWidth = this.element.getAttribute('data-max-width') ? this.element.getAttribute('data-max-width') : 200; 30257 this.sendResized = this.element.getAttribute('data-send-resized') === 'true'; 30258 this.input = document.querySelector(this.element.getAttribute('data-target')); 30259 30260 this.previewElement = document.querySelector('[data-name="' + this.columnName + '-preview"]'); 30261 this.widthElement = document.querySelector('[data-name="' + this.columnName + '-width"]'); 30262 this.heightElement = document.querySelector('[data-name="' + this.columnName + '-height"]'); 30263 this.metadata = this.element.closest('.input-group').querySelector('.metadata'); 30264 } 30265 30266 start () { 30267 super.start(); 30268 this.on('change', '', (e) => { 30269 this.processImage(e.target.files[0]); 30270 }); 30271 }; 30272 30273 sleep () { 30274 this.off('change', ''); 30275 super.sleep(); 30276 }; 30277 30278 processImage (file) { 30279 const reader = new FileReader(); 30280 30281 // make a thumbnail once data is loaded 30282 reader.onload = (readerEvent) => { 30283 const image = new Image(); 30284 image.onload = (imageEvent) => { 30285 const canvas = document.createElement('canvas'); 30286 let w = image.width; 30287 let h = image.height; 30288 if (w > h) { 30289 if (w > this.maxWidth) { 30290 h *= this.maxWidth / w; 30291 w = this.maxWidth; 30292 } 30293 } else { 30294 if (h > this.maxHeight) { 30295 w *= this.maxHeight / h; 30296 h = this.maxHeight; 30297 } 30298 } 30299 canvas.width = w; 30300 canvas.height = h; 30301 canvas.getContext('2d').drawImage(image, 0, 0, w, h); 30302 const dataURL = canvas.toDataURL('image/jpeg', 1.0); 30303 this.previewElement.innerHTML = '<img src="' + dataURL + '">'; 30304 this.metadata.innerHTML = '<strong><em>New image</em></strong> w: <strong>
30304' + image.naturalWidth + '</strong> h: <strong>' + image.naturalHeight + '</strong>'; 30305 30306 if (this.sendResized) { 30307 this.input.value = dataURL; 30308 this.widthElement.value = w; 30309 this.heightElement.value = h; 30310 } else { 30311 this.widthElement.value = image.naturalWidth; 30312 this.heightElement.value = image.naturalHeight; 30313 } 30314 }; 30315 30316 // pipe the file data into the image 30317 image.src = readerEvent.target.result; 30318 30319 if (!this.sendResized) { 30320 this.input.value = readerEvent.target.result; 30321 } 30322 }; 30323 30324 // start reading the file 30325 reader.readAsDataURL(file); 30326 } 30327 } 30328 30329 utils$1.registerSargassoClass('uploadableImage', uploadableImage); 30330 30331 class AdminHandler extends MolaMolaHelper { 30332 pose () { 30333 this.chipHandler = function (e) { 30334 if (e.target === this) { 30335 const selected = []; 30336 const sel = this.closest('.mdc-chip-set').querySelectorAll('.mdc-chip--selected'); 30337 Array.from(sel).forEach(function (chip) { 30338 selected.push(chip.getAttribute('data-id')); 30339 }); 30340 this.closest('.mdc-chip-set').querySelector('input').value = selected.join(','); 30341 } 30342 }; 30343 30344 const chips = this.form.element.getElementsByClassName('mdc-chip'); 30345 Array.from(chips).forEach((chip) => { 30346 chip.addEventListener('MDCChip:selection', this.chipHandler, false); 30347 }); 30348 } 30349 30350 preFlight () { 30351 // special case - always send checkbox value for boolean switch 30352 const checkboxes = this.form.element.getElementsByClassName('mdc-switch__native-control'); 30353 for (let i = 0; i < checkboxes.length; i++) { 30354 const cb = checkboxes[i]; 30355 this.form.payload[cb.getAttribute('name')] = !!cb.checked; // sets data.table.column to true or false 30356 } 30357 30358 const json = {}; 30359 for (const k in this.form.payload) { 30360 const tableColumn = k.match(/^([^\[]+)\[([^\]]+)\]/); 30361 if (!tableColumn) { 30362 json[k] = this.form.payload[k]; 30363 } else { 30364 if (!json[tableColumn[1]]) { 30365 json[tableColumn[1]] = {}; 30366 } 30367 json[tableColumn[1]][tableColumn[2]] = this.form.payload[k]; 30368 } 30369 } 30370 this.form.payload = json; 30371 } 30372 30373 destroy () { 30374 const chips = this.form.element.getElementsByClassName('mdc-chip'); 30375 Array.from(chips).forEach((chip) => { 30376 chip.removeEventListener('MDCChip:selection', this.chipHandler); 30377 }); 30378 super.destroy(); 30379 } 30380 } 30381 30382 molaMolaUtils.registerHelperClass('AdminHandler', AdminHandler); 30383 30384 class BoilerplateHandler extends MolaMolaHelper { 30385 // TODO MDC TextInput floating label borked on autofill, revisit once they fix it 30386 pose () { 30387 setTimeout(() => { 30388 const borked = document.querySelectorAll('input:-webkit-autofill'); 30389 if (borked && borked.length) { 30390 Array.from(borked).forEach((element) => { 30391 const mdcElement = element.closest('.mdc-text-field'); 30392 if (mdcElement) { 30393 const textField = utils$1.elementTools.getMetaData(mdcElement, 'MDCTextField'); 30394 if (textField) { 30395 textField.getLabelAdapterMethods_().floatLabel(true); 30396 } 30397 } 30398 }); 30399 } 30400 }, 500); 30401 } 30402 30403 preFlight () { 30404 const json = {}; 30405 for (const k in this.form.payload) { 30406 const tableColumn = k.match(/^([^\[]+)\[([^\]]+)\]/); 30407 if (!tableColumn) { 30408 json[k] = this.form.payload[k]; 30409 } else { 30410 if (!json[tableColumn[1]]) { 30411 json[tableColumn[1]] = {}; 30412 } 30413 json[tableColumn[1]][tableColumn[2]] = this.form.payload[k]; 30414 } 30415 } 30416 this.form.payload = json; 30417 } 30418 30419 success (data) { 30420 if (data.didLogin) { 30421 didLogIn(); 30422 if (!data.redirect) { 30423 data.redirect = '/users/home'; 30424 } 30425 } 30426 if (data.didLogout) { 30427 didLogOut(); 30428 if (!data.redirect) { 30429 data.redirect = '/users/login'; 30430 } 30431 } 30432 if (data.message) { 30433 tropicBird.pushSnackBar('info', data.message); 30434 } 30435 if (data.errors) { 30436 for (let i = 0; i < data.errors.length; i++) { 30437 tropicBird.pushSnackBar(data['error-level'] || 'info', data.errors[i]); 30438 } 30439 } 30440 30441 if (!data.redirect && this.form.element.getAttribute('data-redirect')) { 30442 data.redirect = this.form.element.getAttribute('data-redirect'); 30443 } 30444 30445 if (data.status === 'ok' && data.redirect) { 30446 loadPage(data.redirect); 30447 } 30448 } 30449 30450 error (err) { 30451 tropicBird.pushSnackBar('error', err.message); 30452 } 30453 } 30454 30455 molaMolaUtils.registerHelperClass('BoilerplateHandler', BoilerplateHandler); 30456 30457 /* 30458 Import modules here as needed. 30459 30460 Exports here are exposed on the global namespace as 'App' by webpack. 30461 30462 EG. 30463 App.CMSUtils 30464 30465 */ 30466 30467 // expose these so huge markdown editor can be dynamically loaded 30468 window.Sargasso = Sargasso; 30469 window.registerSargassoClass = utils$1.registerSargassoClass; 30470 window.elementTools = utils$1.elementTools; 30471 30472 class AnalyticsReport extends Sargasso { 30473 constructor (elem, options) { 30474 super(elem, options); 30475 this.endpoint = this.element.getAttribute('data-endpoint'); 30476 } 30477 30478 start () { 30479 super.start(); 30480 this.load(); 30481 } 30482 30483 sleep () { 30484 30485 } 30486 30487 async load () { 30488 const payload = {}; 30489 30490 try { 30491 const request = await fetch(this.endpoint, { 30492 method: 'POST', 30493 dataType: 'json', 30494 contentType: 'application/json', 30495 data: JSON.stringify(payload) 30496 }); 30497 30498 const data = await response.json(); 30499 this.jqElement.html('<pre>' + JSON.stringify(data, '', 2) + '</pre>'); 30500 } catch (e) { 30501 flashAjaxStatus('error', e.message || 'error'); 30502 } 30503 } 30504 } 30505 30506 utils$1.registerSargassoClass('AnalyticsReport', AnalyticsReport); 30507 30508 const cache = {}; 30509 30510 // TODO web worker thing not working.... revisit when Vibrant is updated 30511 30512 class VibrantController extends Sargasso { 30513 start () { 30514 super.start(); 30515 if (cache[this.element.getAttribute('data-image')]) { 30516 setTimeout(() => { 30517 this.setColors(cache[this.element.getAttribute('data-image')]); 30518 }, 255); 30519 return 30520 } 30521 30522 // var vibrant = new Vibrant(this.element.getAttribute('data-image')) 30523 30524 window.Vibrant 30525 .from(this.element.getAttribute('data-image')) 30526 .getPalette() 30527 .then((palette) => { 30528 cache[this.element.getAttribute('data-image')] = palette; 30529 this.setColors(palette); 30530 }) 30531 .catch((err) => { 30532 console.log(err); 30533 }); 30534 } 30535 30536 setColors (swatches) { 30537 const top = swatches.Muted ? swatches.Muted.getHex() : '#eee'; 30538 const bottom = swatches.DarkMuted ? swatches.DarkMuted.getHex() : '#ccc'; 30539 30540 const title = swatches.Muted.getTitleTextColor() || '#eee'; 30541 const text = swatches.Muted.getBodyTextColor() || '#eee'; 30542
30543 let styles = '.vibrant {color:' + text + '!important;}\n'; 30544 styles += '.vibrant-bg .vibrant-typography { color:' + text + '!important;}\n'; 30545 styles += '.vibrant-bg .vibrant-typography a{color:' + title + '!important;}\n'; 30546 styles += '.vibrant-bg .vibrant-typography a:hover{color:' + title + '!important;}\n'; 30547 styles += '.vibrant-bg .vibrant-typography a:visited{color:' + title + ';}\n'; 30548 styles += '.vibrant-bg .vibrant-typography .secondary{color:' + text + '!important;}\n'; 30549 styles += '.vibrant-bg { transition-property: background;transition-duration: .25s;transition-timing-function: ease; background: linear-gradient(to bottom right,' + top + ',' + bottom + ')};\n'; 30550 styles += '.vibrant-border { border-color:' + bottom + '!important};\n'; 30551 30552 utils$1.elementTools.setCSS(document.getElementById('overscroll-wrapper') || document.body, { 30553 background: 'linear-gradient(to bottom right,' + top + ',' + bottom + ')' 30554 }); 30555 30556 const frame = () => { 30557 document.getElementById('override-styles').textContent = styles; 30558 }; 30559 this.queueFrame(frame); 30560 } 30561 30562 sleep () { 30563 const frame = () => { 30564 document.getElementById('override-styles').textContent = ''; 30565 }; 30566 30567 utils$1.elementTools.setCSS(document.getElementById('overscroll-wrapper') || document.body, { 30568 background: 'linear-gradient(to bottom right, #ffdead, #fff3e0)' 30569 }); 30570 30571 this.queueFrame(frame); 30572 30573 super.sleep(); 30574 } 30575 } 30576 30577 utils$1.registerSargassoClass('VibrantController', VibrantController); 30578 30579 class selectGooglePhotos extends Sargasso { 30580 constructor (elem, options) { 30581 super(elem, options); 30582 } 30583 30584 start () { 30585 super.start(); 30586 30587 this.on('click', 'img', (e, element) => { 30588 utils$1.elementTools.setCSS(element, { 30589 opacity: 0.5 30590 }); 30591 const id = element.getAttribute('id'); 30592 const sel = JSON.parse(this.element.querySelector('textarea').value || '[]'); 30593 if (sel.indexOf(id) !== -1) { 30594 sel.splice(sel.indexOf(id), 1); 30595 } else { 30596 sel.push(id); 30597 } 30598 this.element.querySelector('textarea').value = JSON.stringify(sel); 30599 }); 30600 } 30601 30602 sleep () { 30603 this.off('click', 'img'); 30604 super.sleep(); 30605 } 30606 } 30607 30608 utils$1.registerSargassoClass('selectGooglePhotos', selectGooglePhotos); 30609 30610 class slideShow extends Sargasso { 30611 constructor (elem, options = {}) { 30612 options.watchOrientation = true; 30613 super(elem, options); 30614 this.currentIndex = -1; 30615 this.slides = this.element.getElementsByClassName('slide'); 30616 this.fullScreen = false; 30617 this.napping = true; 30618 } 30619 30620 start () { 30621 super.start(); 30622 30623 utils$1.elementTools.on('slideshow-launch-handler', document.body, 'click', '.launch-slides', (e, element) => { 30624 const index = element.getAttribute('data-index'); 30625 this.showSlideIndex(index); 30626 this.toggleFullscreen(); 30627 }); 30628 30629 utils$1.elementTools.on('slideshow-fullscreenchange', document, 'fullscreenchange', (e) => { 30630 if (this.fullScreen && !document.fullscreenElement) { 30631 this.toggleFullscreen(); 30632 } 30633 }); 30634 } 30635 30636 wakeup () { 30637 // console.log('wakeup', this.napping) 30638 if (this.napping) { 30639 this.napping = false; 30640 this.on('click', '.immersive-icon', () => { 30641 this.toggleFullscreen(); 30642 }); 30643 30644 if ('ontouchstart' in document.documentElement) { 30645 this.addClass('has-touch'); 30646 this.on('touchstart', this.touchHandler.bind(this)); 30647 this.on('touchmove', this.touchMoveHandler.bind(this)); 30648 this.on('touchend', this.touchEndHandler.bind(this)); 30649 this.on('touchcancel', this.touchCancelHandler.bind(this)); 30650 } else { 30651 this.addClass('no-touch'); 30652 30653 utils$1.elementTools.on('slideshow-prev-next', document, 'keydown', (e) => { 30654 if (e.keyCode === 37) { 30655 this.showSlide(-1); 30656 } 30657 if (e.keyCode === 39) { 30658 this.showSlide(1); 30659 } 30660 }); 30661 30662 this.on('click', '.slide', (e) => { 30663 const w = this.element.clientWidth; 30664 const offset = this.element.offsetLeft; 30665 const x = e.pageX - offset; 30666 let delta = 1; 30667 if (w / 2 > x) { 30668 delta = -1; 30669 } 30670 30671 let newIndex = this.currentIndex + delta; 30672 if (newIndex > this.slides.length - 1) { 30673 newIndex = 0; 30674 } 30675 if (newIndex < 0) { 30676 newIndex = this.slides.length - 1; 30677 } 30678 30679 this.showSlideIndex(newIndex + 1); 30680 }); 30681 } 30682 } 30683 } 30684 30685 nap () { 30686 // console.log('nap', this.napping) 30687 if (!this.napping) { 30688 this.napping = true; 30689 if (this.currentIndex !== -1) { 30690 utils$1.elementTools.removeClass(this.slides[this.currentIndex], 'in'); 30691 utils$1.elementTools.addClass(this.slides[this.currentIndex], 'out'); 30692 this.currentIndex = -1; 30693 } 30694 30695 utils$1.elementTools.off('slideshow-prev-next', document, 'keydown'); 30696 elementTools.offAll(this.element); 30697 } 30698 } 30699 30700 sleep () { 30701 this.nap(); 30702 utils$1.elementTools.off('slideshow-launch-handler', document.body, 'click', '.launch-slides'); 30703 utils$1.elementTools.off('slideshow-fullscreenchange', document, 'fullscreenchange'); 30704 super.sleep(); 30705 } 30706 30707 enterFullscreen () { 30708 if (!this.fullScreen) { 30709 if (this.currentIndex === -1) { 30710 this.showSlideIndex(1); 30711 } 30712 30713 this.toggleFullscreen(); 30714 } 30715 } 30716 30717 exitFullscreen () { 30718 if (this.fullScreen) { 30719 this.toggleFullscreen(); 30720 } 30721 } 30722 30723 toggleFullscreen () { 30724 if (!this.fullScreen) { 30725 this.wakeup(); 30726 this.fullScreen = true; 30727 utils$1.elementTools.addClass(document.body, 'fullscreen'); 30728 utils$1.elementTools.on('slideshow-fullscreen-keydown', document, 'keydown', (e) => { 30729 if (e.keyCode === 27) { 30730 this.toggleFullscreen(); 30731 } 30732 }); 30733 if (this.element.requestFullscreen) { 30734 this.element.requestFullscreen().then(() => {}).catch(err => {}); 30735 } 30736 } else { 30737 this.fullScreen = false;
30738 utils$1.elementTools.off('slideshow-fullscreen-keydown', document, 'keydown'); 30739 utils$1.elementTools.removeClass(document.body, 'fullscreen'); 30740 if (document.fullscreenElement) { 30741 document.exitFullscreen(); 30742 } 30743 this.nap(); 30744 } 30745 } 30746 30747 touchMoveHandler (event) { 30748 // console.log('touchmove', this.touching) 30749 30750 if (this.touching) { 30751 event.preventDefault(); 30752 30753 this.deltaX = event.touches[0].pageX - this.startX; 30754 30755 let peek = null; 30756 if (this.deltaX > 0) { 30757 peek = this.slides[this.currentIndex > 0 ? this.currentIndex - 1 : this.slides.length - 1]; 30758 } else { 30759 peek = this.slides[this.currentIndex < this.slides.length - 1 ? this.currentIndex + 1 : 0]; 30760 } 30761 if (peek && peek !== this.peek) { 30762 this.peek = peek; 30763 utils$1.elementTools.removeClass(this.peek, 'out'); 30764 utils$1.elementTools.addClass(this.peek, 'in'); 30765 const lazyBackground = this.peek.children[0]; 30766 lazyBackground.dispatchEvent(new CustomEvent('sargasso', { 30767 detail: { 30768 sargassoEvent: 'enterViewport' 30769 } 30770 })); 30771 } 30772 if (this.peek) { 30773 let peekLeft = 0; 30774 if (this.deltaX < 0) { 30775 peekLeft = ((parseInt(this.deltaX) || 0) + this.slideWidth) + 'px'; 30776 } else { 30777 peekLeft = ((parseInt(this.deltaX) || 0) - this.slideWidth) + 'px'; 30778 } 30779 // this.peek.querySelector('.slide-img').style.marginLeft = peekLeft 30780 30781 this.peek.style.marginLeft = peekLeft; 30782 } 30783 // this.slides[this.currentIndex].querySelector('.slide-img').style.marginLeft = (parseInt(this.deltaX) || 0) + 'px' 30784 30785 this.slides[this.currentIndex].style.marginLeft = (parseInt(this.deltaX) || 0) + 'px'; 30786 } 30787 } 30788 30789 touchEndHandler (event) { 30790 // console.log('touchend', this.touching) 30791 if (this.touching) { 30792 // this.slides[this.currentIndex].querySelector('.slide-img').style.marginLeft = '0px' 30793 this.slides[this.currentIndex].style.marginLeft = '0px'; 30794 30795 if ((this.timerCounter < 30 && this.deltaX > 20) || (this.deltaX >= 50)) { 30796 this.showSlide(-1, true); 30797 } else if ((this.timerCounter < 30 && this.deltaX < -20) || (this.deltaX <= -50)) { 30798 this.showSlide(1, true); 30799 } else { 30800 this.cancelled = true; 30801 this.showSlide(0); 30802 } 30803 30804 this.touchDone(); 30805 } 30806 } 30807 30808 touchCancelHandler (event) { 30809 // console.log('touchcancel', this.touching) 30810 this.cancelled = true; 30811 this.touchDone(); 30812 } 30813 30814 touchHandler (event) { 30815 // console.log('touchstart', this.touching) 30816 if (!this.touching) { 30817 this.touching = true; 30818 if (!this.element.contains(event.target)) { 30819 return 30820 } 30821 this.slideWidth = this.element.clientWidth; 30822 this.maxMove = this.slides.length * this.slideWidth; 30823 30824 this.cancelled = false; 30825 this.startX = event.touches[0].pageX; 30826 30827 this.timer = setInterval(() => { 30828 this.timerCounter++; 30829 }, 10); 30830 } 30831 } 30832 30833 touchDone () { 30834 // console.log('touchdone', this.cancelled) 30835 30836 const peek = this.peek; 30837 30838 if (peek) { 30839 if (this.cancelled) { 30840 utils$1.elementTools.removeClass(peek, 'in'); 30841 utils$1.elementTools.addClass(peek, 'out'); 30842 peek.style.marginLeft = '0px'; 30843 this.cancelled = false; 30844 } 30845 30846 this.peek = null; 30847 } 30848 30849 clearInterval(this.timer); 30850 this.timer = null; 30851 this.timerCounter = 0; 30852 this.touching = false; 30853 this.deltaX = 0; 30854 } 30855 30856 showSlideIndex (index) { 30857 const delta = index - (this.currentIndex + 1); 30858 if (delta) { 30859 this.showSlide(delta); 30860 } 30861 } 30862 30863 showSlide (delta, touch) { 30864 if (this.currentIndex !== -1) { 30865 this.element.querySelector('.slide-overlay').style.diplay = 'none'; 30866 if (touch) { // slide out outgoing 30867 const currentSlide = this.slides[this.currentIndex]; 30868 currentSlide.style.transition = 'margin .25s'; 30869 if (delta < 0) { 30870 currentSlide.style.marginLeft = (this.element.clientWidth) + 'px'; 30871 } else { 30872 currentSlide.style.marginLeft = (this.element.clientWidth * -1) + 'px'; 30873 } 30874 utils$1.elementTools.once(this.uid, currentSlide, 'transitionend', (e) => { 30875 currentSlide.style.transition = 'margin 0s'; 30876 currentSlide.style.marginLeft = '0px'; 30877 utils$1.elementTools.removeClass(currentSlide, 'in'); 30878 utils$1.elementTools.addClass(currentSlide, 'out'); 30879 }); 30880 } else { 30881 utils$1.elementTools.removeClass(this.slides[this.currentIndex], 'in'); 30882 utils$1.elementTools.addClass(this.slides[this.currentIndex], 'out'); 30883 } 30884 30885 utils$1.elementTools.removeClass(this.slides[this.currentIndex].querySelector('.caption'), 'in'); 30886 utils$1.elementTools.addClass(this.slides[this.currentIndex].querySelector('.caption'), 'out'); 30887 } 30888 30889 this.currentIndex += delta; 30890 if (this.currentIndex > this.slides.length - 1) { 30891 this.currentIndex = 0; 30892 } 30893 if (this.currentIndex < 0) { 30894 this.currentIndex = this.slides.length - 1; 30895 } 30896
30897 const lazyBackground = this.slides[this.currentIndex].children[0]; 30898 lazyBackground.dispatchEvent(new CustomEvent('sargasso', { 30899 detail: { 30900 sargassoEvent: 'enterViewport' 30901 } 30902 })); 30903 30904 // preload the next one 30905 if (this.currentIndex < this.slides.length - 1) { 30906 const nextFlyingFish = this.slides[this.currentIndex + 1].children[0]; 30907 nextFlyingFish.dispatchEvent(new CustomEvent('sargasso', { 30908 detail: { 30909 sargassoEvent: 'enterViewport' 30910 } 30911 })); 30912 } 30913 30914 if (touch) { // slide in incoming 30915 const currentSlide = this.slides[this.currentIndex]; 30916 currentSlide.style.transition = 'margin .25s'; 30917 currentSlide.style.marginLeft = '0px'; 30918 utils$1.elementTools.once(this.uid, currentSlide, 'transitionend', (e) => { 30919 currentSlide.style.transition = 'margin 0s'; 30920 }); 30921 } 30922 30923 utils$1.elementTools.removeClass(this.slides[this.currentIndex], 'out'); 30924 utils$1.elementTools.addClass(this.slides[this.currentIndex], 'in'); 30925 utils$1.elementTools.removeClass(this.slides[this.currentIndex].querySelector('.caption'), 'out'); 30926 utils$1.elementTools.addClass(this.slides[this.currentIndex].querySelector('.caption'), 'in'); 30927 30928 const dot = this.element.querySelector('.dot-prompt'); 30929 30930 // update current dot 30931 setTimeout(() => { 30932 dot.innerHTML = (this.currentIndex + 1) + ' of ' + this.slides.length; 30933 }, 500); 30934 } 30935 } 30936 30937 utils$1.registerSargassoClass('slideShow', slideShow); 30938 30939 class immersive extends Sargasso { 30940 constructor (elem, options) { 30941 super(elem, { 30942 watchOrientation: true 30943 }); 30944 30945 this.target = this.element.getAttribute('data-target') ? document.querySelector(this.element.getAttribute('data-target')) : null; 30946 } 30947 30948 start () { 30949 super.start(); 30950 30951 this.clickHandler = (e) => { 30952 this.wantFullscreen(!elementTools.hasClass(document.body, 'fullscreen')); 30953 }; 30954 30955 this.element.addEventListener('click', this.clickHandler, false); 30956 30957 this.keyHandler = (e) => { 30958 if (e.keyCode === 27) { 30959 this.wantFullscreen(false); 30960 } 30961 }; 30962 30963 document.addEventListener('keydown', this.keyHandler); 30964 } 30965 30966 sleep () { 30967 this.element.removeEventListener('click', this.clickHandler); 30968 document.removeEventListener('keydown', this.keyHandler); 30969 elementTools.off(this.uid, this.target, 'click', 'div'); 30970 super.sleep(); 30971 } 30972 30973 enterFullscreen () { 30974 const frame = () => { 30975 elementTools.addClass(document.body, 'fullscreen'); 30976 // kick the document to let everyone knows a big change occured 30977 document.body.dispatchEvent(new Event('resize', { 30978 bubbles: true 30979 })); 30980 }; 30981 this.queueFrame(frame); 30982 if (this.target) { 30983 this.target.dispatchEvent(new CustomEvent('sargasso', { 30984 detail: { 30985 sargassoEvent: 'enterFullscreen' 30986 } 30987 })); 30988 } 30989 } 30990 30991 exitFullscreen () { 30992 const frame = () => { 30993 elementTools.removeClass(document.body, 'fullscreen'); 30994 }; 30995 this.queueFrame(frame); 30996 if (this.target) { 30997 this.target.dispatchEvent(new CustomEvent('sargasso', { 30998 detail: { 30999 sargassoEvent: 'exitFullscreen' 31000 } 31001 })); 31002 } 31003 } 31004 } 31005 31006 utils$1.registerSargassoClass('immersive', immersive); 31007 31008 function setWindowState (scope, key, val) { 31009 const state = getWindowState(scope); 31010 state[key] = val; 31011 sessionStorage.setItem(scope, JSON.stringify(state)); 31012 } 31013 31014 function getWindowState (scope) { 31015 const state = sessionStorage.getItem(scope); 31016 if (state) { 31017 return JSON.parse(state) 31018 } 31019 return {} 31020 } 31021 31022 function deleteWindowState (scope) { 31023 sessionStorage.removeItem(scope); 31024 } 31025 31026 utils$1.elementTools.on('click-handler', document.body, 'click', '[data-click-it]', (e, element) => { 31027 setWindowState(location.pathname + location.search, 'scrollTop', theScrollWatcher.scrollTop()); 31028 setWindowState(location.pathname + location.search, 'target', element.getAttribute('id')); 31029 let href = element.getAttribute('data-click-it'); 31030 href += '?filters=' + encodeURIComponent(location.search); 31031 loadPage(href); 31032 }, true); 31033 31034 class ScrollPosition extends Sargasso { 31035 newPage (oldPage, page) { 31036 const state = getWindowState(page); 31037 deleteWindowState(page); 31038 const isScrolled = theScrollWatcher.scrollTop(); 31039 if (isScrolled !== parseInt(state.scrollTop) && parseInt(state.scrollTop)) { 31040 const frame = () => { 31041 theScrollWatcher.scrollTop(state.scrollTop); 31042 }; 31043 this.queueFrame(frame); 31044 } 31045 31046 if (state.target) { 31047 const frame = () => { 31048 const target = document.getElementById(state.target); 31049 if (target) { 31050 utils$1.elementTools.addClass(target, 'animate__animated'); 31051 utils$1.elementTools.addClass(target, 'animate__pulse'); 31052 utils$1.elementTools.addClass(target, 'animate__faster'); 31053 31054 utils$1.elementTools.once(this.uid, target, 'animationend', '', (e) => { 31055 utils$1.elementTools.removeClass(target, 'animate__animated'); 31056 utils$1.elementTools.removeClass(target, 'animate__pulse'); 31057 utils$1.elementTools.removeClass(target, 'animate__faster'); 31058 }); 31059 } 31060 }; 31061 this.queueFrame(frame); 31062 } 31063 } 31064 } 31065 31066 utils$1.registerSargassoClass('ScrollPosition', ScrollPosition); 31067 31068 class MenuBarScrollHide extends Sargasso { 31069 constructor (elem, options) { 31070 super(elem, { 31071 watchScroll: true 31072 }); 31073 this.lastscroll = theScrollWatcher.scrollTop(); 31074 this.hidden = false;
31075 } 31076 31077 newPage () { 31078 this.show(); 31079 } 31080 31081 didScroll () { 31082 const scrollTop = theScrollWatcher.scrollTop(); 31083 31084 const delta = scrollTop - this.lastscroll; 31085 31086 if (scrollTop < 65) { 31087 this.show(); 31088 } else { 31089 if (Math.abs(delta) > 20) { 31090 if (scrollTop > this.lastscroll) { 31091 this.hide(); 31092 } 31093 if (scrollTop < this.lastscroll) { 31094 this.show(); 31095 } 31096 } 31097 } 31098 this.lastscroll = scrollTop; 31099 } 31100 31101 hide () { 31102 if (!this.hidden) { 31103 this.hidden = true; 31104 const frame = () => { 31105 this.addClass('hidemenu'); 31106 }; 31107 this.queueFrame(frame); 31108 } 31109 } 31110 31111 show () { 31112 if (this.hidden) { 31113 this.hidden = false; 31114 const frame = () => { 31115 this.removeClass('hidemenu'); 31116 }; 31117 this.queueFrame(frame); 31118 } 31119 } 31120 } 31121 31122 utils$1.registerSargassoClass('MenuBarScrollHide', MenuBarScrollHide); 31123 31124 utils$1.elementTools.on('scroll-down-click', document.body, 'click', '.scroll-down', (e) => { 31125 const top = window.innerHeight / 2; 31126 const element = document.getElementById('overscroll-wrapper') || window; 31127 element.scroll({ 31128 top: top, 31129 left: 0, 31130 behavior: 'smooth' 31131 }); 31132 }); 31133 31134 utils$1.elementTools.on('scrolled', document.getElementById('overscroll-wrapper') || window, 'scroll', null, () => { 31135 if (theScrollWatcher.scrollTop() > 65) { 31136 utils$1.elementTools.addClass(document.body, 'scrolled'); 31137 } else { 31138 utils$1.elementTools.removeClass(document.body, 'scrolled'); 31139 } 31140 }); 31141 31142 class FloatingScrollElement extends Sargasso { 31143 constructor (element, options = {}) { 31144 options.watchScroll = true; 31145 super(element, options); 31146 this.element.parentElement.innerHeight = this.element.outerHeight + window.innerHeight; 31147 } 31148 31149 didScroll () { 31150 this.setCSS({ 31151 top: (window.innerHeight + (theScrollWatcher.scrollTop() * -1)) + 'px' 31152 }); 31153 } 31154 } 31155 31156 utils$1.registerSargassoClass('FloatingScrollElement', FloatingScrollElement); 31157 31158 class LoadMore extends Sargasso { 31159 constructor (element, options = {}) { 31160 options.watchViewport = true; 31161 super(element, options); 31162 this.endpoint = this.element.getAttribute('data-endpoint'); 31163 this.filters = this.element.getAttribute('data-filters'); 31164 this.page = this.element.getAttribute('data-page') || 0; 31165 } 31166 31167 enterViewport () { 31168 document.body.dispatchEvent(new CustomEvent('load-more', { 31169 detail: { 31170 endpoint: this.endpoint, 31171 page: this.page, 31172 controller: this, 31173 filters: this.filters 31174 } 31175 })); 31176 } 31177 } 31178 31179 utils$1.registerSargassoClass('LoadMore', LoadMore); 31180 31181 class FadeScrollElement extends Sargasso { 31182 constructor (element, options = {}) { 31183 options.watchScroll = true; 31184 super(element, options); 31185 } 31186 31187 didScroll () { 31188 if (theScrollWatcher.scrollTop() > window.innerHeight / 2) { 31189 this.setCSS({ 31190 opacity: 0 31191 }); 31192 } else { 31193 this.setCSS({ 31194 opacity: 1 31195 }); 31196 } 31197 } 31198 } 31199 31200 utils$1.registerSargassoClass('FadeScrollElement', FadeScrollElement); 31201 31202 class Session extends Sargasso { 31203 constructor (element, options = {}) { 31204 super(element, options); 31205 this.loading = false; 31206 this.highwater = 0; 31207 } 31208 31209 start () { 31210 this.on('load-more', null, (e) => { 31211 if (!this.loading) { 31212 this.loading = true; 31213 31214 const endpoint = e.detail.endpoint; 31215 const page = e.detail.page || 0; 31216 const filters = e.detail.filters; 31217 31218 const options = { 31219 method: 'GET', 31220 headers: { 31221 Accept: 'application/json' 31222 } 31223 }; 31224 31225 fetch(endpoint + '?page=' + page + filters, options) 31226 .then((response) => { 31227 return response.json() 31228 }) 31229 .then((response) => { 31230 this.loading = false; 31231 if (response.status === 'ok') { 31232 if (response.posts.length) { 31233 this.renderPosts(response.posts); 31234 ++this.highwater; 31235 ++e.detail.controller.page; // increment current page 31236 } else { 31237 e.detail.controller.element.remove(); 31238 } 31239 } else { 31240 console.log(response.status, response.message); 31241 } 31242 }) 31243 .catch((err) => { 31244 console.log(err); 31245 }); 31246 } 31247 }); 31248 } 31249 31250 renderPosts (posts) { 31251 const html = postsTemplate({ 31252 posts: posts 31253 }); 31254 31255 // render markup offscreen then get a list of rendered posts 31256 const div = document.createElement('div'); 31257 div.innerHTML = html; 31258 const rendered = Array.from(div.querySelectorAll('.mdc-layout-grid__cell--span-4')); 31259 31260 // append posts to post list 31261 const postList = document.getElementById('post-list'); 31262 for (const item in rendered) { 31263 const post = rendered[item]; 31264 this.queueFrame(() => { 31265 postList.append(post); 31266 }); 31267 } 31268 } 31269 } 31270 31271 utils$1.registerSargassoClass('Session', Session); 31272 31273 // import any ES6 modules you need here and they will get bundled in 31274 31275 // export any ES6 modules you need in your ES5 scripts 31276 // webpack will expose things exported here
31277 // as App.XXX in the global namespace 31278 31279 const boot = () => { 31280 const pos = new ScrollPosition(document.body); 31281 pos.start(); 31282 31283 const session = new Session(document.body); 31284 session.start(); 31285 31286 utils$1.bootSargasso({ 31287 scrollElement: document.getElementById('overscroll-wrapper') || window, 31288 breakpoints: {}, 31289 hijax: { 31290 onError: (level, message) => { 31291 flashAjaxStatus(level, message); 31292 }, 31293 onLoading: function () { 31294 tropicBird.progressBar(this.readyState !== 4); 31295 }, 31296 onExitPage: () => {}, 31297 onEnterPage: () => { 31298 checkSubscription(); 31299 }, 31300 preFlight: (url, cb) => { 31301 const parsed = new URL(url, document.location.href); 31302 if (parsed.pathname === '/' && session.highwater) { 31303 if (parsed.search) { 31304 url += '&'; 31305 } else { 31306 url += '?'; 31307 } 31308 url += 'highwater=' + session.highwater; 31309 } 31310 cb(null, false, url); 31311 } 31312 } 31313 }); 31314 }; 31315 31316 exports.CMSUtils = utils; 31317 exports.boot = boot; 31318 31319 Object.defineProperty(exports, '__esModule', { value: true }); 31320 31321 return exports; 31322 31323}({})); 31324//# sourceMappingURL=userapp.iife.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.