@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.
@@ -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
- __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
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, {
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
- return to;
19
- };
19
+ }
20
+ return to;
21
+ };
20
22
  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);
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 import_gui_core = require("@hanzogui/core"),
43
- import_gui_create_context = require("@hanzogui/create-context"),
44
- import_gui_helpers = require("@hanzogui/helpers"),
45
- import_gui_image = require("@hanzogui/image"),
46
- import_gui_shapes = require("@hanzogui/shapes"),
47
- import_gui_stacks = require("@hanzogui/stacks"),
48
- React = __toESM(require("react"), 1),
49
- import_jsx_runtime = require("react/jsx-runtime");
50
- const AVATAR_NAME = "Avatar",
51
- [createAvatarContext, createAvatarScope] = (0, import_gui_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
- source,
59
- onLoadingStatusChange = () => {},
60
- ...imageProps
61
- } = props,
62
- context = useAvatarContext(IMAGE_NAME, __scopeAvatar),
63
- [status, setStatus] = React.useState("idle"),
64
- shapeSize = (0, import_gui_core.getVariableValue)((0, import_gui_shapes.getShapeSize)(context.size,
65
- // @ts-expect-error
66
- {
67
- tokens: (0, import_gui_core.getTokens)()
68
- })?.width),
69
- resolvedSrc = src || (source && typeof source == "object" && "uri" in source ? source.uri : source);
70
- return React.useEffect(() => {
71
- setStatus(resolvedSrc ? "idle" : "error");
72
- }, [resolvedSrc]), React.useEffect(() => {
73
- onLoadingStatusChange(status), context.onImageLoadingStatusChange(status);
74
- }, [status]), resolvedSrc ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_stacks.YStack, {
75
- fullscreen: !0,
76
- zIndex: 1,
77
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_image.Image, {
78
- position: "absolute",
79
- top: 0,
80
- left: 0,
81
- right: 0,
82
- bottom: 0,
83
- objectFit: "cover",
84
- ...(typeof shapeSize == "number" && !Number.isNaN(shapeSize) && {
85
- width: shapeSize,
86
- height: shapeSize
87
- }),
88
- ...imageProps,
89
- ref: forwardedRef,
90
- src: resolvedSrc,
91
- onError: () => {
92
- setStatus("error");
93
- },
94
- onLoad: () => {
95
- setStatus("loaded");
96
- }
97
- })
98
- }) : null;
99
- });
100
- AvatarImage.displayName = IMAGE_NAME;
101
- const FALLBACK_NAME = "AvatarFallback",
102
- AvatarFallbackFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
103
- name: FALLBACK_NAME,
104
- position: "absolute",
105
- fullscreen: !0,
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
- }, [delayMs]), canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFallbackFrame, {
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, import_gui_core.styled)(import_gui_shapes.Square, {
128
- name: AVATAR_NAME,
129
- position: "relative",
130
- overflow: "hidden"
131
- }),
132
- Avatar = (0, import_gui_helpers.withStaticProperties)(React.forwardRef((props, forwardedRef) => {
133
- const {
134
- __scopeAvatar,
135
- size = "$true",
136
- ...avatarProps
137
- } = props,
138
- [imageLoadingStatus, setImageLoadingStatus] = React.useState("idle");
139
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarProvider, {
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
- scope: __scopeAvatar,
142
- imageLoadingStatus,
143
- onImageLoadingStatusChange: setImageLoadingStatus,
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
- __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __export = (target, all) => {
10
- for (var name in all) __defProp(target, name, {
11
- get: all[name],
12
- enumerable: !0
13
- });
14
- },
15
- __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
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
- return to;
21
- };
21
+ }
22
+ return to;
23
+ };
22
24
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
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: !0
30
- }) : target, mod)),
31
- __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: !0
33
- }), mod);
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
- import_gui_core = require("@hanzogui/core"),
46
- import_gui_create_context = require("@hanzogui/create-context"),
47
- import_gui_helpers = require("@hanzogui/helpers"),
48
- import_gui_image = require("@hanzogui/image"),
49
- import_gui_shapes = require("@hanzogui/shapes"),
50
- import_gui_stacks = require("@hanzogui/stacks"),
51
- React = __toESM(require("react"), 1);
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 < "u" && obj.constructor === Symbol ? "symbol" : typeof obj;
57
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
56
58
  }
57
- var AVATAR_NAME = "Avatar",
58
- [createAvatarContext, createAvatarScope] = (0, import_gui_create_context.createContextScope)(AVATAR_NAME),
59
- [AvatarProvider, useAvatarContext] = createAvatarContext(AVATAR_NAME),
60
- IMAGE_NAME = "AvatarImage",
61
- AvatarImage = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
62
- var _getShapeSize,
63
- {
64
- __scopeAvatar,
65
- src,
66
- source,
67
- onLoadingStatusChange = function () {},
68
- ...imageProps
69
- } = props,
70
- context = useAvatarContext(IMAGE_NAME, __scopeAvatar),
71
- [status, setStatus] = React.useState("idle"),
72
- shapeSize = (0, import_gui_core.getVariableValue)((_getShapeSize = (0, import_gui_shapes.getShapeSize)(context.size,
73
- // @ts-expect-error
74
- {
75
- tokens: (0, import_gui_core.getTokens)()
76
- })) === null || _getShapeSize === void 0 ? void 0 : _getShapeSize.width),
77
- resolvedSrc = src || (source && (typeof source > "u" ? "undefined" : _type_of(source)) === "object" && "uri" in source ? source.uri : source);
78
- return React.useEffect(function () {
79
- setStatus(resolvedSrc ? "idle" : "error");
80
- }, [resolvedSrc]), React.useEffect(function () {
81
- onLoadingStatusChange(status), context.onImageLoadingStatusChange(status);
82
- }, [status]), resolvedSrc ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_stacks.YStack, {
83
- fullscreen: !0,
84
- zIndex: 1,
85
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_gui_image.Image, {
86
- position: "absolute",
87
- top: 0,
88
- left: 0,
89
- right: 0,
90
- bottom: 0,
91
- objectFit: "cover",
92
- ...(typeof shapeSize == "number" && !Number.isNaN(shapeSize) && {
93
- width: shapeSize,
94
- height: shapeSize
95
- }),
96
- ...imageProps,
97
- // @ts-ignore
98
- ref: forwardedRef,
99
- // @ts-ignore
100
- src: resolvedSrc,
101
- // onLoadStart={() => {
102
- // // setStatus('loading')
103
- // }}
104
- onError: function () {
105
- setStatus("error");
106
- },
107
- onLoad: function () {
108
- setStatus("loaded");
109
- }
110
- })
111
- }) : null;
112
- });
113
- AvatarImage.displayName = IMAGE_NAME;
114
- var FALLBACK_NAME = "AvatarFallback",
115
- AvatarFallbackFrame = (0, import_gui_core.styled)(import_gui_stacks.YStack, {
116
- name: FALLBACK_NAME,
117
- position: "absolute",
118
- fullscreen: !0,
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
- }, [delayMs]), canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarFallbackFrame, {
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, import_gui_core.styled)(import_gui_shapes.Square, {
145
- name: AVATAR_NAME,
146
- position: "relative",
147
- overflow: "hidden"
148
- }),
149
- Avatar = (0, import_gui_helpers.withStaticProperties)(/* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
150
- var {
151
- __scopeAvatar,
152
- size = "$true",
153
- ...avatarProps
154
- } = props,
155
- [imageLoadingStatus, setImageLoadingStatus] = React.useState("idle");
156
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AvatarProvider, {
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
- scope: __scopeAvatar,
159
- imageLoadingStatus,
160
- onImageLoadingStatusChange: setImageLoadingStatus,
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