@leve-ui/avatar 0.0.0-stage → 0.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 leve-ui contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const qwik = require("@builder.io/qwik");
4
+ const avatarContextId = qwik.createContextId("leve-ui.avatar");
5
+ exports.avatarContextId = avatarContextId;
@@ -0,0 +1,5 @@
1
+ import { createContextId } from "@builder.io/qwik";
2
+ const avatarContextId = createContextId("leve-ui.avatar");
3
+ export {
4
+ avatarContextId
5
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const avatarContext = require("./avatar-context.qwik.cjs");
6
+ const AvatarFallback = qwik.component$((props) => {
7
+ const context = qwik.useContext(avatarContext.avatarContextId);
8
+ if (context.status.value === "loaded") return null;
9
+ return /* @__PURE__ */ jsxRuntime.jsx("span", {
10
+ ...props,
11
+ "data-leve-avatar-fallback": "",
12
+ "data-state": context.status.value,
13
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
14
+ });
15
+ });
16
+ exports.AvatarFallback = AvatarFallback;
@@ -0,0 +1,16 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useContext, Slot } from "@builder.io/qwik";
3
+ import { avatarContextId } from "./avatar-context.qwik.mjs";
4
+ const AvatarFallback = component$((props) => {
5
+ const context = useContext(avatarContextId);
6
+ if (context.status.value === "loaded") return null;
7
+ return /* @__PURE__ */ jsx("span", {
8
+ ...props,
9
+ "data-leve-avatar-fallback": "",
10
+ "data-state": context.status.value,
11
+ children: /* @__PURE__ */ jsx(Slot, {})
12
+ });
13
+ });
14
+ export {
15
+ AvatarFallback
16
+ };
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const avatarContext = require("./avatar-context.qwik.cjs");
6
+ const AvatarImage = qwik.component$(({ onLoad$, onError$, ...props }) => {
7
+ const context = qwik.useContext(avatarContext.avatarContextId);
8
+ const imageRef = qwik.useSignal();
9
+ qwik.useTask$(({ track }) => {
10
+ const src = track(() => props.src);
11
+ context.status.value = src ? "loading" : "error";
12
+ });
13
+ qwik.useVisibleTask$(() => {
14
+ const image = imageRef.value;
15
+ if (!image?.complete) return;
16
+ context.status.value = image.naturalWidth > 0 ? "loaded" : "error";
17
+ }, {
18
+ strategy: "document-ready"
19
+ });
20
+ const handleLoad$ = qwik.$(() => {
21
+ context.status.value = "loaded";
22
+ });
23
+ const handleError$ = qwik.$(() => {
24
+ context.status.value = "error";
25
+ });
26
+ return (
27
+ // biome-ignore lint/a11y/useAltText: headless のため alt は利用者が props で渡す
28
+ // biome-ignore lint/correctness/useImageSize: width / height は利用者が props で渡す
29
+ /* @__PURE__ */ jsxRuntime.jsx("img", {
30
+ ...props,
31
+ ref: imageRef,
32
+ "data-leve-avatar-image": "",
33
+ "data-state": context.status.value,
34
+ hidden: context.status.value !== "loaded",
35
+ onLoad$: [
36
+ handleLoad$,
37
+ onLoad$
38
+ ],
39
+ onError$: [
40
+ handleError$,
41
+ onError$
42
+ ]
43
+ })
44
+ );
45
+ });
46
+ exports.AvatarImage = AvatarImage;
@@ -0,0 +1,46 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useContext, useSignal, useTask$, useVisibleTask$, $ } from "@builder.io/qwik";
3
+ import { avatarContextId } from "./avatar-context.qwik.mjs";
4
+ const AvatarImage = component$(({ onLoad$, onError$, ...props }) => {
5
+ const context = useContext(avatarContextId);
6
+ const imageRef = useSignal();
7
+ useTask$(({ track }) => {
8
+ const src = track(() => props.src);
9
+ context.status.value = src ? "loading" : "error";
10
+ });
11
+ useVisibleTask$(() => {
12
+ const image = imageRef.value;
13
+ if (!image?.complete) return;
14
+ context.status.value = image.naturalWidth > 0 ? "loaded" : "error";
15
+ }, {
16
+ strategy: "document-ready"
17
+ });
18
+ const handleLoad$ = $(() => {
19
+ context.status.value = "loaded";
20
+ });
21
+ const handleError$ = $(() => {
22
+ context.status.value = "error";
23
+ });
24
+ return (
25
+ // biome-ignore lint/a11y/useAltText: headless のため alt は利用者が props で渡す
26
+ // biome-ignore lint/correctness/useImageSize: width / height は利用者が props で渡す
27
+ /* @__PURE__ */ jsx("img", {
28
+ ...props,
29
+ ref: imageRef,
30
+ "data-leve-avatar-image": "",
31
+ "data-state": context.status.value,
32
+ hidden: context.status.value !== "loaded",
33
+ onLoad$: [
34
+ handleLoad$,
35
+ onLoad$
36
+ ],
37
+ onError$: [
38
+ handleError$,
39
+ onError$
40
+ ]
41
+ })
42
+ );
43
+ });
44
+ export {
45
+ AvatarImage
46
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const avatarContext = require("./avatar-context.qwik.cjs");
6
+ const AvatarRoot = qwik.component$(({ onStatusChange$, ...props }) => {
7
+ const status = qwik.useSignal("idle");
8
+ qwik.useContextProvider(avatarContext.avatarContextId, {
9
+ status
10
+ });
11
+ qwik.useTask$(({ track }) => {
12
+ const current = track(() => status.value);
13
+ if (qwik.isServer) return;
14
+ onStatusChange$?.(current);
15
+ });
16
+ return /* @__PURE__ */ jsxRuntime.jsx("span", {
17
+ ...props,
18
+ "data-leve-avatar": "",
19
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
20
+ });
21
+ });
22
+ exports.AvatarRoot = AvatarRoot;
@@ -0,0 +1,22 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useSignal, useContextProvider, useTask$, isServer, Slot } from "@builder.io/qwik";
3
+ import { avatarContextId } from "./avatar-context.qwik.mjs";
4
+ const AvatarRoot = component$(({ onStatusChange$, ...props }) => {
5
+ const status = useSignal("idle");
6
+ useContextProvider(avatarContextId, {
7
+ status
8
+ });
9
+ useTask$(({ track }) => {
10
+ const current = track(() => status.value);
11
+ if (isServer) return;
12
+ onStatusChange$?.(current);
13
+ });
14
+ return /* @__PURE__ */ jsx("span", {
15
+ ...props,
16
+ "data-leve-avatar": "",
17
+ children: /* @__PURE__ */ jsx(Slot, {})
18
+ });
19
+ });
20
+ export {
21
+ AvatarRoot
22
+ };
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const avatarFallback = require("./avatar-fallback.qwik.cjs");
4
+ const avatarImage = require("./avatar-image.qwik.cjs");
5
+ const avatarRoot = require("./avatar-root.qwik.cjs");
6
+ exports.Fallback = avatarFallback.AvatarFallback;
7
+ exports.Image = avatarImage.AvatarImage;
8
+ exports.Root = avatarRoot.AvatarRoot;
@@ -0,0 +1,8 @@
1
+ import { AvatarFallback } from "./avatar-fallback.qwik.mjs";
2
+ import { AvatarImage } from "./avatar-image.qwik.mjs";
3
+ import { AvatarRoot } from "./avatar-root.qwik.mjs";
4
+ export {
5
+ AvatarFallback as Fallback,
6
+ AvatarImage as Image,
7
+ AvatarRoot as Root
8
+ };
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const avatar = require("./avatar.qwik.cjs");
4
+ exports.Avatar = avatar;
@@ -0,0 +1,4 @@
1
+ import * as avatar from "./avatar.qwik.mjs";
2
+ export {
3
+ avatar as Avatar
4
+ };
@@ -0,0 +1,6 @@
1
+ import { type Signal } from '@builder.io/qwik';
2
+ export type ImageLoadingStatus = 'idle' | 'loading' | 'loaded' | 'error';
3
+ export interface AvatarContext {
4
+ status: Signal<ImageLoadingStatus>;
5
+ }
6
+ export declare const avatarContextId: import("@builder.io/qwik").ContextId<AvatarContext>;
@@ -0,0 +1,4 @@
1
+ import { type PropsOf } from '@builder.io/qwik';
2
+ export type AvatarFallbackProps = PropsOf<'span'>;
3
+ /** 画像が読み込まれていない間(読み込み中・エラー・src 未指定)に表示されます */
4
+ export declare const AvatarFallback: import("@builder.io/qwik").Component<{} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLSpanElement>>;
@@ -0,0 +1,24 @@
1
+ import { type PropsOf } from '@builder.io/qwik';
2
+ export type AvatarImageProps = PropsOf<'img'>;
3
+ export declare const AvatarImage: import("@builder.io/qwik").Component<{
4
+ loading?: "eager" | "lazy" | undefined;
5
+ align?: string | undefined;
6
+ alt?: string | undefined;
7
+ border?: string | undefined;
8
+ decoding?: "auto" | "async" | "sync" | undefined;
9
+ hspace?: number | undefined;
10
+ isMap?: boolean | undefined;
11
+ longDesc?: string | undefined;
12
+ lowsrc?: string | undefined;
13
+ name?: string | undefined;
14
+ sizes?: string | undefined;
15
+ src?: string | undefined;
16
+ srcset?: string | undefined;
17
+ useMap?: string | undefined;
18
+ vspace?: number | undefined;
19
+ crossOrigin?: import("@builder.io/qwik").HTMLCrossOriginAttribute;
20
+ height?: import("@builder.io/qwik").Numberish | undefined;
21
+ referrerPolicy?: ReferrerPolicy | undefined;
22
+ width?: import("@builder.io/qwik").Numberish | undefined;
23
+ children?: undefined | undefined;
24
+ } & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLImageElement>>;
@@ -0,0 +1,7 @@
1
+ import { type PropsOf, type QRL } from '@builder.io/qwik';
2
+ import { type ImageLoadingStatus } from './avatar-context';
3
+ export type AvatarRootProps = PropsOf<'span'> & {
4
+ /** 画像の読み込み状態が変化したときに呼ばれます */
5
+ onStatusChange$?: QRL<(status: ImageLoadingStatus) => void>;
6
+ };
7
+ export declare const AvatarRoot: import("@builder.io/qwik").Component<AvatarRootProps>;
@@ -0,0 +1,3 @@
1
+ export { AvatarFallback as Fallback } from './avatar-fallback';
2
+ export { AvatarImage as Image } from './avatar-image';
3
+ export { AvatarRoot as Root } from './avatar-root';
@@ -0,0 +1,5 @@
1
+ export * as Avatar from './avatar';
2
+ export type { ImageLoadingStatus } from './avatar-context';
3
+ export type { AvatarFallbackProps } from './avatar-fallback';
4
+ export type { AvatarImageProps } from './avatar-image';
5
+ export type { AvatarRootProps } from './avatar-root';
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@leve-ui/avatar",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.0",
4
+ "description": "Headless, WAI-ARIA compliant Avatar component for Qwik. Bring your own styles.",
5
+ "keywords": [
6
+ "qwik",
7
+ "headless-ui",
8
+ "accessibility",
9
+ "wai-aria",
10
+ "avatar"
11
+ ],
12
+ "homepage": "https://github.com/leve-ui/leve-ui#readme",
13
+ "bugs": {
14
+ "url": "https://github.com/leve-ui/leve-ui/issues"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/leve-ui/leve-ui.git",
19
+ "directory": "packages/components/avatar"
20
+ },
21
+ "license": "MIT",
22
+ "type": "module",
23
+ "sideEffects": false,
24
+ "main": "./lib/index.qwik.cjs",
25
+ "module": "./lib/index.qwik.mjs",
26
+ "qwik": "./lib/index.qwik.mjs",
27
+ "types": "./lib-types/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "@leve-ui/source": "./src/index.ts",
31
+ "types": "./lib-types/index.d.ts",
32
+ "import": "./lib/index.qwik.mjs",
33
+ "require": "./lib/index.qwik.cjs"
34
+ }
35
+ },
36
+ "files": [
37
+ "lib",
38
+ "lib-types"
39
+ ],
40
+ "dependencies": {
41
+ "@leve-ui/utils": "0.0.0"
42
+ },
43
+ "peerDependencies": {
44
+ "@builder.io/qwik": "^1.20.4"
45
+ },
46
+ "devDependencies": {
47
+ "@builder.io/qwik": "1.20.4",
48
+ "typescript": "~5.9.3",
49
+ "vite": "^7.3.8",
50
+ "vitest": "^5.1.0",
51
+ "@leve-ui/tsconfig": "0.0.0",
52
+ "@leve-ui/vite-config": "0.0.0"
53
+ },
54
+ "scripts": {
55
+ "build": "pnpm build:lib && pnpm build:types",
56
+ "build:lib": "vite build --mode lib",
57
+ "build:types": "tsc -p tsconfig.build.json",
58
+ "typecheck": "tsc --noEmit",
59
+ "test": "vitest run"
60
+ }
6
61
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.