@hjmds/react 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/evidence.d.ts +1 -1
- package/dist/evidence.js +1 -1
- package/dist/evidence.js.map +1 -1
- package/dist/overlays.d.ts.map +1 -1
- package/dist/overlays.js +2 -1
- package/dist/overlays.js.map +1 -1
- package/dist/portal.d.ts.map +1 -1
- package/dist/portal.js +3 -2
- package/dist/portal.js.map +1 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +8 -2
- package/dist/provider.js.map +1 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +36 -20
- package/dist/select.js.map +1 -1
- package/dist/selection.js +1 -1
- package/dist/selection.js.map +1 -1
- package/dist/styles.css +24 -7
- package/dist/toast.d.ts.map +1 -1
- package/dist/toast.js +2 -1
- package/dist/toast.js.map +1 -1
- package/package.json +3 -3
package/dist/portal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"portal.js","sourceRoot":"","sources":["../src/portal.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,EACX,SAAS,EACT,MAAM,EACN,QAAQ,GAIT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAUzC;;;GAGG;AACH,SAAS,4BAA4B,CAAC,IAAoB,EAAE,MAA0B;IACpF,MAAM,MAAM,GAAG,MAAM,EAAE,OAAO,CAAc,wCAAwC,CAAC,IAAI,IAAI,CAAC;IAC9F,MAAM,gBAAgB,GAAG,MAAM,EAAE,OAAO,CAAc,0BAA0B,CAAC,IAAI,IAAI,CAAC;IAC1F,MAAM,gBAAgB,GAAG,MAAM;QAC7B,EAAE,OAAO,CAAc,wBAAwB,CAAC;QAChD,EAAE,YAAY,CAAC,sBAAsB,CAAC,IAAI,IAAI,CAAC;IACjD,MAAM,UAAU,GAAG,gBAAgB;QACjC,CAAC,gBAAgB,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M,CAAC,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;YACjE,MAAM,CAAC,cAAc,EAAE,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;YAC3E,MAAM,CAAC,cAAc,EAAE,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;YAC3E,cAAc,EAAE,UAAU,EAAE,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IAEtC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n useCallback,\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nexport type PortalProps = Readonly<{\n anchorRef: RefObject<HTMLElement | null>;\n children: ReactNode;\n container?: HTMLElement;\n /** Anchored non-modal popups may render inline until hydration moves them. */\n ssrFallback?: \"none\" | \"inline\";\n}>;\n\n/**\n * Copies the closest provider DOM boundary instead of importing provider\n * runtime code, keeping granular form/overlay entry points lightweight.\n */\nfunction synchronizePortalEnvironment(host: HTMLDivElement, anchor: HTMLElement | null): void {\n const source = anchor?.closest<HTMLElement>(\"[data-hjm-provider], [data-hjm-portal]\") ?? null;\n const directModalOwner = anchor?.closest<HTMLElement>(\"[data-hjm-modal-content]\") ?? null;\n const inheritedOwnerId = anchor\n ?.closest<HTMLElement>(\"[data-hjm-popup-owner]\")\n ?.getAttribute(\"data-hjm-popup-owner\") ?? null;\n const modalOwner = directModalOwner ??\n (inheritedOwnerId === null ? null : document.getElementById(inheritedOwnerId));\n if (modalOwner?.id) host.setAttribute(\"data-hjm-popup-owner\", modalOwner.id);\n else host.removeAttribute(\"data-hjm-popup-owner\");\n if (source) {\n host.removeAttribute(\"style\");\n for (let index = 0; index < source.style.length; index += 1) {\n const property = source.style.item(index);\n if (\n property.startsWith(\"--hjm-\") ||\n property === \"background-color\" ||\n property === \"color\" ||\n property === \"color-scheme\" ||\n property === \"font-family\" ||\n property === \"font-size\" ||\n property === \"line-height\"\n ) {\n host.style.setProperty(\n property,\n source.style.getPropertyValue(property),\n source.style.getPropertyPriority(property),\n );\n }\n }\n for (const attribute of [\"data-motion\", \"data-theme\", \"data-text-scale\"] as const) {\n const value = source.getAttribute(attribute);\n if (value === null) host.removeAttribute(attribute);\n else host.setAttribute(attribute, value);\n }\n host.dir = source.dir;\n return;\n }\n host.removeAttribute(\"style\");\n host.removeAttribute(\"data-motion\");\n host.removeAttribute(\"data-theme\");\n host.removeAttribute(\"data-text-scale\");\n host.dir = anchor?.closest<HTMLElement>(\"[dir]\")?.dir ?? \"\";\n}\n\nexport function AnchoredPortal({\n anchorRef,\n children,\n container,\n ssrFallback = \"none\",\n}: PortalProps) {\n const [mounted, setMounted] = useState(false);\n const hostRef = useRef<HTMLDivElement | null>(null);\n const setHostRef = useCallback((host: HTMLDivElement | null) => {\n hostRef.current = host;\n if (host) synchronizePortalEnvironment(host, anchorRef.current);\n }, [anchorRef]);\n useEffect(() => setMounted(true), []);\n useEffect(() => {\n const host = hostRef.current;\n const source = anchorRef.current?.closest<HTMLElement>(\n \"[data-hjm-provider], [data-hjm-portal]\",\n ) ?? null;\n if (!host || !source || typeof MutationObserver === \"undefined\") return;\n const observer = new MutationObserver(() => {\n synchronizePortalEnvironment(host, anchorRef.current);\n });\n observer.observe(source, {\n attributes: true,\n attributeFilter: [\"data-motion\", \"data-theme\", \"data-text-scale\", \"dir\", \"style\"],\n });\n return () => observer.disconnect();\n }, [anchorRef, mounted]);\n if (!mounted) return ssrFallback === \"inline\" ? children : null;\n return createPortal(\n <div ref={setHostRef} className=\"hjm-root hjm-portal\" data-hjm-portal=\"\">\n {children}\n </div>,\n container ?? document.body,\n );\n}\n\nexport type AnchoredPopupAlign = \"start\" | \"center\" | \"end\";\nexport type AnchoredPopupPlacement = \"bottom\" | \"top\" | \"start\" | \"end\";\n\ntype AnchoredPopupPosition = Readonly<{\n align: AnchoredPopupAlign;\n placement: AnchoredPopupPlacement;\n style: CSSProperties;\n}>;\n\ntype AnchoredPopupOptions = Readonly<{\n align?: AnchoredPopupAlign;\n gap?: number;\n matchAnchorWidth?: boolean;\n placement?: AnchoredPopupPlacement;\n viewportPadding?: number;\n zIndex?: number;\n}>;\n\nconst hiddenPopupPosition: AnchoredPopupPosition = {\n align: \"start\",\n placement: \"bottom\",\n style: {\n position: \"fixed\",\n inset: \"auto\",\n left: 0,\n top: 0,\n visibility: \"hidden\",\n },\n};\n\nfunction samePosition(\n previous: AnchoredPopupPosition,\n next: AnchoredPopupPosition,\n): boolean {\n return previous.align === next.align &&\n previous.placement === next.placement &&\n previous.style.left === next.style.left &&\n previous.style.top === next.style.top &&\n previous.style.minWidth === next.style.minWidth &&\n previous.style.maxWidth === next.style.maxWidth &&\n previous.style.maxHeight === next.style.maxHeight &&\n previous.style.zIndex === next.style.zIndex &&\n previous.style.visibility === next.style.visibility;\n}\n\n/**\n * Positions a fixed portal popup against its anchor using logical alignment.\n * The popup flips vertically and shifts horizontally to stay inside the visual\n * viewport, then follows every scroll/resize source that can move either node.\n */\nexport function useAnchoredPopup(\n anchorRef: RefObject<HTMLElement | null>,\n popup: HTMLElement | null,\n {\n align = \"start\",\n gap = 8,\n matchAnchorWidth = false,\n placement: preferredPlacement = \"bottom\",\n viewportPadding = 16,\n zIndex = 800,\n }: AnchoredPopupOptions = {},\n): AnchoredPopupPosition {\n const [position, setPosition] = useState<AnchoredPopupPosition>(() => ({\n ...hiddenPopupPosition,\n align,\n }));\n\n const update = useCallback(() => {\n const anchor = anchorRef.current;\n if (!anchor || !popup || !anchor.isConnected || !popup.isConnected) return;\n\n const anchorRect = anchor.getBoundingClientRect();\n const popupRect = popup.getBoundingClientRect();\n const visualViewport = window.visualViewport;\n const viewportLeft = visualViewport?.offsetLeft ?? 0;\n const viewportTop = visualViewport?.offsetTop ?? 0;\n const viewportWidth = visualViewport?.width ?? window.innerWidth;\n const viewportHeight = visualViewport?.height ?? window.innerHeight;\n const viewportRight = viewportLeft + viewportWidth;\n const viewportBottom = viewportTop + viewportHeight;\n const availableBottom = Math.max(0, viewportBottom - viewportPadding - anchorRect.bottom - gap);\n const availableTop = Math.max(0, anchorRect.top - viewportTop - viewportPadding - gap);\n const availableLeft = Math.max(0, anchorRect.left - viewportLeft - viewportPadding - gap);\n const availableRight = Math.max(0, viewportRight - viewportPadding - anchorRect.right - gap);\n const maximumPopupHeight = Math.max(0, viewportHeight - (2 * viewportPadding));\n const maximumPopupWidth = Math.max(0, viewportWidth - (2 * viewportPadding));\n const desiredPopupHeight = Math.min(\n Math.max(popupRect.height, popup.scrollHeight),\n maximumPopupHeight,\n );\n const desiredPopupWidth = Math.min(\n Math.max(popupRect.width, popup.scrollWidth, matchAnchorWidth ? anchorRect.width : 0),\n maximumPopupWidth,\n );\n const direction = getComputedStyle(anchor).direction;\n const directModalOwner = anchor.closest<HTMLElement>(\"[data-hjm-modal-content]\");\n const inheritedOwnerId = anchor\n .closest<HTMLElement>(\"[data-hjm-popup-owner]\")\n ?.getAttribute(\"data-hjm-popup-owner\") ?? null;\n const modalOwner = directModalOwner ??\n (inheritedOwnerId === null ? null : document.getElementById(inheritedOwnerId));\n const modalLayerValue = modalOwner\n ?.closest<HTMLElement>(\".hjm-overlay\")\n ?.style.zIndex ?? \"\";\n const modalLayer = Number.parseInt(modalLayerValue, 10);\n const resolvedZIndex = Number.isFinite(modalLayer) ? modalLayer + 1 : zIndex;\n const logicalStartAtLeft = direction !== \"rtl\";\n const preferredPhysicalPlacement = preferredPlacement === \"start\"\n ? (logicalStartAtLeft ? \"left\" : \"right\")\n : preferredPlacement === \"end\"\n ? (logicalStartAtLeft ? \"right\" : \"left\")\n : preferredPlacement;\n let physicalPlacement: \"bottom\" | \"top\" | \"left\" | \"right\" =\n preferredPhysicalPlacement;\n if (\n physicalPlacement === \"bottom\" &&\n desiredPopupHeight > availableBottom &&\n availableTop > availableBottom\n ) physicalPlacement = \"top\";\n else if (\n physicalPlacement === \"top\" &&\n desiredPopupHeight > availableTop &&\n availableBottom > availableTop\n ) physicalPlacement = \"bottom\";\n else if (\n physicalPlacement === \"left\" &&\n desiredPopupWidth > availableLeft &&\n availableRight > availableLeft\n ) physicalPlacement = \"right\";\n else if (\n physicalPlacement === \"right\" &&\n desiredPopupWidth > availableRight &&\n availableLeft > availableRight\n ) physicalPlacement = \"left\";\n const placement: AnchoredPopupPlacement = physicalPlacement === \"left\"\n ? (logicalStartAtLeft ? \"start\" : \"end\")\n : physicalPlacement === \"right\"\n ? (logicalStartAtLeft ? \"end\" : \"start\")\n : physicalPlacement;\n const availableHeight = physicalPlacement === \"bottom\"\n ? availableBottom\n : physicalPlacement === \"top\"\n ? availableTop\n : maximumPopupHeight;\n const availableWidth = physicalPlacement === \"left\"\n ? availableLeft\n : physicalPlacement === \"right\"\n ? availableRight\n : maximumPopupWidth;\n const popupHeight = Math.min(desiredPopupHeight, Math.max(0, availableHeight));\n const popupWidth = Math.min(desiredPopupWidth, Math.max(0, availableWidth));\n const alignLeftEdge = align === \"start\" ? logicalStartAtLeft : !logicalStartAtLeft;\n const inlineAlignedLeft = align === \"center\"\n ? anchorRect.left + ((anchorRect.width - popupWidth) / 2)\n : alignLeftEdge\n ? anchorRect.left\n : anchorRect.right - popupWidth;\n const blockAlignedTop = align === \"center\"\n ? anchorRect.top + ((anchorRect.height - popupHeight) / 2)\n : align === \"start\"\n ? anchorRect.top\n : anchorRect.bottom - popupHeight;\n const desiredLeft = physicalPlacement === \"left\"\n ? anchorRect.left - gap - popupWidth\n : physicalPlacement === \"right\"\n ? anchorRect.right + gap\n : inlineAlignedLeft;\n const maximumLeft = Math.max(\n viewportLeft + viewportPadding,\n viewportRight - viewportPadding - popupWidth,\n );\n const left = Math.min(\n Math.max(desiredLeft, viewportLeft + viewportPadding),\n maximumLeft,\n );\n const desiredTop = physicalPlacement === \"bottom\"\n ? anchorRect.bottom + gap\n : physicalPlacement === \"top\"\n ? anchorRect.top - gap - popupHeight\n : blockAlignedTop;\n const maximumTop = Math.max(\n viewportTop + viewportPadding,\n viewportBottom - viewportPadding - popupHeight,\n );\n const top = Math.min(\n Math.max(desiredTop, viewportTop + viewportPadding),\n maximumTop,\n );\n const next: AnchoredPopupPosition = {\n align,\n placement,\n style: {\n position: \"fixed\",\n inset: \"auto\",\n left: Math.round(left),\n top: Math.round(top),\n minWidth: matchAnchorWidth\n ? Math.round(Math.min(anchorRect.width, availableWidth, maximumPopupWidth))\n : undefined,\n maxWidth: Math.max(0, availableWidth),\n maxHeight: Math.max(0, availableHeight),\n visibility: \"visible\",\n zIndex: resolvedZIndex,\n },\n };\n setPosition((previous) => samePosition(previous, next) ? previous : next);\n }, [\n align,\n anchorRef,\n gap,\n matchAnchorWidth,\n popup,\n preferredPlacement,\n viewportPadding,\n zIndex,\n ]);\n\n useEffect(() => {\n if (!popup) {\n setPosition({ ...hiddenPopupPosition, align });\n return;\n }\n update();\n const frame = requestAnimationFrame(update);\n const handleViewportChange = () => update();\n window.addEventListener(\"resize\", handleViewportChange);\n window.addEventListener(\"scroll\", handleViewportChange, true);\n window.visualViewport?.addEventListener(\"resize\", handleViewportChange);\n window.visualViewport?.addEventListener(\"scroll\", handleViewportChange);\n const resizeObserver = typeof ResizeObserver === \"undefined\"\n ? null\n : new ResizeObserver(update);\n if (anchorRef.current) resizeObserver?.observe(anchorRef.current);\n resizeObserver?.observe(popup);\n return () => {\n cancelAnimationFrame(frame);\n window.removeEventListener(\"resize\", handleViewportChange);\n window.removeEventListener(\"scroll\", handleViewportChange, true);\n window.visualViewport?.removeEventListener(\"resize\", handleViewportChange);\n window.visualViewport?.removeEventListener(\"scroll\", handleViewportChange);\n resizeObserver?.disconnect();\n };\n }, [align, anchorRef, popup, update]);\n\n return position;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"portal.js","sourceRoot":"","sources":["../src/portal.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,WAAW,E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oB,EAAE,IAAI,CAAC,CAAC;QAC9D,MAAM,CAAC,cAAc,EAAE,gBAAgB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACxE,MAAM,CAAC,cAAc,EAAE,gBAAgB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACxE,MAAM,cAAc,GAAG,OAAO,cAAc,KAAK,WAAW;YAC1D,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,SAAS,CAAC,OAAO;YAAE,cAAc,EAAE,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAClE,cAAc,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,GAAG,EAAE;YACV,oBAAoB,CAAC,KAAK,CAAC,CAAC;YAC5B,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;YAC3D,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;YACjE,MAAM,CAAC,cAAc,EAAE,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;YAC3E,MAAM,CAAC,cAAc,EAAE,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;YAC3E,cAAc,EAAE,UAAU,EAAE,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;IAEtC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {\n useCallback,\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type ReactNode,\n type RefObject,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nexport type PortalProps = Readonly<{\n anchorRef: RefObject<HTMLElement | null>;\n children: ReactNode;\n container?: HTMLElement;\n /** Anchored non-modal popups may render inline until hydration moves them. */\n ssrFallback?: \"none\" | \"inline\";\n}>;\n\n/**\n * Copies the closest provider DOM boundary instead of importing provider\n * runtime code, keeping granular form/overlay entry points lightweight.\n */\nfunction synchronizePortalEnvironment(host: HTMLDivElement, anchor: HTMLElement | null): void {\n const source = anchor?.closest<HTMLElement>(\"[data-hjm-provider], [data-hjm-portal]\") ?? null;\n const directModalOwner = anchor?.closest<HTMLElement>(\"[data-hjm-modal-content]\") ?? null;\n const inheritedOwnerId = anchor\n ?.closest<HTMLElement>(\"[data-hjm-popup-owner]\")\n ?.getAttribute(\"data-hjm-popup-owner\") ?? null;\n const modalOwner = directModalOwner ??\n (inheritedOwnerId === null ? null : document.getElementById(inheritedOwnerId));\n if (modalOwner?.id) host.setAttribute(\"data-hjm-popup-owner\", modalOwner.id);\n else host.removeAttribute(\"data-hjm-popup-owner\");\n if (source) {\n host.removeAttribute(\"style\");\n for (let index = 0; index < source.style.length; index += 1) {\n const property = source.style.item(index);\n if (\n property.startsWith(\"--hjm-\") ||\n property === \"background-color\" ||\n property === \"color\" ||\n property === \"color-scheme\" ||\n property === \"font-family\" ||\n property === \"font-size\" ||\n property === \"line-height\"\n ) {\n host.style.setProperty(\n property,\n source.style.getPropertyValue(property),\n source.style.getPropertyPriority(property),\n );\n }\n }\n for (const attribute of [\"data-motion\", \"data-theme\", \"data-text-scale\", \"data-large-text\"] as const) {\n const value = source.getAttribute(attribute);\n if (value === null) host.removeAttribute(attribute);\n else host.setAttribute(attribute, value);\n }\n host.dir = source.dir;\n return;\n }\n host.removeAttribute(\"style\");\n host.removeAttribute(\"data-motion\");\n host.removeAttribute(\"data-theme\");\n host.removeAttribute(\"data-text-scale\");\n host.removeAttribute(\"data-large-text\");\n host.dir = anchor?.closest<HTMLElement>(\"[dir]\")?.dir ?? \"\";\n}\n\nexport function AnchoredPortal({\n anchorRef,\n children,\n container,\n ssrFallback = \"none\",\n}: PortalProps) {\n const [mounted, setMounted] = useState(false);\n const hostRef = useRef<HTMLDivElement | null>(null);\n const setHostRef = useCallback((host: HTMLDivElement | null) => {\n hostRef.current = host;\n if (host) synchronizePortalEnvironment(host, anchorRef.current);\n }, [anchorRef]);\n useEffect(() => setMounted(true), []);\n useEffect(() => {\n const host = hostRef.current;\n const source = anchorRef.current?.closest<HTMLElement>(\n \"[data-hjm-provider], [data-hjm-portal]\",\n ) ?? null;\n if (!host || !source || typeof MutationObserver === \"undefined\") return;\n const observer = new MutationObserver(() => {\n synchronizePortalEnvironment(host, anchorRef.current);\n });\n observer.observe(source, {\n attributes: true,\n attributeFilter: [\"data-motion\", \"data-theme\", \"data-text-scale\", \"data-large-text\", \"dir\", \"style\"],\n });\n return () => observer.disconnect();\n }, [anchorRef, mounted]);\n if (!mounted) return ssrFallback === \"inline\" ? children : null;\n return createPortal(\n <div ref={setHostRef} className=\"hjm-root hjm-portal\" data-hjm-portal=\"\">\n {children}\n </div>,\n container ?? document.body,\n );\n}\n\nexport type AnchoredPopupAlign = \"start\" | \"center\" | \"end\";\nexport type AnchoredPopupPlacement = \"bottom\" | \"top\" | \"start\" | \"end\";\n\ntype AnchoredPopupPosition = Readonly<{\n align: AnchoredPopupAlign;\n placement: AnchoredPopupPlacement;\n style: CSSProperties;\n}>;\n\ntype AnchoredPopupOptions = Readonly<{\n align?: AnchoredPopupAlign;\n gap?: number;\n matchAnchorWidth?: boolean;\n placement?: AnchoredPopupPlacement;\n viewportPadding?: number;\n zIndex?: number;\n}>;\n\nconst hiddenPopupPosition: AnchoredPopupPosition = {\n align: \"start\",\n placement: \"bottom\",\n style: {\n position: \"fixed\",\n inset: \"auto\",\n left: 0,\n top: 0,\n visibility: \"hidden\",\n },\n};\n\nfunction samePosition(\n previous: AnchoredPopupPosition,\n next: AnchoredPopupPosition,\n): boolean {\n return previous.align === next.align &&\n previous.placement === next.placement &&\n previous.style.left === next.style.left &&\n previous.style.top === next.style.top &&\n previous.style.minWidth === next.style.minWidth &&\n previous.style.maxWidth === next.style.maxWidth &&\n previous.style.maxHeight === next.style.maxHeight &&\n previous.style.zIndex === next.style.zIndex &&\n previous.style.visibility === next.style.visibility;\n}\n\n/**\n * Positions a fixed portal popup against its anchor using logical alignment.\n * The popup flips vertically and shifts horizontally to stay inside the visual\n * viewport, then follows every scroll/resize source that can move either node.\n */\nexport function useAnchoredPopup(\n anchorRef: RefObject<HTMLElement | null>,\n popup: HTMLElement | null,\n {\n align = \"start\",\n gap = 8,\n matchAnchorWidth = false,\n placement: preferredPlacement = \"bottom\",\n viewportPadding = 16,\n zIndex = 800,\n }: AnchoredPopupOptions = {},\n): AnchoredPopupPosition {\n const [position, setPosition] = useState<AnchoredPopupPosition>(() => ({\n ...hiddenPopupPosition,\n align,\n }));\n\n const update = useCallback(() => {\n const anchor = anchorRef.current;\n if (!anchor || !popup || !anchor.isConnected || !popup.isConnected) return;\n\n const anchorRect = anchor.getBoundingClientRect();\n const popupRect = popup.getBoundingClientRect();\n const visualViewport = window.visualViewport;\n const viewportLeft = visualViewport?.offsetLeft ?? 0;\n const viewportTop = visualViewport?.offsetTop ?? 0;\n const viewportWidth = visualViewport?.width ?? window.innerWidth;\n const viewportHeight = visualViewport?.height ?? window.innerHeight;\n const viewportRight = viewportLeft + viewportWidth;\n const viewportBottom = viewportTop + viewportHeight;\n const availableBottom = Math.max(0, viewportBottom - viewportPadding - anchorRect.bottom - gap);\n const availableTop = Math.max(0, anchorRect.top - viewportTop - viewportPadding - gap);\n const availableLeft = Math.max(0, anchorRect.left - viewportLeft - viewportPadding - gap);\n const availableRight = Math.max(0, viewportRight - viewportPadding - anchorRect.right - gap);\n const maximumPopupHeight = Math.max(0, viewportHeight - (2 * viewportPadding));\n const maximumPopupWidth = Math.max(0, viewportWidth - (2 * viewportPadding));\n const desiredPopupHeight = Math.min(\n Math.max(popupRect.height, popup.scrollHeight),\n maximumPopupHeight,\n );\n const desiredPopupWidth = Math.min(\n Math.max(popupRect.width, popup.scrollWidth, matchAnchorWidth ? anchorRect.width : 0),\n maximumPopupWidth,\n );\n const direction = getComputedStyle(anchor).direction;\n const directModalOwner = anchor.closest<HTMLElement>(\"[data-hjm-modal-content]\");\n const inheritedOwnerId = anchor\n .closest<HTMLElement>(\"[data-hjm-popup-owner]\")\n ?.getAttribute(\"data-hjm-popup-owner\") ?? null;\n const modalOwner = directModalOwner ??\n (inheritedOwnerId === null ? null : document.getElementById(inheritedOwnerId));\n const modalLayerValue = modalOwner\n ?.closest<HTMLElement>(\".hjm-overlay\")\n ?.style.zIndex ?? \"\";\n const modalLayer = Number.parseInt(modalLayerValue, 10);\n const resolvedZIndex = Number.isFinite(modalLayer) ? modalLayer + 1 : zIndex;\n const logicalStartAtLeft = direction !== \"rtl\";\n const preferredPhysicalPlacement = preferredPlacement === \"start\"\n ? (logicalStartAtLeft ? \"left\" : \"right\")\n : preferredPlacement === \"end\"\n ? (logicalStartAtLeft ? \"right\" : \"left\")\n : preferredPlacement;\n let physicalPlacement: \"bottom\" | \"top\" | \"left\" | \"right\" =\n preferredPhysicalPlacement;\n if (\n physicalPlacement === \"bottom\" &&\n desiredPopupHeight > availableBottom &&\n availableTop > availableBottom\n ) physicalPlacement = \"top\";\n else if (\n physicalPlacement === \"top\" &&\n desiredPopupHeight > availableTop &&\n availableBottom > availableTop\n ) physicalPlacement = \"bottom\";\n else if (\n physicalPlacement === \"left\" &&\n desiredPopupWidth > availableLeft &&\n availableRight > availableLeft\n ) physicalPlacement = \"right\";\n else if (\n physicalPlacement === \"right\" &&\n desiredPopupWidth > availableRight &&\n availableLeft > availableRight\n ) physicalPlacement = \"left\";\n const placement: AnchoredPopupPlacement = physicalPlacement === \"left\"\n ? (logicalStartAtLeft ? \"start\" : \"end\")\n : physicalPlacement === \"right\"\n ? (logicalStartAtLeft ? \"end\" : \"start\")\n : physicalPlacement;\n const availableHeight = physicalPlacement === \"bottom\"\n ? availableBottom\n : physicalPlacement === \"top\"\n ? availableTop\n : maximumPopupHeight;\n const availableWidth = physicalPlacement === \"left\"\n ? availableLeft\n : physicalPlacement === \"right\"\n ? availableRight\n : maximumPopupWidth;\n const popupHeight = Math.min(desiredPopupHeight, Math.max(0, availableHeight));\n const popupWidth = Math.min(desiredPopupWidth, Math.max(0, availableWidth));\n const alignLeftEdge = align === \"start\" ? logicalStartAtLeft : !logicalStartAtLeft;\n const inlineAlignedLeft = align === \"center\"\n ? anchorRect.left + ((anchorRect.width - popupWidth) / 2)\n : alignLeftEdge\n ? anchorRect.left\n : anchorRect.right - popupWidth;\n const blockAlignedTop = align === \"center\"\n ? anchorRect.top + ((anchorRect.height - popupHeight) / 2)\n : align === \"start\"\n ? anchorRect.top\n : anchorRect.bottom - popupHeight;\n const desiredLeft = physicalPlacement === \"left\"\n ? anchorRect.left - gap - popupWidth\n : physicalPlacement === \"right\"\n ? anchorRect.right + gap\n : inlineAlignedLeft;\n const maximumLeft = Math.max(\n viewportLeft + viewportPadding,\n viewportRight - viewportPadding - popupWidth,\n );\n const left = Math.min(\n Math.max(desiredLeft, viewportLeft + viewportPadding),\n maximumLeft,\n );\n const desiredTop = physicalPlacement === \"bottom\"\n ? anchorRect.bottom + gap\n : physicalPlacement === \"top\"\n ? anchorRect.top - gap - popupHeight\n : blockAlignedTop;\n const maximumTop = Math.max(\n viewportTop + viewportPadding,\n viewportBottom - viewportPadding - popupHeight,\n );\n const top = Math.min(\n Math.max(desiredTop, viewportTop + viewportPadding),\n maximumTop,\n );\n const next: AnchoredPopupPosition = {\n align,\n placement,\n style: {\n position: \"fixed\",\n inset: \"auto\",\n left: Math.round(left),\n top: Math.round(top),\n minWidth: matchAnchorWidth\n ? Math.round(Math.min(anchorRect.width, availableWidth, maximumPopupWidth))\n : undefined,\n maxWidth: Math.max(0, availableWidth),\n maxHeight: Math.max(0, availableHeight),\n visibility: \"visible\",\n zIndex: resolvedZIndex,\n },\n };\n setPosition((previous) => samePosition(previous, next) ? previous : next);\n }, [\n align,\n anchorRef,\n gap,\n matchAnchorWidth,\n popup,\n preferredPlacement,\n viewportPadding,\n zIndex,\n ]);\n\n useEffect(() => {\n if (!popup) {\n setPosition({ ...hiddenPopupPosition, align });\n return;\n }\n update();\n const frame = requestAnimationFrame(update);\n const handleViewportChange = () => update();\n window.addEventListener(\"resize\", handleViewportChange);\n window.addEventListener(\"scroll\", handleViewportChange, true);\n window.visualViewport?.addEventListener(\"resize\", handleViewportChange);\n window.visualViewport?.addEventListener(\"scroll\", handleViewportChange);\n const resizeObserver = typeof ResizeObserver === \"undefined\"\n ? null\n : new ResizeObserver(update);\n if (anchorRef.current) resizeObserver?.observe(anchorRef.current);\n resizeObserver?.observe(popup);\n return () => {\n cancelAnimationFrame(frame);\n window.removeEventListener(\"resize\", handleViewportChange);\n window.removeEventListener(\"scroll\", handleViewportChange, true);\n window.visualViewport?.removeEventListener(\"resize\", handleViewportChange);\n window.visualViewport?.removeEventListener(\"scroll\", handleViewportChange);\n resizeObserver?.disconnect();\n };\n }, [align, anchorRef, popup, update]);\n\n return position;\n}\n"]}
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC3B,MAAM,2DAA2D,CAAC;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAErF,OAAO,EAQL,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAMf,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,eAAe,IAAI,OAAO,CAAC;CAC5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ANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { resolveDesignSystemProviderValue, validateDesignSystemProviderValue, } from "@hjmds/design-contracts/components/design-system-provider";
|
|
2
|
+
import { isLargeTextScale, resolveDesignSystemProviderValue, validateDesignSystemProviderValue, } from "@hjmds/design-contracts/components/design-system-provider";
|
|
3
3
|
import { tooltipBehaviorDefaults } from "@hjmds/design-contracts/components/tooltip";
|
|
4
4
|
import { createContext, forwardRef, useCallback, useContext, useRef, useState, useSyncExternalStore, } from "react";
|
|
5
5
|
import { classNames } from "./internal.js";
|
|
@@ -68,7 +68,13 @@ export const HjmProvider = forwardRef(function HjmProvider({ children, theme, di
|
|
|
68
68
|
deactivate: deactivateTooltip,
|
|
69
69
|
shouldSkipDelay: shouldSkipTooltipDelay,
|
|
70
70
|
};
|
|
71
|
-
|
|
71
|
+
// `data-text-scale` is a number, so a stylesheet cannot ask whether it crossed
|
|
72
|
+
// `largeTextThreshold`. The provider resolves that comparison once and publishes
|
|
73
|
+
// the answer; letting each renderer read the environment instead would pull this
|
|
74
|
+
// module into granular entries like ./selection and blow their gzip budgets.
|
|
75
|
+
// See issue #20.
|
|
76
|
+
const largeText = isLargeTextScale(environment.textScale) ? "true" : undefined;
|
|
77
|
+
return (_jsx(HjmThemeContext.Provider, { value: value, children: _jsx(TooltipCoordinatorContext.Provider, { value: tooltipCoordinator, children: _jsx("div", { ...rest, ref: ref, className: classNames("hjm-root", className), "data-hjm-provider": "", "data-host": host, "data-motion": environment.reducedMotion ? "reduced" : "full", "data-theme": environment.theme, "data-text-scale": environment.textScale, "data-large-text": largeText, dir: environment.direction, style: { ...createHjmThemeStyle(value), ...style }, children: children }) }) }));
|
|
72
78
|
});
|
|
73
79
|
export function useHjmTheme() {
|
|
74
80
|
const value = useContext(HjmThemeContext);
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","source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ACrC,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,qBAAqB;IACnC,OAAO,UAAU,CAAC,yBAAyB,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import {\n resolveDesignSystemProviderValue,\n validateDesignSystemProviderValue,\n type DesignSystemDirection,\n type DesignSystemProviderValue,\n type DesignSystemTextScale,\n} from \"@hjmds/design-contracts/components/design-system-provider\";\nimport type { ResolvedTheme, ThemePreference } from \"@hjmds/design-contracts/colors\";\nimport { tooltipBehaviorDefaults } from \"@hjmds/design-contracts/components/tooltip\";\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useRef,\n useState,\n useSyncExternalStore,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { classNames } from \"./internal.js\";\nimport { createHjmThemeStyle } from \"./theme.js\";\n\nconst HjmThemeContext = createContext<DesignSystemProviderValue | null>(null);\n\nexport type TooltipCoordinator = Readonly<{\n activeId: string | null;\n activate(id: string): void;\n deactivate(id: string): void;\n shouldSkipDelay(): boolean;\n}>;\n\nconst TooltipCoordinatorContext = createContext<TooltipCoordinator | null>(null);\n\nfunction subscribeMedia(query: string, callback: () => void): () => void {\n const media = window.matchMedia(query);\n media.addEventListener(\"change\", callback);\n return () => media.removeEventListener(\"change\", callback);\n}\n\nfunction useMediaQuery(query: string, observe = true): boolean {\n return useSyncExternalStore(\n (callback) => observe ? subscribeMedia(query, callback) : () => undefined,\n () => observe && window.matchMedia(query).matches,\n () => false,\n );\n}\n\ntype HjmProviderEnvironmentProps = Readonly<{\n value?: never;\n theme?: ThemePreference;\n direction?: DesignSystemDirection;\n textScale?: DesignSystemTextScale;\n reducedMotion?: boolean;\n minimumVisualTarget?: boolean;\n /** Deterministic SSR/test override; otherwise prefers-color-scheme is observed. */\n systemTheme?: ResolvedTheme;\n}>;\n\ntype HjmProviderValueProps = Readonly<{\n /** Complete, validated environment and semantic product palette. */\n value: DesignSystemProviderValue;\n theme?: never;\n direction?: never;\n textScale?: never;\n reducedMotion?: never;\n minimumVisualTarget?: never;\n systemTheme?: never;\n}>;\n\n/**\n * How the provider's own host element participates in layout and painting.\n *\n * `surface` (default) paints the HJM background, text color and UI typography,\n * which is what a page whose root *is* the provider needs. A product whose\n * document root already paints its surface previously had to neutralise the\n * host with an inline `display: contents` style, re-entering product code into\n * the renderer boundary; `contents` is that intent as a supported axis — the\n * element still carries the CSS variables, `dir` and data attributes.\n */\nexport type HjmProviderHost = \"surface\" | \"contents\";\n\nexport type HjmProviderProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n \"children\" | \"dir\"\n> &\n Readonly<{\n children: ReactNode;\n host?: HjmProviderHost;\n }> & (HjmProviderEnvironmentProps | HjmProviderValueProps);\n\nexport const HjmProvider = forwardRef<HTMLDivElement, HjmProviderProps>(\n function HjmProvider(\n {\n children,\n theme,\n direction,\n textScale,\n reducedMotion,\n minimumVisualTarget,\n systemTheme,\n host = \"surface\",\n value: suppliedValue,\n className,\n style,\n ...rest\n },\n ref,\n ) {\n const parent = useContext(HjmThemeContext);\n const observesSystem = suppliedValue === undefined;\n const prefersDark = useMediaQuery(\"(prefers-color-scheme: dark)\", observesSystem);\n const prefersReducedMotion = useMediaQuery(\n \"(prefers-reduced-motion: reduce)\",\n observesSystem,\n );\n const resolvedSystemTheme = systemTheme ?? (prefersDark ? \"dark\" : \"light\");\n const input = {\n ...(theme === undefined ? {} : { theme }),\n ...(direction === undefined ? {} : { direction }),\n ...(textScale === undefined ? {} : { textScale }),\n ...(reducedMotion === undefined ? {} : { reducedMotion }),\n ...(minimumVisualTarget === undefined ? {} : { minimumVisualTarget }),\n };\n const value = suppliedValue ?? resolveDesignSystemProviderValue(input, {\n systemTheme: resolvedSystemTheme,\n ...(parent === null ? {} : { parent: parent.environment }),\n ...(reducedMotion === undefined && parent === null\n ? { systemReducedMotion: prefersReducedMotion }\n : {}),\n });\n validateDesignSystemProviderValue(value);\n const environment = value.environment;\n const [activeTooltipId, setActiveTooltipId] = useState<string | null>(null);\n const activeTooltipIdRef = useRef<string | null>(null);\n const lastTooltipTransitionAtRef = useRef(Number.NEGATIVE_INFINITY);\n activeTooltipIdRef.current = activeTooltipId;\n const activateTooltip = useCallback((id: string) => {\n setActiveTooltipId((current) => {\n if (current === id) return current;\n if (current !== null) lastTooltipTransitionAtRef.current = Date.now();\n activeTooltipIdRef.current = id;\n return id;\n });\n }, []);\n const deactivateTooltip = useCallback((id: string) => {\n setActiveTooltipId((current) => {\n if (current !== id) return current;\n lastTooltipTransitionAtRef.current = Date.now();\n activeTooltipIdRef.current = null;\n return null;\n });\n }, []);\n const shouldSkipTooltipDelay = useCallback(\n () =>\n activeTooltipIdRef.current !== null ||\n Date.now() - lastTooltipTransitionAtRef.current <\n tooltipBehaviorDefaults.skipDelayMs,\n [],\n );\n const tooltipCoordinator: TooltipCoordinator = {\n activeId: activeTooltipId,\n activate: activateTooltip,\n deactivate: deactivateTooltip,\n shouldSkipDelay: shouldSkipTooltipDelay,\n };\n\n return (\n <HjmThemeContext.Provider value={value}>\n <TooltipCoordinatorContext.Provider value={tooltipCoordinator}>\n <div\n {...rest}\n ref={ref}\n className={classNames(\"hjm-root\", className)}\n data-hjm-provider=\"\"\n data-host={host}\n data-motion={environment.reducedMotion ? \"reduced\" : \"full\"}\n data-theme={environment.theme}\n data-text-scale={environment.textScale}\n dir={environment.direction}\n style={{ ...createHjmThemeStyle(value), ...style }}\n >\n {children}\n </div>\n </TooltipCoordinatorContext.Provider>\n </HjmThemeContext.Provider>\n );\n },\n);\n\nexport function useHjmTheme(): DesignSystemProviderValue {\n const value = useContext(HjmThemeContext);\n if (value === null) {\n throw new Error(\"useHjmTheme must be used inside HjmProvider\");\n }\n return value;\n}\n\n/** Renderer components use the browser default direction when no provider is present. */\nexport function useOptionalHjmTheme(): DesignSystemProviderValue | null {\n return useContext(HjmThemeContext);\n}\n\n/** Internal provider-scoped coordination used by Tooltip renderers. */\nexport function useTooltipCoordinator(): TooltipCoordinator | null {\n return useContext(TooltipCoordinatorContext);\n}\n"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GAAG,UAAU,CAAC,eAAe,CAAC,CAAC;IAC1C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,mBAAmB;IACjC,OAAO,UAAU,CAAC,eAAe,CAAC,CAAC;AACrC,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,qBAAqB;IACnC,OAAO,UAAU,CAAC,yBAAyB,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import {\n isLargeTextScale,\n resolveDesignSystemProviderValue,\n validateDesignSystemProviderValue,\n type DesignSystemDirection,\n type DesignSystemProviderValue,\n type DesignSystemTextScale,\n} from \"@hjmds/design-contracts/components/design-system-provider\";\nimport type { ResolvedTheme, ThemePreference } from \"@hjmds/design-contracts/colors\";\nimport { tooltipBehaviorDefaults } from \"@hjmds/design-contracts/components/tooltip\";\nimport {\n createContext,\n forwardRef,\n useCallback,\n useContext,\n useRef,\n useState,\n useSyncExternalStore,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { classNames } from \"./internal.js\";\nimport { createHjmThemeStyle } from \"./theme.js\";\n\nconst HjmThemeContext = createContext<DesignSystemProviderValue | null>(null);\n\nexport type TooltipCoordinator = Readonly<{\n activeId: string | null;\n activate(id: string): void;\n deactivate(id: string): void;\n shouldSkipDelay(): boolean;\n}>;\n\nconst TooltipCoordinatorContext = createContext<TooltipCoordinator | null>(null);\n\nfunction subscribeMedia(query: string, callback: () => void): () => void {\n const media = window.matchMedia(query);\n media.addEventListener(\"change\", callback);\n return () => media.removeEventListener(\"change\", callback);\n}\n\nfunction useMediaQuery(query: string, observe = true): boolean {\n return useSyncExternalStore(\n (callback) => observe ? subscribeMedia(query, callback) : () => undefined,\n () => observe && window.matchMedia(query).matches,\n () => false,\n );\n}\n\ntype HjmProviderEnvironmentProps = Readonly<{\n value?: never;\n theme?: ThemePreference;\n direction?: DesignSystemDirection;\n textScale?: DesignSystemTextScale;\n reducedMotion?: boolean;\n minimumVisualTarget?: boolean;\n /** Deterministic SSR/test override; otherwise prefers-color-scheme is observed. */\n systemTheme?: ResolvedTheme;\n}>;\n\ntype HjmProviderValueProps = Readonly<{\n /** Complete, validated environment and semantic product palette. */\n value: DesignSystemProviderValue;\n theme?: never;\n direction?: never;\n textScale?: never;\n reducedMotion?: never;\n minimumVisualTarget?: never;\n systemTheme?: never;\n}>;\n\n/**\n * How the provider's own host element participates in layout and painting.\n *\n * `surface` (default) paints the HJM background, text color and UI typography,\n * which is what a page whose root *is* the provider needs. A product whose\n * document root already paints its surface previously had to neutralise the\n * host with an inline `display: contents` style, re-entering product code into\n * the renderer boundary; `contents` is that intent as a supported axis — the\n * element still carries the CSS variables, `dir` and data attributes.\n */\nexport type HjmProviderHost = \"surface\" | \"contents\";\n\nexport type HjmProviderProps = Omit<\n HTMLAttributes<HTMLDivElement>,\n \"children\" | \"dir\"\n> &\n Readonly<{\n children: ReactNode;\n host?: HjmProviderHost;\n }> & (HjmProviderEnvironmentProps | HjmProviderValueProps);\n\nexport const HjmProvider = forwardRef<HTMLDivElement, HjmProviderProps>(\n function HjmProvider(\n {\n children,\n theme,\n direction,\n textScale,\n reducedMotion,\n minimumVisualTarget,\n systemTheme,\n host = \"surface\",\n value: suppliedValue,\n className,\n style,\n ...rest\n },\n ref,\n ) {\n const parent = useContext(HjmThemeContext);\n const observesSystem = suppliedValue === undefined;\n const prefersDark = useMediaQuery(\"(prefers-color-scheme: dark)\", observesSystem);\n const prefersReducedMotion = useMediaQuery(\n \"(prefers-reduced-motion: reduce)\",\n observesSystem,\n );\n const resolvedSystemTheme = systemTheme ?? (prefersDark ? \"dark\" : \"light\");\n const input = {\n ...(theme === undefined ? {} : { theme }),\n ...(direction === undefined ? {} : { direction }),\n ...(textScale === undefined ? {} : { textScale }),\n ...(reducedMotion === undefined ? {} : { reducedMotion }),\n ...(minimumVisualTarget === undefined ? {} : { minimumVisualTarget }),\n };\n const value = suppliedValue ?? resolveDesignSystemProviderValue(input, {\n systemTheme: resolvedSystemTheme,\n ...(parent === null ? {} : { parent: parent.environment }),\n ...(reducedMotion === undefined && parent === null\n ? { systemReducedMotion: prefersReducedMotion }\n : {}),\n });\n validateDesignSystemProviderValue(value);\n const environment = value.environment;\n const [activeTooltipId, setActiveTooltipId] = useState<string | null>(null);\n const activeTooltipIdRef = useRef<string | null>(null);\n const lastTooltipTransitionAtRef = useRef(Number.NEGATIVE_INFINITY);\n activeTooltipIdRef.current = activeTooltipId;\n const activateTooltip = useCallback((id: string) => {\n setActiveTooltipId((current) => {\n if (current === id) return current;\n if (current !== null) lastTooltipTransitionAtRef.current = Date.now();\n activeTooltipIdRef.current = id;\n return id;\n });\n }, []);\n const deactivateTooltip = useCallback((id: string) => {\n setActiveTooltipId((current) => {\n if (current !== id) return current;\n lastTooltipTransitionAtRef.current = Date.now();\n activeTooltipIdRef.current = null;\n return null;\n });\n }, []);\n const shouldSkipTooltipDelay = useCallback(\n () =>\n activeTooltipIdRef.current !== null ||\n Date.now() - lastTooltipTransitionAtRef.current <\n tooltipBehaviorDefaults.skipDelayMs,\n [],\n );\n const tooltipCoordinator: TooltipCoordinator = {\n activeId: activeTooltipId,\n activate: activateTooltip,\n deactivate: deactivateTooltip,\n shouldSkipDelay: shouldSkipTooltipDelay,\n };\n\n // `data-text-scale` is a number, so a stylesheet cannot ask whether it crossed\n // `largeTextThreshold`. The provider resolves that comparison once and publishes\n // the answer; letting each renderer read the environment instead would pull this\n // module into granular entries like ./selection and blow their gzip budgets.\n // See issue #20.\n const largeText = isLargeTextScale(environment.textScale) ? \"true\" : undefined;\n\n return (\n <HjmThemeContext.Provider value={value}>\n <TooltipCoordinatorContext.Provider value={tooltipCoordinator}>\n <div\n {...rest}\n ref={ref}\n className={classNames(\"hjm-root\", className)}\n data-hjm-provider=\"\"\n data-host={host}\n data-motion={environment.reducedMotion ? \"reduced\" : \"full\"}\n data-theme={environment.theme}\n data-text-scale={environment.textScale}\n data-large-text={largeText}\n dir={environment.direction}\n style={{ ...createHjmThemeStyle(value), ...style }}\n >\n {children}\n </div>\n </TooltipCoordinatorContext.Provider>\n </HjmThemeContext.Provider>\n );\n },\n);\n\nexport function useHjmTheme(): DesignSystemProviderValue {\n const value = useContext(HjmThemeContext);\n if (value === null) {\n throw new Error(\"useHjmTheme must be used inside HjmProvider\");\n }\n return value;\n}\n\n/** Renderer components use the browser default direction when no provider is present. */\nexport function useOptionalHjmTheme(): DesignSystemProviderValue | null {\n return useContext(HjmThemeContext);\n}\n\n/** Internal provider-scoped coordination used by Tooltip renderers. */\nexport function useTooltipCoordinator(): TooltipCoordinator | null {\n return useContext(TooltipCoordinatorContext);\n}\n"]}
|
package/dist/select.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../src/select.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,iCAAiC,EACtC,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC5B,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAE1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAOL,KAAK,oBAAoB,EAGzB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAEf,OAAO,EAGL,KAAK,kBAAkB,EACxB,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,UAAU,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,IAAI,oBAAoB,CAAC,GAAG,CAAC,CAAC;AAChF,MAAM,MAAM,aAAa,CACvB,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,UAAU,SAAS,MAAM,GAAG,MAAM,IAChC,iCAAiC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EAAE,wBAAwB,KACjC,SAAS,CAAC;IACf,mBAAmB,CAAC,EAAE,CACpB,IAAI,EAAE,oBAAoB,CAAC,GAAG,CAAC,EAC/B,UAAU,EAAE,8BAA8B,KACvC,SAAS,CAAC;CAChB,CAAC,CAAC;AAEL,MAAM,MAAM,WAAW,CACrB,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,UAAU,SAAS,MAAM,GAAG,MAAM,IAChC,eAAe,CAAC,GAAG,CAAC,GACtB,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,GAClC,oBAAoB,CAAC,GAAG,CAAC,GACzB,eAAe,GACf,gBAAgB,CAAC;AA4jBnB,eAAO,MAAM,MAAM,EAA8B,CAC/C,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,UAAU,SAAS,MAAM,GAAG,MAAM,EAElC,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,aAAa,CAAC,iBAAiB,CAAC,KACnE,YAAY,GAAG,IAAI,CAAC"}
|
package/dist/select.js
CHANGED
|
@@ -164,7 +164,11 @@ function SelectInner(props, forwardedRef) {
|
|
|
164
164
|
? selectedInSource.id
|
|
165
165
|
: reconciledSelectedKey === null && emptySelectionAvailable
|
|
166
166
|
? emptySelectionKey
|
|
167
|
-
|
|
167
|
+
// The empty-selection entry renders first in the listbox, so only the
|
|
168
|
+
// "first" intent (Home/ArrowDown on a closed trigger) lands on it; "last"
|
|
169
|
+
// (End/ArrowUp) must reach the last real option. The previous mapping sent
|
|
170
|
+
// "last" to the empty entry, which contradicted DOM order. See issue #18.
|
|
171
|
+
: intent === "first" && emptySelectionAvailable
|
|
168
172
|
? emptySelectionKey
|
|
169
173
|
: getCollectionNavigationTarget(source, null, intent, loop) ?? null;
|
|
170
174
|
setHighlightedKey(target);
|
|
@@ -176,27 +180,39 @@ function SelectInner(props, forwardedRef) {
|
|
|
176
180
|
.map((item) => item.id);
|
|
177
181
|
const firstKey = enabledKeys[0];
|
|
178
182
|
const lastKey = enabledKeys.at(-1);
|
|
183
|
+
// Treat the empty-selection entry as the first row, matching DOM order. `loop`
|
|
184
|
+
// only joins the two ends of the list: moving between the empty entry and the
|
|
185
|
+
// first option is adjacency, not a wrap, so it stays loop-independent. The
|
|
186
|
+
// previous code gated that "next" on `loop`, which trapped the arrow keys on the
|
|
187
|
+
// empty entry for every Select using the defaults (disallowEmptySelection: false,
|
|
188
|
+
// loop: false). See issue #18.
|
|
179
189
|
if (emptySelectionAvailable) {
|
|
180
|
-
if (intent === "
|
|
190
|
+
if (intent === "first") {
|
|
181
191
|
setHighlightedKey(emptySelectionKey);
|
|
182
192
|
return;
|
|
183
193
|
}
|
|
184
194
|
if (activeKey === emptySelectionKey) {
|
|
185
|
-
if (intent === "
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
setHighlightedKey(firstKey);
|
|
195
|
+
if (intent === "next") {
|
|
196
|
+
if (firstKey !== undefined)
|
|
197
|
+
setHighlightedKey(firstKey);
|
|
198
|
+
return;
|
|
190
199
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
200
|
+
if (intent === "previous") {
|
|
201
|
+
if (loop && lastKey !== undefined)
|
|
202
|
+
setHighlightedKey(lastKey);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
// intent === "last" falls through: the shared path picks the last option.
|
|
196
206
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
207
|
+
else {
|
|
208
|
+
if (intent === "previous" && activeKey === firstKey) {
|
|
209
|
+
setHighlightedKey(emptySelectionKey);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (intent === "next" && activeKey === lastKey && loop) {
|
|
213
|
+
setHighlightedKey(emptySelectionKey);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
200
216
|
}
|
|
201
217
|
}
|
|
202
218
|
const target = getCollectionNavigationTarget(source, activeKey === emptySelectionKey ? null : activeKey, intent, loop);
|
|
@@ -339,15 +355,15 @@ function SelectInner(props, forwardedRef) {
|
|
|
339
355
|
changeOpen(false, "trigger");
|
|
340
356
|
else
|
|
341
357
|
openWithIntent();
|
|
342
|
-
}, children: [triggerLeading ? (_jsx("span", { className: "hjm-select__leading", "aria-hidden": "true", children: triggerLeading })) : null, _jsx("span", { className: "hjm-select__value", "data-state": resolvedSelectedItem ? "selected" : "placeholder", children: resolvedSelectedItem?.label ?? placeholder }), busy ? (_jsx("span", { className: "hjm-select__busy-indicator", "aria-hidden": "true" })) : (_jsx("span", { className: "hjm-select__indicator", "aria-hidden": "true", children: "\u2304" }))] }), open ? (_jsx(AnchoredPortal, { anchorRef: triggerRef, ssrFallback: "inline", ...(portalContainer === undefined ? {} : { container: portalContainer }), children: _jsxs("div", { ref: setListboxRef, id: listboxId, role: "listbox", "aria-label": accessibleName, className: "hjm-select__listbox", "data-density": density, "data-placement": popupPosition.placement, "data-align": popupPosition.align, style: popupPosition.style, children: [asyncState.status !== "idle" ? (_jsx("div", { className: "hjm-select__message", role: asyncState.status === "error" ? "alert" : "status", children: asyncState.message })) : null, showOptions ? (
|
|
343
|
-
const sectionLabelId = `${controlId}-section-${section.id}`;
|
|
344
|
-
return (_jsxs("div", { role: "group", "aria-labelledby": section.label ? sectionLabelId : undefined, "aria-label": section.label ? undefined : section.accessibilityLabel, className: "hjm-select__section", children: [section.label ? (_jsx("div", { id: sectionLabelId, className: "hjm-select__section-label", children: section.label })) : null, section.items.map(renderOption)] }, section.id));
|
|
345
|
-
}) : source.items.map(renderOption)) : null, !disallowEmptySelection && showOptions ? (_jsx("div", { ref: (node) => {
|
|
358
|
+
}, children: [triggerLeading ? (_jsx("span", { className: "hjm-select__leading", "aria-hidden": "true", children: triggerLeading })) : null, _jsx("span", { className: "hjm-select__value", "data-state": resolvedSelectedItem ? "selected" : "placeholder", children: resolvedSelectedItem?.label ?? placeholder }), busy ? (_jsx("span", { className: "hjm-select__busy-indicator", "aria-hidden": "true" })) : (_jsx("span", { className: "hjm-select__indicator", "aria-hidden": "true", children: "\u2304" }))] }), open ? (_jsx(AnchoredPortal, { anchorRef: triggerRef, ssrFallback: "inline", ...(portalContainer === undefined ? {} : { container: portalContainer }), children: _jsxs("div", { ref: setListboxRef, id: listboxId, role: "listbox", "aria-label": accessibleName, className: "hjm-select__listbox", "data-density": density, "data-placement": popupPosition.placement, "data-align": popupPosition.align, style: popupPosition.style, children: [asyncState.status !== "idle" ? (_jsx("div", { className: "hjm-select__message", role: asyncState.status === "error" ? "alert" : "status", children: asyncState.message })) : null, !disallowEmptySelection && showOptions ? (_jsx("div", { ref: (node) => {
|
|
346
359
|
if (node)
|
|
347
360
|
optionRefs.current.set(emptySelectionKey, node);
|
|
348
361
|
else
|
|
349
362
|
optionRefs.current.delete(emptySelectionKey);
|
|
350
|
-
}, id: `${controlId}-option-empty`, role: "option", className: "hjm-select__option hjm-select__option--empty", "aria-selected": reconciledSelectedKey === null, "data-state": reconciledSelectedKey === null ? "selected" : "idle", "data-active": activeKey === emptySelectionKey || undefined, onMouseDown: (event) => event.preventDefault(), onMouseMove: () => setHighlightedKey(emptySelectionKey), onClick: () => commit(emptySelectionKey), children: emptySelectionLabel })) : null
|
|
363
|
+
}, id: `${controlId}-option-empty`, role: "option", className: "hjm-select__option hjm-select__option--empty", "aria-selected": reconciledSelectedKey === null, "data-state": reconciledSelectedKey === null ? "selected" : "idle", "data-active": activeKey === emptySelectionKey || undefined, onMouseDown: (event) => event.preventDefault(), onMouseMove: () => setHighlightedKey(emptySelectionKey), onClick: () => commit(emptySelectionKey), children: emptySelectionLabel })) : null, showOptions ? (source.sections ? source.sections.map((section) => {
|
|
364
|
+
const sectionLabelId = `${controlId}-section-${section.id}`;
|
|
365
|
+
return (_jsxs("div", { role: "group", "aria-labelledby": section.label ? sectionLabelId : undefined, "aria-label": section.label ? undefined : section.accessibilityLabel, className: "hjm-select__section", children: [section.label ? (_jsx("div", { id: sectionLabelId, className: "hjm-select__section-label", children: section.label })) : null, section.items.map(renderOption)] }, section.id));
|
|
366
|
+
}) : source.items.map(renderOption)) : null] }) })) : null] }), description && !error ? (_jsx("div", { id: descriptionId, className: "hjm-field__description", children: description })) : null, error ? _jsx("div", { id: errorId, className: "hjm-field__error", children: error }) : null, name ? _jsx("input", { type: "hidden", name: name, value: reconciledSelectedKey ?? "" }) : null] }));
|
|
351
367
|
}
|
|
352
368
|
export const Select = forwardRef(SelectInner);
|
|
353
369
|
//# sourceMappingURL=select.js.map
|
package/dist/select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../src/select.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7B,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,GAInB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,GAIvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,UAAU,EACV,YAAY,GAGb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,UAAU,EACV,WAAW,EACX,SAAS,EACT,KAAK,EACL,MAAM,EACN,QAAQ,GAOT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EACL,cAAc,EACd,gBAAgB,GAEjB,MAAM,aAAa,CAAC;AAoBrB,MAAM,iBAAiB,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC;AAoF/D,SAAS,WAAW,CAClB,KAAmC,EACnC,YAAmD;IAEnD,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,EACL,kBAAkB,EAClB,WAAW,EACX,KAAK,EACL,WAAW,EACX,mBAAmB,EACnB,UAAU,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAC/B,YAAY,EACZ,sBAAsB,GAAG,sBAAsB,CAAC,sBAAsB,EACtE,IAA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SelectSelection,\n resolveCollectionItem,\n resolveSelectSelectedItem,\n validateCollection,\n type SelectCollectionSectionDescriptor,\n type SelectCollectionSource,\n type SelectOpenChangeReason,\n} from \"@hjmds/design-contracts/components/collection\";\nimport {\n resolveControlAccessibleName,\n selectBehaviorDefaults,\n type AsyncCollectionState,\n type SelectItemDescriptor,\n type WebKeyboardKey,\n} from \"@hjmds/design-contracts/behaviors\";\nimport {\n iconRecipe,\n selectRecipe,\n type SelectDensity,\n type SelectSize,\n} from \"@hjmds/design-contracts/recipes\";\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type FocusEvent,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n type RefAttributes,\n} from \"react\";\nimport { classNames, useControllableState } from \"./internal.js\";\nimport {\n AnchoredPortal,\n useAnchoredPopup,\n type AnchoredPopupAlign,\n} from \"./portal.js\";\n\nexport type SelectItem<Key extends string = string> = SelectItemDescriptor<Key>;\nexport type SelectSection<\n Key extends string = string,\n SectionKey extends string = string,\n> = SelectCollectionSectionDescriptor<Key, SectionKey>;\n\nexport type SelectLeadingRenderProps = Readonly<{\n color: \"currentColor\";\n size: number;\n glyphSize: number;\n}>;\n\nexport type SelectOptionLeadingRenderProps = SelectLeadingRenderProps & Readonly<{\n selected: boolean;\n highlighted: boolean;\n disabled: boolean;\n}>;\n\nconst emptySelectionKey = Symbol(\"hjm-select-empty-selection\");\ntype SelectHighlightKey<Key extends string> = Key | typeof emptySelectionKey;\n\ntype SelectSourceProps<Key extends string, SectionKey extends string> =\n SelectCollectionSource<Key, SectionKey>;\n\ntype SelectSelectionProps<Key extends string> =\n | Readonly<{\n selectedKey: Key | null;\n defaultSelectedKey?: never;\n onSelectionChange(key: Key | null): void;\n }>\n | Readonly<{\n selectedKey?: never;\n defaultSelectedKey?: Key | null;\n onSelectionChange?: (key: Key | null) => void;\n }>;\n\ntype SelectOpenProps =\n | Readonly<{\n open: boolean;\n defaultOpen?: never;\n onOpenChange(open: boolean, reason: SelectOpenChangeReason): void;\n }>\n | Readonly<{\n open?: never;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean, reason: SelectOpenChangeReason) => void;\n }>;\n\ntype SelectLabelProps =\n | Readonly<{ label: string; accessibilityLabel?: string }>\n | Readonly<{ label?: never; accessibilityLabel: string }>;\n\ntype SelectBaseProps<Key extends string> = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n | \"aria-label\"\n | \"children\"\n | \"defaultValue\"\n | \"onChange\"\n | \"role\"\n | \"value\"\n> &\n Readonly<{\n description?: ReactNode;\n error?: ReactNode;\n /** Localized text shown when no item is selected. */\n placeholder: string;\n /** Localized label for the nullable empty-selection option. */\n emptySelectionLabel: string;\n asyncState?: AsyncCollectionState;\n selectedItem?: SelectItemDescriptor<Key>;\n disallowEmptySelection?: boolean;\n loop?: boolean;\n /** Locks interaction without removing the trigger from the focus order. */\n busy?: boolean;\n readOnly?: boolean;\n required?: boolean;\n size?: SelectSize;\n density?: SelectDensity;\n /** Logical listbox alignment against the trigger; automatically mirrors in RTL. */\n align?: AnchoredPopupAlign;\n fieldClassName?: string;\n portalContainer?: HTMLElement;\n locale?: string | readonly string[];\n renderLeading?: (\n item: SelectItemDescriptor<Key> | null,\n appearance: SelectLeadingRenderProps,\n ) => ReactNode;\n renderOptionLeading?: (\n item: SelectItemDescriptor<Key>,\n appearance: SelectOptionLeadingRenderProps,\n ) => ReactNode;\n }>;\n\nexport type SelectProps<\n Key extends string = string,\n SectionKey extends string = string,\n> = SelectBaseProps<Key> &\n SelectSourceProps<Key, SectionKey> &\n SelectSelectionProps<Key> &\n SelectOpenProps &\n SelectLabelProps;\n\nfunction SelectInner<Key extends string, SectionKey extends string>(\n props: SelectProps<Key, SectionKey>,\n forwardedRef: React.ForwardedRef<HTMLButtonElement>,\n) {\n const {\n items,\n sections,\n label,\n accessibilityLabel,\n description,\n error,\n placeholder,\n emptySelectionLabel,\n asyncState = { status: \"idle\" },\n selectedItem,\n disallowEmptySelection = selectBehaviorDefaults.disallowEmptySelection,\n loop = selectBehaviorDefaults.loop,\n busy = false,\n readOnly = false,\n size = selectRecipe.defaults.size,\n density = selectRecipe.defaults.density,\n align = \"start\",\n fieldClassName,\n portalContainer,\n locale,\n renderLeading,\n renderOptionLeading,\n className,\n id: idProp,\n name,\n disabled = false,\n required = false,\n selectedKey: selectedKeyProp,\n defaultSelectedKey,\n onSelectionChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n onClick,\n onFocus,\n onBlur,\n onKeyDown,\n ...buttonProps\n } = props;\n const source: SelectCollectionSource<Key, SectionKey> = sections === undefined\n ? { items: items ?? [] }\n : { sections };\n validateCollection(source);\n const accessibleName = resolveControlAccessibleName(\n label,\n accessibilityLabel,\n \"Select\",\n );\n if (placeholder.trim().length === 0) throw new TypeError(\"Select placeholder must not be empty\");\n if (emptySelectionLabel.trim().length === 0) {\n throw new TypeError(\"Select emptySelectionLabel must not be empty\");\n }\n const flatItems = source.sections\n ? source.sections.flatMap((section) => section.items)\n : source.items;\n if (\n flatItems.length === 0 &&\n (asyncState.status === \"idle\" || asyncState.status === \"loadingMore\")\n ) {\n throw new TypeError(\"Select requires options unless its async state is transient or empty\");\n }\n const initialSelectionRef = useRef<Readonly<{ value: Key | null }> | null>(null);\n if (initialSelectionRef.current === null) {\n initialSelectionRef.current = {\n value: reconcileSelectSelection(\n source,\n selectedKeyProp ?? defaultSelectedKey ?? null,\n {\n disallowEmptySelection,\n asyncState,\n ...(selectedItem === undefined ? {} : { selectedItem }),\n },\n ),\n };\n }\n const [storedSelectedKey, setSelectedKey] = useControllableState<Key | null>({\n ...(selectedKeyProp === undefined ? {} : { value: selectedKeyProp }),\n defaultValue: initialSelectionRef.current.value,\n ...(onSelectionChange === undefined ? {} : { onChange: onSelectionChange }),\n });\n const reconciledSelectedKey = reconcileSelectSelection(source, storedSelectedKey, {\n disallowEmptySelection,\n asyncState,\n ...(selectedItem === undefined ? {} : { selectedItem }),\n });\n const reconciliationRequestRef = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (storedSelectedKey === reconciledSelectedKey) {\n reconciliationRequestRef.current = undefined;\n return;\n }\n const token = `${storedSelectedKey ?? \"<empty>\"}->${reconciledSelectedKey ?? \"<empty>\"}`;\n if (reconciliationRequestRef.current === token) return;\n reconciliationRequestRef.current = token;\n setSelectedKey(reconciledSelectedKey);\n }, [reconciledSelectedKey, setSelectedKey, storedSelectedKey]);\n const resolvedSelectedItem = resolveSelectSelectedItem(\n source,\n reconciledSelectedKey,\n selectedItem !== undefined && selectedItem.id === reconciledSelectedKey\n ? selectedItem\n : undefined,\n );\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const openControlled = openProp !== undefined;\n const open = openControlled ? openProp : internalOpen;\n const pendingOpenRequestRef = useRef<boolean | undefined>(undefined);\n useEffect(() => {\n if (pendingOpenRequestRef.current === open) pendingOpenRequestRef.current = undefined;\n }, [open]);\n const changeOpen = useCallback(\n (nextOpen: boolean, reason: SelectOpenChangeReason) => {\n if (nextOpen === open || pendingOpenRequestRef.current === nextOpen) return;\n pendingOpenRequestRef.current = nextOpen;\n if (!openControlled) setInternalOpen(nextOpen);\n onOpenChange?.(nextOpen, reason);\n if (openControlled && nextOpen) {\n queueMicrotask(() => {\n if (pendingOpenRequestRef.current === true) {\n pendingOpenRequestRef.current = undefined;\n }\n });\n }\n },\n [onOpenChange, open, openControlled],\n );\n\n const generatedId = useId().replaceAll(\":\", \"\");\n const controlId = idProp ?? `hjm-select-${generatedId}`;\n const listboxId = `${controlId}-listbox`;\n const descriptionId = `${controlId}-description`;\n const errorId = `${controlId}-error`;\n const optionId = (key: Key) =>\n `${controlId}-option-${flatItems.findIndex((item) => item.id === key)}`;\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const listboxRef = useRef<HTMLDivElement | null>(null);\n const [listboxNode, setListboxNode] = useState<HTMLDivElement | null>(null);\n const optionRefs = useRef(new Map<SelectHighlightKey<Key>, HTMLDivElement>());\n const typeaheadRef = useRef({ value: \"\", time: 0 });\n const restoreFocusRef = useRef(false);\n const showOptions = asyncState.status === \"idle\" || asyncState.status === \"loadingMore\";\n const emptySelectionAvailable = !disallowEmptySelection && showOptions;\n const selectionItemInSource = resolveCollectionItem(source, reconciledSelectedKey);\n const initialHighlight = selectionItemInSource && !selectionItemInSource.disabled\n ? selectionItemInSource.id\n : reconciledSelectedKey === null && emptySelectionAvailable\n ? emptySelectionKey\n : getCollectionNavigationTarget(source, null, \"first\", loop) ?? null;\n const [highlightedKey, setHighlightedKey] = useState<SelectHighlightKey<Key> | null>(\n initialHighlight,\n );\n const highlightedItem = showOptions && highlightedKey !== emptySelectionKey\n ? resolveCollectionItem(source, highlightedKey)\n : null;\n const activeKey: SelectHighlightKey<Key> | null = highlightedItem && !highlightedItem.disabled\n ? highlightedItem.id\n : highlightedKey === emptySelectionKey && emptySelectionAvailable\n ? emptySelectionKey\n : null;\n const activeOptionId = activeKey === emptySelectionKey\n ? `${controlId}-option-empty`\n : activeKey === null\n ? undefined\n : optionId(activeKey);\n const popupPosition = useAnchoredPopup(triggerRef, listboxNode, {\n align,\n matchAnchorWidth: true,\n zIndex: 800,\n });\n const setListboxRef = useCallback((node: HTMLDivElement | null) => {\n listboxRef.current = node;\n setListboxNode(node);\n }, []);\n\n useEffect(() => {\n if (!open) {\n if (restoreFocusRef.current) {\n restoreFocusRef.current = false;\n queueMicrotask(() => triggerRef.current?.focus());\n }\n return;\n }\n if (activeKey === null && showOptions) setHighlightedKey(initialHighlight);\n }, [activeKey, initialHighlight, open, showOptions]);\n useEffect(() => {\n if (open && activeKey !== null) {\n optionRefs.current.get(activeKey)?.scrollIntoView({ block: \"nearest\" });\n }\n }, [activeKey, open]);\n useEffect(() => {\n if (!open) return;\n const handlePointerDown = (event: PointerEvent) => {\n if (\n event.target instanceof Node &&\n !rootRef.current?.contains(event.target) &&\n !listboxRef.current?.contains(event.target)\n ) {\n changeOpen(false, \"outside\");\n }\n };\n document.addEventListener(\"pointerdown\", handlePointerDown);\n return () => document.removeEventListener(\"pointerdown\", handlePointerDown);\n }, [changeOpen, open]);\n\n const openWithIntent = (intent: \"first\" | \"last\" = \"first\") => {\n if (disabled || busy || readOnly) return;\n const selectedInSource = resolveCollectionItem(source, reconciledSelectedKey);\n const target = selectedInSource && !selectedInSource.disabled\n ? selectedInSource.id\n : reconciledSelectedKey === null && emptySelectionAvailable\n ? emptySelectionKey\n : intent === \"last\" && emptySelectionAvailable\n ? emptySelectionKey\n : getCollectionNavigationTarget(source, null, intent, loop) ?? null;\n setHighlightedKey(target);\n changeOpen(true, \"keyboard\");\n };\n const moveHighlight = (intent: \"next\" | \"previous\" | \"first\" | \"last\") => {\n const enabledKeys = flatItems\n .filter((item) => !item.disabled)\n .map((item) => item.id);\n const firstKey = enabledKeys[0];\n const lastKey = enabledKeys.at(-1);\n if (emptySelectionAvailable) {\n if (intent === \"last\") {\n setHighlightedKey(emptySelectionKey);\n return;\n }\n if (activeKey === emptySelectionKey) {\n if (intent === \"previous\" && lastKey !== undefined) setHighlightedKey(lastKey);\n else if (\n ((intent === \"next\" && loop) || intent === \"first\") &&\n firstKey !== undefined\n ) {\n setHighlightedKey(firstKey);\n }\n return;\n }\n if (intent === \"next\" && activeKey === lastKey) {\n setHighlightedKey(emptySelectionKey);\n return;\n }\n if (intent === \"previous\" && activeKey === firstKey && loop) {\n setHighlightedKey(emptySelectionKey);\n return;\n }\n }\n const target = getCollectionNavigationTarget(\n source,\n activeKey === emptySelectionKey ? null : activeKey,\n intent,\n loop,\n );\n if (target !== undefined) setHighlightedKey(target);\n };\n const commit = (key: SelectHighlightKey<Key>) => {\n if (key === emptySelectionKey) {\n if (disabled || readOnly || !emptySelectionAvailable) return;\n setSelectedKey(null);\n restoreFocusRef.current = true;\n changeOpen(false, \"selection\");\n return;\n }\n const item = resolveCollectionItem(source, key);\n if (\n !item ||\n item.disabled ||\n disabled ||\n busy ||\n readOnly ||\n asyncState.status === \"loading\"\n ) return;\n setSelectedKey(key);\n restoreFocusRef.current = true;\n changeOpen(false, \"selection\");\n };\n const runTypeahead = (key: string) => {\n const now = Date.now();\n const previous = now - typeaheadRef.current.time < 500\n ? typeaheadRef.current.value\n : \"\";\n const combined = `${previous}${key}`;\n const query = new Set(combined.toLocaleLowerCase()).size === 1 ? key : combined;\n typeaheadRef.current = { value: combined, time: now };\n const match = getCollectionTypeaheadMatch(source, query, {\n startsAfterKey: activeKey === emptySelectionKey\n ? reconciledSelectedKey\n : activeKey ?? reconciledSelectedKey,\n ...(locale === undefined ? {} : { locale }),\n });\n if (match !== undefined) {\n setHighlightedKey(match);\n if (!open) changeOpen(true, \"keyboard\");\n }\n };\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || disabled || busy || readOnly) return;\n const navigationIntent = getCollectionNavigationIntent(\n event.key as WebKeyboardKey,\n );\n if (navigationIntent !== undefined) {\n event.preventDefault();\n if (!open) {\n openWithIntent(\n navigationIntent === \"previous\" || navigationIntent === \"last\"\n ? \"last\"\n : \"first\",\n );\n }\n else moveHighlight(navigationIntent);\n return;\n }\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n if (!open) openWithIntent();\n else if (activeKey !== null) commit(activeKey);\n } else if (event.key === \"Escape\" && open) {\n event.preventDefault();\n restoreFocusRef.current = true;\n changeOpen(false, \"escape\");\n } else if (event.key === \"Tab\" && open) {\n changeOpen(false, \"blur\");\n } else if (\n event.key.length === 1 &&\n event.key !== \" \" &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey\n ) {\n event.preventDefault();\n runTypeahead(event.key);\n }\n };\n const handleBlur = (event: FocusEvent<HTMLButtonElement>) => {\n onBlur?.(event);\n if (event.defaultPrevented) return;\n queueMicrotask(() => {\n if (\n open &&\n document.activeElement instanceof Node &&\n !rootRef.current?.contains(document.activeElement) &&\n !listboxRef.current?.contains(document.activeElement)\n ) changeOpen(false, \"blur\");\n });\n };\n const describedBy = error ? errorId : description ? descriptionId : undefined;\n\n const renderOption = (item: SelectItemDescriptor<Key>) => {\n const selected = item.id === reconciledSelectedKey;\n const active = item.id === activeKey;\n const leadingSize = iconRecipe.sizes[selectRecipe.optionLeading.glyph];\n const leading = renderOptionLeading?.(item, {\n selected,\n highlighted: active,\n disabled: item.disabled ?? false,\n color: \"currentColor\",\n size: leadingSize,\n glyphSize: leadingSize,\n });\n return (\n <div\n key={item.id}\n ref={(node) => {\n if (node) optionRefs.current.set(item.id, node);\n else optionRefs.current.delete(item.id);\n }}\n id={optionId(item.id)}\n role=\"option\"\n className=\"hjm-select__option\"\n aria-selected={selected}\n aria-disabled={item.disabled || undefined}\n data-state={item.disabled ? \"disabled\" : selected ? \"selected\" : \"idle\"}\n data-active={active || undefined}\n onMouseDown={(event) => event.preventDefault()}\n onMouseMove={() => {\n if (!item.disabled) setHighlightedKey(item.id);\n }}\n onClick={() => commit(item.id)}\n >\n {leading ? (\n <span className=\"hjm-select__option-leading\" aria-hidden=\"true\">\n {leading}\n </span>\n ) : null}\n <span className=\"hjm-select__option-copy\">\n <span>{item.label}</span>\n {item.description ? (\n <span className=\"hjm-select__option-description\">{item.description}</span>\n ) : null}\n </span>\n {selected ? <span className=\"hjm-select__check\" aria-hidden=\"true\">✓</span> : null}\n </div>\n );\n };\n\n const triggerLeadingSize = iconRecipe.sizes[selectRecipe.sizes[size].glyph];\n const triggerLeading = renderLeading?.(resolvedSelectedItem, {\n color: \"currentColor\",\n size: triggerLeadingSize,\n glyphSize: triggerLeadingSize,\n });\n\n return (\n <div\n ref={rootRef}\n className={classNames(\"hjm-field hjm-select\", fieldClassName)}\n data-state={disabled ? \"disabled\" : error ? \"invalid\" : open ? \"focused\" : \"idle\"}\n data-size={size}\n data-density={density}\n data-async-state={asyncState.status}\n data-busy={busy || undefined}\n >\n {label !== undefined ? (\n <label className=\"hjm-field__label\" htmlFor={controlId}>\n {label}{required ? <span aria-hidden=\"true\"> *</span> : null}\n </label>\n ) : null}\n <div className=\"hjm-select__anchor\">\n <button\n {...buttonProps}\n ref={(node) => {\n triggerRef.current = node;\n if (typeof forwardedRef === \"function\") forwardedRef(node);\n else if (forwardedRef) forwardedRef.current = node;\n }}\n id={controlId}\n type=\"button\"\n role=\"combobox\"\n className={classNames(\"hjm-field__control hjm-select__trigger\", className)}\n disabled={disabled}\n aria-disabled={busy || undefined}\n aria-label={accessibilityLabel ?? (label === undefined ? accessibleName : undefined)}\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open ? activeOptionId : undefined}\n aria-busy={busy || asyncState.status === \"loading\" || asyncState.status === \"loadingMore\" || undefined}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-readonly={readOnly || undefined}\n aria-required={required || undefined}\n onFocus={onFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled || busy || readOnly) return;\n if (open) changeOpen(false, \"trigger\");\n else openWithIntent();\n }}\n >\n {triggerLeading ? (\n <span className=\"hjm-select__leading\" aria-hidden=\"true\">\n {triggerLeading}\n </span>\n ) : null}\n <span\n className=\"hjm-select__value\"\n data-state={resolvedSelectedItem ? \"selected\" : \"placeholder\"}\n >\n {resolvedSelectedItem?.label ?? placeholder}\n </span>\n {busy ? (\n <span className=\"hjm-select__busy-indicator\" aria-hidden=\"true\" />\n ) : (\n <span className=\"hjm-select__indicator\" aria-hidden=\"true\">⌄</span>\n )}\n </button>\n {open ? (\n <AnchoredPortal\n anchorRef={triggerRef}\n ssrFallback=\"inline\"\n {...(portalContainer === undefined ? {} : { container: portalContainer })}\n >\n <div\n ref={setListboxRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={accessibleName}\n className=\"hjm-select__listbox\"\n data-density={density}\n data-placement={popupPosition.placement}\n data-align={popupPosition.align}\n style={popupPosition.style}\n >\n {asyncState.status !== \"idle\" ? (\n <div\n className=\"hjm-select__message\"\n role={asyncState.status === \"error\" ? \"alert\" : \"status\"}\n >\n {asyncState.message}\n </div>\n ) : null}\n {showOptions ? (\n source.sections ? source.sections.map((section) => {\n const sectionLabelId = `${controlId}-section-${section.id}`;\n return (\n <div\n key={section.id}\n role=\"group\"\n aria-labelledby={section.label ? sectionLabelId : undefined}\n aria-label={section.label ? undefined : section.accessibilityLabel}\n className=\"hjm-select__section\"\n >\n {section.label ? (\n <div id={sectionLabelId} className=\"hjm-select__section-label\">\n {section.label}\n </div>\n ) : null}\n {section.items.map(renderOption)}\n </div>\n );\n }) : source.items.map(renderOption)\n ) : null}\n {!disallowEmptySelection && showOptions ? (\n <div\n ref={(node) => {\n if (node) optionRefs.current.set(emptySelectionKey, node);\n else optionRefs.current.delete(emptySelectionKey);\n }}\n id={`${controlId}-option-empty`}\n role=\"option\"\n className=\"hjm-select__option hjm-select__option--empty\"\n aria-selected={reconciledSelectedKey === null}\n data-state={reconciledSelectedKey === null ? \"selected\" : \"idle\"}\n data-active={activeKey === emptySelectionKey || undefined}\n onMouseDown={(event) => event.preventDefault()}\n onMouseMove={() => setHighlightedKey(emptySelectionKey)}\n onClick={() => commit(emptySelectionKey)}\n >\n {emptySelectionLabel}\n </div>\n ) : null}\n </div>\n </AnchoredPortal>\n ) : null}\n </div>\n {description && !error ? (\n <div id={descriptionId} className=\"hjm-field__description\">{description}</div>\n ) : null}\n {error ? <div id={errorId} className=\"hjm-field__error\">{error}</div> : null}\n {name ? <input type=\"hidden\" name={name} value={reconciledSelectedKey ?? \"\"} /> : null}\n </div>\n );\n}\n\nexport const Select = forwardRef(SelectInner) as <\n Key extends string = string,\n SectionKey extends string = string,\n>(\n props: SelectProps<Key, SectionKey> & RefAttributes<HTMLButtonElement>,\n) => ReactElement | null;\n"]}
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../src/select.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,6BAA6B,EAC7B,6BAA6B,EAC7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AK,CAAC,CAAC,CAAC,CACf,cAAK,EAAE,EAAE,cAAc,EAAE,SAAS,EAAC,2BAA2B,YAC3D,OAAO,CAAC,KAAK,GACV,CACP,CAAC,CAAC,CAAC,IAAI,EACP,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,KAX3B,OAAO,CAAC,EAAE,CAYX,CACP,CAAC;gCACJ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CACpC,CAAC,CAAC,CAAC,IAAI,IACF,GACS,CAClB,CAAC,CAAC,CAAC,IAAI,IACJ,EACL,WAAW,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CACvB,cAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAC,wBAAwB,YAAE,WAAW,GAAO,CAC/E,CAAC,CAAC,CAAC,IAAI,EACP,KAAK,CAAC,CAAC,CAAC,cAAK,EAAE,EAAE,OAAO,EAAE,SAAS,EAAC,kBAAkB,YAAE,KAAK,GAAO,CAAC,CAAC,CAAC,IAAI,EAC3E,IAAI,CAAC,CAAC,CAAC,gBAAO,IAAI,EAAC,QAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,qBAAqB,IAAI,EAAE,GAAI,CAAC,CAAC,CAAC,IAAI,IAClF,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAAC,WAAW,CAKpB,CAAC","sourcesContent":["import {\n getCollectionNavigationIntent,\n getCollectionNavigationTarget,\n getCollectionTypeaheadMatch,\n reconcileSelectSelection,\n resolveCollectionItem,\n resolveSelectSelectedItem,\n validateCollection,\n type SelectCollectionSectionDescriptor,\n type SelectCollectionSource,\n type SelectOpenChangeReason,\n} from \"@hjmds/design-contracts/components/collection\";\nimport {\n resolveControlAccessibleName,\n selectBehaviorDefaults,\n type AsyncCollectionState,\n type SelectItemDescriptor,\n type WebKeyboardKey,\n} from \"@hjmds/design-contracts/behaviors\";\nimport {\n iconRecipe,\n selectRecipe,\n type SelectDensity,\n type SelectSize,\n} from \"@hjmds/design-contracts/recipes\";\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useId,\n useRef,\n useState,\n type ButtonHTMLAttributes,\n type FocusEvent,\n type KeyboardEvent,\n type ReactElement,\n type ReactNode,\n type RefAttributes,\n} from \"react\";\nimport { classNames, useControllableState } from \"./internal.js\";\nimport {\n AnchoredPortal,\n useAnchoredPopup,\n type AnchoredPopupAlign,\n} from \"./portal.js\";\n\nexport type SelectItem<Key extends string = string> = SelectItemDescriptor<Key>;\nexport type SelectSection<\n Key extends string = string,\n SectionKey extends string = string,\n> = SelectCollectionSectionDescriptor<Key, SectionKey>;\n\nexport type SelectLeadingRenderProps = Readonly<{\n color: \"currentColor\";\n size: number;\n glyphSize: number;\n}>;\n\nexport type SelectOptionLeadingRenderProps = SelectLeadingRenderProps & Readonly<{\n selected: boolean;\n highlighted: boolean;\n disabled: boolean;\n}>;\n\nconst emptySelectionKey = Symbol(\"hjm-select-empty-selection\");\ntype SelectHighlightKey<Key extends string> = Key | typeof emptySelectionKey;\n\ntype SelectSourceProps<Key extends string, SectionKey extends string> =\n SelectCollectionSource<Key, SectionKey>;\n\ntype SelectSelectionProps<Key extends string> =\n | Readonly<{\n selectedKey: Key | null;\n defaultSelectedKey?: never;\n onSelectionChange(key: Key | null): void;\n }>\n | Readonly<{\n selectedKey?: never;\n defaultSelectedKey?: Key | null;\n onSelectionChange?: (key: Key | null) => void;\n }>;\n\ntype SelectOpenProps =\n | Readonly<{\n open: boolean;\n defaultOpen?: never;\n onOpenChange(open: boolean, reason: SelectOpenChangeReason): void;\n }>\n | Readonly<{\n open?: never;\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean, reason: SelectOpenChangeReason) => void;\n }>;\n\ntype SelectLabelProps =\n | Readonly<{ label: string; accessibilityLabel?: string }>\n | Readonly<{ label?: never; accessibilityLabel: string }>;\n\ntype SelectBaseProps<Key extends string> = Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n | \"aria-label\"\n | \"children\"\n | \"defaultValue\"\n | \"onChange\"\n | \"role\"\n | \"value\"\n> &\n Readonly<{\n description?: ReactNode;\n error?: ReactNode;\n /** Localized text shown when no item is selected. */\n placeholder: string;\n /** Localized label for the nullable empty-selection option. */\n emptySelectionLabel: string;\n asyncState?: AsyncCollectionState;\n selectedItem?: SelectItemDescriptor<Key>;\n disallowEmptySelection?: boolean;\n loop?: boolean;\n /** Locks interaction without removing the trigger from the focus order. */\n busy?: boolean;\n readOnly?: boolean;\n required?: boolean;\n size?: SelectSize;\n density?: SelectDensity;\n /** Logical listbox alignment against the trigger; automatically mirrors in RTL. */\n align?: AnchoredPopupAlign;\n fieldClassName?: string;\n portalContainer?: HTMLElement;\n locale?: string | readonly string[];\n renderLeading?: (\n item: SelectItemDescriptor<Key> | null,\n appearance: SelectLeadingRenderProps,\n ) => ReactNode;\n renderOptionLeading?: (\n item: SelectItemDescriptor<Key>,\n appearance: SelectOptionLeadingRenderProps,\n ) => ReactNode;\n }>;\n\nexport type SelectProps<\n Key extends string = string,\n SectionKey extends string = string,\n> = SelectBaseProps<Key> &\n SelectSourceProps<Key, SectionKey> &\n SelectSelectionProps<Key> &\n SelectOpenProps &\n SelectLabelProps;\n\nfunction SelectInner<Key extends string, SectionKey extends string>(\n props: SelectProps<Key, SectionKey>,\n forwardedRef: React.ForwardedRef<HTMLButtonElement>,\n) {\n const {\n items,\n sections,\n label,\n accessibilityLabel,\n description,\n error,\n placeholder,\n emptySelectionLabel,\n asyncState = { status: \"idle\" },\n selectedItem,\n disallowEmptySelection = selectBehaviorDefaults.disallowEmptySelection,\n loop = selectBehaviorDefaults.loop,\n busy = false,\n readOnly = false,\n size = selectRecipe.defaults.size,\n density = selectRecipe.defaults.density,\n align = \"start\",\n fieldClassName,\n portalContainer,\n locale,\n renderLeading,\n renderOptionLeading,\n className,\n id: idProp,\n name,\n disabled = false,\n required = false,\n selectedKey: selectedKeyProp,\n defaultSelectedKey,\n onSelectionChange,\n open: openProp,\n defaultOpen = false,\n onOpenChange,\n onClick,\n onFocus,\n onBlur,\n onKeyDown,\n ...buttonProps\n } = props;\n const source: SelectCollectionSource<Key, SectionKey> = sections === undefined\n ? { items: items ?? [] }\n : { sections };\n validateCollection(source);\n const accessibleName = resolveControlAccessibleName(\n label,\n accessibilityLabel,\n \"Select\",\n );\n if (placeholder.trim().length === 0) throw new TypeError(\"Select placeholder must not be empty\");\n if (emptySelectionLabel.trim().length === 0) {\n throw new TypeError(\"Select emptySelectionLabel must not be empty\");\n }\n const flatItems = source.sections\n ? source.sections.flatMap((section) => section.items)\n : source.items;\n if (\n flatItems.length === 0 &&\n (asyncState.status === \"idle\" || asyncState.status === \"loadingMore\")\n ) {\n throw new TypeError(\"Select requires options unless its async state is transient or empty\");\n }\n const initialSelectionRef = useRef<Readonly<{ value: Key | null }> | null>(null);\n if (initialSelectionRef.current === null) {\n initialSelectionRef.current = {\n value: reconcileSelectSelection(\n source,\n selectedKeyProp ?? defaultSelectedKey ?? null,\n {\n disallowEmptySelection,\n asyncState,\n ...(selectedItem === undefined ? {} : { selectedItem }),\n },\n ),\n };\n }\n const [storedSelectedKey, setSelectedKey] = useControllableState<Key | null>({\n ...(selectedKeyProp === undefined ? {} : { value: selectedKeyProp }),\n defaultValue: initialSelectionRef.current.value,\n ...(onSelectionChange === undefined ? {} : { onChange: onSelectionChange }),\n });\n const reconciledSelectedKey = reconcileSelectSelection(source, storedSelectedKey, {\n disallowEmptySelection,\n asyncState,\n ...(selectedItem === undefined ? {} : { selectedItem }),\n });\n const reconciliationRequestRef = useRef<string | undefined>(undefined);\n useEffect(() => {\n if (storedSelectedKey === reconciledSelectedKey) {\n reconciliationRequestRef.current = undefined;\n return;\n }\n const token = `${storedSelectedKey ?? \"<empty>\"}->${reconciledSelectedKey ?? \"<empty>\"}`;\n if (reconciliationRequestRef.current === token) return;\n reconciliationRequestRef.current = token;\n setSelectedKey(reconciledSelectedKey);\n }, [reconciledSelectedKey, setSelectedKey, storedSelectedKey]);\n const resolvedSelectedItem = resolveSelectSelectedItem(\n source,\n reconciledSelectedKey,\n selectedItem !== undefined && selectedItem.id === reconciledSelectedKey\n ? selectedItem\n : undefined,\n );\n\n const [internalOpen, setInternalOpen] = useState(defaultOpen);\n const openControlled = openProp !== undefined;\n const open = openControlled ? openProp : internalOpen;\n const pendingOpenRequestRef = useRef<boolean | undefined>(undefined);\n useEffect(() => {\n if (pendingOpenRequestRef.current === open) pendingOpenRequestRef.current = undefined;\n }, [open]);\n const changeOpen = useCallback(\n (nextOpen: boolean, reason: SelectOpenChangeReason) => {\n if (nextOpen === open || pendingOpenRequestRef.current === nextOpen) return;\n pendingOpenRequestRef.current = nextOpen;\n if (!openControlled) setInternalOpen(nextOpen);\n onOpenChange?.(nextOpen, reason);\n if (openControlled && nextOpen) {\n queueMicrotask(() => {\n if (pendingOpenRequestRef.current === true) {\n pendingOpenRequestRef.current = undefined;\n }\n });\n }\n },\n [onOpenChange, open, openControlled],\n );\n\n const generatedId = useId().replaceAll(\":\", \"\");\n const controlId = idProp ?? `hjm-select-${generatedId}`;\n const listboxId = `${controlId}-listbox`;\n const descriptionId = `${controlId}-description`;\n const errorId = `${controlId}-error`;\n const optionId = (key: Key) =>\n `${controlId}-option-${flatItems.findIndex((item) => item.id === key)}`;\n const rootRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const listboxRef = useRef<HTMLDivElement | null>(null);\n const [listboxNode, setListboxNode] = useState<HTMLDivElement | null>(null);\n const optionRefs = useRef(new Map<SelectHighlightKey<Key>, HTMLDivElement>());\n const typeaheadRef = useRef({ value: \"\", time: 0 });\n const restoreFocusRef = useRef(false);\n const showOptions = asyncState.status === \"idle\" || asyncState.status === \"loadingMore\";\n const emptySelectionAvailable = !disallowEmptySelection && showOptions;\n const selectionItemInSource = resolveCollectionItem(source, reconciledSelectedKey);\n const initialHighlight = selectionItemInSource && !selectionItemInSource.disabled\n ? selectionItemInSource.id\n : reconciledSelectedKey === null && emptySelectionAvailable\n ? emptySelectionKey\n : getCollectionNavigationTarget(source, null, \"first\", loop) ?? null;\n const [highlightedKey, setHighlightedKey] = useState<SelectHighlightKey<Key> | null>(\n initialHighlight,\n );\n const highlightedItem = showOptions && highlightedKey !== emptySelectionKey\n ? resolveCollectionItem(source, highlightedKey)\n : null;\n const activeKey: SelectHighlightKey<Key> | null = highlightedItem && !highlightedItem.disabled\n ? highlightedItem.id\n : highlightedKey === emptySelectionKey && emptySelectionAvailable\n ? emptySelectionKey\n : null;\n const activeOptionId = activeKey === emptySelectionKey\n ? `${controlId}-option-empty`\n : activeKey === null\n ? undefined\n : optionId(activeKey);\n const popupPosition = useAnchoredPopup(triggerRef, listboxNode, {\n align,\n matchAnchorWidth: true,\n zIndex: 800,\n });\n const setListboxRef = useCallback((node: HTMLDivElement | null) => {\n listboxRef.current = node;\n setListboxNode(node);\n }, []);\n\n useEffect(() => {\n if (!open) {\n if (restoreFocusRef.current) {\n restoreFocusRef.current = false;\n queueMicrotask(() => triggerRef.current?.focus());\n }\n return;\n }\n if (activeKey === null && showOptions) setHighlightedKey(initialHighlight);\n }, [activeKey, initialHighlight, open, showOptions]);\n useEffect(() => {\n if (open && activeKey !== null) {\n optionRefs.current.get(activeKey)?.scrollIntoView({ block: \"nearest\" });\n }\n }, [activeKey, open]);\n useEffect(() => {\n if (!open) return;\n const handlePointerDown = (event: PointerEvent) => {\n if (\n event.target instanceof Node &&\n !rootRef.current?.contains(event.target) &&\n !listboxRef.current?.contains(event.target)\n ) {\n changeOpen(false, \"outside\");\n }\n };\n document.addEventListener(\"pointerdown\", handlePointerDown);\n return () => document.removeEventListener(\"pointerdown\", handlePointerDown);\n }, [changeOpen, open]);\n\n const openWithIntent = (intent: \"first\" | \"last\" = \"first\") => {\n if (disabled || busy || readOnly) return;\n const selectedInSource = resolveCollectionItem(source, reconciledSelectedKey);\n const target = selectedInSource && !selectedInSource.disabled\n ? selectedInSource.id\n : reconciledSelectedKey === null && emptySelectionAvailable\n ? emptySelectionKey\n // The empty-selection entry renders first in the listbox, so only the\n // \"first\" intent (Home/ArrowDown on a closed trigger) lands on it; \"last\"\n // (End/ArrowUp) must reach the last real option. The previous mapping sent\n // \"last\" to the empty entry, which contradicted DOM order. See issue #18.\n : intent === \"first\" && emptySelectionAvailable\n ? emptySelectionKey\n : getCollectionNavigationTarget(source, null, intent, loop) ?? null;\n setHighlightedKey(target);\n changeOpen(true, \"keyboard\");\n };\n const moveHighlight = (intent: \"next\" | \"previous\" | \"first\" | \"last\") => {\n const enabledKeys = flatItems\n .filter((item) => !item.disabled)\n .map((item) => item.id);\n const firstKey = enabledKeys[0];\n const lastKey = enabledKeys.at(-1);\n // Treat the empty-selection entry as the first row, matching DOM order. `loop`\n // only joins the two ends of the list: moving between the empty entry and the\n // first option is adjacency, not a wrap, so it stays loop-independent. The\n // previous code gated that \"next\" on `loop`, which trapped the arrow keys on the\n // empty entry for every Select using the defaults (disallowEmptySelection: false,\n // loop: false). See issue #18.\n if (emptySelectionAvailable) {\n if (intent === \"first\") {\n setHighlightedKey(emptySelectionKey);\n return;\n }\n if (activeKey === emptySelectionKey) {\n if (intent === \"next\") {\n if (firstKey !== undefined) setHighlightedKey(firstKey);\n return;\n }\n if (intent === \"previous\") {\n if (loop && lastKey !== undefined) setHighlightedKey(lastKey);\n return;\n }\n // intent === \"last\" falls through: the shared path picks the last option.\n } else {\n if (intent === \"previous\" && activeKey === firstKey) {\n setHighlightedKey(emptySelectionKey);\n return;\n }\n if (intent === \"next\" && activeKey === lastKey && loop) {\n setHighlightedKey(emptySelectionKey);\n return;\n }\n }\n }\n const target = getCollectionNavigationTarget(\n source,\n activeKey === emptySelectionKey ? null : activeKey,\n intent,\n loop,\n );\n if (target !== undefined) setHighlightedKey(target);\n };\n const commit = (key: SelectHighlightKey<Key>) => {\n if (key === emptySelectionKey) {\n if (disabled || readOnly || !emptySelectionAvailable) return;\n setSelectedKey(null);\n restoreFocusRef.current = true;\n changeOpen(false, \"selection\");\n return;\n }\n const item = resolveCollectionItem(source, key);\n if (\n !item ||\n item.disabled ||\n disabled ||\n busy ||\n readOnly ||\n asyncState.status === \"loading\"\n ) return;\n setSelectedKey(key);\n restoreFocusRef.current = true;\n changeOpen(false, \"selection\");\n };\n const runTypeahead = (key: string) => {\n const now = Date.now();\n const previous = now - typeaheadRef.current.time < 500\n ? typeaheadRef.current.value\n : \"\";\n const combined = `${previous}${key}`;\n const query = new Set(combined.toLocaleLowerCase()).size === 1 ? key : combined;\n typeaheadRef.current = { value: combined, time: now };\n const match = getCollectionTypeaheadMatch(source, query, {\n startsAfterKey: activeKey === emptySelectionKey\n ? reconciledSelectedKey\n : activeKey ?? reconciledSelectedKey,\n ...(locale === undefined ? {} : { locale }),\n });\n if (match !== undefined) {\n setHighlightedKey(match);\n if (!open) changeOpen(true, \"keyboard\");\n }\n };\n const handleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.defaultPrevented || disabled || busy || readOnly) return;\n const navigationIntent = getCollectionNavigationIntent(\n event.key as WebKeyboardKey,\n );\n if (navigationIntent !== undefined) {\n event.preventDefault();\n if (!open) {\n openWithIntent(\n navigationIntent === \"previous\" || navigationIntent === \"last\"\n ? \"last\"\n : \"first\",\n );\n }\n else moveHighlight(navigationIntent);\n return;\n }\n if (event.key === \"Enter\" || event.key === \" \") {\n event.preventDefault();\n if (!open) openWithIntent();\n else if (activeKey !== null) commit(activeKey);\n } else if (event.key === \"Escape\" && open) {\n event.preventDefault();\n restoreFocusRef.current = true;\n changeOpen(false, \"escape\");\n } else if (event.key === \"Tab\" && open) {\n changeOpen(false, \"blur\");\n } else if (\n event.key.length === 1 &&\n event.key !== \" \" &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey\n ) {\n event.preventDefault();\n runTypeahead(event.key);\n }\n };\n const handleBlur = (event: FocusEvent<HTMLButtonElement>) => {\n onBlur?.(event);\n if (event.defaultPrevented) return;\n queueMicrotask(() => {\n if (\n open &&\n document.activeElement instanceof Node &&\n !rootRef.current?.contains(document.activeElement) &&\n !listboxRef.current?.contains(document.activeElement)\n ) changeOpen(false, \"blur\");\n });\n };\n const describedBy = error ? errorId : description ? descriptionId : undefined;\n\n const renderOption = (item: SelectItemDescriptor<Key>) => {\n const selected = item.id === reconciledSelectedKey;\n const active = item.id === activeKey;\n const leadingSize = iconRecipe.sizes[selectRecipe.optionLeading.glyph];\n const leading = renderOptionLeading?.(item, {\n selected,\n highlighted: active,\n disabled: item.disabled ?? false,\n color: \"currentColor\",\n size: leadingSize,\n glyphSize: leadingSize,\n });\n return (\n <div\n key={item.id}\n ref={(node) => {\n if (node) optionRefs.current.set(item.id, node);\n else optionRefs.current.delete(item.id);\n }}\n id={optionId(item.id)}\n role=\"option\"\n className=\"hjm-select__option\"\n aria-selected={selected}\n aria-disabled={item.disabled || undefined}\n data-state={item.disabled ? \"disabled\" : selected ? \"selected\" : \"idle\"}\n data-active={active || undefined}\n onMouseDown={(event) => event.preventDefault()}\n onMouseMove={() => {\n if (!item.disabled) setHighlightedKey(item.id);\n }}\n onClick={() => commit(item.id)}\n >\n {leading ? (\n <span className=\"hjm-select__option-leading\" aria-hidden=\"true\">\n {leading}\n </span>\n ) : null}\n <span className=\"hjm-select__option-copy\">\n <span>{item.label}</span>\n {item.description ? (\n <span className=\"hjm-select__option-description\">{item.description}</span>\n ) : null}\n </span>\n {selected ? <span className=\"hjm-select__check\" aria-hidden=\"true\">✓</span> : null}\n </div>\n );\n };\n\n const triggerLeadingSize = iconRecipe.sizes[selectRecipe.sizes[size].glyph];\n const triggerLeading = renderLeading?.(resolvedSelectedItem, {\n color: \"currentColor\",\n size: triggerLeadingSize,\n glyphSize: triggerLeadingSize,\n });\n\n return (\n <div\n ref={rootRef}\n className={classNames(\"hjm-field hjm-select\", fieldClassName)}\n data-state={disabled ? \"disabled\" : error ? \"invalid\" : open ? \"focused\" : \"idle\"}\n data-size={size}\n data-density={density}\n data-async-state={asyncState.status}\n data-busy={busy || undefined}\n >\n {label !== undefined ? (\n <label className=\"hjm-field__label\" htmlFor={controlId}>\n {label}{required ? <span aria-hidden=\"true\"> *</span> : null}\n </label>\n ) : null}\n <div className=\"hjm-select__anchor\">\n <button\n {...buttonProps}\n ref={(node) => {\n triggerRef.current = node;\n if (typeof forwardedRef === \"function\") forwardedRef(node);\n else if (forwardedRef) forwardedRef.current = node;\n }}\n id={controlId}\n type=\"button\"\n role=\"combobox\"\n className={classNames(\"hjm-field__control hjm-select__trigger\", className)}\n disabled={disabled}\n aria-disabled={busy || undefined}\n aria-label={accessibilityLabel ?? (label === undefined ? accessibleName : undefined)}\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open ? activeOptionId : undefined}\n aria-busy={busy || asyncState.status === \"loading\" || asyncState.status === \"loadingMore\" || undefined}\n aria-invalid={error ? true : undefined}\n aria-describedby={describedBy}\n aria-readonly={readOnly || undefined}\n aria-required={required || undefined}\n onFocus={onFocus}\n onBlur={handleBlur}\n onKeyDown={handleKeyDown}\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented || disabled || busy || readOnly) return;\n if (open) changeOpen(false, \"trigger\");\n else openWithIntent();\n }}\n >\n {triggerLeading ? (\n <span className=\"hjm-select__leading\" aria-hidden=\"true\">\n {triggerLeading}\n </span>\n ) : null}\n <span\n className=\"hjm-select__value\"\n data-state={resolvedSelectedItem ? \"selected\" : \"placeholder\"}\n >\n {resolvedSelectedItem?.label ?? placeholder}\n </span>\n {busy ? (\n <span className=\"hjm-select__busy-indicator\" aria-hidden=\"true\" />\n ) : (\n <span className=\"hjm-select__indicator\" aria-hidden=\"true\">⌄</span>\n )}\n </button>\n {open ? (\n <AnchoredPortal\n anchorRef={triggerRef}\n ssrFallback=\"inline\"\n {...(portalContainer === undefined ? {} : { container: portalContainer })}\n >\n <div\n ref={setListboxRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={accessibleName}\n className=\"hjm-select__listbox\"\n data-density={density}\n data-placement={popupPosition.placement}\n data-align={popupPosition.align}\n style={popupPosition.style}\n >\n {asyncState.status !== \"idle\" ? (\n <div\n className=\"hjm-select__message\"\n role={asyncState.status === \"error\" ? \"alert\" : \"status\"}\n >\n {asyncState.message}\n </div>\n ) : null}\n {/* Rendered before the options: with no selection the active descendant\n starts on this entry, and a trailing position made that starting point\n the bottom of the list, where ArrowDown has nowhere to go (issue #18).\n moveHighlight follows this DOM order. */}\n {!disallowEmptySelection && showOptions ? (\n <div\n ref={(node) => {\n if (node) optionRefs.current.set(emptySelectionKey, node);\n else optionRefs.current.delete(emptySelectionKey);\n }}\n id={`${controlId}-option-empty`}\n role=\"option\"\n className=\"hjm-select__option hjm-select__option--empty\"\n aria-selected={reconciledSelectedKey === null}\n data-state={reconciledSelectedKey === null ? \"selected\" : \"idle\"}\n data-active={activeKey === emptySelectionKey || undefined}\n onMouseDown={(event) => event.preventDefault()}\n onMouseMove={() => setHighlightedKey(emptySelectionKey)}\n onClick={() => commit(emptySelectionKey)}\n >\n {emptySelectionLabel}\n </div>\n ) : null}\n {showOptions ? (\n source.sections ? source.sections.map((section) => {\n const sectionLabelId = `${controlId}-section-${section.id}`;\n return (\n <div\n key={section.id}\n role=\"group\"\n aria-labelledby={section.label ? sectionLabelId : undefined}\n aria-label={section.label ? undefined : section.accessibilityLabel}\n className=\"hjm-select__section\"\n >\n {section.label ? (\n <div id={sectionLabelId} className=\"hjm-select__section-label\">\n {section.label}\n </div>\n ) : null}\n {section.items.map(renderOption)}\n </div>\n );\n }) : source.items.map(renderOption)\n ) : null}\n </div>\n </AnchoredPortal>\n ) : null}\n </div>\n {description && !error ? (\n <div id={descriptionId} className=\"hjm-field__description\">{description}</div>\n ) : null}\n {error ? <div id={errorId} className=\"hjm-field__error\">{error}</div> : null}\n {name ? <input type=\"hidden\" name={name} value={reconciledSelectedKey ?? \"\"} /> : null}\n </div>\n );\n}\n\nexport const Select = forwardRef(SelectInner) as <\n Key extends string = string,\n SectionKey extends string = string,\n>(\n props: SelectProps<Key, SectionKey> & RefAttributes<HTMLButtonElement>,\n) => ReactElement | null;\n"]}
|
package/dist/selection.js
CHANGED
|
@@ -184,7 +184,7 @@ export const Switch = forwardRef(function Switch({ label, checked: checkedProp,
|
|
|
184
184
|
return (_jsxs("button", { ...props, style: { ...style, ...layoutStyle }, ref: ref, type: type, role: "switch", className: classNames("hjm-switch", className), "data-size": size, "data-state": checked ? "checked" : "unchecked", "aria-checked": checked, disabled: disabled, onClick: (event) => {
|
|
185
185
|
setChecked((current) => !current);
|
|
186
186
|
onClick?.(event);
|
|
187
|
-
}, children: [_jsx("span", { className: "hjm-switch__track", "aria-hidden": "true", children: _jsx("span", { className: "hjm-switch__thumb" }) }), _jsx("span", { children: label })] }));
|
|
187
|
+
}, children: [_jsx("span", { className: "hjm-switch__track", "aria-hidden": "true", children: _jsx("span", { className: "hjm-switch__thumb" }) }), _jsx("span", { className: "hjm-switch__label", children: label })] }));
|
|
188
188
|
});
|
|
189
189
|
export const SegmentedControl = forwardRef(function SegmentedControl({ label, items, value: valueProp, defaultValue, onValueChange, size = segmentedControlRecipe.defaults.size, name, className, ...props }, ref) {
|
|
190
190
|
validateItems("SegmentedControl", items);
|