@hjmds/react 0.8.2
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/README.md +146 -0
- package/dist/actions.d.ts +61 -0
- package/dist/actions.d.ts.map +1 -0
- package/dist/actions.js +54 -0
- package/dist/actions.js.map +1 -0
- package/dist/advanced-display.d.ts +133 -0
- package/dist/advanced-display.d.ts.map +1 -0
- package/dist/advanced-display.js +201 -0
- package/dist/advanced-display.js.map +1 -0
- package/dist/advanced-forms.d.ts +116 -0
- package/dist/advanced-forms.d.ts.map +1 -0
- package/dist/advanced-forms.js +234 -0
- package/dist/advanced-forms.js.map +1 -0
- package/dist/advanced-navigation.d.ts +24 -0
- package/dist/advanced-navigation.d.ts.map +1 -0
- package/dist/advanced-navigation.js +25 -0
- package/dist/advanced-navigation.js.map +1 -0
- package/dist/bottom-navigation.d.ts +37 -0
- package/dist/bottom-navigation.d.ts.map +1 -0
- package/dist/bottom-navigation.js +132 -0
- package/dist/bottom-navigation.js.map +1 -0
- package/dist/date-picker.d.ts +24 -0
- package/dist/date-picker.d.ts.map +1 -0
- package/dist/date-picker.js +81 -0
- package/dist/date-picker.js.map +1 -0
- package/dist/display-public.d.ts +5 -0
- package/dist/display-public.d.ts.map +1 -0
- package/dist/display-public.js +5 -0
- package/dist/display-public.js.map +1 -0
- package/dist/display.d.ts +77 -0
- package/dist/display.d.ts.map +1 -0
- package/dist/display.js +51 -0
- package/dist/display.js.map +1 -0
- package/dist/evidence.d.ts +940 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +98 -0
- package/dist/evidence.js.map +1 -0
- package/dist/feedback.d.ts +89 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/feedback.js +41 -0
- package/dist/feedback.js.map +1 -0
- package/dist/file-picker.d.ts +30 -0
- package/dist/file-picker.d.ts.map +1 -0
- package/dist/file-picker.js +40 -0
- package/dist/file-picker.js.map +1 -0
- package/dist/forms-public.d.ts +8 -0
- package/dist/forms-public.d.ts.map +1 -0
- package/dist/forms-public.js +8 -0
- package/dist/forms-public.js.map +1 -0
- package/dist/forms.d.ts +160 -0
- package/dist/forms.d.ts.map +1 -0
- package/dist/forms.js +178 -0
- package/dist/forms.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +17 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +68 -0
- package/dist/internal.js.map +1 -0
- package/dist/layout.d.ts +134 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +167 -0
- package/dist/layout.js.map +1 -0
- package/dist/navigation-public.d.ts +6 -0
- package/dist/navigation-public.d.ts.map +1 -0
- package/dist/navigation-public.js +6 -0
- package/dist/navigation-public.js.map +1 -0
- package/dist/navigation.d.ts +65 -0
- package/dist/navigation.d.ts.map +1 -0
- package/dist/navigation.js +196 -0
- package/dist/navigation.js.map +1 -0
- package/dist/number-field.d.ts +55 -0
- package/dist/number-field.d.ts.map +1 -0
- package/dist/number-field.js +107 -0
- package/dist/number-field.js.map +1 -0
- package/dist/otp-field.d.ts +2 -0
- package/dist/otp-field.d.ts.map +1 -0
- package/dist/otp-field.js +2 -0
- package/dist/otp-field.js.map +1 -0
- package/dist/overlays.d.ts +192 -0
- package/dist/overlays.d.ts.map +1 -0
- package/dist/overlays.js +949 -0
- package/dist/overlays.js.map +1 -0
- package/dist/password-field.d.ts +2 -0
- package/dist/password-field.d.ts.map +1 -0
- package/dist/password-field.js +2 -0
- package/dist/password-field.js.map +1 -0
- package/dist/portal.d.ts +32 -0
- package/dist/portal.d.ts.map +1 -0
- package/dist/portal.js +264 -0
- package/dist/portal.js.map +1 -0
- package/dist/provider.d.ts +38 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +87 -0
- package/dist/provider.js.map +1 -0
- package/dist/select.d.ts +72 -0
- package/dist/select.d.ts.map +1 -0
- package/dist/select.js +353 -0
- package/dist/select.js.map +1 -0
- package/dist/selection.d.ts +160 -0
- package/dist/selection.d.ts.map +1 -0
- package/dist/selection.js +225 -0
- package/dist/selection.js.map +1 -0
- package/dist/slider.d.ts +35 -0
- package/dist/slider.d.ts.map +1 -0
- package/dist/slider.js +150 -0
- package/dist/slider.js.map +1 -0
- package/dist/steps.d.ts +29 -0
- package/dist/steps.d.ts.map +1 -0
- package/dist/steps.js +10 -0
- package/dist/steps.js.map +1 -0
- package/dist/styles.css +1349 -0
- package/dist/supplemental-display.d.ts +59 -0
- package/dist/supplemental-display.d.ts.map +1 -0
- package/dist/supplemental-display.js +136 -0
- package/dist/supplemental-display.js.map +1 -0
- package/dist/supplemental-navigation.d.ts +28 -0
- package/dist/supplemental-navigation.d.ts.map +1 -0
- package/dist/supplemental-navigation.js +106 -0
- package/dist/supplemental-navigation.js.map +1 -0
- package/dist/theme.d.ts +5 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +55 -0
- package/dist/theme.js.map +1 -0
- package/dist/toast.d.ts +41 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +250 -0
- package/dist/toast.js.map +1 -0
- package/dist/upload-item.d.ts +18 -0
- package/dist/upload-item.d.ts.map +1 -0
- package/dist/upload-item.js +19 -0
- package/dist/upload-item.js.map +1 -0
- package/package.json +151 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,QAAQ,EACR,oBAAoB,GAIrB,MAAM,OAAO,CAAC;AAEf,MAAM,UAAU,UAAU,CACxB,GAAG,MAAsD;IAEzD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChD,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,C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CAAC,MAAM,CAAC,CAAC;QAC5C,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvB,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACrC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CAAC,KAAK,EAAE,GAAG,CAAU,CAAC;AAC/B,CAAC","sourcesContent":["import {\n useCallback,\n useEffect,\n useState,\n useSyncExternalStore,\n type Dispatch,\n type Ref,\n type SetStateAction,\n} from \"react\";\n\nexport function classNames(\n ...values: readonly (string | false | null | undefined)[]\n): string | undefined {\n const result = values.filter(Boolean).join(\" \");\n return result.length > 0 ? result : undefined;\n}\n\nexport function assignRef<Element>(ref: Ref<Element> | undefined, value: Element | null): void {\n if (typeof ref === \"function\") ref(value);\n else if (ref) ref.current = value;\n}\n\nexport function composeRefs<Element>(\n ...refs: readonly (Ref<Element> | undefined)[]\n): (value: Element | null) => void {\n return (value) => {\n for (const ref of refs) assignRef(ref, value);\n };\n}\n\ntype ControllableStateOptions<Value> = Readonly<{\n value?: Value;\n defaultValue: Value;\n onChange?: (value: Value) => void;\n}>;\n\nexport function useControllableState<Value>({\n value,\n defaultValue,\n onChange,\n}: ControllableStateOptions<Value>): readonly [\n Value,\n Dispatch<SetStateAction<Value>>,\n] {\n const [internalValue, setInternalValue] = useState(defaultValue);\n const controlled = value !== undefined;\n const currentValue = controlled ? value : internalValue;\n\n const setValue: Dispatch<SetStateAction<Value>> = useCallback(\n (next) => {\n const resolved = typeof next === \"function\"\n ? (next as (previous: Value) => Value)(currentValue)\n : next;\n if (!controlled) setInternalValue(resolved);\n if (!Object.is(resolved, currentValue)) onChange?.(resolved);\n },\n [controlled, currentValue, onChange],\n );\n\n return [currentValue, setValue] as const;\n}\n\nfunction subscribeWindowResize(callback: () => void): () => void {\n window.addEventListener(\"resize\", callback);\n return () => window.removeEventListener(\"resize\", callback);\n}\n\nfunction getWindowWidth(): number {\n return window.innerWidth;\n}\n\nfunction getServerWindowWidth(): number {\n return 0;\n}\n\nexport function useWindowWidth(): number {\n return useSyncExternalStore(\n subscribeWindowResize,\n getWindowWidth,\n getServerWindowWidth,\n );\n}\n\nexport function useElementWidth<Element extends HTMLElement>(\n externalRef?: Ref<Element>,\n): readonly [number | undefined, (node: Element | null) => void] {\n const [node, setNode] = useState<Element | null>(null);\n const [width, setWidth] = useState<number>();\n const ref = useCallback(\n (nextNode: Element | null) => {\n setNode(nextNode);\n assignRef(externalRef, nextNode);\n },\n [externalRef],\n );\n\n useEffect(() => {\n if (!node) return;\n const update = () => setWidth(node.getBoundingClientRect().width);\n update();\n if (typeof ResizeObserver === \"undefined\") {\n window.addEventListener(\"resize\", update);\n return () => window.removeEventListener(\"resize\", update);\n }\n const observer = new ResizeObserver(update);\n observer.observe(node);\n return () => observer.disconnect();\n }, [node]);\n\n return [width, ref] as const;\n}\n"]}
|
package/dist/layout.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type GridDescriptor, type GridGap } from "@hjmds/design-contracts/grid";
|
|
2
|
+
import { type LayoutSidebarRole } from "@hjmds/design-contracts/components/layout";
|
|
3
|
+
import { type SurfacePadding, type SurfaceRadius, type SurfaceTone } from "@hjmds/design-contracts/recipes/base";
|
|
4
|
+
import { type StackAlign, type StackAxis, type StackGap, type StackJustify, type TextEmphasis, type TextTone } from "@hjmds/design-contracts/recipes";
|
|
5
|
+
import type { TextVariant } from "@hjmds/design-contracts/foundations";
|
|
6
|
+
import { type AnchorHTMLAttributes, type HTMLAttributes, type ReactElement, type ReactNode, type Ref } from "react";
|
|
7
|
+
export type { SurfacePadding, SurfaceRadius, SurfaceTone, } from "@hjmds/design-contracts/recipes/base";
|
|
8
|
+
export type { StackAlign, StackAxis, StackGap, StackJustify, TextEmphasis, TextTone, } from "@hjmds/design-contracts/recipes";
|
|
9
|
+
type LayoutRegionProps = Omit<HTMLAttributes<HTMLElement>, "children" | "role">;
|
|
10
|
+
type LayoutSidebarBase = Readonly<{
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
role: LayoutSidebarRole;
|
|
13
|
+
label: string;
|
|
14
|
+
landmarkProps?: Omit<LayoutRegionProps, "aria-label">;
|
|
15
|
+
landmarkRef?: Ref<HTMLElement>;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* A persistent sidebar is rendered in the shell grid. An overlay sidebar is
|
|
19
|
+
* deliberately handed to the product's SidePanel (or equivalent) through
|
|
20
|
+
* `renderOverlay`; Layout never owns a second open/dismiss lifecycle.
|
|
21
|
+
*/
|
|
22
|
+
export type LayoutSidebar = (LayoutSidebarBase & Readonly<{
|
|
23
|
+
mode: "persistent";
|
|
24
|
+
renderOverlay?: never;
|
|
25
|
+
}>) | (LayoutSidebarBase & Readonly<{
|
|
26
|
+
mode: "overlay";
|
|
27
|
+
renderOverlay(sidebarLandmark: ReactElement): ReactNode;
|
|
28
|
+
}>);
|
|
29
|
+
export type LayoutProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & Readonly<{
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
header?: ReactNode;
|
|
32
|
+
footer?: ReactNode;
|
|
33
|
+
sidebar?: LayoutSidebar;
|
|
34
|
+
skipLinkLabel?: string;
|
|
35
|
+
/** Stable product id for deep links; a hydration-safe id is generated when omitted. */
|
|
36
|
+
mainId?: string;
|
|
37
|
+
mainRef?: Ref<HTMLElement>;
|
|
38
|
+
headerProps?: LayoutRegionProps;
|
|
39
|
+
mainProps?: Omit<LayoutRegionProps, "id" | "tabIndex">;
|
|
40
|
+
footerProps?: LayoutRegionProps;
|
|
41
|
+
skipLinkProps?: Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "children" | "href">;
|
|
42
|
+
}>;
|
|
43
|
+
/** Accessible Web app shell with real landmarks and bypass navigation. */
|
|
44
|
+
export declare const Layout: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "children"> & Readonly<{
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
header?: ReactNode;
|
|
47
|
+
footer?: ReactNode;
|
|
48
|
+
sidebar?: LayoutSidebar;
|
|
49
|
+
skipLinkLabel?: string;
|
|
50
|
+
/** Stable product id for deep links; a hydration-safe id is generated when omitted. */
|
|
51
|
+
mainId?: string;
|
|
52
|
+
mainRef?: Ref<HTMLElement>;
|
|
53
|
+
headerProps?: LayoutRegionProps;
|
|
54
|
+
mainProps?: Omit<LayoutRegionProps, "id" | "tabIndex">;
|
|
55
|
+
footerProps?: LayoutRegionProps;
|
|
56
|
+
skipLinkProps?: Omit<AnchorHTMLAttributes<HTMLAnchorElement>, "children" | "href">;
|
|
57
|
+
}> & import("react").RefAttributes<HTMLDivElement>>;
|
|
58
|
+
export type TextProps = Omit<HTMLAttributes<HTMLElement>, "children"> & Readonly<{
|
|
59
|
+
children: ReactNode;
|
|
60
|
+
as?: "span" | "p" | "div" | "strong" | "small";
|
|
61
|
+
variant?: TextVariant;
|
|
62
|
+
tone?: TextTone;
|
|
63
|
+
emphasis?: TextEmphasis;
|
|
64
|
+
}>;
|
|
65
|
+
export declare const Text: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLElement>, "children"> & Readonly<{
|
|
66
|
+
children: ReactNode;
|
|
67
|
+
as?: "span" | "p" | "div" | "strong" | "small";
|
|
68
|
+
variant?: TextVariant;
|
|
69
|
+
tone?: TextTone;
|
|
70
|
+
emphasis?: TextEmphasis;
|
|
71
|
+
}> & import("react").RefAttributes<HTMLElement>>;
|
|
72
|
+
export type SurfaceProps = HTMLAttributes<HTMLElement> & Readonly<{
|
|
73
|
+
as?: "div" | "section" | "article";
|
|
74
|
+
tone?: SurfaceTone;
|
|
75
|
+
bordered?: boolean;
|
|
76
|
+
padding?: SurfacePadding;
|
|
77
|
+
radius?: SurfaceRadius;
|
|
78
|
+
}>;
|
|
79
|
+
export declare const Surface: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLElement> & Readonly<{
|
|
80
|
+
as?: "div" | "section" | "article";
|
|
81
|
+
tone?: SurfaceTone;
|
|
82
|
+
bordered?: boolean;
|
|
83
|
+
padding?: SurfacePadding;
|
|
84
|
+
radius?: SurfaceRadius;
|
|
85
|
+
}> & import("react").RefAttributes<HTMLElement>>;
|
|
86
|
+
export type StackProps = HTMLAttributes<HTMLDivElement> & Readonly<{
|
|
87
|
+
axis?: StackAxis;
|
|
88
|
+
gap?: StackGap;
|
|
89
|
+
align?: StackAlign;
|
|
90
|
+
justify?: StackJustify;
|
|
91
|
+
wrap?: boolean;
|
|
92
|
+
}>;
|
|
93
|
+
export declare const Stack: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & Readonly<{
|
|
94
|
+
axis?: StackAxis;
|
|
95
|
+
gap?: StackGap;
|
|
96
|
+
align?: StackAlign;
|
|
97
|
+
justify?: StackJustify;
|
|
98
|
+
wrap?: boolean;
|
|
99
|
+
}> & import("react").RefAttributes<HTMLDivElement>>;
|
|
100
|
+
export type GridProps = Omit<HTMLAttributes<HTMLDivElement>, "children"> & Pick<GridDescriptor, "columns" | "gap" | "minColumnWidth"> & Readonly<{
|
|
101
|
+
children?: ReactNode;
|
|
102
|
+
/** Test/SSR override. Browser renderers otherwise observe window.innerWidth. */
|
|
103
|
+
windowWidth?: number;
|
|
104
|
+
/** Container measurement override; ResizeObserver is used when omitted. */
|
|
105
|
+
availableWidth?: number;
|
|
106
|
+
}>;
|
|
107
|
+
export declare const Grid: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "children"> & Pick<Readonly<{
|
|
108
|
+
columns: import("@hjmds/design-contracts/responsive").ResponsiveValue<number>;
|
|
109
|
+
gap?: import("@hjmds/design-contracts/responsive").ResponsiveValue<GridGap>;
|
|
110
|
+
minColumnWidth?: import("@hjmds/design-contracts/responsive").ResponsiveValue<number>;
|
|
111
|
+
}>, "gap" | "columns" | "minColumnWidth"> & Readonly<{
|
|
112
|
+
children?: ReactNode;
|
|
113
|
+
/** Test/SSR override. Browser renderers otherwise observe window.innerWidth. */
|
|
114
|
+
windowWidth?: number;
|
|
115
|
+
/** Container measurement override; ResizeObserver is used when omitted. */
|
|
116
|
+
availableWidth?: number;
|
|
117
|
+
}> & import("react").RefAttributes<HTMLDivElement>>;
|
|
118
|
+
export type SectionProps = Omit<HTMLAttributes<HTMLElement>, "children" | "title"> & Readonly<{
|
|
119
|
+
title?: ReactNode;
|
|
120
|
+
description?: ReactNode;
|
|
121
|
+
action?: ReactNode;
|
|
122
|
+
children: ReactNode;
|
|
123
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
124
|
+
}>;
|
|
125
|
+
/** Large-text-safe semantic content section with an optional header action. */
|
|
126
|
+
export declare const Section: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLElement>, "children" | "title"> & Readonly<{
|
|
127
|
+
title?: ReactNode;
|
|
128
|
+
description?: ReactNode;
|
|
129
|
+
action?: ReactNode;
|
|
130
|
+
children: ReactNode;
|
|
131
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6;
|
|
132
|
+
}> & import("react").RefAttributes<HTMLElement>>;
|
|
133
|
+
export type { GridGap };
|
|
134
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,OAAO,EACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,QAAQ,EACd,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK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AM;IACpB,2EAA2E;qBAC1D,MAAM;mDAuDzB,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,GAChF,QAAQ,CAAC;IACP,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAClC,CAAC,CAAC;AAEL,+EAA+E;AAC/E,eAAO,MAAM,OAAO;YARR,SAAS;kBACH,SAAS;aACd,SAAS;cACR,SAAS;mBACJ,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC;gDAqClC,CAAC;AAEH,YAAY,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/layout.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { resolveGridLayout, } from "@hjmds/design-contracts/grid";
|
|
3
|
+
import { layoutRecipe, validateLayoutWebDescriptor, } from "@hjmds/design-contracts/components/layout";
|
|
4
|
+
import { surfaceDefaults, surfaceGeometry, surfaceRecipe, } from "@hjmds/design-contracts/recipes/base";
|
|
5
|
+
import { stackRecipe, textRecipe, } from "@hjmds/design-contracts/recipes";
|
|
6
|
+
import { createElement, forwardRef, useId, useRef, } from "react";
|
|
7
|
+
import { classNames, composeRefs, useElementWidth, useWindowWidth, } from "./internal.js";
|
|
8
|
+
function hasRegionContent(content) {
|
|
9
|
+
return content !== undefined && content !== null && content !== false;
|
|
10
|
+
}
|
|
11
|
+
function assertMainId(id) {
|
|
12
|
+
if (id.trim().length === 0) {
|
|
13
|
+
throw new TypeError("Layout mainId must not be empty");
|
|
14
|
+
}
|
|
15
|
+
if (/\s/u.test(id)) {
|
|
16
|
+
throw new TypeError("Layout mainId must not contain whitespace");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Accessible Web app shell with real landmarks and bypass navigation. */
|
|
20
|
+
export const Layout = forwardRef(function Layout({ children, header, footer, sidebar, skipLinkLabel, mainId: mainIdProp, mainRef: forwardedMainRef, headerProps, mainProps, footerProps, skipLinkProps, className, ...props }, ref) {
|
|
21
|
+
const generatedId = `hjm-main-${useId().replaceAll(":", "")}`;
|
|
22
|
+
const internalMainRef = useRef(null);
|
|
23
|
+
const mainId = mainIdProp ?? generatedId;
|
|
24
|
+
assertMainId(mainId);
|
|
25
|
+
const hasHeader = hasRegionContent(header);
|
|
26
|
+
const hasFooter = hasRegionContent(footer);
|
|
27
|
+
const descriptor = {
|
|
28
|
+
...(hasHeader ? { hasHeader: true } : {}),
|
|
29
|
+
...(hasFooter ? { hasFooter: true } : {}),
|
|
30
|
+
...(sidebar === undefined
|
|
31
|
+
? {}
|
|
32
|
+
: {
|
|
33
|
+
sidebar: {
|
|
34
|
+
role: sidebar.role,
|
|
35
|
+
mode: sidebar.mode,
|
|
36
|
+
label: sidebar.label,
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
...(skipLinkLabel === undefined ? {} : { skipLinkLabel }),
|
|
40
|
+
};
|
|
41
|
+
validateLayoutWebDescriptor(descriptor);
|
|
42
|
+
if (sidebar?.mode === "overlay" &&
|
|
43
|
+
typeof sidebar.renderOverlay !== "function") {
|
|
44
|
+
throw new TypeError("Layout overlay sidebar requires renderOverlay so SidePanel owns its lifecycle");
|
|
45
|
+
}
|
|
46
|
+
const { className: headerClassName, ...restHeaderProps } = headerProps ?? {};
|
|
47
|
+
const { className: mainClassName, style: mainStyle, ...restMainProps } = mainProps ?? {};
|
|
48
|
+
const { className: footerClassName, ...restFooterProps } = footerProps ?? {};
|
|
49
|
+
const { className: skipLinkClassName, onClick: onSkipLinkClick, ...restSkipLinkProps } = skipLinkProps ?? {};
|
|
50
|
+
let sidebarNode;
|
|
51
|
+
if (sidebar !== undefined) {
|
|
52
|
+
const { className: sidebarClassName, style: sidebarStyle, ...restSidebarProps } = sidebar.landmarkProps ?? {};
|
|
53
|
+
const sidebarLandmark = createElement(sidebar.role === "navigation" ? "nav" : "aside", {
|
|
54
|
+
...restSidebarProps,
|
|
55
|
+
ref: sidebar.landmarkRef,
|
|
56
|
+
className: classNames("hjm-layout__sidebar", sidebarClassName),
|
|
57
|
+
"aria-label": sidebar.label,
|
|
58
|
+
"data-mode": sidebar.mode,
|
|
59
|
+
style: {
|
|
60
|
+
...(sidebar.mode === "persistent"
|
|
61
|
+
? { inlineSize: layoutRecipe.sidebar.width }
|
|
62
|
+
: {}),
|
|
63
|
+
...sidebarStyle,
|
|
64
|
+
},
|
|
65
|
+
}, sidebar.children);
|
|
66
|
+
sidebarNode = sidebar.mode === "overlay"
|
|
67
|
+
? sidebar.renderOverlay(sidebarLandmark)
|
|
68
|
+
: sidebarLandmark;
|
|
69
|
+
}
|
|
70
|
+
const moveFocusToMain = (event) => {
|
|
71
|
+
onSkipLinkClick?.(event);
|
|
72
|
+
if (event.defaultPrevented)
|
|
73
|
+
return;
|
|
74
|
+
const main = internalMainRef.current;
|
|
75
|
+
if (main === null)
|
|
76
|
+
return;
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
const url = new URL(window.location.href);
|
|
79
|
+
url.hash = mainId;
|
|
80
|
+
window.history.replaceState(window.history.state, "", url);
|
|
81
|
+
main.focus({ preventScroll: true });
|
|
82
|
+
main.scrollIntoView?.({ block: "start" });
|
|
83
|
+
};
|
|
84
|
+
return (_jsxs("div", { ...props, ref: ref, className: classNames("hjm-layout", className), "data-hjm-component": "Layout", "data-sidebar-mode": sidebar?.mode ?? "none", children: [skipLinkLabel === undefined ? null : (_jsx("a", { ...restSkipLinkProps, href: `#${mainId}`, className: classNames("hjm-layout__skip-link", skipLinkClassName), onClick: moveFocusToMain, children: skipLinkLabel })), hasHeader ? (_jsx("header", { ...restHeaderProps, className: classNames("hjm-layout__header", headerClassName), children: header })) : null, sidebarNode, _jsx("main", { ...restMainProps, ref: composeRefs(internalMainRef, forwardedMainRef), id: mainId, className: classNames("hjm-layout__main", mainClassName), tabIndex: -1, style: {
|
|
85
|
+
maxInlineSize: layoutRecipe.main.maxWidth,
|
|
86
|
+
paddingInline: layoutRecipe.main.paddingHorizontal,
|
|
87
|
+
...mainStyle,
|
|
88
|
+
}, children: children }), hasFooter ? (_jsx("footer", { ...restFooterProps, className: classNames("hjm-layout__footer", footerClassName), children: footer })) : null] }));
|
|
89
|
+
});
|
|
90
|
+
export const Text = forwardRef(function Text({ as = "span", variant = textRecipe.defaults.variant, tone = textRecipe.defaults.tone, emphasis = textRecipe.defaults.emphasis, className, ...props }, ref) {
|
|
91
|
+
return createElement(as, {
|
|
92
|
+
...props,
|
|
93
|
+
ref,
|
|
94
|
+
className: classNames("hjm-text", className),
|
|
95
|
+
"data-variant": variant,
|
|
96
|
+
"data-tone": tone,
|
|
97
|
+
"data-emphasis": emphasis,
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
export const Surface = forwardRef(function Surface({ as = "div", tone = surfaceDefaults.tone, bordered = surfaceDefaults.bordered, padding = surfaceDefaults.padding, radius = surfaceDefaults.radius, className, style, ...props }, ref) {
|
|
101
|
+
const contract = surfaceRecipe[tone];
|
|
102
|
+
return createElement(as, {
|
|
103
|
+
...props,
|
|
104
|
+
ref,
|
|
105
|
+
className: classNames("hjm-surface", className),
|
|
106
|
+
"data-tone": tone,
|
|
107
|
+
"data-bordered": bordered || contract.borderAlways,
|
|
108
|
+
"data-elevated": contract.elevated,
|
|
109
|
+
"data-padding": padding,
|
|
110
|
+
"data-radius": radius,
|
|
111
|
+
style: {
|
|
112
|
+
padding: surfaceGeometry.paddings[padding],
|
|
113
|
+
borderRadius: surfaceGeometry.radii[radius],
|
|
114
|
+
...style,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
const justifyValues = {
|
|
119
|
+
start: "flex-start",
|
|
120
|
+
center: "center",
|
|
121
|
+
end: "flex-end",
|
|
122
|
+
between: "space-between",
|
|
123
|
+
};
|
|
124
|
+
export const Stack = forwardRef(function Stack({ axis = stackRecipe.defaults.axis, gap = stackRecipe.defaults.gap, align = stackRecipe.defaults.align, justify = stackRecipe.defaults.justify, wrap = stackRecipe.defaults.wrap, className, style, ...props }, ref) {
|
|
125
|
+
return (_jsx("div", { ...props, ref: ref, className: classNames("hjm-stack", className), "data-axis": axis, "data-gap": gap, style: {
|
|
126
|
+
display: "flex",
|
|
127
|
+
flexDirection: stackRecipe.axes[axis],
|
|
128
|
+
gap: stackRecipe.gaps[gap],
|
|
129
|
+
alignItems: align === "start" || align === "end" ? `flex-${align}` : align,
|
|
130
|
+
justifyContent: justifyValues[justify],
|
|
131
|
+
flexWrap: wrap ? "wrap" : "nowrap",
|
|
132
|
+
...style,
|
|
133
|
+
} }));
|
|
134
|
+
});
|
|
135
|
+
export const Grid = forwardRef(function Grid({ columns, gap, minColumnWidth, windowWidth, availableWidth, className, style, ...props }, forwardedRef) {
|
|
136
|
+
const browserWindowWidth = useWindowWidth();
|
|
137
|
+
const [measuredWidth, gridRef] = useElementWidth(forwardedRef);
|
|
138
|
+
const compactSsrWidth = 320;
|
|
139
|
+
const effectiveWindowWidth = windowWidth ??
|
|
140
|
+
(browserWindowWidth > 0 ? browserWindowWidth : compactSsrWidth);
|
|
141
|
+
const effectiveAvailableWidth = availableWidth ??
|
|
142
|
+
(measuredWidth !== undefined && measuredWidth > 0
|
|
143
|
+
? measuredWidth
|
|
144
|
+
: effectiveWindowWidth);
|
|
145
|
+
const descriptor = {
|
|
146
|
+
columns,
|
|
147
|
+
...(gap === undefined ? {} : { gap }),
|
|
148
|
+
...(minColumnWidth === undefined ? {} : { minColumnWidth }),
|
|
149
|
+
};
|
|
150
|
+
const layout = resolveGridLayout(descriptor, {
|
|
151
|
+
windowWidth: effectiveWindowWidth,
|
|
152
|
+
availableWidth: effectiveAvailableWidth,
|
|
153
|
+
});
|
|
154
|
+
return (_jsx("div", { ...props, ref: gridRef, className: classNames("hjm-grid", className), "data-window-class": layout.windowClass, "data-columns": layout.columns, "data-requested-columns": layout.requestedColumns, "data-state": layout.columns < layout.requestedColumns ? "collapsed" : "resolved", style: {
|
|
155
|
+
display: "grid",
|
|
156
|
+
gridTemplateColumns: `repeat(${layout.columns}, minmax(0, 1fr))`,
|
|
157
|
+
rowGap: layout.rowGap,
|
|
158
|
+
columnGap: layout.columnGap,
|
|
159
|
+
...style,
|
|
160
|
+
} }));
|
|
161
|
+
});
|
|
162
|
+
/** Large-text-safe semantic content section with an optional header action. */
|
|
163
|
+
export const Section = forwardRef(function Section({ title, description, action, children, headingLevel = 2, className, ...props }, ref) {
|
|
164
|
+
const hasHeader = title !== undefined || description !== undefined || action !== undefined;
|
|
165
|
+
return (_jsxs("section", { ...props, ref: ref, className: classNames("hjm-section", className), children: [hasHeader ? (_jsxs("header", { className: "hjm-section__header", children: [_jsxs("div", { className: "hjm-section__copy", children: [title === undefined ? null : createElement(`h${headingLevel}`, { className: "hjm-section__title" }, title), description === undefined ? null : (_jsx("div", { className: "hjm-section__description", children: description }))] }), action === undefined ? null : _jsx("div", { className: "hjm-section__action", children: action })] })) : null, _jsx("div", { className: "hjm-section__content", children: children })] }));
|
|
166
|
+
});
|
|
167
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../src/layout.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,iBAAiB,GAGlB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,YAAY,EACZ,2BAA2B,GAG5B,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,GAId,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACL,WAAW,EACX,UAAU,GAOX,MAAM,iCAAiC,CAAC;AAE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IAC3E,CACV,CAAC,CAAC,CAAC,IAAI,EACR,cAAK,SAAS,EAAC,sBAAsB,YAAE,QAAQ,GAAO,IAC9C,CACX,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["import {\n resolveGridLayout,\n type GridDescriptor,\n type GridGap,\n} from \"@hjmds/design-contracts/grid\";\nimport {\n layoutRecipe,\n validateLayoutWebDescriptor,\n type LayoutSidebarDescriptor,\n type LayoutSidebarRole,\n} from \"@hjmds/design-contracts/components/layout\";\nimport {\n surfaceDefaults,\n surfaceGeometry,\n surfaceRecipe,\n type SurfacePadding,\n type SurfaceRadius,\n type SurfaceTone,\n} from \"@hjmds/design-contracts/recipes/base\";\nimport {\n stackRecipe,\n textRecipe,\n type StackAlign,\n type StackAxis,\n type StackGap,\n type StackJustify,\n type TextEmphasis,\n type TextTone,\n} from \"@hjmds/design-contracts/recipes\";\nimport type { TextVariant } from \"@hjmds/design-contracts/foundations\";\nimport {\n createElement,\n forwardRef,\n useId,\n useRef,\n type AnchorHTMLAttributes,\n type HTMLAttributes,\n type MouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from \"react\";\nimport {\n classNames,\n composeRefs,\n useElementWidth,\n useWindowWidth,\n} from \"./internal.js\";\n\nexport type {\n SurfacePadding,\n SurfaceRadius,\n SurfaceTone,\n} from \"@hjmds/design-contracts/recipes/base\";\nexport type {\n StackAlign,\n StackAxis,\n StackGap,\n StackJustify,\n TextEmphasis,\n TextTone,\n} from \"@hjmds/design-contracts/recipes\";\n\ntype LayoutRegionProps = Omit<\n HTMLAttributes<HTMLElement>,\n \"children\" | \"role\"\n>;\n\ntype LayoutSidebarBase = Readonly<{\n children: ReactNode;\n role: LayoutSidebarRole;\n label: string;\n landmarkProps?: Omit<LayoutRegionProps, \"aria-label\">;\n landmarkRef?: Ref<HTMLElement>;\n}>;\n\n/**\n * A persistent sidebar is rendered in the shell grid. An overlay sidebar is\n * deliberately handed to the product's SidePanel (or equivalent) through\n * `renderOverlay`; Layout never owns a second open/dismiss lifecycle.\n */\nexport type LayoutSidebar =\n | (LayoutSidebarBase &\n Readonly<{\n mode: \"persistent\";\n renderOverlay?: never;\n }>)\n | (LayoutSidebarBase &\n Readonly<{\n mode: \"overlay\";\n renderOverlay(sidebarLandmark: ReactElement): ReactNode;\n }>);\n\nexport type LayoutProps = Omit<HTMLAttributes<HTMLDivElement>, \"children\"> &\n Readonly<{\n children: ReactNode;\n header?: ReactNode;\n footer?: ReactNode;\n sidebar?: LayoutSidebar;\n skipLinkLabel?: string;\n /** Stable product id for deep links; a hydration-safe id is generated when omitted. */\n mainId?: string;\n mainRef?: Ref<HTMLElement>;\n headerProps?: LayoutRegionProps;\n mainProps?: Omit<LayoutRegionProps, \"id\" | \"tabIndex\">;\n footerProps?: LayoutRegionProps;\n skipLinkProps?: Omit<\n AnchorHTMLAttributes<HTMLAnchorElement>,\n \"children\" | \"href\"\n >;\n }>;\n\nfunction hasRegionContent(content: ReactNode | undefined): boolean {\n return content !== undefined && content !== null && content !== false;\n}\n\nfunction assertMainId(id: string): void {\n if (id.trim().length === 0) {\n throw new TypeError(\"Layout mainId must not be empty\");\n }\n if (/\\s/u.test(id)) {\n throw new TypeError(\"Layout mainId must not contain whitespace\");\n }\n}\n\n/** Accessible Web app shell with real landmarks and bypass navigation. */\nexport const Layout = forwardRef<HTMLDivElement, LayoutProps>(function Layout(\n {\n children,\n header,\n footer,\n sidebar,\n skipLinkLabel,\n mainId: mainIdProp,\n mainRef: forwardedMainRef,\n headerProps,\n mainProps,\n footerProps,\n skipLinkProps,\n className,\n ...props\n },\n ref,\n) {\n const generatedId = `hjm-main-${useId().replaceAll(\":\", \"\")}`;\n const internalMainRef = useRef<HTMLElement>(null);\n const mainId = mainIdProp ?? generatedId;\n assertMainId(mainId);\n\n const hasHeader = hasRegionContent(header);\n const hasFooter = hasRegionContent(footer);\n const descriptor = {\n ...(hasHeader ? { hasHeader: true } : {}),\n ...(hasFooter ? { hasFooter: true } : {}),\n ...(sidebar === undefined\n ? {}\n : {\n sidebar: {\n role: sidebar.role,\n mode: sidebar.mode,\n label: sidebar.label,\n } satisfies LayoutSidebarDescriptor,\n }),\n ...(skipLinkLabel === undefined ? {} : { skipLinkLabel }),\n };\n validateLayoutWebDescriptor(descriptor);\n\n if (\n sidebar?.mode === \"overlay\" &&\n typeof sidebar.renderOverlay !== \"function\"\n ) {\n throw new TypeError(\n \"Layout overlay sidebar requires renderOverlay so SidePanel owns its lifecycle\",\n );\n }\n\n const {\n className: headerClassName,\n ...restHeaderProps\n } = headerProps ?? {};\n const {\n className: mainClassName,\n style: mainStyle,\n ...restMainProps\n } = mainProps ?? {};\n const {\n className: footerClassName,\n ...restFooterProps\n } = footerProps ?? {};\n const {\n className: skipLinkClassName,\n onClick: onSkipLinkClick,\n ...restSkipLinkProps\n } = skipLinkProps ?? {};\n\n let sidebarNode: ReactNode;\n if (sidebar !== undefined) {\n const {\n className: sidebarClassName,\n style: sidebarStyle,\n ...restSidebarProps\n } = sidebar.landmarkProps ?? {};\n const sidebarLandmark = createElement(\n sidebar.role === \"navigation\" ? \"nav\" : \"aside\",\n {\n ...restSidebarProps,\n ref: sidebar.landmarkRef,\n className: classNames(\"hjm-layout__sidebar\", sidebarClassName),\n \"aria-label\": sidebar.label,\n \"data-mode\": sidebar.mode,\n style: {\n ...(sidebar.mode === \"persistent\"\n ? { inlineSize: layoutRecipe.sidebar.width }\n : {}),\n ...sidebarStyle,\n },\n },\n sidebar.children,\n );\n sidebarNode = sidebar.mode === \"overlay\"\n ? sidebar.renderOverlay(sidebarLandmark)\n : sidebarLandmark;\n }\n\n const moveFocusToMain = (event: MouseEvent<HTMLAnchorElement>) => {\n onSkipLinkClick?.(event);\n if (event.defaultPrevented) return;\n const main = internalMainRef.current;\n if (main === null) return;\n event.preventDefault();\n const url = new URL(window.location.href);\n url.hash = mainId;\n window.history.replaceState(window.history.state, \"\", url);\n main.focus({ preventScroll: true });\n main.scrollIntoView?.({ block: \"start\" });\n };\n\n return (\n <div\n {...props}\n ref={ref}\n className={classNames(\"hjm-layout\", className)}\n data-hjm-component=\"Layout\"\n data-sidebar-mode={sidebar?.mode ?? \"none\"}\n >\n {skipLinkLabel === undefined ? null : (\n <a\n {...restSkipLinkProps}\n href={`#${mainId}`}\n className={classNames(\n \"hjm-layout__skip-link\",\n skipLinkClassName,\n )}\n onClick={moveFocusToMain}\n >\n {skipLinkLabel}\n </a>\n )}\n {hasHeader ? (\n <header\n {...restHeaderProps}\n className={classNames(\"hjm-layout__header\", headerClassName)}\n >\n {header}\n </header>\n ) : null}\n {sidebarNode}\n <main\n {...restMainProps}\n ref={composeRefs(internalMainRef, forwardedMainRef)}\n id={mainId}\n className={classNames(\"hjm-layout__main\", mainClassName)}\n tabIndex={-1}\n style={{\n maxInlineSize: layoutRecipe.main.maxWidth,\n paddingInline: layoutRecipe.main.paddingHorizontal,\n ...mainStyle,\n }}\n >\n {children}\n </main>\n {hasFooter ? (\n <footer\n {...restFooterProps}\n className={classNames(\"hjm-layout__footer\", footerClassName)}\n >\n {footer}\n </footer>\n ) : null}\n </div>\n );\n});\n\nexport type TextProps = Omit<HTMLAttributes<HTMLElement>, \"children\"> &\n Readonly<{\n children: ReactNode;\n as?: \"span\" | \"p\" | \"div\" | \"strong\" | \"small\";\n variant?: TextVariant;\n tone?: TextTone;\n emphasis?: TextEmphasis;\n }>;\n\nexport const Text = forwardRef<HTMLElement, TextProps>(function Text(\n {\n as = \"span\",\n variant = textRecipe.defaults.variant,\n tone = textRecipe.defaults.tone,\n emphasis = textRecipe.defaults.emphasis,\n className,\n ...props\n },\n ref,\n) {\n return createElement(as, {\n ...props,\n ref,\n className: classNames(\"hjm-text\", className),\n \"data-variant\": variant,\n \"data-tone\": tone,\n \"data-emphasis\": emphasis,\n });\n});\n\nexport type SurfaceProps = HTMLAttributes<HTMLElement> &\n Readonly<{\n as?: \"div\" | \"section\" | \"article\";\n tone?: SurfaceTone;\n bordered?: boolean;\n padding?: SurfacePadding;\n radius?: SurfaceRadius;\n }>;\n\nexport const Surface = forwardRef<HTMLElement, SurfaceProps>(function Surface(\n {\n as = \"div\",\n tone = surfaceDefaults.tone,\n bordered = surfaceDefaults.bordered,\n padding = surfaceDefaults.padding,\n radius = surfaceDefaults.radius,\n className,\n style,\n ...props\n },\n ref,\n) {\n const contract = surfaceRecipe[tone];\n return createElement(as, {\n ...props,\n ref,\n className: classNames(\"hjm-surface\", className),\n \"data-tone\": tone,\n \"data-bordered\": bordered || contract.borderAlways,\n \"data-elevated\": contract.elevated,\n \"data-padding\": padding,\n \"data-radius\": radius,\n style: {\n padding: surfaceGeometry.paddings[padding],\n borderRadius: surfaceGeometry.radii[radius],\n ...style,\n },\n });\n});\n\nexport type StackProps = HTMLAttributes<HTMLDivElement> &\n Readonly<{\n axis?: StackAxis;\n gap?: StackGap;\n align?: StackAlign;\n justify?: StackJustify;\n wrap?: boolean;\n }>;\n\nconst justifyValues = {\n start: \"flex-start\",\n center: \"center\",\n end: \"flex-end\",\n between: \"space-between\",\n} as const;\n\nexport const Stack = forwardRef<HTMLDivElement, StackProps>(function Stack(\n {\n axis = stackRecipe.defaults.axis,\n gap = stackRecipe.defaults.gap,\n align = stackRecipe.defaults.align,\n justify = stackRecipe.defaults.justify,\n wrap = stackRecipe.defaults.wrap,\n className,\n style,\n ...props\n },\n ref,\n) {\n return (\n <div\n {...props}\n ref={ref}\n className={classNames(\"hjm-stack\", className)}\n data-axis={axis}\n data-gap={gap}\n style={{\n display: \"flex\",\n flexDirection: stackRecipe.axes[axis],\n gap: stackRecipe.gaps[gap],\n alignItems: align === \"start\" || align === \"end\" ? `flex-${align}` : align,\n justifyContent: justifyValues[justify],\n flexWrap: wrap ? \"wrap\" : \"nowrap\",\n ...style,\n }}\n />\n );\n});\n\nexport type GridProps = Omit<HTMLAttributes<HTMLDivElement>, \"children\"> &\n Pick<GridDescriptor, \"columns\" | \"gap\" | \"minColumnWidth\"> &\n Readonly<{\n children?: ReactNode;\n /** Test/SSR override. Browser renderers otherwise observe window.innerWidth. */\n windowWidth?: number;\n /** Container measurement override; ResizeObserver is used when omitted. */\n availableWidth?: number;\n }>;\n\nexport const Grid = forwardRef<HTMLDivElement, GridProps>(function Grid(\n {\n columns,\n gap,\n minColumnWidth,\n windowWidth,\n availableWidth,\n className,\n style,\n ...props\n },\n forwardedRef,\n) {\n const browserWindowWidth = useWindowWidth();\n const [measuredWidth, gridRef] = useElementWidth(forwardedRef);\n const compactSsrWidth = 320;\n const effectiveWindowWidth =\n windowWidth ??\n (browserWindowWidth > 0 ? browserWindowWidth : compactSsrWidth);\n const effectiveAvailableWidth =\n availableWidth ??\n (measuredWidth !== undefined && measuredWidth > 0\n ? measuredWidth\n : effectiveWindowWidth);\n const descriptor: GridDescriptor = {\n columns,\n ...(gap === undefined ? {} : { gap }),\n ...(minColumnWidth === undefined ? {} : { minColumnWidth }),\n };\n const layout = resolveGridLayout(descriptor, {\n windowWidth: effectiveWindowWidth,\n availableWidth: effectiveAvailableWidth,\n });\n\n return (\n <div\n {...props}\n ref={gridRef}\n className={classNames(\"hjm-grid\", className)}\n data-window-class={layout.windowClass}\n data-columns={layout.columns}\n data-requested-columns={layout.requestedColumns}\n data-state={layout.columns < layout.requestedColumns ? \"collapsed\" : \"resolved\"}\n style={{\n display: \"grid\",\n gridTemplateColumns: `repeat(${layout.columns}, minmax(0, 1fr))`,\n rowGap: layout.rowGap,\n columnGap: layout.columnGap,\n ...style,\n }}\n />\n );\n});\n\nexport type SectionProps = Omit<HTMLAttributes<HTMLElement>, \"children\" | \"title\"> &\n Readonly<{\n title?: ReactNode;\n description?: ReactNode;\n action?: ReactNode;\n children: ReactNode;\n headingLevel?: 2 | 3 | 4 | 5 | 6;\n }>;\n\n/** Large-text-safe semantic content section with an optional header action. */\nexport const Section = forwardRef<HTMLElement, SectionProps>(function Section(\n {\n title,\n description,\n action,\n children,\n headingLevel = 2,\n className,\n ...props\n },\n ref,\n) {\n const hasHeader = title !== undefined || description !== undefined || action !== undefined;\n return (\n <section {...props} ref={ref} className={classNames(\"hjm-section\", className)}>\n {hasHeader ? (\n <header className=\"hjm-section__header\">\n <div className=\"hjm-section__copy\">\n {title === undefined ? null : createElement(\n `h${headingLevel}`,\n { className: \"hjm-section__title\" },\n title,\n )}\n {description === undefined ? null : (\n <div className=\"hjm-section__description\">{description}</div>\n )}\n </div>\n {action === undefined ? null : <div className=\"hjm-section__action\">{action}</div>}\n </header>\n ) : null}\n <div className=\"hjm-section__content\">{children}</div>\n </section>\n );\n});\n\nexport type { GridGap };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-public.d.ts","sourceRoot":"","sources":["../src/navigation-public.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-public.js","sourceRoot":"","sources":["../src/navigation-public.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,YAAY,CAAC;AAC3B,cAAc,wBAAwB,CAAC","sourcesContent":["export * from \"./navigation.js\";\nexport * from \"./advanced-navigation.js\";\nexport * from \"./supplemental-navigation.js\";\nexport * from \"./steps.js\";\nexport * from \"./bottom-navigation.js\";\n"]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type TabsActivationMode, type TabsDirection, type TabsMountPolicy, type TabsOrientation, type TabsPanelMode } from "@hjmds/design-contracts/behaviors";
|
|
2
|
+
import { type TabSize, type TabsLayout, type TabsOverflow } from "@hjmds/design-contracts/recipes";
|
|
3
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
4
|
+
export type TabLeadingRenderProps = Readonly<{
|
|
5
|
+
selected: boolean;
|
|
6
|
+
disabled: boolean;
|
|
7
|
+
color: "currentColor";
|
|
8
|
+
/** Pixel size resolved from `tabsRecipe.icon.glyph`. */
|
|
9
|
+
size: number;
|
|
10
|
+
/** Compatibility alias for product icon libraries that name this value explicitly. */
|
|
11
|
+
glyphSize: number;
|
|
12
|
+
}>;
|
|
13
|
+
export type TabItem = Readonly<{
|
|
14
|
+
id: string;
|
|
15
|
+
label: ReactNode;
|
|
16
|
+
panel?: ReactNode;
|
|
17
|
+
renderLeading?: (state: TabLeadingRenderProps) => ReactNode;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
type TabsSelection = Readonly<{
|
|
21
|
+
value: string;
|
|
22
|
+
defaultValue?: never;
|
|
23
|
+
onValueChange(value: string): void;
|
|
24
|
+
}> | Readonly<{
|
|
25
|
+
value?: never;
|
|
26
|
+
defaultValue?: string;
|
|
27
|
+
onValueChange?: (value: string) => void;
|
|
28
|
+
}>;
|
|
29
|
+
export type TabsProps = Omit<HTMLAttributes<HTMLDivElement>, "dir" | "onChange"> & TabsSelection & Readonly<{
|
|
30
|
+
label: string;
|
|
31
|
+
items: readonly TabItem[];
|
|
32
|
+
activationMode?: TabsActivationMode;
|
|
33
|
+
mountPolicy?: TabsMountPolicy;
|
|
34
|
+
panelMode?: TabsPanelMode;
|
|
35
|
+
orientation?: TabsOrientation;
|
|
36
|
+
direction?: TabsDirection;
|
|
37
|
+
loop?: boolean;
|
|
38
|
+
size?: TabSize;
|
|
39
|
+
layout?: TabsLayout;
|
|
40
|
+
overflow?: TabsOverflow;
|
|
41
|
+
/** Set false when panels are rendered separately with `TabPanel`. */
|
|
42
|
+
renderPanels?: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
export declare function getTabId(tabsId: string, value: string): string;
|
|
45
|
+
export declare function getTabPanelId(tabsId: string, value: string, mode?: TabsPanelMode): string;
|
|
46
|
+
export declare function getDynamicTabPanelId(tabsId: string): string;
|
|
47
|
+
type ExternalTabPanelBaseProps = Omit<HTMLAttributes<HTMLDivElement>, "id"> & Readonly<{
|
|
48
|
+
tabsId: string;
|
|
49
|
+
activeValue: string;
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
}>;
|
|
52
|
+
export type TabPanelProps = ExternalTabPanelBaseProps & (Readonly<{
|
|
53
|
+
mode: "dynamic";
|
|
54
|
+
value?: never;
|
|
55
|
+
mountPolicy?: never;
|
|
56
|
+
}> | Readonly<{
|
|
57
|
+
mode?: "keyed";
|
|
58
|
+
value: string;
|
|
59
|
+
mountPolicy?: TabsMountPolicy;
|
|
60
|
+
}>);
|
|
61
|
+
/** External panel host for products that keep routing, query, or scroll state outside Tabs. */
|
|
62
|
+
export declare function TabPanel(props: TabPanelProps): import("react").JSX.Element | null;
|
|
63
|
+
export declare const Tabs: import("react").ForwardRefExoticComponent<TabsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../src/navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,aAAa,EACnB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,UAAU,EACf,KAAK,YAAY,EAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAML,KAAK,cAAc,EAEnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,cAAc,CAAC;IACtB,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,sFAAsF;IACtF,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,MAA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