omim
Version:
Material Design for Omi.
1,062 lines (1,030 loc) • 86.2 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("omi"));
else if(typeof define === 'function' && define.amd)
define(["omi"], factory);
else if(typeof exports === 'object')
exports["MSlider"] = factory(require("omi"));
else
root["MSlider"] = factory(root["Omi"]);
})(window, function(__WEBPACK_EXTERNAL_MODULE_omi__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/slider/index.tsx");
/******/ })
/************************************************************************/
/******/ ({
/***/ "./node_modules/@material/animation/util.js":
/*!**************************************************!*\
!*** ./node_modules/@material/animation/util.js ***!
\**************************************************/
/*! exports provided: getCorrectPropertyName, getCorrectEventName */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCorrectPropertyName", function() { return getCorrectPropertyName; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getCorrectEventName", function() { return getCorrectEventName; });
/**
* @license
* Copyright 2016 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var cssPropertyNameMap = {
animation: {
prefixed: '-webkit-animation',
standard: 'animation',
},
transform: {
prefixed: '-webkit-transform',
standard: 'transform',
},
transition: {
prefixed: '-webkit-transition',
standard: 'transition',
},
};
var jsEventTypeMap = {
animationend: {
cssProperty: 'animation',
prefixed: 'webkitAnimationEnd',
standard: 'animationend',
},
animationiteration: {
cssProperty: 'animation',
prefixed: 'webkitAnimationIteration',
standard: 'animationiteration',
},
animationstart: {
cssProperty: 'animation',
prefixed: 'webkitAnimationStart',
standard: 'animationstart',
},
transitionend: {
cssProperty: 'transition',
prefixed: 'webkitTransitionEnd',
standard: 'transitionend',
},
};
function isWindow(windowObj) {
return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
}
function getCorrectPropertyName(windowObj, cssProperty) {
if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
var el = windowObj.document.createElement('div');
var _a = cssPropertyNameMap[cssProperty], standard = _a.standard, prefixed = _a.prefixed;
var isStandard = standard in el.style;
return isStandard ? standard : prefixed;
}
return cssProperty;
}
function getCorrectEventName(windowObj, eventType) {
if (isWindow(windowObj) && eventType in jsEventTypeMap) {
var el = windowObj.document.createElement('div');
var _a = jsEventTypeMap[eventType], standard = _a.standard, prefixed = _a.prefixed, cssProperty = _a.cssProperty;
var isStandard = cssProperty in el.style;
return isStandard ? standard : prefixed;
}
return eventType;
}
//# sourceMappingURL=util.js.map
/***/ }),
/***/ "./node_modules/@material/base/component.js":
/*!**************************************************!*\
!*** ./node_modules/@material/base/component.js ***!
\**************************************************/
/*! exports provided: MDCComponent, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCComponent", function() { return MDCComponent; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
/* harmony import */ var _foundation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./foundation */ "./node_modules/@material/base/foundation.js");
/**
* @license
* Copyright 2016 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var MDCComponent = /** @class */ (function () {
function MDCComponent(root, foundation) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
this.root_ = root;
this.initialize.apply(this, tslib__WEBPACK_IMPORTED_MODULE_0__["__spread"](args));
// Note that we initialize foundation here and not within the constructor's default param so that
// this.root_ is defined and can be used within the foundation class.
this.foundation_ = foundation === undefined ? this.getDefaultFoundation() : foundation;
this.foundation_.init();
this.initialSyncWithDOM();
}
MDCComponent.attachTo = function (root) {
// Subclasses which extend MDCBase should provide an attachTo() method that takes a root element and
// returns an instantiated component with its root set to that element. Also note that in the cases of
// subclasses, an explicit foundation class will not have to be passed in; it will simply be initialized
// from getDefaultFoundation().
return new MDCComponent(root, new _foundation__WEBPACK_IMPORTED_MODULE_1__["MDCFoundation"]({}));
};
/* istanbul ignore next: method param only exists for typing purposes; it does not need to be unit tested */
MDCComponent.prototype.initialize = function () {
var _args = [];
for (var _i = 0; _i < arguments.length; _i++) {
_args[_i] = arguments[_i];
}
// Subclasses can override this to do any additional setup work that would be considered part of a
// "constructor". Essentially, it is a hook into the parent constructor before the foundation is
// initialized. Any additional arguments besides root and foundation will be passed in here.
};
MDCComponent.prototype.getDefaultFoundation = function () {
// Subclasses must override this method to return a properly configured foundation class for the
// component.
throw new Error('Subclasses must override getDefaultFoundation to return a properly configured ' +
'foundation class');
};
MDCComponent.prototype.initialSyncWithDOM = function () {
// Subclasses should override this method if they need to perform work to synchronize with a host DOM
// object. An example of this would be a form control wrapper that needs to synchronize its internal state
// to some property or attribute of the host DOM. Please note: this is *not* the place to perform DOM
// reads/writes that would cause layout / paint, as this is called synchronously from within the constructor.
};
MDCComponent.prototype.destroy = function () {
// Subclasses may implement this method to release any resources / deregister any listeners they have
// attached. An example of this might be deregistering a resize event from the window object.
this.foundation_.destroy();
};
MDCComponent.prototype.listen = function (evtType, handler) {
this.root_.addEventListener(evtType, handler);
};
MDCComponent.prototype.unlisten = function (evtType, handler) {
this.root_.removeEventListener(evtType, handler);
};
/**
* Fires a cross-browser-compatible custom event from the component root of the given type, with the given data.
*/
MDCComponent.prototype.emit = function (evtType, evtData, shouldBubble) {
if (shouldBubble === void 0) { shouldBubble = false; }
var evt;
if (typeof CustomEvent === 'function') {
evt = new CustomEvent(evtType, {
bubbles: shouldBubble,
detail: evtData,
});
}
else {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent(evtType, shouldBubble, false, evtData);
}
this.root_.dispatchEvent(evt);
};
return MDCComponent;
}());
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
/* harmony default export */ __webpack_exports__["default"] = (MDCComponent);
//# sourceMappingURL=component.js.map
/***/ }),
/***/ "./node_modules/@material/base/foundation.js":
/*!***************************************************!*\
!*** ./node_modules/@material/base/foundation.js ***!
\***************************************************/
/*! exports provided: MDCFoundation, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCFoundation", function() { return MDCFoundation; });
/**
* @license
* Copyright 2016 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var MDCFoundation = /** @class */ (function () {
function MDCFoundation(adapter) {
if (adapter === void 0) { adapter = {}; }
this.adapter_ = adapter;
}
Object.defineProperty(MDCFoundation, "cssClasses", {
get: function () {
// Classes extending MDCFoundation should implement this method to return an object which exports every
// CSS class the foundation class needs as a property. e.g. {ACTIVE: 'mdc-component--active'}
return {};
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCFoundation, "strings", {
get: function () {
// Classes extending MDCFoundation should implement this method to return an object which exports all
// semantic strings as constants. e.g. {ARIA_ROLE: 'tablist'}
return {};
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCFoundation, "numbers", {
get: function () {
// Classes extending MDCFoundation should implement this method to return an object which exports all
// of its semantic numbers as constants. e.g. {ANIMATION_DELAY_MS: 350}
return {};
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCFoundation, "defaultAdapter", {
get: function () {
// Classes extending MDCFoundation may choose to implement this getter in order to provide a convenient
// way of viewing the necessary methods of an adapter. In the future, this could also be used for adapter
// validation.
return {};
},
enumerable: true,
configurable: true
});
MDCFoundation.prototype.init = function () {
// Subclasses should override this method to perform initialization routines (registering events, etc.)
};
MDCFoundation.prototype.destroy = function () {
// Subclasses should override this method to perform de-initialization routines (de-registering events, etc.)
};
return MDCFoundation;
}());
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
/* harmony default export */ __webpack_exports__["default"] = (MDCFoundation);
//# sourceMappingURL=foundation.js.map
/***/ }),
/***/ "./node_modules/@material/slider/component.js":
/*!****************************************************!*\
!*** ./node_modules/@material/slider/component.js ***!
\****************************************************/
/*! exports provided: MDCSlider */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCSlider", function() { return MDCSlider; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
/* harmony import */ var _material_base_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @material/base/component */ "./node_modules/@material/base/component.js");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./constants */ "./node_modules/@material/slider/constants.js");
/* harmony import */ var _foundation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./foundation */ "./node_modules/@material/slider/foundation.js");
/**
* @license
* Copyright 2017 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var MDCSlider = /** @class */ (function (_super) {
tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MDCSlider, _super);
function MDCSlider() {
return _super !== null && _super.apply(this, arguments) || this;
}
MDCSlider.attachTo = function (root) {
return new MDCSlider(root);
};
Object.defineProperty(MDCSlider.prototype, "value", {
get: function () {
return this.foundation_.getValue();
},
set: function (value) {
this.foundation_.setValue(value);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCSlider.prototype, "min", {
get: function () {
return this.foundation_.getMin();
},
set: function (min) {
this.foundation_.setMin(min);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCSlider.prototype, "max", {
get: function () {
return this.foundation_.getMax();
},
set: function (max) {
this.foundation_.setMax(max);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCSlider.prototype, "step", {
get: function () {
return this.foundation_.getStep();
},
set: function (step) {
this.foundation_.setStep(step);
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCSlider.prototype, "disabled", {
get: function () {
return this.foundation_.isDisabled();
},
set: function (disabled) {
this.foundation_.setDisabled(disabled);
},
enumerable: true,
configurable: true
});
MDCSlider.prototype.initialize = function () {
this.thumbContainer_ = this.root_.querySelector(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].THUMB_CONTAINER_SELECTOR);
this.track_ = this.root_.querySelector(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].TRACK_SELECTOR);
this.pinValueMarker_ = this.root_.querySelector(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].PIN_VALUE_MARKER_SELECTOR);
this.trackMarkerContainer_ = this.root_.querySelector(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].TRACK_MARKER_CONTAINER_SELECTOR);
};
MDCSlider.prototype.getDefaultFoundation = function () {
var _this = this;
// DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>.
// To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable.
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
var adapter = {
hasClass: function (className) { return _this.root_.classList.contains(className); },
addClass: function (className) { return _this.root_.classList.add(className); },
removeClass: function (className) { return _this.root_.classList.remove(className); },
getAttribute: function (name) { return _this.root_.getAttribute(name); },
setAttribute: function (name, value) { return _this.root_.setAttribute(name, value); },
removeAttribute: function (name) { return _this.root_.removeAttribute(name); },
computeBoundingRect: function () { return _this.root_.getBoundingClientRect(); },
getTabIndex: function () { return _this.root_.tabIndex; },
registerInteractionHandler: function (evtType, handler) { return _this.listen(evtType, handler); },
deregisterInteractionHandler: function (evtType, handler) { return _this.unlisten(evtType, handler); },
registerThumbContainerInteractionHandler: function (evtType, handler) {
_this.thumbContainer_.addEventListener(evtType, handler);
},
deregisterThumbContainerInteractionHandler: function (evtType, handler) {
_this.thumbContainer_.removeEventListener(evtType, handler);
},
registerBodyInteractionHandler: function (evtType, handler) { return document.body.addEventListener(evtType, handler); },
deregisterBodyInteractionHandler: function (evtType, handler) { return document.body.removeEventListener(evtType, handler); },
registerResizeHandler: function (handler) { return window.addEventListener('resize', handler); },
deregisterResizeHandler: function (handler) { return window.removeEventListener('resize', handler); },
notifyInput: function () { return _this.emit(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].INPUT_EVENT, _this); },
notifyChange: function () { return _this.emit(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].CHANGE_EVENT, _this); },
setThumbContainerStyleProperty: function (propertyName, value) {
_this.thumbContainer_.style.setProperty(propertyName, value);
},
setTrackStyleProperty: function (propertyName, value) { return _this.track_.style.setProperty(propertyName, value); },
setMarkerValue: function (value) { return _this.pinValueMarker_.innerText = value.toLocaleString(); },
appendTrackMarkers: function (numMarkers) {
var frag = document.createDocumentFragment();
for (var i = 0; i < numMarkers; i++) {
var marker = document.createElement('div');
marker.classList.add('mdc-slider__track-marker');
frag.appendChild(marker);
}
_this.trackMarkerContainer_.appendChild(frag);
},
removeTrackMarkers: function () {
while (_this.trackMarkerContainer_.firstChild) {
_this.trackMarkerContainer_.removeChild(_this.trackMarkerContainer_.firstChild);
}
},
setLastTrackMarkersStyleProperty: function (propertyName, value) {
// We remove and append new nodes, thus, the last track marker must be dynamically found.
var lastTrackMarker = _this.root_.querySelector(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].LAST_TRACK_MARKER_SELECTOR);
lastTrackMarker.style.setProperty(propertyName, value);
},
isRTL: function () { return getComputedStyle(_this.root_).direction === 'rtl'; },
};
// tslint:enable:object-literal-sort-keys
return new _foundation__WEBPACK_IMPORTED_MODULE_3__["MDCSliderFoundation"](adapter);
};
MDCSlider.prototype.initialSyncWithDOM = function () {
var origValueNow = this.parseFloat_(this.root_.getAttribute(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].ARIA_VALUENOW), this.value);
var min = this.parseFloat_(this.root_.getAttribute(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].ARIA_VALUEMIN), this.min);
var max = this.parseFloat_(this.root_.getAttribute(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].ARIA_VALUEMAX), this.max);
// min and max need to be set in the right order to avoid throwing an error
// when the new min is greater than the default max.
if (min >= this.max) {
this.max = max;
this.min = min;
}
else {
this.min = min;
this.max = max;
}
this.step = this.parseFloat_(this.root_.getAttribute(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].STEP_DATA_ATTR), this.step);
this.value = origValueNow;
this.disabled = (this.root_.hasAttribute(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].ARIA_DISABLED) &&
this.root_.getAttribute(_constants__WEBPACK_IMPORTED_MODULE_2__["strings"].ARIA_DISABLED) !== 'false');
this.foundation_.setupTrackMarker();
};
MDCSlider.prototype.layout = function () {
this.foundation_.layout();
};
MDCSlider.prototype.stepUp = function (amount) {
if (amount === void 0) { amount = (this.step || 1); }
this.value += amount;
};
MDCSlider.prototype.stepDown = function (amount) {
if (amount === void 0) { amount = (this.step || 1); }
this.value -= amount;
};
MDCSlider.prototype.parseFloat_ = function (str, defaultValue) {
var num = parseFloat(str); // tslint:disable-line:ban
var isNumeric = typeof num === 'number' && isFinite(num);
return isNumeric ? num : defaultValue;
};
return MDCSlider;
}(_material_base_component__WEBPACK_IMPORTED_MODULE_1__["MDCComponent"]));
//# sourceMappingURL=component.js.map
/***/ }),
/***/ "./node_modules/@material/slider/constants.js":
/*!****************************************************!*\
!*** ./node_modules/@material/slider/constants.js ***!
\****************************************************/
/*! exports provided: cssClasses, strings, numbers */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cssClasses", function() { return cssClasses; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "strings", function() { return strings; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "numbers", function() { return numbers; });
/**
* @license
* Copyright 2017 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var cssClasses = {
ACTIVE: 'mdc-slider--active',
DISABLED: 'mdc-slider--disabled',
DISCRETE: 'mdc-slider--discrete',
FOCUS: 'mdc-slider--focus',
HAS_TRACK_MARKER: 'mdc-slider--display-markers',
IN_TRANSIT: 'mdc-slider--in-transit',
IS_DISCRETE: 'mdc-slider--discrete',
};
var strings = {
ARIA_DISABLED: 'aria-disabled',
ARIA_VALUEMAX: 'aria-valuemax',
ARIA_VALUEMIN: 'aria-valuemin',
ARIA_VALUENOW: 'aria-valuenow',
CHANGE_EVENT: 'MDCSlider:change',
INPUT_EVENT: 'MDCSlider:input',
LAST_TRACK_MARKER_SELECTOR: '.mdc-slider__track-marker:last-child',
PIN_VALUE_MARKER_SELECTOR: '.mdc-slider__pin-value-marker',
STEP_DATA_ATTR: 'data-step',
THUMB_CONTAINER_SELECTOR: '.mdc-slider__thumb-container',
TRACK_MARKER_CONTAINER_SELECTOR: '.mdc-slider__track-marker-container',
TRACK_SELECTOR: '.mdc-slider__track',
};
var numbers = {
PAGE_FACTOR: 4,
};
//# sourceMappingURL=constants.js.map
/***/ }),
/***/ "./node_modules/@material/slider/foundation.js":
/*!*****************************************************!*\
!*** ./node_modules/@material/slider/foundation.js ***!
\*****************************************************/
/*! exports provided: MDCSliderFoundation, default */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MDCSliderFoundation", function() { return MDCSliderFoundation; });
/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js");
/* harmony import */ var _material_animation_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @material/animation/util */ "./node_modules/@material/animation/util.js");
/* harmony import */ var _material_base_foundation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @material/base/foundation */ "./node_modules/@material/base/foundation.js");
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./constants */ "./node_modules/@material/slider/constants.js");
/**
* @license
* Copyright 2017 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var DOWN_EVENTS = ['mousedown', 'pointerdown', 'touchstart'];
var UP_EVENTS = ['mouseup', 'pointerup', 'touchend'];
var MOVE_EVENT_MAP = {
mousedown: 'mousemove',
pointerdown: 'pointermove',
touchstart: 'touchmove',
};
var KEY_IDS = {
ARROW_DOWN: 'ArrowDown',
ARROW_LEFT: 'ArrowLeft',
ARROW_RIGHT: 'ArrowRight',
ARROW_UP: 'ArrowUp',
END: 'End',
HOME: 'Home',
PAGE_DOWN: 'PageDown',
PAGE_UP: 'PageUp',
};
var MDCSliderFoundation = /** @class */ (function (_super) {
tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MDCSliderFoundation, _super);
function MDCSliderFoundation(adapter) {
var _this = _super.call(this, tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, MDCSliderFoundation.defaultAdapter, adapter)) || this;
/**
* We set this to NaN since we want it to be a number, but we can't use '0' or '-1'
* because those could be valid tabindices set by the client code.
*/
_this.savedTabIndex_ = NaN;
_this.active_ = false;
_this.inTransit_ = false;
_this.isDiscrete_ = false;
_this.hasTrackMarker_ = false;
_this.handlingThumbTargetEvt_ = false;
_this.min_ = 0;
_this.max_ = 100;
_this.step_ = 0;
_this.value_ = 0;
_this.disabled_ = false;
_this.preventFocusState_ = false;
_this.thumbContainerPointerHandler_ = function () { return _this.handlingThumbTargetEvt_ = true; };
_this.interactionStartHandler_ = function (evt) { return _this.handleDown_(evt); };
_this.keydownHandler_ = function (evt) { return _this.handleKeydown_(evt); };
_this.focusHandler_ = function () { return _this.handleFocus_(); };
_this.blurHandler_ = function () { return _this.handleBlur_(); };
_this.resizeHandler_ = function () { return _this.layout(); };
return _this;
}
Object.defineProperty(MDCSliderFoundation, "cssClasses", {
get: function () {
return _constants__WEBPACK_IMPORTED_MODULE_3__["cssClasses"];
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCSliderFoundation, "strings", {
get: function () {
return _constants__WEBPACK_IMPORTED_MODULE_3__["strings"];
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCSliderFoundation, "numbers", {
get: function () {
return _constants__WEBPACK_IMPORTED_MODULE_3__["numbers"];
},
enumerable: true,
configurable: true
});
Object.defineProperty(MDCSliderFoundation, "defaultAdapter", {
get: function () {
// tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
return {
hasClass: function () { return false; },
addClass: function () { return undefined; },
removeClass: function () { return undefined; },
getAttribute: function () { return null; },
setAttribute: function () { return undefined; },
removeAttribute: function () { return undefined; },
computeBoundingRect: function () { return ({ top: 0, right: 0, bottom: 0, left: 0, width: 0, height: 0 }); },
getTabIndex: function () { return 0; },
registerInteractionHandler: function () { return undefined; },
deregisterInteractionHandler: function () { return undefined; },
registerThumbContainerInteractionHandler: function () { return undefined; },
deregisterThumbContainerInteractionHandler: function () { return undefined; },
registerBodyInteractionHandler: function () { return undefined; },
deregisterBodyInteractionHandler: function () { return undefined; },
registerResizeHandler: function () { return undefined; },
deregisterResizeHandler: function () { return undefined; },
notifyInput: function () { return undefined; },
notifyChange: function () { return undefined; },
setThumbContainerStyleProperty: function () { return undefined; },
setTrackStyleProperty: function () { return undefined; },
setMarkerValue: function () { return undefined; },
appendTrackMarkers: function () { return undefined; },
removeTrackMarkers: function () { return undefined; },
setLastTrackMarkersStyleProperty: function () { return undefined; },
isRTL: function () { return false; },
};
// tslint:enable:object-literal-sort-keys
},
enumerable: true,
configurable: true
});
MDCSliderFoundation.prototype.init = function () {
var _this = this;
this.isDiscrete_ = this.adapter_.hasClass(_constants__WEBPACK_IMPORTED_MODULE_3__["cssClasses"].IS_DISCRETE);
this.hasTrackMarker_ = this.adapter_.hasClass(_constants__WEBPACK_IMPORTED_MODULE_3__["cssClasses"].HAS_TRACK_MARKER);
DOWN_EVENTS.forEach(function (evtName) {
_this.adapter_.registerInteractionHandler(evtName, _this.interactionStartHandler_);
_this.adapter_.registerThumbContainerInteractionHandler(evtName, _this.thumbContainerPointerHandler_);
});
this.adapter_.registerInteractionHandler('keydown', this.keydownHandler_);
this.adapter_.registerInteractionHandler('focus', this.focusHandler_);
this.adapter_.registerInteractionHandler('blur', this.blurHandler_);
this.adapter_.registerResizeHandler(this.resizeHandler_);
this.layout();
// At last step, provide a reasonable default value to discrete slider
if (this.isDiscrete_ && this.getStep() === 0) {
this.step_ = 1;
}
};
MDCSliderFoundation.prototype.destroy = function () {
var _this = this;
DOWN_EVENTS.forEach(function (evtName) {
_this.adapter_.deregisterInteractionHandler(evtName, _this.interactionStartHandler_);
_this.adapter_.deregisterThumbContainerInteractionHandler(evtName, _this.thumbContainerPointerHandler_);
});
this.adapter_.deregisterInteractionHandler('keydown', this.keydownHandler_);
this.adapter_.deregisterInteractionHandler('focus', this.focusHandler_);
this.adapter_.deregisterInteractionHandler('blur', this.blurHandler_);
this.adapter_.deregisterResizeHandler(this.resizeHandler_);
};
MDCSliderFoundation.prototype.setupTrackMarker = function () {
if (this.isDiscrete_ && this.hasTrackMarker_ && this.getStep() !== 0) {
var min = this.getMin();
var max = this.getMax();
var step = this.getStep();
var numMarkers = (max - min) / step;
// In case distance between max & min is indivisible to step,
// we place the secondary to last marker proportionally at where thumb
// could reach and place the last marker at max value
var indivisible = Math.ceil(numMarkers) !== numMarkers;
if (indivisible) {
numMarkers = Math.ceil(numMarkers);
}
this.adapter_.removeTrackMarkers();
this.adapter_.appendTrackMarkers(numMarkers);
if (indivisible) {
var lastStepRatio = (max - numMarkers * step) / step + 1;
this.adapter_.setLastTrackMarkersStyleProperty('flex-grow', String(lastStepRatio));
}
}
};
MDCSliderFoundation.prototype.layout = function () {
this.rect_ = this.adapter_.computeBoundingRect();
this.updateUIForCurrentValue_();
};
MDCSliderFoundation.prototype.getValue = function () {
return this.value_;
};
MDCSliderFoundation.prototype.setValue = function (value) {
this.setValue_(value, false);
};
MDCSliderFoundation.prototype.getMax = function () {
return this.max_;
};
MDCSliderFoundation.prototype.setMax = function (max) {
if (max < this.min_) {
throw new Error('Cannot set max to be less than the slider\'s minimum value');
}
this.max_ = max;
this.setValue_(this.value_, false, true);
this.adapter_.setAttribute(_constants__WEBPACK_IMPORTED_MODULE_3__["strings"].ARIA_VALUEMAX, String(this.max_));
this.setupTrackMarker();
};
MDCSliderFoundation.prototype.getMin = function () {
return this.min_;
};
MDCSliderFoundation.prototype.setMin = function (min) {
if (min > this.max_) {
throw new Error('Cannot set min to be greater than the slider\'s maximum value');
}
this.min_ = min;
this.setValue_(this.value_, false, true);
this.adapter_.setAttribute(_constants__WEBPACK_IMPORTED_MODULE_3__["strings"].ARIA_VALUEMIN, String(this.min_));
this.setupTrackMarker();
};
MDCSliderFoundation.prototype.getStep = function () {
return this.step_;
};
MDCSliderFoundation.prototype.setStep = function (step) {
if (step < 0) {
throw new Error('Step cannot be set to a negative number');
}
if (this.isDiscrete_ && (typeof (step) !== 'number' || step < 1)) {
step = 1;
}
this.step_ = step;
this.setValue_(this.value_, false, true);
this.setupTrackMarker();
};
MDCSliderFoundation.prototype.isDisabled = function () {
return this.disabled_;
};
MDCSliderFoundation.prototype.setDisabled = function (disabled) {
this.disabled_ = disabled;
this.toggleClass_(_constants__WEBPACK_IMPORTED_MODULE_3__["cssClasses"].DISABLED, this.disabled_);
if (this.disabled_) {
this.savedTabIndex_ = this.adapter_.getTabIndex();
this.adapter_.setAttribute(_constants__WEBPACK_IMPORTED_MODULE_3__["strings"].ARIA_DISABLED, 'true');
this.adapter_.removeAttribute('tabindex');
}
else {
this.adapter_.removeAttribute(_constants__WEBPACK_IMPORTED_MODULE_3__["strings"].ARIA_DISABLED);
if (!isNaN(this.savedTabIndex_)) {
this.adapter_.setAttribute('tabindex', String(this.savedTabIndex_));
}
}
};
/**
* Called when the user starts interacting with the slider
*/
MDCSliderFoundation.prototype.handleDown_ = function (downEvent) {
var _this = this;
if (this.disabled_) {
return;
}
this.preventFocusState_ = true;
this.setInTransit_(!this.handlingThumbTargetEvt_);
this.handlingThumbTargetEvt_ = false;
this.setActive_(true);
var moveHandler = function (moveEvent) {
_this.handleMove_(moveEvent);
};
var moveEventType = MOVE_EVENT_MAP[downEvent.type];
// Note: upHandler is [de]registered on ALL potential pointer-related release event types, since some browsers
// do not always fire these consistently in pairs.
// (See https://github.com/material-components/material-components-web/issues/1192)
var upHandler = function () {
_this.handleUp_();
_this.adapter_.deregisterBodyInteractionHandler(moveEventType, moveHandler);
UP_EVENTS.forEach(function (evtName) { return _this.adapter_.deregisterBodyInteractionHandler(evtName, upHandler); });
};
this.adapter_.registerBodyInteractionHandler(moveEventType, moveHandler);
UP_EVENTS.forEach(function (evtName) { return _this.adapter_.registerBodyInteractionHandler(evtName, upHandler); });
this.setValueFromEvt_(downEvent);
};
/**
* Called when the user moves the slider
*/
MDCSliderFoundation.prototype.handleMove_ = function (evt) {
evt.preventDefault();
this.setValueFromEvt_(evt);
};
/**
* Called when the user's interaction with the slider ends
*/
MDCSliderFoundation.prototype.handleUp_ = function () {
this.setActive_(false);
this.adapter_.notifyChange();
};
/**
* Returns the pageX of the event
*/
MDCSliderFoundation.prototype.getPageX_ = function (evt) {
if (evt.targetTouches && evt.targetTouches.length > 0) {
return evt.targetTouches[0].pageX;
}
return evt.pageX;
};
/**
* Sets the slider value from an event
*/
MDCSliderFoundation.prototype.setValueFromEvt_ = function (evt) {
var pageX = this.getPageX_(evt);
var value = this.computeValueFromPageX_(pageX);
this.setValue_(value, true);
};
/**
* Computes the new value from the pageX position
*/
MDCSliderFoundation.prototype.computeValueFromPageX_ = function (pageX) {
var _a = this, max = _a.max_, min = _a.min_;
var xPos = pageX - this.rect_.left;
var pctComplete = xPos / this.rect_.width;
if (this.adapter_.isRTL()) {
pctComplete = 1 - pctComplete;
}
// Fit the percentage complete between the range [min,max]
// by remapping from [0, 1] to [min, min+(max-min)].
return min + pctComplete * (max - min);
};
/**
* Handles keydown events
*/
MDCSliderFoundation.prototype.handleKeydown_ = function (evt) {
var keyId = this.getKeyId_(evt);
var value = this.getValueForKeyId_(keyId);
if (isNaN(value)) {
return;
}
// Prevent page from scrolling due to key presses that would normally scroll the page
evt.preventDefault();
this.adapter_.addClass(_constants__WEBPACK_IMPORTED_MODULE_3__["cssClasses"].FOCUS);
this.setValue_(value, true);
this.adapter_.notifyChange();
};
/**
* Returns the computed name of the event
*/
MDCSliderFoundation.prototype.getKeyId_ = function (kbdEvt) {
if (kbdEvt.key === KEY_IDS.ARROW_LEFT || kbdEvt.keyCode === 37) {
return KEY_IDS.ARROW_LEFT;
}
if (kbdEvt.key === KEY_IDS.ARROW_RIGHT || kbdEvt.keyCode === 39) {
return KEY_IDS.ARROW_RIGHT;
}
if (kbdEvt.key === KEY_IDS.ARROW_UP || kbdEvt.keyCode === 38) {
return KEY_IDS.ARROW_UP;
}
if (kbdEvt.key === KEY_IDS.ARROW_DOWN || kbdEvt.keyCode === 40) {
return KEY_IDS.ARROW_DOWN;
}
if (kbdEvt.key === KEY_IDS.HOME || kbdEvt.keyCode === 36) {
return KEY_IDS.HOME;
}
if (kbdEvt.key === KEY_IDS.END || kbdEvt.keyCode === 35) {
return KEY_IDS.END;
}
if (kbdEvt.key === KEY_IDS.PAGE_UP || kbdEvt.keyCode === 33) {
return KEY_IDS.PAGE_UP;
}
if (kbdEvt.key === KEY_IDS.PAGE_DOWN || kbdEvt.keyCode === 34) {
return KEY_IDS.PAGE_DOWN;
}
return '';
};
/**
* Computes the value given a keyboard key ID
*/
MDCSliderFoundation.prototype.getValueForKeyId_ = function (keyId) {
var _a = this, max = _a.max_, min = _a.min_, step = _a.step_;
var delta = step || (max - min) / 100;
var valueNeedsToBeFlipped = this.adapter_.isRTL() && (keyId === KEY_IDS.ARROW_LEFT || keyId === KEY_IDS.ARROW_RIGHT);
if (valueNeedsToBeFlipped) {
delta = -delta;
}
switch (keyId) {
case KEY_IDS.ARROW_LEFT:
case KEY_IDS.ARROW_DOWN:
return this.value_ - delta;
case KEY_IDS.ARROW_RIGHT:
case KEY_IDS.ARROW_UP:
return this.value_ + delta;
case KEY_IDS.HOME:
return this.min_;