UNPKG

@uifabric/merge-styles

Version:
1,121 lines (999 loc) 66.9 kB
var MergeStyles = /******/ (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 = "./lib/index.js"); /******/ }) /************************************************************************/ /******/ ({ /***/ "../../node_modules/tslib/tslib.es6.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spreadArrays", function() { return __spreadArrays; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; }); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; } return __assign.apply(this, arguments); } function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { 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; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __exportStar(m, exports) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; } function __values(o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; 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); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; 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; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; 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); 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); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result.default = mod; return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } /***/ }), /***/ "../set-version/lib/index.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _setVersion__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../set-version/lib/setVersion.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "setVersion", function() { return _setVersion__WEBPACK_IMPORTED_MODULE_0__["setVersion"]; }); Object(_setVersion__WEBPACK_IMPORTED_MODULE_0__["setVersion"])('@uifabric/set-version', '6.0.0'); /***/ }), /***/ "../set-version/lib/setVersion.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setVersion", function() { return setVersion; }); // A packages cache that makes sure that we don't inject the same packageName twice in the same bundle - // this cache is local to the module closure inside this bundle var packagesCache = {}; // Cache access to window to avoid IE11 memory leak. var _win = undefined; try { _win = window; } catch (e) { /* no-op */ } function setVersion(packageName, packageVersion) { if (typeof _win !== 'undefined') { // eslint-disable-next-line @typescript-eslint/no-explicit-any var packages = (_win.__packages__ = _win.__packages__ || {}); // We allow either the global packages or local packages caches to invalidate so testing can // just clear the global to set this state if (!packages[packageName] || !packagesCache[packageName]) { packagesCache[packageName] = packageVersion; var versions = (packages[packageName] = packages[packageName] || []); versions.push(packageVersion); } } } /***/ }), /***/ "./lib/StyleOptionsState.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setRTL", function() { return setRTL; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getRTL", function() { return getRTL; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getStyleOptions", function() { return getStyleOptions; }); /** * Sets the current RTL value. */ function setRTL(isRTL) { if (_rtl !== isRTL) { _rtl = isRTL; } } /** * Gets the current RTL value. */ function getRTL() { if (_rtl === undefined) { _rtl = typeof document !== 'undefined' && !!document.documentElement && document.documentElement.getAttribute('dir') === 'rtl'; } return _rtl; } // This has been split into 2 lines because it was working in Fabric due to the code being transpiled to es5, so this // was converted to var while not working in Fluent that uses babel to transpile the code to be es6-like. Splitting the // logic into two lines, however, allows it to work in both scenarios. var _rtl; _rtl = getRTL(); function getStyleOptions() { return { rtl: getRTL(), }; } /***/ }), /***/ "./lib/Stylesheet.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InjectionMode", function() { return InjectionMode; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stylesheet", function() { return Stylesheet; }); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/tslib/tslib.es6.js"); var InjectionMode = { /** * Avoids style injection, use getRules() to read the styles. */ none: 0, /** * Inserts rules using the insertRule api. */ insertNode: 1, /** * Appends rules using appendChild. */ appendChild: 2, }; var STYLESHEET_SETTING = '__stylesheet__'; /** * MSIE 11 doesn't cascade styles based on DOM ordering, but rather on the order that each style node * is created. As such, to maintain consistent priority, IE11 should reuse a single style node. */ var REUSE_STYLE_NODE = typeof navigator !== 'undefined' && /rv:11.0/.test(navigator.userAgent); var _global = {}; // Grab window. try { _global = window; } catch (_a) { /* leave as blank object */ } var _stylesheet; /** * Represents the state of styles registered in the page. Abstracts * the surface for adding styles to the stylesheet, exposes helpers * for reading the styles registered in server rendered scenarios. * * @public */ var Stylesheet = /** @class */ (function () { function Stylesheet(config) { this._rules = []; this._preservedRules = []; this._rulesToInsert = []; this._counter = 0; this._keyToClassName = {}; this._onResetCallbacks = []; this._classNameToArgs = {}; this._config = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ injectionMode: InjectionMode.insertNode, defaultPrefix: 'css', namespace: undefined, cspSettings: undefined }, config); this._keyToClassName = this._config.classNameCache || {}; } /** * Gets the singleton instance. */ Stylesheet.getInstance = function () { var _a; _stylesheet = _global[STYLESHEET_SETTING]; if (!_stylesheet || (_stylesheet._lastStyleElement && _stylesheet._lastStyleElement.ownerDocument !== document)) { var fabricConfig = ((_a = _global) === null || _a === void 0 ? void 0 : _a.FabricConfig) || {}; _stylesheet = _global[STYLESHEET_SETTING] = new Stylesheet(fabricConfig.mergeStyles); } return _stylesheet; }; /** * Configures the stylesheet. */ Stylesheet.prototype.setConfig = function (config) { this._config = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, this._config), config); }; /** * Configures a reset callback. * * @param callback - A callback which will be called when the Stylesheet is reset. */ Stylesheet.prototype.onReset = function (callback) { this._onResetCallbacks.push(callback); }; /** * Generates a unique classname. * * @param displayName - Optional value to use as a prefix. */ Stylesheet.prototype.getClassName = function (displayName) { var namespace = this._config.namespace; var prefix = displayName || this._config.defaultPrefix; return "" + (namespace ? namespace + '-' : '') + prefix + "-" + this._counter++; }; /** * Used internally to cache information about a class which was * registered with the stylesheet. */ Stylesheet.prototype.cacheClassName = function (className, key, args, rules) { this._keyToClassName[key] = className; this._classNameToArgs[className] = { args: args, rules: rules, }; }; /** * Gets the appropriate classname given a key which was previously * registered using cacheClassName. */ Stylesheet.prototype.classNameFromKey = function (key) { return this._keyToClassName[key]; }; /** * Gets all classnames cache with the stylesheet. */ Stylesheet.prototype.getClassNameCache = function () { return this._keyToClassName; }; /** * Gets the arguments associated with a given classname which was * previously registered using cacheClassName. */ Stylesheet.prototype.argsFromClassName = function (className) { var entry = this._classNameToArgs[className]; return entry && entry.args; }; /** * Gets the arguments associated with a given classname which was * previously registered using cacheClassName. */ Stylesheet.prototype.insertedRulesFromClassName = function (className) { var entry = this._classNameToArgs[className]; return entry && entry.rules; }; /** * Inserts a css rule into the stylesheet. * @param preserve - Preserves the rule beyond a reset boundary. */ Stylesheet.prototype.insertRule = function (rule, preserve) { var injectionMode = this._config.injectionMode; var element = injectionMode !== InjectionMode.none ? this._getStyleElement() : undefined; if (preserve) { this._preservedRules.push(rule); } if (element) { switch (this._config.injectionMode) { case InjectionMode.insertNode: var sheet = element.sheet; try { sheet.insertRule(rule, sheet.cssRules.length); } catch (e) { // The browser will throw exceptions on unsupported rules (such as a moz prefix in webkit.) // We need to swallow the exceptions for this scenario, otherwise we'd need to filter // which could be slower and bulkier. } break; case InjectionMode.appendChild: element.appendChild(document.createTextNode(rule)); break; } } else { this._rules.push(rule); } if (this._config.onInsertRule) { this._config.onInsertRule(rule); } }; /** * Gets all rules registered with the stylesheet; only valid when * using InsertionMode.none. */ Stylesheet.prototype.getRules = function (includePreservedRules) { return ((includePreservedRules ? this._preservedRules.join('') : '') + this._rules.join('') + this._rulesToInsert.join('')); }; /** * Resets the internal state of the stylesheet. Only used in server * rendered scenarios where we're using InsertionMode.none. */ Stylesheet.prototype.reset = function () { this._rules = []; this._rulesToInsert = []; this._counter = 0; this._classNameToArgs = {}; this._keyToClassName = {}; this._onResetCallbacks.forEach(function (callback) { return callback(); }); }; // Forces the regeneration of incoming styles without totally resetting the stylesheet. Stylesheet.prototype.resetKeys = function () { this._keyToClassName = {}; }; Stylesheet.prototype._getStyleElement = function () { var _this = this; if (!this._styleElement && typeof document !== 'undefined') { this._styleElement = this._createStyleElement(); if (!REUSE_STYLE_NODE) { // Reset the style element on the next frame. window.requestAnimationFrame(function () { _this._styleElement = undefined; }); } } return this._styleElement; }; Stylesheet.prototype._createStyleElement = function () { var head = document.head; var styleElement = document.createElement('style'); var nodeToInsertBefore = null; styleElement.setAttribute('data-merge-styles', 'true'); var cspSettings = this._config.cspSettings; if (cspSettings) { if (cspSettings.nonce) { styleElement.setAttribute('nonce', cspSettings.nonce); } } if (this._lastStyleElement) { // If the `nextElementSibling` is null, then the insertBefore will act as a regular append. // https://developer.mozilla.org/en-US/docs/Web/API/Node/insertBefore#Syntax nodeToInsertBefore = this._lastStyleElement.nextElementSibling; } else { var placeholderStyleTag = this._findPlaceholderStyleTag(); if (placeholderStyleTag) { nodeToInsertBefore = placeholderStyleTag.nextElementSibling; } else { nodeToInsertBefore = head.childNodes[0]; } } head.insertBefore(styleElement, head.contains(nodeToInsertBefore) ? nodeToInsertBefore : null); this._lastStyleElement = styleElement; return styleElement; }; Stylesheet.prototype._findPlaceholderStyleTag = function () { var head = document.head; if (head) { return head.querySelector('style[data-merge-styles]'); } return null; }; return Stylesheet; }()); /***/ }), /***/ "./lib/concatStyleSets.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "concatStyleSets", function() { return concatStyleSets; }); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/tslib/tslib.es6.js"); /** * Combine a set of styles together (but does not register css classes). * @param styleSets - One or more stylesets to be merged (each param can also be falsy). */ function concatStyleSets() { var styleSets = []; for (var _i = 0; _i < arguments.length; _i++) { styleSets[_i] = arguments[_i]; } if (styleSets && styleSets.length === 1 && styleSets[0] && !styleSets[0].subComponentStyles) { return styleSets[0]; } var mergedSet = {}; // We process sub component styles in two phases. First we collect them, then we combine them into 1 style function. var workingSubcomponentStyles = {}; for (var _a = 0, styleSets_1 = styleSets; _a < styleSets_1.length; _a++) { var currentSet = styleSets_1[_a]; if (currentSet) { for (var prop in currentSet) { if (currentSet.hasOwnProperty(prop)) { if (prop === 'subComponentStyles' && currentSet.subComponentStyles !== undefined) { // subcomponent styles - style functions or objects var currentComponentStyles = currentSet.subComponentStyles; for (var subCompProp in currentComponentStyles) { if (currentComponentStyles.hasOwnProperty(subCompProp)) { if (workingSubcomponentStyles.hasOwnProperty(subCompProp)) { workingSubcomponentStyles[subCompProp].push(currentComponentStyles[subCompProp]); } else { workingSubcomponentStyles[subCompProp] = [currentComponentStyles[subCompProp]]; } } } continue; } // the as any casts below is a workaround for ts 2.8. // todo: remove cast to any in ts 2.9. var mergedValue = mergedSet[prop]; var currentValue = currentSet[prop]; if (mergedValue === undefined) { mergedSet[prop] = currentValue; } else { mergedSet[prop] = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__spreadArrays"])((Array.isArray(mergedValue) ? mergedValue : [mergedValue]), (Array.isArray(currentValue) ? currentValue : [currentValue])); } } } } } if (Object.keys(workingSubcomponentStyles).length > 0) { mergedSet.subComponentStyles = {}; var mergedSubStyles = mergedSet.subComponentStyles; var _loop_1 = function (subCompProp) { if (workingSubcomponentStyles.hasOwnProperty(subCompProp)) { var workingSet_1 = workingSubcomponentStyles[subCompProp]; mergedSubStyles[subCompProp] = function (styleProps) { return concatStyleSets.apply(void 0, workingSet_1.map(function (styleFunctionOrObject) { return typeof styleFunctionOrObject === 'function' ? styleFunctionOrObject(styleProps) : styleFunctionOrObject; })); }; } }; // now we process the subcomponent styles if there are any for (var subCompProp in workingSubcomponentStyles) { _loop_1(subCompProp); } } return mergedSet; } /***/ }), /***/ "./lib/concatStyleSetsWithProps.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "concatStyleSetsWithProps", function() { return concatStyleSetsWithProps; }); /* harmony import */ var _concatStyleSets__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib/concatStyleSets.js"); /** * Concatenates style sets into one, but resolves functional sets using the given props. * @param styleProps - Props used to resolve functional sets. * @param allStyles - Style sets, which can be functions or objects. */ function concatStyleSetsWithProps(styleProps) { var allStyles = []; for (var _i = 1; _i < arguments.length; _i++) { allStyles[_i - 1] = arguments[_i]; } var result = []; for (var _a = 0, allStyles_1 = allStyles; _a < allStyles_1.length; _a++) { var styles = allStyles_1[_a]; if (styles) { result.push(typeof styles === 'function' ? styles(styleProps) : styles); } } if (result.length === 1) { return result[0]; } else if (result.length) { // cliffkoh: I cannot figure out how to avoid the cast to any here. // It is something to do with the use of Omit in IStyleSet. // It might not be necessary once Omit becomes part of lib.d.ts (when we remove our own Omit and rely on // the official version). return _concatStyleSets__WEBPACK_IMPORTED_MODULE_0__["concatStyleSets"].apply(void 0, result); } return {}; } /***/ }), /***/ "./lib/extractStyleParts.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractStyleParts", function() { return extractStyleParts; }); /* harmony import */ var _Stylesheet__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib/Stylesheet.js"); /** * Separates the classes and style objects. Any classes that are pre-registered * args are auto expanded into objects. */ function extractStyleParts() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } var classes = []; var objects = []; var stylesheet = _Stylesheet__WEBPACK_IMPORTED_MODULE_0__["Stylesheet"].getInstance(); function _processArgs(argsList) { for (var _i = 0, argsList_1 = argsList; _i < argsList_1.length; _i++) { var arg = argsList_1[_i]; if (arg) { if (typeof arg === 'string') { if (arg.indexOf(' ') >= 0) { _processArgs(arg.split(' ')); } else { var translatedArgs = stylesheet.argsFromClassName(arg); if (translatedArgs) { _processArgs(translatedArgs); } else { // Avoid adding the same class twice. if (classes.indexOf(arg) === -1) { classes.push(arg); } } } } else if (Array.isArray(arg)) { _processArgs(arg); } else if (typeof arg === 'object') { objects.push(arg); } } } } _processArgs(args); return { classes: classes, objects: objects, }; } /***/ }), /***/ "./lib/fontFace.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fontFace", function() { return fontFace; }); /* harmony import */ var _StyleOptionsState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib/StyleOptionsState.js"); /* harmony import */ var _Stylesheet__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./lib/Stylesheet.js"); /* harmony import */ var _styleToClassName__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./lib/styleToClassName.js"); /** * Registers a font face. * @public */ function fontFace(font) { _Stylesheet__WEBPACK_IMPORTED_MODULE_1__["Stylesheet"].getInstance().insertRule("@font-face{" + Object(_styleToClassName__WEBPACK_IMPORTED_MODULE_2__["serializeRuleEntries"])(Object(_StyleOptionsState__WEBPACK_IMPORTED_MODULE_0__["getStyleOptions"])(), font) + "}", true); } /***/ }), /***/ "./lib/getVendorSettings.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getVendorSettings", function() { return getVendorSettings; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setVendorSettings", function() { return setVendorSettings; }); var _vendorSettings; function getVendorSettings() { var _a, _b; if (!_vendorSettings) { var doc = typeof document !== 'undefined' ? document : undefined; var nav = typeof navigator !== 'undefined' ? navigator : undefined; var userAgent = (_b = (_a = nav) === null || _a === void 0 ? void 0 : _a.userAgent) === null || _b === void 0 ? void 0 : _b.toLowerCase(); if (!doc) { _vendorSettings = { isWebkit: true, isMoz: true, isOpera: true, isMs: true, }; } else { _vendorSettings = { isWebkit: !!(doc && 'WebkitAppearance' in doc.documentElement.style), isMoz: !!(userAgent && userAgent.indexOf('firefox') > -1), isOpera: !!(userAgent && userAgent.indexOf('opera') > -1), isMs: !!(nav && (/rv:11.0/i.test(nav.userAgent) || /Edge\/\d./i.test(navigator.userAgent))), }; } } return _vendorSettings; } /** * Sets the vendor settings for prefixing and vendor specific operations. */ function setVendorSettings(vendorSettings) { _vendorSettings = vendorSettings; } /***/ }), /***/ "./lib/index.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony import */ var _mergeStyles__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib/mergeStyles.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mergeStyles", function() { return _mergeStyles__WEBPACK_IMPORTED_MODULE_0__["mergeStyles"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mergeCss", function() { return _mergeStyles__WEBPACK_IMPORTED_MODULE_0__["mergeCss"]; }); /* harmony import */ var _mergeStyleSets__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./lib/mergeStyleSets.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mergeStyleSets", function() { return _mergeStyleSets__WEBPACK_IMPORTED_MODULE_1__["mergeStyleSets"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "mergeCssSets", function() { return _mergeStyleSets__WEBPACK_IMPORTED_MODULE_1__["mergeCssSets"]; }); /* harmony import */ var _concatStyleSets__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./lib/concatStyleSets.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "concatStyleSets", function() { return _concatStyleSets__WEBPACK_IMPORTED_MODULE_2__["concatStyleSets"]; }); /* harmony import */ var _concatStyleSetsWithProps__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./lib/concatStyleSetsWithProps.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "concatStyleSetsWithProps", function() { return _concatStyleSetsWithProps__WEBPACK_IMPORTED_MODULE_3__["concatStyleSetsWithProps"]; }); /* harmony import */ var _fontFace__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./lib/fontFace.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "fontFace", function() { return _fontFace__WEBPACK_IMPORTED_MODULE_4__["fontFace"]; }); /* harmony import */ var _keyframes__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("./lib/keyframes.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "keyframes", function() { return _keyframes__WEBPACK_IMPORTED_MODULE_5__["keyframes"]; }); /* harmony import */ var _Stylesheet__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("./lib/Stylesheet.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InjectionMode", function() { return _Stylesheet__WEBPACK_IMPORTED_MODULE_6__["InjectionMode"]; }); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stylesheet", function() { return _Stylesheet__WEBPACK_IMPORTED_MODULE_6__["Stylesheet"]; }); /* harmony import */ var _StyleOptionsState__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("./lib/StyleOptionsState.js"); /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "setRTL", function() { return _StyleOptionsState__WEBPACK_IMPORTED_MODULE_7__["setRTL"]; }); /* harmony import */ var _version__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__("./lib/version.js"); /***/ }), /***/ "./lib/keyframes.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "keyframes", function() { return keyframes; }); /* harmony import */ var _StyleOptionsState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib/StyleOptionsState.js"); /* harmony import */ var _Stylesheet__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./lib/Stylesheet.js"); /* harmony import */ var _styleToClassName__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./lib/styleToClassName.js"); /** * Registers keyframe definitions. * * @public */ function keyframes(timeline) { var stylesheet = _Stylesheet__WEBPACK_IMPORTED_MODULE_1__["Stylesheet"].getInstance(); var name = stylesheet.getClassName(); var rulesArray = []; for (var prop in timeline) { if (timeline.hasOwnProperty(prop)) { rulesArray.push(prop, '{', Object(_styleToClassName__WEBPACK_IMPORTED_MODULE_2__["serializeRuleEntries"])(Object(_StyleOptionsState__WEBPACK_IMPORTED_MODULE_0__["getStyleOptions"])(), timeline[prop]), '}'); } } var rules = rulesArray.join(''); stylesheet.insertRule("@keyframes " + name + "{" + rules + "}", true); stylesheet.cacheClassName(name, rules, [], ['keyframes', rules]); return name; } /***/ }), /***/ "./lib/mergeStyleSets.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mergeStyleSets", function() { return mergeStyleSets; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mergeCssSets", function() { return mergeCssSets; }); /* harmony import */ var _concatStyleSets__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib/concatStyleSets.js"); /* harmony import */ var _extractStyleParts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./lib/extractStyleParts.js"); /* harmony import */ var _StyleOptionsState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./lib/StyleOptionsState.js"); /* harmony import */ var _styleToClassName__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./lib/styleToClassName.js"); /** * Takes in one or more style set objects, each consisting of a set of areas, * each which will produce a class name. Using this is analogous to calling * `mergeStyles` for each property in the object, but ensures we maintain the * set ordering when multiple style sets are merged. * * @param styleSets - One or more style sets to be merged. */ function mergeStyleSets() { var styleSets = []; for (var _i = 0; _i < arguments.length; _i++) { styleSets[_i] = arguments[_i]; } return mergeCssSets(styleSets, Object(_StyleOptionsState__WEBPACK_IMPORTED_MODULE_2__["getStyleOptions"])()); } /** * Takes in one or more style set objects, each1consisting of a set of areas, * each which will produce a class name. Using this is analogous to calling * `mergeCss` for each property in the object, but ensures the * set ordering when multiple style sets are merged. * * @param styleSets - One or more style sets to be merged. * @param options - (optional) Options to use when creating rules. */ function mergeCssSets(styleSets, options) { var _a, _b; var classNameSet = { subComponentStyles: {} }; var styleSet = styleSets[0]; if (!styleSet && styleSets.length <= 1) { return { subComponentStyles: {} }; } var concatenatedStyleSet = _concatStyleSets__WEBPACK_IMPORTED_MODULE_0__["concatStyleSets"].apply(void 0, styleSets); var registrations = []; for (var styleSetArea in concatenatedStyleSet) { if (concatenatedStyleSet.hasOwnProperty(styleSetArea)) { if (styleSetArea === 'subComponentStyles') { classNameSet.subComponentStyles = concatenatedStyleSet.subComponentStyles || {}; continue; } var styles = concatenatedStyleSet[styleSetArea]; var _c = Object(_extractStyleParts__WEBPACK_IMPORTED_MODULE_1__["extractStyleParts"])(styles), classes = _c.classes, objects = _c.objects; if ((_a = objects) === null || _a === void 0 ? void 0 : _a.length) { var registration = Object(_styleToClassName__WEBPACK_IMPORTED_MODULE_3__["styleToRegistration"])(options || {}, { displayName: styleSetArea }, objects); if (registration) { registrations.push(registration); classNameSet[styleSetArea] = classes.concat([registration.className]).join(' '); } } else { classNameSet[styleSetArea] = classes.join(' '); } } } for (var _i = 0, registrations_1 = registrations; _i < registrations_1.length; _i++) { var registration = registrations_1[_i]; if (registration) { Object(_styleToClassName__WEBPACK_IMPORTED_MODULE_3__["applyRegistration"])(registration, (_b = options) === null || _b === void 0 ? void 0 : _b.specificityMultiplier); } } return classNameSet; } /***/ }), /***/ "./lib/mergeStyles.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mergeStyles", function() { return mergeStyles; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mergeCss", function() { return mergeCss; }); /* harmony import */ var _extractStyleParts__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./lib/extractStyleParts.js"); /* harmony import */ var _StyleOptionsState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./lib/StyleOptionsState.js"); /* harmony import */ var _styleToClassName__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./lib/styleToClassName.js"); /** * Concatenation helper, which can merge class names together. Skips over falsey values. * * @public */ function mergeStyles() { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } return mergeCss(args, Object(_StyleOptionsState__WEBPACK_IMPORTED_MODULE_1__["getStyleOptions"])()); } /** * Concatenation helper, which can merge class names together. Skips over falsey values. * Accepts a set of options that will be used when calculating styles. * * @public */ function mergeCss(args, options) { var styleArgs = args instanceof Array ? args : [args]; var _a = Object(_extractStyleParts__WEBPACK_IMPORTED_MODULE_0__["extractStyleParts"])(styleArgs), classes = _a.classes, objects = _a.objects; if (objects.length) { classes.push(Object(_styleToClassName__WEBPACK_IMPORTED_MODULE_2__["styleToClassName"])(options || {}, objects)); } return classes.join(' '); } /***/ }), /***/ "./lib/styleToClassName.js": /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeRuleEntries", function() { return serializeRuleEntries; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "styleToRegistration", function() { return styleToRegistration; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applyRegistration", function() { return applyRegistration; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "styleToClassName", function() { return styleToClassName; }); /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("../../node_modules/tslib/tslib.es6.js"); /* harmony import */ var _Stylesheet__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./lib/Stylesheet.js"); /* harmony import */ var _transforms_kebabRules__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./lib/transforms/kebabRules.js"); /* harmony import */ var _transforms_prefixRules__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./lib/transforms/prefixRules.js"); /* harmony import */ var _transforms_provideUnits__WEBPAC