Initial commit
This commit is contained in:
24
node_modules/@radix-ui/react-avatar/dist/index.d.mts
generated
vendored
Normal file
24
node_modules/@radix-ui/react-avatar/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as _radix_ui_react_context from '@radix-ui/react-context';
|
||||
import * as React from 'react';
|
||||
import { Primitive } from '@radix-ui/react-primitive';
|
||||
|
||||
declare const createAvatarScope: _radix_ui_react_context.CreateScope;
|
||||
type ImageLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
||||
type PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;
|
||||
interface AvatarProps extends PrimitiveSpanProps {
|
||||
}
|
||||
declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
type PrimitiveImageProps = React.ComponentPropsWithoutRef<typeof Primitive.img>;
|
||||
interface AvatarImageProps extends PrimitiveImageProps {
|
||||
onLoadingStatusChange?: (status: ImageLoadingStatus) => void;
|
||||
}
|
||||
declare const AvatarImage: React.ForwardRefExoticComponent<AvatarImageProps & React.RefAttributes<HTMLImageElement>>;
|
||||
interface AvatarFallbackProps extends PrimitiveSpanProps {
|
||||
delayMs?: number;
|
||||
}
|
||||
declare const AvatarFallback: React.ForwardRefExoticComponent<AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
declare const Root: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
declare const Image: React.ForwardRefExoticComponent<AvatarImageProps & React.RefAttributes<HTMLImageElement>>;
|
||||
declare const Fallback: React.ForwardRefExoticComponent<AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
|
||||
export { Avatar, AvatarFallback, type AvatarFallbackProps, AvatarImage, type AvatarImageProps, type AvatarProps, Fallback, Image, Root, createAvatarScope };
|
||||
24
node_modules/@radix-ui/react-avatar/dist/index.d.ts
generated
vendored
Normal file
24
node_modules/@radix-ui/react-avatar/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as _radix_ui_react_context from '@radix-ui/react-context';
|
||||
import * as React from 'react';
|
||||
import { Primitive } from '@radix-ui/react-primitive';
|
||||
|
||||
declare const createAvatarScope: _radix_ui_react_context.CreateScope;
|
||||
type ImageLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
||||
type PrimitiveSpanProps = React.ComponentPropsWithoutRef<typeof Primitive.span>;
|
||||
interface AvatarProps extends PrimitiveSpanProps {
|
||||
}
|
||||
declare const Avatar: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
type PrimitiveImageProps = React.ComponentPropsWithoutRef<typeof Primitive.img>;
|
||||
interface AvatarImageProps extends PrimitiveImageProps {
|
||||
onLoadingStatusChange?: (status: ImageLoadingStatus) => void;
|
||||
}
|
||||
declare const AvatarImage: React.ForwardRefExoticComponent<AvatarImageProps & React.RefAttributes<HTMLImageElement>>;
|
||||
interface AvatarFallbackProps extends PrimitiveSpanProps {
|
||||
delayMs?: number;
|
||||
}
|
||||
declare const AvatarFallback: React.ForwardRefExoticComponent<AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
declare const Root: React.ForwardRefExoticComponent<AvatarProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
declare const Image: React.ForwardRefExoticComponent<AvatarImageProps & React.RefAttributes<HTMLImageElement>>;
|
||||
declare const Fallback: React.ForwardRefExoticComponent<AvatarFallbackProps & React.RefAttributes<HTMLSpanElement>>;
|
||||
|
||||
export { Avatar, AvatarFallback, type AvatarFallbackProps, AvatarImage, type AvatarImageProps, type AvatarProps, Fallback, Image, Root, createAvatarScope };
|
||||
135
node_modules/@radix-ui/react-avatar/dist/index.js
generated
vendored
Normal file
135
node_modules/@radix-ui/react-avatar/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
"use strict";
|
||||
"use client";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__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: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// packages/react/avatar/src/index.ts
|
||||
var src_exports = {};
|
||||
__export(src_exports, {
|
||||
Avatar: () => Avatar,
|
||||
AvatarFallback: () => AvatarFallback,
|
||||
AvatarImage: () => AvatarImage,
|
||||
Fallback: () => Fallback,
|
||||
Image: () => Image,
|
||||
Root: () => Root,
|
||||
createAvatarScope: () => createAvatarScope
|
||||
});
|
||||
module.exports = __toCommonJS(src_exports);
|
||||
|
||||
// packages/react/avatar/src/avatar.tsx
|
||||
var React = __toESM(require("react"));
|
||||
var import_react_context = require("@radix-ui/react-context");
|
||||
var import_react_use_callback_ref = require("@radix-ui/react-use-callback-ref");
|
||||
var import_react_use_layout_effect = require("@radix-ui/react-use-layout-effect");
|
||||
var import_react_primitive = require("@radix-ui/react-primitive");
|
||||
var import_jsx_runtime = require("react/jsx-runtime");
|
||||
var AVATAR_NAME = "Avatar";
|
||||
var [createAvatarContext, createAvatarScope] = (0, import_react_context.createContextScope)(AVATAR_NAME);
|
||||
var [AvatarProvider, useAvatarContext] = createAvatarContext(AVATAR_NAME);
|
||||
var Avatar = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const { __scopeAvatar, ...avatarProps } = props;
|
||||
const [imageLoadingStatus, setImageLoadingStatus] = React.useState("idle");
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
||||
AvatarProvider,
|
||||
{
|
||||
scope: __scopeAvatar,
|
||||
imageLoadingStatus,
|
||||
onImageLoadingStatusChange: setImageLoadingStatus,
|
||||
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.span, { ...avatarProps, ref: forwardedRef })
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
Avatar.displayName = AVATAR_NAME;
|
||||
var IMAGE_NAME = "AvatarImage";
|
||||
var AvatarImage = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const { __scopeAvatar, src, onLoadingStatusChange = () => {
|
||||
}, ...imageProps } = props;
|
||||
const context = useAvatarContext(IMAGE_NAME, __scopeAvatar);
|
||||
const imageLoadingStatus = useImageLoadingStatus(src, imageProps.referrerPolicy);
|
||||
const handleLoadingStatusChange = (0, import_react_use_callback_ref.useCallbackRef)((status) => {
|
||||
onLoadingStatusChange(status);
|
||||
context.onImageLoadingStatusChange(status);
|
||||
});
|
||||
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
||||
if (imageLoadingStatus !== "idle") {
|
||||
handleLoadingStatusChange(imageLoadingStatus);
|
||||
}
|
||||
}, [imageLoadingStatus, handleLoadingStatusChange]);
|
||||
return imageLoadingStatus === "loaded" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.img, { ...imageProps, ref: forwardedRef, src }) : null;
|
||||
}
|
||||
);
|
||||
AvatarImage.displayName = IMAGE_NAME;
|
||||
var FALLBACK_NAME = "AvatarFallback";
|
||||
var AvatarFallback = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const { __scopeAvatar, delayMs, ...fallbackProps } = props;
|
||||
const context = useAvatarContext(FALLBACK_NAME, __scopeAvatar);
|
||||
const [canRender, setCanRender] = React.useState(delayMs === void 0);
|
||||
React.useEffect(() => {
|
||||
if (delayMs !== void 0) {
|
||||
const timerId = window.setTimeout(() => setCanRender(true), delayMs);
|
||||
return () => window.clearTimeout(timerId);
|
||||
}
|
||||
}, [delayMs]);
|
||||
return canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_primitive.Primitive.span, { ...fallbackProps, ref: forwardedRef }) : null;
|
||||
}
|
||||
);
|
||||
AvatarFallback.displayName = FALLBACK_NAME;
|
||||
function useImageLoadingStatus(src, referrerPolicy) {
|
||||
const [loadingStatus, setLoadingStatus] = React.useState("idle");
|
||||
(0, import_react_use_layout_effect.useLayoutEffect)(() => {
|
||||
if (!src) {
|
||||
setLoadingStatus("error");
|
||||
return;
|
||||
}
|
||||
let isMounted = true;
|
||||
const image = new window.Image();
|
||||
const updateStatus = (status) => () => {
|
||||
if (!isMounted) return;
|
||||
setLoadingStatus(status);
|
||||
};
|
||||
setLoadingStatus("loading");
|
||||
image.onload = updateStatus("loaded");
|
||||
image.onerror = updateStatus("error");
|
||||
image.src = src;
|
||||
if (referrerPolicy) {
|
||||
image.referrerPolicy = referrerPolicy;
|
||||
}
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, [src, referrerPolicy]);
|
||||
return loadingStatus;
|
||||
}
|
||||
var Root = Avatar;
|
||||
var Image = AvatarImage;
|
||||
var Fallback = AvatarFallback;
|
||||
//# sourceMappingURL=index.js.map
|
||||
7
node_modules/@radix-ui/react-avatar/dist/index.js.map
generated
vendored
Normal file
7
node_modules/@radix-ui/react-avatar/dist/index.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
103
node_modules/@radix-ui/react-avatar/dist/index.mjs
generated
vendored
Normal file
103
node_modules/@radix-ui/react-avatar/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
"use client";
|
||||
|
||||
// packages/react/avatar/src/avatar.tsx
|
||||
import * as React from "react";
|
||||
import { createContextScope } from "@radix-ui/react-context";
|
||||
import { useCallbackRef } from "@radix-ui/react-use-callback-ref";
|
||||
import { useLayoutEffect } from "@radix-ui/react-use-layout-effect";
|
||||
import { Primitive } from "@radix-ui/react-primitive";
|
||||
import { jsx } from "react/jsx-runtime";
|
||||
var AVATAR_NAME = "Avatar";
|
||||
var [createAvatarContext, createAvatarScope] = createContextScope(AVATAR_NAME);
|
||||
var [AvatarProvider, useAvatarContext] = createAvatarContext(AVATAR_NAME);
|
||||
var Avatar = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const { __scopeAvatar, ...avatarProps } = props;
|
||||
const [imageLoadingStatus, setImageLoadingStatus] = React.useState("idle");
|
||||
return /* @__PURE__ */ jsx(
|
||||
AvatarProvider,
|
||||
{
|
||||
scope: __scopeAvatar,
|
||||
imageLoadingStatus,
|
||||
onImageLoadingStatusChange: setImageLoadingStatus,
|
||||
children: /* @__PURE__ */ jsx(Primitive.span, { ...avatarProps, ref: forwardedRef })
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
Avatar.displayName = AVATAR_NAME;
|
||||
var IMAGE_NAME = "AvatarImage";
|
||||
var AvatarImage = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const { __scopeAvatar, src, onLoadingStatusChange = () => {
|
||||
}, ...imageProps } = props;
|
||||
const context = useAvatarContext(IMAGE_NAME, __scopeAvatar);
|
||||
const imageLoadingStatus = useImageLoadingStatus(src, imageProps.referrerPolicy);
|
||||
const handleLoadingStatusChange = useCallbackRef((status) => {
|
||||
onLoadingStatusChange(status);
|
||||
context.onImageLoadingStatusChange(status);
|
||||
});
|
||||
useLayoutEffect(() => {
|
||||
if (imageLoadingStatus !== "idle") {
|
||||
handleLoadingStatusChange(imageLoadingStatus);
|
||||
}
|
||||
}, [imageLoadingStatus, handleLoadingStatusChange]);
|
||||
return imageLoadingStatus === "loaded" ? /* @__PURE__ */ jsx(Primitive.img, { ...imageProps, ref: forwardedRef, src }) : null;
|
||||
}
|
||||
);
|
||||
AvatarImage.displayName = IMAGE_NAME;
|
||||
var FALLBACK_NAME = "AvatarFallback";
|
||||
var AvatarFallback = React.forwardRef(
|
||||
(props, forwardedRef) => {
|
||||
const { __scopeAvatar, delayMs, ...fallbackProps } = props;
|
||||
const context = useAvatarContext(FALLBACK_NAME, __scopeAvatar);
|
||||
const [canRender, setCanRender] = React.useState(delayMs === void 0);
|
||||
React.useEffect(() => {
|
||||
if (delayMs !== void 0) {
|
||||
const timerId = window.setTimeout(() => setCanRender(true), delayMs);
|
||||
return () => window.clearTimeout(timerId);
|
||||
}
|
||||
}, [delayMs]);
|
||||
return canRender && context.imageLoadingStatus !== "loaded" ? /* @__PURE__ */ jsx(Primitive.span, { ...fallbackProps, ref: forwardedRef }) : null;
|
||||
}
|
||||
);
|
||||
AvatarFallback.displayName = FALLBACK_NAME;
|
||||
function useImageLoadingStatus(src, referrerPolicy) {
|
||||
const [loadingStatus, setLoadingStatus] = React.useState("idle");
|
||||
useLayoutEffect(() => {
|
||||
if (!src) {
|
||||
setLoadingStatus("error");
|
||||
return;
|
||||
}
|
||||
let isMounted = true;
|
||||
const image = new window.Image();
|
||||
const updateStatus = (status) => () => {
|
||||
if (!isMounted) return;
|
||||
setLoadingStatus(status);
|
||||
};
|
||||
setLoadingStatus("loading");
|
||||
image.onload = updateStatus("loaded");
|
||||
image.onerror = updateStatus("error");
|
||||
image.src = src;
|
||||
if (referrerPolicy) {
|
||||
image.referrerPolicy = referrerPolicy;
|
||||
}
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, [src, referrerPolicy]);
|
||||
return loadingStatus;
|
||||
}
|
||||
var Root = Avatar;
|
||||
var Image = AvatarImage;
|
||||
var Fallback = AvatarFallback;
|
||||
export {
|
||||
Avatar,
|
||||
AvatarFallback,
|
||||
AvatarImage,
|
||||
Fallback,
|
||||
Image,
|
||||
Root,
|
||||
createAvatarScope
|
||||
};
|
||||
//# sourceMappingURL=index.mjs.map
|
||||
7
node_modules/@radix-ui/react-avatar/dist/index.mjs.map
generated
vendored
Normal file
7
node_modules/@radix-ui/react-avatar/dist/index.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user