@tamagui/avatar 1.116.0 → 1.116.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,115 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: !0 });
9
+ }, __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from == "object" || typeof from == "function")
11
+ for (let key of __getOwnPropNames(from))
12
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ return to;
14
+ };
15
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
+ // If the importer is in node compatibility mode or this is not an ESM
17
+ // file that has been converted to a CommonJS file using a Babel-
18
+ // compatible transform (i.e. "__esModule" has not been set), then set
19
+ // "default" to the CommonJS "module.exports" for node compatibility.
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
+ mod
22
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
+ var Avatar_exports = {};
24
+ __export(Avatar_exports, {
25
+ Avatar: () => Avatar,
26
+ AvatarFallback: () => AvatarFallback,
27
+ AvatarFallbackFrame: () => AvatarFallbackFrame,
28
+ AvatarFrame: () => AvatarFrame,
29
+ AvatarImage: () => AvatarImage,
30
+ createAvatarScope: () => createAvatarScope
31
+ });
32
+ module.exports = __toCommonJS(Avatar_exports);
33
+ var import_core = require("@tamagui/core"), import_create_context = require("@tamagui/create-context"), import_helpers = require("@tamagui/helpers"), import_image = require("@tamagui/image"), import_shapes = require("@tamagui/shapes"), import_stacks = require("@tamagui/stacks"), React = __toESM(require("react")), import_jsx_runtime = require("react/jsx-runtime");
34
+ const AVATAR_NAME = "Avatar", [createAvatarContext, createAvatarScope] = (0, import_create_context.createContextScope)(AVATAR_NAME), [AvatarProvider, useAvatarContext] = createAvatarContext(AVATAR_NAME), IMAGE_NAME = "AvatarImage", AvatarImage = React.forwardRef(
35
+ (props, forwardedRef) => {
36
+ const { __scopeAvatar, src, onLoadingStatusChange = () => {
37
+ }, ...imageProps } = props, context = useAvatarContext(IMAGE_NAME, __scopeAvatar), [status, setStatus] = React.useState("idle"), shapeSize = (0, import_core.getVariableValue)(
38
+ (0, import_shapes.getShapeSize)(
39
+ context.size,
40
+ // @ts-expect-error
41
+ { tokens: (0, import_core.getTokens)() }
42
+ )?.width
43
+ );
44
+ return React.useEffect(() => {
45
+ setStatus("idle");
46
+ }, [JSON.stringify(src)]), React.useEffect(() => {
47
+ onLoadingStatusChange(status), context.onImageLoadingStatusChange(status);
48
+ }, [status]), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_stacks.YStack, { fullscreen: !0, zIndex: 1, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ import_image.Image,
50
+ {
51
+ fullscreen: !0,
52
+ ...typeof shapeSize == "number" && !Number.isNaN(shapeSize) && {
53
+ width: shapeSize,
54
+ height: shapeSize
55
+ },
56
+ ...imageProps,
57
+ ref: forwardedRef,
58
+ src,
59
+ onError: () => {
60
+ setStatus("error");
61
+ },
62
+ onLoad: () => {
63
+ setStatus("loaded");
64
+ }
65
+ }
66
+ ) });
67
+ }
68
+ );
69
+ AvatarImage.displayName = IMAGE_NAME;
70
+ const FALLBACK_NAME = "AvatarFallback", AvatarFallbackFrame = (0, import_core.styled)(import_stacks.YStack, {
71
+ name: FALLBACK_NAME,
72
+ position: "absolute",
73
+ fullscreen: !0,
74
+ zIndex: 0
75
+ }), AvatarFallback = AvatarFallbackFrame.extractable(
76
+ React.forwardRef(
77
+ (props, forwardedRef) => {
78
+ const { __scopeAvatar, delayMs, ...fallbackProps } = props, context = useAvatarContext(FALLBACK_NAME, __scopeAvatar), [canRender, setCanRender] = React.useState(delayMs === void 0);
79
+ return React.useEffect(() => {
80
+ if (delayMs !== void 0) {
81
+ const timerId = setTimeout(() => setCanRender(!0), delayMs);
82
+ return () => clearTimeout(timerId);
83
+ }
84
+ }, [delayMs]), canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarFallbackFrame, { ...fallbackProps, ref: forwardedRef }) : null;
85
+ }
86
+ )
87
+ );
88
+ AvatarFallback.displayName = FALLBACK_NAME;
89
+ const AvatarFrame = (0, import_core.styled)(import_shapes.Square, {
90
+ name: AVATAR_NAME,
91
+ position: "relative",
92
+ overflow: "hidden"
93
+ }), Avatar = (0, import_helpers.withStaticProperties)(
94
+ React.forwardRef(
95
+ (props, forwardedRef) => {
96
+ const { __scopeAvatar, size = "$true", ...avatarProps } = props, [imageLoadingStatus, setImageLoadingStatus] = React.useState("idle");
97
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
98
+ AvatarProvider,
99
+ {
100
+ size,
101
+ scope: __scopeAvatar,
102
+ imageLoadingStatus,
103
+ onImageLoadingStatusChange: setImageLoadingStatus,
104
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AvatarFrame, { size, ...avatarProps, ref: forwardedRef })
105
+ }
106
+ );
107
+ }
108
+ ),
109
+ {
110
+ Image: AvatarImage,
111
+ Fallback: AvatarFallback
112
+ }
113
+ );
114
+ Avatar.displayName = AVATAR_NAME;
115
+ //# sourceMappingURL=Avatar.js.map
@@ -0,0 +1,15 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from == "object" || typeof from == "function")
7
+ for (let key of __getOwnPropNames(from))
8
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
9
+ return to;
10
+ }, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
11
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
12
+ var src_exports = {};
13
+ module.exports = __toCommonJS(src_exports);
14
+ __reExport(src_exports, require("./Avatar"), module.exports);
15
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/avatar",
3
- "version": "1.116.0",
3
+ "version": "1.116.2",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -34,14 +34,14 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "@tamagui/core": "1.116.0",
38
- "@tamagui/helpers": "1.116.0",
39
- "@tamagui/image": "1.116.0",
40
- "@tamagui/shapes": "1.116.0",
41
- "@tamagui/text": "1.116.0"
37
+ "@tamagui/core": "1.116.2",
38
+ "@tamagui/helpers": "1.116.2",
39
+ "@tamagui/image": "1.116.2",
40
+ "@tamagui/shapes": "1.116.2",
41
+ "@tamagui/text": "1.116.2"
42
42
  },
43
43
  "devDependencies": {
44
- "@tamagui/build": "1.116.0",
44
+ "@tamagui/build": "1.116.2",
45
45
  "react": "^18.2.0 || ^19.0.0",
46
46
  "react-native": "0.74.1"
47
47
  },
File without changes
File without changes