@tamagui/react-native-web-lite
Version:
React Native for Web
183 lines (180 loc) • 7.49 kB
JavaScript
import { AnimatedEvent } from "../AnimatedEvent.native.js";
import AnimatedNode from "./AnimatedNode.native.js";
import AnimatedStyle from "./AnimatedStyle.native.js";
import NativeAnimatedHelper from "../NativeAnimatedHelper.native.js";
import { invariant } from "@tamagui/react-native-web-internals";
function _assert_this_initialized(self) {
if (self === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return self;
}
function _call_super(_this, derived, args) {
return derived = _get_prototype_of(derived), _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
}
function _class_call_check(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _create_class(Constructor, protoProps, staticProps) {
return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor;
}
function _get(target, property, receiver) {
return typeof Reflect < "u" && Reflect.get ? _get = Reflect.get : _get = function (target2, property2, receiver2) {
var base = _super_prop_base(target2, property2);
if (base) {
var desc = Object.getOwnPropertyDescriptor(base, property2);
return desc.get ? desc.get.call(receiver2 || target2) : desc.value;
}
}, _get(target, property, receiver || target);
}
function _get_prototype_of(o) {
return _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function (o2) {
return o2.__proto__ || Object.getPrototypeOf(o2);
}, _get_prototype_of(o);
}
function _inherits(subClass, superClass) {
if (typeof superClass != "function" && superClass !== null) throw new TypeError("Super expression must either be null or a function");
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: !0,
configurable: !0
}
}), superClass && _set_prototype_of(subClass, superClass);
}
function _possible_constructor_return(self, call) {
return call && (_type_of(call) === "object" || typeof call == "function") ? call : _assert_this_initialized(self);
}
function _set_prototype_of(o, p) {
return _set_prototype_of = Object.setPrototypeOf || function (o2, p2) {
return o2.__proto__ = p2, o2;
}, _set_prototype_of(o, p);
}
function _super_prop_base(object, property) {
for (; !Object.prototype.hasOwnProperty.call(object, property) && (object = _get_prototype_of(object), object !== null););
return object;
}
function _type_of(obj) {
"@swc/helpers - typeof";
return obj && typeof Symbol < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
function _is_native_reflect_construct() {
try {
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
} catch {}
return (_is_native_reflect_construct = function () {
return !!result;
})();
}
var AnimatedProps = /* @__PURE__ */function (AnimatedNode1) {
"use strict";
_inherits(AnimatedProps2, AnimatedNode1);
function AnimatedProps2(props, callback) {
_class_call_check(this, AnimatedProps2);
var _this;
return _this = _call_super(this, AnimatedProps2), props.style && (props = {
...props,
style: new AnimatedStyle(props.style)
}), _this._props = props, _this._callback = callback, _this.__attach(), _this;
}
return _create_class(AnimatedProps2, [{
key: "__getValue",
value: function () {
var props = {};
for (var key in this._props) {
var value = this._props[key];
value instanceof AnimatedNode ? (!value.__isNative || value instanceof AnimatedStyle) && (props[key] = value.__getValue()) : value instanceof AnimatedEvent ? props[key] = value.__getHandler() : props[key] = value;
}
return props;
}
}, {
key: "__getAnimatedValue",
value: function () {
var props = {};
for (var key in this._props) {
var value = this._props[key];
value instanceof AnimatedNode && (props[key] = value.__getAnimatedValue());
}
return props;
}
}, {
key: "__attach",
value: function () {
for (var key in this._props) {
var value = this._props[key];
value instanceof AnimatedNode && value.__addChild(this);
}
}
}, {
key: "__detach",
value: function () {
this.__isNative && this._animatedView && this.__disconnectAnimatedView();
for (var key in this._props) {
var value = this._props[key];
value instanceof AnimatedNode && value.__removeChild(this);
}
_get(_get_prototype_of(AnimatedProps2.prototype), "__detach", this).call(this);
}
}, {
key: "update",
value: function () {
this._callback();
}
}, {
key: "__makeNative",
value: function () {
if (!this.__isNative) {
this.__isNative = !0;
for (var key in this._props) {
var value = this._props[key];
value instanceof AnimatedNode && value.__makeNative();
}
this._animatedView && this.__connectAnimatedView();
}
}
}, {
key: "setNativeView",
value: function (animatedView) {
this._animatedView !== animatedView && (this._animatedView = animatedView, this.__isNative && this.__connectAnimatedView());
}
}, {
key: "__connectAnimatedView",
value: function () {
invariant(this.__isNative, 'Expected node to be marked as "native"');
var nativeViewTag = this._animatedView;
invariant(nativeViewTag != null, "Unable to locate attached view in the native tree"), NativeAnimatedHelper.API.connectAnimatedNodeToView(this.__getNativeTag(), nativeViewTag);
}
}, {
key: "__disconnectAnimatedView",
value: function () {
invariant(this.__isNative, 'Expected node to be marked as "native"');
var nativeViewTag = this._animatedView;
invariant(nativeViewTag != null, "Unable to locate attached view in the native tree"), NativeAnimatedHelper.API.disconnectAnimatedNodeFromView(this.__getNativeTag(), nativeViewTag);
}
}, {
key: "__restoreDefaultValues",
value: function () {
this.__isNative && NativeAnimatedHelper.API.restoreDefaultValues(this.__getNativeTag());
}
}, {
key: "__getNativeConfig",
value: function () {
var propsConfig = {};
for (var propKey in this._props) {
var value = this._props[propKey];
value instanceof AnimatedNode && (value.__makeNative(), propsConfig[propKey] = value.__getNativeTag());
}
return {
type: "props",
props: propsConfig
};
}
}]), AnimatedProps2;
}(AnimatedNode),
AnimatedProps_default = AnimatedProps;
export { AnimatedProps_default as default };
//# sourceMappingURL=AnimatedProps.native.js.map