@tamagui/avatar 1.114.4 → 1.115.1
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,147 @@
|
|
|
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,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var Avatar_exports = {};
|
|
33
|
+
__export(Avatar_exports, {
|
|
34
|
+
Avatar: () => Avatar,
|
|
35
|
+
AvatarFallback: () => AvatarFallback,
|
|
36
|
+
AvatarFallbackFrame: () => AvatarFallbackFrame,
|
|
37
|
+
AvatarFrame: () => AvatarFrame,
|
|
38
|
+
AvatarImage: () => AvatarImage,
|
|
39
|
+
createAvatarScope: () => createAvatarScope
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(Avatar_exports);
|
|
42
|
+
var import_core = require("@tamagui/core"),
|
|
43
|
+
import_create_context = require("@tamagui/create-context"),
|
|
44
|
+
import_helpers = require("@tamagui/helpers"),
|
|
45
|
+
import_image = require("@tamagui/image"),
|
|
46
|
+
import_shapes = require("@tamagui/shapes"),
|
|
47
|
+
import_stacks = require("@tamagui/stacks"),
|
|
48
|
+
React = __toESM(require("react")),
|
|
49
|
+
import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
+
const AVATAR_NAME = "Avatar",
|
|
51
|
+
[createAvatarContext, createAvatarScope] = (0, import_create_context.createContextScope)(AVATAR_NAME),
|
|
52
|
+
[AvatarProvider, useAvatarContext] = createAvatarContext(AVATAR_NAME),
|
|
53
|
+
IMAGE_NAME = "AvatarImage",
|
|
54
|
+
AvatarImage = React.forwardRef((props, forwardedRef) => {
|
|
55
|
+
const {
|
|
56
|
+
__scopeAvatar,
|
|
57
|
+
src,
|
|
58
|
+
onLoadingStatusChange = () => {},
|
|
59
|
+
...imageProps
|
|
60
|
+
} = props,
|
|
61
|
+
context = useAvatarContext(IMAGE_NAME, __scopeAvatar),
|
|
62
|
+
[status, setStatus] = React.useState("idle"),
|
|
63
|
+
shapeSize = (0, import_core.getVariableValue)((0, import_shapes.getShapeSize)(context.size,
|
|
64
|
+
// @ts-expect-error
|
|
65
|
+
{
|
|
66
|
+
tokens: (0, import_core.getTokens)()
|
|
67
|
+
})?.width);
|
|
68
|
+
return React.useEffect(() => {
|
|
69
|
+
setStatus("idle");
|
|
70
|
+
}, [JSON.stringify(src)]), React.useEffect(() => {
|
|
71
|
+
onLoadingStatusChange(status), context.onImageLoadingStatusChange(status);
|
|
72
|
+
}, [status]), /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
73
|
+
fullscreen: !0,
|
|
74
|
+
zIndex: 1,
|
|
75
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_image.Image, {
|
|
76
|
+
fullscreen: !0,
|
|
77
|
+
...(typeof shapeSize == "number" && !Number.isNaN(shapeSize) && {
|
|
78
|
+
width: shapeSize,
|
|
79
|
+
height: shapeSize
|
|
80
|
+
}),
|
|
81
|
+
...imageProps,
|
|
82
|
+
ref: forwardedRef,
|
|
83
|
+
src,
|
|
84
|
+
onError: () => {
|
|
85
|
+
setStatus("error");
|
|
86
|
+
},
|
|
87
|
+
onLoad: () => {
|
|
88
|
+
setStatus("loaded");
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
AvatarImage.displayName = IMAGE_NAME;
|
|
94
|
+
const FALLBACK_NAME = "AvatarFallback",
|
|
95
|
+
AvatarFallbackFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
96
|
+
name: FALLBACK_NAME,
|
|
97
|
+
position: "absolute",
|
|
98
|
+
fullscreen: !0,
|
|
99
|
+
zIndex: 0
|
|
100
|
+
}),
|
|
101
|
+
AvatarFallback = AvatarFallbackFrame.extractable(React.forwardRef((props, forwardedRef) => {
|
|
102
|
+
const {
|
|
103
|
+
__scopeAvatar,
|
|
104
|
+
delayMs,
|
|
105
|
+
...fallbackProps
|
|
106
|
+
} = props,
|
|
107
|
+
context = useAvatarContext(FALLBACK_NAME, __scopeAvatar),
|
|
108
|
+
[canRender, setCanRender] = React.useState(delayMs === void 0);
|
|
109
|
+
return React.useEffect(() => {
|
|
110
|
+
if (delayMs !== void 0) {
|
|
111
|
+
const timerId = setTimeout(() => setCanRender(!0), delayMs);
|
|
112
|
+
return () => clearTimeout(timerId);
|
|
113
|
+
}
|
|
114
|
+
}, [delayMs]), canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFallbackFrame, {
|
|
115
|
+
...fallbackProps,
|
|
116
|
+
ref: forwardedRef
|
|
117
|
+
}) : null;
|
|
118
|
+
}));
|
|
119
|
+
AvatarFallback.displayName = FALLBACK_NAME;
|
|
120
|
+
const AvatarFrame = (0, import_core.styled)(import_shapes.Square, {
|
|
121
|
+
name: AVATAR_NAME,
|
|
122
|
+
position: "relative",
|
|
123
|
+
overflow: "hidden"
|
|
124
|
+
}),
|
|
125
|
+
Avatar = (0, import_helpers.withStaticProperties)(React.forwardRef((props, forwardedRef) => {
|
|
126
|
+
const {
|
|
127
|
+
__scopeAvatar,
|
|
128
|
+
size = "$true",
|
|
129
|
+
...avatarProps
|
|
130
|
+
} = props,
|
|
131
|
+
[imageLoadingStatus, setImageLoadingStatus] = React.useState("idle");
|
|
132
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarProvider, {
|
|
133
|
+
size,
|
|
134
|
+
scope: __scopeAvatar,
|
|
135
|
+
imageLoadingStatus,
|
|
136
|
+
onImageLoadingStatusChange: setImageLoadingStatus,
|
|
137
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFrame, {
|
|
138
|
+
size,
|
|
139
|
+
...avatarProps,
|
|
140
|
+
ref: forwardedRef
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
}), {
|
|
144
|
+
Image: AvatarImage,
|
|
145
|
+
Fallback: AvatarFallback
|
|
146
|
+
});
|
|
147
|
+
Avatar.displayName = AVATAR_NAME;
|
|
@@ -0,0 +1,18 @@
|
|
|
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") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
7
|
+
get: () => from[key],
|
|
8
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
9
|
+
});
|
|
10
|
+
return to;
|
|
11
|
+
},
|
|
12
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
13
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
14
|
+
value: !0
|
|
15
|
+
}), mod);
|
|
16
|
+
var src_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(src_exports);
|
|
18
|
+
__reExport(src_exports, require("./Avatar.cjs"), module.exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/avatar",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.115.1",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.css"
|
|
6
6
|
],
|
|
@@ -29,18 +29,19 @@
|
|
|
29
29
|
"react-native": "./dist/cjs/index.native.js",
|
|
30
30
|
"types": "./types/index.d.ts",
|
|
31
31
|
"import": "./dist/esm/index.mjs",
|
|
32
|
-
"require": "./dist/cjs/index.
|
|
32
|
+
"require": "./dist/cjs/index.cjs",
|
|
33
|
+
"default": "./dist/cjs/index.native.js"
|
|
33
34
|
}
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@tamagui/core": "1.
|
|
37
|
-
"@tamagui/helpers": "1.
|
|
38
|
-
"@tamagui/image": "1.
|
|
39
|
-
"@tamagui/shapes": "1.
|
|
40
|
-
"@tamagui/text": "1.
|
|
37
|
+
"@tamagui/core": "1.115.1",
|
|
38
|
+
"@tamagui/helpers": "1.115.1",
|
|
39
|
+
"@tamagui/image": "1.115.1",
|
|
40
|
+
"@tamagui/shapes": "1.115.1",
|
|
41
|
+
"@tamagui/text": "1.115.1"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@tamagui/build": "1.
|
|
44
|
+
"@tamagui/build": "1.115.1",
|
|
44
45
|
"react": "^18.2.0 || ^19.0.0",
|
|
45
46
|
"react-native": "0.74.1"
|
|
46
47
|
},
|
package/dist/cjs/Avatar.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
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
|
package/dist/cjs/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
File without changes
|
|
File without changes
|