swiftui-react-native
Version:
A React Native component library inspired by SwiftUI
241 lines • 8.89 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSwiftUIComponent = void 0;
const react_1 = require("react");
function createSwiftUIComponent(type, props, children) {
const Element = deepUnfreeze((0, react_1.createElement)(type, props, children));
// @ts-ignore
Element.ref = null;
Element.key = type.displayName;
Element.props._modifiers = [];
Element.padding = function (value) {
this.props._modifiers = [...this.props._modifiers, { padding: value }];
return this;
};
Element.bold = function (isActive = true) {
this.props._modifiers = [...this.props._modifiers, { bold: isActive }];
return this;
};
Element.border = function ({ color, width }) {
this.props._modifiers = [
...this.props._modifiers,
{ border: { color, width } },
];
return this;
};
Element.imageScale = function (scale) {
this.props._modifiers = [...this.props._modifiers, { imageScale: scale }];
return this;
};
Element.frame = function (frame) {
this.props._modifiers = [...this.props._modifiers, { frame }];
return this;
};
Element.foregroundStyle = function (foregroundStyle) {
this.props._modifiers = [...this.props._modifiers, { foregroundStyle }];
return this;
};
Element.rotationEffect = function (rotationEffect) {
this.props._modifiers = [...this.props._modifiers, { rotationEffect }];
return this;
};
Element.scaleEffect = function (scaleEffect) {
this.props._modifiers = [...this.props._modifiers, { scaleEffect }];
return this;
};
Element.shadow = function (shadow) {
this.props._modifiers = [...this.props._modifiers, { shadow }];
return this;
};
Element.background = function (background) {
this.props._modifiers = [...this.props._modifiers, { background }];
return this;
};
Element.hidden = function () {
this.props._modifiers = [...this.props._modifiers, { hidden: true }];
return this;
};
Element.zIndex = function (zIndex) {
this.props._modifiers = [...this.props._modifiers, { zIndex }];
return this;
};
Element.opacity = function (opacity) {
this.props._modifiers = [...this.props._modifiers, { opacity }];
return this;
};
Element.tint = function (tint) {
this.props._modifiers = [...this.props._modifiers, { tint }];
return this;
};
Element.cornerRadius = function (cornerRadius) {
this.props._modifiers = [...this.props._modifiers, { cornerRadius }];
return this;
};
Element.position = function (position) {
this.props._modifiers = [...this.props._modifiers, { position }];
return this;
};
Element.offset = function (offset) {
this.props._modifiers = [...this.props._modifiers, { offset }];
return this;
};
Element.animation = function (animation) {
this.props._modifiers = [...this.props._modifiers, { animation }];
return this;
};
Element.contentTransition = function (contentTransition) {
this.props._modifiers = [...this.props._modifiers, { contentTransition }];
return this;
};
Element.blur = function (blur) {
this.props._modifiers = [...this.props._modifiers, { blur }];
return this;
};
Element.saturation = function (saturation) {
this.props._modifiers = [...this.props._modifiers, { saturation }];
return this;
};
Element.grayscale = function (grayscale) {
this.props._modifiers = [...this.props._modifiers, { grayscale }];
return this;
};
Element.brightness = function (brightness) {
this.props._modifiers = [...this.props._modifiers, { brightness }];
return this;
};
Element.contrast = function (contrast) {
this.props._modifiers = [...this.props._modifiers, { contrast }];
return this;
};
Element.blendMode = function (blendMode) {
this.props._modifiers = [...this.props._modifiers, { blendMode }];
return this;
};
Element.mask = function (mask) {
this.props._modifiers = [...this.props._modifiers, { mask }];
return this;
};
Element.clipShape = function (clipShape) {
this.props._modifiers = [...this.props._modifiers, { clipShape }];
return this;
};
Element.environment = function (environment) {
this.props._modifiers = [...this.props._modifiers, { environment }];
return this;
};
Element.textContentType = function (textContentType) {
this.props._modifiers = [...this.props._modifiers, { textContentType }];
return this;
};
Element.keyboardType = function (keyboardType) {
this.props._modifiers = [...this.props._modifiers, { keyboardType }];
return this;
};
Element.textInputAutocapitalization = function (textInputAutocapitalization) {
this.props._modifiers = [
...this.props._modifiers,
{ textInputAutocapitalization },
];
return this;
};
Element.autocorrectionDisabled = function (autocorrectionDisabled) {
this.props._modifiers = [
...this.props._modifiers,
{ autocorrectionDisabled },
];
return this;
};
Element.resizable = function () {
this.props._modifiers = [...this.props._modifiers, { resizable: true }];
return this;
};
Element.symbolRenderingMode = function (symbolRenderingMode) {
this.props._modifiers = [...this.props._modifiers, { symbolRenderingMode }];
return this;
};
Element.fontSize = function (fontSize) {
this.props._modifiers = [...this.props._modifiers, { fontSize }];
return this;
};
Element.fontWeight = function (fontWeight) {
this.props._modifiers = [...this.props._modifiers, { fontWeight }];
return this;
};
Element.font = function (font) {
this.props._modifiers = [...this.props._modifiers, { font }];
return this;
};
Element.italic = function (italic = true) {
this.props._modifiers = [...this.props._modifiers, { italic }];
return this;
};
Element.strikethrough = function (strikethrough = true) {
this.props._modifiers = [...this.props._modifiers, { strikethrough }];
return this;
};
Element.underline = function (underline = true) {
this.props._modifiers = [...this.props._modifiers, { underline }];
return this;
};
Element.buttonStyle = function (buttonStyle) {
this.props._modifiers = [...this.props._modifiers, { buttonStyle }];
return this;
};
Element.pickerStyle = function (pickerStyle) {
this.props._modifiers = [...this.props._modifiers, { pickerStyle }];
return this;
};
Element.textFieldStyle = function (textFieldStyle) {
this.props._modifiers = [...this.props._modifiers, { textFieldStyle }];
return this;
};
Element.listStyle = function (listStyle) {
this.props._modifiers = [...this.props._modifiers, { listStyle }];
return this;
};
Element.sensoryFeedback = function (sensoryFeedback) {
this.props._modifiers = [...this.props._modifiers, { sensoryFeedback }];
return this;
};
Element.labelIsHidden = function () {
this.props._modifiers = [...this.props._modifiers, { labelIsHidden: true }];
return this;
};
Element.fill = function (color) {
this.props._modifiers = [...this.props._modifiers, { fill: color }];
return this;
};
Element.stroke = function (stroke) {
this.props._modifiers = [...this.props._modifiers, { stroke }];
return this;
};
Element.redacted = function (reason) {
this.props._modifiers = [...this.props._modifiers, { redacted: reason }];
return this;
};
Element.ignoresSafeArea = function (ignoresSafeArea) {
this.props._modifiers = [...this.props._modifiers, { ignoresSafeArea }];
return this;
};
Element.style = function (style) {
this.props.style = style;
return this;
};
return Element;
}
exports.createSwiftUIComponent = createSwiftUIComponent;
function deepUnfreeze(obj) {
if (!Object.isFrozen(obj)) {
return obj;
}
const unfrozenCopy = { ...obj };
for (const key in unfrozenCopy) {
if (unfrozenCopy.hasOwnProperty(key) &&
typeof unfrozenCopy[key] === 'object' &&
Object.isFrozen(unfrozenCopy[key])) {
unfrozenCopy[key] = deepUnfreeze(unfrozenCopy[key]);
}
}
return unfrozenCopy;
}
//# sourceMappingURL=createSwiftUIComponent.js.map