[d565449] | 1 | 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); }
|
---|
| 2 |
|
---|
| 3 | function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
---|
| 4 |
|
---|
| 5 | 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."); }
|
---|
| 6 |
|
---|
| 7 | 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); }
|
---|
| 8 |
|
---|
| 9 | function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
---|
| 10 |
|
---|
| 11 | function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
---|
| 12 |
|
---|
| 13 | 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; }
|
---|
| 14 |
|
---|
| 15 | function filterUniqueArray(arr) {
|
---|
| 16 | return arr.filter(function (val, index) {
|
---|
| 17 | return arr.lastIndexOf(val) === index;
|
---|
| 18 | });
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | export default function assignStyle(base) {
|
---|
| 22 | for (var i = 0, len = arguments.length <= 1 ? 0 : arguments.length - 1; i < len; ++i) {
|
---|
| 23 | var style = i + 1 < 1 || arguments.length <= i + 1 ? undefined : arguments[i + 1];
|
---|
| 24 |
|
---|
| 25 | for (var property in style) {
|
---|
| 26 | var value = style[property];
|
---|
| 27 | var baseValue = base[property];
|
---|
| 28 |
|
---|
| 29 | if (baseValue && value) {
|
---|
| 30 | if (Array.isArray(baseValue)) {
|
---|
| 31 | base[property] = filterUniqueArray(baseValue.concat(value));
|
---|
| 32 | continue;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | if (Array.isArray(value)) {
|
---|
| 36 | base[property] = filterUniqueArray([baseValue].concat(_toConsumableArray(value)));
|
---|
| 37 | continue;
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | if (_typeof(value) === 'object') {
|
---|
| 41 | base[property] = assignStyle({}, baseValue, value);
|
---|
| 42 | continue;
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | base[property] = value;
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | return base;
|
---|
| 51 | } |
---|