@hjmds/react 1.28.0 → 1.29.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/auth-screen.d.ts +18 -1
- package/dist/auth-screen.d.ts.map +1 -1
- package/dist/auth-screen.js +10 -7
- package/dist/auth-screen.js.map +1 -1
- package/dist/collection-rail.d.ts +7 -1
- package/dist/collection-rail.d.ts.map +1 -1
- package/dist/collection-rail.js +7 -4
- package/dist/collection-rail.js.map +1 -1
- package/dist/evidence.d.ts +331 -1
- package/dist/evidence.d.ts.map +1 -1
- package/dist/evidence.js +52 -2
- package/dist/evidence.js.map +1 -1
- package/dist/feedback.d.ts +11 -0
- package/dist/feedback.d.ts.map +1 -1
- package/dist/feedback.js +3 -2
- package/dist/feedback.js.map +1 -1
- package/dist/forms.d.ts +21 -0
- package/dist/forms.d.ts.map +1 -1
- package/dist/forms.js +9 -4
- package/dist/forms.js.map +1 -1
- package/dist/internal/initial-focus.d.ts +48 -0
- package/dist/internal/initial-focus.d.ts.map +1 -0
- package/dist/internal/initial-focus.js +134 -0
- package/dist/internal/initial-focus.js.map +1 -0
- package/dist/modal.d.ts +18 -1
- package/dist/modal.d.ts.map +1 -1
- package/dist/modal.js +21 -4
- package/dist/modal.js.map +1 -1
- package/dist/overlays.d.ts +13 -0
- package/dist/overlays.d.ts.map +1 -1
- package/dist/overlays.js +14 -4
- package/dist/overlays.js.map +1 -1
- package/dist/screen-flows.d.ts +4 -2
- package/dist/screen-flows.d.ts.map +1 -1
- package/dist/screen-flows.js +7 -5
- package/dist/screen-flows.js.map +1 -1
- package/dist/screens.d.ts +19 -1
- package/dist/screens.d.ts.map +1 -1
- package/dist/screens.js +19 -9
- package/dist/screens.js.map +1 -1
- package/dist/styles.css +15 -3
- package/dist/styles.layered.css +15 -3
- package/package.json +3 -3
package/dist/auth-screen.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type AuthScreenDensity, type AuthScreenDescriptor, type AuthScreenHeroDescriptor, type AuthScreenPolicyLinkDescriptor } from "@hjmds/design-contracts/components/auth-screen";
|
|
2
|
-
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { type HTMLAttributeAnchorTarget, type HTMLAttributes, type ReactNode } from "react";
|
|
3
|
+
import { type ScreenInitialFocus } from "@hjmds/design-contracts/screen-patterns";
|
|
3
4
|
import type { HjmCompositionStyleProp } from "./composition-style.js";
|
|
4
5
|
export type AuthScreenLayoutProps = Omit<HTMLAttributes<HTMLElement>, "children"> & AuthScreenDescriptor & Readonly<{
|
|
5
6
|
/** Use section inside a product shell that already owns the main landmark. */
|
|
@@ -17,6 +18,11 @@ export type AuthScreenLayoutProps = Omit<HTMLAttributes<HTMLElement>, "children"
|
|
|
17
18
|
className?: string;
|
|
18
19
|
/** Canonical layout-only placement on the root element. Controlled visual keys are excluded. */
|
|
19
20
|
layoutStyle?: HjmCompositionStyleProp;
|
|
21
|
+
/**
|
|
22
|
+
* Entry focus, same rules as ScreenLayout `initialFocus`. Off by default because auth screens lead with provider
|
|
23
|
+
* buttons; a signup nickname step opts in with `first-input` (2026-10-18 adoption, same as Native).
|
|
24
|
+
*/
|
|
25
|
+
initialFocus?: ScreenInitialFocus;
|
|
20
26
|
}>;
|
|
21
27
|
/**
|
|
22
28
|
* Two regions: hero + main stay one vertically centred block, the footer sits at
|
|
@@ -42,6 +48,11 @@ export declare const AuthScreenLayout: import("react").ForwardRefExoticComponent
|
|
|
42
48
|
className?: string;
|
|
43
49
|
/** Canonical layout-only placement on the root element. Controlled visual keys are excluded. */
|
|
44
50
|
layoutStyle?: HjmCompositionStyleProp;
|
|
51
|
+
/**
|
|
52
|
+
* Entry focus, same rules as ScreenLayout `initialFocus`. Off by default because auth screens lead with provider
|
|
53
|
+
* buttons; a signup nickname step opts in with `first-input` (2026-10-18 adoption, same as Native).
|
|
54
|
+
*/
|
|
55
|
+
initialFocus?: ScreenInitialFocus;
|
|
45
56
|
}> & import("react").RefAttributes<HTMLElement>>;
|
|
46
57
|
export type AuthScreenHeroProps = AuthScreenHeroDescriptor & Readonly<{
|
|
47
58
|
/** Product mark asset. HJM never ships product marks. */
|
|
@@ -56,6 +67,12 @@ export declare function AuthScreenHero({ mark, title, eyebrow, description, head
|
|
|
56
67
|
export type AuthScreenPolicyLink = AuthScreenPolicyLinkDescriptor & Readonly<{
|
|
57
68
|
/** Document URL; renders an anchor. */
|
|
58
69
|
href?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Anchor target with `href`, e.g. `_blank` for policy documents that open beside the app (diairy web lost its
|
|
72
|
+
* new-tab links on adoption, 2026-10-17). `rel` defaults to "noreferrer noopener" for `_blank`, as on Link.
|
|
73
|
+
*/
|
|
74
|
+
target?: HTMLAttributeAnchorTarget;
|
|
75
|
+
rel?: string;
|
|
59
76
|
/** In-app handler; renders a button when there is no `href`. */
|
|
60
77
|
onClick?: () => void;
|
|
61
78
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-screen.d.ts","sourceRoot":"","sources":["../src/auth-screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACpC,MAAM,gDAAgD,CAAC;AAExD,OAAO,EAA+G,KAAK,cAAc,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"auth-screen.d.ts","sourceRoot":"","sources":["../src/auth-screen.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACpC,MAAM,gDAAgD,CAAC;AAExD,OAAO,EAA+G,KAAK,yBAAyB,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAS,MAAM,OAAO,CAAC;AAChN,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,yCAAyC,CAAC;AAGxG,OAAO,KA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AA8B,GAC/D,QAAQ,CAAC;IACP,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,yBAAyB,CAAC;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC,CAAC;AAEL,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,uCAAuC;IACvC,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,iEAAiE;IACjE,KAAK,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACvC,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC,CAAC;AAEH;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,qBAAqB,+BA8BlF"}
|
package/dist/auth-screen.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { authScreenRecipe, resolveAuthScreenDescriptor, validateAuthScreenHeroDescriptor, validateAuthScreenPolicyLinks, } from "@hjmds/design-contracts/components/auth-screen";
|
|
3
3
|
import { typography } from "@hjmds/design-contracts/foundations";
|
|
4
|
-
import { createContext, createElement, forwardRef, Fragment, useContext, useLayoutEffect, useRef } from "react";
|
|
4
|
+
import { createContext, createElement, forwardRef, Fragment, useContext, useLayoutEffect, useRef, useId } from "react";
|
|
5
|
+
import { initialFocusDefaults } from "@hjmds/design-contracts/screen-patterns";
|
|
5
6
|
import { classNames, useDesignProfileDefaults } from "./internal.js";
|
|
7
|
+
import { InitialFocusScope } from "./internal/initial-focus.js";
|
|
6
8
|
// The hero follows the layout density without the product passing it twice.
|
|
7
9
|
const AuthScreenDensityContext = createContext(undefined);
|
|
8
10
|
/**
|
|
@@ -10,7 +12,7 @@ const AuthScreenDensityContext = createContext(undefined);
|
|
|
10
12
|
* the bottom. The measurements come from the resolved descriptor as custom
|
|
11
13
|
* properties so the stylesheet keeps one source of truth with the contract.
|
|
12
14
|
*/
|
|
13
|
-
export const AuthScreenLayout = forwardRef(function AuthScreenLayout({ hero, main, footer, density, hasFooter, pendingLabel, mainCard = false, className, as: Element = "main", layoutStyle, ...props }, forwardedRef) {
|
|
15
|
+
export const AuthScreenLayout = forwardRef(function AuthScreenLayout({ hero, main, footer, density, hasFooter, pendingLabel, mainCard = false, className, as: Element = "main", layoutStyle, initialFocus = initialFocusDefaults.auth, ...props }, forwardedRef) {
|
|
14
16
|
const resolved = resolveAuthScreenDescriptor({
|
|
15
17
|
...(density === undefined ? {} : { density }),
|
|
16
18
|
...(hasFooter === undefined ? {} : { hasFooter }),
|
|
@@ -31,7 +33,7 @@ export const AuthScreenLayout = forwardRef(function AuthScreenLayout({ hero, mai
|
|
|
31
33
|
}, [pending]);
|
|
32
34
|
if (pending && !pendingLabel.trim())
|
|
33
35
|
throw new TypeError("AuthScreen pendingLabel must not be empty");
|
|
34
|
-
return (
|
|
36
|
+
return (_jsx(Element, { ...props, ref: forwardedRef, className: classNames("hjm-auth-screen", className), "data-density": resolved.density, style: {
|
|
35
37
|
["--hjm-auth-screen-max-width"]: `${resolved.maxWidth}px`,
|
|
36
38
|
["--hjm-auth-screen-hero-gap"]: `${resolved.heroGap}px`,
|
|
37
39
|
["--hjm-auth-screen-main-gap"]: `${resolved.mainGap}px`,
|
|
@@ -40,8 +42,8 @@ export const AuthScreenLayout = forwardRef(function AuthScreenLayout({ hero, mai
|
|
|
40
42
|
["--hjm-auth-screen-padding-block"]: `${resolved.paddingBlock}px`,
|
|
41
43
|
...props.style,
|
|
42
44
|
...layoutStyle,
|
|
43
|
-
}, children: [_jsxs("div", { className: "hjm-auth-screen__block", children: [_jsx(AuthScreenDensityContext.Provider, { value: resolved.density, children: _jsx("div", { className: "hjm-auth-screen__hero", children: hero }) }), _jsxs("div", { className: "hjm-auth-screen__main", "data-card": mainCard || undefined, "aria-busy": pending || undefined, children: [_jsx("div", { ref: actionsRef, className: "hjm-auth-screen__actions", inert: pending, "aria-hidden": pending || undefined, onFocusCapture: event => { focusedAction.current = event.target; }, onBlurCapture: event => { if (!pending && !event.currentTarget.contains(event.relatedTarget))
|
|
44
|
-
|
|
45
|
+
}, children: _jsxs(InitialFocusScope, { mode: initialFocus, children: [_jsxs("div", { className: "hjm-auth-screen__block", children: [_jsx(AuthScreenDensityContext.Provider, { value: resolved.density, children: _jsx("div", { className: "hjm-auth-screen__hero", children: hero }) }), _jsxs("div", { className: "hjm-auth-screen__main", "data-card": mainCard || undefined, "aria-busy": pending || undefined, children: [_jsx("div", { ref: actionsRef, className: "hjm-auth-screen__actions", inert: pending, "aria-hidden": pending || undefined, onFocusCapture: event => { focusedAction.current = event.target; }, onBlurCapture: event => { if (!pending && !event.currentTarget.contains(event.relatedTarget))
|
|
46
|
+
focusedAction.current = null; }, style: pending ? { visibility: "hidden" } : undefined, children: main }), pending ? _jsx("div", { className: "hjm-auth-screen__pending", role: "status", "aria-label": pendingLabel, children: _jsx("span", { className: "hjm-auth-provider-button__spinner", "aria-hidden": "true" }) }) : null] })] }), showFooter ? _jsx("div", { className: "hjm-auth-screen__footer", children: footer }) : null] }) }));
|
|
45
47
|
});
|
|
46
48
|
/** Token weight per variant, following the nearest design profile like `Text` does. */
|
|
47
49
|
function useTypeWeight() {
|
|
@@ -81,11 +83,12 @@ export function AuthScreenFooter({ notice, links, children }) {
|
|
|
81
83
|
const recipe = authScreenRecipe.footer;
|
|
82
84
|
const weight = useTypeWeight();
|
|
83
85
|
const linkStyle = { fontWeight: weight(recipe.link.textVariant) };
|
|
86
|
+
const hintId = useId();
|
|
84
87
|
return (_jsxs("div", { className: "hjm-auth-screen__footer-content", style: { gap: recipe.noticeGap }, children: [notice ? _jsx("p", { className: "hjm-text", "data-variant": recipe.notice.textVariant, "data-font-role": "ui", "data-tone": recipe.notice.tone, style: { fontWeight: weight(recipe.notice.textVariant) }, children: notice }) : null, _jsx("div", { className: "hjm-auth-screen__links", style: {
|
|
85
88
|
["--hjm-auth-screen-link-gap"]: `${recipe.linkGap}px`,
|
|
86
89
|
["--hjm-auth-screen-link-target"]: `${authScreenRecipe.footerMinTouchTarget}px`,
|
|
87
90
|
}, children: links.map((link, index) => (_jsxs(Fragment, { children: [index > 0 ? _jsx("span", { className: "hjm-text hjm-auth-screen__separator", "data-variant": recipe.link.textVariant, "data-tone": recipe.notice.tone, "aria-hidden": "true", children: recipe.separator }) : null, link.href !== undefined
|
|
88
|
-
? _jsx("a", { className: "hjm-text hjm-auth-screen__link", "data-variant": recipe.link.textVariant, "data-font-role": "ui", "data-tone": recipe.link.tone, style: linkStyle, href: link.href, onClick: link.onClick, children: link.label })
|
|
89
|
-
: _jsx("button", { type: "button", className: "hjm-text hjm-auth-screen__link", "data-variant": recipe.link.textVariant, "data-font-role": "ui", "data-tone": recipe.link.tone, style: linkStyle, onClick: link.onClick, children: link.label })] }, `${index}:${link.label}`))) }), children] }));
|
|
91
|
+
? _jsx("a", { className: "hjm-text hjm-auth-screen__link", "data-variant": recipe.link.textVariant, "data-font-role": "ui", "data-tone": recipe.link.tone, style: linkStyle, href: link.href, target: link.target, rel: link.rel ?? (link.target === "_blank" ? "noreferrer noopener" : undefined), "aria-describedby": link.accessibilityHint === undefined ? undefined : `${hintId}-${index}`, onClick: link.onClick, children: link.label })
|
|
92
|
+
: _jsx("button", { type: "button", className: "hjm-text hjm-auth-screen__link", "data-variant": recipe.link.textVariant, "data-font-role": "ui", "data-tone": recipe.link.tone, style: linkStyle, "aria-describedby": link.accessibilityHint === undefined ? undefined : `${hintId}-${index}`, onClick: link.onClick, children: link.label }), link.accessibilityHint === undefined ? null : _jsx("span", { id: `${hintId}-${index}`, className: "hjm-visually-hidden", children: link.accessibilityHint })] }, `${index}:${link.label}`))) }), children] }));
|
|
90
93
|
}
|
|
91
94
|
//# sourceMappingURL=auth-screen.js.map
|
package/dist/auth-scre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E,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,YAAG,IAAI,CAAC,KAAK,GAAU,KAJ9M,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAK5B,CACZ,CAAC,GACE,EACL,QAAQ,IACL,CACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n authScreenRecipe,\n resolveAuthScreenDescriptor,\n validateAuthScreenHeroDescriptor,\n validateAuthScreenPolicyLinks,\n type AuthScreenDensity,\n type AuthScreenDescriptor,\n type AuthScreenHeroDescriptor,\n type AuthScreenPolicyLinkDescriptor,\n} from \"@hjmds/design-contracts/components/auth-screen\";\nimport { typography, type TextVariant } from \"@hjmds/design-contracts/foundations\";\nimport { createContext, createElement, forwardRef, Fragment, useContext, useLayoutEffect, useRef, type CSSProperties, type HTMLAttributes, type ReactNode } from \"react\";\nimport { classNames, useDesignProfileDefaults } from \"./internal.js\";\nimport type { HjmCompositionStyleProp } from \"./composition-style.js\";\n\n// The hero follows the layout density without the product passing it twice.\nconst AuthScreenDensityContext = createContext<AuthScreenDensity | undefined>(undefined);\n\nexport type AuthScreenLayoutProps = Omit<HTMLAttributes<HTMLElement>, \"children\"> &\n AuthScreenDescriptor &\n Readonly<{\n /** Use section inside a product shell that already owns the main landmark. */\n as?: \"main\" | \"section\";\n /** Product mark, title and description. The product owns every string here. */\n hero: ReactNode;\n /** The primary action block — provider buttons, or a product's own sign-in bundle. */\n main: ReactNode;\n /** Product-localized progress label; presence replaces actions with one centred loader. */\n pendingLabel?: string;\n /** Let the layout own the action card; omit when the product already supplies a surface. */\n mainCard?: boolean;\n /** Consent notice and policy links. Omit with `hasFooter: false`. */\n footer?: ReactNode;\n className?: string;\n /** Canonical layout-only placement on the root element. Controlled visual keys are excluded. */\n layoutStyle?: HjmCompositionStyleProp;\n }>;\n\n/**\n * Two regions: hero + main stay one vertically centred block, the footer sits at\n * the bottom. The measurements come from the resolved descriptor as custom\n * properties so the stylesheet keeps one source of truth with the contract.\n */\nexport const AuthScreenLayout = forwardRef<HTMLElement, AuthScreenLayoutProps>(\n function AuthScreenLayout(\n { hero, main, footer, density, hasFooter, pendingLabel, mainCard = false, className, as: Element = \"main\", layoutStyle, ...props },\n forwardedRef,\n ) {\n const resolved = resolveAuthScreenDescriptor({\n ...(density === undefined ? {} : { density }),\n ...(hasFooter === undefined ? {} : { hasFooter }),\n });\n const showFooter = resolved.hasFooter && footer !== undefined && footer !== null;\n const pending = pendingLabel !== undefined;\n const actionsRef = useRef<HTMLDivElement>(null);\n const focusedAction = useRef<HTMLElement | null>(null);\n const wasPending = useRef(pending);\n useLayoutEffect(() => {\n // Inert loading content sends keyboard focus to body. Resume at the same\n // action after failure/cancellation, unless the user moved somewhere else.\n const target = focusedAction.current;\n if (wasPending.current && !pending && document.activeElement === document.body && target?.isConnected && actionsRef.current?.contains(target)) {\n target.focus({ preventScroll: true });\n }\n wasPending.current = pending;\n }, [pending]);\n if (pending && !pendingLabel.trim()) throw new TypeError(\"AuthScreen pendingLabel must not be empty\");\n return (\n <Element\n {...props}\n ref={forwardedRef}\n className={classNames(\"hjm-auth-screen\", className)}\n data-density={resolved.density}\n style={{\n [\"--hjm-auth-screen-max-width\" as string]: `${resolved.maxWidth}px`,\n [\"--hjm-auth-screen-hero-gap\" as string]: `${resolved.heroGap}px`,\n [\"--hjm-auth-screen-main-gap\" as string]: `${resolved.mainGap}px`,\n [\"--hjm-auth-screen-footer-gap\" as string]: `${resolved.footerGap}px`,\n [\"--hjm-auth-screen-padding-inline\" as string]: `${resolved.paddingInline}px`,\n [\"--hjm-auth-screen-padding-block\" as string]: `${resolved.paddingBlock}px`,\n ...props.style,\n ...layoutStyle,\n }}\n >\n <div className=\"hjm-auth-screen__block\">\n <AuthScreenDensityContext.Provider value={resolved.density}><div className=\"hjm-auth-screen__hero\">{hero}</div></AuthScreenDensityContext.Provider>\n <div className=\"hjm-auth-screen__main\" data-card={mainCard || undefined} aria-busy={pending || undefined}>\n {/* Keep the action block in flow so the card never collapses; inert also removes keyboard access. */}\n <div ref={actionsRef} className=\"hjm-auth-screen__actions\" inert={pending} aria-hidden={pending || undefined}\n onFocusCapture={event => { focusedAction.current = event.target; }}\n onBlurCapture={event => { if (!pending && !event.currentTarget.contains(event.relatedTarget)) focusedAction.current = null; }}\n style={pending ? { visibility: \"hidden\" } : undefined}>{main}</div>\n {pending ? <div className=\"hjm-auth-screen__pending\" role=\"status\" aria-label={pendingLabel}>\n <span className=\"hjm-auth-provider-button__spinner\" aria-hidden=\"true\" />\n </div> : null}\n </div>\n </div>\n {showFooter ? <div className=\"hjm-auth-screen__footer\">{footer}</div> : null}\n </Element>\n );\n },\n);\n\n/** Token weight per variant, following the nearest design profile like `Text` does. */\nfunction useTypeWeight(): (variant: TextVariant) => number | string {\n const profile = useDesignProfileDefaults();\n const tokens = profile?.tokens.typography ?? typography;\n return variant => tokens[variant].fontWeight;\n}\n\nexport type AuthScreenHeroProps = AuthScreenHeroDescriptor &\n Readonly<{\n /** Product mark asset. HJM never ships product marks. */\n mark?: ReactNode;\n }>;\n\n/**\n * The `hero` slot content: mark, eyebrow, tagline and one description line. The\n * product supplies the strings and mark; the type steps, tones and gaps come from\n * `authScreenRecipe.hero` so a login slogan never borrows the page-heading size.\n */\nexport function AuthScreenHero({ mark, title, eyebrow, description, headingLevel = 1 }: AuthScreenHeroProps) {\n validateAuthScreenHeroDescriptor({ title, ...(eyebrow === undefined ? {} : { eyebrow }), ...(description === undefined ? {} : { description }), headingLevel });\n const density = useContext(AuthScreenDensityContext);\n const variant = resolveAuthScreenDescriptor(density === undefined ? {} : { density }).titleVariant;\n const weight = useTypeWeight();\n const recipe = authScreenRecipe.hero;\n // Fragment: the mark and the copy are direct children of the hero so the\n // recipe hero gap separates them on both platforms.\n return (\n <Fragment>\n {mark ? <div className=\"hjm-auth-screen__mark\">{mark}</div> : null}\n <div className=\"hjm-auth-screen__copy\">\n {eyebrow ? <p className=\"hjm-text hjm-auth-screen__eyebrow\" data-variant={recipe.eyebrow.textVariant} data-font-role=\"ui\" data-tone={recipe.eyebrow.tone}\n style={{ marginBlockEnd: recipe.eyebrow.gapBelow, fontWeight: weight(recipe.eyebrow.textVariant) }}>{eyebrow}</p> : null}\n {/* A real heading element: the tagline is the route's first heading. */}\n {createElement(`h${headingLevel}`, {\n className: \"hjm-text hjm-auth-screen__title\",\n \"data-variant\": variant,\n \"data-font-role\": \"display\",\n \"data-tone\": recipe.title.tone,\n // The title step's own weight (500), not Text's regular default outside a profile.\n style: { fontWeight: weight(variant) },\n }, title)}\n {description ? <p className=\"hjm-text hjm-auth-screen__description\" data-variant={recipe.description.textVariant} data-font-role=\"ui\" data-tone={recipe.description.tone}\n style={{ marginBlockStart: recipe.description.gapAbove, fontWeight: weight(recipe.description.textVariant) }}>{description}</p> : null}\n </div>\n </Fragment>\n );\n}\n\nexport type AuthScreenPolicyLink = AuthScreenPolicyLinkDescriptor &\n Readonly<{\n /** Document URL; renders an anchor. */\n href?: string;\n /** In-app handler; renders a button when there is no `href`. */\n onClick?: () => void;\n }>;\n\nexport type AuthScreenFooterProps = Readonly<{\n /** Optional consent notice (LS-04). */\n notice?: ReactNode;\n /** Terms and privacy links; at least one is required (LS-04). */\n links: readonly AuthScreenPolicyLink[];\n /** Extra product content under the links. */\n children?: ReactNode;\n}>;\n\n/**\n * The `footer` slot content: consent notice plus dot-separated policy links. The\n * visible gap between two links is `linkGap` + separator + `linkGap`; the 44px\n * touch target is an invisible hit area, not visible padding.\n */\nexport function AuthScreenFooter({ notice, links, children }: AuthScreenFooterProps) {\n validateAuthScreenPolicyLinks(links);\n const recipe = authScreenRecipe.footer;\n const weight = useTypeWeight();\n const linkStyle = { fontWeight: weight(recipe.link.textVariant) };\n return (\n <div className=\"hjm-auth-screen__footer-content\" style={{ gap: recipe.noticeGap }}>\n {notice ? <p className=\"hjm-text\" data-variant={recipe.notice.textVariant} data-font-role=\"ui\" data-tone={recipe.notice.tone} style={{ fontWeight: weight(recipe.notice.textVariant) }}>{notice}</p> : null}\n <div className=\"hjm-auth-screen__links\" style={{\n [\"--hjm-auth-screen-link-gap\" as string]: `${recipe.linkGap}px`,\n [\"--hjm-auth-screen-link-target\" as string]: `${authScreenRecipe.footerMinTouchTarget}px`,\n } as CSSProperties}>\n {links.map((link, index) => (\n <Fragment key={`${index}:${link.label}`}>\n {index > 0 ? <span className=\"hjm-text hjm-auth-screen__separator\" data-variant={recipe.link.textVariant} data-tone={recipe.notice.tone} aria-hidden=\"true\">{recipe.separator}</span> : null}\n {link.href !== undefined\n ? <a className=\"hjm-text hjm-auth-screen__link\" data-variant={recipe.link.textVariant} data-font-role=\"ui\" data-tone={recipe.link.tone} style={linkStyle} href={link.href} onClick={link.onClick}>{link.label}</a>\n : <button type=\"button\" className=\"hjm-text hjm-auth-screen__link\" data-variant={recipe.link.textVariant} data-font-role=\"ui\" data-tone={recipe.link.tone} style={linkStyle} onClick={link.onClick}>{link.label}</button>}\n </Fragment>\n ))}\n </div>\n {children}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"auth-screen.js","sourceRoot":"","sources":["../src/auth-screen.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,gBAAgB,EAChB,2BAA2B,EAC3B,gCAAgC,EAChC,6BAA6B,GAK9B,MAAM,gDAAgD,CAAC;AACxD,OAAO,EAAE,UAAU,EAAoB,MAAM,qCAAqC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAA2F,KAAK,EAAE,MAAM,OAAO,CAAC;AAChN,OAAO,EAAE,oBAAoB,EAA2B,MAAM,yCAAyC,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,4EAA4E;AAC5E,MAAM,wBAAwB,GAAG,aAAa,CAAgC,SAAS,CAAC,CAAC;AA2BzF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M,IAAI,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,YAAG,IAAI,CAAC,KAAK,GAAU,EAE5I,IAAI,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAM,EAAE,EAAE,GAAG,MAAM,IAAI,KAAK,EAAE,EAAE,SAAS,EAAC,qBAAqB,YAAE,IAAI,CAAC,iBAAiB,GAAQ,KATjI,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAU5B,CACZ,CAAC,GACE,EACL,QAAQ,IACL,CACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n authScreenRecipe,\n resolveAuthScreenDescriptor,\n validateAuthScreenHeroDescriptor,\n validateAuthScreenPolicyLinks,\n type AuthScreenDensity,\n type AuthScreenDescriptor,\n type AuthScreenHeroDescriptor,\n type AuthScreenPolicyLinkDescriptor,\n} from \"@hjmds/design-contracts/components/auth-screen\";\nimport { typography, type TextVariant } from \"@hjmds/design-contracts/foundations\";\nimport { createContext, createElement, forwardRef, Fragment, useContext, useLayoutEffect, useRef, type CSSProperties, type HTMLAttributeAnchorTarget, type HTMLAttributes, type ReactNode, useId } from \"react\";\nimport { initialFocusDefaults, type ScreenInitialFocus } from \"@hjmds/design-contracts/screen-patterns\";\nimport { classNames, useDesignProfileDefaults } from \"./internal.js\";\nimport { InitialFocusScope } from \"./internal/initial-focus.js\";\nimport type { HjmCompositionStyleProp } from \"./composition-style.js\";\n\n// The hero follows the layout density without the product passing it twice.\nconst AuthScreenDensityContext = createContext<AuthScreenDensity | undefined>(undefined);\n\nexport type AuthScreenLayoutProps = Omit<HTMLAttributes<HTMLElement>, \"children\"> &\n AuthScreenDescriptor &\n Readonly<{\n /** Use section inside a product shell that already owns the main landmark. */\n as?: \"main\" | \"section\";\n /** Product mark, title and description. The product owns every string here. */\n hero: ReactNode;\n /** The primary action block — provider buttons, or a product's own sign-in bundle. */\n main: ReactNode;\n /** Product-localized progress label; presence replaces actions with one centred loader. */\n pendingLabel?: string;\n /** Let the layout own the action card; omit when the product already supplies a surface. */\n mainCard?: boolean;\n /** Consent notice and policy links. Omit with `hasFooter: false`. */\n footer?: ReactNode;\n className?: string;\n /** Canonical layout-only placement on the root element. Controlled visual keys are excluded. */\n layoutStyle?: HjmCompositionStyleProp;\n /**\n * Entry focus, same rules as ScreenLayout `initialFocus`. Off by default because auth screens lead with provider\n * buttons; a signup nickname step opts in with `first-input` (2026-10-18 adoption, same as Native).\n */\n initialFocus?: ScreenInitialFocus;\n }>;\n\n/**\n * Two regions: hero + main stay one vertically centred block, the footer sits at\n * the bottom. The measurements come from the resolved descriptor as custom\n * properties so the stylesheet keeps one source of truth with the contract.\n */\nexport const AuthScreenLayout = forwardRef<HTMLElement, AuthScreenLayoutProps>(\n function AuthScreenLayout(\n { hero, main, footer, density, hasFooter, pendingLabel, mainCard = false, className, as: Element = \"main\", layoutStyle, initialFocus = initialFocusDefaults.auth, ...props },\n forwardedRef,\n ) {\n const resolved = resolveAuthScreenDescriptor({\n ...(density === undefined ? {} : { density }),\n ...(hasFooter === undefined ? {} : { hasFooter }),\n });\n const showFooter = resolved.hasFooter && footer !== undefined && footer !== null;\n const pending = pendingLabel !== undefined;\n const actionsRef = useRef<HTMLDivElement>(null);\n const focusedAction = useRef<HTMLElement | null>(null);\n const wasPending = useRef(pending);\n useLayoutEffect(() => {\n // Inert loading content sends keyboard focus to body. Resume at the same\n // action after failure/cancellation, unless the user moved somewhere else.\n const target = focusedAction.current;\n if (wasPending.current && !pending && document.activeElement === document.body && target?.isConnected && actionsRef.current?.contains(target)) {\n target.focus({ preventScroll: true });\n }\n wasPending.current = pending;\n }, [pending]);\n if (pending && !pendingLabel.trim()) throw new TypeError(\"AuthScreen pendingLabel must not be empty\");\n return (\n <Element\n {...props}\n ref={forwardedRef}\n className={classNames(\"hjm-auth-screen\", className)}\n data-density={resolved.density}\n style={{\n [\"--hjm-auth-screen-max-width\" as string]: `${resolved.maxWidth}px`,\n [\"--hjm-auth-screen-hero-gap\" as string]: `${resolved.heroGap}px`,\n [\"--hjm-auth-screen-main-gap\" as string]: `${resolved.mainGap}px`,\n [\"--hjm-auth-screen-footer-gap\" as string]: `${resolved.footerGap}px`,\n [\"--hjm-auth-screen-padding-inline\" as string]: `${resolved.paddingInline}px`,\n [\"--hjm-auth-screen-padding-block\" as string]: `${resolved.paddingBlock}px`,\n ...props.style,\n ...layoutStyle,\n }}\n >\n <InitialFocusScope mode={initialFocus}>\n <div className=\"hjm-auth-screen__block\">\n <AuthScreenDensityContext.Provider value={resolved.density}><div className=\"hjm-auth-screen__hero\">{hero}</div></AuthScreenDensityContext.Provider>\n <div className=\"hjm-auth-screen__main\" data-card={mainCard || undefined} aria-busy={pending || undefined}>\n {/* Keep the action block in flow so the card never collapses; inert also removes keyboard access. */}\n <div ref={actionsRef} className=\"hjm-auth-screen__actions\" inert={pending} aria-hidden={pending || undefined}\n onFocusCapture={event => { focusedAction.current = event.target; }}\n onBlurCapture={event => { if (!pending && !event.currentTarget.contains(event.relatedTarget)) focusedAction.current = null; }}\n style={pending ? { visibility: \"hidden\" } : undefined}>{main}</div>\n {pending ? <div className=\"hjm-auth-screen__pending\" role=\"status\" aria-label={pendingLabel}>\n <span className=\"hjm-auth-provider-button__spinner\" aria-hidden=\"true\" />\n </div> : null}\n </div>\n </div>\n {showFooter ? <div className=\"hjm-auth-screen__footer\">{footer}</div> : null}\n </InitialFocusScope>\n </Element>\n );\n },\n);\n\n/** Token weight per variant, following the nearest design profile like `Text` does. */\nfunction useTypeWeight(): (variant: TextVariant) => number | string {\n const profile = useDesignProfileDefaults();\n const tokens = profile?.tokens.typography ?? typography;\n return variant => tokens[variant].fontWeight;\n}\n\nexport type AuthScreenHeroProps = AuthScreenHeroDescriptor &\n Readonly<{\n /** Product mark asset. HJM never ships product marks. */\n mark?: ReactNode;\n }>;\n\n/**\n * The `hero` slot content: mark, eyebrow, tagline and one description line. The\n * product supplies the strings and mark; the type steps, tones and gaps come from\n * `authScreenRecipe.hero` so a login slogan never borrows the page-heading size.\n */\nexport function AuthScreenHero({ mark, title, eyebrow, description, headingLevel = 1 }: AuthScreenHeroProps) {\n validateAuthScreenHeroDescriptor({ title, ...(eyebrow === undefined ? {} : { eyebrow }), ...(description === undefined ? {} : { description }), headingLevel });\n const density = useContext(AuthScreenDensityContext);\n const variant = resolveAuthScreenDescriptor(density === undefined ? {} : { density }).titleVariant;\n const weight = useTypeWeight();\n const recipe = authScreenRecipe.hero;\n // Fragment: the mark and the copy are direct children of the hero so the\n // recipe hero gap separates them on both platforms.\n return (\n <Fragment>\n {mark ? <div className=\"hjm-auth-screen__mark\">{mark}</div> : null}\n <div className=\"hjm-auth-screen__copy\">\n {eyebrow ? <p className=\"hjm-text hjm-auth-screen__eyebrow\" data-variant={recipe.eyebrow.textVariant} data-font-role=\"ui\" data-tone={recipe.eyebrow.tone}\n style={{ marginBlockEnd: recipe.eyebrow.gapBelow, fontWeight: weight(recipe.eyebrow.textVariant) }}>{eyebrow}</p> : null}\n {/* A real heading element: the tagline is the route's first heading. */}\n {createElement(`h${headingLevel}`, {\n className: \"hjm-text hjm-auth-screen__title\",\n \"data-variant\": variant,\n \"data-font-role\": \"display\",\n \"data-tone\": recipe.title.tone,\n // The title step's own weight (500), not Text's regular default outside a profile.\n style: { fontWeight: weight(variant) },\n }, title)}\n {description ? <p className=\"hjm-text hjm-auth-screen__description\" data-variant={recipe.description.textVariant} data-font-role=\"ui\" data-tone={recipe.description.tone}\n style={{ marginBlockStart: recipe.description.gapAbove, fontWeight: weight(recipe.description.textVariant) }}>{description}</p> : null}\n </div>\n </Fragment>\n );\n}\n\nexport type AuthScreenPolicyLink = AuthScreenPolicyLinkDescriptor &\n Readonly<{\n /** Document URL; renders an anchor. */\n href?: string;\n /**\n * Anchor target with `href`, e.g. `_blank` for policy documents that open beside the app (diairy web lost its\n * new-tab links on adoption, 2026-10-17). `rel` defaults to \"noreferrer noopener\" for `_blank`, as on Link.\n */\n target?: HTMLAttributeAnchorTarget;\n rel?: string;\n /** In-app handler; renders a button when there is no `href`. */\n onClick?: () => void;\n }>;\n\nexport type AuthScreenFooterProps = Readonly<{\n /** Optional consent notice (LS-04). */\n notice?: ReactNode;\n /** Terms and privacy links; at least one is required (LS-04). */\n links: readonly AuthScreenPolicyLink[];\n /** Extra product content under the links. */\n children?: ReactNode;\n}>;\n\n/**\n * The `footer` slot content: consent notice plus dot-separated policy links. The\n * visible gap between two links is `linkGap` + separator + `linkGap`; the 44px\n * touch target is an invisible hit area, not visible padding.\n */\nexport function AuthScreenFooter({ notice, links, children }: AuthScreenFooterProps) {\n validateAuthScreenPolicyLinks(links);\n const recipe = authScreenRecipe.footer;\n const weight = useTypeWeight();\n const linkStyle = { fontWeight: weight(recipe.link.textVariant) };\n const hintId = useId();\n return (\n <div className=\"hjm-auth-screen__footer-content\" style={{ gap: recipe.noticeGap }}>\n {notice ? <p className=\"hjm-text\" data-variant={recipe.notice.textVariant} data-font-role=\"ui\" data-tone={recipe.notice.tone} style={{ fontWeight: weight(recipe.notice.textVariant) }}>{notice}</p> : null}\n <div className=\"hjm-auth-screen__links\" style={{\n [\"--hjm-auth-screen-link-gap\" as string]: `${recipe.linkGap}px`,\n [\"--hjm-auth-screen-link-target\" as string]: `${authScreenRecipe.footerMinTouchTarget}px`,\n } as CSSProperties}>\n {links.map((link, index) => (\n <Fragment key={`${index}:${link.label}`}>\n {index > 0 ? <span className=\"hjm-text hjm-auth-screen__separator\" data-variant={recipe.link.textVariant} data-tone={recipe.notice.tone} aria-hidden=\"true\">{recipe.separator}</span> : null}\n {link.href !== undefined\n ? <a className=\"hjm-text hjm-auth-screen__link\" data-variant={recipe.link.textVariant} data-font-role=\"ui\" data-tone={recipe.link.tone} style={linkStyle} href={link.href}\n target={link.target} rel={link.rel ?? (link.target === \"_blank\" ? \"noreferrer noopener\" : undefined)}\n aria-describedby={link.accessibilityHint === undefined ? undefined : `${hintId}-${index}`} onClick={link.onClick}>{link.label}</a>\n : <button type=\"button\" className=\"hjm-text hjm-auth-screen__link\" data-variant={recipe.link.textVariant} data-font-role=\"ui\" data-tone={recipe.link.tone} style={linkStyle}\n aria-describedby={link.accessibilityHint === undefined ? undefined : `${hintId}-${index}`} onClick={link.onClick}>{link.label}</button>}\n {/* Native announces the hint after the label; Web reads the same text as the link's description. */}\n {link.accessibilityHint === undefined ? null : <span id={`${hintId}-${index}`} className=\"hjm-visually-hidden\">{link.accessibilityHint}</span>}\n </Fragment>\n ))}\n </div>\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -17,8 +17,14 @@ export type CollectionRailProps = Omit<HTMLAttributes<HTMLDivElement>, "children
|
|
|
17
17
|
defaultStartKey?: string;
|
|
18
18
|
/** Observed leading item, independent of product selection/detail state. Empty lists report null. */
|
|
19
19
|
onStartKeyChange?: (key: string | null) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Scroll to the screen edges from inside the default inset ScreenLayout body: the viewport reaches past the body
|
|
22
|
+
* gutter (`--hjm-screen-body-inline`) and pads it back, so the first and last items rest on the gutter (no
|
|
23
|
+
* `body-edge` + per-section gutter, spint home 2026-10-17). Place the rail directly in the body.
|
|
24
|
+
*/
|
|
25
|
+
bleed?: boolean;
|
|
20
26
|
layoutStyle?: HjmCompositionStyleProp;
|
|
21
27
|
}>;
|
|
22
28
|
/** Finite all-mounted list placement; Card, inputs and Dialog keep their own state. */
|
|
23
|
-
export declare function CollectionRail({ label, items, renderItem, labels, density, emptyContent, defaultStartKey, onStartKeyChange, layoutStyle, ...props }: CollectionRailProps): import("react").JSX.Element;
|
|
29
|
+
export declare function CollectionRail({ label, items, renderItem, labels, density, emptyContent, defaultStartKey, onStartKeyChange, bleed, layoutStyle, ...props }: CollectionRailProps): import("react").JSX.Element;
|
|
24
30
|
//# sourceMappingURL=collection-rail.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-rail.d.ts","sourceRoot":"","sources":["../src/collection-rail.tsx"],"names":[],"mappings":"AAAA,O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5
|
import { Icon } from "./supplemental-display.js";
|
|
6
6
|
import { useOptionalHjmTheme } from "./provider.js";
|
|
7
7
|
/** Finite all-mounted list placement; Card, inputs and Dialog keep their own state. */
|
|
8
|
-
export function CollectionRail({ label, items, renderItem, labels, density = collectionRailRecipe.defaults.density, emptyContent, defaultStartKey, onStartKeyChange, layoutStyle, ...props }) {
|
|
8
|
+
export function CollectionRail({ label, items, renderItem, labels, density = collectionRailRecipe.defaults.density, emptyContent, defaultStartKey, onStartKeyChange, bleed = false, layoutStyle, ...props }) {
|
|
9
9
|
validateCollectionRail(items);
|
|
10
10
|
if (!label.trim() || Object.values(labels).some(value => !value.trim()))
|
|
11
11
|
throw new TypeError("CollectionRail labels must not be empty");
|
|
@@ -66,7 +66,10 @@ export function CollectionRail({ label, items, renderItem, labels, density = col
|
|
|
66
66
|
return;
|
|
67
67
|
let initialMeasurement = true;
|
|
68
68
|
function measure() {
|
|
69
|
-
|
|
69
|
+
// clientWidth includes the bleed padding; item geometry uses the gutter-aligned box inside it.
|
|
70
|
+
const style = getComputedStyle(viewport);
|
|
71
|
+
const room = (parseFloat(style.paddingLeft) || 0) + (parseFloat(style.paddingRight) || 0);
|
|
72
|
+
const next = resolveCollectionRailLayout(itemsRef.current.length, Math.max(0, viewport.clientWidth - room), density, gap);
|
|
70
73
|
// ResizeObserver also delivers an initial unchanged box. Re-aligning then
|
|
71
74
|
// would undo a focus reveal that happened after the layout effect.
|
|
72
75
|
if (!initialMeasurement && next.viewport === current.current.layout.viewport)
|
|
@@ -92,7 +95,7 @@ export function CollectionRail({ label, items, renderItem, labels, density = col
|
|
|
92
95
|
const observer = new ResizeObserver(measure);
|
|
93
96
|
observer.observe(viewport);
|
|
94
97
|
return () => observer.disconnect();
|
|
95
|
-
}, [identity, density, gap, direction]);
|
|
98
|
+
}, [identity, density, gap, direction, bleed]);
|
|
96
99
|
function navigate(intent) {
|
|
97
100
|
scrollToOffset(getCollectionRailTargetOffset(current.current.layout, pendingOffset.current ?? current.current.offset, intent), true);
|
|
98
101
|
}
|
|
@@ -110,7 +113,7 @@ export function CollectionRail({ label, items, renderItem, labels, density = col
|
|
|
110
113
|
event.preventDefault();
|
|
111
114
|
navigate(intent);
|
|
112
115
|
}
|
|
113
|
-
}, children: [_jsxs("div", { ref: viewportRef, role: "list", "aria-label": label, tabIndex: 0, "data-collection-rail-viewport": true, style: { overflowX: "auto", overscrollBehaviorX: "contain", minWidth: 0 }, onPointerDown: () => { pendingOffset.current = null; }, onWheel: () => { pendingOffset.current = null; }, onScroll: event => {
|
|
116
|
+
}, children: [_jsxs("div", { ref: viewportRef, role: "list", "aria-label": label, tabIndex: 0, "data-collection-rail-viewport": true, "data-bleed": bleed || undefined, className: "hjm-collection-rail__viewport", style: { overflowX: "auto", overscrollBehaviorX: "contain", minWidth: 0 }, onPointerDown: () => { pendingOffset.current = null; }, onWheel: () => { pendingOffset.current = null; }, onScroll: event => {
|
|
114
117
|
const offset = direction === "rtl" ? -event.currentTarget.scrollLeft : event.currentTarget.scrollLeft;
|
|
115
118
|
if (pendingOffset.current !== null && Math.abs(offset - pendingOffset.current) <= 0.5)
|
|
116
119
|
pendingOffset.current = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-rail.js","sourceRoot":"","sources":["../src/collection-rail.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAuC,MAAM,OAAO,CAAC;AAC/F,OAAO,EACL,oBAAoB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,6BAA6B,EACxG,6BAA6B,EAAE,2BAA2B,EAAE,6BAA6B,EACzF,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAcpD,uFAAuF;AACvF,MAAM,UAA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qBAAqB,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,aAE7I,KAAC,UAAU,IAAC,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAC,OAAO,mBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAE,KAAC,IAAI,IAAC,IAAI,EAAC,cAAc,GAAG,GAAa,EAChK,KAAC,UAAU,IAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAC,OAAO,mBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAE,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,GAAa,IAChJ,IACF,CAAC;AACT,CAAC","sourcesContent":["import { useLayoutEffect, useRef, useState, type HTMLAttributes, type ReactNode } from \"react\";\nimport {\n collectionRailRecipe, validateCollectionRail, resolveCollectionRailLayout, resolveCollectionRailViewport,\n getCollectionRailTargetOffset, getCollectionRailItemOffset, getCollectionRailRevealOffset,\n getCollectionRailKeyboardIntent, type CollectionRailItem, type CollectionRailDensity, type CollectionRailLayout,\n} from \"@hjmds/design-contracts/collection-rail\";\nimport { IconButton } from \"./actions.js\";\nimport { Icon } from \"./supplemental-display.js\";\nimport { useOptionalHjmTheme } from \"./provider.js\";\nimport type { HjmCompositionStyleProp } from \"./composition-style.js\";\n\nexport type CollectionRailLabels = Readonly<{ previous: string; next: string; navigation: string }>;\nexport type CollectionRailProps = Omit<HTMLAttributes<HTMLDivElement>, \"children\"> & Readonly<{\n label: string; items: readonly CollectionRailItem[]; renderItem: (item: CollectionRailItem) => ReactNode;\n labels: CollectionRailLabels; density?: CollectionRailDensity; emptyContent?: ReactNode;\n /** Initial scroll anchor, not selection. Later collection changes reconcile by stable ID. */\n defaultStartKey?: string;\n /** Observed leading item, independent of product selection/detail state. Empty lists report null. */\n onStartKeyChange?: (key: string | null) => void;\n layoutStyle?: HjmCompositionStyleProp;\n}>;\n\n/** Finite all-mounted list placement; Card, inputs and Dialog keep their own state. */\nexport function CollectionRail({ label, items, renderItem, labels, density = collectionRailRecipe.defaults.density,\n emptyContent, defaultStartKey, onStartKeyChange, layoutStyle, ...props }: CollectionRailProps) {\n validateCollectionRail(items);\n if (!label.trim() || Object.values(labels).some(value => !value.trim())) throw new TypeError(\"CollectionRail labels must not be empty\");\n const theme = useOptionalHjmTheme(), direction = theme?.environment.direction ?? \"ltr\";\n const gap = collectionRailRecipe.gap;\n const viewportRef = useRef<HTMLDivElement>(null);\n const detachedFocus = useRef<HTMLElement | null>(null);\n useLayoutEffect(() => {\n const old = detachedFocus.current;\n detachedFocus.current = null;\n // A removed card must leave a keyboard origin in this collection, without\n // moving focus away from a surviving input or an external control.\n if (old && !old.isConnected && old.ownerDocument.activeElement === old.ownerDocument.body) {\n viewportRef.current?.focus({ preventScroll: true });\n }\n });\n const anchor = useRef<string | null>(defaultStartKey ?? items[0]?.id ?? null);\n const initialized = useRef(false);\n if (!initialized.current) { validateCollectionRail(items, defaultStartKey); initialized.current = true; }\n const callback = useRef(onStartKeyChange); callback.current = onStartKeyChange;\n const current = useRef({ layout: resolveCollectionRailLayout(items.length, 0, density, gap), offset: 0 });\n const pendingOffset = useRef<number | null>(null);\n const [position, setPosition] = useState(current.current);\n const identity = JSON.stringify(items.map(item => item.id));\n const itemsRef = useRef(items); itemsRef.current = items;\n\n function publish(layout: CollectionRailLayout, offset: number) {\n const resolved = resolveCollectionRailViewport(layout, offset);\n const key = itemsRef.current[resolved.startIndex]?.id ?? null;\n if (key !== anchor.current) { anchor.current = key; callback.current?.(key); }\n current.current = { layout, offset: resolved.offset };\n setPosition(current.current);\n }\n function scrollToOffset(offset: number, animated: boolean) {\n const viewport = viewportRef.current;\n if (!viewport) return;\n const resolved = resolveCollectionRailViewport(current.current.layout, offset);\n // CSS RTL scrollLeft is negative; clamp Safari rubber-banding through the\n // shared logical resolver rather than reversing data or selection keys.\n viewport.scrollTo({ left: direction === \"rtl\" ? -resolved.offset : resolved.offset,\n behavior: animated && !theme?.environment.reducedMotion ? \"smooth\" : \"instant\" });\n pendingOffset.current = animated && !theme?.environment.reducedMotion ? resolved.offset : null;\n // Smooth scroll is a request, not an observed viewport. Publishing its\n // destination now would disable the end action and report an unseen anchor.\n publish(current.current.layout, direction === \"rtl\" ? -viewport.scrollLeft : viewport.scrollLeft);\n }\n useLayoutEffect(() => {\n const viewport = viewportRef.current;\n if (!viewport) return;\n let initialMeasurement = true;\n function measure() {\n const next = resolveCollectionRailLayout(itemsRef.current.length, viewport!.clientWidth, density, gap);\n // ResizeObserver also delivers an initial unchanged box. Re-aligning then\n // would undo a focus reveal that happened after the layout effect.\n if (!initialMeasurement && next.viewport === current.current.layout.viewport) return;\n initialMeasurement = false;\n pendingOffset.current = null;\n const index = Math.max(0, itemsRef.current.findIndex(item => item.id === anchor.current));\n let offset = next.count ? getCollectionRailItemOffset(next, index) : 0;\n const focused = document.activeElement?.closest(\"[data-collection-rail-item]\");\n const focusedIndex = focused && viewport!.contains(focused)\n ? itemsRef.current.findIndex(item => item.id === focused.getAttribute(\"data-collection-rail-item\")) : -1;\n // A narrower viewport cannot keep a distant focused action and the old\n // leading item visible together; focus exposure takes priority over anchor alignment.\n if (focusedIndex >= 0) offset = getCollectionRailRevealOffset(next, offset, focusedIndex);\n current.current = { layout: next, offset };\n // Width/direction changes keep the leading item's identity, and never\n // key/remount its input or detail owner (docs/collection-rail.md).\n viewport!.scrollTo({ left: direction === \"rtl\" ? -offset : offset, behavior: \"instant\" });\n publish(next, offset);\n }\n measure();\n const observer = new ResizeObserver(measure); observer.observe(viewport);\n return () => observer.disconnect();\n }, [identity, density, gap, direction]);\n\n function navigate(intent: \"previous\" | \"next\" | \"first\" | \"last\") {\n scrollToOffset(getCollectionRailTargetOffset(current.current.layout, pendingOffset.current ?? current.current.offset, intent), true);\n }\n const resolved = resolveCollectionRailViewport(position.layout, position.offset);\n return <div {...props} style={{ ...props.style, ...layoutStyle, minWidth: 0 }}\n data-collection-rail data-start-key={items[resolved.startIndex]?.id} dir={direction}\n onKeyDown={event => {\n props.onKeyDown?.(event);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n // Item widgets own arrows/Home/End. Rail navigation belongs only to its\n // viewport and explicit controls, not an input nested in a visible card.\n if (event.target !== viewportRef.current && !(event.target instanceof Element && event.target.closest(\"[data-collection-rail-controls]\"))) return;\n const intent = getCollectionRailKeyboardIntent(event.key, direction);\n if (intent) { event.preventDefault(); navigate(intent); }\n }}>\n <div ref={viewportRef} role=\"list\" aria-label={label} tabIndex={0} data-collection-rail-viewport\n style={{ overflowX: \"auto\", overscrollBehaviorX: \"contain\", minWidth: 0 }}\n onPointerDown={() => { pendingOffset.current = null; }} onWheel={() => { pendingOffset.current = null; }}\n onScroll={event => {\n const offset = direction === \"rtl\" ? -event.currentTarget.scrollLeft : event.currentTarget.scrollLeft;\n if (pendingOffset.current !== null && Math.abs(offset - pendingOffset.current) <= 0.5) pendingOffset.current = null;\n publish(current.current.layout, offset);\n }}>\n <div style={{ display: \"flex\", gap, width: \"max-content\", minWidth: \"100%\", paddingBlock: \"var(--hjm-space-xs)\" }}>\n {items.map((item, index) => <div key={item.id} role=\"listitem\" data-collection-rail-item={item.id}\n ref={node => {\n if (!node) return;\n return () => {\n const active = node.ownerDocument.activeElement;\n if (active instanceof HTMLElement && node.contains(active)) detachedFocus.current = active;\n };\n }}\n style={{ flex: \"0 0 auto\", width: position.layout.itemWidth || \"auto\", minWidth: 0 }}\n onFocusCapture={() => scrollToOffset(getCollectionRailRevealOffset(current.current.layout, current.current.offset, index), false)}>\n {renderItem(item)}\n </div>)}\n </div>\n {items.length === 0 ? emptyContent : null}\n </div>\n <div data-collection-rail-controls role=\"group\" aria-label={labels.navigation}\n style={{ display: \"flex\", flexWrap: \"wrap\", justifyContent: \"flex-end\", gap: \"var(--hjm-space-sm)\", marginBlockStart: \"var(--hjm-space-sm)\" }}>\n {/* Tool actions: icon buttons named by the localized label, as Carousel (2026-10-17 review E9). */}\n <IconButton label={labels.previous} tone=\"ghost\" aria-disabled={resolved.atStart} onClick={() => navigate(\"previous\")}><Icon name=\"chevronStart\" /></IconButton>\n <IconButton label={labels.next} tone=\"ghost\" aria-disabled={resolved.atEnd} onClick={() => navigate(\"next\")}><Icon name=\"chevronEnd\" /></IconButton>\n </div>\n </div>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"collection-rail.js","sourceRoot":"","sources":["../src/collection-rail.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAuC,MAAM,OAAO,CAAC;AAC/F,OAAO,EACL,oBAAoB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,6BAA6B,EACxG,6BAA6B,EAAE,2BAA2B,EAAE,6BAA6B,EACzF,+BAA+B,GAChC,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAoBpD,uFAAuF;AACvF,MAAM,UAAU,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,GAAG,oBAAoB,CAAC,QAAQ,CAAC,OAAO,EAChH,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,KAAK,GAAG,KAAK,EAAE,WAAW,EAAE,GAAG,KAAK,EAAuB;IAC5G,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,yCAAyC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,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAC,OAAO,mBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAE,KAAC,IAAI,IAAC,IAAI,EAAC,cAAc,GAAG,GAAa,EAChK,KAAC,UAAU,IAAC,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,EAAC,OAAO,mBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAE,KAAC,IAAI,IAAC,IAAI,EAAC,YAAY,GAAG,GAAa,IAChJ,IACF,CAAC;AACT,CAAC","sourcesContent":["import { useLayoutEffect, useRef, useState, type HTMLAttributes, type ReactNode } from \"react\";\nimport {\n collectionRailRecipe, validateCollectionRail, resolveCollectionRailLayout, resolveCollectionRailViewport,\n getCollectionRailTargetOffset, getCollectionRailItemOffset, getCollectionRailRevealOffset,\n getCollectionRailKeyboardIntent, type CollectionRailItem, type CollectionRailDensity, type CollectionRailLayout,\n} from \"@hjmds/design-contracts/collection-rail\";\nimport { IconButton } from \"./actions.js\";\nimport { Icon } from \"./supplemental-display.js\";\nimport { useOptionalHjmTheme } from \"./provider.js\";\nimport type { HjmCompositionStyleProp } from \"./composition-style.js\";\n\nexport type CollectionRailLabels = Readonly<{ previous: string; next: string; navigation: string }>;\nexport type CollectionRailProps = Omit<HTMLAttributes<HTMLDivElement>, \"children\"> & Readonly<{\n label: string; items: readonly CollectionRailItem[]; renderItem: (item: CollectionRailItem) => ReactNode;\n labels: CollectionRailLabels; density?: CollectionRailDensity; emptyContent?: ReactNode;\n /** Initial scroll anchor, not selection. Later collection changes reconcile by stable ID. */\n defaultStartKey?: string;\n /** Observed leading item, independent of product selection/detail state. Empty lists report null. */\n onStartKeyChange?: (key: string | null) => void;\n /**\n * Scroll to the screen edges from inside the default inset ScreenLayout body: the viewport reaches past the body\n * gutter (`--hjm-screen-body-inline`) and pads it back, so the first and last items rest on the gutter (no\n * `body-edge` + per-section gutter, spint home 2026-10-17). Place the rail directly in the body.\n */\n bleed?: boolean;\n layoutStyle?: HjmCompositionStyleProp;\n}>;\n\n/** Finite all-mounted list placement; Card, inputs and Dialog keep their own state. */\nexport function CollectionRail({ label, items, renderItem, labels, density = collectionRailRecipe.defaults.density,\n emptyContent, defaultStartKey, onStartKeyChange, bleed = false, layoutStyle, ...props }: CollectionRailProps) {\n validateCollectionRail(items);\n if (!label.trim() || Object.values(labels).some(value => !value.trim())) throw new TypeError(\"CollectionRail labels must not be empty\");\n const theme = useOptionalHjmTheme(), direction = theme?.environment.direction ?? \"ltr\";\n const gap = collectionRailRecipe.gap;\n const viewportRef = useRef<HTMLDivElement>(null);\n const detachedFocus = useRef<HTMLElement | null>(null);\n useLayoutEffect(() => {\n const old = detachedFocus.current;\n detachedFocus.current = null;\n // A removed card must leave a keyboard origin in this collection, without\n // moving focus away from a surviving input or an external control.\n if (old && !old.isConnected && old.ownerDocument.activeElement === old.ownerDocument.body) {\n viewportRef.current?.focus({ preventScroll: true });\n }\n });\n const anchor = useRef<string | null>(defaultStartKey ?? items[0]?.id ?? null);\n const initialized = useRef(false);\n if (!initialized.current) { validateCollectionRail(items, defaultStartKey); initialized.current = true; }\n const callback = useRef(onStartKeyChange); callback.current = onStartKeyChange;\n const current = useRef({ layout: resolveCollectionRailLayout(items.length, 0, density, gap), offset: 0 });\n const pendingOffset = useRef<number | null>(null);\n const [position, setPosition] = useState(current.current);\n const identity = JSON.stringify(items.map(item => item.id));\n const itemsRef = useRef(items); itemsRef.current = items;\n\n function publish(layout: CollectionRailLayout, offset: number) {\n const resolved = resolveCollectionRailViewport(layout, offset);\n const key = itemsRef.current[resolved.startIndex]?.id ?? null;\n if (key !== anchor.current) { anchor.current = key; callback.current?.(key); }\n current.current = { layout, offset: resolved.offset };\n setPosition(current.current);\n }\n function scrollToOffset(offset: number, animated: boolean) {\n const viewport = viewportRef.current;\n if (!viewport) return;\n const resolved = resolveCollectionRailViewport(current.current.layout, offset);\n // CSS RTL scrollLeft is negative; clamp Safari rubber-banding through the\n // shared logical resolver rather than reversing data or selection keys.\n viewport.scrollTo({ left: direction === \"rtl\" ? -resolved.offset : resolved.offset,\n behavior: animated && !theme?.environment.reducedMotion ? \"smooth\" : \"instant\" });\n pendingOffset.current = animated && !theme?.environment.reducedMotion ? resolved.offset : null;\n // Smooth scroll is a request, not an observed viewport. Publishing its\n // destination now would disable the end action and report an unseen anchor.\n publish(current.current.layout, direction === \"rtl\" ? -viewport.scrollLeft : viewport.scrollLeft);\n }\n useLayoutEffect(() => {\n const viewport = viewportRef.current;\n if (!viewport) return;\n let initialMeasurement = true;\n function measure() {\n // clientWidth includes the bleed padding; item geometry uses the gutter-aligned box inside it.\n const style = getComputedStyle(viewport!);\n const room = (parseFloat(style.paddingLeft) || 0) + (parseFloat(style.paddingRight) || 0);\n const next = resolveCollectionRailLayout(itemsRef.current.length, Math.max(0, viewport!.clientWidth - room), density, gap);\n // ResizeObserver also delivers an initial unchanged box. Re-aligning then\n // would undo a focus reveal that happened after the layout effect.\n if (!initialMeasurement && next.viewport === current.current.layout.viewport) return;\n initialMeasurement = false;\n pendingOffset.current = null;\n const index = Math.max(0, itemsRef.current.findIndex(item => item.id === anchor.current));\n let offset = next.count ? getCollectionRailItemOffset(next, index) : 0;\n const focused = document.activeElement?.closest(\"[data-collection-rail-item]\");\n const focusedIndex = focused && viewport!.contains(focused)\n ? itemsRef.current.findIndex(item => item.id === focused.getAttribute(\"data-collection-rail-item\")) : -1;\n // A narrower viewport cannot keep a distant focused action and the old\n // leading item visible together; focus exposure takes priority over anchor alignment.\n if (focusedIndex >= 0) offset = getCollectionRailRevealOffset(next, offset, focusedIndex);\n current.current = { layout: next, offset };\n // Width/direction changes keep the leading item's identity, and never\n // key/remount its input or detail owner (docs/collection-rail.md).\n viewport!.scrollTo({ left: direction === \"rtl\" ? -offset : offset, behavior: \"instant\" });\n publish(next, offset);\n }\n measure();\n const observer = new ResizeObserver(measure); observer.observe(viewport);\n return () => observer.disconnect();\n }, [identity, density, gap, direction, bleed]);\n\n function navigate(intent: \"previous\" | \"next\" | \"first\" | \"last\") {\n scrollToOffset(getCollectionRailTargetOffset(current.current.layout, pendingOffset.current ?? current.current.offset, intent), true);\n }\n const resolved = resolveCollectionRailViewport(position.layout, position.offset);\n return <div {...props} style={{ ...props.style, ...layoutStyle, minWidth: 0 }}\n data-collection-rail data-start-key={items[resolved.startIndex]?.id} dir={direction}\n onKeyDown={event => {\n props.onKeyDown?.(event);\n if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n // Item widgets own arrows/Home/End. Rail navigation belongs only to its\n // viewport and explicit controls, not an input nested in a visible card.\n if (event.target !== viewportRef.current && !(event.target instanceof Element && event.target.closest(\"[data-collection-rail-controls]\"))) return;\n const intent = getCollectionRailKeyboardIntent(event.key, direction);\n if (intent) { event.preventDefault(); navigate(intent); }\n }}>\n <div ref={viewportRef} role=\"list\" aria-label={label} tabIndex={0} data-collection-rail-viewport data-bleed={bleed || undefined}\n className=\"hjm-collection-rail__viewport\"\n style={{ overflowX: \"auto\", overscrollBehaviorX: \"contain\", minWidth: 0 }}\n onPointerDown={() => { pendingOffset.current = null; }} onWheel={() => { pendingOffset.current = null; }}\n onScroll={event => {\n const offset = direction === \"rtl\" ? -event.currentTarget.scrollLeft : event.currentTarget.scrollLeft;\n if (pendingOffset.current !== null && Math.abs(offset - pendingOffset.current) <= 0.5) pendingOffset.current = null;\n publish(current.current.layout, offset);\n }}>\n <div style={{ display: \"flex\", gap, width: \"max-content\", minWidth: \"100%\", paddingBlock: \"var(--hjm-space-xs)\" }}>\n {items.map((item, index) => <div key={item.id} role=\"listitem\" data-collection-rail-item={item.id}\n ref={node => {\n if (!node) return;\n return () => {\n const active = node.ownerDocument.activeElement;\n if (active instanceof HTMLElement && node.contains(active)) detachedFocus.current = active;\n };\n }}\n style={{ flex: \"0 0 auto\", width: position.layout.itemWidth || \"auto\", minWidth: 0 }}\n onFocusCapture={() => scrollToOffset(getCollectionRailRevealOffset(current.current.layout, current.current.offset, index), false)}>\n {renderItem(item)}\n </div>)}\n </div>\n {items.length === 0 ? emptyContent : null}\n </div>\n <div data-collection-rail-controls role=\"group\" aria-label={labels.navigation}\n style={{ display: \"flex\", flexWrap: \"wrap\", justifyContent: \"flex-end\", gap: \"var(--hjm-space-sm)\", marginBlockStart: \"var(--hjm-space-sm)\" }}>\n {/* Tool actions: icon buttons named by the localized label, as Carousel (2026-10-17 review E9). */}\n <IconButton label={labels.previous} tone=\"ghost\" aria-disabled={resolved.atStart} onClick={() => navigate(\"previous\")}><Icon name=\"chevronStart\" /></IconButton>\n <IconButton label={labels.next} tone=\"ghost\" aria-disabled={resolved.atEnd} onClick={() => navigate(\"next\")}><Icon name=\"chevronEnd\" /></IconButton>\n </div>\n </div>;\n}\n"]}
|