@hjmds/react 1.31.0 → 1.32.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bottom-cta.d.ts +6 -1
- package/dist/bottom-cta.d.ts.map +1 -1
- package/dist/bottom-cta.js +1 -1
- package/dist/bottom-cta.js.map +1 -1
- package/dist/bottom-navigation.d.ts +4 -1
- package/dist/bottom-navigation.d.ts.map +1 -1
- package/dist/bottom-navigation.js +18 -2
- package/dist/bottom-navigation.js.map +1 -1
- package/dist/evidence.d.ts +1 -1
- package/dist/evidence.js +1 -1
- package/dist/evidence.js.map +1 -1
- package/dist/image-choice.d.ts +15 -2
- package/dist/image-choice.d.ts.map +1 -1
- package/dist/image-choice.js +59 -7
- package/dist/image-choice.js.map +1 -1
- package/dist/internal/media-album.d.ts +22 -1
- package/dist/internal/media-album.d.ts.map +1 -1
- package/dist/internal/media-album.js +28 -7
- package/dist/internal/media-album.js.map +1 -1
- package/dist/internal/message-reactions.d.ts +11 -0
- package/dist/internal/message-reactions.d.ts.map +1 -1
- package/dist/internal/message-reactions.js +10 -1
- package/dist/internal/message-reactions.js.map +1 -1
- package/dist/pagination.d.ts +13 -11
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +12 -5
- package/dist/pagination.js.map +1 -1
- package/dist/public-exports.generated.d.ts +1 -0
- package/dist/public-exports.generated.d.ts.map +1 -1
- package/dist/public-exports.generated.js +3 -0
- package/dist/public-exports.generated.js.map +1 -1
- package/dist/screen-flows.d.ts +18 -6
- package/dist/screen-flows.d.ts.map +1 -1
- package/dist/screen-flows.js +13 -10
- package/dist/screen-flows.js.map +1 -1
- package/dist/screens.d.ts +12 -4
- package/dist/screens.d.ts.map +1 -1
- package/dist/screens.js +23 -3
- package/dist/screens.js.map +1 -1
- package/dist/styles.css +47 -7
- package/dist/styles.layered.css +47 -7
- package/dist/toast.d.ts.map +1 -1
- package/dist/toast.js +1 -1
- package/dist/toast.js.map +1 -1
- package/package.json +3 -3
package/dist/bottom-cta.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HTMLAttributes, type MouseEventHandler, type ReactNode } from "react";
|
|
1
|
+
import { type HTMLAttributes, type MouseEventHandler, type ReactNode, type Ref } from "react";
|
|
2
2
|
import { type ButtonSize, type ButtonTone } from "./actions.js";
|
|
3
3
|
import type { HjmCompositionStyleProp } from "./composition-style.js";
|
|
4
4
|
export type BottomCTAAction = Readonly<{
|
|
@@ -10,6 +10,11 @@ export type BottomCTAAction = Readonly<{
|
|
|
10
10
|
loadingLabel?: string;
|
|
11
11
|
size?: ButtonSize;
|
|
12
12
|
tone?: ButtonTone;
|
|
13
|
+
/**
|
|
14
|
+
* Ref to this action's button. The component `ref` names the bar; a dialog or overlay opened from the primary
|
|
15
|
+
* action needs the button itself to return focus to on close (2026-10-18 Utilverse display board).
|
|
16
|
+
*/
|
|
17
|
+
buttonRef?: Ref<HTMLButtonElement>;
|
|
13
18
|
}>;
|
|
14
19
|
export type BottomCTAProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & Readonly<{
|
|
15
20
|
primaryAction: BottomCTAAction;
|
package/dist/bottom-cta.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottom-cta.d.ts","sourceRoot":"","sources":["../src/bottom-cta.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA8C,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"bottom-cta.d.ts","sourceRoot":"","sources":["../src/bottom-cta.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA8C,KAAK,cAAc,EAAE,KAAK,iBAAiB,EAAE,KAAK,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAC1I,OAAO,EAAU,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAIxE,OAAO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) {
|
|
10
10
|
if (!action.label.trim())
|
|
11
11
|
throw new TypeError("BottomCTA action label must not be empty");
|
|
12
|
-
return _jsx(Button, { onClick: action.onClick, tone: action.tone ?? tone, size: action.size ?? "medium", disabled: action.disabled, loading: action.loading ?? false, "aria-label": action.loading ? action.loadingLabel ?? action.accessibilityLabel ?? action.label : action.accessibilityLabel, children: action.label });
|
|
12
|
+
return _jsx(Button, { ref: action.buttonRef, onClick: action.onClick, tone: action.tone ?? tone, size: action.size ?? "medium", disabled: action.disabled, loading: action.loading ?? false, "aria-label": action.loading ? action.loadingLabel ?? action.accessibilityLabel ?? action.label : action.accessibilityLabel, children: action.label });
|
|
13
13
|
}
|
|
14
14
|
function isAction(value) {
|
|
15
15
|
return typeof value === "object" && value !== null && "label" in value && "onClick" in value;
|
package/dist/bottom-cta.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottom-cta.js","sourceRoot":"","sources":["../src/bottom-cta.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"bottom-cta.js","sourceRoot":"","sources":["../src/bottom-cta.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2DAA2D,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,UAAU,EAA6F,MAAM,OAAO,CAAC;AAC1I,OAAO,EAAE,MAAM,EAAoC,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AA+BlE,SAAS,MA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ACF,CAAC;AACT,CAAC,CAAC,CAAC","sourcesContent":["import { bottomCtaRecipe } from \"@hjmds/design-contracts/recipes\";\nimport { isLargeTextScale } from \"@hjmds/design-contracts/components/design-system-provider\";\nimport { forwardRef, useContext, type CSSProperties, type HTMLAttributes, type MouseEventHandler, type ReactNode, type Ref } from \"react\";\nimport { Button, type ButtonSize, type ButtonTone } from \"./actions.js\";\nimport { classNames } from \"./internal.js\";\nimport { useOptionalHjmTheme } from \"./provider.js\";\nimport { ScreenFooterContext } from \"./internal/screen-footer.js\";\nimport type { HjmCompositionStyleProp } from \"./composition-style.js\";\n\nexport type BottomCTAAction = Readonly<{\n label: string;\n onClick: MouseEventHandler<HTMLButtonElement>;\n accessibilityLabel?: string;\n disabled?: boolean;\n loading?: boolean;\n loadingLabel?: string;\n size?: ButtonSize;\n tone?: ButtonTone;\n /**\n * Ref to this action's button. The component `ref` names the bar; a dialog or overlay opened from the primary\n * action needs the button itself to return focus to on close (2026-10-18 Utilverse display board).\n */\n buttonRef?: Ref<HTMLButtonElement>;\n}>;\n\nexport type BottomCTAProps = Omit<HTMLAttributes<HTMLDivElement>, \"children\"> & Readonly<{\n primaryAction: BottomCTAAction;\n secondaryAction?: BottomCTAAction | ReactNode;\n description?: string;\n accessibilityLabel?: string;\n safeAreaBottom?: number;\n /** Sticky remains in document flow; fixed overlays would need a measured content spacer. */\n position?: \"flow\" | \"sticky\";\n /** Canonical layout-only placement on the root element. Controlled visual keys are excluded. */\n layoutStyle?: HjmCompositionStyleProp;\n}>;\n\nfunction Action({ action, tone }: { action: BottomCTAAction; tone: ButtonTone }) {\n if (!action.label.trim()) throw new TypeError(\"BottomCTA action label must not be empty\");\n return <Button ref={action.buttonRef} onClick={action.onClick} tone={action.tone ?? tone} size={action.size ?? \"medium\"}\n disabled={action.disabled} loading={action.loading ?? false}\n aria-label={action.loading ? action.loadingLabel ?? action.accessibilityLabel ?? action.label : action.accessibilityLabel}>\n {action.label}\n </Button>;\n}\n\nfunction isAction(value: BottomCTAAction | ReactNode): value is BottomCTAAction {\n return typeof value === \"object\" && value !== null && \"label\" in value && \"onClick\" in value;\n}\n\n/** One primary action with optional supporting copy and a secondary action, matching Native's slots. */\nexport const BottomCTA = forwardRef<HTMLDivElement, BottomCTAProps>(function BottomCTA({\n primaryAction, secondaryAction, description, accessibilityLabel, safeAreaBottom = 0,\n position = \"flow\", className, style, layoutStyle, ...props\n}, ref) {\n const theme = useOptionalHjmTheme();\n const inScreenFooter = useContext(ScreenFooterContext);\n if (!Number.isFinite(safeAreaBottom) || safeAreaBottom < 0) throw new RangeError(\"BottomCTA safeAreaBottom must be non-negative\");\n return <div {...props} ref={ref} role=\"group\" aria-label={accessibilityLabel}\n className={classNames(\"hjm-bottom-cta\", className)} data-position={position}\n data-placement={inScreenFooter ? \"screen-footer\" : undefined}\n data-large-text={isLargeTextScale(theme?.environment.textScale ?? 1)}\n style={{\n \"--hjm-bottom-cta-min-height\": `${bottomCtaRecipe.minHeight}px`,\n \"--hjm-bottom-cta-padding-inline\": `${bottomCtaRecipe.paddingHorizontal}px`,\n \"--hjm-bottom-cta-padding-top\": `${bottomCtaRecipe.paddingTop}px`,\n \"--hjm-bottom-cta-padding-bottom\": `${bottomCtaRecipe.paddingBottom}px`,\n \"--hjm-bottom-cta-gap\": `${bottomCtaRecipe.gap}px`,\n \"--hjm-bottom-cta-content-max-width\": `${bottomCtaRecipe.contentMaxWidth}px`,\n \"--hjm-bottom-cta-safe-area\": `${safeAreaBottom}px`, ...style, ...layoutStyle,\n } as CSSProperties}>\n {description ? <p className=\"hjm-bottom-cta__description\">{description}</p> : null}\n <div className=\"hjm-bottom-cta__actions\">\n {secondaryAction == null ? null : <div className=\"hjm-bottom-cta__secondary\">{isAction(secondaryAction) ? <Action action={secondaryAction} tone=\"secondary\" /> : secondaryAction}</div>}\n <div className=\"hjm-bottom-cta__primary\"><Action action={primaryAction} tone=\"primary\" /></div>\n </div>\n </div>;\n});\n"]}
|
|
@@ -6,7 +6,10 @@ export type BottomNavigationInsetProviderProps = Readonly<{
|
|
|
6
6
|
}>;
|
|
7
7
|
/** Wrap the app shell that holds both the screens and the BottomNavigation. */
|
|
8
8
|
export declare function BottomNavigationInsetProvider({ children }: BottomNavigationInsetProviderProps): import("react").JSX.Element;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Bottom height covered by the BottomNavigation inside the nearest provider; 0 outside one. For layouts that are not
|
|
11
|
+
* a ScreenLayout: inside one the shell already pads by it, so adding it again doubles the space.
|
|
12
|
+
*/
|
|
10
13
|
export declare function useBottomNavigationInset(): number;
|
|
11
14
|
export type BottomNavigationIconRenderProps<Key extends string = string, IconName extends string = string> = Readonly<{
|
|
12
15
|
item: ResolvedBottomNavigationItemDescriptor<Key, IconName>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottom-navigation.d.ts","sourceRoot":"","sources":["../src/bottom-navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,0BAA0B,EAC/B,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,sCAAsC,EAC5C,MAAM,sDAAsD,CAAC;AAK9D,OAAO,EAQL,KAAK,oBAAoB,EAGzB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AActE,MAAM,MAAM,kCAAkC,GAAG,QAAQ,CAAC;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AAEnF,+EAA+E;AAC/E,wBAAgB,6BAA6B,CAAC,EAAE,QAAQ,EAAE,EAAE,kCAAkC,+BAc7F;AAED
|
|
1
|
+
{"version":3,"file":"bottom-navigation.d.ts","sourceRoot":"","sources":["../src/bottom-navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,0BAA0B,EAC/B,KAAK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,GAAG,YAAY,GACnC,MAAM,GAAG,SAAS,CAIpB;AAmPD,eAAO,MAAM,gBAAgB,EAAwC,CACnE,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,QAAQ,SAAS,MAAM,GAAG,MAAM,EAEhC,KAAK,EAAE,qBAAqB,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,aAAa,CAAC,WAAW,CAAC,KACrE,YAAY,GAAG,IAAI,CAAC"}
|
|
@@ -22,7 +22,10 @@ export function BottomNavigationInsetProvider({ children }) {
|
|
|
22
22
|
}, []);
|
|
23
23
|
return (_jsx(BottomNavigationInsetReporterContext.Provider, { value: report, children: _jsx(BottomNavigationInsetContext.Provider, { value: inset, children: _jsx("div", { style: { display: "contents", "--hjm-bottom-navigation-inset": `${inset}px` }, children: children }) }) }));
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Bottom height covered by the BottomNavigation inside the nearest provider; 0 outside one. For layouts that are not
|
|
27
|
+
* a ScreenLayout: inside one the shell already pads by it, so adding it again doubles the space.
|
|
28
|
+
*/
|
|
26
29
|
export function useBottomNavigationInset() {
|
|
27
30
|
return useContext(BottomNavigationInsetContext);
|
|
28
31
|
}
|
|
@@ -93,6 +96,11 @@ function BottomNavigationInner({ descriptor, configuration = {}, getHref, render
|
|
|
93
96
|
const iconSize = presentation.iconSize === "standard"
|
|
94
97
|
? iconRecipe.sizes[density.icon]
|
|
95
98
|
: bottomNavigationRecipe.iconSizes[presentation.iconSize];
|
|
99
|
+
// `shape` reframes the floating surface (radius + inner padding); `standard` keeps the presentation recipe.
|
|
100
|
+
const shapeRecipe = presentation.shape === "standard"
|
|
101
|
+
? null
|
|
102
|
+
: bottomNavigationRecipe.shapes[presentation.shape];
|
|
103
|
+
const liftRecipe = bottomNavigationRecipe.icon.liftEmphasis;
|
|
96
104
|
const prominentRecipe = bottomNavigationRecipe.prominentDestination;
|
|
97
105
|
// Lifting by (diameter - indicator height) keeps the prominent label on the other labels' line; an app-icon
|
|
98
106
|
// slot taller than the indicator minimum raises that height.
|
|
@@ -125,7 +133,7 @@ function BottomNavigationInner({ descriptor, configuration = {}, getHref, render
|
|
|
125
133
|
return (_jsx("nav", { ...props, ref: (node) => {
|
|
126
134
|
navRef.current = node;
|
|
127
135
|
assignRef(ref, node);
|
|
128
|
-
}, "aria-label": resolved.accessibilityLabel, className: classNames("hjm-bottom-navigation", className), "data-expanded-labels": (theme?.environment.textScale ?? 1) >= 1.5 || resolved.items.length > 4 ? "true" : "false", "data-density": presentation.density, "data-distribution": presentation.distribution, "data-keyboard-behavior": presentation.keyboardBehavior, "data-labels": presentation.labels, "data-selection": presentation.selection, "data-surface": presentation.surface, "data-presentation": presentation.presentation, dir: presentation.direction, style: {
|
|
136
|
+
}, "aria-label": resolved.accessibilityLabel, className: classNames("hjm-bottom-navigation", className), "data-expanded-labels": (theme?.environment.textScale ?? 1) >= 1.5 || resolved.items.length > 4 ? "true" : "false", "data-density": presentation.density, "data-distribution": presentation.distribution, "data-keyboard-behavior": presentation.keyboardBehavior, "data-labels": presentation.labels, "data-selection": presentation.selection, "data-surface": presentation.surface, "data-presentation": presentation.presentation, "data-shape": presentation.shape, "data-icon-emphasis": presentation.iconEmphasis, dir: presentation.direction, style: {
|
|
129
137
|
"--hjm-bottom-navigation-center-gap": `${centerGap}px`,
|
|
130
138
|
"--hjm-bottom-navigation-columns": resolved.items.length,
|
|
131
139
|
"--hjm-bottom-navigation-half-columns": resolved.items.length / 2,
|
|
@@ -143,6 +151,14 @@ function BottomNavigationInner({ descriptor, configuration = {}, getHref, render
|
|
|
143
151
|
"--hjm-bottom-navigation-outer-top": `${presentationRecipe.outerPaddingTop}px`,
|
|
144
152
|
"--hjm-bottom-navigation-prominent-diameter": `${prominentRecipe.diameter}px`,
|
|
145
153
|
"--hjm-bottom-navigation-prominent-lift": `${prominentLift}px`,
|
|
154
|
+
...(shapeRecipe ? {
|
|
155
|
+
"--hjm-bottom-navigation-shape-radius": `var(--hjm-radius-${shapeRecipe.radius})`,
|
|
156
|
+
"--hjm-bottom-navigation-shape-padding": `${shapeRecipe.surfacePadding}px`,
|
|
157
|
+
} : {}),
|
|
158
|
+
...(presentation.iconEmphasis === "lift" ? {
|
|
159
|
+
"--hjm-bottom-navigation-lift-offset": `${liftRecipe.translateY}px`,
|
|
160
|
+
"--hjm-bottom-navigation-lift-idle-opacity": liftRecipe.idleOpacity,
|
|
161
|
+
} : {}),
|
|
146
162
|
...style,
|
|
147
163
|
...layoutStyle,
|
|
148
164
|
}, children: _jsxs("div", { className: "hjm-bottom-navigation__surface", children: [_jsx("ul", { className: "hjm-bottom-navigation__list", children: resolved.items.map((item, index) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottom-navigation.js","sourceRoot":"","sources":["../src/bottom-navigation.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,iCAAiC,EACjC,oCAAoC,EACpC,iCAAiC,EACjC,kCAAkC,GAKnC,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,UAAU,GACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,aAAa,EACb,UAAU,EACV,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAST,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,+BAA+B,GAAG,GAAG,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,4BAA4B,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AACtD,MAAM,oCAAoC,GAAG,aAAa,CAAoC,IAAI,CAAC,CAAC;AAIpG,+EAA+E;AAC/E,MAAM,UAAU,6BAA6B,CAAC,EAAE,QAAQ,EAAsC;IAC5F,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;I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AAI,EAAE,EAAE,CAAC;4BACjB,MAAM,IAAI,SAAS,CAAC,4CAA4C,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;wBAC7E,CAAC;wBACD,MAAM,SAAS,GAAoC;4BACjD,cAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS;4BAC7C,YAAY,EAAE,IAAI,CAAC,0BAA0B;4BAC7C,SAAS,EAAE,6BAA6B;4BACxC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM;4BAC5C,IAAI;4BACJ,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;gCACjB,IAAI,CAAC,wCAAwC,CAAC,KAAK,CAAC;oCAAE,OAAO;gCAC7D,MAAM,UAAU,GAAG,iCAAiC,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;gCAC1E,IAAI,UAAU;oCAAE,UAAU,EAAE,CAAC,UAAU,CAAC,CAAC;4BAC3C,CAAC;4BACD,QAAQ,EAAE,OAAO;yBAClB,CAAC;wBACF,OAAO,CACL,aAAkB,KAAK,EAAE,SAAS,mBAAiB,QAAQ,oBAAkB,IAAI,CAAC,SAAS,IAAI,SAAS,YACrG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,eAAO,SAAS,GAAI,IADnD,IAAI,CAAC,EAAE,CAEX,CACN,CAAC;oBACJ,CAAC,CAAC,GACC,EACJ,aAAa,CAAC,CAAC,CAAC,CACf,cAAK,SAAS,EAAC,uCAAuC,YAAE,aAAa,GAAO,CAC7E,CAAC,CAAC,CAAC,IAAI,IACJ,GACF,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,UAAU,CAAC,qBAAqB,CAKxC,CAAC","sourcesContent":["import {\n resolveBottomNavigationActivation,\n resolveBottomNavigationConfiguration,\n resolveBottomNavigationDescriptor,\n validateBottomNavigationProminence,\n type BottomNavigationActivation,\n type BottomNavigationConfiguration,\n type BottomNavigationDescriptor,\n type ResolvedBottomNavigationItemDescriptor,\n} from \"@hjmds/design-contracts/components/bottom-navigation\";\nimport {\n bottomNavigationRecipe,\n iconRecipe,\n} from \"@hjmds/design-contracts/recipes\";\nimport {\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type AnchorHTMLAttributes,\n type CSSProperties,\n type ForwardedRef,\n type HTMLAttributes,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type RefAttributes,\n} from \"react\";\nimport { assignRef, classNames } from \"./internal.js\";\nimport type { HjmCompositionStyleProp } from \"./composition-style.js\";\nimport { useOptionalHjmTheme } from \"./provider.js\";\n\nconst virtualKeyboardMinimumOcclusion = 120;\n\n/**\n * Height of the viewport bottom covered by the fixed bar (safe area and a raised center circle included); 0 when\n * there is no bar or it is hidden for the keyboard. The provider also exposes it as `--hjm-bottom-navigation-inset`,\n * which ScreenLayout's last region adds to its bottom padding, so products stop hand-keeping a bottom spacer\n * (2026-10-18; Native shares the same API for its `placement=\"overlay\"` bar).\n */\nconst BottomNavigationInsetContext = createContext(0);\nconst BottomNavigationInsetReporterContext = createContext<((height: number) => void) | null>(null);\n\nexport type BottomNavigationInsetProviderProps = Readonly<{ children: ReactNode }>;\n\n/** Wrap the app shell that holds both the screens and the BottomNavigation. */\nexport function BottomNavigationInsetProvider({ children }: BottomNavigationInsetProviderProps) {\n const [inset, setInset] = useState(0);\n const report = useMemo(() => (height: number) => {\n const next = Number.isFinite(height) && height > 0 ? height : 0;\n setInset(current => current === next ? current : next);\n }, []);\n return (\n <BottomNavigationInsetReporterContext.Provider value={report}>\n <BottomNavigationInsetContext.Provider value={inset}>\n {/* `display: contents` adds no box; the custom property still inherits to every screen below. */}\n <div style={{ display: \"contents\", \"--hjm-bottom-navigation-inset\": `${inset}px` } as CSSProperties}>{children}</div>\n </BottomNavigationInsetContext.Provider>\n </BottomNavigationInsetReporterContext.Provider>\n );\n}\n\n/** Bottom height covered by the BottomNavigation inside the nearest provider; 0 outside one. */\nexport function useBottomNavigationInset(): number {\n return useContext(BottomNavigationInsetContext);\n}\n\nexport type BottomNavigationIconRenderProps<\n Key extends string = string,\n IconName extends string = string,\n> = Readonly<{\n item: ResolvedBottomNavigationItemDescriptor<Key, IconName>;\n name: IconName;\n selected: boolean;\n color: \"currentColor\";\n size: number;\n strokeWidth: number;\n scale: number;\n}>;\n\nexport type BottomNavigationLinkRenderProps = AnchorHTMLAttributes<HTMLAnchorElement> &\n Readonly<{\n href: string;\n children: ReactNode;\n \"data-state\": \"idle\" | \"selected\";\n }>;\n\nexport type BottomNavigationProps<\n Key extends string = string,\n IconName extends string = string,\n> = Omit<\n HTMLAttributes<HTMLElement>,\n \"aria-label\" | \"aria-labelledby\" | \"children\" | \"dir\" | \"onChange\" | \"role\"\n> &\n Readonly<{\n descriptor: BottomNavigationDescriptor<Key, IconName>;\n configuration?: BottomNavigationConfiguration;\n getHref: (item: ResolvedBottomNavigationItemDescriptor<Key, IconName>) => string;\n renderIcon: (props: BottomNavigationIconRenderProps<Key, IconName>) => ReactNode;\n /** Framework navigation adapter, for example Next.js Link. */\n renderLink?: (props: BottomNavigationLinkRenderProps) => ReactElement;\n primaryAction?: ReactNode;\n onActivate?: (activation: BottomNavigationActivation<Key>) => void;\n /** Canonical layout-only placement on the root element. Controlled visual keys are excluded. */\n layoutStyle?: HjmCompositionStyleProp;\n }>;\n\nexport function isUnmodifiedPrimaryBottomNavigationClick(\n event: Pick<\n MouseEvent<HTMLAnchorElement>,\n \"altKey\" | \"button\" | \"ctrlKey\" | \"defaultPrevented\" | \"metaKey\" | \"shiftKey\"\n >,\n): boolean {\n return (\n !event.defaultPrevented &&\n event.button === 0 &&\n !event.metaKey &&\n !event.ctrlKey &&\n !event.shiftKey &&\n !event.altKey\n );\n}\n\nexport function shouldHideBottomNavigationForKeyboard(input: Readonly<{\n behavior: \"hide\" | \"remain\";\n layoutViewportHeight: number;\n visualViewportHeight: number;\n visualViewportOffsetTop?: number;\n visualViewportScale?: number;\n}>): boolean {\n if (input.behavior !== \"hide\") return false;\n if ((input.visualViewportScale ?? 1) !== 1) return false;\n const visibleBottom =\n input.visualViewportHeight + (input.visualViewportOffsetTop ?? 0);\n return layoutViewportHeightIsValid(input.layoutViewportHeight) &&\n input.layoutViewportHeight - visibleBottom >= virtualKeyboardMinimumOcclusion;\n}\n\nfunction layoutViewportHeightIsValid(value: number): boolean {\n return Number.isFinite(value) && value >= 0;\n}\n\nexport function getBottomNavigationGridColumn(\n index: number,\n itemCount: number,\n distribution: \"equal\" | \"center-gap\",\n): number | undefined {\n if (distribution !== \"center-gap\") return undefined;\n const middle = itemCount / 2;\n return index < middle ? index + 1 : index + 2;\n}\n\nfunction useKeyboardHidden(behavior: \"hide\" | \"remain\"): boolean {\n const [hidden, setHidden] = useState(false);\n useEffect(() => {\n const viewport = window.visualViewport;\n if (!viewport) return;\n const update = () => {\n setHidden(\n shouldHideBottomNavigationForKeyboard({\n behavior,\n layoutViewportHeight: window.innerHeight,\n visualViewportHeight: viewport.height,\n visualViewportOffsetTop: viewport.offsetTop,\n visualViewportScale: viewport.scale,\n }),\n );\n };\n update();\n viewport.addEventListener(\"resize\", update);\n viewport.addEventListener(\"scroll\", update);\n return () => {\n viewport.removeEventListener(\"resize\", update);\n viewport.removeEventListener(\"scroll\", update);\n };\n }, [behavior]);\n return hidden;\n}\n\nfunction BottomNavigationInner<\n Key extends string = string,\n IconName extends string = string,\n>(\n {\n descriptor,\n configuration = {},\n getHref,\n renderIcon,\n renderLink,\n primaryAction,\n onActivate,\n className,\n style,\n layoutStyle,\n ...props\n }: BottomNavigationProps<Key, IconName>,\n ref: ForwardedRef<HTMLElement>,\n) {\n const resolved = resolveBottomNavigationDescriptor(descriptor);\n const theme = useOptionalHjmTheme();\n const direction = configuration.direction ?? theme?.environment.direction;\n const presentation = resolveBottomNavigationConfiguration(\n {\n ...configuration,\n ...(direction === undefined ? {} : { direction }),\n },\n resolved.items.length,\n );\n validateBottomNavigationProminence(resolved.items, presentation);\n const hidden = useKeyboardHidden(presentation.keyboardBehavior);\n const density = bottomNavigationRecipe.density[presentation.density];\n const presentationRecipe =\n bottomNavigationRecipe.presentations[presentation.presentation];\n const centerGap =\n bottomNavigationRecipe.distributions[presentation.distribution].centerGap;\n const iconSize = presentation.iconSize === \"standard\"\n ? iconRecipe.sizes[density.icon]\n : bottomNavigationRecipe.iconSizes[presentation.iconSize];\n const prominentRecipe = bottomNavigationRecipe.prominentDestination;\n // Lifting by (diameter - indicator height) keeps the prominent label on the other labels' line; an app-icon\n // slot taller than the indicator minimum raises that height.\n const prominentLift = prominentRecipe.diameter - Math.max(bottomNavigationRecipe.indicator.minHeight, iconSize);\n // The part of the circle above the nav box still covers content, so the reported inset includes it.\n const prominentOverflow = resolved.items.some((item) => item.prominent)\n ? Math.max(0, prominentLift - density.padding - presentationRecipe.outerPaddingTop)\n : 0;\n const navRef = useRef<HTMLElement | null>(null);\n const reportInset = useContext(BottomNavigationInsetReporterContext);\n useEffect(() => {\n const nav = navRef.current;\n if (!reportInset) return;\n if (hidden || !nav) {\n reportInset(0);\n return;\n }\n const update = () => reportInset(nav.getBoundingClientRect().height + prominentOverflow);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(nav);\n return () => {\n observer.disconnect();\n reportInset(0);\n };\n }, [reportInset, hidden, prominentOverflow]);\n\n if (hidden) return null;\n\n return (\n <nav\n {...props}\n ref={(node) => {\n navRef.current = node;\n assignRef(ref, node);\n }}\n aria-label={resolved.accessibilityLabel}\n className={classNames(\"hjm-bottom-navigation\", className)}\n data-expanded-labels={(theme?.environment.textScale ?? 1) >= 1.5 || resolved.items.length > 4 ? \"true\" : \"false\"}\n data-density={presentation.density}\n data-distribution={presentation.distribution}\n data-keyboard-behavior={presentation.keyboardBehavior}\n data-labels={presentation.labels}\n data-selection={presentation.selection}\n data-surface={presentation.surface}\n data-presentation={presentation.presentation}\n dir={presentation.direction}\n style={{\n \"--hjm-bottom-navigation-center-gap\": `${centerGap}px`,\n \"--hjm-bottom-navigation-columns\": resolved.items.length,\n \"--hjm-bottom-navigation-half-columns\": resolved.items.length / 2,\n \"--hjm-bottom-navigation-item-gap\": `${density.gap}px`,\n \"--hjm-bottom-navigation-item-min-height\": `${density.itemMinHeight}px`,\n \"--hjm-bottom-navigation-item-min-width\": `${density.itemMinWidth}px`,\n \"--hjm-bottom-navigation-item-padding\": `${density.padding}px`,\n \"--hjm-bottom-navigation-max-width\": presentationRecipe.maxWidth\n ? `${presentationRecipe.maxWidth}px`\n : \"none\",\n \"--hjm-bottom-navigation-content-max-width\": presentationRecipe.contentMaxWidth\n ? `${presentationRecipe.contentMaxWidth}px`\n : \"none\",\n \"--hjm-bottom-navigation-outer-inline\": `${presentationRecipe.outerPaddingHorizontal}px`,\n \"--hjm-bottom-navigation-outer-top\": `${presentationRecipe.outerPaddingTop}px`,\n \"--hjm-bottom-navigation-prominent-diameter\": `${prominentRecipe.diameter}px`,\n \"--hjm-bottom-navigation-prominent-lift\": `${prominentLift}px`,\n ...style,\n ...layoutStyle,\n } as CSSProperties}\n >\n <div className=\"hjm-bottom-navigation__surface\">\n <ul className=\"hjm-bottom-navigation__list\">\n {resolved.items.map((item, index) => {\n const selected = item.id === resolved.selectedKey;\n const content = (\n <>\n <span\n aria-hidden=\"true\"\n className=\"hjm-bottom-navigation__indicator\"\n data-state={selected ? \"selected\" : \"idle\"}\n >\n {renderIcon({\n item,\n name: item.icon.name,\n selected,\n color: \"currentColor\",\n size: item.prominent ? iconRecipe.sizes[prominentRecipe.icon] : iconSize,\n strokeWidth: selected\n ? bottomNavigationRecipe.icon.selectedEmphasis.strokeWidth.selected\n : bottomNavigationRecipe.icon.selectedEmphasis.strokeWidth.idle,\n scale: selected\n ? bottomNavigationRecipe.icon.selectedEmphasis.scale.selected\n : bottomNavigationRecipe.icon.selectedEmphasis.scale.idle,\n })}\n {item.badge ? (\n <span aria-hidden=\"true\" className=\"hjm-bottom-navigation__badge\">\n {item.badge.visibleLabel}\n </span>\n ) : null}\n </span>\n {/* Hidden labels are not rendered: the item link already carries\n resolvedAccessibilityLabel, so a visually-hidden copy would only duplicate it. */}\n {presentation.labels === \"visible\" ? (\n <span className=\"hjm-bottom-navigation__label\">{item.label}</span>\n ) : null}\n </>\n );\n const itemStyle = {\n gridColumn: getBottomNavigationGridColumn(\n index,\n resolved.items.length,\n presentation.distribution,\n ),\n };\n if (item.disabled) {\n return (\n <li key={item.id} style={itemStyle} data-selected=\"false\" data-prominent={item.prominent || undefined}>\n <span\n aria-disabled=\"true\"\n aria-label={item.resolvedAccessibilityLabel}\n className=\"hjm-bottom-navigation__item\"\n data-state=\"disabled\"\n role=\"link\"\n >\n {content}\n </span>\n </li>\n );\n }\n const href = getHref(item);\n if (!href.trim()) {\n throw new TypeError(`BottomNavigation href must not be empty: ${item.id}`);\n }\n const linkProps: BottomNavigationLinkRenderProps = {\n \"aria-current\": selected ? \"page\" : undefined,\n \"aria-label\": item.resolvedAccessibilityLabel,\n className: \"hjm-bottom-navigation__item\",\n \"data-state\": selected ? \"selected\" : \"idle\",\n href,\n onClick: (event) => {\n if (!isUnmodifiedPrimaryBottomNavigationClick(event)) return;\n const activation = resolveBottomNavigationActivation(descriptor, item.id);\n if (activation) onActivate?.(activation);\n },\n children: content,\n };\n return (\n <li key={item.id} style={itemStyle} data-selected={selected} data-prominent={item.prominent || undefined}>\n {renderLink ? renderLink(linkProps) : <a {...linkProps} />}\n </li>\n );\n })}\n </ul>\n {primaryAction ? (\n <div className=\"hjm-bottom-navigation__primary-action\">{primaryAction}</div>\n ) : null}\n </div>\n </nav>\n );\n}\n\nexport const BottomNavigation = forwardRef(BottomNavigationInner) as <\n Key extends string = string,\n IconName extends string = string,\n>(\n props: BottomNavigationProps<Key, IconName> & RefAttributes<HTMLElement>,\n) => ReactElement | null;\n"]}
|
|
1
|
+
{"version":3,"file":"bottom-navigation.js","sourceRoot":"","sources":["../src/bottom-navigation.tsx"],"names":[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BAAgB,GAAG,UAAU,CAAC,qBAAqB,CAKxC,CAAC","sourcesContent":["import {\n resolveBottomNavigationActivation,\n resolveBottomNavigationConfiguration,\n resolveBottomNavigationDescriptor,\n validateBottomNavigationProminence,\n type BottomNavigationActivation,\n type BottomNavigationConfiguration,\n type BottomNavigationDescriptor,\n type ResolvedBottomNavigationItemDescriptor,\n} from \"@hjmds/design-contracts/components/bottom-navigation\";\nimport {\n bottomNavigationRecipe,\n iconRecipe,\n} from \"@hjmds/design-contracts/recipes\";\nimport {\n createContext,\n forwardRef,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type AnchorHTMLAttributes,\n type CSSProperties,\n type ForwardedRef,\n type HTMLAttributes,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type RefAttributes,\n} from \"react\";\nimport { assignRef, classNames } from \"./internal.js\";\nimport type { HjmCompositionStyleProp } from \"./composition-style.js\";\nimport { useOptionalHjmTheme } from \"./provider.js\";\n\nconst virtualKeyboardMinimumOcclusion = 120;\n\n/**\n * Height of the viewport bottom covered by the fixed bar (safe area and a raised center circle included); 0 when\n * there is no bar or it is hidden for the keyboard. The provider also exposes it as `--hjm-bottom-navigation-inset`,\n * which ScreenLayout's last region adds to its bottom padding, so products stop hand-keeping a bottom spacer\n * (2026-10-18; Native shares the same API for its `placement=\"overlay\"` bar).\n */\nconst BottomNavigationInsetContext = createContext(0);\nconst BottomNavigationInsetReporterContext = createContext<((height: number) => void) | null>(null);\n\nexport type BottomNavigationInsetProviderProps = Readonly<{ children: ReactNode }>;\n\n/** Wrap the app shell that holds both the screens and the BottomNavigation. */\nexport function BottomNavigationInsetProvider({ children }: BottomNavigationInsetProviderProps) {\n const [inset, setInset] = useState(0);\n const report = useMemo(() => (height: number) => {\n const next = Number.isFinite(height) && height > 0 ? height : 0;\n setInset(current => current === next ? current : next);\n }, []);\n return (\n <BottomNavigationInsetReporterContext.Provider value={report}>\n <BottomNavigationInsetContext.Provider value={inset}>\n {/* `display: contents` adds no box; the custom property still inherits to every screen below. */}\n <div style={{ display: \"contents\", \"--hjm-bottom-navigation-inset\": `${inset}px` } as CSSProperties}>{children}</div>\n </BottomNavigationInsetContext.Provider>\n </BottomNavigationInsetReporterContext.Provider>\n );\n}\n\n/**\n * Bottom height covered by the BottomNavigation inside the nearest provider; 0 outside one. For layouts that are not\n * a ScreenLayout: inside one the shell already pads by it, so adding it again doubles the space.\n */\nexport function useBottomNavigationInset(): number {\n return useContext(BottomNavigationInsetContext);\n}\n\nexport type BottomNavigationIconRenderProps<\n Key extends string = string,\n IconName extends string = string,\n> = Readonly<{\n item: ResolvedBottomNavigationItemDescriptor<Key, IconName>;\n name: IconName;\n selected: boolean;\n color: \"currentColor\";\n size: number;\n strokeWidth: number;\n scale: number;\n}>;\n\nexport type BottomNavigationLinkRenderProps = AnchorHTMLAttributes<HTMLAnchorElement> &\n Readonly<{\n href: string;\n children: ReactNode;\n \"data-state\": \"idle\" | \"selected\";\n }>;\n\nexport type BottomNavigationProps<\n Key extends string = string,\n IconName extends string = string,\n> = Omit<\n HTMLAttributes<HTMLElement>,\n \"aria-label\" | \"aria-labelledby\" | \"children\" | \"dir\" | \"onChange\" | \"role\"\n> &\n Readonly<{\n descriptor: BottomNavigationDescriptor<Key, IconName>;\n configuration?: BottomNavigationConfiguration;\n getHref: (item: ResolvedBottomNavigationItemDescriptor<Key, IconName>) => string;\n renderIcon: (props: BottomNavigationIconRenderProps<Key, IconName>) => ReactNode;\n /** Framework navigation adapter, for example Next.js Link. */\n renderLink?: (props: BottomNavigationLinkRenderProps) => ReactElement;\n primaryAction?: ReactNode;\n onActivate?: (activation: BottomNavigationActivation<Key>) => void;\n /** Canonical layout-only placement on the root element. Controlled visual keys are excluded. */\n layoutStyle?: HjmCompositionStyleProp;\n }>;\n\nexport function isUnmodifiedPrimaryBottomNavigationClick(\n event: Pick<\n MouseEvent<HTMLAnchorElement>,\n \"altKey\" | \"button\" | \"ctrlKey\" | \"defaultPrevented\" | \"metaKey\" | \"shiftKey\"\n >,\n): boolean {\n return (\n !event.defaultPrevented &&\n event.button === 0 &&\n !event.metaKey &&\n !event.ctrlKey &&\n !event.shiftKey &&\n !event.altKey\n );\n}\n\nexport function shouldHideBottomNavigationForKeyboard(input: Readonly<{\n behavior: \"hide\" | \"remain\";\n layoutViewportHeight: number;\n visualViewportHeight: number;\n visualViewportOffsetTop?: number;\n visualViewportScale?: number;\n}>): boolean {\n if (input.behavior !== \"hide\") return false;\n if ((input.visualViewportScale ?? 1) !== 1) return false;\n const visibleBottom =\n input.visualViewportHeight + (input.visualViewportOffsetTop ?? 0);\n return layoutViewportHeightIsValid(input.layoutViewportHeight) &&\n input.layoutViewportHeight - visibleBottom >= virtualKeyboardMinimumOcclusion;\n}\n\nfunction layoutViewportHeightIsValid(value: number): boolean {\n return Number.isFinite(value) && value >= 0;\n}\n\nexport function getBottomNavigationGridColumn(\n index: number,\n itemCount: number,\n distribution: \"equal\" | \"center-gap\",\n): number | undefined {\n if (distribution !== \"center-gap\") return undefined;\n const middle = itemCount / 2;\n return index < middle ? index + 1 : index + 2;\n}\n\nfunction useKeyboardHidden(behavior: \"hide\" | \"remain\"): boolean {\n const [hidden, setHidden] = useState(false);\n useEffect(() => {\n const viewport = window.visualViewport;\n if (!viewport) return;\n const update = () => {\n setHidden(\n shouldHideBottomNavigationForKeyboard({\n behavior,\n layoutViewportHeight: window.innerHeight,\n visualViewportHeight: viewport.height,\n visualViewportOffsetTop: viewport.offsetTop,\n visualViewportScale: viewport.scale,\n }),\n );\n };\n update();\n viewport.addEventListener(\"resize\", update);\n viewport.addEventListener(\"scroll\", update);\n return () => {\n viewport.removeEventListener(\"resize\", update);\n viewport.removeEventListener(\"scroll\", update);\n };\n }, [behavior]);\n return hidden;\n}\n\nfunction BottomNavigationInner<\n Key extends string = string,\n IconName extends string = string,\n>(\n {\n descriptor,\n configuration = {},\n getHref,\n renderIcon,\n renderLink,\n primaryAction,\n onActivate,\n className,\n style,\n layoutStyle,\n ...props\n }: BottomNavigationProps<Key, IconName>,\n ref: ForwardedRef<HTMLElement>,\n) {\n const resolved = resolveBottomNavigationDescriptor(descriptor);\n const theme = useOptionalHjmTheme();\n const direction = configuration.direction ?? theme?.environment.direction;\n const presentation = resolveBottomNavigationConfiguration(\n {\n ...configuration,\n ...(direction === undefined ? {} : { direction }),\n },\n resolved.items.length,\n );\n validateBottomNavigationProminence(resolved.items, presentation);\n const hidden = useKeyboardHidden(presentation.keyboardBehavior);\n const density = bottomNavigationRecipe.density[presentation.density];\n const presentationRecipe =\n bottomNavigationRecipe.presentations[presentation.presentation];\n const centerGap =\n bottomNavigationRecipe.distributions[presentation.distribution].centerGap;\n const iconSize = presentation.iconSize === \"standard\"\n ? iconRecipe.sizes[density.icon]\n : bottomNavigationRecipe.iconSizes[presentation.iconSize];\n // `shape` reframes the floating surface (radius + inner padding); `standard` keeps the presentation recipe.\n const shapeRecipe = presentation.shape === \"standard\"\n ? null\n : bottomNavigationRecipe.shapes[presentation.shape];\n const liftRecipe = bottomNavigationRecipe.icon.liftEmphasis;\n const prominentRecipe = bottomNavigationRecipe.prominentDestination;\n // Lifting by (diameter - indicator height) keeps the prominent label on the other labels' line; an app-icon\n // slot taller than the indicator minimum raises that height.\n const prominentLift = prominentRecipe.diameter - Math.max(bottomNavigationRecipe.indicator.minHeight, iconSize);\n // The part of the circle above the nav box still covers content, so the reported inset includes it.\n const prominentOverflow = resolved.items.some((item) => item.prominent)\n ? Math.max(0, prominentLift - density.padding - presentationRecipe.outerPaddingTop)\n : 0;\n const navRef = useRef<HTMLElement | null>(null);\n const reportInset = useContext(BottomNavigationInsetReporterContext);\n useEffect(() => {\n const nav = navRef.current;\n if (!reportInset) return;\n if (hidden || !nav) {\n reportInset(0);\n return;\n }\n const update = () => reportInset(nav.getBoundingClientRect().height + prominentOverflow);\n update();\n const observer = new ResizeObserver(update);\n observer.observe(nav);\n return () => {\n observer.disconnect();\n reportInset(0);\n };\n }, [reportInset, hidden, prominentOverflow]);\n\n if (hidden) return null;\n\n return (\n <nav\n {...props}\n ref={(node) => {\n navRef.current = node;\n assignRef(ref, node);\n }}\n aria-label={resolved.accessibilityLabel}\n className={classNames(\"hjm-bottom-navigation\", className)}\n data-expanded-labels={(theme?.environment.textScale ?? 1) >= 1.5 || resolved.items.length > 4 ? \"true\" : \"false\"}\n data-density={presentation.density}\n data-distribution={presentation.distribution}\n data-keyboard-behavior={presentation.keyboardBehavior}\n data-labels={presentation.labels}\n data-selection={presentation.selection}\n data-surface={presentation.surface}\n data-presentation={presentation.presentation}\n data-shape={presentation.shape}\n data-icon-emphasis={presentation.iconEmphasis}\n dir={presentation.direction}\n style={{\n \"--hjm-bottom-navigation-center-gap\": `${centerGap}px`,\n \"--hjm-bottom-navigation-columns\": resolved.items.length,\n \"--hjm-bottom-navigation-half-columns\": resolved.items.length / 2,\n \"--hjm-bottom-navigation-item-gap\": `${density.gap}px`,\n \"--hjm-bottom-navigation-item-min-height\": `${density.itemMinHeight}px`,\n \"--hjm-bottom-navigation-item-min-width\": `${density.itemMinWidth}px`,\n \"--hjm-bottom-navigation-item-padding\": `${density.padding}px`,\n \"--hjm-bottom-navigation-max-width\": presentationRecipe.maxWidth\n ? `${presentationRecipe.maxWidth}px`\n : \"none\",\n \"--hjm-bottom-navigation-content-max-width\": presentationRecipe.contentMaxWidth\n ? `${presentationRecipe.contentMaxWidth}px`\n : \"none\",\n \"--hjm-bottom-navigation-outer-inline\": `${presentationRecipe.outerPaddingHorizontal}px`,\n \"--hjm-bottom-navigation-outer-top\": `${presentationRecipe.outerPaddingTop}px`,\n \"--hjm-bottom-navigation-prominent-diameter\": `${prominentRecipe.diameter}px`,\n \"--hjm-bottom-navigation-prominent-lift\": `${prominentLift}px`,\n ...(shapeRecipe ? {\n \"--hjm-bottom-navigation-shape-radius\": `var(--hjm-radius-${shapeRecipe.radius})`,\n \"--hjm-bottom-navigation-shape-padding\": `${shapeRecipe.surfacePadding}px`,\n } : {}),\n ...(presentation.iconEmphasis === \"lift\" ? {\n \"--hjm-bottom-navigation-lift-offset\": `${liftRecipe.translateY}px`,\n \"--hjm-bottom-navigation-lift-idle-opacity\": liftRecipe.idleOpacity,\n } : {}),\n ...style,\n ...layoutStyle,\n } as CSSProperties}\n >\n <div className=\"hjm-bottom-navigation__surface\">\n <ul className=\"hjm-bottom-navigation__list\">\n {resolved.items.map((item, index) => {\n const selected = item.id === resolved.selectedKey;\n const content = (\n <>\n <span\n aria-hidden=\"true\"\n className=\"hjm-bottom-navigation__indicator\"\n data-state={selected ? \"selected\" : \"idle\"}\n >\n {renderIcon({\n item,\n name: item.icon.name,\n selected,\n color: \"currentColor\",\n size: item.prominent ? iconRecipe.sizes[prominentRecipe.icon] : iconSize,\n strokeWidth: selected\n ? bottomNavigationRecipe.icon.selectedEmphasis.strokeWidth.selected\n : bottomNavigationRecipe.icon.selectedEmphasis.strokeWidth.idle,\n scale: selected\n ? bottomNavigationRecipe.icon.selectedEmphasis.scale.selected\n : bottomNavigationRecipe.icon.selectedEmphasis.scale.idle,\n })}\n {item.badge ? (\n <span aria-hidden=\"true\" className=\"hjm-bottom-navigation__badge\">\n {item.badge.visibleLabel}\n </span>\n ) : null}\n </span>\n {/* Hidden labels are not rendered: the item link already carries\n resolvedAccessibilityLabel, so a visually-hidden copy would only duplicate it. */}\n {presentation.labels === \"visible\" ? (\n <span className=\"hjm-bottom-navigation__label\">{item.label}</span>\n ) : null}\n </>\n );\n const itemStyle = {\n gridColumn: getBottomNavigationGridColumn(\n index,\n resolved.items.length,\n presentation.distribution,\n ),\n };\n if (item.disabled) {\n return (\n <li key={item.id} style={itemStyle} data-selected=\"false\" data-prominent={item.prominent || undefined}>\n <span\n aria-disabled=\"true\"\n aria-label={item.resolvedAccessibilityLabel}\n className=\"hjm-bottom-navigation__item\"\n data-state=\"disabled\"\n role=\"link\"\n >\n {content}\n </span>\n </li>\n );\n }\n const href = getHref(item);\n if (!href.trim()) {\n throw new TypeError(`BottomNavigation href must not be empty: ${item.id}`);\n }\n const linkProps: BottomNavigationLinkRenderProps = {\n \"aria-current\": selected ? \"page\" : undefined,\n \"aria-label\": item.resolvedAccessibilityLabel,\n className: \"hjm-bottom-navigation__item\",\n \"data-state\": selected ? \"selected\" : \"idle\",\n href,\n onClick: (event) => {\n if (!isUnmodifiedPrimaryBottomNavigationClick(event)) return;\n const activation = resolveBottomNavigationActivation(descriptor, item.id);\n if (activation) onActivate?.(activation);\n },\n children: content,\n };\n return (\n <li key={item.id} style={itemStyle} data-selected={selected} data-prominent={item.prominent || undefined}>\n {renderLink ? renderLink(linkProps) : <a {...linkProps} />}\n </li>\n );\n })}\n </ul>\n {primaryAction ? (\n <div className=\"hjm-bottom-navigation__primary-action\">{primaryAction}</div>\n ) : null}\n </div>\n </nav>\n );\n}\n\nexport const BottomNavigation = forwardRef(BottomNavigationInner) as <\n Key extends string = string,\n IconName extends string = string,\n>(\n props: BottomNavigationProps<Key, IconName> & RefAttributes<HTMLElement>,\n) => ReactElement | null;\n"]}
|
package/dist/evidence.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ export type ReactRendererEvidenceManifest = Readonly<{
|
|
|
34
34
|
export declare const reactRendererEvidence: {
|
|
35
35
|
readonly schemaVersion: 2;
|
|
36
36
|
readonly packageName: "@hjmds/react";
|
|
37
|
-
readonly packageVersion: "1.
|
|
37
|
+
readonly packageVersion: "1.32.1";
|
|
38
38
|
readonly surface: "web";
|
|
39
39
|
readonly components: Readonly<{
|
|
40
40
|
/** Canonical component id from the design-contracts catalog. */
|
package/dist/evidence.js
CHANGED
|
@@ -134,7 +134,7 @@ const activeWebEntries = componentCatalog.filter((entry) => {
|
|
|
134
134
|
export const reactRendererEvidence = {
|
|
135
135
|
schemaVersion: reactRendererEvidenceSchemaVersion,
|
|
136
136
|
packageName: "@hjmds/react",
|
|
137
|
-
packageVersion: "1.
|
|
137
|
+
packageVersion: "1.32.1",
|
|
138
138
|
surface: "web",
|
|
139
139
|
components: activeWebEntries.map(derivedClaim),
|
|
140
140
|
};
|
package/dist/evidence.js.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AAC,CAAC;IACvD,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,MAAM,CAAC;AAClD,CAAC,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,aAAa,EAAE,kCAAkC;IACjD,WAAW,EAAE,cAAc;IAC3B,cAAc,EAAE,QAAQ;IACxB,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,gBAAgB,CAAC,GAAG,CAAC,YAAY,CAAC;CACE,CAAC","sourcesContent":["import type { ShowcaseScenarioId } from \"@hjmds/design-contracts/showcase\";\nimport { getRequiredShowcaseEvidence } from \"@hjmds/design-contracts/showcase\";\nimport { componentCatalog, componentIdOf, getComponentSurfaceStatus, type ComponentCatalogEntry } from \"@hjmds/design-contracts/catalog\";\nimport { publicExportEntries } from \"./public-exports.generated.js\";\n\nexport const reactRendererEvidenceSchemaVersion = 2 as const;\n\nexport type ReactRendererEvidenceScenario = Exclude<ShowcaseScenarioId, \"contract\" | \"native-actions\">;\n\nexport type ReactRendererEvidenceComponent = Readonly<{\n /** Canonical component id from the design-contracts catalog. */\n componentId: string;\n /** Public symbols that implement this contract on the declared subpath. */\n exportNames: readonly string[];\n /** Granular @hjmds/react export used by consumers. */\n subpath: `./${string}`;\n /** Scenarios supported by automated first-party renderer evidence. */\n scenarios: readonly ReactRendererEvidenceScenario[];\n /** Repository-local executable proof for every claimed scenario. */\n proofs: readonly Readonly<{\n scenarios: readonly ReactRendererEvidenceScenario[];\n file: `test/${string}.test.tsx`;\n caseId: string;\n }>[];\n}>;\n\nexport type ReactRendererEvidenceManifest = Readonly<{\n schemaVersion: typeof reactRendererEvidenceSchemaVersion;\n packageName: \"@hjmds/react\";\n packageVersion: string;\n surface: \"web\";\n components: readonly ReactRendererEvidenceComponent[];\n}>;\n\nconst defaultProofFile = \"test/default-render.ssr.test.tsx\" as const;\nconst matrixProofFile = \"test/scenario-matrix.browser.test.tsx\" as const;\nconst stableCoreProofFile = \"test/stable-core.browser.test.tsx\" as const;\n\ntype ProofFile = `test/${string}.test.tsx`;\n\n/**\n * Scenarios a component does not pass yet. Each entry is promotion debt that\n * the generated evidence projection reports; remove it when the component is\n * fixed and the matrix case passes. Stable surfaces cannot carry a gap\n * (scripts/check-workspace-sync.mjs).\n */\nconst webScenarioGaps: Readonly<Record<string, readonly ReactRendererEvidenceScenario[]>> = {};\n\n/**\n * Proofs that live outside the shared default/matrix files: keyboard behavior in a dedicated browser test,\n * long copy proven inside a portal by the component's own test, or a whole matrix run in a component file.\n * Everything else about a claim derives from the catalog row (2026-10-18 registration input).\n */\ntype ClaimExtras = Readonly<{\n /** Extra proofs; their scenarios are removed from the shared matrix proof. */\n proofs?: readonly Readonly<{ scenarios: readonly ReactRendererEvidenceScenario[]; file: ProofFile }>[];\n /** Hooks or helpers published beside the component symbols on the same subpath. */\n exportNames?: readonly string[];\n}>;\n\nconst keyboard = (file: ProofFile = stableCoreProofFile): ClaimExtras => ({ proofs: [{ scenarios: [\"keyboard\"], file }] });\nconst keyboardAndLongCopy = (file: ProofFile): ClaimExtras => ({ proofs: [{ scenarios: [\"keyboard\", \"long-copy\"], file }] });\n\nconst claimExtras: Readonly<Record<string, ClaimExtras>> = {\n \"design-system-provider\": { exportNames: [\"useHjmTheme\"] },\n layout: keyboard(),\n link: keyboard(),\n field: keyboard(),\n \"search-field\": keyboard(),\n \"password-field\": keyboard(),\n \"otp-field\": keyboard(),\n \"number-field\": keyboard(),\n slider: keyboard(),\n form: keyboard(\"test/form.keyboard.browser.test.tsx\"),\n \"date-picker\": keyboard(),\n calendar: keyboard(\"test/calendar.browser.test.tsx\"),\n \"file-picker\": keyboard(\"test/file-picker.keyboard.browser.test.tsx\"),\n checkbox: keyboard(),\n \"checkbox-group\": keyboard(),\n \"radio-group\": keyboard(),\n switch: keyboard(),\n \"segmented-control\": keyboard(),\n chip: keyboard(),\n tabs: keyboard(\"test/tabs.keyboard.browser.test.tsx\"),\n breadcrumb: keyboard(\"test/page-navigation.browser.test.tsx\"),\n pagination: keyboard(\"test/pagination.keyboard.browser.test.tsx\"),\n popover: keyboardAndLongCopy(\"test/popover.browser.test.tsx\"),\n \"side-panel\": keyboardAndLongCopy(\"test/side-panel.browser.test.tsx\"),\n splitter: keyboard(\"test/splitter.browser.test.tsx\"),\n tour: keyboardAndLongCopy(\"test/tour.browser.test.tsx\"),\n tree: keyboard(\"test/tree.browser.test.tsx\"),\n \"transfer-list\": keyboard(\"test/transfer-list.browser.test.tsx\"),\n mentions: keyboard(\"test/mentions.browser.test.tsx\"),\n \"command-palette\": keyboardAndLongCopy(\"test/command-palette.browser.test.tsx\"),\n agreement: keyboard(\"test/agreement.keyboard.browser.test.tsx\"),\n \"toggle-group\": keyboard(),\n \"tags-input\": keyboard(),\n \"skip-nav\": keyboardAndLongCopy(\"test/skip-nav.browser.test.tsx\"),\n sidebar: keyboard(\"test/sidebar.browser.test.tsx\"),\n \"date-range-picker\": keyboard(\"test/date-range.keyboard.browser.test.tsx\"),\n \"auth-provider-button\": keyboard(),\n \"data-table\": keyboard(\"test/data-table.keyboard.browser.test.tsx\"),\n collapsible: keyboard(\"test/collapsible.keyboard.browser.test.tsx\"),\n \"context-menu\": keyboardAndLongCopy(\"test/context-menu.interactions.browser.test.tsx\"),\n menubar: keyboard(\"test/menubar.keyboard.browser.test.tsx\"),\n anchor: keyboard(\"test/anchor.browser.test.tsx\"),\n \"bottom-navigation\": keyboard(\"test/bottom-navigation.keyboard.browser.test.tsx\"),\n \"load-more\": keyboard(\"test/load-more.interactions.browser.test.tsx\"),\n carousel: keyboard(\"test/carousel.browser.test.tsx\"),\n \"floating-action-button\": keyboard(),\n accordion: keyboard(\"test/accordion.keyboard.browser.test.tsx\"),\n \"upload-item\": keyboard(\"test/upload-item.browser.test.tsx\"),\n // ThinkingOrb runs its whole environment matrix in its own file (canvas timing), not in scenario-matrix.\n \"thinking-orb\": { proofs: [{ scenarios: [\"dark\", \"large-text\", \"rtl\", \"reduced-motion\", \"accessibility\"], file: \"test/thinking-orb.browser.test.tsx\" }] },\n \"color-picker\": keyboard(\"test/web-additions.browser.test.tsx\"),\n // SSR proves semantics but cannot catch the close-only row seen in BurnTok.\n // Keep real geometry evidence attached without promoting catalog maturity.\n toast: {\n exportNames: [\"useToast\"],\n proofs: [\n { scenarios: [\"keyboard\"], file: stableCoreProofFile },\n { scenarios: [\"dark\", \"long-copy\", \"large-text\", \"rtl\"], file: \"test/toast-layout.browser.test.tsx\" },\n ],\n },\n select: keyboard(),\n combobox: keyboard(),\n dialog: keyboard(\"test/advanced.browser.test.tsx\"),\n \"alert-dialog\": keyboardAndLongCopy(\"test/alert-dialog.keyboard.browser.test.tsx\"),\n sheet: keyboardAndLongCopy(\"test/sheet-layout.browser.test.tsx\"),\n tooltip: keyboard(\"test/tooltip.browser.test.tsx\"),\n menu: keyboardAndLongCopy(\"test/menu.keyboard.browser.test.tsx\"),\n};\n\nconst exportEntries: Readonly<Record<string, readonly `./${string}`[] | undefined>> = publicExportEntries;\n\n/**\n * One claim per active Web row of the catalog. The subpath is the symbol's canonical granular entry, the export\n * names are the row's own symbol plus the companions published on that entry, and the scenarios are the row's\n * required Web evidence minus recorded gaps. Keyboard is never implied: it comes only from a dedicated proof.\n */\nfunction derivedClaim(entry: ComponentCatalogEntry): ReactRendererEvidenceComponent {\n const componentId = componentIdOf(entry);\n const extras = claimExtras[componentId] ?? {};\n const symbols = entry.name === \"DesignSystemProvider\" ? [\"HjmProvider\"] : [entry.name, ...(entry.companions ?? [])];\n // A row whose own name is not a symbol (Chart) claims through its first published companion.\n const subpath = symbols.map((symbol) => exportEntries[symbol]?.[0]).find((entry) => entry !== undefined);\n if (!subpath) throw new Error(`${entry.name} has no granular @hjmds/react export to claim evidence on`);\n const exportNames = [\n ...symbols.filter((symbol) => exportEntries[symbol]?.includes(subpath)),\n ...(extras.exportNames ?? []),\n ];\n const required = getRequiredShowcaseEvidence(entry).find((evidence) => evidence.surface === \"web\")?.scenarios ?? [];\n const gaps = webScenarioGaps[componentId] ?? [];\n const extraProofs = extras.proofs ?? [];\n const proven = new Set(extraProofs.flatMap((proof) => proof.scenarios));\n const matrix = required.filter((scenario): scenario is ReactRendererEvidenceScenario =>\n scenario !== \"default\" && scenario !== \"keyboard\" && scenario !== \"native-actions\" && scenario !== \"contract\"\n && !gaps.includes(scenario as ReactRendererEvidenceScenario) && !proven.has(scenario as ReactRendererEvidenceScenario));\n const proofs = [\n { scenarios: [\"default\" as const], file: defaultProofFile, caseId: componentId },\n ...(matrix.length === 0 ? [] : [{ scenarios: matrix, file: matrixProofFile, caseId: componentId }]),\n ...extraProofs.map((proof) => ({ ...proof, caseId: componentId })),\n ];\n return {\n componentId,\n exportNames,\n subpath,\n scenarios: proofs.flatMap((proof) => proof.scenarios),\n proofs,\n };\n}\n\nconst activeWebEntries: readonly ComponentCatalogEntry[] = componentCatalog.filter((entry) => {\n const status = getComponentSurfaceStatus(entry, \"web\");\n return status === \"stable\" || status === \"beta\";\n});\n\n/**\n * First-party Web renderer claims. Scenario axes remain fail-closed: the\n * default scenario is an SSR render, the environment and accessibility\n * scenarios are computed-style assertions in scenario-matrix.browser.\n * Keyboard and cross-platform parity remain fail-closed until dedicated\n * interaction or paired-renderer proofs are mapped one-to-one.\n */\nexport const reactRendererEvidence = {\n schemaVersion: reactRendererEvidenceSchemaVersion,\n packageName: \"@hjmds/react\",\n packageVersion: \"1.31.0\",\n surface: \"web\",\n components: activeWebEntries.map(derivedClaim),\n} as const satisfies ReactRendererEvidenceManifest;\n"]}
|
|
1
|
+
{"version":3,"file":"evidence.js","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,yBAAyB,EAA8B,MAAM,iCAAiC,CAAC;AACzI,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEpE,MAAM,CAAC,MAAM,kCAAkC,GAAG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["import type { ShowcaseScenarioId } from \"@hjmds/design-contracts/showcase\";\nimport { getRequiredShowcaseEvidence } from \"@hjmds/design-contracts/showcase\";\nimport { componentCatalog, componentIdOf, getComponentSurfaceStatus, type ComponentCatalogEntry } from \"@hjmds/design-contracts/catalog\";\nimport { publicExportEntries } from \"./public-exports.generated.js\";\n\nexport const reactRendererEvidenceSchemaVersion = 2 as const;\n\nexport type ReactRendererEvidenceScenario = Exclude<ShowcaseScenarioId, \"contract\" | \"native-actions\">;\n\nexport type ReactRendererEvidenceComponent = Readonly<{\n /** Canonical component id from the design-contracts catalog. */\n componentId: string;\n /** Public symbols that implement this contract on the declared subpath. */\n exportNames: readonly string[];\n /** Granular @hjmds/react export used by consumers. */\n subpath: `./${string}`;\n /** Scenarios supported by automated first-party renderer evidence. */\n scenarios: readonly ReactRendererEvidenceScenario[];\n /** Repository-local executable proof for every claimed scenario. */\n proofs: readonly Readonly<{\n scenarios: readonly ReactRendererEvidenceScenario[];\n file: `test/${string}.test.tsx`;\n caseId: string;\n }>[];\n}>;\n\nexport type ReactRendererEvidenceManifest = Readonly<{\n schemaVersion: typeof reactRendererEvidenceSchemaVersion;\n packageName: \"@hjmds/react\";\n packageVersion: string;\n surface: \"web\";\n components: readonly ReactRendererEvidenceComponent[];\n}>;\n\nconst defaultProofFile = \"test/default-render.ssr.test.tsx\" as const;\nconst matrixProofFile = \"test/scenario-matrix.browser.test.tsx\" as const;\nconst stableCoreProofFile = \"test/stable-core.browser.test.tsx\" as const;\n\ntype ProofFile = `test/${string}.test.tsx`;\n\n/**\n * Scenarios a component does not pass yet. Each entry is promotion debt that\n * the generated evidence projection reports; remove it when the component is\n * fixed and the matrix case passes. Stable surfaces cannot carry a gap\n * (scripts/check-workspace-sync.mjs).\n */\nconst webScenarioGaps: Readonly<Record<string, readonly ReactRendererEvidenceScenario[]>> = {};\n\n/**\n * Proofs that live outside the shared default/matrix files: keyboard behavior in a dedicated browser test,\n * long copy proven inside a portal by the component's own test, or a whole matrix run in a component file.\n * Everything else about a claim derives from the catalog row (2026-10-18 registration input).\n */\ntype ClaimExtras = Readonly<{\n /** Extra proofs; their scenarios are removed from the shared matrix proof. */\n proofs?: readonly Readonly<{ scenarios: readonly ReactRendererEvidenceScenario[]; file: ProofFile }>[];\n /** Hooks or helpers published beside the component symbols on the same subpath. */\n exportNames?: readonly string[];\n}>;\n\nconst keyboard = (file: ProofFile = stableCoreProofFile): ClaimExtras => ({ proofs: [{ scenarios: [\"keyboard\"], file }] });\nconst keyboardAndLongCopy = (file: ProofFile): ClaimExtras => ({ proofs: [{ scenarios: [\"keyboard\", \"long-copy\"], file }] });\n\nconst claimExtras: Readonly<Record<string, ClaimExtras>> = {\n \"design-system-provider\": { exportNames: [\"useHjmTheme\"] },\n layout: keyboard(),\n link: keyboard(),\n field: keyboard(),\n \"search-field\": keyboard(),\n \"password-field\": keyboard(),\n \"otp-field\": keyboard(),\n \"number-field\": keyboard(),\n slider: keyboard(),\n form: keyboard(\"test/form.keyboard.browser.test.tsx\"),\n \"date-picker\": keyboard(),\n calendar: keyboard(\"test/calendar.browser.test.tsx\"),\n \"file-picker\": keyboard(\"test/file-picker.keyboard.browser.test.tsx\"),\n checkbox: keyboard(),\n \"checkbox-group\": keyboard(),\n \"radio-group\": keyboard(),\n switch: keyboard(),\n \"segmented-control\": keyboard(),\n chip: keyboard(),\n tabs: keyboard(\"test/tabs.keyboard.browser.test.tsx\"),\n breadcrumb: keyboard(\"test/page-navigation.browser.test.tsx\"),\n pagination: keyboard(\"test/pagination.keyboard.browser.test.tsx\"),\n popover: keyboardAndLongCopy(\"test/popover.browser.test.tsx\"),\n \"side-panel\": keyboardAndLongCopy(\"test/side-panel.browser.test.tsx\"),\n splitter: keyboard(\"test/splitter.browser.test.tsx\"),\n tour: keyboardAndLongCopy(\"test/tour.browser.test.tsx\"),\n tree: keyboard(\"test/tree.browser.test.tsx\"),\n \"transfer-list\": keyboard(\"test/transfer-list.browser.test.tsx\"),\n mentions: keyboard(\"test/mentions.browser.test.tsx\"),\n \"command-palette\": keyboardAndLongCopy(\"test/command-palette.browser.test.tsx\"),\n agreement: keyboard(\"test/agreement.keyboard.browser.test.tsx\"),\n \"toggle-group\": keyboard(),\n \"tags-input\": keyboard(),\n \"skip-nav\": keyboardAndLongCopy(\"test/skip-nav.browser.test.tsx\"),\n sidebar: keyboard(\"test/sidebar.browser.test.tsx\"),\n \"date-range-picker\": keyboard(\"test/date-range.keyboard.browser.test.tsx\"),\n \"auth-provider-button\": keyboard(),\n \"data-table\": keyboard(\"test/data-table.keyboard.browser.test.tsx\"),\n collapsible: keyboard(\"test/collapsible.keyboard.browser.test.tsx\"),\n \"context-menu\": keyboardAndLongCopy(\"test/context-menu.interactions.browser.test.tsx\"),\n menubar: keyboard(\"test/menubar.keyboard.browser.test.tsx\"),\n anchor: keyboard(\"test/anchor.browser.test.tsx\"),\n \"bottom-navigation\": keyboard(\"test/bottom-navigation.keyboard.browser.test.tsx\"),\n \"load-more\": keyboard(\"test/load-more.interactions.browser.test.tsx\"),\n carousel: keyboard(\"test/carousel.browser.test.tsx\"),\n \"floating-action-button\": keyboard(),\n accordion: keyboard(\"test/accordion.keyboard.browser.test.tsx\"),\n \"upload-item\": keyboard(\"test/upload-item.browser.test.tsx\"),\n // ThinkingOrb runs its whole environment matrix in its own file (canvas timing), not in scenario-matrix.\n \"thinking-orb\": { proofs: [{ scenarios: [\"dark\", \"large-text\", \"rtl\", \"reduced-motion\", \"accessibility\"], file: \"test/thinking-orb.browser.test.tsx\" }] },\n \"color-picker\": keyboard(\"test/web-additions.browser.test.tsx\"),\n // SSR proves semantics but cannot catch the close-only row seen in BurnTok.\n // Keep real geometry evidence attached without promoting catalog maturity.\n toast: {\n exportNames: [\"useToast\"],\n proofs: [\n { scenarios: [\"keyboard\"], file: stableCoreProofFile },\n { scenarios: [\"dark\", \"long-copy\", \"large-text\", \"rtl\"], file: \"test/toast-layout.browser.test.tsx\" },\n ],\n },\n select: keyboard(),\n combobox: keyboard(),\n dialog: keyboard(\"test/advanced.browser.test.tsx\"),\n \"alert-dialog\": keyboardAndLongCopy(\"test/alert-dialog.keyboard.browser.test.tsx\"),\n sheet: keyboardAndLongCopy(\"test/sheet-layout.browser.test.tsx\"),\n tooltip: keyboard(\"test/tooltip.browser.test.tsx\"),\n menu: keyboardAndLongCopy(\"test/menu.keyboard.browser.test.tsx\"),\n};\n\nconst exportEntries: Readonly<Record<string, readonly `./${string}`[] | undefined>> = publicExportEntries;\n\n/**\n * One claim per active Web row of the catalog. The subpath is the symbol's canonical granular entry, the export\n * names are the row's own symbol plus the companions published on that entry, and the scenarios are the row's\n * required Web evidence minus recorded gaps. Keyboard is never implied: it comes only from a dedicated proof.\n */\nfunction derivedClaim(entry: ComponentCatalogEntry): ReactRendererEvidenceComponent {\n const componentId = componentIdOf(entry);\n const extras = claimExtras[componentId] ?? {};\n const symbols = entry.name === \"DesignSystemProvider\" ? [\"HjmProvider\"] : [entry.name, ...(entry.companions ?? [])];\n // A row whose own name is not a symbol (Chart) claims through its first published companion.\n const subpath = symbols.map((symbol) => exportEntries[symbol]?.[0]).find((entry) => entry !== undefined);\n if (!subpath) throw new Error(`${entry.name} has no granular @hjmds/react export to claim evidence on`);\n const exportNames = [\n ...symbols.filter((symbol) => exportEntries[symbol]?.includes(subpath)),\n ...(extras.exportNames ?? []),\n ];\n const required = getRequiredShowcaseEvidence(entry).find((evidence) => evidence.surface === \"web\")?.scenarios ?? [];\n const gaps = webScenarioGaps[componentId] ?? [];\n const extraProofs = extras.proofs ?? [];\n const proven = new Set(extraProofs.flatMap((proof) => proof.scenarios));\n const matrix = required.filter((scenario): scenario is ReactRendererEvidenceScenario =>\n scenario !== \"default\" && scenario !== \"keyboard\" && scenario !== \"native-actions\" && scenario !== \"contract\"\n && !gaps.includes(scenario as ReactRendererEvidenceScenario) && !proven.has(scenario as ReactRendererEvidenceScenario));\n const proofs = [\n { scenarios: [\"default\" as const], file: defaultProofFile, caseId: componentId },\n ...(matrix.length === 0 ? [] : [{ scenarios: matrix, file: matrixProofFile, caseId: componentId }]),\n ...extraProofs.map((proof) => ({ ...proof, caseId: componentId })),\n ];\n return {\n componentId,\n exportNames,\n subpath,\n scenarios: proofs.flatMap((proof) => proof.scenarios),\n proofs,\n };\n}\n\nconst activeWebEntries: readonly ComponentCatalogEntry[] = componentCatalog.filter((entry) => {\n const status = getComponentSurfaceStatus(entry, \"web\");\n return status === \"stable\" || status === \"beta\";\n});\n\n/**\n * First-party Web renderer claims. Scenario axes remain fail-closed: the\n * default scenario is an SSR render, the environment and accessibility\n * scenarios are computed-style assertions in scenario-matrix.browser.\n * Keyboard and cross-platform parity remain fail-closed until dedicated\n * interaction or paired-renderer proofs are mapped one-to-one.\n */\nexport const reactRendererEvidence = {\n schemaVersion: reactRendererEvidenceSchemaVersion,\n packageName: \"@hjmds/react\",\n packageVersion: \"1.32.1\",\n surface: \"web\",\n components: activeWebEntries.map(derivedClaim),\n} as const satisfies ReactRendererEvidenceManifest;\n"]}
|
package/dist/image-choice.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type ImageChoiceItemDescriptor } from "@hjmds/design-contracts/components/image-choice";
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type ImageChoiceItemDescriptor, type ImageChoiceItemLabelLines } from "@hjmds/design-contracts/components/image-choice";
|
|
3
3
|
export type ImageChoiceItem = ImageChoiceItemDescriptor & Readonly<{
|
|
4
4
|
image: ReactNode;
|
|
5
5
|
}>;
|
|
6
|
+
export type ImageChoiceVirtualization = Readonly<{
|
|
7
|
+
/** Height of the scrolling viewport in px. The group scrolls itself, so do not also put it in a scrolling parent. */
|
|
8
|
+
height: number;
|
|
9
|
+
/** Rows kept mounted above and below the visible window. */
|
|
10
|
+
overscan?: number;
|
|
11
|
+
}>;
|
|
6
12
|
type Base = Readonly<{
|
|
7
13
|
/** Localized group name read before the choices. */
|
|
8
14
|
label: string;
|
|
@@ -13,9 +19,16 @@ type Base = Readonly<{
|
|
|
13
19
|
* The tile keeps the same accessible name, so turning this on does not change what assistive tech reads.
|
|
14
20
|
*/
|
|
15
21
|
showItemLabels?: boolean;
|
|
22
|
+
/** Lines the visible item label wraps to before the ellipsis (default 1). Every tile reserves the same height. */
|
|
23
|
+
itemLabelLines?: ImageChoiceItemLabelLines;
|
|
16
24
|
items: readonly ImageChoiceItem[];
|
|
17
25
|
disabled?: boolean;
|
|
18
26
|
className?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Long lists (hundreds of people): only the rows near the viewport are mounted. Tiles keep their size; the column
|
|
29
|
+
* count follows the measured width.
|
|
30
|
+
*/
|
|
31
|
+
virtualized?: ImageChoiceVirtualization;
|
|
19
32
|
}>;
|
|
20
33
|
export type ImageChoiceGroupProps = Base & (Readonly<{
|
|
21
34
|
selectionMode: "single";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-choice.d.ts","sourceRoot":"","sources":["../src/image-choice.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"image-choice.d.ts","sourceRoot":"","sources":["../src/image-choice.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA2E,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAIhH,OAAO,EAEwD,KAAK,yBAAyB,EAAE,KAAK,yBAAyB,EAC5H,MAAM,iDAAiD,CAAC;AAGzD,MAAM,MAAM,eAAe,GAAG,yBAAyB,GAAG,QAAQ,CAAC;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AACzF,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C,qHAAqH;IACrH,MAAM,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC;AACH,KAAK,IAAI,GAAG,QAAQ,CAAC;IACnB,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,8FAA8F;IAC9F,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kHAAkH;IAClH,cAAc,CAAC,EAAE,yBAAyB,CAAC;IAC3C,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,yBAAyB,CAAC;CACzC,CAAC,CAAC;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,GAAG,CACvC,QAAQ,CAAC;IAAE,aAAa,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,GAC/F,QAAQ,CAAC;IAAE,aAAa,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;CAAE,CAAC,CAC1G,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,+BAyC5D"}
|
package/dist/image-choice.js
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
2
3
|
import { Text } from "./layout.js";
|
|
3
|
-
import {
|
|
4
|
+
import { useOptionalHjmTheme } from "./provider.js";
|
|
5
|
+
import { typography } from "@hjmds/design-contracts/foundations";
|
|
6
|
+
import { imageChoiceRecipe, resolveImageChoiceCaptionLines, resolveImageChoiceColumns, resolveImageChoiceTileHeight, resolveImageChoiceToggle, validateImageChoiceItemLabelLines, validateImageChoiceItems, } from "@hjmds/design-contracts/components/image-choice";
|
|
7
|
+
import { resolveVirtualWindow, virtualListRecipe } from "@hjmds/design-contracts/components/virtual-list";
|
|
4
8
|
/**
|
|
5
9
|
* Picks avatars or photos by image (2026-10-16). Tiles are square, wrap to the available width, and show
|
|
6
10
|
* a brand ring plus a check when chosen; assistive tech hears radios (single) or checkboxes (multiple).
|
|
7
11
|
*/
|
|
8
12
|
export function ImageChoiceGroup(props) {
|
|
9
|
-
const { label, showLabel = false, showItemLabels = false, items, disabled = false, className } = props;
|
|
13
|
+
const { label, showLabel = false, showItemLabels = false, itemLabelLines = imageChoiceRecipe.itemLabelLines, items, disabled = false, className, virtualized } = props;
|
|
10
14
|
validateImageChoiceItems(items);
|
|
15
|
+
validateImageChoiceItemLabelLines(itemLabelLines);
|
|
16
|
+
const theme = useOptionalHjmTheme();
|
|
17
|
+
const baseId = useId();
|
|
11
18
|
const isSelected = (id) => props.selectionMode === "single" ? props.value === id : props.value.includes(id);
|
|
12
19
|
const choose = (id) => {
|
|
13
20
|
if (props.selectionMode === "single")
|
|
@@ -16,10 +23,55 @@ export function ImageChoiceGroup(props) {
|
|
|
16
23
|
props.onValueChange(resolveImageChoiceToggle("multiple", props.value, id));
|
|
17
24
|
};
|
|
18
25
|
const role = props.selectionMode === "single" ? "radio" : "checkbox";
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
const groupRole = props.selectionMode === "single" ? "radiogroup" : "group";
|
|
27
|
+
const captionLines = resolveImageChoiceCaptionLines({ showItemLabels, itemLabelLines, hasDescription: items.some(item => item.description !== undefined) });
|
|
28
|
+
const style = { "--hjm-image-choice-size": `${imageChoiceRecipe.tileSize}px`, "--hjm-image-choice-gap": `${imageChoiceRecipe.gap}px`, "--hjm-image-choice-radius": `${imageChoiceRecipe.radius}px`, "--hjm-image-choice-ring": `${imageChoiceRecipe.ringWidth}px`, "--hjm-image-choice-offset": `${imageChoiceRecipe.ringOffset}px`, "--hjm-image-choice-check": `${imageChoiceRecipe.checkSize}px`, "--hjm-image-choice-item-label-gap": `${imageChoiceRecipe.itemLabelGap}px`, "--hjm-image-choice-caption-lines": captionLines, "--hjm-image-choice-viewport-inset": `${imageChoiceRecipe.virtualViewportInset}px` };
|
|
29
|
+
const renderTile = (item, index) => {
|
|
30
|
+
const selected = isSelected(item.id);
|
|
31
|
+
const descriptionId = item.description === undefined ? undefined : `${baseId}-description-${index}`;
|
|
32
|
+
return _jsxs("button", { type: "button", role: role, "aria-checked": selected, "aria-label": item.label, "aria-describedby": descriptionId, className: "hjm-image-choice__tile", "data-selected": selected || undefined, disabled: disabled || item.disabled, onClick: () => choose(item.id), children: [_jsxs("span", { className: "hjm-image-choice__ring", children: [_jsx("span", { className: "hjm-image-choice__image", children: item.image }), selected ? _jsx("span", { className: "hjm-image-choice__check", "aria-hidden": "true", children: "\u2713" }) : null] }), captionLines > 0 ? _jsxs("span", { className: "hjm-image-choice__caption", children: [showItemLabels ? _jsx(Text, { variant: imageChoiceRecipe.itemLabelVariant, className: "hjm-image-choice__item-label", "aria-hidden": "true", "data-lines": itemLabelLines === 1 ? undefined : itemLabelLines, children: item.label }) : null, item.description === undefined ? null : _jsx(Text, { id: descriptionId, variant: imageChoiceRecipe.itemDescriptionVariant, tone: imageChoiceRecipe.itemDescriptionTone, className: "hjm-image-choice__item-description", "aria-hidden": "true", children: item.description })] }) : null] }, item.id);
|
|
33
|
+
};
|
|
34
|
+
// First-paint estimate in px; the rendered row is measured afterwards because caption line height is rem-based.
|
|
35
|
+
const estimatedTileHeight = resolveImageChoiceTileHeight(captionLines, typography[imageChoiceRecipe.itemLabelVariant].lineHeight * (theme?.environment.textScale ?? 1));
|
|
36
|
+
return _jsxs("div", { className: ["hjm-image-choice", className].filter(Boolean).join(" "), style: style, children: [showLabel ? _jsx("span", { className: "hjm-image-choice__label", children: label }) : null, virtualized
|
|
37
|
+
? _jsx(VirtualTileRows, { items: items, renderTile: renderTile, label: label, role: groupRole, height: virtualized.height, overscan: virtualized.overscan ?? virtualListRecipe.overscan, estimatedTileHeight: estimatedTileHeight })
|
|
38
|
+
: _jsx("div", { className: "hjm-image-choice__tiles", role: groupRole, "aria-label": label, children: items.map(renderTile) })] });
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Windowed rows of tiles. It reuses the VirtualList window math (`resolveVirtualWindow`) but not the VirtualList
|
|
42
|
+
* component: that one names its rows as list items and moves focus row by row, which would replace the radio/checkbox
|
|
43
|
+
* group this control is. Tiles stay in the tab order; focusing one scrolls it into view and the window follows.
|
|
44
|
+
*/
|
|
45
|
+
function VirtualTileRows({ items, renderTile, label, role, height, overscan, estimatedTileHeight }) {
|
|
46
|
+
const host = useRef(null);
|
|
47
|
+
const [width, setWidth] = useState(0);
|
|
48
|
+
const [measuredTileHeight, setMeasuredTileHeight] = useState(0);
|
|
49
|
+
const [scrollTop, setScrollTop] = useState(0);
|
|
50
|
+
const [focusedRow, setFocusedRow] = useState(null);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (!host.current)
|
|
53
|
+
return;
|
|
54
|
+
// Measure the slot itself (content box: inside the inset and the scrollbar); sheets and sidebars change it.
|
|
55
|
+
const observer = new ResizeObserver(([entry]) => setWidth(entry?.contentRect.width ?? 0));
|
|
56
|
+
observer.observe(host.current);
|
|
57
|
+
return () => observer.disconnect();
|
|
58
|
+
}, []);
|
|
59
|
+
useLayoutEffect(() => {
|
|
60
|
+
// Every row is one tile high (the caption block is reserved), so any mounted row gives the real stride.
|
|
61
|
+
const rendered = host.current?.querySelector(".hjm-image-choice__row")?.offsetHeight ?? 0;
|
|
62
|
+
if (rendered > 0 && rendered !== measuredTileHeight)
|
|
63
|
+
setMeasuredTileHeight(rendered);
|
|
64
|
+
});
|
|
65
|
+
const columns = width > 0 ? resolveImageChoiceColumns(width) : 0;
|
|
66
|
+
const stride = (measuredTileHeight || estimatedTileHeight) + imageChoiceRecipe.gap;
|
|
67
|
+
const rowCount = columns ? Math.ceil(items.length / columns) : 0;
|
|
68
|
+
const range = resolveVirtualWindow(rowCount, stride, height, scrollTop, overscan);
|
|
69
|
+
// Keep the focused tile's row mounted when scrolling moves it out of the window, so focus is not dropped to body.
|
|
70
|
+
const rows = Array.from({ length: range.end - range.start }, (_, i) => range.start + i);
|
|
71
|
+
if (focusedRow !== null && focusedRow < rowCount && !rows.includes(focusedRow))
|
|
72
|
+
rows.push(focusedRow);
|
|
73
|
+
rows.sort((first, second) => first - second); // DOM order is the tab order
|
|
74
|
+
return _jsx("div", { ref: host, className: "hjm-image-choice__viewport", role: role, "aria-label": label, style: { height }, onScroll: event => setScrollTop(event.currentTarget.scrollTop), children: columns ? _jsx("div", { style: { position: "relative", height: Math.max(0, range.totalHeight - imageChoiceRecipe.gap) }, children: rows.map(row => _jsx("div", { className: "hjm-image-choice__row", style: { top: row * stride }, onFocusCapture: () => setFocusedRow(row), onBlurCapture: event => { if (!event.currentTarget.contains(event.relatedTarget))
|
|
75
|
+
setFocusedRow(current => current === row ? null : current); }, children: items.slice(row * columns, row * columns + columns).map((item, offset) => renderTile(item, row * columns + offset)) }, row)) }) : null });
|
|
24
76
|
}
|
|
25
77
|
//# sourceMappingURL=image-choice.js.map
|
package/dist/image-choice.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image-choice.js","sourceRoot":"","sources":["../src/image-choice.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,wBAAwB,EAAkC,MAAM,iDAAiD,CAAC;AAsBxK;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,KAAK,EAAE,cAAc,GAAG,KAAK,EAAE,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IACvG,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,EA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CAAC,CAAC,IAAI,EAC5E,cAAK,SAAS,EAAC,yBAAyB,EAAC,IAAI,EAAE,KAAK,CAAC,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,gBAAc,KAAK,YACxH,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;oBAChB,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBACrC,OAAO,kBAAsB,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,kBAAgB,QAAQ,gBAAc,IAAI,CAAC,KAAK,EAAE,SAAS,EAAC,wBAAwB,mBAAgB,QAAQ,IAAI,SAAS,EAC5K,QAAQ,EAAE,QAAQ,IAAI,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,aAEnE,gBAAM,SAAS,EAAC,wBAAwB,aACtC,eAAM,SAAS,EAAC,yBAAyB,YAAE,IAAI,CAAC,KAAK,GAAQ,EAC5D,QAAQ,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,yBAAyB,iBAAa,MAAM,uBAAS,CAAC,CAAC,CAAC,IAAI,IACnF,EAEN,cAAc,CAAC,CAAC,CAAC,KAAC,IAAI,IAAC,OAAO,EAAE,iBAAiB,CAAC,gBAAgB,EAAE,SAAS,EAAC,8BAA8B,iBAAa,MAAM,YAAE,IAAI,CAAC,KAAK,GAAQ,CAAC,CAAC,CAAC,IAAI,KARzI,IAAI,CAAC,EAAE,CASlB,CAAC;gBACZ,CAAC,CAAC,GACE,IACF,CAAC;AACT,CAAC","sourcesContent":["import type { CSSProperties, ReactNode } from \"react\";\nimport { Text } from \"./layout.js\";\nimport { imageChoiceRecipe, resolveImageChoiceToggle, validateImageChoiceItems, type ImageChoiceItemDescriptor } from \"@hjmds/design-contracts/components/image-choice\";\n\nexport type ImageChoiceItem = ImageChoiceItemDescriptor & Readonly<{ image: ReactNode }>;\ntype Base = Readonly<{\n /** Localized group name read before the choices. */\n label: string;\n /** Visible caption above the tiles; omit when the screen heading already names the choice. */\n showLabel?: boolean;\n /**\n * Shows each item's `label` under its tile (one ellipsized line), e.g. a person's name in a recipient picker.\n * The tile keeps the same accessible name, so turning this on does not change what assistive tech reads.\n */\n showItemLabels?: boolean;\n items: readonly ImageChoiceItem[];\n disabled?: boolean;\n className?: string;\n}>;\nexport type ImageChoiceGroupProps = Base & (\n | Readonly<{ selectionMode: \"single\"; value: string | null; onValueChange(value: string): void }>\n | Readonly<{ selectionMode: \"multiple\"; value: readonly string[]; onValueChange(value: string[]): void }>\n);\n\n/**\n * Picks avatars or photos by image (2026-10-16). Tiles are square, wrap to the available width, and show\n * a brand ring plus a check when chosen; assistive tech hears radios (single) or checkboxes (multiple).\n */\nexport function ImageChoiceGroup(props: ImageChoiceGroupProps) {\n const { label, showLabel = false, showItemLabels = false, items, disabled = false, className } = props;\n validateImageChoiceItems(items);\n const isSelected = (id: string) => props.selectionMode === \"single\" ? props.value === id : props.value.includes(id);\n const choose = (id: string) => {\n if (props.selectionMode === \"single\") props.onValueChange(resolveImageChoiceToggle(\"single\", props.value, id));\n else props.onValueChange(resolveImageChoiceToggle(\"multiple\", props.value, id));\n };\n const role = props.selectionMode === \"single\" ? \"radio\" : \"checkbox\";\n const style = { \"--hjm-image-choice-size\": `${imageChoiceRecipe.tileSize}px`, \"--hjm-image-choice-gap\": `${imageChoiceRecipe.gap}px`, \"--hjm-image-choice-radius\": `${imageChoiceRecipe.radius}px`, \"--hjm-image-choice-ring\": `${imageChoiceRecipe.ringWidth}px`, \"--hjm-image-choice-offset\": `${imageChoiceRecipe.ringOffset}px`, \"--hjm-image-choice-check\": `${imageChoiceRecipe.checkSize}px`, \"--hjm-image-choice-item-label-gap\": `${imageChoiceRecipe.itemLabelGap}px` } as CSSProperties;\n return <div className={[\"hjm-image-choice\", className].filter(Boolean).join(\" \")} style={style}>\n {showLabel ? <span className=\"hjm-image-choice__label\">{label}</span> : null}\n <div className=\"hjm-image-choice__tiles\" role={props.selectionMode === \"single\" ? \"radiogroup\" : \"group\"} aria-label={label}>\n {items.map(item => {\n const selected = isSelected(item.id);\n return <button key={item.id} type=\"button\" role={role} aria-checked={selected} aria-label={item.label} className=\"hjm-image-choice__tile\" data-selected={selected || undefined}\n disabled={disabled || item.disabled} onClick={() => choose(item.id)}>\n {/* The ring lives on an inner frame so an item label can sit below it inside the same button (one tap target). */}\n <span className=\"hjm-image-choice__ring\">\n <span className=\"hjm-image-choice__image\">{item.image}</span>\n {selected ? <span className=\"hjm-image-choice__check\" aria-hidden=\"true\">✓</span> : null}\n </span>\n {/* aria-label already names the tile; the visible copy must not be read twice. */}\n {showItemLabels ? <Text variant={imageChoiceRecipe.itemLabelVariant} className=\"hjm-image-choice__item-label\" aria-hidden=\"true\">{item.label}</Text> : null}\n </button>;\n })}\n </div>\n </div>;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"image-choice.js","sourceRoot":"","sources":["../src/image-choice.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAC;AAChH,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EACL,iBAAiB,EAAE,8BAA8B,EAAE,yBAAyB,EAAE,4BAA4B,EAAE,wBAAwB,EACpI,iCAAiC,EAAE,wBAAwB,GAC5D,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAmC1G;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAA4B;IAC3D,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,KAAK,EAAE,cAAc,GAAG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ReactNode } from \"react\";\nimport { Text } from \"./layout.js\";\nimport { useOptionalHjmTheme } from \"./provider.js\";\nimport { typography } from \"@hjmds/design-contracts/foundations\";\nimport {\n imageChoiceRecipe, resolveImageChoiceCaptionLines, resolveImageChoiceColumns, resolveImageChoiceTileHeight, resolveImageChoiceToggle,\n validateImageChoiceItemLabelLines, validateImageChoiceItems, type ImageChoiceItemDescriptor, type ImageChoiceItemLabelLines,\n} from \"@hjmds/design-contracts/components/image-choice\";\nimport { resolveVirtualWindow, virtualListRecipe } from \"@hjmds/design-contracts/components/virtual-list\";\n\nexport type ImageChoiceItem = ImageChoiceItemDescriptor & Readonly<{ image: ReactNode }>;\nexport type ImageChoiceVirtualization = Readonly<{\n /** Height of the scrolling viewport in px. The group scrolls itself, so do not also put it in a scrolling parent. */\n height: number;\n /** Rows kept mounted above and below the visible window. */\n overscan?: number;\n}>;\ntype Base = Readonly<{\n /** Localized group name read before the choices. */\n label: string;\n /** Visible caption above the tiles; omit when the screen heading already names the choice. */\n showLabel?: boolean;\n /**\n * Shows each item's `label` under its tile (one ellipsized line), e.g. a person's name in a recipient picker.\n * The tile keeps the same accessible name, so turning this on does not change what assistive tech reads.\n */\n showItemLabels?: boolean;\n /** Lines the visible item label wraps to before the ellipsis (default 1). Every tile reserves the same height. */\n itemLabelLines?: ImageChoiceItemLabelLines;\n items: readonly ImageChoiceItem[];\n disabled?: boolean;\n className?: string;\n /**\n * Long lists (hundreds of people): only the rows near the viewport are mounted. Tiles keep their size; the column\n * count follows the measured width.\n */\n virtualized?: ImageChoiceVirtualization;\n}>;\nexport type ImageChoiceGroupProps = Base & (\n | Readonly<{ selectionMode: \"single\"; value: string | null; onValueChange(value: string): void }>\n | Readonly<{ selectionMode: \"multiple\"; value: readonly string[]; onValueChange(value: string[]): void }>\n);\n\n/**\n * Picks avatars or photos by image (2026-10-16). Tiles are square, wrap to the available width, and show\n * a brand ring plus a check when chosen; assistive tech hears radios (single) or checkboxes (multiple).\n */\nexport function ImageChoiceGroup(props: ImageChoiceGroupProps) {\n const { label, showLabel = false, showItemLabels = false, itemLabelLines = imageChoiceRecipe.itemLabelLines, items, disabled = false, className, virtualized } = props;\n validateImageChoiceItems(items);\n validateImageChoiceItemLabelLines(itemLabelLines);\n const theme = useOptionalHjmTheme();\n const baseId = useId();\n const isSelected = (id: string) => props.selectionMode === \"single\" ? props.value === id : props.value.includes(id);\n const choose = (id: string) => {\n if (props.selectionMode === \"single\") props.onValueChange(resolveImageChoiceToggle(\"single\", props.value, id));\n else props.onValueChange(resolveImageChoiceToggle(\"multiple\", props.value, id));\n };\n const role = props.selectionMode === \"single\" ? \"radio\" : \"checkbox\";\n const groupRole = props.selectionMode === \"single\" ? \"radiogroup\" : \"group\";\n const captionLines = resolveImageChoiceCaptionLines({ showItemLabels, itemLabelLines, hasDescription: items.some(item => item.description !== undefined) });\n const style = { \"--hjm-image-choice-size\": `${imageChoiceRecipe.tileSize}px`, \"--hjm-image-choice-gap\": `${imageChoiceRecipe.gap}px`, \"--hjm-image-choice-radius\": `${imageChoiceRecipe.radius}px`, \"--hjm-image-choice-ring\": `${imageChoiceRecipe.ringWidth}px`, \"--hjm-image-choice-offset\": `${imageChoiceRecipe.ringOffset}px`, \"--hjm-image-choice-check\": `${imageChoiceRecipe.checkSize}px`, \"--hjm-image-choice-item-label-gap\": `${imageChoiceRecipe.itemLabelGap}px`, \"--hjm-image-choice-caption-lines\": captionLines, \"--hjm-image-choice-viewport-inset\": `${imageChoiceRecipe.virtualViewportInset}px` } as CSSProperties;\n const renderTile = (item: ImageChoiceItem, index: number) => {\n const selected = isSelected(item.id);\n const descriptionId = item.description === undefined ? undefined : `${baseId}-description-${index}`;\n return <button key={item.id} type=\"button\" role={role} aria-checked={selected} aria-label={item.label} aria-describedby={descriptionId} className=\"hjm-image-choice__tile\" data-selected={selected || undefined}\n disabled={disabled || item.disabled} onClick={() => choose(item.id)}>\n {/* The ring lives on an inner frame so an item label can sit below it inside the same button (one tap target). */}\n <span className=\"hjm-image-choice__ring\">\n <span className=\"hjm-image-choice__image\">{item.image}</span>\n {selected ? <span className=\"hjm-image-choice__check\" aria-hidden=\"true\">✓</span> : null}\n </span>\n {/* Every tile reserves the same caption block, so wrapped rows stay even and virtual rows share one height.\n aria-label already names the tile; the description is read once through aria-describedby. */}\n {captionLines > 0 ? <span className=\"hjm-image-choice__caption\">\n {showItemLabels ? <Text variant={imageChoiceRecipe.itemLabelVariant} className=\"hjm-image-choice__item-label\" aria-hidden=\"true\" data-lines={itemLabelLines === 1 ? undefined : itemLabelLines}>{item.label}</Text> : null}\n {item.description === undefined ? null : <Text id={descriptionId} variant={imageChoiceRecipe.itemDescriptionVariant} tone={imageChoiceRecipe.itemDescriptionTone} className=\"hjm-image-choice__item-description\" aria-hidden=\"true\">{item.description}</Text>}\n </span> : null}\n </button>;\n };\n // First-paint estimate in px; the rendered row is measured afterwards because caption line height is rem-based.\n const estimatedTileHeight = resolveImageChoiceTileHeight(captionLines, typography[imageChoiceRecipe.itemLabelVariant].lineHeight * (theme?.environment.textScale ?? 1));\n return <div className={[\"hjm-image-choice\", className].filter(Boolean).join(\" \")} style={style}>\n {showLabel ? <span className=\"hjm-image-choice__label\">{label}</span> : null}\n {virtualized\n ? <VirtualTileRows items={items} renderTile={renderTile} label={label} role={groupRole} height={virtualized.height} overscan={virtualized.overscan ?? virtualListRecipe.overscan} estimatedTileHeight={estimatedTileHeight} />\n : <div className=\"hjm-image-choice__tiles\" role={groupRole} aria-label={label}>{items.map(renderTile)}</div>}\n </div>;\n}\n\n/**\n * Windowed rows of tiles. It reuses the VirtualList window math (`resolveVirtualWindow`) but not the VirtualList\n * component: that one names its rows as list items and moves focus row by row, which would replace the radio/checkbox\n * group this control is. Tiles stay in the tab order; focusing one scrolls it into view and the window follows.\n */\nfunction VirtualTileRows({ items, renderTile, label, role, height, overscan, estimatedTileHeight }: Readonly<{\n items: readonly ImageChoiceItem[]; renderTile: (item: ImageChoiceItem, index: number) => ReactNode; label: string;\n role: \"radiogroup\" | \"group\"; height: number; overscan: number; estimatedTileHeight: number;\n}>) {\n const host = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(0);\n const [measuredTileHeight, setMeasuredTileHeight] = useState(0);\n const [scrollTop, setScrollTop] = useState(0);\n const [focusedRow, setFocusedRow] = useState<number | null>(null);\n useEffect(() => {\n if (!host.current) return;\n // Measure the slot itself (content box: inside the inset and the scrollbar); sheets and sidebars change it.\n const observer = new ResizeObserver(([entry]) => setWidth(entry?.contentRect.width ?? 0));\n observer.observe(host.current);\n return () => observer.disconnect();\n }, []);\n useLayoutEffect(() => {\n // Every row is one tile high (the caption block is reserved), so any mounted row gives the real stride.\n const rendered = host.current?.querySelector<HTMLElement>(\".hjm-image-choice__row\")?.offsetHeight ?? 0;\n if (rendered > 0 && rendered !== measuredTileHeight) setMeasuredTileHeight(rendered);\n });\n const columns = width > 0 ? resolveImageChoiceColumns(width) : 0;\n const stride = (measuredTileHeight || estimatedTileHeight) + imageChoiceRecipe.gap;\n const rowCount = columns ? Math.ceil(items.length / columns) : 0;\n const range = resolveVirtualWindow(rowCount, stride, height, scrollTop, overscan);\n // Keep the focused tile's row mounted when scrolling moves it out of the window, so focus is not dropped to body.\n const rows = Array.from({ length: range.end - range.start }, (_, i) => range.start + i);\n if (focusedRow !== null && focusedRow < rowCount && !rows.includes(focusedRow)) rows.push(focusedRow);\n rows.sort((first, second) => first - second); // DOM order is the tab order\n return <div ref={host} className=\"hjm-image-choice__viewport\" role={role} aria-label={label} style={{ height }}\n onScroll={event => setScrollTop(event.currentTarget.scrollTop)}>\n {columns ? <div style={{ position: \"relative\", height: Math.max(0, range.totalHeight - imageChoiceRecipe.gap) }}>\n {rows.map(row => <div key={row} className=\"hjm-image-choice__row\" style={{ top: row * stride }}\n onFocusCapture={() => setFocusedRow(row)} onBlurCapture={event => { if (!event.currentTarget.contains(event.relatedTarget)) setFocusedRow(current => current === row ? null : current); }}>\n {items.slice(row * columns, row * columns + columns).map((item, offset) => renderTile(item, row * columns + offset))}\n </div>)}\n </div> : null}\n </div>;\n}\n"]}
|