UNPKG

@tamagui/react-native-web-lite

Version:
109 lines (108 loc) 4.05 kB
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 ActivityIndicator_exports = {}; __export(ActivityIndicator_exports, { default: () => ActivityIndicator_default }); module.exports = __toCommonJS(ActivityIndicator_exports); var React = __toESM(require("react")), import_react_native_web_internals = require("@tamagui/react-native-web-internals"), import_View = __toESM(require("../View/index")), import_jsx_runtime = require("react/jsx-runtime"); const createSvgCircle = (style) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "16", cy: "16", fill: "none", r: "14", strokeWidth: "4", style }), ActivityIndicator = React.forwardRef( (props, forwardedRef) => { const { animating = !0, color = "#1976D2", hidesWhenStopped = !0, size = "small", style, ...other } = props, svg = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { height: "100%", viewBox: "0 0 32 32", width: "100%", children: [ createSvgCircle({ stroke: color, opacity: 0.2 }), createSvgCircle({ stroke: color, strokeDasharray: 80, strokeDashoffset: 60 }) ] }); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_View.default, { ...other, accessibilityRole: "progressbar", accessibilityValueMax: 1, accessibilityValueMin: 0, ref: forwardedRef, style: [styles.container, style], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_View.default, { children: svg, style: [ typeof size == "number" ? { height: size, width: size } : indicatorSizes[size], styles.animation, !animating && styles.animationPause, !animating && hidesWhenStopped && styles.hidesWhenStopped ] } ) } ); } ); ActivityIndicator.displayName = "ActivityIndicator"; const styles = import_react_native_web_internals.StyleSheet.create({ container: { alignItems: "center", justifyContent: "center" }, hidesWhenStopped: { visibility: "hidden" }, animation: { animationDuration: "0.75s", animationKeyframes: [ { "0%": { transform: [{ rotate: "0deg" }] }, "100%": { transform: [{ rotate: "360deg" }] } } ], animationTimingFunction: "linear", animationIterationCount: "infinite" }, animationPause: { animationPlayState: "paused" } }), indicatorSizes = import_react_native_web_internals.StyleSheet.create({ small: { width: 20, height: 20 }, large: { width: 36, height: 36 } }); var ActivityIndicator_default = ActivityIndicator; //# sourceMappingURL=index.js.map