templates/miniprogram/miniprogram_npm/@react-spring/web/index.js

530 lines
18 KiB
JavaScript

module.exports = (function() {
var __MODS__ = {};
var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
__DEFINE__(1656641689797, function(require, module, exports) {
if (process.env.NODE_ENV === "production") {
module.exports = require("./react-spring-web.cjs.prod.js");
} else {
module.exports = require("./react-spring-web.cjs.dev.js");
}
}, function(modId) {var map = {"./react-spring-web.cjs.prod.js":1656641689798,"./react-spring-web.cjs.dev.js":1656641689799}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1656641689798, function(require, module, exports) {
Object.defineProperty(exports, '__esModule', { value: true });
var core = require('@react-spring/core');
var reactDom = require('react-dom');
var shared = require('@react-spring/shared');
var animated$1 = require('@react-spring/animated');
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
const _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
const isCustomPropRE = /^--/;
function dangerousStyleValue(name, value) {
if (value == null || typeof value === 'boolean' || value === '') return '';
if (typeof value === 'number' && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px';
return ('' + value).trim();
}
const attributeCache = {};
function applyAnimatedValues(instance, props) {
if (!instance.nodeType || !instance.setAttribute) {
return false;
}
const isFilterElement = instance.nodeName === 'filter' || instance.parentNode && instance.parentNode.nodeName === 'filter';
const _ref = props,
{
style,
children,
scrollTop,
scrollLeft
} = _ref,
attributes = _objectWithoutPropertiesLoose(_ref, _excluded$2);
const values = Object.values(attributes);
const names = Object.keys(attributes).map(name => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, n => '-' + n.toLowerCase())));
if (children !== void 0) {
instance.textContent = children;
}
for (let name in style) {
if (style.hasOwnProperty(name)) {
const value = dangerousStyleValue(name, style[name]);
if (isCustomPropRE.test(name)) {
instance.style.setProperty(name, value);
} else {
instance.style[name] = value;
}
}
}
names.forEach((name, i) => {
instance.setAttribute(name, values[i]);
});
if (scrollTop !== void 0) {
instance.scrollTop = scrollTop;
}
if (scrollLeft !== void 0) {
instance.scrollLeft = scrollLeft;
}
}
let isUnitlessNumber = {
animationIterationCount: true,
borderImageOutset: true,
borderImageSlice: true,
borderImageWidth: true,
boxFlex: true,
boxFlexGroup: true,
boxOrdinalGroup: true,
columnCount: true,
columns: true,
flex: true,
flexGrow: true,
flexPositive: true,
flexShrink: true,
flexNegative: true,
flexOrder: true,
gridRow: true,
gridRowEnd: true,
gridRowSpan: true,
gridRowStart: true,
gridColumn: true,
gridColumnEnd: true,
gridColumnSpan: true,
gridColumnStart: true,
fontWeight: true,
lineClamp: true,
lineHeight: true,
opacity: true,
order: true,
orphans: true,
tabSize: true,
widows: true,
zIndex: true,
zoom: true,
fillOpacity: true,
floodOpacity: true,
stopOpacity: true,
strokeDasharray: true,
strokeDashoffset: true,
strokeMiterlimit: true,
strokeOpacity: true,
strokeWidth: true
};
const prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1);
const prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
prefixes.forEach(prefix => acc[prefixKey(prefix, prop)] = acc[prop]);
return acc;
}, isUnitlessNumber);
const _excluded$1 = ["x", "y", "z"];
const domTransforms = /^(matrix|translate|scale|rotate|skew)/;
const pxTransforms = /^(translate)/;
const degTransforms = /^(rotate|skew)/;
const addUnit = (value, unit) => shared.is.num(value) && value !== 0 ? value + unit : value;
const isValueIdentity = (value, id) => shared.is.arr(value) ? value.every(v => isValueIdentity(v, id)) : shared.is.num(value) ? value === id : parseFloat(value) === id;
class AnimatedStyle extends animated$1.AnimatedObject {
constructor(_ref) {
let {
x,
y,
z
} = _ref,
style = _objectWithoutPropertiesLoose(_ref, _excluded$1);
const inputs = [];
const transforms = [];
if (x || y || z) {
inputs.push([x || 0, y || 0, z || 0]);
transforms.push(xyz => [`translate3d(${xyz.map(v => addUnit(v, 'px')).join(',')})`, isValueIdentity(xyz, 0)]);
}
shared.eachProp(style, (value, key) => {
if (key === 'transform') {
inputs.push([value || '']);
transforms.push(transform => [transform, transform === '']);
} else if (domTransforms.test(key)) {
delete style[key];
if (shared.is.und(value)) return;
const unit = pxTransforms.test(key) ? 'px' : degTransforms.test(key) ? 'deg' : '';
inputs.push(shared.toArray(value));
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)]);
}
});
if (inputs.length) {
style.transform = new FluidTransform(inputs, transforms);
}
super(style);
}
}
class FluidTransform extends shared.FluidValue {
constructor(inputs, transforms) {
super();
this._value = null;
this.inputs = inputs;
this.transforms = transforms;
}
get() {
return this._value || (this._value = this._get());
}
_get() {
let transform = '';
let identity = true;
shared.each(this.inputs, (input, i) => {
const arg1 = shared.getFluidValue(input[0]);
const [t, id] = this.transforms[i](shared.is.arr(arg1) ? arg1 : input.map(shared.getFluidValue));
transform += ' ' + t;
identity = identity && id;
});
return identity ? 'none' : transform;
}
observerAdded(count) {
if (count == 1) shared.each(this.inputs, input => shared.each(input, value => shared.hasFluidValue(value) && shared.addFluidObserver(value, this)));
}
observerRemoved(count) {
if (count == 0) shared.each(this.inputs, input => shared.each(input, value => shared.hasFluidValue(value) && shared.removeFluidObserver(value, this)));
}
eventObserved(event) {
if (event.type == 'change') {
this._value = null;
}
shared.callFluidObservers(this, event);
}
}
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'];
const _excluded = ["scrollTop", "scrollLeft"];
core.Globals.assign({
batchedUpdates: reactDom.unstable_batchedUpdates,
createStringInterpolator: shared.createStringInterpolator,
colors: shared.colors
});
const host = animated$1.createHost(primitives, {
applyAnimatedValues,
createAnimatedStyle: style => new AnimatedStyle(style),
getComponentProps: _ref => {
let props = _objectWithoutPropertiesLoose(_ref, _excluded);
return props;
}
});
const animated = host.animated;
exports.a = animated;
exports.animated = animated;
Object.keys(core).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function () {
return core[k];
}
});
});
}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
__DEFINE__(1656641689799, function(require, module, exports) {
Object.defineProperty(exports, '__esModule', { value: true });
var core = require('@react-spring/core');
var reactDom = require('react-dom');
var shared = require('@react-spring/shared');
var animated$1 = require('@react-spring/animated');
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
const _excluded$2 = ["style", "children", "scrollTop", "scrollLeft"];
const isCustomPropRE = /^--/;
function dangerousStyleValue(name, value) {
if (value == null || typeof value === 'boolean' || value === '') return '';
if (typeof value === 'number' && value !== 0 && !isCustomPropRE.test(name) && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px';
return ('' + value).trim();
}
const attributeCache = {};
function applyAnimatedValues(instance, props) {
if (!instance.nodeType || !instance.setAttribute) {
return false;
}
const isFilterElement = instance.nodeName === 'filter' || instance.parentNode && instance.parentNode.nodeName === 'filter';
const _ref = props,
{
style,
children,
scrollTop,
scrollLeft
} = _ref,
attributes = _objectWithoutPropertiesLoose(_ref, _excluded$2);
const values = Object.values(attributes);
const names = Object.keys(attributes).map(name => isFilterElement || instance.hasAttribute(name) ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, n => '-' + n.toLowerCase())));
if (children !== void 0) {
instance.textContent = children;
}
for (let name in style) {
if (style.hasOwnProperty(name)) {
const value = dangerousStyleValue(name, style[name]);
if (isCustomPropRE.test(name)) {
instance.style.setProperty(name, value);
} else {
instance.style[name] = value;
}
}
}
names.forEach((name, i) => {
instance.setAttribute(name, values[i]);
});
if (scrollTop !== void 0) {
instance.scrollTop = scrollTop;
}
if (scrollLeft !== void 0) {
instance.scrollLeft = scrollLeft;
}
}
let isUnitlessNumber = {
animationIterationCount: true,
borderImageOutset: true,
borderImageSlice: true,
borderImageWidth: true,
boxFlex: true,
boxFlexGroup: true,
boxOrdinalGroup: true,
columnCount: true,
columns: true,
flex: true,
flexGrow: true,
flexPositive: true,
flexShrink: true,
flexNegative: true,
flexOrder: true,
gridRow: true,
gridRowEnd: true,
gridRowSpan: true,
gridRowStart: true,
gridColumn: true,
gridColumnEnd: true,
gridColumnSpan: true,
gridColumnStart: true,
fontWeight: true,
lineClamp: true,
lineHeight: true,
opacity: true,
order: true,
orphans: true,
tabSize: true,
widows: true,
zIndex: true,
zoom: true,
fillOpacity: true,
floodOpacity: true,
stopOpacity: true,
strokeDasharray: true,
strokeDashoffset: true,
strokeMiterlimit: true,
strokeOpacity: true,
strokeWidth: true
};
const prefixKey = (prefix, key) => prefix + key.charAt(0).toUpperCase() + key.substring(1);
const prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
isUnitlessNumber = Object.keys(isUnitlessNumber).reduce((acc, prop) => {
prefixes.forEach(prefix => acc[prefixKey(prefix, prop)] = acc[prop]);
return acc;
}, isUnitlessNumber);
const _excluded$1 = ["x", "y", "z"];
const domTransforms = /^(matrix|translate|scale|rotate|skew)/;
const pxTransforms = /^(translate)/;
const degTransforms = /^(rotate|skew)/;
const addUnit = (value, unit) => shared.is.num(value) && value !== 0 ? value + unit : value;
const isValueIdentity = (value, id) => shared.is.arr(value) ? value.every(v => isValueIdentity(v, id)) : shared.is.num(value) ? value === id : parseFloat(value) === id;
class AnimatedStyle extends animated$1.AnimatedObject {
constructor(_ref) {
let {
x,
y,
z
} = _ref,
style = _objectWithoutPropertiesLoose(_ref, _excluded$1);
const inputs = [];
const transforms = [];
if (x || y || z) {
inputs.push([x || 0, y || 0, z || 0]);
transforms.push(xyz => [`translate3d(${xyz.map(v => addUnit(v, 'px')).join(',')})`, isValueIdentity(xyz, 0)]);
}
shared.eachProp(style, (value, key) => {
if (key === 'transform') {
inputs.push([value || '']);
transforms.push(transform => [transform, transform === '']);
} else if (domTransforms.test(key)) {
delete style[key];
if (shared.is.und(value)) return;
const unit = pxTransforms.test(key) ? 'px' : degTransforms.test(key) ? 'deg' : '';
inputs.push(shared.toArray(value));
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)]);
}
});
if (inputs.length) {
style.transform = new FluidTransform(inputs, transforms);
}
super(style);
}
}
class FluidTransform extends shared.FluidValue {
constructor(inputs, transforms) {
super();
this._value = null;
this.inputs = inputs;
this.transforms = transforms;
}
get() {
return this._value || (this._value = this._get());
}
_get() {
let transform = '';
let identity = true;
shared.each(this.inputs, (input, i) => {
const arg1 = shared.getFluidValue(input[0]);
const [t, id] = this.transforms[i](shared.is.arr(arg1) ? arg1 : input.map(shared.getFluidValue));
transform += ' ' + t;
identity = identity && id;
});
return identity ? 'none' : transform;
}
observerAdded(count) {
if (count == 1) shared.each(this.inputs, input => shared.each(input, value => shared.hasFluidValue(value) && shared.addFluidObserver(value, this)));
}
observerRemoved(count) {
if (count == 0) shared.each(this.inputs, input => shared.each(input, value => shared.hasFluidValue(value) && shared.removeFluidObserver(value, this)));
}
eventObserved(event) {
if (event.type == 'change') {
this._value = null;
}
shared.callFluidObservers(this, event);
}
}
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'];
const _excluded = ["scrollTop", "scrollLeft"];
core.Globals.assign({
batchedUpdates: reactDom.unstable_batchedUpdates,
createStringInterpolator: shared.createStringInterpolator,
colors: shared.colors
});
const host = animated$1.createHost(primitives, {
applyAnimatedValues,
createAnimatedStyle: style => new AnimatedStyle(style),
getComponentProps: _ref => {
let props = _objectWithoutPropertiesLoose(_ref, _excluded);
return props;
}
});
const animated = host.animated;
exports.a = animated;
exports.animated = animated;
Object.keys(core).forEach(function (k) {
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function () {
return core[k];
}
});
});
}, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
return __REQUIRE__(1656641689797);
})()
//miniprogram-npm-outsideDeps=["@react-spring/core","react-dom","@react-spring/shared","@react-spring/animated"]
//# sourceMappingURL=index.js.map