Guest User

Untitled

a guest
Jun 9th, 2021
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. Object.defineProperty(exports, '__esModule', { value: true });
  4.  
  5. var core = require('@react-spring/core');
  6. var reactDom = require('react-dom');
  7. var shared = require('@react-spring/shared');
  8. var animated$1 = require('@react-spring/animated');
  9.  
  10. function _objectWithoutPropertiesLoose(source, excluded) {
  11.   if (source == null) return {};
  12.   var target = {};
  13.   var sourceKeys = Object.keys(source);
  14.   var key, i;
  15.  
  16.   for (i = 0; i < sourceKeys.length; i++) {
  17.     key = sourceKeys[i];
  18.     if (excluded.indexOf(key) >= 0) continue;
  19.     target[key] = source[key];
  20.   }
  21.  
  22.   return target;
  23. }
  24.  
  25. const _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
  26. const isCustomPropRE = /^--/;
  27.  
  28. function dangerousStyleValue(name, value) {
  29.   console.log("name in dSV", name);
  30.   console.log("value in dSV", value);
  31.   if (value == null || typeof value === 'boolean' || value === '') return '';
  32.   if (typeof value === 'number' && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px';
  33.   return ('' + value).trim();
  34. }
  35.  
  36. const attributeCache = {};
  37. function applyAnimatedValues(instance, props) {
  38.   console.log("instance", instance)
  39.   console.log("props", props)
  40.   if (!instance.nodeType || !instance.setAttribute) {
  41.     return false;
  42.   }
  43.  
  44.   const isFilterElement = instance.nodeName === 'filter' || instance.parentNode && instance.parentNode.nodeName === 'filter';
  45.  
  46.   let attributes;
  47.   let style;
  48.   let children;
  49.   let scrollTop;
  50.   let scrollLeft;
  51.  
  52.   try {
  53.   const _ref = props;
  54.     style = _ref.style;
  55.     children = _ref.children;
  56.     scrollTop = _ref.scrollTop;
  57.     scrollLeft = _ref.scrollLeft;
  58.     attributes = _objectWithoutPropertiesLoose(_ref, _excluded$2);
  59.   } catch (e) {
  60.     console.log('you were right', props);
  61.     throw e;
  62.   }
  63.  
  64.   const values = Object.values(attributes);
  65.   const names = Object.keys(attributes).map(name => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, n => '-' + n.toLowerCase())));
  66.  
  67.   if (children !== void 0) {
  68.     instance.textContent = children;
  69.   }
  70.  
  71.   try {
  72.     for (let name in style) {
  73.       console.log("name", name)
  74.       console.log("style", style)
  75.       if (style.hasOwnProperty(name)) {
  76.         console.log("style.hasOwnProperty(name)");
  77.         const value = dangerousStyleValue(name, style[name]);
  78.         console.log("value", value);
  79.         if (name === 'float') {
  80.           console.log('here');
  81.           name = 'cssFloat';
  82.         } else if (isCustomPropRE.test(name)) {
  83.           console.log('here 2');
  84.           instance.style.setProperty(name, value);
  85.         } else {
  86.           console.log('here 3');
  87.           instance.style[name] = value;
  88.         }
  89.       }
  90.     }
  91.   } catch (e) {
  92.     console.log('line 81');
  93.     throw e;
  94.   }
  95.  
  96.   try {
  97.     names.forEach((name, i) => {
  98.       instance.setAttribute(name, values[i]);
  99.     });
  100.   } catch (e) {
  101.     console.log('line 85');
  102.     throw e;
  103.   }
  104.  
  105.   if (scrollTop !== void 0) {
  106.     instance.scrollTop = scrollTop;
  107.   }
  108.  
  109.   if (scrollLeft !== void 0) {
  110.     instance.scrollLeft = scrollLeft;
  111.   }
  112. }
  113. let isUnitlessNumber = {
  114.   animationIterationCount: true,
  115.   borderImageOutset: true,
  116.   borderImageSlice: true,
  117.   borderImageWidth: true,
  118.   boxFlex: true,
  119.   boxFlexGroup: true,
  120.   boxOrdinalGroup: true,
  121.   columnCount: true,
  122.   columns: true,
  123.   flex: true,
  124.   flexGrow: true,
  125.   flexPositive: true,
  126.   flexShrink: true,
  127.   flexNegative: true,
  128.   flexOrder: true,
  129.   gridRow: true,
  130.   gridRowEnd: true,
  131.   gridRowSpan: true,
  132.   gridRowStart: true,
  133.   gridColumn: true,
  134.   gridColumnEnd: true,
  135.   gridColumnSpan: true,
  136.   gridColumnStart: true,
  137.   fontWeight: true,
  138.   lineClamp: true,
  139.   lineHeight: true,
  140.   opacity: true,
  141.   order: true,
  142.   orphans: true,
  143.   tabSize: true,
  144.   widows: true,
  145.   zIndex: true,
  146.   zoom: true,
  147.   fillOpacity: true,
  148.   floodOpacity: true,
  149.   stopOpacity: true,
  150.   strokeDasharray: true,
  151.   strokeDashoffset: true,
  152.   strokeMiterlimit: true,
  153.   strokeOpacity: true,
  154.   strokeWidth: true
  155. };
  156.  
  157. const prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1);
  158.  
  159. const prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
  160. isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
  161.   prefixes.forEach(prefix => acc[prefixKey(prefix, prop)] = acc[prop]);
  162.   return acc;
  163. }, isUnitlessNumber);
  164.  
  165. const _excluded$1 = ["x", "y", "z"];
  166. const domTransforms = /^(matrix|translate|scale|rotate|skew)/;
  167. const pxTransforms = /^(translate)/;
  168. const degTransforms = /^(rotate|skew)/;
  169.  
  170. const addUnit = (value, unit) => shared.is.num(value) && value !== 0 ? value + unit : value;
  171.  
  172. const isValueIdentity = (value, id) => shared.is.arr(value) ? value.every(v => isValueIdentity(v, id)) : shared.is.num(value) ? value === id : parseFloat(value) === id;
  173.  
  174. class AnimatedStyle extends animated$1.AnimatedObject {
  175.   constructor(_ref) {
  176.     let {
  177.       x,
  178.       y,
  179.       z
  180.     } = _ref,
  181.         style = _objectWithoutPropertiesLoose(_ref, _excluded$1);
  182.  
  183.     const inputs = [];
  184.     const transforms = [];
  185.  
  186.     if (x || y || z) {
  187.       inputs.push([x || 0, y || 0, z || 0]);
  188.       transforms.push(xyz => [`translate3d(${xyz.map(v => addUnit(v, 'px')).join(',')})`, isValueIdentity(xyz, 0)]);
  189.     }
  190.  
  191.     shared.eachProp(style, (value, key) => {
  192.       if (key === 'transform') {
  193.         inputs.push([value || '']);
  194.         transforms.push(transform => [transform, transform === '']);
  195.       } else if (domTransforms.test(key)) {
  196.         delete style[key];
  197.         if (shared.is.und(value)) return;
  198.         const unit = pxTransforms.test(key) ? 'px' : degTransforms.test(key) ? 'deg' : '';
  199.         inputs.push(shared.toArray(value));
  200.         transforms.push(key === 'rotate3d' ? ([x, y, z, deg]) => [`rotate3d(${x},${y},${z},${addUnit(deg, unit)})`, isValueIdentity(deg, 0)] : input => [`${key}(${input.map(v => addUnit(v, unit)).join(',')})`, isValueIdentity(input, key.startsWith('scale') ? 1 : 0)]);
  201.       }
  202.     });
  203.  
  204.     if (inputs.length) {
  205.       style.transform = new FluidTransform(inputs, transforms);
  206.     }
  207.  
  208.     super(style);
  209.   }
  210.  
  211. }
  212.  
  213. class FluidTransform extends shared.FluidValue {
  214.   constructor(inputs, transforms) {
  215.     super();
  216.     this._value = null;
  217.     this.inputs = inputs;
  218.     this.transforms = transforms;
  219.   }
  220.  
  221.   get() {
  222.     return this._value || (this._value = this._get());
  223.   }
  224.  
  225.   _get() {
  226.     let transform = '';
  227.     let identity = true;
  228.     shared.each(this.inputs, (input, i) => {
  229.       const arg1 = shared.getFluidValue(input[0]);
  230.       const [t, id] = this.transforms[i](shared.is.arr(arg1) ? arg1 : input.map(shared.getFluidValue));
  231.       transform += ' ' + t;
  232.       identity = identity && id;
  233.     });
  234.     return identity ? 'none' : transform;
  235.   }
  236.  
  237.   observerAdded(count) {
  238.     if (count == 1) shared.each(this.inputs, input => shared.each(input, value => shared.hasFluidValue(value) && shared.addFluidObserver(value, this)));
  239.   }
  240.  
  241.   observerRemoved(count) {
  242.     if (count == 0) shared.each(this.inputs, input => shared.each(input, value => shared.hasFluidValue(value) && shared.removeFluidObserver(value, this)));
  243.   }
  244.  
  245.   eventObserved(event) {
  246.     if (event.type == 'change') {
  247.       this._value = null;
  248.     }
  249.  
  250.     shared.callFluidObservers(this, event);
  251.   }
  252.  
  253. }
  254.  
  255. const primitives = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', 'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
  256.  
  257. const _excluded = ["scrollTop", "scrollLeft"];
  258. core.Globals.assign({
  259.   batchedUpdates: reactDom.unstable_batchedUpdates,
  260.   createStringInterpolator: shared.createStringInterpolator,
  261.   colors: shared.colors
  262. });
  263. const host = animated$1.createHost(primitives, {
  264.   applyAnimatedValues,
  265.   createAnimatedStyle: style => new AnimatedStyle(style),
  266.   getComponentProps: _ref => {
  267.     let props = _objectWithoutPropertiesLoose(_ref, _excluded);
  268.  
  269.     return props;
  270.   }
  271. });
  272. const animated = host.animated;
  273.  
  274. exports.a = animated;
  275. exports.animated = animated;
  276. Object.keys(core).forEach(function (k) {
  277.   if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
  278.     enumerable: true,
  279.     get: function () {
  280.       return core[k];
  281.     }
  282.   });
  283. });
  284.  
Advertisement
Add Comment
Please, Sign In to add comment