@tamagui/react-native-web-lite
Version:
React Native for Web
131 lines (130 loc) • 6.31 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 Text_exports = {};
__export(Text_exports, {
default: () => Text_default
});
module.exports = __toCommonJS(Text_exports);
var import_jsx_runtime = require("react/jsx-runtime"), import_react_native_web_internals = require("@tamagui/react-native-web-internals"), React = __toESM(require("react")), import_createElement = require("../createElement/index"), pickProps = function(props) {
return (0, import_react_native_web_internals.pick)(props, import_react_native_web_internals.forwardPropsListText);
}, Text = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
var { hrefAttrs, numberOfLines, onClick, onLayout, onPress, onMoveShouldSetResponder, onMoveShouldSetResponderCapture, onResponderEnd, onResponderGrant, onResponderMove, onResponderReject, onResponderRelease, onResponderStart, onResponderTerminate, onResponderTerminationRequest, onScrollShouldSetResponder, onScrollShouldSetResponderCapture, onSelectionChangeShouldSetResponder, onSelectionChangeShouldSetResponderCapture, onStartShouldSetResponder, onStartShouldSetResponderCapture, selectable, ...rest } = props, hasTextAncestor = React.useContext(import_react_native_web_internals.TextAncestorContext), hostRef = React.useRef(null), { direction: contextDirection } = (0, import_react_native_web_internals.useLocaleContext)();
(0, import_react_native_web_internals.useElementLayout)(hostRef, onLayout), (0, import_react_native_web_internals.useResponderEvents)(hostRef, {
onMoveShouldSetResponder,
onMoveShouldSetResponderCapture,
onResponderEnd,
onResponderGrant,
onResponderMove,
onResponderReject,
onResponderRelease,
onResponderStart,
onResponderTerminate,
onResponderTerminationRequest,
onScrollShouldSetResponder,
onScrollShouldSetResponderCapture,
onSelectionChangeShouldSetResponder,
onSelectionChangeShouldSetResponderCapture,
onStartShouldSetResponder,
onStartShouldSetResponderCapture
});
var handleClick = React.useCallback(function(e) {
onClick != null ? onClick(e) : onPress != null && (e.stopPropagation(), onPress(e));
}, [
onClick,
onPress
]), component = hasTextAncestor ? "span" : "div", langDirection = props.lang != null ? (0, import_react_native_web_internals.getLocaleDirection)(props.lang) : null, componentDirection = props.dir || langDirection, writingDirection = componentDirection || contextDirection, supportedProps = pickProps(rest);
if (supportedProps.dir = componentDirection, hasTextAncestor || (supportedProps.dir = componentDirection ?? "auto"), (onClick || onPress) && (supportedProps.onClick = handleClick), supportedProps.style = [
numberOfLines != null && numberOfLines > 1 && {
WebkitLineClamp: numberOfLines
},
hasTextAncestor === !0 ? styles.textHasAncestor$raw : styles.text,
numberOfLines === 1 && styles.textOneLine,
numberOfLines != null && numberOfLines > 1 && styles.textMultiLine,
props.style,
selectable === !0 && styles.selectable,
selectable === !1 && styles.notSelectable,
onPress && styles.pressable
], props.href != null && (component = "a", hrefAttrs != null)) {
var { download, rel, target } = hrefAttrs;
download != null && (supportedProps.download = download), rel != null && (supportedProps.rel = rel), typeof target == "string" && (supportedProps.target = target.charAt(0) !== "_" ? "_" + target : target);
}
var platformMethodsRef = (0, import_react_native_web_internals.usePlatformMethods)(supportedProps), setRef = (0, import_react_native_web_internals.useMergeRefs)(hostRef, platformMethodsRef, forwardedRef);
supportedProps.ref = setRef;
var element = (0, import_createElement.useCreateElement)(component, supportedProps, {
writingDirection
});
return hasTextAncestor ? element : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native_web_internals.TextAncestorContext.Provider, {
value: !0,
children: element
});
});
Text.displayName = "Text";
var textStyle = {
backgroundColor: "transparent",
border: "0 solid black",
boxSizing: "border-box",
color: "black",
display: "inline",
font: "14px System",
listStyle: "none",
margin: 0,
padding: 0,
textAlign: "inherit",
textDecoration: "none",
whiteSpace: "pre-wrap",
wordWrap: "break-word"
}, styles = {
text: textStyle,
textHasAncestor$raw: {
...textStyle,
color: "inherit",
font: "inherit",
whiteSpace: "inherit"
},
textOneLine: {
maxWidth: "100%",
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
wordWrap: "normal"
},
// See #13
textMultiLine: {
display: "-webkit-box",
maxWidth: "100%",
overflow: "hidden",
textOverflow: "ellipsis",
WebkitBoxOrient: "vertical"
},
notSelectable: {
userSelect: "none"
},
selectable: {
userSelect: "text"
},
pressable: {
cursor: "pointer"
}
}, Text_default = Text;
//# sourceMappingURL=index.js.map