UNPKG

36.9 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://github.com/material-components/material-components-web/blob/master/LICENSE
7 */
8(function webpackUniversalModuleDefinition(root, factory) {
9 if(typeof exports === 'object' && typeof module === 'object')
10 module.exports = factory();
11 else if(typeof define === 'function' && define.amd)
12 define("@material/floating-label", [], factory);
13 else if(typeof exports === 'object')
14 exports["floating-label"] = factory();
15 else
16 root["mdc"] = root["mdc"] || {}, root["mdc"]["floating-label"] = factory();
17})(this, function() {
18return /******/ (function(modules) { // webpackBootstrap
19/******/ // The module cache
20/******/ var installedModules = {};
21/******/
22/******/ // The require function
23/******/ function __webpack_require__(moduleId) {
24/******/
25/******/ // Check if module is in cache
26/******/ if(installedModules[moduleId]) {
27/******/ return installedModules[moduleId].exports;
28/******/ }
29/******/ // Create a new module (and put it into the cache)
30/******/ var module = installedModules[moduleId] = {
31/******/ i: moduleId,
32/******/ l: false,
33/******/ exports: {}
34/******/ };
35/******/
36/******/ // Execute the module function
37/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
38/******/
39/******/ // Flag the module as loaded
40/******/ module.l = true;
41/******/
42/******/ // Return the exports of the module
43/******/ return module.exports;
44/******/ }
45/******/
46/******/
47/******/ // expose the modules object (__webpack_modules__)
48/******/ __webpack_require__.m = modules;
49/******/
50/******/ // expose the module cache
51/******/ __webpack_require__.c = installedModules;
52/******/
53/******/ // define getter function for harmony exports
54/******/ __webpack_require__.d = function(exports, name, getter) {
55/******/ if(!__webpack_require__.o(exports, name)) {
56/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
57/******/ }
58/******/ };
59/******/
60/******/ // define __esModule on exports
61/******/ __webpack_require__.r = function(exports) {
62/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
63/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
64/******/ }
65/******/ Object.defineProperty(exports, '__esModule', { value: true });
66/******/ };
67/******/
68/******/ // create a fake namespace object
69/******/ // mode & 1: value is a module id, require it
70/******/ // mode & 2: merge all properties of value into the ns
71/******/ // mode & 4: return value when already ns object
72/******/ // mode & 8|1: behave like require
73/******/ __webpack_require__.t = function(value, mode) {
74/******/ if(mode & 1) value = __webpack_require__(value);
75/******/ if(mode & 8) return value;
76/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
77/******/ var ns = Object.create(null);
78/******/ __webpack_require__.r(ns);
79/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
80/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
81/******/ return ns;
82/******/ };
83/******/
84/******/ // getDefaultExport function for compatibility with non-harmony modules
85/******/ __webpack_require__.n = function(module) {
86/******/ var getter = module && module.__esModule ?
87/******/ function getDefault() { return module['default']; } :
88/******/ function getModuleExports() { return module; };
89/******/ __webpack_require__.d(getter, 'a', getter);
90/******/ return getter;
91/******/ };
92/******/
93/******/ // Object.prototype.hasOwnProperty.call
94/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
95/******/
96/******/ // __webpack_public_path__
97/******/ __webpack_require__.p = "";
98/******/
99/******/
100/******/ // Load entry module and return exports
101/******/ return __webpack_require__(__webpack_require__.s = "./packages/mdc-floating-label/index.ts");
102/******/ })
103/************************************************************************/
104/******/ ({
105
106/***/ "./packages/mdc-base/component.ts":
107/*!****************************************!*\
108 !*** ./packages/mdc-base/component.ts ***!
109 \****************************************/
110/*! no static exports found */
111/***/ (function(module, exports, __webpack_require__) {
112
113"use strict";
114
115/**
116 * @license
117 * Copyright 2016 Google Inc.
118 *
119 * Permission is hereby granted, free of charge, to any person obtaining a copy
120 * of this software and associated documentation files (the "Software"), to deal
121 * in the Software without restriction, including without limitation the rights
122 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
123 * copies of the Software, and to permit persons to whom the Software is
124 * furnished to do so, subject to the following conditions:
125 *
126 * The above copyright notice and this permission notice shall be included in
127 * all copies or substantial portions of the Software.
128 *
129 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
130 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
131 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
132 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
133 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
134 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
135 * THE SOFTWARE.
136 */
137
138var __read = this && this.__read || function (o, n) {
139 var m = typeof Symbol === "function" && o[Symbol.iterator];
140 if (!m) return o;
141 var i = m.call(o),
142 r,
143 ar = [],
144 e;
145 try {
146 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
147 ar.push(r.value);
148 }
149 } catch (error) {
150 e = { error: error };
151 } finally {
152 try {
153 if (r && !r.done && (m = i["return"])) m.call(i);
154 } finally {
155 if (e) throw e.error;
156 }
157 }
158 return ar;
159};
160var __spreadArray = this && this.__spreadArray || function (to, from) {
161 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) {
162 to[j] = from[i];
163 }return to;
164};
165Object.defineProperty(exports, "__esModule", { value: true });
166exports.MDCComponent = void 0;
167var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-base/foundation.ts");
168var MDCComponent = /** @class */function () {
169 function MDCComponent(root, foundation) {
170 var args = [];
171 for (var _i = 2; _i < arguments.length; _i++) {
172 args[_i - 2] = arguments[_i];
173 }
174 this.root = root;
175 this.initialize.apply(this, __spreadArray([], __read(args)));
176 // Note that we initialize foundation here and not within the constructor's
177 // default param so that this.root is defined and can be used within the
178 // foundation class.
179 this.foundation = foundation === undefined ? this.getDefaultFoundation() : foundation;
180 this.foundation.init();
181 this.initialSyncWithDOM();
182 }
183 MDCComponent.attachTo = function (root) {
184 // Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
185 // returns an instantiated component with its root set to that element. Also note that in the cases of
186 // subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
187 // from getDefaultFoundation().
188 return new MDCComponent(root, new foundation_1.MDCFoundation({}));
189 };
190 /* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
191 MDCComponent.prototype.initialize = function () {
192 var _args = [];
193 for (var _i = 0; _i < arguments.length; _i++) {
194 _args[_i] = arguments[_i];
195 }
196 // Subclasses can override this to do any additional setup work that would be considered part of a
197 // "constructor". Essentially, it is a hook into the parent constructor before the foundation is
198 // initialized. Any additional arguments besides root and foundation will be passed in here.
199 };
200 MDCComponent.prototype.getDefaultFoundation = function () {
201 // Subclasses must override this method to return a properly configured foundation class for the
202 // component.
203 throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' + 'foundation class');
204 };
205 MDCComponent.prototype.initialSyncWithDOM = function () {
206 // Subclasses should override this method if they need to perform work to synchronize with a host DOM
207 // object. An example of this would be a form control wrapper that needs to synchronize its internal state
208 // to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
209 // reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
210 };
211 MDCComponent.prototype.destroy = function () {
212 // Subclasses may implement this method to release any resources / deregister any listeners they have
213 // attached. An example of this might be deregistering a resize event from the window object.
214 this.foundation.destroy();
215 };
216 MDCComponent.prototype.listen = function (evtType, handler, options) {
217 this.root.addEventListener(evtType, handler, options);
218 };
219 MDCComponent.prototype.unlisten = function (evtType, handler, options) {
220 this.root.removeEventListener(evtType, handler, options);
221 };
222 /**
223 * Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
224 */
225 MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
226 if (shouldBubble === void 0) {
227 shouldBubble = false;
228 }
229 var evt;
230 if (typeof CustomEvent === 'function') {
231 evt = new CustomEvent(evtType, {
232 bubbles: shouldBubble,
233 detail: evtData
234 });
235 } else {
236 evt = document.createEvent('CustomEvent');
237 evt.initCustomEvent(evtType, shouldBubble, false, evtData);
238 }
239 this.root.dispatchEvent(evt);
240 };
241 return MDCComponent;
242}();
243exports.MDCComponent = MDCComponent;
244// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
245exports.default = MDCComponent;
246
247/***/ }),
248
249/***/ "./packages/mdc-base/foundation.ts":
250/*!*****************************************!*\
251 !*** ./packages/mdc-base/foundation.ts ***!
252 \*****************************************/
253/*! no static exports found */
254/***/ (function(module, exports, __webpack_require__) {
255
256"use strict";
257
258/**
259 * @license
260 * Copyright 2016 Google Inc.
261 *
262 * Permission is hereby granted, free of charge, to any person obtaining a copy
263 * of this software and associated documentation files (the "Software"), to deal
264 * in the Software without restriction, including without limitation the rights
265 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
266 * copies of the Software, and to permit persons to whom the Software is
267 * furnished to do so, subject to the following conditions:
268 *
269 * The above copyright notice and this permission notice shall be included in
270 * all copies or substantial portions of the Software.
271 *
272 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
273 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
274 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
275 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
276 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
277 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
278 * THE SOFTWARE.
279 */
280
281Object.defineProperty(exports, "__esModule", { value: true });
282exports.MDCFoundation = void 0;
283var MDCFoundation = /** @class */function () {
284 function MDCFoundation(adapter) {
285 if (adapter === void 0) {
286 adapter = {};
287 }
288 this.adapter = adapter;
289 }
290 Object.defineProperty(MDCFoundation, "cssClasses", {
291 get: function get() {
292 // Classes extending MDCFoundation should implement this method to return an object which exports every
293 // CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
294 return {};
295 },
296 enumerable: false,
297 configurable: true
298 });
299 Object.defineProperty(MDCFoundation, "strings", {
300 get: function get() {
301 // Classes extending MDCFoundation should implement this method to return an object which exports all
302 // semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
303 return {};
304 },
305 enumerable: false,
306 configurable: true
307 });
308 Object.defineProperty(MDCFoundation, "numbers", {
309 get: function get() {
310 // Classes extending MDCFoundation should implement this method to return an object which exports all
311 // of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
312 return {};
313 },
314 enumerable: false,
315 configurable: true
316 });
317 Object.defineProperty(MDCFoundation, "defaultAdapter", {
318 get: function get() {
319 // Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
320 // way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
321 // validation.
322 return {};
323 },
324 enumerable: false,
325 configurable: true
326 });
327 MDCFoundation.prototype.init = function () {
328 // Subclasses should override this method to perform initialization routines (registering events, etc.)
329 };
330 MDCFoundation.prototype.destroy = function () {
331 // Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
332 };
333 return MDCFoundation;
334}();
335exports.MDCFoundation = MDCFoundation;
336// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
337exports.default = MDCFoundation;
338
339/***/ }),
340
341/***/ "./packages/mdc-dom/ponyfill.ts":
342/*!**************************************!*\
343 !*** ./packages/mdc-dom/ponyfill.ts ***!
344 \**************************************/
345/*! no static exports found */
346/***/ (function(module, exports, __webpack_require__) {
347
348"use strict";
349
350/**
351 * @license
352 * Copyright 2018 Google Inc.
353 *
354 * Permission is hereby granted, free of charge, to any person obtaining a copy
355 * of this software and associated documentation files (the "Software"), to deal
356 * in the Software without restriction, including without limitation the rights
357 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
358 * copies of the Software, and to permit persons to whom the Software is
359 * furnished to do so, subject to the following conditions:
360 *
361 * The above copyright notice and this permission notice shall be included in
362 * all copies or substantial portions of the Software.
363 *
364 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
365 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
366 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
367 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
368 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
369 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
370 * THE SOFTWARE.
371 */
372
373Object.defineProperty(exports, "__esModule", { value: true });
374exports.estimateScrollWidth = exports.matches = exports.closest = void 0;
375/**
376 * @fileoverview A "ponyfill" is a polyfill that doesn't modify the global prototype chain.
377 * This makes ponyfills safer than traditional polyfills, especially for libraries like MDC.
378 */
379function closest(element, selector) {
380 if (element.closest) {
381 return element.closest(selector);
382 }
383 var el = element;
384 while (el) {
385 if (matches(el, selector)) {
386 return el;
387 }
388 el = el.parentElement;
389 }
390 return null;
391}
392exports.closest = closest;
393function matches(element, selector) {
394 var nativeMatches = element.matches || element.webkitMatchesSelector || element.msMatchesSelector;
395 return nativeMatches.call(element, selector);
396}
397exports.matches = matches;
398/**
399 * Used to compute the estimated scroll width of elements. When an element is
400 * hidden due to display: none; being applied to a parent element, the width is
401 * returned as 0. However, the element will have a true width once no longer
402 * inside a display: none context. This method computes an estimated width when
403 * the element is hidden or returns the true width when the element is visble.
404 * @param {Element} element the element whose width to estimate
405 */
406function estimateScrollWidth(element) {
407 // Check the offsetParent. If the element inherits display: none from any
408 // parent, the offsetParent property will be null (see
409 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent).
410 // This check ensures we only clone the node when necessary.
411 var htmlEl = element;
412 if (htmlEl.offsetParent !== null) {
413 return htmlEl.scrollWidth;
414 }
415 var clone = htmlEl.cloneNode(true);
416 clone.style.setProperty('position', 'absolute');
417 clone.style.setProperty('transform', 'translate(-9999px, -9999px)');
418 document.documentElement.appendChild(clone);
419 var scrollWidth = clone.scrollWidth;
420 document.documentElement.removeChild(clone);
421 return scrollWidth;
422}
423exports.estimateScrollWidth = estimateScrollWidth;
424
425/***/ }),
426
427/***/ "./packages/mdc-floating-label/adapter.ts":
428/*!************************************************!*\
429 !*** ./packages/mdc-floating-label/adapter.ts ***!
430 \************************************************/
431/*! no static exports found */
432/***/ (function(module, exports, __webpack_require__) {
433
434"use strict";
435
436/**
437 * @license
438 * Copyright 2017 Google Inc.
439 *
440 * Permission is hereby granted, free of charge, to any person obtaining a copy
441 * of this software and associated documentation files (the "Software"), to deal
442 * in the Software without restriction, including without limitation the rights
443 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
444 * copies of the Software, and to permit persons to whom the Software is
445 * furnished to do so, subject to the following conditions:
446 *
447 * The above copyright notice and this permission notice shall be included in
448 * all copies or substantial portions of the Software.
449 *
450 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
451 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
452 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
453 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
454 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
455 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
456 * THE SOFTWARE.
457 */
458
459Object.defineProperty(exports, "__esModule", { value: true });
460
461/***/ }),
462
463/***/ "./packages/mdc-floating-label/component.ts":
464/*!**************************************************!*\
465 !*** ./packages/mdc-floating-label/component.ts ***!
466 \**************************************************/
467/*! no static exports found */
468/***/ (function(module, exports, __webpack_require__) {
469
470"use strict";
471
472/**
473 * @license
474 * Copyright 2016 Google Inc.
475 *
476 * Permission is hereby granted, free of charge, to any person obtaining a copy
477 * of this software and associated documentation files (the "Software"), to deal
478 * in the Software without restriction, including without limitation the rights
479 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
480 * copies of the Software, and to permit persons to whom the Software is
481 * furnished to do so, subject to the following conditions:
482 *
483 * The above copyright notice and this permission notice shall be included in
484 * all copies or substantial portions of the Software.
485 *
486 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
487 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
488 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
489 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
490 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
491 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
492 * THE SOFTWARE.
493 */
494
495var __extends = this && this.__extends || function () {
496 var _extendStatics = function extendStatics(d, b) {
497 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
498 d.__proto__ = b;
499 } || function (d, b) {
500 for (var p in b) {
501 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
502 }
503 };
504 return _extendStatics(d, b);
505 };
506 return function (d, b) {
507 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
508 _extendStatics(d, b);
509 function __() {
510 this.constructor = d;
511 }
512 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
513 };
514}();
515Object.defineProperty(exports, "__esModule", { value: true });
516exports.MDCFloatingLabel = void 0;
517var component_1 = __webpack_require__(/*! @material/base/component */ "./packages/mdc-base/component.ts");
518var ponyfill_1 = __webpack_require__(/*! @material/dom/ponyfill */ "./packages/mdc-dom/ponyfill.ts");
519var foundation_1 = __webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts");
520var MDCFloatingLabel = /** @class */function (_super) {
521 __extends(MDCFloatingLabel, _super);
522 function MDCFloatingLabel() {
523 return _super !== null && _super.apply(this, arguments) || this;
524 }
525 MDCFloatingLabel.attachTo = function (root) {
526 return new MDCFloatingLabel(root);
527 };
528 /**
529 * Styles the label to produce the label shake for errors.
530 * @param shouldShake If true, shakes the label by adding a CSS class; otherwise, stops shaking by removing the class.
531 */
532 MDCFloatingLabel.prototype.shake = function (shouldShake) {
533 this.foundation.shake(shouldShake);
534 };
535 /**
536 * Styles the label to float/dock.
537 * @param shouldFloat If true, floats the label by adding a CSS class; otherwise, docks it by removing the class.
538 */
539 MDCFloatingLabel.prototype.float = function (shouldFloat) {
540 this.foundation.float(shouldFloat);
541 };
542 /**
543 * Styles the label as required.
544 * @param isRequired If true, adds an asterisk to the label, indicating that it is required.
545 */
546 MDCFloatingLabel.prototype.setRequired = function (isRequired) {
547 this.foundation.setRequired(isRequired);
548 };
549 MDCFloatingLabel.prototype.getWidth = function () {
550 return this.foundation.getWidth();
551 };
552 MDCFloatingLabel.prototype.getDefaultFoundation = function () {
553 var _this = this;
554 // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
555 // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
556 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
557 var adapter = {
558 addClass: function addClass(className) {
559 return _this.root.classList.add(className);
560 },
561 removeClass: function removeClass(className) {
562 return _this.root.classList.remove(className);
563 },
564 getWidth: function getWidth() {
565 return ponyfill_1.estimateScrollWidth(_this.root);
566 },
567 registerInteractionHandler: function registerInteractionHandler(evtType, handler) {
568 return _this.listen(evtType, handler);
569 },
570 deregisterInteractionHandler: function deregisterInteractionHandler(evtType, handler) {
571 return _this.unlisten(evtType, handler);
572 }
573 };
574 // tslint:enable:object-literal-sort-keys
575 return new foundation_1.MDCFloatingLabelFoundation(adapter);
576 };
577 return MDCFloatingLabel;
578}(component_1.MDCComponent);
579exports.MDCFloatingLabel = MDCFloatingLabel;
580
581/***/ }),
582
583/***/ "./packages/mdc-floating-label/constants.ts":
584/*!**************************************************!*\
585 !*** ./packages/mdc-floating-label/constants.ts ***!
586 \**************************************************/
587/*! no static exports found */
588/***/ (function(module, exports, __webpack_require__) {
589
590"use strict";
591
592/**
593 * @license
594 * Copyright 2016 Google Inc.
595 *
596 * Permission is hereby granted, free of charge, to any person obtaining a copy
597 * of this software and associated documentation files (the "Software"), to deal
598 * in the Software without restriction, including without limitation the rights
599 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
600 * copies of the Software, and to permit persons to whom the Software is
601 * furnished to do so, subject to the following conditions:
602 *
603 * The above copyright notice and this permission notice shall be included in
604 * all copies or substantial portions of the Software.
605 *
606 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
607 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
608 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
609 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
610 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
611 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
612 * THE SOFTWARE.
613 */
614
615Object.defineProperty(exports, "__esModule", { value: true });
616exports.cssClasses = void 0;
617exports.cssClasses = {
618 LABEL_FLOAT_ABOVE: 'mdc-floating-label--float-above',
619 LABEL_REQUIRED: 'mdc-floating-label--required',
620 LABEL_SHAKE: 'mdc-floating-label--shake',
621 ROOT: 'mdc-floating-label'
622};
623
624/***/ }),
625
626/***/ "./packages/mdc-floating-label/foundation.ts":
627/*!***************************************************!*\
628 !*** ./packages/mdc-floating-label/foundation.ts ***!
629 \***************************************************/
630/*! no static exports found */
631/***/ (function(module, exports, __webpack_require__) {
632
633"use strict";
634
635/**
636 * @license
637 * Copyright 2016 Google Inc.
638 *
639 * Permission is hereby granted, free of charge, to any person obtaining a copy
640 * of this software and associated documentation files (the "Software"), to deal
641 * in the Software without restriction, including without limitation the rights
642 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
643 * copies of the Software, and to permit persons to whom the Software is
644 * furnished to do so, subject to the following conditions:
645 *
646 * The above copyright notice and this permission notice shall be included in
647 * all copies or substantial portions of the Software.
648 *
649 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
650 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
651 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
652 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
653 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
654 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
655 * THE SOFTWARE.
656 */
657
658var __extends = this && this.__extends || function () {
659 var _extendStatics = function extendStatics(d, b) {
660 _extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (d, b) {
661 d.__proto__ = b;
662 } || function (d, b) {
663 for (var p in b) {
664 if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
665 }
666 };
667 return _extendStatics(d, b);
668 };
669 return function (d, b) {
670 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
671 _extendStatics(d, b);
672 function __() {
673 this.constructor = d;
674 }
675 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
676 };
677}();
678var __assign = this && this.__assign || function () {
679 __assign = Object.assign || function (t) {
680 for (var s, i = 1, n = arguments.length; i < n; i++) {
681 s = arguments[i];
682 for (var p in s) {
683 if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
684 }
685 }
686 return t;
687 };
688 return __assign.apply(this, arguments);
689};
690Object.defineProperty(exports, "__esModule", { value: true });
691exports.MDCFloatingLabelFoundation = void 0;
692var foundation_1 = __webpack_require__(/*! @material/base/foundation */ "./packages/mdc-base/foundation.ts");
693var constants_1 = __webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts");
694var MDCFloatingLabelFoundation = /** @class */function (_super) {
695 __extends(MDCFloatingLabelFoundation, _super);
696 function MDCFloatingLabelFoundation(adapter) {
697 var _this = _super.call(this, __assign(__assign({}, MDCFloatingLabelFoundation.defaultAdapter), adapter)) || this;
698 _this.shakeAnimationEndHandler = function () {
699 _this.handleShakeAnimationEnd();
700 };
701 return _this;
702 }
703 Object.defineProperty(MDCFloatingLabelFoundation, "cssClasses", {
704 get: function get() {
705 return constants_1.cssClasses;
706 },
707 enumerable: false,
708 configurable: true
709 });
710 Object.defineProperty(MDCFloatingLabelFoundation, "defaultAdapter", {
711 /**
712 * See {@link MDCFloatingLabelAdapter} for typing information on parameters and return types.
713 */
714 get: function get() {
715 // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
716 return {
717 addClass: function addClass() {
718 return undefined;
719 },
720 removeClass: function removeClass() {
721 return undefined;
722 },
723 getWidth: function getWidth() {
724 return 0;
725 },
726 registerInteractionHandler: function registerInteractionHandler() {
727 return undefined;
728 },
729 deregisterInteractionHandler: function deregisterInteractionHandler() {
730 return undefined;
731 }
732 };
733 // tslint:enable:object-literal-sort-keys
734 },
735 enumerable: false,
736 configurable: true
737 });
738 MDCFloatingLabelFoundation.prototype.init = function () {
739 this.adapter.registerInteractionHandler('animationend', this.shakeAnimationEndHandler);
740 };
741 MDCFloatingLabelFoundation.prototype.destroy = function () {
742 this.adapter.deregisterInteractionHandler('animationend', this.shakeAnimationEndHandler);
743 };
744 /**
745 * Returns the width of the label element.
746 */
747 MDCFloatingLabelFoundation.prototype.getWidth = function () {
748 return this.adapter.getWidth();
749 };
750 /**
751 * Styles the label to produce a shake animation to indicate an error.
752 * @param shouldShake If true, adds the shake CSS class; otherwise, removes shake class.
753 */
754 MDCFloatingLabelFoundation.prototype.shake = function (shouldShake) {
755 var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
756 if (shouldShake) {
757 this.adapter.addClass(LABEL_SHAKE);
758 } else {
759 this.adapter.removeClass(LABEL_SHAKE);
760 }
761 };
762 /**
763 * Styles the label to float or dock.
764 * @param shouldFloat If true, adds the float CSS class; otherwise, removes float and shake classes to dock the label.
765 */
766 MDCFloatingLabelFoundation.prototype.float = function (shouldFloat) {
767 var _a = MDCFloatingLabelFoundation.cssClasses,
768 LABEL_FLOAT_ABOVE = _a.LABEL_FLOAT_ABOVE,
769 LABEL_SHAKE = _a.LABEL_SHAKE;
770 if (shouldFloat) {
771 this.adapter.addClass(LABEL_FLOAT_ABOVE);
772 } else {
773 this.adapter.removeClass(LABEL_FLOAT_ABOVE);
774 this.adapter.removeClass(LABEL_SHAKE);
775 }
776 };
777 /**
778 * Styles the label as required.
779 * @param isRequired If true, adds an asterisk to the label, indicating that it is required.
780 */
781 MDCFloatingLabelFoundation.prototype.setRequired = function (isRequired) {
782 var LABEL_REQUIRED = MDCFloatingLabelFoundation.cssClasses.LABEL_REQUIRED;
783 if (isRequired) {
784 this.adapter.addClass(LABEL_REQUIRED);
785 } else {
786 this.adapter.removeClass(LABEL_REQUIRED);
787 }
788 };
789 MDCFloatingLabelFoundation.prototype.handleShakeAnimationEnd = function () {
790 var LABEL_SHAKE = MDCFloatingLabelFoundation.cssClasses.LABEL_SHAKE;
791 this.adapter.removeClass(LABEL_SHAKE);
792 };
793 return MDCFloatingLabelFoundation;
794}(foundation_1.MDCFoundation);
795exports.MDCFloatingLabelFoundation = MDCFloatingLabelFoundation;
796// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
797exports.default = MDCFloatingLabelFoundation;
798
799/***/ }),
800
801/***/ "./packages/mdc-floating-label/index.ts":
802/*!**********************************************!*\
803 !*** ./packages/mdc-floating-label/index.ts ***!
804 \**********************************************/
805/*! no static exports found */
806/***/ (function(module, exports, __webpack_require__) {
807
808"use strict";
809
810/**
811 * @license
812 * Copyright 2019 Google Inc.
813 *
814 * Permission is hereby granted, free of charge, to any person obtaining a copy
815 * of this software and associated documentation files (the "Software"), to deal
816 * in the Software without restriction, including without limitation the rights
817 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
818 * copies of the Software, and to permit persons to whom the Software is
819 * furnished to do so, subject to the following conditions:
820 *
821 * The above copyright notice and this permission notice shall be included in
822 * all copies or substantial portions of the Software.
823 *
824 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
825 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
826 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
827 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
828 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
829 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
830 * THE SOFTWARE.
831 */
832
833var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) {
834 if (k2 === undefined) k2 = k;
835 Object.defineProperty(o, k2, { enumerable: true, get: function get() {
836 return m[k];
837 } });
838} : function (o, m, k, k2) {
839 if (k2 === undefined) k2 = k;
840 o[k2] = m[k];
841});
842var __exportStar = this && this.__exportStar || function (m, exports) {
843 for (var p in m) {
844 if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
845 }
846};
847Object.defineProperty(exports, "__esModule", { value: true });
848__exportStar(__webpack_require__(/*! ./adapter */ "./packages/mdc-floating-label/adapter.ts"), exports);
849__exportStar(__webpack_require__(/*! ./component */ "./packages/mdc-floating-label/component.ts"), exports);
850__exportStar(__webpack_require__(/*! ./constants */ "./packages/mdc-floating-label/constants.ts"), exports);
851__exportStar(__webpack_require__(/*! ./foundation */ "./packages/mdc-floating-label/foundation.ts"), exports);
852
853/***/ })
854
855/******/ });
856});
857//# sourceMappingURL=mdc.floatingLabel.js.map
\No newline at end of file