@atom63/widgets 0.1.0-beta.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/dist/index.js ADDED
@@ -0,0 +1,206 @@
1
+ import { cn } from './chunk-F5NV6XJ5.js';
2
+ export { WIDGET_BODY_GAP, WIDGET_BODY_INSET, WIDGET_CANONICAL_CELL_PX, WIDGET_DENSITY_SCALE, WIDGET_MAX_PRESENTATION_SCALE, WIDGET_TYPE_FLOOR, WIDGET_TYPE_RAMP, WIDGET_TYPE_ROLE_FLOOR, WIDGET_UNIT_BASE_PX, WIDGET_UNIT_SPAN, WidgetGrid, WidgetSizeProvider, WidgetViewport, cn, useWidgetSize, widgetChromeIconStyle, widgetClampRelief, widgetInsetPx, widgetInsetStyle, widgetPresentationStyle, widgetSizeStyle, widgetTypeDesignPx, widgetTypeStyle, widgetUnitStyle, withWidgetViewport, wu, wuClamp, wuMerge, wuStyle } from './chunk-F5NV6XJ5.js';
3
+ import { Skeleton } from '@atom63/ui-react';
4
+ import { useReducedMotion } from 'motion/react';
5
+ import { createContext, useState, useEffect, useMemo, useContext } from 'react';
6
+ import { jsx, jsxs } from 'react/jsx-runtime';
7
+
8
+ // src/destination.ts
9
+ var SPECIAL_PROTOCOL = /^(mailto|tel|sms):/i;
10
+ function resolveDestination(href, appOrigins = []) {
11
+ if (!href) {
12
+ return null;
13
+ }
14
+ const value = href.trim();
15
+ if (value === "") {
16
+ return null;
17
+ }
18
+ if (value.startsWith("//")) {
19
+ return { kind: "external", href: value };
20
+ }
21
+ if (value.startsWith("#") || value.startsWith("/")) {
22
+ return { kind: "internal", href: value };
23
+ }
24
+ if (SPECIAL_PROTOCOL.test(value)) {
25
+ return null;
26
+ }
27
+ const base = typeof globalThis.window === "undefined" ? void 0 : globalThis.window.location.href;
28
+ try {
29
+ const url = new URL(value, base);
30
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
31
+ return null;
32
+ }
33
+ const isOwnOrigin = base != null && url.origin === globalThis.window.location.origin || appOrigins.includes(url.origin);
34
+ if (!isOwnOrigin) {
35
+ return { kind: "external", href: value };
36
+ }
37
+ return { kind: "internal", href: `${url.pathname}${url.search}${url.hash}` };
38
+ } catch {
39
+ return null;
40
+ }
41
+ }
42
+ function resolveDestinationKind(href, appOrigins = []) {
43
+ return resolveDestination(href, appOrigins)?.kind ?? null;
44
+ }
45
+ function WidgetImage({
46
+ alt,
47
+ aspectRatio = "16/9",
48
+ className,
49
+ containerClassName,
50
+ crossfade = false,
51
+ onLoadedImage,
52
+ priority = false,
53
+ showSkeleton = true,
54
+ src
55
+ }) {
56
+ const reduceMotion = useReducedMotion();
57
+ const [displaySrc, setDisplaySrc] = useState(src);
58
+ const [incomingSrc, setIncomingSrc] = useState(void 0);
59
+ const [incomingShown, setIncomingShown] = useState(false);
60
+ const [isLoading, setIsLoading] = useState(Boolean(src));
61
+ const [hasError, setHasError] = useState(false);
62
+ useEffect(() => {
63
+ if (!src) {
64
+ setDisplaySrc(void 0);
65
+ setIncomingSrc(void 0);
66
+ setIncomingShown(false);
67
+ setIsLoading(false);
68
+ setHasError(false);
69
+ return;
70
+ }
71
+ if (src === displaySrc || src === incomingSrc) {
72
+ setHasError(false);
73
+ return;
74
+ }
75
+ const canCrossfade = crossfade && !reduceMotion && Boolean(displaySrc);
76
+ if (!canCrossfade) {
77
+ setDisplaySrc(src);
78
+ setIncomingSrc(void 0);
79
+ setIncomingShown(false);
80
+ setIsLoading(true);
81
+ setHasError(false);
82
+ return;
83
+ }
84
+ let cancelled = false;
85
+ const promote = () => {
86
+ if (cancelled) {
87
+ return;
88
+ }
89
+ setIncomingSrc(src);
90
+ setIncomingShown(false);
91
+ setIsLoading(false);
92
+ setHasError(false);
93
+ };
94
+ const preload = new window.Image();
95
+ preload.decoding = "async";
96
+ preload.onload = promote;
97
+ preload.onerror = () => {
98
+ if (cancelled) {
99
+ return;
100
+ }
101
+ setIsLoading(false);
102
+ };
103
+ preload.src = src;
104
+ if (preload.complete && preload.naturalWidth > 0) {
105
+ promote();
106
+ }
107
+ return () => {
108
+ cancelled = true;
109
+ };
110
+ }, [crossfade, displaySrc, incomingSrc, reduceMotion, src]);
111
+ useEffect(() => {
112
+ if (!incomingSrc) {
113
+ return;
114
+ }
115
+ const frame = window.requestAnimationFrame(() => {
116
+ setIncomingShown(true);
117
+ });
118
+ return () => window.cancelAnimationFrame(frame);
119
+ }, [incomingSrc]);
120
+ if (!src || hasError && !displaySrc && !incomingSrc) {
121
+ return /* @__PURE__ */ jsx("div", { className: cn("a63-WidgetImage-empty", containerClassName), "data-aspect": aspectRatio, children: "No image provided" });
122
+ }
123
+ const showSkeletonOverlay = Boolean(showSkeleton && isLoading && !displaySrc && !incomingSrc);
124
+ const paintedSrc = incomingSrc ?? displaySrc;
125
+ return /* @__PURE__ */ jsxs(
126
+ "div",
127
+ {
128
+ className: cn("a63-WidgetImage", containerClassName),
129
+ "data-aspect": aspectRatio,
130
+ "data-slot": "widget-image",
131
+ "data-widget-image-crossfade": crossfade ? "true" : void 0,
132
+ "data-widget-image-loading": isLoading ? "true" : void 0,
133
+ "data-widget-image-src": paintedSrc,
134
+ children: [
135
+ showSkeletonOverlay ? /* @__PURE__ */ jsx(Skeleton, { className: "a63-WidgetImage-skeleton" }) : null,
136
+ displaySrc ? /* @__PURE__ */ jsx(
137
+ "img",
138
+ {
139
+ alt: incomingSrc ? "" : alt,
140
+ "aria-hidden": incomingSrc ? true : void 0,
141
+ className: cn("a63-WidgetImage-img", className),
142
+ decoding: priority ? "sync" : "async",
143
+ loading: priority ? "eager" : "lazy",
144
+ onError: () => {
145
+ if (incomingSrc) {
146
+ return;
147
+ }
148
+ setHasError(true);
149
+ setIsLoading(false);
150
+ },
151
+ onLoad: (event) => {
152
+ setIsLoading(false);
153
+ onLoadedImage?.(event.currentTarget);
154
+ },
155
+ src: displaySrc
156
+ }
157
+ ) : null,
158
+ incomingSrc ? /* @__PURE__ */ jsx(
159
+ "img",
160
+ {
161
+ alt,
162
+ className: cn("a63-WidgetImage-img", "a63-WidgetImage-incoming", className),
163
+ "data-shown": incomingShown ? "true" : void 0,
164
+ decoding: priority ? "sync" : "async",
165
+ loading: priority ? "eager" : "lazy",
166
+ onLoad: (event) => onLoadedImage?.(event.currentTarget),
167
+ onTransitionEnd: (event) => {
168
+ if (event.propertyName !== "opacity") {
169
+ return;
170
+ }
171
+ setDisplaySrc(incomingSrc);
172
+ setIncomingSrc(void 0);
173
+ setIncomingShown(false);
174
+ setIsLoading(false);
175
+ },
176
+ src: incomingSrc
177
+ }
178
+ ) : null
179
+ ]
180
+ }
181
+ );
182
+ }
183
+ var EMPTY = { origins: [] };
184
+ var WidgetLinkContext = createContext(EMPTY);
185
+ function WidgetLinkProvider({
186
+ children,
187
+ Link,
188
+ origins
189
+ }) {
190
+ const value = useMemo(
191
+ () => ({ Link, origins: origins ?? [] }),
192
+ [Link, origins]
193
+ );
194
+ return /* @__PURE__ */ jsx(WidgetLinkContext.Provider, { value, children });
195
+ }
196
+ function useWidgetLink() {
197
+ return useContext(WidgetLinkContext).Link;
198
+ }
199
+ function useWidgetDestination(href) {
200
+ const { origins } = useContext(WidgetLinkContext);
201
+ return useMemo(() => resolveDestination(href, origins), [href, origins]);
202
+ }
203
+
204
+ export { WidgetImage, WidgetLinkProvider, resolveDestination, resolveDestinationKind, useWidgetDestination, useWidgetLink };
205
+ //# sourceMappingURL=index.js.map
206
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/destination.ts","../src/image.tsx","../src/widget-link.tsx"],"names":["jsx"],"mappings":";;;;;;;;AAEA,IAAM,gBAAA,GAAmB,qBAAA;AAuClB,SAAS,kBAAA,CACd,IAAA,EAUA,UAAA,GAAgC,EAAC,EACP;AAC1B,EAAA,IAAI,CAAC,IAAA,EAAM;AACT,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,MAAM,KAAA,GAAQ,KAAK,IAAA,EAAK;AAIxB,EAAA,IAAI,UAAU,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AA;AACtB,cAAA,YAAA,CAAa,KAAK,CAAA;AAAA,YACpB,CAAA;AAAA,YACA,GAAA,EAAK;AAAA;AAAA,SACP,GACE;AAAA;AAAA;AAAA,GACN;AAEJ;AC3KA,IAAM,KAAA,GAAgC,EAAE,OAAA,EAAS,EAAC,EAAE;AAEpD,IAAM,iBAAA,GAAoB,cAAsC,KAAK,CAAA;AA2C9D,SAAS,kBAAA,CAAmB;AAAA,EACjC,QAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAA,EAKG;AACD,EAAA,MAAM,KAAA,GAAQ,OAAA;AAAA,IACZ,OAAO,EAAE,IAAA,EAAM,OAAA,EAAS,OAAA,IAAW,EAAC,EAAE,CAAA;AAAA,IACtC,CAAC,MAAM,OAAO;AAAA,GAChB;AAEA,EAAA,uBAAOA,GAAAA,CAAC,iBAAA,CAAkB,QAAA,EAAlB,EAA2B,OAAe,QAAA,EAAS,CAAA;AAC7D;AAGO,SAAS,aAAA,GAA4D;AAC1E,EAAA,OAAO,UAAA,CAAW,iBAAiB,CAAA,CAAE,IAAA;AACvC;AASO,SAAS,qBAAqB,IAAA,EAAoD;AACvF,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,UAAA,CAAW,iBAAiB,CAAA;AAChD,EAAA,OAAO,OAAA,CAAQ,MAAM,kBAAA,CAAmB,IAAA,EAAM,OAAO,CAAA,EAAG,CAAC,IAAA,EAAM,OAAO,CAAC,CAAA;AACzE","file":"index.js","sourcesContent":["import type { DestinationKind } from '@atom63/ui-react'\n\nconst SPECIAL_PROTOCOL = /^(mailto|tel|sms):/i\n\nexport interface WidgetDestination {\n /** Where it goes, from the widget's own runtime origin. */\n kind: DestinationKind\n /**\n * The href to actually render.\n *\n * For `internal` this is origin-relative (`/projects/x?a=1#b`) even when the\n * card authored an absolute URL, because that is what a router can route.\n * For `external` it is the href as authored.\n */\n href: string\n}\n\n/**\n * Resolve an `href` into the destination a widget should render.\n *\n * This has to happen at render, not in data: portfolio cards carry absolute\n * `https://atom63.io/...` hrefs, which are an in-app route on atom63.io and a\n * cross-origin link from os.atom63.io. The same card is genuinely both, so a\n * `kind` baked into the card would be wrong in one host.\n *\n * Normalising the href is the other half of that, and skipping it fails\n * silently rather than visibly: an absolute same-origin URL still points at the\n * right page, so the indicator looks correct and the anchor still works — but\n * every router-level behaviour is lost. On atom63.io, `DetailHrefLink` rejects\n * anything not starting with `/` and falls back to a plain navigation, so the\n * card reloads the whole site instead of opening the project overlay. Handing\n * back the path is what lets a host route it.\n *\n * `mailto:` / `tel:` / `sms:` are neither kind: they leave the web entirely and\n * neither icon describes that. Callers get `null` and should render no\n * indicator rather than guess.\n *\n * Off-origin during SSR is treated as external, matching `isExternalMdxHref` —\n * an absolute http(s) URL with no origin to compare against is the case where\n * assuming in-app navigation would break the link.\n */\nexport function resolveDestination(\n href: string | undefined,\n /**\n * Extra origins the running app answers for.\n *\n * The running origin alone is right in production and wrong everywhere a\n * change is tested: atom63.io's own cards author absolute\n * `https://atom63.io/...` hrefs, which compare as cross-origin on\n * `localhost` and on preview deployments. Prefer `useWidgetDestination`,\n * which reads these from the host.\n */\n appOrigins: readonly string[] = []\n): WidgetDestination | null {\n if (!href) {\n return null\n }\n\n const value = href.trim()\n\n // `new URL('', base)` resolves to the current page rather than throwing, so\n // a blank href would otherwise report as an in-app destination.\n if (value === '') {\n return null\n }\n\n if (value.startsWith('//')) {\n return { kind: 'external', href: value }\n }\n\n // Already origin-relative — nothing to normalise.\n if (value.startsWith('#') || value.startsWith('/')) {\n return { kind: 'internal', href: value }\n }\n\n if (SPECIAL_PROTOCOL.test(value)) {\n return null\n }\n\n const base =\n typeof globalThis.window === 'undefined' ? undefined : globalThis.window.location.href\n\n try {\n const url = new URL(value, base)\n if (url.protocol !== 'http:' && url.protocol !== 'https:') {\n return null\n }\n const isOwnOrigin =\n (base != null && url.origin === globalThis.window.location.origin) ||\n appOrigins.includes(url.origin)\n\n if (!isOwnOrigin) {\n return { kind: 'external', href: value }\n }\n return { kind: 'internal', href: `${url.pathname}${url.search}${url.hash}` }\n } catch {\n return null\n }\n}\n\n/** Just the kind, when the caller does not need the normalised href. */\nexport function resolveDestinationKind(\n href: string | undefined,\n appOrigins: readonly string[] = []\n): DestinationKind | null {\n return resolveDestination(href, appOrigins)?.kind ?? null\n}\n","import { Skeleton } from '@atom63/ui-react'\nimport { useReducedMotion } from 'motion/react'\nimport { useEffect, useState } from 'react'\nimport { cn } from './utils'\n\ntype WidgetImageAspect = '1/1' | '16/9' | '2/3' | 'none'\n\ninterface WidgetImageProps {\n alt: string\n aspectRatio?: WidgetImageAspect\n className?: string\n containerClassName?: string\n /**\n * Crossfade when `src` swaps after the first painted frame (shuffle / fan tiles).\n * First paint still mounts immediately; only later swaps wait on decode.\n */\n crossfade?: boolean\n /** Prefer eager decode for above-the-fold / widget tiles that swap on shuffle. */\n priority?: boolean\n /**\n * Callback with the painted element, for canvas work that needs pixels —\n * dominant-color extraction, for instance.\n *\n * This is the element already on screen, so sampling it issues no second\n * request and composes with lazy loading. Prefer it over re-fetching the URL\n * (`useExtractColor`), which pulls every full-size source in a lazy grid.\n * Cross-origin sources are loaded without `crossOrigin`, so sampling one\n * taints the canvas and the extractor reports no colour rather than throwing.\n */\n onLoadedImage?: (image: HTMLImageElement) => void\n showSkeleton?: boolean\n src?: string\n}\n\n/**\n * The aspect ratio is a `data-aspect` attribute that the stylesheet maps to\n * `aspect-ratio` (`none` sets none), so a consumer class can still override it.\n */\nexport function WidgetImage({\n alt,\n aspectRatio = '16/9',\n className,\n containerClassName,\n crossfade = false,\n onLoadedImage,\n priority = false,\n showSkeleton = true,\n src,\n}: WidgetImageProps) {\n const reduceMotion = useReducedMotion()\n const [displaySrc, setDisplaySrc] = useState<string | undefined>(src)\n const [incomingSrc, setIncomingSrc] = useState<string | undefined>(undefined)\n const [incomingShown, setIncomingShown] = useState(false)\n const [isLoading, setIsLoading] = useState(Boolean(src))\n const [hasError, setHasError] = useState(false)\n\n useEffect(() => {\n if (!src) {\n setDisplaySrc(undefined)\n setIncomingSrc(undefined)\n setIncomingShown(false)\n setIsLoading(false)\n setHasError(false)\n return\n }\n\n if (src === displaySrc || src === incomingSrc) {\n setHasError(false)\n return\n }\n\n const canCrossfade = crossfade && !reduceMotion && Boolean(displaySrc)\n\n // Default path mounts immediately so covers stay in the DOM (album 1×1,\n // content cards). Crossfade waits on decode so the outgoing frame holds.\n if (!canCrossfade) {\n setDisplaySrc(src)\n setIncomingSrc(undefined)\n setIncomingShown(false)\n setIsLoading(true)\n setHasError(false)\n return\n }\n\n let cancelled = false\n const promote = () => {\n if (cancelled) {\n return\n }\n setIncomingSrc(src)\n setIncomingShown(false)\n setIsLoading(false)\n setHasError(false)\n }\n\n const preload = new window.Image()\n preload.decoding = 'async'\n preload.onload = promote\n preload.onerror = () => {\n if (cancelled) {\n return\n }\n // Keep the held frame if the next decode fails.\n setIsLoading(false)\n }\n preload.src = src\n\n if (preload.complete && preload.naturalWidth > 0) {\n promote()\n }\n\n return () => {\n cancelled = true\n }\n }, [crossfade, displaySrc, incomingSrc, reduceMotion, src])\n\n useEffect(() => {\n if (!incomingSrc) {\n return\n }\n\n const frame = window.requestAnimationFrame(() => {\n setIncomingShown(true)\n })\n return () => window.cancelAnimationFrame(frame)\n }, [incomingSrc])\n\n if (!src || (hasError && !displaySrc && !incomingSrc)) {\n return (\n <div className={cn('a63-WidgetImage-empty', containerClassName)} data-aspect={aspectRatio}>\n No image provided\n </div>\n )\n }\n\n const showSkeletonOverlay = Boolean(showSkeleton && isLoading && !displaySrc && !incomingSrc)\n const paintedSrc = incomingSrc ?? displaySrc\n\n return (\n <div\n className={cn('a63-WidgetImage', containerClassName)}\n data-aspect={aspectRatio}\n data-slot=\"widget-image\"\n data-widget-image-crossfade={crossfade ? 'true' : undefined}\n data-widget-image-loading={isLoading ? 'true' : undefined}\n data-widget-image-src={paintedSrc}\n >\n {showSkeletonOverlay ? <Skeleton className=\"a63-WidgetImage-skeleton\" /> : null}\n {displaySrc ? (\n <img\n alt={incomingSrc ? '' : alt}\n aria-hidden={incomingSrc ? true : undefined}\n className={cn('a63-WidgetImage-img', className)}\n decoding={priority ? 'sync' : 'async'}\n loading={priority ? 'eager' : 'lazy'}\n onError={() => {\n if (incomingSrc) {\n return\n }\n setHasError(true)\n setIsLoading(false)\n }}\n onLoad={event => {\n setIsLoading(false)\n onLoadedImage?.(event.currentTarget)\n }}\n src={displaySrc}\n />\n ) : null}\n {incomingSrc ? (\n <img\n alt={alt}\n className={cn('a63-WidgetImage-img', 'a63-WidgetImage-incoming', className)}\n data-shown={incomingShown ? 'true' : undefined}\n decoding={priority ? 'sync' : 'async'}\n loading={priority ? 'eager' : 'lazy'}\n onLoad={event => onLoadedImage?.(event.currentTarget)}\n onTransitionEnd={event => {\n if (event.propertyName !== 'opacity') {\n return\n }\n setDisplaySrc(incomingSrc)\n setIncomingSrc(undefined)\n setIncomingShown(false)\n setIsLoading(false)\n }}\n src={incomingSrc}\n />\n ) : null}\n </div>\n )\n}\n","import {\n createContext,\n useContext,\n useMemo,\n type AnchorHTMLAttributes,\n type ComponentType,\n type ReactNode,\n} from 'react'\nimport { resolveDestination, type WidgetDestination } from './destination'\n\nexport type WidgetLinkProps = {\n href: string\n children?: ReactNode\n} & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, 'children' | 'href'>\n\ninterface WidgetLinkContextValue {\n Link?: ComponentType<WidgetLinkProps>\n origins: readonly string[]\n}\n\nconst EMPTY: WidgetLinkContextValue = { origins: [] }\n\nconst WidgetLinkContext = createContext<WidgetLinkContextValue>(EMPTY)\n\n/**\n * Supplies the component that in-app destinations render as, and the origins\n * this app answers for.\n *\n * Widgets link to app routes, but the package cannot import a router: it is\n * mounted in two apps with different navigation, and on atom63.io an in-app\n * portfolio href does not even change route — it opens the detail overlay on\n * the current page. So the host names the component and the widget asks for it.\n *\n * This is context rather than a prop because there is no prop channel to use.\n * Widgets reach the screen through a lazy registry whose entries are\n * `ComponentType<{ size }>`, composed by the agent's slot renderer — threading\n * a slot to them would mean changing that contract in both apps and in the\n * agent package. Navigation is an app-wide singleton, which is what context is\n * for.\n *\n * ## Why `origins` is not just `window.location.origin`\n *\n * Portfolio cards author one absolute `https://atom63.io/...` href for every\n * host, so \"is this mine?\" is decided by comparing origins. The running origin\n * alone answers that correctly in production and WRONGLY everywhere a change\n * is actually tested: on `localhost:5173` and on a `*.vercel.app` preview,\n * atom63.io's own cards compare as cross-origin and render as external links\n * that leave for production. A host that knows it IS atom63.io says so here,\n * and dev, preview and production agree.\n *\n * Only a host that can route should declare them: the origins decide which\n * links are treated as in-app, so claiming one you cannot route turns a\n * working external link into a dead in-app one.\n *\n * Opt-in by design: with no provider, in-app destinations fall back to a\n * native anchor and full-page navigate. That is a working link, just not a\n * routed one, so a host that forgets this degrades rather than breaks.\n *\n * External destinations never use it — they always open a plain new-tab anchor.\n *\n * @example\n * <WidgetLinkProvider Link={DetailHrefLink} origins={[PORTFOLIO_ORIGIN]}>\n * <AgentChat />\n * </WidgetLinkProvider>\n */\nexport function WidgetLinkProvider({\n children,\n Link,\n origins,\n}: {\n children: ReactNode\n Link: ComponentType<WidgetLinkProps>\n /** Origins this app serves, besides the one it is running on. */\n origins?: readonly string[]\n}) {\n const value = useMemo<WidgetLinkContextValue>(\n () => ({ Link, origins: origins ?? [] }),\n [Link, origins]\n )\n\n return <WidgetLinkContext.Provider value={value}>{children}</WidgetLinkContext.Provider>\n}\n\n/** The host's in-app link component, or undefined when none was provided. */\nexport function useWidgetLink(): ComponentType<WidgetLinkProps> | undefined {\n return useContext(WidgetLinkContext).Link\n}\n\n/**\n * Resolve a destination against the running origin AND any the host declared.\n *\n * Prefer this over calling `resolveDestination` directly from a view: the bare\n * function cannot see the host's origins, so it reports atom63.io's own cards\n * as external on localhost and on preview deployments.\n */\nexport function useWidgetDestination(href: string | undefined): WidgetDestination | null {\n const { origins } = useContext(WidgetLinkContext)\n return useMemo(() => resolveDestination(href, origins), [href, origins])\n}\n"]}
@@ -0,0 +1,123 @@
1
+ import * as React from 'react';
2
+ import { HTMLAttributes, ReactNode } from 'react';
3
+ export { W as WIDGET_BODY_INSET_CLASS, a as WidgetBlock, b as WidgetBlockContent, c as WidgetBlockFooter, d as WidgetBlockHeader, e as WidgetCard, f as WidgetCardContent, g as WidgetCardHeader, h as WidgetCardHeaderLeft, i as WidgetCardHeaderRight, j as WidgetCardRow, k as WidgetCardTextGroup, l as WidgetCardTitle, m as WidgetShell } from '../widget-card-BckLTmBY.js';
4
+ import { W as WidgetSize } from '../types-C0zDKyo1.js';
5
+
6
+ type WidgetAvatarSize = 'sm' | 'md' | 'lg' | 'xl';
7
+ interface WidgetAvatarProps {
8
+ alt?: string;
9
+ /** Loading or shuffling: reveals the overlay and shows a spinner. */
10
+ busy?: boolean;
11
+ className?: string;
12
+ fallback: string;
13
+ /** When provided, the avatar becomes a shuffle affordance (hover/focus reveal). */
14
+ onShuffle?: () => void;
15
+ shuffleLabel?: string;
16
+ /** Draws the primary accent ring (e.g. the featured card avatar). */
17
+ showOutline?: boolean;
18
+ size?: WidgetAvatarSize;
19
+ src?: string;
20
+ /**
21
+ * Shows the decorative presence dot seated on the circle's lower-right.
22
+ * The status meaning is conveyed textually elsewhere (e.g. a status badge),
23
+ * so the dot itself is aria-hidden.
24
+ */
25
+ status?: boolean;
26
+ }
27
+ /**
28
+ * Circular avatar primitive with an optional shuffle overlay and a presence dot.
29
+ * Chrome-agnostic and data-agnostic — widgets map their own data onto it.
30
+ *
31
+ * Per-size geometry (the avatar, the presence dot and the shuffle glyph) comes
32
+ * from the stylesheet, keyed on `data-widget-avatar-size`. The status dot is
33
+ * seated on the circle's lower-end arc, not the bounding-box corner.
34
+ */
35
+ declare const WidgetAvatar: React.NamedExoticComponent<WidgetAvatarProps>;
36
+
37
+ /**
38
+ * Outer shell of the themed widget surface — the rim.
39
+ *
40
+ * The rim is real geometry between the tile edge and the card face, so it can
41
+ * carry a gradient across the whole frame, its own backdrop-filter, and a
42
+ * smaller inner radius; a `box-shadow` inset can do none of those.
43
+ *
44
+ * It is a BORDER, not padding. Both inset the face identically, but only a
45
+ * border follows `border-radius` — it mitres around each corner arc and takes a
46
+ * per-side color. That is what lets a bevel theme light the top and left edges
47
+ * while darkening the bottom and right AT ANY RADIUS. Radius is a
48
+ * personalization axis, so the chrome has to hold up across it, not just at
49
+ * each theme's default.
50
+ *
51
+ * The drop shadow belongs here, on the outermost box, so it casts from the true
52
+ * tile edge. The shell's z-index scopes the face's material pseudo to this
53
+ * surface's own stacking context so it can't bleed behind sibling tiles.
54
+ *
55
+ * The declarations live in `@atom63/widgets/styles.css` (`.a63-WidgetSurface`).
56
+ */
57
+ declare const WIDGET_RIM_SHELL_CLASS = "a63-WidgetSurface";
58
+ /**
59
+ * Inner face of the themed widget surface — the card material.
60
+ *
61
+ * The frosted-glass fill + backdrop blur live on an isolated `::before` layer
62
+ * (behind the content), not on the face element itself. Decoupling the blur
63
+ * from content paint fixes the Chrome backdrop-filter flicker (crbug 41471914)
64
+ * and the border-radius bleed (crbug 41212594 / 41432992).
65
+ *
66
+ * Deliberately NOT `position: relative`: a host can compose this class with its
67
+ * own absolute positioning (a drag placeholder, for instance). `WidgetSurface`
68
+ * adds the positioning itself to anchor the ::before material to the face.
69
+ *
70
+ * The declarations live in `@atom63/widgets/styles.css`
71
+ * (`.a63-WidgetSurface-face`).
72
+ */
73
+ declare const WIDGET_CARD_SURFACE_CLASS = "a63-WidgetSurface-face";
74
+
75
+ /** Read the size of the nearest enclosing WidgetSurface (undefined outside one). */
76
+ declare function useWidgetSurfaceSize(): WidgetSize | undefined;
77
+ /**
78
+ * Publish a surface size WITHOUT any chrome.
79
+ *
80
+ * Use this inside a widget when an inner region only needs content blocks to
81
+ * read `useWidgetSurfaceSize()` for density. Reaching for `WidgetSurface` and
82
+ * switching its chrome off with `rounded-none border-0 bg-transparent
83
+ * before:hidden` no longer works: `className` lands on the face, so the rim
84
+ * shell still paints padding, background and radius — which renders as a
85
+ * nested card inside the widget.
86
+ */
87
+ declare function WidgetSurfaceSizeProvider({ children, size, }: {
88
+ children: ReactNode;
89
+ size: WidgetSize;
90
+ }): React.JSX.Element;
91
+ interface WidgetSurfaceProps extends HTMLAttributes<HTMLDivElement> {
92
+ children: ReactNode;
93
+ /** Grid footprint: 1×1, 2×1 or 2×2. Every widget is designed at all three. */
94
+ size: WidgetSize;
95
+ }
96
+ /**
97
+ * The sized surface primitive: themed chrome + size semantics. `size` is a
98
+ * signal (data attribute + context), not dimensions — the box comes from the
99
+ * consumption context (a grid tile). Content blocks read the size via
100
+ * useWidgetSurfaceSize() to adapt density.
101
+ *
102
+ * It nests two layers: an outer SHELL carrying the rim (real padded geometry,
103
+ * so it can hold a gradient across the whole frame) and an inner FACE carrying
104
+ * today's background, border, and the ::before backdrop.
105
+ * The shell is the surface root — `{...rest}` and the `data-widget-surface*`
106
+ * attributes live there, because measurement tooling queries them and the tile
107
+ * edge is the outer box.
108
+ *
109
+ * Consumer `className` is PARTITIONED between the two boxes, because real call
110
+ * sites mix both concerns in one string (`flex size-full min-h-0 flex-col`):
111
+ *
112
+ * - box classes (`w-80`, `size-full`, `aspect-[2/1]`) size the widget itself, so
113
+ * they move to the shell. Left on the face they constrain the material while
114
+ * the shell still stretches to its parent, leaving dead space along one edge.
115
+ * - flex-item and `overflow-*` classes apply to BOTH, since each box is a flex
116
+ * item of the one above and the shell owns the outer clip.
117
+ * - everything else stays on the face: inner layout (`flex-col`, `gap-3`,
118
+ * `p-4`) and the chrome escape hatches (`before:hidden`, `border-0`) that need
119
+ * to reach the element actually painting the material.
120
+ */
121
+ declare function WidgetSurface({ children, className, size, ...rest }: WidgetSurfaceProps): React.JSX.Element;
122
+
123
+ export { WIDGET_CARD_SURFACE_CLASS, WIDGET_RIM_SHELL_CLASS, WidgetAvatar, type WidgetAvatarProps, type WidgetAvatarSize, WidgetSurface, type WidgetSurfaceProps, WidgetSurfaceSizeProvider, useWidgetSurfaceSize };
@@ -0,0 +1,4 @@
1
+ export { WIDGET_BODY_INSET_CLASS, WIDGET_CARD_SURFACE_CLASS, WIDGET_RIM_SHELL_CLASS, WidgetAvatar, WidgetBlock, WidgetBlockContent, WidgetBlockFooter, WidgetBlockHeader, WidgetCard, WidgetCardContent, WidgetCardHeader, WidgetCardHeaderLeft, WidgetCardHeaderRight, WidgetCardRow, WidgetCardTextGroup, WidgetCardTitle, WidgetShell, WidgetSurface, WidgetSurfaceSizeProvider, useWidgetSurfaceSize } from '../chunk-US2CE3BV.js';
2
+ import '../chunk-F5NV6XJ5.js';
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,129 @@
1
+ import * as React from 'react';
2
+ import { ReactNode, ComponentProps } from 'react';
3
+ import { W as WidgetSize } from '../types-C0zDKyo1.js';
4
+ import { e as WidgetCard } from '../widget-card-BckLTmBY.js';
5
+
6
+ /** Shared centered spinner for widget content loading (module defer + data fetch). */
7
+ declare function WidgetContentFallback(): React.JSX.Element;
8
+
9
+ /**
10
+ * Crossfade inner widget content while the outer card shell stays mounted.
11
+ *
12
+ * Each layer grows from its top-start corner. `originClassName` adds a class
13
+ * to the layer to change that (a consumer utility such as `origin-center`
14
+ * outranks the stylesheet's default).
15
+ */
16
+ declare function WidgetHostContentTransition({ children, className, contentClassName, contentKey, originClassName, }: {
17
+ children: ReactNode;
18
+ className?: string;
19
+ contentClassName?: string;
20
+ contentKey: string;
21
+ originClassName?: string;
22
+ }): React.JSX.Element;
23
+
24
+ /** Widget card shell for runtime error boundaries (lazy load, render crash). */
25
+ declare function WidgetHostErrorFallback({ message, onRetry, size, title, }: {
26
+ message?: string;
27
+ onRetry?: () => void;
28
+ size: WidgetSize;
29
+ title?: string;
30
+ }): React.JSX.Element;
31
+
32
+ /**
33
+ * Card shell with a centered spinner only — no title (avoids header flash on
34
+ * resolve). Takes the footprint it is standing in for, so the chrome it paints
35
+ * while loading matches the chrome the widget paints once resolved.
36
+ */
37
+ declare function WidgetHostLoadingShell({ content, size, }: {
38
+ content?: ReactNode;
39
+ size: WidgetSize;
40
+ }): React.JSX.Element;
41
+
42
+ /** Header slot that only exists on some sizes (e.g. profile small). */
43
+ declare function WidgetHostOptionalHeader({ children, visible, }: {
44
+ children: ReactNode;
45
+ visible: boolean;
46
+ }): React.JSX.Element;
47
+
48
+ type WidgetHostTitleMotion = 'crossfade' | 'slide';
49
+ /** Crossfade title or header-end chrome while the header row stays mounted. */
50
+ declare function WidgetHostTitleTransition({ children, className, contentKey, variant, }: {
51
+ children: ReactNode;
52
+ className?: string;
53
+ contentKey: string;
54
+ variant?: WidgetHostTitleMotion;
55
+ }): React.JSX.Element;
56
+
57
+ /** Shell + content size transition duration (seconds) for widget resize + crossfade. */
58
+ declare const WIDGET_HOST_SIZE_TRANSITION_DURATION = 0.32;
59
+ declare const WIDGET_HOST_SIZE_TRANSITION_EASE: readonly [0.5, 0, 0, 1];
60
+ /** Blur amount for hosted content/title crossfades — masks reflow during shell resize. */
61
+ declare const WIDGET_HOST_CROSSFADE_BLUR = "6px";
62
+ /** Shared motion transition for desktop shell resize and inner content crossfade. */
63
+ declare const widgetHostSizeMotionTransition: {
64
+ readonly duration: 0.32;
65
+ readonly ease: readonly [0.5, 0, 0, 1];
66
+ };
67
+ type WidgetHostMotionPhase = 'active' | 'enter' | 'exit';
68
+ /** Motion returns null when no reduced-motion preference is set — treat that as animated. */
69
+ declare function shouldReduceWidgetHostMotion(reduceMotion: boolean | null): boolean;
70
+ /**
71
+ * Opacity + blur crossfade for inner widget content and title chrome.
72
+ * Blur is applied on clipped inner layers only — not the widget card shell —
73
+ * so themed backdrop-filter on the shell stays intact.
74
+ *
75
+ * The resting state is `none`, not `blur(0px)`. Any filter value other than
76
+ * `none` establishes a backdrop root, which neutralises `backdrop-filter` on
77
+ * everything below it — so a resting `blur(0px)` silently disables the blur
78
+ * ramp inside widgets that put text over photography. `none` costs nothing at
79
+ * rest and the animated phases still carry the blur.
80
+ */
81
+ declare function getWidgetHostCrossfadeMotion(phase: WidgetHostMotionPhase, reduceMotion: boolean | null): {
82
+ filter: string;
83
+ opacity: number;
84
+ };
85
+ /**
86
+ * Opacity-only swap for copy inside a locked height box (film title/year).
87
+ * No blur (glyph bounds) and no translate — even a small `y` shifts the
88
+ * visual mass of the line and reads as the text plate changing height.
89
+ */
90
+ declare function getWidgetHostSlideFadeMotion(phase: WidgetHostMotionPhase, reduceMotion: boolean | null): {
91
+ opacity: number;
92
+ };
93
+
94
+ /**
95
+ * Stable widget card shell with optional header and crossfading body content.
96
+ *
97
+ * ⚠ **`children` must supply their own inset** when there is no `footer`. This
98
+ * shell only wraps the body in a padded `WidgetBlock` when a `footer` is given.
99
+ * Pass a raw `<div>` and it sits flush against the face edge — which reads as a
100
+ * misaligned widget, not a missing wrapper, so it is easy to miss.
101
+ *
102
+ * Use one of:
103
+ * - `WidgetCardContent` — footprint-aware `widgetInsetStyle(size, 'body')`
104
+ * - `WidgetBlock` with `style={widgetInsetStyle(size, 'body')}`
105
+ * - chrome-less faces with `style={widgetInsetStyle(size, 'face')}`
106
+ *
107
+ * Give that slot `flex: 1` when the composition anchors anything to the bottom
108
+ * (`justify-content: space-between`, a pinned footer row). The slot otherwise
109
+ * sizes to its content, leaving the children bunched at the top above dead
110
+ * space.
111
+ *
112
+ * The padding is deliberately NOT unconditional: widgets that pad themselves
113
+ * would double up.
114
+ *
115
+ * The shell fills its host box. A `style` passed here lands on the surface's
116
+ * outer shell, after that fill.
117
+ */
118
+ declare function WidgetHostedShell({ children, className, contentClassName, contentKey, contentSlotClassName, footer, header, size, style, ...cardProps }: {
119
+ children: ReactNode;
120
+ className?: string;
121
+ contentClassName?: string;
122
+ contentKey: string;
123
+ contentSlotClassName?: string;
124
+ /** Pinned below the crossfading body inside the same block gap rhythm. */
125
+ footer?: ReactNode;
126
+ header?: ReactNode;
127
+ } & Omit<ComponentProps<typeof WidgetCard>, 'children'>): React.JSX.Element;
128
+
129
+ export { WIDGET_HOST_CROSSFADE_BLUR, WIDGET_HOST_SIZE_TRANSITION_DURATION, WIDGET_HOST_SIZE_TRANSITION_EASE, WidgetContentFallback, WidgetHostContentTransition, WidgetHostErrorFallback, WidgetHostLoadingShell, WidgetHostOptionalHeader, WidgetHostTitleTransition, WidgetHostedShell, getWidgetHostCrossfadeMotion, getWidgetHostSlideFadeMotion, shouldReduceWidgetHostMotion, widgetHostSizeMotionTransition };