[d565449] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports["default"] = assignStyle;
|
---|
| 7 |
|
---|
| 8 | function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
---|
| 9 |
|
---|
| 10 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
---|
| 11 |
|
---|
| 12 | function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
---|
| 13 |
|
---|
| 14 | function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
---|
| 15 |
|
---|
| 16 | function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
---|
| 17 |
|
---|
| 18 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
---|
| 19 |
|
---|
| 20 | function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
---|
| 21 |
|
---|
| 22 | function filterUniqueArray(arr) {
|
---|
| 23 | return arr.filter(function (val, index) {
|
---|
| 24 | return arr.lastIndexOf(val) === index;
|
---|
| 25 | });
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | function assignStyle(base) {
|
---|
| 29 | for (var i = 0, len = arguments.length <= 1 ? 0 : arguments.length - 1; i < len; ++i) {
|
---|
| 30 | var style = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
|
---|
| 31 |
|
---|
| 32 | for (var property in style) {
|
---|
| 33 | var value = style[property];
|
---|
| 34 | var baseValue = base[property];
|
---|
| 35 |
|
---|
| 36 | if (baseValue && value) {
|
---|
| 37 | if (Array.isArray(baseValue)) {
|
---|
| 38 | base[property] = filterUniqueArray(baseValue.concat(value));
|
---|
| 39 | continue;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | if (Array.isArray(value)) {
|
---|
| 43 | base[property] = filterUniqueArray([baseValue].concat(_toConsumableArray(value)));
|
---|
| 44 | continue;
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | if (_typeof(value) === 'object') {
|
---|
| 48 | base[property] = assignStyle({}, baseValue, value);
|
---|
| 49 | continue;
|
---|
| 50 | }
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | base[property] = value;
|
---|
| 54 | }
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | return base;
|
---|
| 58 | } |
---|