se-design 1.0.77-dev-v1 → 1.0.78-dev1
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/assets/style.css +1 -1
- package/dist/components/Banner/index.d.ts +0 -1
- package/dist/components/CustomModal/index.d.ts +29 -0
- package/dist/index12.js +36 -34
- package/dist/index12.js.map +1 -1
- package/dist/index13.js +11 -11
- package/dist/index13.js.map +1 -1
- package/dist/index19.js +154 -154
- package/dist/index19.js.map +1 -1
- package/dist/index197.js +5 -5
- package/dist/index201.js +1 -1
- package/dist/{index206.js → index208.js} +1 -1
- package/dist/{index206.js.map → index208.js.map} +1 -1
- package/dist/{index207.js → index209.js} +1 -1
- package/dist/{index207.js.map → index209.js.map} +1 -1
- package/dist/{index215.js → index217.js} +1 -1
- package/dist/{index215.js.map → index217.js.map} +1 -1
- package/dist/{index223.js → index225.js} +1 -1
- package/dist/{index223.js.map → index225.js.map} +1 -1
- package/dist/{index226.js → index228.js} +1 -1
- package/dist/{index226.js.map → index228.js.map} +1 -1
- package/dist/{index235.js → index237.js} +1 -1
- package/dist/{index235.js.map → index237.js.map} +1 -1
- package/dist/index238.js +3 -18
- package/dist/index238.js.map +1 -1
- package/dist/index240.js +18 -9
- package/dist/index240.js.map +1 -1
- package/dist/index241.js +9 -4
- package/dist/index241.js.map +1 -1
- package/dist/index242.js +10 -170
- package/dist/index242.js.map +1 -1
- package/dist/index243.js +5 -11
- package/dist/index243.js.map +1 -1
- package/dist/index244.js +170 -6
- package/dist/index244.js.map +1 -1
- package/dist/index245.js +11 -6
- package/dist/index245.js.map +1 -1
- package/dist/index246.js +5 -37
- package/dist/index246.js.map +1 -1
- package/dist/index247.js +6 -2
- package/dist/index247.js.map +1 -1
- package/dist/index248.js +37 -7
- package/dist/index248.js.map +1 -1
- package/dist/index249.js +2 -327
- package/dist/index249.js.map +1 -1
- package/dist/index250.js +7 -49
- package/dist/index250.js.map +1 -1
- package/dist/index251.js +327 -2
- package/dist/index251.js.map +1 -1
- package/dist/index252.js +45 -71
- package/dist/index252.js.map +1 -1
- package/dist/index253.js +2 -93
- package/dist/index253.js.map +1 -1
- package/dist/index254.js +72 -48
- package/dist/index254.js.map +1 -1
- package/dist/index255.js +92 -7
- package/dist/index255.js.map +1 -1
- package/dist/index256.js +51 -4
- package/dist/index256.js.map +1 -1
- package/dist/index257.js +7 -51
- package/dist/index257.js.map +1 -1
- package/dist/index258.js +5 -2
- package/dist/index258.js.map +1 -1
- package/dist/index259.js +52 -2
- package/dist/index259.js.map +1 -1
- package/dist/index260.js +5 -0
- package/dist/index260.js.map +1 -0
- package/dist/index261.js +5 -0
- package/dist/index261.js.map +1 -0
- package/dist/index28.js +2 -2
- package/dist/index30.js +74 -75
- package/dist/index30.js.map +1 -1
- package/dist/index40.js +1 -1
- package/dist/index46.js +1 -1
- package/dist/index49.js +16 -14
- package/dist/index49.js.map +1 -1
- package/dist/index51.js +17 -17
- package/dist/index51.js.map +1 -1
- package/dist/index53.js +1 -1
- package/dist/index63.js +1 -1
- package/dist/index76.js +1 -1
- package/package.json +1 -1
- package/dist/index236.js +0 -7
- package/dist/index236.js.map +0 -1
- package/dist/index239.js +0 -13
- package/dist/index239.js.map +0 -1
package/dist/index19.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index19.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n getA11yNameAttributes,\n useDismissOnFocusOut,\n FOCUSABLE_WITH_ROLES_SELECTOR,\n getFocusableElements,\n getFirstFocusableElement,\n getLastFocusableElement\n} from '../../utils/a11y';\n\nexport interface PopoverHandle {\n togglePopover: (focusFirst?: boolean | 'last') => void;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: () => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: (focusFirst?: boolean | 'last') => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n sourceRole?: 'button' | 'combobox';\n popoverContentStyleProperty?: React.CSSProperties;\n disableClickToggle?: boolean;\n disableAutoClose?: boolean;\n /** Focus the first focusable element when the popover opens via isPopoverOpen (external state). */\n focusFirstOnOpen?: boolean;\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ariaLabel,\n ariaLabelledBy,\n sourceRole = 'button',\n popoverContentStyleProperty = {\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n },\n disableClickToggle = false,\n noBorder = false,\n disableAutoClose = false,\n focusFirstOnOpen = false,\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n // Compute accessible name/description props with correct precedence\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy: undefined // Popover doesn't support describedBy yet\n });\n\n // Use shared focus-out dismissal for non-portal popovers.\n // Portal content lives outside the wrapper, so portal uses a dedicated onBlur fallback below.\n const { onBlurCapture: onDismissBlurCapture } = useDismissOnFocusOut<HTMLDivElement>({\n disabled: !displayPopover || disableAutoClose || isWithPortal,\n onFocusOut: () => setDisplayPopover(false),\n closeOnEscape: false\n });\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0, srcWidth: 0 });\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0, srcWidth: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n const popoverWidth = popoverRect?.width || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust center positions to account for popover width\n if (localPosition === 'bottom-center' || localPosition === 'top-center') {\n // Center the popover by subtracting half its width from the source center\n left = left - popoverWidth / 2;\n }\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n\n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above viewport\n if (top < 0) {\n top = 0;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n if (top < 0) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(0, viewportHeight - popoverHeight);\n }\n }\n\n return { top, left, srcWidth: srcRect.width };\n };\n\n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n // Add click listener for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickListener, true);\n }\n checkPopoverPosition();\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickListener, true);\n }\n };\n } else if (displayPopover && isWithPortal) {\n // Add click/scroll listeners for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n // When disableAutoClose is true, still listen to scroll for repositioning\n window.addEventListener('scroll', scrollListenerForRepositioning);\n }\n // Always add resize listener for repositioning\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Initial position calculation\n const timeout1 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n checkSourceVisibility();\n\n if (position) {\n setPortalPosition(position);\n }\n }, 0);\n\n // Recalculate after popover is rendered to get accurate dimensions\n const timeout2 = setTimeout(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }, 10);\n\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n window.removeEventListener('scroll', scrollListenerForRepositioning);\n }\n window.removeEventListener('resize', resizeListenerWithPortal);\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }\n }, [displayPopover, isWithPortal, disableAutoClose]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens.\n // For portal, delay longer so isSrcElementVisible can be set and portal can mount first.\n if (displayPopover) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable && (focusFirstOnOpen || document.activeElement === srcElementRef.current)) {\n firstFocusable.focus();\n }\n }, isWithPortal ? 60 : 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if (disableAutoClose) return;\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n if (disableAutoClose) return;\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const scrollListenerForRepositioning = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = (focusFirst: boolean | 'last' = false) => {\n const wasOpen = displayPopover;\n setDisplayPopover((prev) => !prev);\n if (!wasOpen && focusFirst) {\n setTimeout(() => {\n if (focusFirst === 'last') {\n const lastFocusable = getLastFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (lastFocusable) lastFocusable.focus();\n } else {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }\n }, 50);\n }\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Native form controls own their arrow key behavior — don't intercept.\n // (e.g. a SearchBox inside a Popover should keep focus while typing/navigating)\n const activeEl = document.activeElement;\n if (activeEl?.tagName === 'INPUT' || activeEl?.tagName === 'TEXTAREA' || activeEl?.tagName === 'SELECT') {\n return;\n }\n\n const focusableElements = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_WITH_ROLES_SELECTOR)).filter((el) => {\n // Filter out disabled and hidden elements.\n // Note: check aria-disabled VALUE not just presence — React always writes aria-disabled=\"false\"\n // on elements like MenuItem even when not disabled, so hasAttribute would wrongly exclude them.\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n el.getAttribute('aria-disabled') !== 'true' &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n const handlePopoverContentKeyDown = (e: React.KeyboardEvent) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'Tab') {\n // Close popover when Tab exits the menu\n setDisplayPopover(false);\n if (e.shiftKey) {\n // Shift+Tab: prevent default (would go to wrapper) and focus trigger instead\n e.preventDefault();\n srcElementRef.current?.focus();\n } else if (isWithPortal) {\n // Portal forward Tab: portal content is at document.body so natural Tab order\n // skips back to the top of the page. Manually advance to the next focusable\n // element after the trigger in the main document instead.\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const focusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? focusables.indexOf(srcEl) : -1;\n const next = focusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n // Non-portal forward Tab: do NOT preventDefault — browser moves focus to next element naturally\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n } else if (e.key === 'Enter' || e.key === ' ') {\n // Prevent Enter/Space from bubbling to wrapper (mirrors click stopPropagation)\n e.stopPropagation();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled || disableClickToggle) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled || disableClickToggle) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening.\n // Portal content isn't mounted until isSrcElementVisible resolves (via setTimeout 0),\n // so use a longer delay for portal to ensure popoverContentRef.current is set.\n if (!wasOpen) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, isWithPortal ? 60 : 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, 0);\n }\n }}\n onBlurCapture={onDismissBlurCapture}\n onBlur={(e) => {\n // Portal content is rendered outside wrapper, so keep explicit check for that case.\n if (!displayPopover || disableAutoClose || !isWithPortal) return;\n\n const nextFocused = e.relatedTarget as Node | null;\n const isFocusInSource = !!(nextFocused && srcElementRef.current?.contains(nextFocused));\n const isFocusInPopover = !!(nextFocused && popoverContentRef.current?.contains(nextFocused));\n\n // Close only when focus leaves both source and portal content.\n if (!isFocusInSource && !isFocusInPopover) {\n setDisplayPopover(false);\n }\n }}\n role={disableClickToggle ? 'none' : sourceRole}\n aria-expanded={disableClickToggle ? undefined : displayPopover ? 'true' : 'false'}\n aria-haspopup={disableClickToggle ? undefined : sourceRole === 'combobox' ? 'listbox' : 'true'}\n tabIndex={disabled || disableClickToggle ? -1 : 0}\n aria-disabled={disableClickToggle ? undefined : disabled ? 'true' : 'false'}\n {...accessibleNameProps}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n ...popoverContentStyleProperty,\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal z-[2002] ${popoverContentClasses} ${\n contentWidth == 'full' ? '' : 'w-max'\n }`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n ...(contentWidth === 'full' && portalPosition.srcWidth\n ? { width: `${portalPosition.srcWidth}px` }\n : {}),\n ...popoverContentStyleProperty\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","ariaLabel","ariaLabelledBy","sourceRole","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","disableAutoClose","focusFirstOnOpen","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","onBlurCapture","onDismissBlurCapture","useDismissOnFocusOut","onFocusOut","closeOnEscape","portalPosition","setPortalPosition","top","left","srcWidth","calculatePositionOfPopover","current","localPosition","srcRect","getBoundingClientRect","viewportWidth","window","innerWidth","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","Math","max","spaceAbove","spaceBelow","useEffect","document","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","scrollListenerForRepositioning","clickAndScrollListenerWithPortal","resizeListenerWithPortal","timeout1","setTimeout","checkSourceVisibility","timeout2","clearTimeout","rec","isVisible","firstFocusable","getFirstFocusableElement","container","includeRoles","activeElement","focus","includes","event","currentDropRef","target","isSourcePopover","contains","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","focusFirst","wasOpen","prev","lastFocusable","getLastFocusableElement","handleArrowKeyNavigation","e","activeEl","tagName","focusableElements","Array","from","querySelectorAll","FOCUSABLE_WITH_ROLES_SELECTOR","filter","el","style","getComputedStyle","hasAttribute","getAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","key","preventDefault","stopPropagation","handlePopoverContentKeyDown","shiftKey","srcEl","focusables","getFocusableElements","filterHidden","idx","indexOf","next","useImperativeHandle","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","currentRef","onBlur","nextFocused","relatedTarget","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal"],"mappings":";;;;;;;;;;;;;;;AAsCO,MAAMA,wBACX,CACE;AAAA,EACEC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,UAAAA,IAAW;AAAA,EACXC,4BAAAA,IAA6B;AAAA,EAC7BC,cAAAA,IAAe;AAAA,EACfC,uBAAAA;AAAAA,EACAC,yBAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,6BAAAA,IAA8B;AAAA,IAC5BC,QAAQ;AAAA,IACRC,aAAa;AAAA,IACbC,OAAO;AAAA,IACPC,iBAAiB;AAAA,EAAA;AAAA,EAEnBC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,IAAW;AAAA,EACXC,kBAAAA,IAAmB;AAAA,EACnBC,kBAAAA,KAAmB;AAAA,EACnB,GAAGC;AACL,GACAC,OACG;AACH,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpD,CAACC,GAAiBC,CAAkB,IAAIF,EAASzB,CAAQ,GACzD,CAAC4B,IAAqBC,CAAsB,IAAIJ,EAAS,EAAK,GAC9DK,IAAgBC,EAAuB,IAAI,GAC3CC,IAAoBD,EAAuB,IAAI,GAG/CE,KAAsBC,GAAsB;AAAA,IAChDzB,WAAAA;AAAAA,IACAC,gBAAAA;AAAAA,IACAyB,iBAAiBC;AAAAA;AAAAA,EAAAA,CAClB,GAIK;AAAA,IAAEC,eAAeC;AAAAA,EAAAA,IAAyBC,GAAqC;AAAA,IACnFhC,UAAU,CAACgB,KAAkBJ,KAAoBX;AAAAA,IACjDgC,YAAYA,MAAMhB,EAAkB,EAAK;AAAA,IACzCi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GAEnBE,EAAsB;AAAA,IAAE6J,gBAAgBA,MAAMxI,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GAENhB,KACCe,KACAK,MACAqI,gBAAAA,GAASC,aACPd,gBAAAA,EAAAC,cAAA,OAAA;AAAA,IACEvJ,WAAW,wCAAwCqJ,CAAqB,IACtEjJ,KAAgB,SAAS,KAAK,OAAO;AAAA,IAEvCuH,OAAO;AAAA,MACLzH,UAAU;AAAA,MACV4C,KAAKF,EAAeE;AAAAA,MACpBC,MAAMH,EAAeG;AAAAA,MACrB,GAAI3C,MAAiB,UAAUwC,EAAeI,WAC1C;AAAA,QAAEa,OAAO,GAAGjB,EAAeI,QAAQ;AAAA,MAAA,IACnC,CAAA;AAAA,MACJ,GAAGlC;AAAAA,IAAAA;AAAAA,IAEL2I,SAAUxC,CAAAA,MAAMA,EAAEuB,gBAAAA;AAAAA,IAClBkB,WAAWjB;AAAAA,IACXjH,KAAKU;AAAAA,IACL,sBAAoB/B;AAAAA,EAAAA,GAEnBE,EAAsB;AAAA,IAAE6J,gBAAgBA,MAAMxI,EAAkB,EAAK;AAAA,EAAA,CAAG,CACtE,GACL6C,SAASC,IACX,CACC;AAET,CACF;"}
|
|
1
|
+
{"version":3,"file":"index19.js","sources":["../src/components/Popover/index.tsx"],"sourcesContent":["import React, { useState, useRef, ReactNode, useEffect, forwardRef, ForwardedRef, useImperativeHandle } from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n getA11yNameAttributes,\n useDismissOnFocusOut,\n FOCUSABLE_WITH_ROLES_SELECTOR,\n getFocusableElements,\n getFirstFocusableElement,\n getLastFocusableElement\n} from '../../utils/a11y';\n\nexport interface PopoverHandle {\n togglePopover: (focusFirst?: boolean | 'last') => void;\n}\n\nexport interface PopoverProps {\n className?: string;\n automationId?: string;\n popoverContentAutomationId?: string;\n renderPopoverContents: (props: { closePopoverCb: () => void }) => ReactNode;\n renderPopoverSrcElement: (props: { displayPopover: boolean; togglePopover: (focusFirst?: boolean | 'last') => void }) => ReactNode;\n position?: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'top-center' | 'top-left' | 'top-right';\n onPopoverToggle?: (displayPopover: boolean) => void;\n contentWidth?: 'full' | 'max';\n isPopoverOpen?: boolean;\n disabled?: boolean;\n isWithPortal?: boolean;\n noBorder?: boolean;\n ariaLabel?: string;\n ariaLabelledBy?: string;\n sourceRole?: 'button' | 'combobox';\n popoverContentStyleProperty?: React.CSSProperties;\n disableClickToggle?: boolean;\n disableAutoClose?: boolean;\n /** Focus the first focusable element when the popover opens via isPopoverOpen (external state). */\n focusFirstOnOpen?: boolean;\n}\n\nexport const Popover = forwardRef<PopoverHandle, PopoverProps>(\n (\n {\n className = '',\n automationId = '',\n position = 'bottom-center',\n popoverContentAutomationId = '',\n contentWidth = 'max',\n renderPopoverContents,\n renderPopoverSrcElement,\n onPopoverToggle,\n isPopoverOpen,\n disabled = false,\n isWithPortal = false,\n ariaLabel,\n ariaLabelledBy,\n sourceRole = 'button',\n popoverContentStyleProperty = {\n zIndex: 1000,\n borderColor: 'var(--color-gray-200)',\n color: 'var(--color-gray-900)',\n backgroundColor: 'var(--color-white)'\n },\n disableClickToggle = false,\n noBorder = false,\n disableAutoClose = false,\n focusFirstOnOpen = false,\n ...props\n },\n ref: ForwardedRef<PopoverHandle>\n ) => {\n const [displayPopover, setDisplayPopover] = useState(false);\n const [popoverPosition, setPopoverPosition] = useState(position);\n const [isSrcElementVisible, setIsSrcElementVisible] = useState(false);\n const srcElementRef = useRef<HTMLDivElement>(null);\n const popoverContentRef = useRef<HTMLDivElement>(null);\n\n // Compute accessible name/description props with correct precedence\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy: undefined // Popover doesn't support describedBy yet\n });\n\n // Use shared focus-out dismissal for non-portal popovers.\n // Portal content lives outside the wrapper, so portal uses a dedicated onBlur fallback below.\n const { onBlurCapture: onDismissBlurCapture } = useDismissOnFocusOut<HTMLDivElement>({\n disabled: !displayPopover || disableAutoClose || isWithPortal,\n onFocusOut: () => setDisplayPopover(false),\n closeOnEscape: false\n });\n\n const [portalPosition, setPortalPosition] = useState({ top: 0, left: 0, srcWidth: 0 });\n const [isPortalMeasured, setIsPortalMeasured] = useState(false);\n\n const calculatePositionOfPopover = (position: string = 'bottom-center') => {\n if (!srcElementRef.current) return { top: 0, left: 0, srcWidth: 0 };\n\n let localPosition = position;\n\n const srcRect = srcElementRef.current.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Calculate position for portal\n let top = 0;\n let left = 0;\n\n switch (localPosition) {\n case 'bottom-left':\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n case 'bottom-right':\n top = srcRect.bottom;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'bottom-center':\n top = srcRect.bottom;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n case 'top-left':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.left;\n break;\n case 'top-right':\n top = srcRect.top - srcRect.height * 1.9;\n left = srcRect.right - srcRect.width * 0.5;\n break;\n case 'top-center':\n top = srcRect.top - srcRect.height * 1.9;\n // Center the popover relative to the source element\n left = srcRect.left + srcRect.width / 2;\n break;\n default:\n top = srcRect.bottom;\n left = srcRect.left;\n break;\n }\n\n // Get popover dimensions if available\n const popoverRect = popoverContentRef.current?.getBoundingClientRect();\n // When contentWidth='full', the panel will be sized to srcRect.width after measurement.\n // Use srcRect.width directly so centering and viewport clamping use the correct final width.\n const popoverWidth = (contentWidth === 'full' ? srcRect.width : popoverRect?.width) || 0;\n const popoverHeight = popoverRect?.height || 0;\n\n // Adjust center positions to account for popover width\n if (localPosition === 'bottom-center' || localPosition === 'top-center') {\n // Center the popover by subtracting half its width from the source center\n left = left - popoverWidth / 2;\n }\n\n // Adjust position to keep popover within viewport bounds\n // Horizontal adjustments\n if (left + popoverWidth > viewportWidth) {\n // Popover extends beyond right edge, shift it left\n left = Math.max(0, viewportWidth - popoverWidth);\n }\n if (left < 0) {\n // Popover extends beyond left edge, shift it right\n left = 0;\n }\n\n // Vertical adjustments\n if (top + popoverHeight > viewportHeight) {\n // Popover extends beyond bottom edge\n // Try to position it above the source element\n const spaceAbove = srcRect.top;\n const spaceBelow = viewportHeight - srcRect.bottom;\n\n if (spaceAbove >= popoverHeight || spaceAbove > spaceBelow) {\n // Position above if there's enough space or more space above\n top = srcRect.top - popoverHeight;\n // Ensure it doesn't go above the topbar (48px fixed header)\n if (top < 48) {\n top = 48;\n }\n } else {\n // Keep at bottom but adjust to fit within viewport\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n if (top < 48) {\n // Popover extends beyond top edge, position it below the source element\n top = srcRect.bottom;\n // Ensure it doesn't go below viewport\n if (top + popoverHeight > viewportHeight) {\n top = Math.max(48, viewportHeight - popoverHeight);\n }\n }\n\n return { top: Math.round(top), left: Math.round(left), srcWidth: srcRect.width };\n };\n\n useEffect(() => {\n if (onPopoverToggle) {\n onPopoverToggle(displayPopover);\n }\n\n if (displayPopover && !isWithPortal) {\n // Add click listener for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickListener, true);\n }\n checkPopoverPosition();\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickListener, true);\n }\n };\n } else if (displayPopover && isWithPortal) {\n // Add click/scroll listeners for auto-close behavior only if not disabled\n if (!disableAutoClose) {\n document.body.addEventListener('click', clickAndScrollListenerWithPortal, true);\n window.addEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n // When disableAutoClose is true, still listen to scroll for repositioning\n window.addEventListener('scroll', scrollListenerForRepositioning);\n }\n // Always add resize listener for repositioning\n window.addEventListener('resize', resizeListenerWithPortal);\n\n // Trigger source visibility check immediately\n checkSourceVisibility();\n\n // Use double-rAF to measure portal after browser has completed layout,\n // guaranteeing real dimensions are available for flip/clamp calculations.\n // Portal is hidden via visibility:hidden until this completes (no flash).\n let rafId1: number;\n let rafId2: number;\n rafId1 = requestAnimationFrame(() => {\n rafId2 = requestAnimationFrame(() => {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n setIsPortalMeasured(true);\n });\n });\n\n return () => {\n if (!disableAutoClose) {\n document.body.removeEventListener('click', clickAndScrollListenerWithPortal, true);\n window.removeEventListener('scroll', clickAndScrollListenerWithPortal);\n } else {\n window.removeEventListener('scroll', scrollListenerForRepositioning);\n }\n window.removeEventListener('resize', resizeListenerWithPortal);\n cancelAnimationFrame(rafId1);\n cancelAnimationFrame(rafId2);\n setIsPortalMeasured(false);\n };\n }\n }, [displayPopover, isWithPortal, disableAutoClose]);\n\n const checkSourceVisibility = () => {\n if (!srcElementRef.current) {\n setIsSrcElementVisible(false);\n return;\n }\n\n const rec = srcElementRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const isVisible = rec.top < viewportHeight && rec.bottom > 0 && rec.left < viewportWidth && rec.right > 0;\n\n setIsSrcElementVisible(isVisible);\n };\n\n useEffect(() => {\n setDisplayPopover(isPopoverOpen ?? false);\n }, [isPopoverOpen]);\n\n useEffect(() => {\n // Focus first focusable element when popover opens.\n // For portal, delay longer so isSrcElementVisible can be set and portal can mount first.\n if (displayPopover) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable && (focusFirstOnOpen || document.activeElement === srcElementRef.current)) {\n firstFocusable.focus();\n }\n }, isWithPortal ? 60 : 0);\n }\n }, [displayPopover]);\n\n //Function to check popover position\n const checkPopoverPosition = () => {\n if (!popoverContentRef.current) return;\n\n const popoverRect = popoverContentRef.current.getBoundingClientRect();\n const viewportHeight = window.innerHeight;\n\n if (popoverRect?.bottom > viewportHeight) {\n setPopoverPosition(\n position.includes('left') ? 'top-left' : position.includes('right') ? 'top-right' : 'top-center'\n );\n } else if (popoverRect?.top < 0) {\n // If popover extends beyond top of viewport, switch to bottom position\n setPopoverPosition(\n position.includes('left') ? 'bottom-left' : position.includes('right') ? 'bottom-right' : 'bottom-center'\n );\n }\n };\n\n const clickListener = (event: MouseEvent) => {\n const currentDropRef = srcElementRef.current;\n if (!currentDropRef) return;\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = popoverContentRef.current?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if (disableAutoClose) return;\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const clickAndScrollListenerWithPortal = (event: Event) => {\n const currentDropRef = srcElementRef.current;\n const currentPopoverRef = popoverContentRef.current;\n if (!currentDropRef) return;\n checkSourceVisibility();\n\n // Recalculate position on scroll\n if (event.type === 'scroll' && displayPopover) {\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n\n const target = event.target as Node;\n const isSourcePopover = currentDropRef.contains(target);\n const isPopoverContent = currentPopoverRef?.contains(target);\n\n // Check if click is on another popover's source element\n const clickedElement = target as HTMLElement;\n const closestPopoverWrapper = clickedElement.closest?.('.se-design-popover-wrapper');\n const isAnotherPopoverSource = closestPopoverWrapper && closestPopoverWrapper !== currentDropRef;\n\n // check if the clicked popover is a nesteded child of the current popover content\n const isNestedPopover = popoverContentRef.current?.contains(closestPopoverWrapper as Node);\n\n if (disableAutoClose) return;\n // if clicked source is parent or the popover-content, do not toggle dropdown.\n // Also close if clicking on another popover's source element\n if ((!isSourcePopover && !isPopoverContent) || (isAnotherPopoverSource && !isNestedPopover)) {\n setDisplayPopover(false);\n }\n };\n\n const resizeListenerWithPortal = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const scrollListenerForRepositioning = () => {\n if (displayPopover && isWithPortal && srcElementRef.current) {\n checkSourceVisibility();\n const position = calculatePositionOfPopover(popoverPosition);\n if (position) {\n setPortalPosition(position);\n }\n }\n };\n\n const togglePopover = (focusFirst: boolean | 'last' = false) => {\n const wasOpen = displayPopover;\n setDisplayPopover((prev) => !prev);\n if (!wasOpen && focusFirst) {\n setTimeout(() => {\n if (focusFirst === 'last') {\n const lastFocusable = getLastFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (lastFocusable) lastFocusable.focus();\n } else {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }\n }, 50);\n }\n };\n\n const handleArrowKeyNavigation = (e: React.KeyboardEvent, container: HTMLDivElement | null) => {\n if (!container) return;\n\n // Native form controls own their arrow key behavior — don't intercept.\n // (e.g. a SearchBox inside a Popover should keep focus while typing/navigating)\n const activeEl = document.activeElement;\n if (activeEl?.tagName === 'INPUT' || activeEl?.tagName === 'TEXTAREA' || activeEl?.tagName === 'SELECT') {\n return;\n }\n\n const focusableElements = Array.from(container.querySelectorAll<HTMLElement>(FOCUSABLE_WITH_ROLES_SELECTOR)).filter((el) => {\n // Filter out disabled and hidden elements.\n // Note: check aria-disabled VALUE not just presence — React always writes aria-disabled=\"false\"\n // on elements like MenuItem even when not disabled, so hasAttribute would wrongly exclude them.\n const style = window.getComputedStyle(el);\n return (\n !el.hasAttribute('disabled') &&\n el.getAttribute('aria-disabled') !== 'true' &&\n style.display !== 'none' &&\n style.visibility !== 'hidden' &&\n (el.tabIndex >= 0 || el.hasAttribute('role'))\n );\n });\n\n if (focusableElements.length === 0) return;\n\n const currentIndex = focusableElements.findIndex((el) => el === document.activeElement);\n let nextIndex = -1;\n\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex < focusableElements.length - 1 ? currentIndex + 1 : 0;\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = currentIndex > 0 ? currentIndex - 1 : focusableElements.length - 1;\n } else if (e.key === 'Home') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = 0;\n } else if (e.key === 'End') {\n e.preventDefault();\n e.stopPropagation();\n nextIndex = focusableElements.length - 1;\n }\n\n if (nextIndex >= 0 && focusableElements[nextIndex]) {\n focusableElements[nextIndex].focus();\n } else if (currentIndex === -1 && focusableElements.length > 0) {\n // If no element is currently focused, focus the first one\n focusableElements[0].focus();\n }\n };\n\n const handlePopoverContentKeyDown = (e: React.KeyboardEvent) => {\n // Allow Escape key to close popover when focus is on content\n if (e.key === 'Escape') {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n srcElementRef.current?.focus();\n } else if (e.key === 'Tab') {\n // Close popover when Tab exits the menu\n setDisplayPopover(false);\n if (e.shiftKey) {\n // Shift+Tab: prevent default (would go to wrapper) and focus trigger instead\n e.preventDefault();\n srcElementRef.current?.focus();\n } else if (isWithPortal) {\n // Portal forward Tab: portal content is at document.body so natural Tab order\n // skips back to the top of the page. Manually advance to the next focusable\n // element after the trigger in the main document instead.\n e.preventDefault();\n const srcEl = srcElementRef.current;\n const focusables = getFocusableElements({ container: document.body, filterHidden: true });\n const idx = srcEl ? focusables.indexOf(srcEl) : -1;\n const next = focusables[idx + 1];\n if (next) next.focus();\n else srcEl?.focus();\n }\n // Non-portal forward Tab: do NOT preventDefault — browser moves focus to next element naturally\n } else if (e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'Home' || e.key === 'End') {\n // Handle arrow key navigation for focusable elements inside popover\n handleArrowKeyNavigation(e, popoverContentRef.current);\n } else if (e.key === 'Enter' || e.key === ' ') {\n // Prevent Enter/Space from bubbling to wrapper (mirrors click stopPropagation)\n e.stopPropagation();\n }\n };\n\n useImperativeHandle(ref, () => ({ togglePopover }), []);\n\n const popoverContentStyle = {\n 'bottom-left': { left: '0', top: '100%' },\n 'bottom-right': { right: '0', top: '100%' },\n 'bottom-center': { left: '50%', transform: 'translateX(-50%)', top: '100%' },\n 'top-left': { left: '0', bottom: '100%' },\n 'top-right': { right: '0', bottom: '100%' },\n 'top-center': { left: '50%', transform: 'translateX(-50%)', bottom: '100%' }\n };\n const popoverContentClasses = noBorder ? '' : 'shadow-md border rounded-md';\n\n return (\n <div\n className={\n 'se-design-popover-wrapper cursor-pointer relative focus-outline rounded-md' +\n (className.length > 0 ? ` ${className}` : '') +\n (displayPopover ? ' open' : '') +\n (disabled ? ' opacity-50 cursor-not-allowed pointer-events-none' : '')\n }\n ref={srcElementRef}\n onClick={(e) => {\n if (disabled || disableClickToggle) return;\n e.stopPropagation();\n togglePopover();\n }}\n onKeyDown={(e) => {\n if (disabled || disableClickToggle) return;\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n e.stopPropagation();\n const wasOpen = displayPopover;\n togglePopover();\n // Focus first focusable element when opening.\n // Portal content isn't mounted until isSrcElementVisible resolves (via setTimeout 0),\n // so use a longer delay for portal to ensure popoverContentRef.current is set.\n if (!wasOpen) {\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, isWithPortal ? 60 : 0);\n }\n } else if (e.key === 'Escape' && displayPopover) {\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(false);\n } else if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') && displayPopover) {\n // Handle arrow keys when popover is open\n const currentRef = popoverContentRef.current;\n if (currentRef) {\n handleArrowKeyNavigation(e, currentRef);\n }\n } else if (e.key === 'ArrowDown' && !displayPopover) {\n // Open popover and focus first item when ArrowDown is pressed\n e.preventDefault();\n e.stopPropagation();\n setDisplayPopover(true);\n setTimeout(() => {\n const firstFocusable = getFirstFocusableElement({ container: popoverContentRef.current, includeRoles: true });\n if (firstFocusable) firstFocusable.focus();\n }, 0);\n }\n }}\n onBlurCapture={onDismissBlurCapture}\n onBlur={(e) => {\n // Portal content is rendered outside wrapper, so keep explicit check for that case.\n if (!displayPopover || disableAutoClose || !isWithPortal) return;\n\n const nextFocused = e.relatedTarget as Node | null;\n const isFocusInSource = !!(nextFocused && srcElementRef.current?.contains(nextFocused));\n const isFocusInPopover = !!(nextFocused && popoverContentRef.current?.contains(nextFocused));\n\n // Close only when focus leaves both source and portal content.\n if (!isFocusInSource && !isFocusInPopover) {\n setDisplayPopover(false);\n }\n }}\n role={disableClickToggle ? 'none' : sourceRole}\n aria-expanded={disableClickToggle ? undefined : displayPopover ? 'true' : 'false'}\n aria-haspopup={disableClickToggle ? undefined : sourceRole === 'combobox' ? 'listbox' : 'true'}\n tabIndex={disabled || disableClickToggle ? -1 : 0}\n aria-disabled={disableClickToggle ? undefined : disabled ? 'true' : 'false'}\n {...accessibleNameProps}\n data-automation-id={automationId}\n {...props}\n >\n {renderPopoverSrcElement({ displayPopover, togglePopover })}\n\n {displayPopover && !isWithPortal && (\n <div\n className={`popover-content absolute ${popoverContentClasses} z-[1000] ${\n contentWidth == 'full' ? 'w-full' : 'w-max'\n }`}\n style={{\n ...popoverContentStyleProperty,\n ...popoverContentStyle[popoverPosition]\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>\n )}\n {isWithPortal &&\n displayPopover &&\n isSrcElementVisible &&\n ReactDOM.createPortal(\n <div\n className={`popover-content-with-portal z-[2002] ${popoverContentClasses} ${\n contentWidth == 'full' ? '' : 'w-max'\n }`}\n style={{\n position: 'fixed',\n top: portalPosition.top,\n left: portalPosition.left,\n visibility: isPortalMeasured ? 'visible' : 'hidden',\n ...(contentWidth === 'full' && portalPosition.srcWidth\n ? { width: `${portalPosition.srcWidth}px` }\n : {}),\n ...popoverContentStyleProperty\n }}\n onClick={(e) => e.stopPropagation()}\n onKeyDown={handlePopoverContentKeyDown}\n ref={popoverContentRef}\n data-automation-id={popoverContentAutomationId}\n >\n {renderPopoverContents({ closePopoverCb: () => setDisplayPopover(false) })}\n </div>,\n document.body\n )}\n </div>\n );\n }\n);\n"],"names":["Popover","className","automationId","position","popoverContentAutomationId","contentWidth","renderPopoverContents","renderPopoverSrcElement","onPopoverToggle","isPopoverOpen","disabled","isWithPortal","ariaLabel","ariaLabelledBy","sourceRole","popoverContentStyleProperty","zIndex","borderColor","color","backgroundColor","disableClickToggle","noBorder","disableAutoClose","focusFirstOnOpen","props","ref","displayPopover","setDisplayPopover","useState","popoverPosition","setPopoverPosition","isSrcElementVisible","setIsSrcElementVisible","srcElementRef","useRef","popoverContentRef","accessibleNameProps","getA11yNameAttributes","ariaDescribedBy","undefined","onBlurCapture","onDismissBlurCapture","useDismissOnFocusOut","onFocusOut","closeOnEscape","portalPosition","setPortalPosition","top","left","srcWidth","isPortalMeasured","setIsPortalMeasured","calculatePositionOfPopover","current","localPosition","srcRect","getBoundingClientRect","viewportWidth","window","innerWidth","viewportHeight","innerHeight","bottom","right","width","height","popoverRect","popoverWidth","popoverHeight","Math","max","spaceAbove","spaceBelow","round","useEffect","document","body","addEventListener","clickListener","checkPopoverPosition","removeEventListener","scrollListenerForRepositioning","clickAndScrollListenerWithPortal","resizeListenerWithPortal","checkSourceVisibility","rafId1","rafId2","requestAnimationFrame","cancelAnimationFrame","rec","isVisible","setTimeout","firstFocusable","getFirstFocusableElement","container","includeRoles","activeElement","focus","includes","event","currentDropRef","target","isSourcePopover","contains","isPopoverContent","closestPopoverWrapper","closest","isAnotherPopoverSource","isNestedPopover","currentPopoverRef","type","togglePopover","focusFirst","wasOpen","prev","lastFocusable","getLastFocusableElement","handleArrowKeyNavigation","e","activeEl","tagName","focusableElements","Array","from","querySelectorAll","FOCUSABLE_WITH_ROLES_SELECTOR","filter","el","style","getComputedStyle","hasAttribute","getAttribute","display","visibility","tabIndex","length","currentIndex","findIndex","nextIndex","key","preventDefault","stopPropagation","handlePopoverContentKeyDown","shiftKey","srcEl","focusables","getFocusableElements","filterHidden","idx","indexOf","next","useImperativeHandle","popoverContentStyle","transform","popoverContentClasses","React","createElement","_extends","onClick","onKeyDown","currentRef","onBlur","nextFocused","relatedTarget","isFocusInSource","isFocusInPopover","role","closePopoverCb","ReactDOM","createPortal"],"mappings":";;;;;;;;;;;;;;;AAsCO,MAAMA,wBACX,CACE;AAAA,EACEC,WAAAA,IAAY;AAAA,EACZC,cAAAA,IAAe;AAAA,EACfC,UAAAA,IAAW;AAAA,EACXC,4BAAAA,IAA6B;AAAA,EAC7BC,cAAAA,IAAe;AAAA,EACfC,uBAAAA;AAAAA,EACAC,yBAAAA;AAAAA,EACAC,iBAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,WAAAA;AAAAA,EACAC,gBAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,6BAAAA,IAA8B;AAAA,IAC5BC,QAAQ;AAAA,IACRC,aAAa;AAAA,IACbC,OAAO;AAAA,IACPC,iBAAiB;AAAA,EAAA;AAAA,EAEnBC,oBAAAA,IAAqB;AAAA,EACrBC,UAAAA,KAAW;AAAA,EACXC,kBAAAA,IAAmB;AAAA,EACnBC,kBAAAA,KAAmB;AAAA,EACnB,GAAGC;AACL,GACAC,OACG;AACH,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpD,CAACC,GAAiBC,CAAkB,IAAIF,EAASzB,CAAQ,GACzD,CAAC4B,IAAqBC,CAAsB,IAAIJ,EAAS,EAAK,GAC9DK,IAAgBC,EAAuB,IAAI,GAC3CC,IAAoBD,EAAuB,IAAI,GAG/CE,KAAsBC,G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D from "./
|
|
4
|
-
import { SVGInjector as A } from "./
|
|
5
|
-
import { p as t } from "./
|
|
1
|
+
import N from "./index241.js";
|
|
2
|
+
import R from "./index242.js";
|
|
3
|
+
import D from "./index243.js";
|
|
4
|
+
import { SVGInjector as A } from "./index244.js";
|
|
5
|
+
import { p as t } from "./index245.js";
|
|
6
6
|
import * as h from "react";
|
|
7
7
|
var O = function(s) {
|
|
8
8
|
var o = s?.ownerDocument || document;
|
package/dist/index201.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useRef as l } from "react";
|
|
2
2
|
import { useFocusTrap as d } from "./index72.js";
|
|
3
|
-
import { useDismissOnEscape as u } from "./
|
|
3
|
+
import { useDismissOnEscape as u } from "./index208.js";
|
|
4
4
|
import { getA11yNameAttributes as c } from "./index78.js";
|
|
5
5
|
import { useStableId as f } from "./index199.js";
|
|
6
6
|
function v({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"index208.js","sources":["../src/utils/a11y/useDismissOnEscape.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { RefObject } from 'react';\n\nexport interface UseDismissOnEscapeOptions<T extends HTMLElement = HTMLElement> {\n /**\n * Container element ref to check if focus is within.\n * Escape will only trigger if focus is within this container.\n */\n containerRef: RefObject<T | null>;\n /**\n * Callback when Escape key is pressed and focus is within container.\n */\n onDismiss?: () => void;\n /**\n * Whether the Escape handler is active.\n * Default: true\n */\n enabled?: boolean;\n /**\n * Whether to call preventDefault() when handling Escape.\n * Default: true\n */\n preventDefault?: boolean;\n /**\n * Whether to call stopPropagation() when handling Escape.\n * Default: true\n */\n stopPropagation?: boolean;\n}\n\n/**\n * Hook to handle Escape key dismissal when focus is within a container.\n * \n * This is a UX pattern: if user is interacting with an overlay/sidebar\n * (indicated by focus being within it), Escape should close it.\n * \n * @example\n * ```tsx\n * const MySidebar = ({ isOpen, onClose }) => {\n * const containerRef = useRef<HTMLDivElement>(null);\n * \n * useDismissOnEscape({\n * containerRef,\n * onDismiss: onClose,\n * enabled: isOpen\n * });\n * \n * return <div ref={containerRef}>...</div>;\n * };\n * ```\n */\nexport function useDismissOnEscape<T extends HTMLElement = HTMLElement>({\n containerRef,\n onDismiss,\n enabled = true,\n preventDefault = true,\n stopPropagation = true\n}: UseDismissOnEscapeOptions<T>): void {\n useEffect(() => {\n if (!enabled || !onDismiss) return;\n \n const container = containerRef.current;\n if (!container) return;\n\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key === 'Escape' && container.contains(document.activeElement)) {\n preventDefault && e.preventDefault();\n stopPropagation && e.stopPropagation();\n onDismiss();\n }\n };\n\n document.addEventListener('keydown', handleEscape, { capture: true });\n return () => document.removeEventListener('keydown', handleEscape, { capture: true });\n }, [enabled, onDismiss, containerRef, preventDefault, stopPropagation]);\n}\n"],"names":["useEffect","useDismissOnEscape","containerRef","onDismiss","enabled","preventDefault","stopPropagation","container","current","handleEscape","e","key","contains","document","activeElement","addEventListener","capture","removeEventListener"],"mappings":"AAmDO,SAAA,aAAAA,SAAA;AAAA,SAASC,EAAwD;AAAA,EACtEC,cAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,SAAAA,IAAU;AAAA,EACVC,gBAAAA,IAAiB;AAAA,EACjBC,iBAAAA,IAAkB;AACU,GAAS;AACrCN,EAAAA,EAAU,MAAM;AACd,QAAI,CAACI,KAAW,CAACD,EAAW;AAE5B,UAAMI,IAAYL,EAAaM;AAC/B,QAAI,CAACD,EAAW;AAEhB,UAAME,IAAeA,CAACC,MAAqB;AACzC,MAAIA,EAAEC,QAAQ,YAAYJ,EAAUK,SAASC,SAASC,aAAa,MACjET,KAAkBK,EAAEL,eAAAA,GACpBC,KAAmBI,EAAEJ,gBAAAA,GACrBH,EAAAA;AAAAA,IAEJ;AAEAU,oBAASE,iBAAiB,WAAWN,GAAc;AAAA,MAAEO,SAAS;AAAA,IAAA,CAAM,GAC7D,MAAMH,SAASI,oBAAoB,WAAWR,GAAc;AAAA,MAAEO,SAAS;AAAA,IAAA,CAAM;AAAA,EACtF,GAAG,CAACZ,GAASD,GAAWD,GAAcG,GAAgBC,CAAe,CAAC;AACxE;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"index209.js","sources":["../src/utils/a11y/useFocusSentinel.ts"],"sourcesContent":["import { useRef, useEffect, useLayoutEffect } from 'react';\n\nimport { getFirstFocusableElement, getLastFocusableElement } from './focusableElements';\nimport { consumeLastInteractedElement, consumeFocusAnchor } from './useFocusTrap';\n\nconst SENTINEL_STYLE: React.CSSProperties = {\n position: 'absolute',\n opacity: 0,\n pointerEvents: 'none',\n width: 0,\n height: 0,\n};\n\nexport interface UseFocusSentinelOptions {\n /** Whether the panel is currently open. */\n isOpen: boolean | undefined;\n /**\n * When true the hook is a no-op — dialog mode (focus trap) handles focus management instead.\n */\n isModal: boolean;\n /** Ref to the panel container element. */\n containerRef: React.RefObject<HTMLElement | null>;\n /**\n * Explicit element to restore focus to on close.\n * Overrides the automatic trigger capture.\n */\n returnFocusRef?: React.RefObject<HTMLElement | null>;\n}\n\nexport interface SentinelProps {\n ref: React.RefObject<HTMLDivElement | null>;\n tabIndex: number;\n style: React.CSSProperties;\n onFocus: (e: React.FocusEvent) => void;\n}\n\nexport interface UseFocusSentinelReturn {\n /** Spread onto an invisible div placed before the panel content. */\n startSentinelProps: SentinelProps;\n /** Spread onto an invisible div placed after the panel content. */\n endSentinelProps: SentinelProps;\n}\n\n/**\n * Focus management for complementary (non-modal) side panels.\n *\n * Moves focus into the panel on open, restores it to the trigger on close,\n * and wraps Tab / Shift+Tab back to the trigger when focus reaches either end.\n *\n * Sentinel tabIndex values are mutated imperatively (no state) to avoid\n * re-renders. React does not touch a DOM attribute unless the JSX prop value\n * changes, so the initial tabIndex={-1} in the returned props is safe.\n */\nexport function useFocusSentinel({\n isOpen,\n isModal,\n containerRef,\n returnFocusRef,\n}: UseFocusSentinelOptions): UseFocusSentinelReturn {\n const triggerRef = useRef<HTMLElement | null>(null);\n const startSentinelRef = useRef<HTMLDivElement>(null);\n const endSentinelRef = useRef<HTMLDivElement>(null);\n\n // Capture trigger before React commits (document.activeElement is still the opener).\n // Body focus = page-load open → skip so sentinels stay inert.\n useLayoutEffect(() => {\n if (isModal || !isOpen) return;\n const trigger =\n returnFocusRef?.current ??\n consumeFocusAnchor() ??\n consumeLastInteractedElement() ??\n (document.activeElement as HTMLElement);\n if (!trigger || trigger === document.body) return;\n triggerRef.current = trigger;\n if (endSentinelRef.current) endSentinelRef.current.tabIndex = 0;\n return () => {\n if (endSentinelRef.current) endSentinelRef.current.tabIndex = -1;\n };\n }, [isOpen, isModal]);\n\n // Move focus into panel on open; restore to trigger on close.\n useEffect(() => {\n if (isModal || !isOpen || !triggerRef.current) return;\n\n const rafId = requestAnimationFrame(() => {\n const first = getFirstFocusableElement({ container: containerRef.current });\n (first ?? containerRef.current)?.focus();\n // Activate start sentinel so Shift+Tab from first content returns to trigger.\n if (startSentinelRef.current) startSentinelRef.current.tabIndex = 0;\n });\n\n return () => {\n cancelAnimationFrame(rafId);\n if (startSentinelRef.current) startSentinelRef.current.tabIndex = -1;\n const trigger = triggerRef.current;\n triggerRef.current = null;\n if (trigger?.isConnected) {\n requestAnimationFrame(() => trigger.focus());\n }\n };\n }, [isOpen, isModal]);\n\n const handleStartFocus = (e: React.FocusEvent) => {\n const fromInside =\n containerRef.current?.contains(e.relatedTarget as Node) &&\n e.relatedTarget !== containerRef.current;\n if (fromInside) {\n // Shift+Tab from first content → restore trigger\n const trigger = triggerRef.current;\n if (trigger?.isConnected) trigger.focus();\n } else {\n // Natural Tab entry from outside → forward to first content,\n // deactivate so next Shift+Tab exits naturally.\n if (startSentinelRef.current) startSentinelRef.current.tabIndex = -1;\n const first = getFirstFocusableElement({ container: containerRef.current });\n (first ?? containerRef.current)?.focus();\n }\n };\n\n const handleEndFocus = (e: React.FocusEvent) => {\n const fromInside =\n containerRef.current?.contains(e.relatedTarget as Node) &&\n e.relatedTarget !== containerRef.current;\n if (fromInside) {\n // Tab from last content → restore trigger\n const trigger = triggerRef.current;\n if (trigger?.isConnected) trigger.focus();\n } else {\n // Shift+Tab entry from outside → back to last content\n const last = getLastFocusableElement({ container: containerRef.current });\n (last ?? containerRef.current)?.focus();\n }\n };\n\n return {\n startSentinelProps: {\n ref: startSentinelRef,\n tabIndex: -1,\n style: SENTINEL_STYLE,\n onFocus: handleStartFocus,\n },\n endSentinelProps: {\n ref: endSentinelRef,\n tabIndex: -1,\n style: SENTINEL_STYLE,\n onFocus: handleEndFocus,\n },\n };\n}\n"],"names":["useRef","useLayoutEffect","useEffect","getFirstFocusableElement","getLastFocusableElement","consumeFocusAnchor","consumeLastInteractedElement","SENTINEL_STYLE","position","opacity","pointerEvents","width","height","useFocusSentinel","isOpen","isModal","containerRef","returnFocusRef","triggerRef","startSentinelRef","endSentinelRef","trigger","current","document","activeElement","body","tabIndex","rafId","requestAnimationFrame","container","focus","cancelAnimationFrame","isConnected","startSentinelProps","ref","style","onFocus","handleStartFocus","e","contains","relatedTarget","endSentinelProps","handleEndFocus"],"mappings":"AAKA,SAAA,UAAAA,GAAA,mBAAAC,GAAA,aAAAC,SAAA;AAAA,SAAA,4BAAAC,GAAA,2BAAAC,SAAA;AAAA,SAAA,sBAAAC,GAAA,gCAAAC,SAAA;AAAA,MAAMC,IAAsC;AAAA,EAC1CC,UAAU;AAAA,EACVC,SAAS;AAAA,EACTC,eAAe;AAAA,EACfC,OAAO;AAAA,EACPC,QAAQ;AACV;AA0CO,SAASC,EAAiB;AAAA,EAC/BC,QAAAA;AAAAA,EACAC,SAAAA;AAAAA,EACAC,cAAAA;AAAAA,EACAC,gBAAAA;AACuB,GAA2B;AAClD,QAAMC,IAAalB,EAA2B,IAAI,GAC5CmB,IAAmBnB,EAAuB,IAAI,GAC9CoB,IAAiBpB,EAAuB,IAAI;AAIlDC,SAAAA,EAAgB,MAAM;AACpB,QAAIc,KAAW,CAACD,EA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UQ,MAAAA;AAAAA,MAErC;AAAA,IAsBaO;AAAAA,IAEXI,kBAAkB;AAAA,MAChBP,KAAKd;AAAAA,MACLM,UAAU;AAAA,MACVS,OAAO5B;AAAAA,MACP6B,SA1BmBM,CAACJ,MAAwB;AAI9C,YAFEtB,EAAaM,SAASiB,SAASD,EAAEE,aAAqB,KACtDF,EAAEE,kBAAkBxB,EAAaM,SACnB;AAEd,gBAAMD,IAAUH,EAAWI;AAC3B,UAAID,GAASW,eAAaX,EAAQS,MAAAA;AAAAA,QACpC;AAGE,WADa1B,EAAwB;AAAA,YAAEyB,WAAWb,EAAaM;AAAAA,UAAAA,CAAS,KAC/DN,EAAaM,UAAUQ,MAAAA;AAAAA,MAEpC;AAAA,IAaaY;AAAAA,EACX;AAEJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"index217.js","sources":["../src/utils/debounce.ts"],"sourcesContent":["export function debounce<T extends (...args: any[]) => void>(func: T, wait: number) {\n let timeout: ReturnType<typeof setTimeout> | null;\n const debounced = (...args: Parameters<T>) => {\n if (timeout) clearTimeout(timeout);\n timeout = setTimeout(() => {\n func(...args);\n }, wait);\n };\n debounced.cancel = () => {\n if (timeout) clearTimeout(timeout);\n timeout = null;\n };\n return debounced as T & { cancel: () => void };\n }"],"names":["debounce","func","wait","timeout","debounced","args","setTimeout","cancel"],"mappings":"AAAO,SAASA,EAA6CC,GAASC,GAAc;AAChF,MAAIC;AACJ,QAAMC,IAAYA,IAAIC,MAAwB;AAC5C,IAAIF,kBAAsBA,CAAO,GACjCA,IAAUG,WAAW,MAAM;AACzBL,MAAAA,EAAK,GAAGI,CAAI;AAAA,IACd,GAAGH,CAAI;AAAA,EACT;AACAE,SAAAA,EAAUG,SAAS,MAAM;AACvB,IAAIJ,kBAAsBA,CAAO,GACjCA,IAAU;AAAA,EACZ,GACOC;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"index228.js","sources":["../src/components/NavigationBar/TabButton.tsx"],"sourcesContent":["import React, { forwardRef } from 'react';\nimport { Button } from '../Button';\n\nexport interface TabButtonProps {\n id: string;\n label: string;\n isSelected: boolean;\n isDisabled?: boolean;\n panelId?: string;\n tabIndex: number;\n className?: string;\n automationId?: string;\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;\n onFocus: () => void;\n onKeyDown: (e: React.KeyboardEvent<HTMLButtonElement>) => void;\n}\n\n/**\n * Internal TabButton component for NavigationBar.\n * Uses Button (unstyled) internally for consistent activation handling.\n * Supports forwardRef for focus management (roving tabindex).\n */\nexport const TabButton = forwardRef<HTMLButtonElement, TabButtonProps>(\n (\n {\n id,\n label,\n isSelected,\n isDisabled = false,\n panelId,\n tabIndex,\n className = '',\n automationId,\n onClick,\n onFocus,\n onKeyDown\n },\n ref\n ) => {\n return (\n <Button\n ref={ref}\n type=\"unstyled\"\n label={label}\n disabled={isDisabled}\n onClick={onClick}\n className={className}\n automationId={automationId}\n role=\"tab\"\n id={id}\n aria-selected={isSelected}\n {...(panelId ? { 'aria-controls': panelId } : {})}\n tabIndex={tabIndex}\n onFocus={onFocus}\n onKeyDown={onKeyDown}\n />\n );\n }\n);\n\nTabButton.displayName = 'TabButton';\n"],"names":["TabButton","id","label","isSelected","isDisabled","panelId","tabIndex","className","automationId","onClick","onFocus","onKeyDown","ref","React","createElement","Button","_extends","type","disabled","role","displayName"],"mappings":";;;;;;;;;;;AAsBO,MAAMA,sBACX,CACE;AAAA,EACEC,IAAAA;AAAAA,EACAC,OAAAA;AAAAA,EACAC,YAAAA;AAAAA,EACAC,YAAAA,IAAa;AAAA,EACbC,SAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,WAAAA,IAAY;AAAA,EACZC,cAAAA;AAAAA,EACAC,SAAAA;AAAAA,EACAC,SAAAA;AAAAA,EACAC,WAAAA;AACF,GACAC,MAGEC,gBAAAA,EAAAC,cAACC,GAAMC,EAAA;AAAA,EACLJ,KAAAA;AAAAA,EACAK,MAAK;AAAA,EACLf,OAAAA;AAAAA,EACAgB,UAAUd;AAAAA,EACVK,SAAAA;AAAAA,EACAF,WAAAA;AAAAA,EACAC,cAAAA;AAAAA,EACAW,MAAK;AAAA,EACLlB,IAAAA;AAAAA,EACA,iBAAeE;AAAAA,GACVE,IAAU;AAAA,EAAE,iBAAiBA;AAAAA,IAAY,IAAE;AAAA,EAChDC,UAAAA;AAAAA,EACAI,SAAAA;AAAAA,EACAC,WAAAA;AAAAA,CAAqB,CACtB,CAGP;AAEAX,EAAUoB,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index235.js","sources":["../src/components/DatePicker/useDatePickerA11y.ts"],"sourcesContent":["import React, { useState, useCallback, useEffect, useMemo } from 'react';\n\nimport { useRovingFocus, RovingItemProps, RovingContainerProps, AccessibleNameInput } from '../../utils/a11y/useRovingFocus';\nimport type { DateRange } from './index';\n\nexport const getCellAriaLabel = (\n date: Date,\n isStart: boolean,\n isEnd: boolean,\n isSameStartEnd: boolean,\n singleDateSelection: boolean\n): string => {\n const base = date.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n year: 'numeric'\n });\n if (singleDateSelection) return base;\n if (isSameStartEnd) return `${base}, start and end of range`;\n if (isStart) return `${base}, start of range`;\n if (isEnd) return `${base}, end of range`;\n return base;\n};\n\nexport const formatDateId = (d: Date) => {\n const y = d.getFullYear();\n const m = String(d.getMonth() + 1).padStart(2, '0');\n const dd = String(d.getDate()).padStart(2, '0');\n return `date-${y}-${m}-${dd}`;\n};\n\nconst getDaysInMonth = (year: number, month: number) => new Date(year, month + 1, 0).getDate();\n\nconst getPanelItemIds = (panelDate: Date): string[] => {\n const year = panelDate.getFullYear();\n const month = panelDate.getMonth();\n return Array.from({ length: getDaysInMonth(year, month) }, (_, i) =>\n formatDateId(new Date(year, month, i + 1))\n );\n};\n\nconst getPanelDefaultFocusId = (panelDate: Date, itemIds: string[], selectedRange: DateRange): string => {\n const year = panelDate.getFullYear();\n const month = panelDate.getMonth();\n const isInPanel = (d: Date) => d.getFullYear() === year && d.getMonth() === month;\n\n // Prefer startDate if it falls in this panel\n if (selectedRange.startDate && isInPanel(selectedRange.startDate)) {\n const d = new Date(selectedRange.startDate);\n d.setHours(0, 0, 0, 0);\n const id = formatDateId(d);\n if (itemIds.includes(id)) return id;\n }\n // Fall back to endDate if it falls in this panel (e.g. right panel when start is in left panel)\n if (selectedRange.endDate && isInPanel(selectedRange.endDate)) {\n const d = new Date(selectedRange.endDate);\n d.setHours(0, 0, 0, 0);\n const id = formatDateId(d);\n if (itemIds.includes(id)) return id;\n }\n const today = new Date();\n if (isInPanel(today)) {\n const id = formatDateId(today);\n if (itemIds.includes(id)) return id;\n }\n return itemIds[0] || '';\n};\n\ninterface UseDatePickerA11yOptions {\n leftMonth: Date;\n rightMonth: Date;\n showSingleMonth: boolean;\n selectedRange: DateRange;\n onMonthChange: (date: Date, isLeft: boolean) => void;\n}\n\ninterface CellKeyDownOptions {\n isLeftCalendar: boolean;\n isDateDisabled: (date: Date) => boolean;\n handleDateClick: (date: Date) => void;\n}\n\ninterface GridCellItemInput {\n cellId: string;\n cellDate: Date;\n disabled: boolean;\n ariaLabel: string;\n ariaSelected: boolean;\n ariaCurrent: 'date' | undefined;\n ariaDisabled: true | undefined;\n}\n\nexport interface GridCellElementProps {\n id: string;\n role: 'gridcell';\n ref: (el: HTMLElement | null) => void;\n tabIndex: number;\n onFocus: () => void;\n 'aria-label': string;\n 'aria-selected': boolean;\n 'aria-current': 'date' | undefined;\n 'aria-disabled': true | undefined;\n onKeyDown: (e: React.KeyboardEvent) => void;\n onClick: () => void;\n}\n\ninterface UseDatePickerA11yReturn {\n getGridCellProps: (options: CellKeyDownOptions) => (item: GridCellItemInput) => GridCellElementProps;\n getLeftRovingItemProps: (id: string) => RovingItemProps;\n getRightRovingItemProps: (id: string) => RovingItemProps;\n getLeftContainerProps: (nameInput?: AccessibleNameInput) => RovingContainerProps;\n getRightContainerProps: (nameInput?: AccessibleNameInput) => RovingContainerProps;\n focusLeftItem: (id: string) => void;\n focusRightItem: (id: string) => void;\n}\n\nexport function useDatePickerA11y({\n leftMonth,\n rightMonth,\n showSingleMonth,\n selectedRange,\n onMonthChange\n}: UseDatePickerA11yOptions): UseDatePickerA11yReturn {\n const [keyboardFocusDate, setKeyboardFocusDate] = useState<Date | null>(null);\n\n const leftItemIds = useMemo(() => getPanelItemIds(leftMonth), [leftMonth]);\n const rightItemIds = useMemo(() => getPanelItemIds(rightMonth), [rightMonth]);\n\n const leftDefaultFocusId = useMemo(\n () => getPanelDefaultFocusId(leftMonth, leftItemIds, selectedRange),\n [leftMonth, leftItemIds, selectedRange]\n );\n const rightDefaultFocusId = useMemo(\n () => getPanelDefaultFocusId(rightMonth, rightItemIds, selectedRange),\n [rightMonth, rightItemIds, selectedRange]\n );\n\n const { getRovingItemProps: getLeftRovingItemProps, focusItem: focusLeftItem, getContainerProps: getLeftContainerProps } = useRovingFocus({\n itemIds: leftItemIds,\n defaultFocusedId: leftDefaultFocusId,\n orientation: 'grid',\n cols: 7,\n loop: false,\n role: 'grid'\n });\n\n const { getRovingItemProps: getRightRovingItemProps, focusItem: focusRightItem, getContainerProps: getRightContainerProps } = useRovingFocus({\n itemIds: rightItemIds,\n defaultFocusedId: rightDefaultFocusId,\n orientation: 'grid',\n cols: 7,\n loop: false,\n role: 'grid'\n });\n\n // After keyboard navigation shifts a panel to a new month, focus the target cell via roving focus refs\n useEffect(() => {\n if (!keyboardFocusDate) return;\n const id = formatDateId(keyboardFocusDate);\n if (leftItemIds.includes(id)) {\n focusLeftItem(id);\n setKeyboardFocusDate(null);\n } else if (rightItemIds.includes(id)) {\n focusRightItem(id);\n setKeyboardFocusDate(null);\n }\n }, [keyboardFocusDate, leftItemIds, rightItemIds, focusLeftItem, focusRightItem]);\n\n // Navigate the keyboard focus to a date that may be in a different month.\n // Each panel advances completely independently — never touches the other panel.\n const handleKeyboardNavigate = useCallback(\n (targetDate: Date, sourcePanel: 'left' | 'right') => {\n const isLeft = showSingleMonth || sourcePanel === 'left';\n onMonthChange(new Date(targetDate.getFullYear(), targetDate.getMonth(), 1), isLeft);\n setKeyboardFocusDate(new Date(targetDate));\n },\n [showSingleMonth, onMonthChange]\n );\n\n const getGridCellProps = useCallback(\n ({ isLeftCalendar, isDateDisabled, handleDateClick }: CellKeyDownOptions) => {\n const panel: 'left' | 'right' = isLeftCalendar ? 'left' : 'right';\n const focusPanelItem = isLeftCalendar ? focusLeftItem : focusRightItem;\n const getRovingItemProps = isLeftCalendar ? getLeftRovingItemProps : getRightRovingItemProps;\n\n const handleKeyDown = (e: React.KeyboardEvent, cellDate: Date) => {\n const cellYear = cellDate.getFullYear();\n const cellMonth = cellDate.getMonth();\n const cellDay = cellDate.getDate();\n\n const navigateTo = (targetDate: Date) => {\n if (targetDate.getFullYear() !== cellYear || targetDate.getMonth() !== cellMonth) {\n handleKeyboardNavigate(targetDate, panel);\n return;\n }\n focusPanelItem(formatDateId(targetDate));\n };\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault(); e.stopPropagation();\n navigateTo(new Date(cellYear, cellMonth, cellDay - 1));\n break;\n case 'ArrowRight':\n e.preventDefault(); e.stopPropagation();\n navigateTo(new Date(cellYear, cellMonth, cellDay + 1));\n break;\n case 'ArrowUp':\n e.preventDefault(); e.stopPropagation();\n navigateTo(new Date(cellYear, cellMonth, cellDay - 7));\n break;\n case 'ArrowDown':\n e.preventDefault(); e.stopPropagation();\n navigateTo(new Date(cellYear, cellMonth, cellDay + 7));\n break;\n case 'Home': {\n // First day of the current week row (Sunday), clamped to month start\n e.preventDefault(); e.stopPropagation();\n const dayOfWeek = cellDate.getDay();\n const homeDate = new Date(cellYear, cellMonth, cellDay - dayOfWeek);\n const clamped = homeDate.getMonth() !== cellMonth ? new Date(cellYear, cellMonth, 1) : homeDate;\n focusPanelItem(formatDateId(clamped));\n break;\n }\n case 'End': {\n // Last day of the current week row (Saturday), clamped to month end\n e.preventDefault(); e.stopPropagation();\n const dayOfWeek = cellDate.getDay();\n const endDate = new Date(cellYear, cellMonth, cellDay + (6 - dayOfWeek));\n const daysInThisMonth = getDaysInMonth(cellYear, cellMonth);\n const clamped =\n endDate.getMonth() !== cellMonth ? new Date(cellYear, cellMonth, daysInThisMonth) : endDate;\n focusPanelItem(formatDateId(clamped));\n break;\n }\n case 'PageUp': {\n // Shift+PageUp = previous year, PageUp = previous month\n e.preventDefault(); e.stopPropagation();\n const tYear = e.shiftKey ? cellYear - 1 : cellYear;\n const tMonth = e.shiftKey ? cellMonth : cellMonth - 1;\n const tDay = Math.min(cellDay, getDaysInMonth(tYear, tMonth));\n handleKeyboardNavigate(new Date(tYear, tMonth, tDay), panel);\n break;\n }\n case 'PageDown': {\n // Shift+PageDown = next year, PageDown = next month\n e.preventDefault(); e.stopPropagation();\n const tYear = e.shiftKey ? cellYear + 1 : cellYear;\n const tMonth = e.shiftKey ? cellMonth : cellMonth + 1;\n const tDay = Math.min(cellDay, getDaysInMonth(tYear, tMonth));\n handleKeyboardNavigate(new Date(tYear, tMonth, tDay), panel);\n break;\n }\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!isDateDisabled(cellDate)) {\n handleDateClick(cellDate);\n }\n break;\n }\n };\n\n return ({ cellId, cellDate, disabled, ariaLabel, ariaSelected, ariaCurrent, ariaDisabled }: GridCellItemInput): GridCellElementProps => {\n const rovingProps = getRovingItemProps(cellId);\n return {\n id: cellId,\n role: 'gridcell',\n ref: rovingProps.ref,\n tabIndex: rovingProps.tabIndex,\n onFocus: rovingProps.onFocus,\n 'aria-label': ariaLabel,\n 'aria-selected': ariaSelected,\n 'aria-current': ariaCurrent,\n 'aria-disabled': ariaDisabled,\n onKeyDown: (e: React.KeyboardEvent) => handleKeyDown(e, cellDate),\n onClick: () => { if (!disabled) handleDateClick(cellDate); }\n };\n };\n },\n [handleKeyboardNavigate, focusLeftItem, focusRightItem, getLeftRovingItemProps, getRightRovingItemProps]\n );\n\n return {\n getGridCellProps,\n getLeftRovingItemProps,\n getRightRovingItemProps,\n getLeftContainerProps,\n getRightContainerProps,\n focusLeftItem,\n focusRightItem\n };\n}\n"],"names":["useState","useMemo","useEffect","useCallback","useRovingFocus","getCellAriaLabel","date","isStart","isEnd","isSameStartEnd","singleDateSelection","base","toLocaleDateString","weekday","month","day","year","formatDateId","d","y","getFullYear","m","String","getMonth","padStart","dd","getDate","getDaysInMonth","Date","getPanelItemIds","panelDate","Array","from","length","_","i","getPanelDefaultFocusId","itemIds","selectedRange","isInPanel","startDate","setHours","id","includes","endDate","today","useDatePickerA11y","leftMonth","rightMonth","showSingleMonth","onMonthChange","keyboardFocusDate","setKeyboardFocusDate","leftItemIds","rightItemIds","leftDefaultFocusId","rightDefaultFocusId","getRovingItemProps","getLeftRovingItemProps","focusItem","focusLeftItem","getContainerProps","getLeftContainerProps","defaultFocusedId","orientation","cols","loop","role","getRightRovingItemProps","focusRightItem","getRightContainerProps","handleKeyboardNavigate","targetDate","sourcePanel","isLeft","getGridCellProps","isLeftCalendar","isDateDisabled","handleDateClick","panel","focusPanelItem","handleKeyDown","e","cellDate","cellYear","cellMonth","cellDay","navigateTo","key","preventDefault","stopPropagation","dayOfWeek","getDay","homeDate","clamped","daysInThisMonth","tYear","shiftKey","tMonth","tDay","Math","min","cellId","disabled","ariaLabel","ariaSelected","ariaC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HG,YAAAA,EAAEO,eAAAA,GACGZ,EAAeM,CAAQ,KAC1BL,EAAgBK,CAAQ;AAE1B;AAAA,QAAA;AAAA,MAEN;AAEA,aAAO,CAAC;AAAA,QAAEmB,QAAAA;AAAAA,QAAQnB,UAAAA;AAAAA,QAAUoB,UAAAA;AAAAA,QAAUC,WAAAA;AAAAA,QAAWC,cAAAA;AAAAA,QAAcC,aAAAA;AAAAA,QAAaC,cAAAA;AAAAA,MAAAA,MAA4D;AACtI,cAAMC,IAAcnD,EAAmB6C,CAAM;AAC7C,eAAO;AAAA,UACL5D,IAAI4D;AAAAA,UACJnC,MAAM;AAAA,UACN0C,KAAKD,EAAYC;AAAAA,UACjBC,UAAUF,EAAYE;AAAAA,UACtBC,SAASH,EAAYG;AAAAA,UACrB,cAAcP;AAAAA,UACd,iBAAiBC;AAAAA,UACjB,gBAAgBC;AAAAA,UAChB,iBAAiBC;AAAAA,UACjBK,WAAWA,CAAC9B,MAA2BD,EAAcC,GAAGC,CAAQ;AAAA,UAChE8B,SAASA,MAAM;AAAE,YAAKV,KAAUzB,EAAgBK,CAAQ;AAAA,UAAG;AAAA,QAAA;AAAA,MAE/D;AAAA,IACF,GACA,CAACZ,GAAwBX,GAAeS,GAAgBX,GAAwBU,CAAuB,CACzG;AAAA,IAIEV,wBAAAA;AAAAA,IACAU,yBAAAA;AAAAA,IACAN,uBAAAA;AAAAA,IACAQ,wBAAAA;AAAAA,IACAV,eAAAA;AAAAA,IACAS,gBAAAA;AAAAA,EAAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"index237.js","sources":["../src/components/DatePicker/useDatePickerA11y.ts"],"sourcesContent":["import React, { useState, useCallback, useEffect, useMemo } from 'react';\n\nimport { useRovingFocus, RovingItemProps, RovingContainerProps, AccessibleNameInput } from '../../utils/a11y/useRovingFocus';\nimport type { DateRange } from './index';\n\nexport const getCellAriaLabel = (\n date: Date,\n isStart: boolean,\n isEnd: boolean,\n isSameStartEnd: boolean,\n singleDateSelection: boolean\n): string => {\n const base = date.toLocaleDateString('en-US', {\n weekday: 'long',\n month: 'long',\n day: 'numeric',\n year: 'numeric'\n });\n if (singleDateSelection) return base;\n if (isSameStartEnd) return `${base}, start and end of range`;\n if (isStart) return `${base}, start of range`;\n if (isEnd) return `${base}, end of range`;\n return base;\n};\n\nexport const formatDateId = (d: Date) => {\n const y = d.getFullYear();\n const m = String(d.getMonth() + 1).padStart(2, '0');\n const dd = String(d.getDate()).padStart(2, '0');\n return `date-${y}-${m}-${dd}`;\n};\n\nconst getDaysInMonth = (year: number, month: number) => new Date(year, month + 1, 0).getDate();\n\nconst getPanelItemIds = (panelDate: Date): string[] => {\n const year = panelDate.getFullYear();\n const month = panelDate.getMonth();\n return Array.from({ length: getDaysInMonth(year, month) }, (_, i) =>\n formatDateId(new Date(year, month, i + 1))\n );\n};\n\nconst getPanelDefaultFocusId = (panelDate: Date, itemIds: string[], selectedRange: DateRange): string => {\n const year = panelDate.getFullYear();\n const month = panelDate.getMonth();\n const isInPanel = (d: Date) => d.getFullYear() === year && d.getMonth() === month;\n\n // Prefer startDate if it falls in this panel\n if (selectedRange.startDate && isInPanel(selectedRange.startDate)) {\n const d = new Date(selectedRange.startDate);\n d.setHours(0, 0, 0, 0);\n const id = formatDateId(d);\n if (itemIds.includes(id)) return id;\n }\n // Fall back to endDate if it falls in this panel (e.g. right panel when start is in left panel)\n if (selectedRange.endDate && isInPanel(selectedRange.endDate)) {\n const d = new Date(selectedRange.endDate);\n d.setHours(0, 0, 0, 0);\n const id = formatDateId(d);\n if (itemIds.includes(id)) return id;\n }\n const today = new Date();\n if (isInPanel(today)) {\n const id = formatDateId(today);\n if (itemIds.includes(id)) return id;\n }\n return itemIds[0] || '';\n};\n\ninterface UseDatePickerA11yOptions {\n leftMonth: Date;\n rightMonth: Date;\n showSingleMonth: boolean;\n selectedRange: DateRange;\n onMonthChange: (date: Date, isLeft: boolean) => void;\n}\n\ninterface CellKeyDownOptions {\n isLeftCalendar: boolean;\n isDateDisabled: (date: Date) => boolean;\n handleDateClick: (date: Date) => void;\n}\n\ninterface GridCellItemInput {\n cellId: string;\n cellDate: Date;\n disabled: boolean;\n ariaLabel: string;\n ariaSelected: boolean;\n ariaCurrent: 'date' | undefined;\n ariaDisabled: true | undefined;\n}\n\nexport interface GridCellElementProps {\n id: string;\n role: 'gridcell';\n ref: (el: HTMLElement | null) => void;\n tabIndex: number;\n onFocus: () => void;\n 'aria-label': string;\n 'aria-selected': boolean;\n 'aria-current': 'date' | undefined;\n 'aria-disabled': true | undefined;\n onKeyDown: (e: React.KeyboardEvent) => void;\n onClick: () => void;\n}\n\ninterface UseDatePickerA11yReturn {\n getGridCellProps: (options: CellKeyDownOptions) => (item: GridCellItemInput) => GridCellElementProps;\n getLeftRovingItemProps: (id: string) => RovingItemProps;\n getRightRovingItemProps: (id: string) => RovingItemProps;\n getLeftContainerProps: (nameInput?: AccessibleNameInput) => RovingContainerProps;\n getRightContainerProps: (nameInput?: AccessibleNameInput) => RovingContainerProps;\n focusLeftItem: (id: string) => void;\n focusRightItem: (id: string) => void;\n}\n\nexport function useDatePickerA11y({\n leftMonth,\n rightMonth,\n showSingleMonth,\n selectedRange,\n onMonthChange\n}: UseDatePickerA11yOptions): UseDatePickerA11yReturn {\n const [keyboardFocusDate, setKeyboardFocusDate] = useState<Date | null>(null);\n\n const leftItemIds = useMemo(() => getPanelItemIds(leftMonth), [leftMonth]);\n const rightItemIds = useMemo(() => getPanelItemIds(rightMonth), [rightMonth]);\n\n const leftDefaultFocusId = useMemo(\n () => getPanelDefaultFocusId(leftMonth, leftItemIds, selectedRange),\n [leftMonth, leftItemIds, selectedRange]\n );\n const rightDefaultFocusId = useMemo(\n () => getPanelDefaultFocusId(rightMonth, rightItemIds, selectedRange),\n [rightMonth, rightItemIds, selectedRange]\n );\n\n const { getRovingItemProps: getLeftRovingItemProps, focusItem: focusLeftItem, getContainerProps: getLeftContainerProps } = useRovingFocus({\n itemIds: leftItemIds,\n defaultFocusedId: leftDefaultFocusId,\n orientation: 'grid',\n cols: 7,\n loop: false,\n role: 'grid'\n });\n\n const { getRovingItemProps: getRightRovingItemProps, focusItem: focusRightItem, getContainerProps: getRightContainerProps } = useRovingFocus({\n itemIds: rightItemIds,\n defaultFocusedId: rightDefaultFocusId,\n orientation: 'grid',\n cols: 7,\n loop: false,\n role: 'grid'\n });\n\n // After keyboard navigation shifts a panel to a new month, focus the target cell via roving focus refs\n useEffect(() => {\n if (!keyboardFocusDate) return;\n const id = formatDateId(keyboardFocusDate);\n if (leftItemIds.includes(id)) {\n focusLeftItem(id);\n setKeyboardFocusDate(null);\n } else if (rightItemIds.includes(id)) {\n focusRightItem(id);\n setKeyboardFocusDate(null);\n }\n }, [keyboardFocusDate, leftItemIds, rightItemIds, focusLeftItem, focusRightItem]);\n\n // Navigate the keyboard focus to a date that may be in a different month.\n // Each panel advances completely independently — never touches the other panel.\n const handleKeyboardNavigate = useCallback(\n (targetDate: Date, sourcePanel: 'left' | 'right') => {\n const isLeft = showSingleMonth || sourcePanel === 'left';\n onMonthChange(new Date(targetDate.getFullYear(), targetDate.getMonth(), 1), isLeft);\n setKeyboardFocusDate(new Date(targetDate));\n },\n [showSingleMonth, onMonthChange]\n );\n\n const getGridCellProps = useCallback(\n ({ isLeftCalendar, isDateDisabled, handleDateClick }: CellKeyDownOptions) => {\n const panel: 'left' | 'right' = isLeftCalendar ? 'left' : 'right';\n const focusPanelItem = isLeftCalendar ? focusLeftItem : focusRightItem;\n const getRovingItemProps = isLeftCalendar ? getLeftRovingItemProps : getRightRovingItemProps;\n\n const handleKeyDown = (e: React.KeyboardEvent, cellDate: Date) => {\n const cellYear = cellDate.getFullYear();\n const cellMonth = cellDate.getMonth();\n const cellDay = cellDate.getDate();\n\n const navigateTo = (targetDate: Date) => {\n if (targetDate.getFullYear() !== cellYear || targetDate.getMonth() !== cellMonth) {\n handleKeyboardNavigate(targetDate, panel);\n return;\n }\n focusPanelItem(formatDateId(targetDate));\n };\n\n switch (e.key) {\n case 'ArrowLeft':\n e.preventDefault(); e.stopPropagation();\n navigateTo(new Date(cellYear, cellMonth, cellDay - 1));\n break;\n case 'ArrowRight':\n e.preventDefault(); e.stopPropagation();\n navigateTo(new Date(cellYear, cellMonth, cellDay + 1));\n break;\n case 'ArrowUp':\n e.preventDefault(); e.stopPropagation();\n navigateTo(new Date(cellYear, cellMonth, cellDay - 7));\n break;\n case 'ArrowDown':\n e.preventDefault(); e.stopPropagation();\n navigateTo(new Date(cellYear, cellMonth, cellDay + 7));\n break;\n case 'Home': {\n // First day of the current week row (Sunday), clamped to month start\n e.preventDefault(); e.stopPropagation();\n const dayOfWeek = cellDate.getDay();\n const homeDate = new Date(cellYear, cellMonth, cellDay - dayOfWeek);\n const clamped = homeDate.getMonth() !== cellMonth ? new Date(cellYear, cellMonth, 1) : homeDate;\n focusPanelItem(formatDateId(clamped));\n break;\n }\n case 'End': {\n // Last day of the current week row (Saturday), clamped to month end\n e.preventDefault(); e.stopPropagation();\n const dayOfWeek = cellDate.getDay();\n const endDate = new Date(cellYear, cellMonth, cellDay + (6 - dayOfWeek));\n const daysInThisMonth = getDaysInMonth(cellYear, cellMonth);\n const clamped =\n endDate.getMonth() !== cellMonth ? new Date(cellYear, cellMonth, daysInThisMonth) : endDate;\n focusPanelItem(formatDateId(clamped));\n break;\n }\n case 'PageUp': {\n // Shift+PageUp = previous year, PageUp = previous month\n e.preventDefault(); e.stopPropagation();\n const tYear = e.shiftKey ? cellYear - 1 : cellYear;\n const tMonth = e.shiftKey ? cellMonth : cellMonth - 1;\n const tDay = Math.min(cellDay, getDaysInMonth(tYear, tMonth));\n handleKeyboardNavigate(new Date(tYear, tMonth, tDay), panel);\n break;\n }\n case 'PageDown': {\n // Shift+PageDown = next year, PageDown = next month\n e.preventDefault(); e.stopPropagation();\n const tYear = e.shiftKey ? cellYear + 1 : cellYear;\n const tMonth = e.shiftKey ? cellMonth : cellMonth + 1;\n const tDay = Math.min(cellDay, getDaysInMonth(tYear, tMonth));\n handleKeyboardNavigate(new Date(tYear, tMonth, tDay), panel);\n break;\n }\n case 'Enter':\n case ' ':\n e.preventDefault();\n if (!isDateDisabled(cellDate)) {\n handleDateClick(cellDate);\n }\n break;\n }\n };\n\n return ({ cellId, cellDate, disabled, ariaLabel, ariaSelected, ariaCurrent, ariaDisabled }: GridCellItemInput): GridCellElementProps => {\n const rovingProps = getRovingItemProps(cellId);\n return {\n id: cellId,\n role: 'gridcell',\n ref: rovingProps.ref,\n tabIndex: rovingProps.tabIndex,\n onFocus: rovingProps.onFocus,\n 'aria-label': ariaLabel,\n 'aria-selected': ariaSelected,\n 'aria-current': ariaCurrent,\n 'aria-disabled': ariaDisabled,\n onKeyDown: (e: React.KeyboardEvent) => handleKeyDown(e, cellDate),\n onClick: () => { if (!disabled) handleDateClick(cellDate); }\n };\n };\n },\n [handleKeyboardNavigate, focusLeftItem, focusRightItem, getLeftRovingItemProps, getRightRovingItemProps]\n );\n\n return {\n getGridCellProps,\n getLeftRovingItemProps,\n getRightRovingItemProps,\n getLeftContainerProps,\n getRightContainerProps,\n focusLeftItem,\n focusRightItem\n };\n}\n"],"names":["useState","useMemo","useEffect","useCallback","useRovingFocus","getCellAriaLabel","date","isStart","isEnd","isSameStartEnd","singleDateSelection","base","toLocaleDateString","weekday","month","day","year","formatDateId","d","y","getFullYear","m","String","getMonth","padStart","dd","getDate","getDaysInMonth","Date","getPanelItemIds","panelDate","Array","from","length","_","i","getPanelDefaultFocusId","itemIds","selectedRange","isInPanel","startDate","setHours","id","includes","endDate","today","useDatePickerA11y","leftMonth","rightMonth","showSingleMonth","onMonthChange","keyboardFocusDate","setKeyboardFocusDate","leftItemIds","rightItemIds","leftDefaultFocusId","rightDefaultFocusId","getRovingItemProps","getLeftRovingItemProps","focusItem","focusLeftItem","getContainerProps","getLeftContainerProps","defaultFocusedId","orientation","cols","loop","role","getRightRovingItemProps","focusRightItem","getRightContainerProps","handleKeyboardNavigate","targetDate","sourcePanel","isLeft","getGridCellProps","isLeftCalendar","isDateDisabled","handleDateClick","panel","focusPanelItem","handleKeyDown","e","cellDate","cellYear","cellMonth","cellDay","navigateTo","key","preventDefault","stopPropagation","dayOfWeek","getDay","homeDate","clamped","daysInThisMonth","tYear","shiftKey","tMonth","tDay","Math","min","cellId","disabled","ariaLabel","ariaSelected","ariaCurrent","ariaDisabled","rovingProps","ref","tabIndex","onFocus","onKeyDown","onClick"],"mappings":"AAKO,SAAA,YAAAA,GAAA,WAAAC,GAAA,aAAAC,GAAA,eAAAC,SAAA;AAAA,SAAA,kBAAAC,SAAA;AAAA,MAAMC,IAAmBA,CAC9BC,GACAC,GACAC,GACAC,GACAC,MACW;AACX,QAAMC,IAAOL,EAAKM,mBAAmB,SAAS;AAAA,IAC5CC,SAAS;AAAA,IACTC,OAAO;AAAA,IACPC,KAAK;AAAA,IACLC,MAAM;AAAA,EAAA,CACP;AACD,SAAIN,IAA4BC,IAC5BF,IAAuB,GAAGE,CAAI,6BAC9BJ,IAAgB,GAAGI,CAAI,qBACvBH,IAAc,GAAGG,CAAI,mBAClBA;AACT,GAEaM,IAAeA,CAACC,MAAY;AACvC,QAAMC,IAAID,EAAEE,YAAAA,GACNC,IAAIC,OAAOJ,EAAEK,SAAAA,IAAa,CAAC,EAAEC,SAAS,GAAG,GAAG,GAC5CC,IAAKH,OAAOJ,EAAEQ,QAAAA,CAAS,EAAEF,SAAS,GAAG,GAAG;AAC9C,SAAO,QAAQL,CAAC,IAAIE,CAAC,IAAII,CAAE;AAC7B,GAEME,IAAiBA,CAACX,GAAcF,MAAkB,IAAIc,KAAKZ,GAAMF,IAAQ,GAAG,CAAC,EAAEY,QAAAA,GAE/EG,IAAkBA,CAACC,MAA8B;AACrD,QAAMd,IAAOc,EAAUV,YAAAA,GACjBN,IAAQgB,EAAUP,SAAAA;AACxB,SAAOQ,MAAMC,KAAK;AAAA,IAAEC,QAAQN,EAAeX,GAAMF,CAAK;AAAA,EAAA,GAAK,CAACoB,GAAGC,MAC7DlB,EAAa,IAAIW,KAAKZ,G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
};
|
|
5
|
-
function m({
|
|
6
|
-
containerRef: t,
|
|
7
|
-
activeIndex: o,
|
|
8
|
-
itemSelector: r = '[role="option"]',
|
|
9
|
-
enabled: c = !0,
|
|
10
|
-
scrollOptions: e = u
|
|
11
|
-
}) {
|
|
12
|
-
s(() => {
|
|
13
|
-
if (!c || o < 0 || !t?.current)
|
|
14
|
-
return;
|
|
15
|
-
const n = t.current.querySelectorAll(r)[o];
|
|
16
|
-
n && n.scrollIntoView(e);
|
|
17
|
-
}, [o, t, r, c, e]);
|
|
1
|
+
function n(e) {
|
|
2
|
+
return new Promise((t) => setTimeout(t, e));
|
|
18
3
|
}
|
|
19
4
|
export {
|
|
20
|
-
|
|
5
|
+
n as delay
|
|
21
6
|
};
|
|
22
7
|
//# sourceMappingURL=index238.js.map
|
package/dist/index238.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index238.js","sources":["../src/utils/
|
|
1
|
+
{"version":3,"file":"index238.js","sources":["../src/utils/delay.ts"],"sourcesContent":["/**\n * Delays execution by the specified number of milliseconds\n * @param ms - The number of milliseconds to delay\n * @returns A Promise that resolves after the specified delay\n */\nexport function delay(ms: number): Promise<void> {\n return new Promise(resolve => setTimeout(resolve, ms));\n} "],"names":["delay","ms","Promise","resolve","setTimeout"],"mappings":"AAKO,SAASA,EAAMC,GAA2B;AAC7C,SAAO,IAAIC,QAAQC,CAAAA,MAAWC,WAAWD,GAASF,CAAE,CAAC;AACzD;"}
|
package/dist/index240.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { useEffect as s } from "react";
|
|
2
|
+
const u = {
|
|
3
|
+
block: "nearest"
|
|
4
|
+
};
|
|
5
|
+
function m({
|
|
6
|
+
containerRef: t,
|
|
7
|
+
activeIndex: o,
|
|
8
|
+
itemSelector: r = '[role="option"]',
|
|
9
|
+
enabled: c = !0,
|
|
10
|
+
scrollOptions: e = u
|
|
11
|
+
}) {
|
|
12
|
+
s(() => {
|
|
13
|
+
if (!c || o < 0 || !t?.current)
|
|
14
|
+
return;
|
|
15
|
+
const n = t.current.querySelectorAll(r)[o];
|
|
16
|
+
n && n.scrollIntoView(e);
|
|
17
|
+
}, [o, t, r, c, e]);
|
|
9
18
|
}
|
|
10
19
|
export {
|
|
11
|
-
|
|
20
|
+
m as useScrollActiveIntoView
|
|
12
21
|
};
|
|
13
22
|
//# sourceMappingURL=index240.js.map
|
package/dist/index240.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index240.js","sources":["../
|
|
1
|
+
{"version":3,"file":"index240.js","sources":["../src/utils/a11y/useScrollActiveIntoView.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport type { RefObject } from 'react';\n\nconst DEFAULT_SCROLL_OPTIONS: ScrollIntoViewOptions = { block: 'nearest' };\n\nexport interface UseScrollActiveIntoViewOptions {\n /**\n * Ref to the container element\n */\n containerRef?: RefObject<HTMLElement | null>;\n \n /**\n * Index of the currently active/highlighted item (-1 if none)\n */\n activeIndex: number;\n \n /**\n * CSS selector for item elements\n * Default: '[role=\"option\"]'\n */\n itemSelector?: string;\n \n /**\n * Whether scrolling is enabled\n * Default: true\n */\n enabled?: boolean;\n \n /**\n * ScrollIntoView options\n * Default: { block: 'nearest' }\n */\n scrollOptions?: ScrollIntoViewOptions;\n}\n\n/**\n * Hook to automatically scroll the active item into view.\n * \n * Useful for aria-activedescendant patterns where DOM focus stays\n * on the container (e.g., input field) but we need to visually show\n * which descendant option is logically active.\n * \n * Common use cases:\n * - Combobox dropdown options\n * - Menu items with virtual focus\n * - Grid cells with keyboard navigation\n * - Tree view items\n * - Listbox options\n * \n * @example\n * ```tsx\n * const [highlightedIndex, setHighlightedIndex] = useState(-1);\n * const listboxRef = useRef<HTMLDivElement>(null);\n * \n * useScrollActiveIntoView({\n * containerRef: listboxRef,\n * activeIndex: highlightedIndex,\n * itemSelector: '[role=\"option\"]'\n * });\n * \n * // Now when highlightedIndex changes, the item scrolls into view\n * ```\n * \n * @example Custom scroll behavior\n * ```tsx\n * useScrollActiveIntoView({\n * containerRef: menuRef,\n * activeIndex: activeMenuIndex,\n * itemSelector: '[role=\"menuitem\"]',\n * scrollOptions: { block: 'center', behavior: 'smooth' }\n * });\n * ```\n */\nexport function useScrollActiveIntoView({\n containerRef,\n activeIndex,\n itemSelector = '[role=\"option\"]',\n enabled = true,\n scrollOptions = DEFAULT_SCROLL_OPTIONS\n}: UseScrollActiveIntoViewOptions): void {\n useEffect(() => {\n // Early returns for disabled states\n if (!enabled || activeIndex < 0 || !containerRef?.current) {\n return;\n }\n \n const container = containerRef.current;\n const items = container.querySelectorAll(itemSelector);\n const activeItem = items[activeIndex] as HTMLElement;\n \n if (activeItem) {\n activeItem.scrollIntoView(scrollOptions);\n }\n }, [activeIndex, containerRef, itemSelector, enabled, scrollOptions]);\n}\n"],"names":["useEffect","DEFAULT_SCROLL_OPTIONS","block","useScrollActiveIntoView","containerRef","activeIndex","itemSelector","enabled","scrollOptions","current","activeItem","querySelectorAll","scrollIntoView"],"mappings":"AAGA,SAAA,aAAAA,SAAA;AAAA,MAAMC,IAAgD;AAAA,EAAEC,OAAO;AAAU;AAsElE,SAASC,EAAwB;AAAA,EACtCC,cAAAA;AAAAA,EACAC,aAAAA;AAAAA,EACAC,cAAAA,IAAe;AAAA,EACfC,SAAAA,IAAU;AAAA,EACVC,eAAAA,IAAgBP;AACc,GAAS;AACvCD,EAAAA,EAAU,MAAM;AAEd,QAAI,CAACO,KAAWF,IAAc,KAAK,CAACD,GAAcK;AAChD;AAKF,UAAMC,IAFYN,EAAaK,QACPE,iBAAiBL,CAAY,EAC5BD,CAAW;AAEpC,IAAIK,KACFA,EAAWE,eAAeJ,CAAa;AAAA,EAE3C,GAAG,CAACH,GAAaD,GAAcE,GAAcC,GAASC,CAAa,CAAC;AACtE;"}
|
package/dist/index241.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
function r(t, i) {
|
|
2
|
+
if (t == null) return {};
|
|
3
|
+
var o = {};
|
|
4
|
+
for (var e in t) if ({}.hasOwnProperty.call(t, e)) {
|
|
5
|
+
if (i.indexOf(e) !== -1) continue;
|
|
6
|
+
o[e] = t[e];
|
|
7
|
+
}
|
|
8
|
+
return o;
|
|
4
9
|
}
|
|
5
10
|
export {
|
|
6
|
-
|
|
11
|
+
r as default
|
|
7
12
|
};
|
|
8
13
|
//# sourceMappingURL=index241.js.map
|
package/dist/index241.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index241.js","sources":["../node_modules/@babel/runtime/helpers/esm/
|
|
1
|
+
{"version":3,"file":"index241.js","sources":["../node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js"],"sourcesContent":["function _objectWithoutPropertiesLoose(r, e) {\n if (null == r) return {};\n var t = {};\n for (var n in r) if ({}.hasOwnProperty.call(r, n)) {\n if (-1 !== e.indexOf(n)) continue;\n t[n] = r[n];\n }\n return t;\n}\nexport { _objectWithoutPropertiesLoose as default };"],"names":["_objectWithoutPropertiesLoose","r","e","t","n"],"mappings":"AAAA,SAASA,EAA8BC,GAAGC,GAAG;AAC3C,MAAYD,KAAR,KAAW,QAAO,CAAA;AACtB,MAAIE,IAAI,CAAA;AACR,WAASC,KAAKH,EAAG,KAAI,CAAA,EAAG,eAAe,KAAKA,GAAGG,CAAC,GAAG;AACjD,QAAWF,EAAE,QAAQE,CAAC,MAAlB,GAAqB;AACzB,IAAAD,EAAEC,CAAC,IAAIH,EAAEG,CAAC;AAAA,EACZ;AACA,SAAOD;AACT;","x_google_ignoreList":[0]}
|