@tamagui/react-native-web-lite
Version:
React Native for Web
115 lines (114 loc) • 5.21 kB
JavaScript
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: !0 });
}, __copyProps = (to, from, except, desc) => {
if (from && typeof from == "object" || typeof from == "function")
for (let key of __getOwnPropNames(from))
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
mod
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
var AnimatedProps_exports = {};
__export(AnimatedProps_exports, {
default: () => AnimatedProps_default
});
module.exports = __toCommonJS(AnimatedProps_exports);
var import_AnimatedEvent = require("../AnimatedEvent"), import_AnimatedNode = __toESM(require("./AnimatedNode")), import_AnimatedStyle = __toESM(require("./AnimatedStyle")), import_NativeAnimatedHelper = __toESM(require("../NativeAnimatedHelper")), import_react_native_web_internals = require("@tamagui/react-native-web-internals");
class AnimatedProps extends import_AnimatedNode.default {
constructor(props, callback) {
super(), props.style && (props = {
...props,
style: new import_AnimatedStyle.default(props.style)
}), this._props = props, this._callback = callback, this.__attach();
}
__getValue() {
const props = {};
for (const key in this._props) {
const value = this._props[key];
value instanceof import_AnimatedNode.default ? (!value.__isNative || value instanceof import_AnimatedStyle.default) && (props[key] = value.__getValue()) : value instanceof import_AnimatedEvent.AnimatedEvent ? props[key] = value.__getHandler() : props[key] = value;
}
return props;
}
__getAnimatedValue() {
const props = {};
for (const key in this._props) {
const value = this._props[key];
value instanceof import_AnimatedNode.default && (props[key] = value.__getAnimatedValue());
}
return props;
}
__attach() {
for (const key in this._props) {
const value = this._props[key];
value instanceof import_AnimatedNode.default && value.__addChild(this);
}
}
__detach() {
this.__isNative && this._animatedView && this.__disconnectAnimatedView();
for (const key in this._props) {
const value = this._props[key];
value instanceof import_AnimatedNode.default && value.__removeChild(this);
}
super.__detach();
}
update() {
this._callback();
}
__makeNative() {
if (!this.__isNative) {
this.__isNative = !0;
for (const key in this._props) {
const value = this._props[key];
value instanceof import_AnimatedNode.default && value.__makeNative();
}
this._animatedView && this.__connectAnimatedView();
}
}
setNativeView(animatedView) {
this._animatedView !== animatedView && (this._animatedView = animatedView, this.__isNative && this.__connectAnimatedView());
}
__connectAnimatedView() {
(0, import_react_native_web_internals.invariant)(this.__isNative, 'Expected node to be marked as "native"');
const nativeViewTag = this._animatedView;
(0, import_react_native_web_internals.invariant)(nativeViewTag != null, "Unable to locate attached view in the native tree"), import_NativeAnimatedHelper.default.API.connectAnimatedNodeToView(
this.__getNativeTag(),
nativeViewTag
);
}
__disconnectAnimatedView() {
(0, import_react_native_web_internals.invariant)(this.__isNative, 'Expected node to be marked as "native"');
const nativeViewTag = this._animatedView;
(0, import_react_native_web_internals.invariant)(nativeViewTag != null, "Unable to locate attached view in the native tree"), import_NativeAnimatedHelper.default.API.disconnectAnimatedNodeFromView(
this.__getNativeTag(),
nativeViewTag
);
}
__restoreDefaultValues() {
this.__isNative && import_NativeAnimatedHelper.default.API.restoreDefaultValues(this.__getNativeTag());
}
__getNativeConfig() {
const propsConfig = {};
for (const propKey in this._props) {
const value = this._props[propKey];
value instanceof import_AnimatedNode.default && (value.__makeNative(), propsConfig[propKey] = value.__getNativeTag());
}
return {
type: "props",
props: propsConfig
};
}
}
var AnimatedProps_default = AnimatedProps;
//# sourceMappingURL=AnimatedProps.js.map