@hanzogui/avatar 3.0.2 → 102.0.0-rc.41-hanzoai.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.
- package/dist/cjs/Avatar.cjs +142 -129
- package/dist/cjs/Avatar.native.js +153 -140
- package/dist/cjs/Avatar.native.js.map +1 -1
- package/dist/cjs/index.cjs +7 -5
- package/dist/cjs/index.native.js +7 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/Avatar.mjs +109 -98
- package/dist/esm/Avatar.mjs.map +1 -1
- package/dist/esm/Avatar.native.js +120 -109
- package/dist/esm/Avatar.native.js.map +1 -1
- package/dist/jsx/Avatar.mjs +109 -98
- package/dist/jsx/Avatar.mjs.map +1 -1
- package/dist/jsx/Avatar.native.js +153 -140
- package/dist/jsx/Avatar.native.js.map +1 -1
- package/dist/jsx/index.native.js +7 -5
- package/package.json +13 -13
- package/src/Avatar.tsx +4 -4
- package/types/Avatar.d.ts +31 -31
- package/types/Avatar.d.ts.map +1 -0
- package/types/index.d.ts.map +1 -0
package/dist/cjs/Avatar.cjs
CHANGED
|
@@ -2,33 +2,35 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
6
|
-
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
23
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
24
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
25
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
+
value: mod,
|
|
29
|
+
enumerable: true
|
|
30
|
+
}) : target, mod));
|
|
31
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
+
value: true
|
|
33
|
+
}), mod);
|
|
32
34
|
var Avatar_exports = {};
|
|
33
35
|
__export(Avatar_exports, {
|
|
34
36
|
Avatar: () => Avatar,
|
|
@@ -39,116 +41,127 @@ __export(Avatar_exports, {
|
|
|
39
41
|
createAvatarScope: () => createAvatarScope
|
|
40
42
|
});
|
|
41
43
|
module.exports = __toCommonJS(Avatar_exports);
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const AVATAR_NAME = "Avatar"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
zIndex: 0
|
|
107
|
-
}),
|
|
108
|
-
AvatarFallback = AvatarFallbackFrame.styleable((props, forwardedRef) => {
|
|
109
|
-
const {
|
|
110
|
-
__scopeAvatar,
|
|
111
|
-
delayMs,
|
|
112
|
-
...fallbackProps
|
|
113
|
-
} = props,
|
|
114
|
-
context = useAvatarContext(FALLBACK_NAME, __scopeAvatar),
|
|
115
|
-
[canRender, setCanRender] = React.useState(delayMs === void 0);
|
|
116
|
-
return React.useEffect(() => {
|
|
117
|
-
if (delayMs !== void 0) {
|
|
118
|
-
const timerId = setTimeout(() => setCanRender(!0), delayMs);
|
|
119
|
-
return () => clearTimeout(timerId);
|
|
44
|
+
var import_core = require("@hanzogui/core");
|
|
45
|
+
var import_create_context = require("@hanzogui/create-context");
|
|
46
|
+
var import_helpers = require("@hanzogui/helpers");
|
|
47
|
+
var import_image = require("@hanzogui/image");
|
|
48
|
+
var import_shapes = require("@hanzogui/shapes");
|
|
49
|
+
var import_stacks = require("@hanzogui/stacks");
|
|
50
|
+
var React = __toESM(require("react"), 1);
|
|
51
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
+
const AVATAR_NAME = "Avatar";
|
|
53
|
+
const [createAvatarContext, createAvatarScope] = (0, import_create_context.createContextScope)(AVATAR_NAME);
|
|
54
|
+
const [AvatarProvider, useAvatarContext] = createAvatarContext(AVATAR_NAME);
|
|
55
|
+
const IMAGE_NAME = "AvatarImage";
|
|
56
|
+
const AvatarImage = React.forwardRef((props, forwardedRef) => {
|
|
57
|
+
const {
|
|
58
|
+
__scopeAvatar,
|
|
59
|
+
src,
|
|
60
|
+
source,
|
|
61
|
+
onLoadingStatusChange = () => {},
|
|
62
|
+
...imageProps
|
|
63
|
+
} = props;
|
|
64
|
+
const context = useAvatarContext(IMAGE_NAME, __scopeAvatar);
|
|
65
|
+
const [status, setStatus] = React.useState("idle");
|
|
66
|
+
const shapeSize = (0, import_core.getVariableValue)((0, import_shapes.getShapeSize)(context.size,
|
|
67
|
+
// @ts-expect-error
|
|
68
|
+
{
|
|
69
|
+
tokens: (0, import_core.getTokens)()
|
|
70
|
+
})?.width);
|
|
71
|
+
const resolvedSrc = src || (source && typeof source === "object" && "uri" in source ? source.uri : source);
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
if (!resolvedSrc) {
|
|
74
|
+
setStatus("error");
|
|
75
|
+
} else {
|
|
76
|
+
setStatus("idle");
|
|
77
|
+
}
|
|
78
|
+
}, [resolvedSrc]);
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
onLoadingStatusChange(status);
|
|
81
|
+
context.onImageLoadingStatusChange(status);
|
|
82
|
+
}, [status]);
|
|
83
|
+
if (!resolvedSrc) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
87
|
+
fullscreen: true,
|
|
88
|
+
zIndex: 1,
|
|
89
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_image.Image, {
|
|
90
|
+
position: "absolute",
|
|
91
|
+
top: 0,
|
|
92
|
+
left: 0,
|
|
93
|
+
right: 0,
|
|
94
|
+
bottom: 0,
|
|
95
|
+
objectFit: "cover",
|
|
96
|
+
...(typeof shapeSize === "number" && !Number.isNaN(shapeSize) && {
|
|
97
|
+
width: shapeSize,
|
|
98
|
+
height: shapeSize
|
|
99
|
+
}),
|
|
100
|
+
...imageProps,
|
|
101
|
+
ref: forwardedRef,
|
|
102
|
+
src: resolvedSrc,
|
|
103
|
+
onError: () => {
|
|
104
|
+
setStatus("error");
|
|
105
|
+
},
|
|
106
|
+
onLoad: () => {
|
|
107
|
+
setStatus("loaded");
|
|
120
108
|
}
|
|
121
|
-
}
|
|
122
|
-
...fallbackProps,
|
|
123
|
-
ref: forwardedRef
|
|
124
|
-
}) : null;
|
|
109
|
+
})
|
|
125
110
|
});
|
|
111
|
+
});
|
|
112
|
+
AvatarImage.displayName = IMAGE_NAME;
|
|
113
|
+
const FALLBACK_NAME = "AvatarFallback";
|
|
114
|
+
const AvatarFallbackFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
115
|
+
name: FALLBACK_NAME,
|
|
116
|
+
position: "absolute",
|
|
117
|
+
fullscreen: true,
|
|
118
|
+
zIndex: 0
|
|
119
|
+
});
|
|
120
|
+
const AvatarFallback = AvatarFallbackFrame.styleable((props, forwardedRef) => {
|
|
121
|
+
const {
|
|
122
|
+
__scopeAvatar,
|
|
123
|
+
delayMs,
|
|
124
|
+
...fallbackProps
|
|
125
|
+
} = props;
|
|
126
|
+
const context = useAvatarContext(FALLBACK_NAME, __scopeAvatar);
|
|
127
|
+
const [canRender, setCanRender] = React.useState(delayMs === void 0);
|
|
128
|
+
React.useEffect(() => {
|
|
129
|
+
if (delayMs !== void 0) {
|
|
130
|
+
const timerId = setTimeout(() => setCanRender(true), delayMs);
|
|
131
|
+
return () => clearTimeout(timerId);
|
|
132
|
+
}
|
|
133
|
+
}, [delayMs]);
|
|
134
|
+
return canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFallbackFrame, {
|
|
135
|
+
...fallbackProps,
|
|
136
|
+
ref: forwardedRef
|
|
137
|
+
}) : null;
|
|
138
|
+
});
|
|
126
139
|
AvatarFallback.displayName = FALLBACK_NAME;
|
|
127
|
-
const AvatarFrame = (0,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
+
const AvatarFrame = (0, import_core.styled)(import_shapes.Square, {
|
|
141
|
+
name: AVATAR_NAME,
|
|
142
|
+
position: "relative",
|
|
143
|
+
overflow: "hidden"
|
|
144
|
+
});
|
|
145
|
+
const Avatar = (0, import_helpers.withStaticProperties)(React.forwardRef((props, forwardedRef) => {
|
|
146
|
+
const {
|
|
147
|
+
__scopeAvatar,
|
|
148
|
+
size = "$true",
|
|
149
|
+
...avatarProps
|
|
150
|
+
} = props;
|
|
151
|
+
const [imageLoadingStatus, setImageLoadingStatus] = React.useState("idle");
|
|
152
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarProvider, {
|
|
153
|
+
size,
|
|
154
|
+
scope: __scopeAvatar,
|
|
155
|
+
imageLoadingStatus,
|
|
156
|
+
onImageLoadingStatusChange: setImageLoadingStatus,
|
|
157
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFrame, {
|
|
140
158
|
size,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFrame, {
|
|
145
|
-
size,
|
|
146
|
-
...avatarProps,
|
|
147
|
-
ref: forwardedRef
|
|
148
|
-
})
|
|
149
|
-
});
|
|
150
|
-
}), {
|
|
151
|
-
Image: AvatarImage,
|
|
152
|
-
Fallback: AvatarFallback
|
|
159
|
+
...avatarProps,
|
|
160
|
+
ref: forwardedRef
|
|
161
|
+
})
|
|
153
162
|
});
|
|
163
|
+
}), {
|
|
164
|
+
Image: AvatarImage,
|
|
165
|
+
Fallback: AvatarFallback
|
|
166
|
+
});
|
|
154
167
|
Avatar.displayName = AVATAR_NAME;
|
|
@@ -4,33 +4,35 @@ var __create = Object.create;
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf
|
|
8
|
-
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
9
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
18
|
get: () => from[key],
|
|
18
19
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
20
|
});
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
22
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
+
value: mod,
|
|
31
|
+
enumerable: true
|
|
32
|
+
}) : target, mod));
|
|
33
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
+
value: true
|
|
35
|
+
}), mod);
|
|
34
36
|
var Avatar_exports = {};
|
|
35
37
|
__export(Avatar_exports, {
|
|
36
38
|
Avatar: () => Avatar,
|
|
@@ -41,132 +43,143 @@ __export(Avatar_exports, {
|
|
|
41
43
|
createAvatarScope: () => createAvatarScope
|
|
42
44
|
});
|
|
43
45
|
module.exports = __toCommonJS(Avatar_exports);
|
|
44
|
-
var import_jsx_runtime = require("react/jsx-runtime")
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
|
+
var import_core = require("@hanzogui/core");
|
|
48
|
+
var import_create_context = require("@hanzogui/create-context");
|
|
49
|
+
var import_helpers = require("@hanzogui/helpers");
|
|
50
|
+
var import_image = require("@hanzogui/image");
|
|
51
|
+
var import_shapes = require("@hanzogui/shapes");
|
|
52
|
+
var import_stacks = require("@hanzogui/stacks");
|
|
53
|
+
var React = __toESM(require("react"), 1);
|
|
52
54
|
function _type_of(obj) {
|
|
53
55
|
"@swc/helpers - typeof";
|
|
54
56
|
|
|
55
|
-
return obj && typeof Symbol
|
|
57
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
56
58
|
}
|
|
57
|
-
var AVATAR_NAME = "Avatar"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
zIndex: 0
|
|
120
|
-
}),
|
|
121
|
-
AvatarFallback = AvatarFallbackFrame.styleable(function (props, forwardedRef) {
|
|
122
|
-
var {
|
|
123
|
-
__scopeAvatar,
|
|
124
|
-
delayMs,
|
|
125
|
-
...fallbackProps
|
|
126
|
-
} = props,
|
|
127
|
-
context = useAvatarContext(FALLBACK_NAME, __scopeAvatar),
|
|
128
|
-
[canRender, setCanRender] = React.useState(delayMs === void 0);
|
|
129
|
-
return React.useEffect(function () {
|
|
130
|
-
if (delayMs !== void 0) {
|
|
131
|
-
var timerId = setTimeout(function () {
|
|
132
|
-
return setCanRender(!0);
|
|
133
|
-
}, delayMs);
|
|
134
|
-
return function () {
|
|
135
|
-
return clearTimeout(timerId);
|
|
136
|
-
};
|
|
59
|
+
var AVATAR_NAME = "Avatar";
|
|
60
|
+
var [createAvatarContext, createAvatarScope] = (0, import_create_context.createContextScope)(AVATAR_NAME);
|
|
61
|
+
var [AvatarProvider, useAvatarContext] = createAvatarContext(AVATAR_NAME);
|
|
62
|
+
var IMAGE_NAME = "AvatarImage";
|
|
63
|
+
var AvatarImage = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
64
|
+
var _getShapeSize;
|
|
65
|
+
var {
|
|
66
|
+
__scopeAvatar,
|
|
67
|
+
src,
|
|
68
|
+
source,
|
|
69
|
+
onLoadingStatusChange = function () {},
|
|
70
|
+
...imageProps
|
|
71
|
+
} = props;
|
|
72
|
+
var context = useAvatarContext(IMAGE_NAME, __scopeAvatar);
|
|
73
|
+
var [status, setStatus] = React.useState("idle");
|
|
74
|
+
var shapeSize = (0, import_core.getVariableValue)((_getShapeSize = (0, import_shapes.getShapeSize)(context.size,
|
|
75
|
+
// @ts-expect-error
|
|
76
|
+
{
|
|
77
|
+
tokens: (0, import_core.getTokens)()
|
|
78
|
+
})) === null || _getShapeSize === void 0 ? void 0 : _getShapeSize.width);
|
|
79
|
+
var resolvedSrc = src || (source && (typeof source === "undefined" ? "undefined" : _type_of(source)) === "object" && "uri" in source ? source.uri : source);
|
|
80
|
+
React.useEffect(function () {
|
|
81
|
+
if (!resolvedSrc) {
|
|
82
|
+
setStatus("error");
|
|
83
|
+
} else {
|
|
84
|
+
setStatus("idle");
|
|
85
|
+
}
|
|
86
|
+
}, [resolvedSrc]);
|
|
87
|
+
React.useEffect(function () {
|
|
88
|
+
onLoadingStatusChange(status);
|
|
89
|
+
context.onImageLoadingStatusChange(status);
|
|
90
|
+
}, [status]);
|
|
91
|
+
if (!resolvedSrc) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
|
|
95
|
+
fullscreen: true,
|
|
96
|
+
zIndex: 1,
|
|
97
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_image.Image, {
|
|
98
|
+
position: "absolute",
|
|
99
|
+
top: 0,
|
|
100
|
+
left: 0,
|
|
101
|
+
right: 0,
|
|
102
|
+
bottom: 0,
|
|
103
|
+
objectFit: "cover",
|
|
104
|
+
...(typeof shapeSize === "number" && !Number.isNaN(shapeSize) && {
|
|
105
|
+
width: shapeSize,
|
|
106
|
+
height: shapeSize
|
|
107
|
+
}),
|
|
108
|
+
...imageProps,
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
ref: forwardedRef,
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
src: resolvedSrc,
|
|
113
|
+
// onLoadStart={() => {
|
|
114
|
+
// // setStatus('loading')
|
|
115
|
+
// }}
|
|
116
|
+
onError: function () {
|
|
117
|
+
setStatus("error");
|
|
118
|
+
},
|
|
119
|
+
onLoad: function () {
|
|
120
|
+
setStatus("loaded");
|
|
137
121
|
}
|
|
138
|
-
}
|
|
139
|
-
...fallbackProps,
|
|
140
|
-
ref: forwardedRef
|
|
141
|
-
}) : null;
|
|
122
|
+
})
|
|
142
123
|
});
|
|
124
|
+
});
|
|
125
|
+
AvatarImage.displayName = IMAGE_NAME;
|
|
126
|
+
var FALLBACK_NAME = "AvatarFallback";
|
|
127
|
+
var AvatarFallbackFrame = (0, import_core.styled)(import_stacks.YStack, {
|
|
128
|
+
name: FALLBACK_NAME,
|
|
129
|
+
position: "absolute",
|
|
130
|
+
fullscreen: true,
|
|
131
|
+
zIndex: 0
|
|
132
|
+
});
|
|
133
|
+
var AvatarFallback = AvatarFallbackFrame.styleable(function (props, forwardedRef) {
|
|
134
|
+
var {
|
|
135
|
+
__scopeAvatar,
|
|
136
|
+
delayMs,
|
|
137
|
+
...fallbackProps
|
|
138
|
+
} = props;
|
|
139
|
+
var context = useAvatarContext(FALLBACK_NAME, __scopeAvatar);
|
|
140
|
+
var [canRender, setCanRender] = React.useState(delayMs === void 0);
|
|
141
|
+
React.useEffect(function () {
|
|
142
|
+
if (delayMs !== void 0) {
|
|
143
|
+
var timerId = setTimeout(function () {
|
|
144
|
+
return setCanRender(true);
|
|
145
|
+
}, delayMs);
|
|
146
|
+
return function () {
|
|
147
|
+
return clearTimeout(timerId);
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}, [delayMs]);
|
|
151
|
+
return canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFallbackFrame, {
|
|
152
|
+
...fallbackProps,
|
|
153
|
+
ref: forwardedRef
|
|
154
|
+
}) : null;
|
|
155
|
+
});
|
|
143
156
|
AvatarFallback.displayName = FALLBACK_NAME;
|
|
144
|
-
var AvatarFrame = (0,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
+
var AvatarFrame = (0, import_core.styled)(import_shapes.Square, {
|
|
158
|
+
name: AVATAR_NAME,
|
|
159
|
+
position: "relative",
|
|
160
|
+
overflow: "hidden"
|
|
161
|
+
});
|
|
162
|
+
var Avatar = (0, import_helpers.withStaticProperties)(/* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
|
|
163
|
+
var {
|
|
164
|
+
__scopeAvatar,
|
|
165
|
+
size = "$true",
|
|
166
|
+
...avatarProps
|
|
167
|
+
} = props;
|
|
168
|
+
var [imageLoadingStatus, setImageLoadingStatus] = React.useState("idle");
|
|
169
|
+
return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarProvider, {
|
|
170
|
+
size,
|
|
171
|
+
scope: __scopeAvatar,
|
|
172
|
+
imageLoadingStatus,
|
|
173
|
+
onImageLoadingStatusChange: setImageLoadingStatus,
|
|
174
|
+
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFrame, {
|
|
157
175
|
size,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFrame, {
|
|
162
|
-
size,
|
|
163
|
-
...avatarProps,
|
|
164
|
-
ref: forwardedRef
|
|
165
|
-
})
|
|
166
|
-
});
|
|
167
|
-
}), {
|
|
168
|
-
Image: AvatarImage,
|
|
169
|
-
Fallback: AvatarFallback
|
|
176
|
+
...avatarProps,
|
|
177
|
+
ref: forwardedRef
|
|
178
|
+
})
|
|
170
179
|
});
|
|
180
|
+
}), {
|
|
181
|
+
Image: AvatarImage,
|
|
182
|
+
Fallback: AvatarFallback
|
|
183
|
+
});
|
|
171
184
|
Avatar.displayName = AVATAR_NAME;
|
|
172
185
|
//# sourceMappingURL=Avatar.native.js.map
|