@sofyan/glass 0.1.6 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react/Glass.tsx","../../src/react/cx.ts","../../src/react/GlassButton.tsx","../../src/react/GlassFilter.tsx","../../src/react/GlassSheet.tsx","../../src/react/swipe.ts"],"sourcesContent":["import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementType,\n type ForwardedRef,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\nimport { cx } from './cx';\n\nexport type GlassTone = 'light' | 'dark' | 'clear' | 'tinted' | 'tinted-secondary' | 'danger';\nexport type GlassThickness = 'thin' | 'regular' | 'thick';\nexport type GlassShape = 'sm' | 'md' | 'lg' | 'xl' | 'pill';\n\nconst TONE_CLASS: Record<GlassTone, string | undefined> = {\n light: undefined,\n dark: 'glass-dark',\n clear: 'glass-clear',\n tinted: 'glass-tinted',\n 'tinted-secondary': 'glass-tinted-secondary',\n danger: 'glass-danger',\n};\n\nconst THICKNESS_CLASS: Record<GlassThickness, string | undefined> = {\n thin: 'glass-thin',\n regular: undefined,\n thick: 'glass-thick',\n};\n\nconst SHAPE_CLASS: Record<GlassShape, string | undefined> = {\n sm: 'glass-sm',\n md: undefined,\n lg: 'glass-lg',\n xl: 'glass-xl',\n pill: 'glass-pill',\n};\n\nexport interface GlassOptions {\n tone?: GlassTone;\n thickness?: GlassThickness;\n shape?: GlassShape;\n /** Hover fill, press-scale and focus ring. Use for clickable surfaces. */\n interactive?: boolean;\n /** Float upward on hover. Use for cards. */\n lift?: boolean;\n /** Chromium-only SVG refraction (no-op elsewhere). Needs <GlassFilter /> mounted once. */\n refract?: boolean;\n}\n\n/** The class list for a glass surface, for elements you can't swap for <Glass>. */\nexport function glassClasses({\n tone = 'light',\n thickness = 'regular',\n shape = 'md',\n interactive = false,\n lift = false,\n refract = false,\n}: GlassOptions = {}): string {\n return cx(\n 'glass',\n TONE_CLASS[tone],\n THICKNESS_CLASS[thickness],\n SHAPE_CLASS[shape],\n interactive && 'glass-interactive',\n lift && 'glass-lift',\n refract && 'glass-refract',\n );\n}\n\nexport type GlassProps<T extends ElementType = 'div'> = GlassOptions & {\n as?: T;\n className?: string;\n children?: ReactNode;\n} & Omit<ComponentPropsWithoutRef<T>, keyof GlassOptions | 'as' | 'className' | 'children'>;\n\nfunction GlassInner<T extends ElementType = 'div'>(\n {\n as,\n tone,\n thickness,\n shape,\n interactive,\n lift,\n refract,\n className,\n children,\n ...rest\n }: GlassProps<T>,\n ref: ForwardedRef<Element>,\n) {\n const Component: ElementType = as ?? 'div';\n return (\n <Component\n ref={ref}\n className={cx(\n glassClasses({ tone, thickness, shape, interactive, lift, refract }),\n className,\n )}\n {...rest}\n >\n {children}\n </Component>\n );\n}\n\n/** A Liquid Glass surface. Polymorphic: `<Glass as=\"nav\" tone=\"dark\" shape=\"pill\">`. */\nexport const Glass = forwardRef(GlassInner) as <T extends ElementType = 'div'>(\n props: GlassProps<T> & { ref?: Ref<Element> },\n) => ReactElement | null;\n","/** Join class names, skipping falsy values. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(' ');\n}\n","import { forwardRef, type ButtonHTMLAttributes } from 'react';\nimport { cx } from './cx';\n\nexport type GlassButtonVariant = 'glass' | 'dark' | 'clear' | 'primary' | 'secondary' | 'danger';\nexport type GlassButtonSize = 'sm' | 'md' | 'lg';\n\nconst VARIANT_CLASS: Record<GlassButtonVariant, string | undefined> = {\n glass: undefined,\n dark: 'glass-dark',\n clear: 'glass-clear',\n primary: 'glass-tinted',\n secondary: 'glass-tinted-secondary',\n danger: 'glass-danger',\n};\n\nconst SIZE_CLASS: Record<GlassButtonSize, string | undefined> = {\n sm: 'glass-btn-sm',\n md: undefined,\n lg: 'glass-btn-lg',\n};\n\nexport interface GlassButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: GlassButtonVariant;\n size?: GlassButtonSize;\n /** Stretch to the container width. */\n block?: boolean;\n}\n\n/** A glass button with a 44px touch target. Defaults to `type=\"button\"`. */\nexport const GlassButton = forwardRef<HTMLButtonElement, GlassButtonProps>(function GlassButton(\n { variant = 'glass', size = 'md', block = false, className, type = 'button', ...rest },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'glass-btn',\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n block && 'glass-block',\n className,\n )}\n {...rest}\n />\n );\n});\n","import { useEffect } from 'react';\n\n/**\n * True when the browser renders SVG filters inside `backdrop-filter`\n * (currently Chromium only). Safari and Firefox accept the syntax but either\n * ignore it or drop the whole backdrop, so we gate on the engine instead.\n */\nexport function supportsBackdropRefraction(): boolean {\n if (typeof navigator === 'undefined' || typeof CSS === 'undefined') return false;\n const uaData = (navigator as Navigator & { userAgentData?: { brands?: { brand: string }[] } })\n .userAgentData;\n const isChromium = !!uaData?.brands?.some((b) => b.brand === 'Chromium');\n return isChromium && CSS.supports('backdrop-filter', 'url(#lg-refract)');\n}\n\n/**\n * Mount once near the app root. Provides the `#lg-refract` displacement filter\n * used by `.glass-refract` and flags support on <html data-lg-refract>.\n */\nexport function GlassFilter() {\n useEffect(() => {\n if (!supportsBackdropRefraction()) return;\n const root = document.documentElement;\n root.setAttribute('data-lg-refract', '');\n return () => {\n root.removeAttribute('data-lg-refract');\n };\n }, []);\n\n return (\n <svg\n aria-hidden=\"true\"\n focusable=\"false\"\n width=\"0\"\n height=\"0\"\n style={{ position: 'absolute', width: 0, height: 0, overflow: 'hidden' }}\n >\n <filter\n id=\"lg-refract\"\n x=\"0\"\n y=\"0\"\n width=\"100%\"\n height=\"100%\"\n colorInterpolationFilters=\"sRGB\"\n >\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.008 0.012\"\n numOctaves=\"2\"\n seed=\"7\"\n result=\"noise\"\n />\n <feGaussianBlur in=\"noise\" stdDeviation=\"2\" result=\"softNoise\" />\n <feDisplacementMap\n in=\"SourceGraphic\"\n in2=\"softNoise\"\n scale=\"18\"\n xChannelSelector=\"R\"\n yChannelSelector=\"G\"\n />\n </filter>\n </svg>\n );\n}\n","import {\n useEffect,\n useId,\n useRef,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n} from 'react';\nimport { cx } from './cx';\nimport { useSwipeToClose } from './swipe';\n\nexport interface GlassSheetProps {\n open: boolean;\n /** Called when the person closes it: the close button, a swipe down, Esc or a tap outside. */\n onClose: () => void;\n /** Names the dialog (aria-labelledby). */\n title: ReactNode;\n /** Small line above the title, e.g. \"About event\". */\n eyebrow?: ReactNode;\n /** Accessible name of the close button. Translate it. */\n closeLabel?: string;\n /** Pull down to close in the phone (bottom sheet) layout. Default true. */\n swipeToClose?: boolean;\n /** Content pinned under the scrolling body, e.g. actions. */\n footer?: ReactNode;\n children?: ReactNode;\n className?: string;\n bodyClassName?: string;\n}\n\n/** Light dismiss is native where `closedby` is supported; elsewhere it is done below. */\nconst needsLightDismissFallback = () =>\n typeof HTMLDialogElement !== 'undefined' && !('closedBy' in HTMLDialogElement.prototype);\n\nconst isOutside = (e: ReactMouseEvent<HTMLDialogElement>) => {\n const r = e.currentTarget.getBoundingClientRect();\n return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;\n};\n\nfunction CloseIcon() {\n return (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M6 18 18 6M6 6l12 12\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n\n/**\n * A modal sheet on a native <dialog>: the browser makes the page inert, keeps focus inside,\n * closes on Esc and returns focus to the opener. Centred from 640px up; on phones a bottom\n * sheet with a grabber that can be pulled down to close. On phones the ✕ is hidden, like a\n * native sheet: a tap outside is the single-tap alternative to the swipe (WCAG 2.5.1 and\n * 2.5.7), and the button stays for screen readers and keyboards.\n *\n * Opening focuses the dialog itself rather than the close button, so screen readers start\n * at the title and no focus ring flashes on the ✕ for touch users.\n */\nexport function GlassSheet({\n open,\n onClose,\n title,\n eyebrow,\n closeLabel = 'Close',\n swipeToClose = true,\n footer,\n children,\n className,\n bodyClassName,\n}: GlassSheetProps) {\n const dialogRef = useRef<HTMLDialogElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const titleId = useId();\n const pressedOutside = useRef(false);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog || open === dialog.hasAttribute('open')) return;\n // Feature-checked: older engines and jsdom lack showModal/close.\n if (open) {\n if (typeof dialog.showModal === 'function') dialog.showModal();\n else dialog.setAttribute('open', '');\n dialog.focus({ preventScroll: true });\n if (bodyRef.current) bodyRef.current.scrollTop = 0;\n } else if (typeof dialog.close === 'function') {\n dialog.close();\n } else {\n dialog.removeAttribute('open');\n }\n }, [open]);\n\n useSwipeToClose(dialogRef, { enabled: open && swipeToClose, scrollRef: bodyRef, onClose });\n\n return (\n <dialog\n ref={dialogRef}\n // Not yet in React's types; React passes it through as an attribute.\n {...{ closedby: 'any' }}\n tabIndex={-1}\n aria-labelledby={titleId}\n // Esc or light dismiss closed it; when `open` is already false the page closed it.\n onClose={() => {\n if (open) onClose();\n }}\n // Without `closedby`: close only when both the press and the release are outside the\n // box, so a text selection dragged onto the backdrop does not dismiss.\n onPointerDown={(e) => {\n pressedOutside.current = needsLightDismissFallback() && isOutside(e);\n }}\n onPointerUp={(e) => {\n if (pressedOutside.current && isOutside(e)) onClose();\n pressedOutside.current = false;\n }}\n className={cx('glass-dialog', className)}\n >\n {swipeToClose && <div className=\"glass-dialog-grabber\" aria-hidden=\"true\" />}\n <header className=\"glass-dialog-header\">\n <div className=\"glass-dialog-heading\">\n {eyebrow && <p className=\"glass-dialog-eyebrow\">{eyebrow}</p>}\n <h2 id={titleId} className=\"glass-dialog-title\">\n {title}\n </h2>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={closeLabel}\n className=\"glass-dialog-close\"\n >\n <CloseIcon />\n </button>\n </header>\n <div ref={bodyRef} className={cx('glass-dialog-body', bodyClassName)}>\n {children}\n </div>\n {footer && <div className=\"glass-dialog-footer\">{footer}</div>}\n </dialog>\n );\n}\n","import { useEffect, useRef, type RefObject } from 'react';\n\n/** Movement (px) before a press counts as a drag, so taps and small jitters stay taps. */\nexport const DRAG_SLOP_PX = 8;\n/** Pull further than this share of the sheet's height and it closes on release. */\nexport const CLOSE_DISTANCE_RATIO = 0.25;\n/** Or flick downward at least this fast (px per ms), however short the pull. */\nexport const CLOSE_VELOCITY = 0.5;\n/** A flick only counts once the sheet has moved this far, so a twitch doesn't close it. */\nexport const MIN_FLICK_PX = 24;\n/** How long the sheet takes to slide away or settle back (ms). */\nexport const SETTLE_MS = 220;\n/**\n * How long after release the owner is asked to close (ms): the slide-away plus a margin, so\n * the transition has really finished. Closing a dialog while its transform is still moving\n * is one more thing iOS Safari may get wrong.\n */\nexport const SLIDE_AWAY_MS = SETTLE_MS + 60;\n/**\n * After `onClose`, how long the sheet waits off-screen for its owner to close it (ms). If it\n * is still open by then (the owner kept it, e.g. to ask \"discard changes?\"), it comes back.\n */\nexport const REOPEN_AFTER_MS = 250;\n\nconst SETTLE_EASE = 'cubic-bezier(0.22, 1, 0.36, 1)';\n\nexport interface ReleaseState {\n /** How far the sheet is pulled down (px). */\n offset: number;\n /** The sheet's height (px). */\n height: number;\n /** Downward speed at release (px per ms; negative means moving up). */\n velocity: number;\n}\n\n/** Whether a released drag should close the sheet or let it settle back. */\nexport function shouldClose({ offset, height, velocity }: ReleaseState): boolean {\n if (offset <= 0) return false;\n if (height > 0 && offset >= height * CLOSE_DISTANCE_RATIO) return true;\n return velocity >= CLOSE_VELOCITY && offset >= MIN_FLICK_PX;\n}\n\n/** Controls a press should leave alone: a drag starting on one would steal its tap. */\nconst INTERACTIVE =\n 'button, a[href], input, select, textarea, label, summary, [contenteditable=\"\"], [contenteditable=\"true\"], [role=\"button\"], [role=\"slider\"], [data-glass-no-drag]';\n\n/** Counts the hook runs per sheet, so a late tidy-up never touches a sheet that is in use again. */\nconst runs = new WeakMap<HTMLElement, number>();\n\nconst prefersReducedMotion = () =>\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n\nexport interface SwipeToCloseOptions {\n /** Turn the gesture on or off (e.g. only while open, only in the bottom-sheet layout). */\n enabled: boolean;\n /** The scrolling part of the sheet. A press there drags only while it is scrolled to the top. */\n scrollRef?: RefObject<HTMLElement | null>;\n /**\n * Called once the sheet has slid away. The sheet stays off-screen until `enabled` turns\n * false; if that has not happened `REOPEN_AFTER_MS` later, it slides back.\n *\n * From release until the sheet is closed and tidied up (or comes back) it carries\n * `data-closing`. Style the backdrop with it, so the dim is gone before the close.\n */\n onClose: () => void;\n /** Media query for when the gesture applies. Default: the phone bottom-sheet layout. */\n media?: string;\n}\n\ninterface Drag {\n pointerId: number | 'touch';\n startX: number;\n startY: number;\n lastY: number;\n lastT: number;\n velocity: number;\n /** Null until the press has moved past the slop and we know whether it is our drag. */\n active: boolean | null;\n}\n\n/**\n * Pull-down-to-close for a sheet. Touch uses touch events, because a pointer-events drag\n * over scrollable content is cancelled by the browser as soon as it starts to pan; with\n * a non-passive touchmove we can stop that pan. Mouse and pen use pointer events. The sheet\n * follows the finger via an inline transform and either slides away (then `onClose`) or\n * settles back.\n *\n * iOS Safari decides at the first touchmove of a gesture whether the page pans, and later\n * moves can no longer stop it. So wherever nothing in the sheet would scroll for that touch\n * (the header, grabber and backdrop, a downward pull at the top of the body, a body with\n * nothing to scroll), touchmoves are cancelled from the first one; taps still click.\n *\n * After a slide-away the inline transform is kept until the effect is torn down (the owner\n * closed the sheet and `enabled` turned false). Clearing it earlier would show the sheet at\n * rest for a frame before the close is committed.\n *\n * From release until the sheet is closed and tidied up, or comes back, the sheet has the\n * attribute `data-closing`. Fade the backdrop out with it (`[data-closing]::backdrop`): iOS\n * Safari can leave a dialog's backdrop painted after it closes, so it must be clear by then.\n */\nexport function useSwipeToClose(\n sheetRef: RefObject<HTMLElement | null>,\n { enabled, scrollRef, onClose, media = '(max-width: 639.98px)' }: SwipeToCloseOptions,\n): void {\n const onCloseRef = useRef(onClose);\n onCloseRef.current = onClose;\n\n useEffect(() => {\n const sheet = sheetRef.current;\n if (!enabled || !sheet) return;\n\n let drag: Drag | null = null;\n // Cancel every touchmove until this touch ends: nothing under it scrolls, so a pan would\n // move the page behind the dialog. Cleared on touchstart, touchend and touchcancel.\n let holdPage = false;\n let suppressClick = false;\n // False once the effect is torn down, so nothing is scheduled on a sheet we let go of.\n let alive = true;\n // True from release until the owner closes the sheet or it comes back.\n let closing = false;\n // The release phases (slide away, wait for the owner, settle back) run one after\n // another, so a single timer handle covers them.\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const clearTimer = () => {\n clearTimeout(timer);\n timer = undefined;\n };\n\n const applies = () =>\n typeof window.matchMedia !== 'function' || window.matchMedia(media).matches;\n\n const resetStyles = () => {\n sheet.style.transform = '';\n sheet.style.transition = '';\n sheet.removeAttribute('data-dragging');\n sheet.removeAttribute('data-closing');\n };\n\n // Start clean: an earlier run may have left its inline styles (see the cleanup).\n runs.set(sheet, (runs.get(sheet) ?? 0) + 1);\n resetStyles();\n sheet.style.animation = '';\n\n /** Animate back to rest, then drop the inline styles. */\n const settleBack = () => {\n // Now, not once it has settled: the backdrop fades back in while the sheet slides up.\n sheet.removeAttribute('data-closing');\n sheet.style.transition = `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;\n sheet.style.transform = '';\n // A timer, not transitionend: that event never fires if nothing moved or the tab hid.\n timer = setTimeout(resetStyles, SETTLE_MS);\n };\n\n /**\n * Ask the owner to close, leaving the sheet where it is. The effect cleanup clears the\n * styles once the sheet really closes; if it is still open after REOPEN_AFTER_MS,\n * `comeBack` runs.\n */\n const requestClose = (comeBack: () => void) => {\n try {\n onCloseRef.current();\n } finally {\n // The owner may have closed the sheet synchronously, tearing this effect down.\n if (alive) {\n timer = setTimeout(() => {\n closing = false;\n comeBack();\n }, REOPEN_AFTER_MS);\n }\n }\n };\n\n const begin = (id: Drag['pointerId'], x: number, y: number, target: EventTarget | null) => {\n // While closing, the sheet is sliding away or waiting for its owner: leave it be.\n if (drag || closing || !applies()) return;\n const el = target instanceof Element ? target : null;\n if (!el || !sheet.contains(el) || el.closest(INTERACTIVE)) return;\n const scroller = scrollRef?.current;\n if (scroller && scroller.contains(el) && scroller.scrollTop > 0) return;\n // Text selected inside the body: the press is probably adjusting it.\n if (scroller?.contains(el) && window.getSelection()?.isCollapsed === false) return;\n clearTimer();\n drag = {\n pointerId: id,\n startX: x,\n startY: y,\n lastY: y,\n lastT: performance.now(),\n velocity: 0,\n active: null,\n };\n };\n\n /** Returns true while the move belongs to the drag (so the caller can stop scrolling). */\n const move = (x: number, y: number): boolean => {\n if (!drag) return false;\n const dy = y - drag.startY;\n const dx = x - drag.startX;\n if (drag.active === null) {\n if (Math.abs(dy) < DRAG_SLOP_PX && Math.abs(dx) < DRAG_SLOP_PX) return false;\n // Upward or sideways: a scroll or a swipe for something else. Let it go.\n if (dy <= 0 || Math.abs(dx) > Math.abs(dy)) {\n drag = null;\n return false;\n }\n drag.active = true;\n sheet.setAttribute('data-dragging', '');\n sheet.style.transition = 'none';\n // Off until the sheet closes (see cleanup). An open animation with a fill mode would\n // override the inline transform, and switching it off only for the drag would replay\n // it on release.\n sheet.style.animation = 'none';\n }\n const now = performance.now();\n const dt = now - drag.lastT;\n if (dt > 0) drag.velocity = (y - drag.lastY) / dt;\n drag.lastY = y;\n drag.lastT = now;\n sheet.style.transform = `translate3d(0, ${Math.max(0, dy - DRAG_SLOP_PX)}px, 0)`;\n return true;\n };\n\n const end = () => {\n if (!drag) return;\n const wasActive = drag.active === true;\n const wasTouch = drag.pointerId === 'touch';\n const offset = Math.max(0, drag.lastY - drag.startY - DRAG_SLOP_PX);\n // A long pause before letting go means the flick is over.\n const velocity = performance.now() - drag.lastT > 100 ? 0 : drag.velocity;\n drag = null;\n if (!wasActive) return;\n // Only a mouse or pen drag ends in a click to swallow. A touch drag does not, and the\n // flag would then eat the next real activation (e.g. from a screen reader).\n suppressClick = !wasTouch;\n sheet.removeAttribute('data-dragging');\n\n const close = shouldClose({ offset, height: sheet.getBoundingClientRect().height, velocity });\n const reduceMotion = prefersReducedMotion();\n if (!close) {\n if (reduceMotion) resetStyles();\n else settleBack();\n return;\n }\n closing = true;\n // The backdrop fades out from now, so nothing dark is left to repaint at the close.\n sheet.setAttribute('data-closing', '');\n // Reduced motion: no slide, the sheet goes at once. The close still waits, so it never\n // lands in the frame the backdrop changes.\n sheet.style.transition = reduceMotion ? 'none' : `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;\n sheet.style.transform = 'translate3d(0, 100%, 0)';\n // A timer, not transitionend: that event never fires if nothing moved or the tab hid.\n const comeBack = reduceMotion ? resetStyles : settleBack;\n timer = setTimeout(() => requestClose(comeBack), SLIDE_AWAY_MS);\n };\n\n const cancel = () => {\n const wasActive = drag?.active === true;\n drag = null;\n if (wasActive) resetStyles();\n };\n\n /** Whether the body has nothing to scroll, so a pan in it would chain to the page. */\n const bodyCannotScroll = () => {\n const scroller = scrollRef?.current;\n return !scroller || scroller.scrollHeight <= scroller.clientHeight;\n };\n\n // Touch\n const onTouchStart = (e: TouchEvent) => {\n holdPage = false;\n const t = e.touches[0];\n if (e.touches.length !== 1 || !t) return cancel();\n begin('touch', t.clientX, t.clientY, e.target);\n // Outside the body (header, grabber, footer, the backdrop) nothing scrolls natively;\n // nor does a body whose content fits. Hold from the start: the first move decides.\n const scroller = scrollRef?.current;\n const inBody = !!scroller && e.target instanceof Node && scroller.contains(e.target);\n holdPage = drag?.pointerId === 'touch' && (!inBody || bodyCannotScroll());\n };\n const onTouchMove = (e: TouchEvent) => {\n const t = e.touches[0];\n let stopPan = holdPage;\n if (t && drag?.pointerId === 'touch') {\n const pulledDown = t.clientY > drag.startY;\n if (move(t.clientX, t.clientY)) {\n stopPan = true; // our drag\n } else if (drag) {\n // Within the slop. At the top of the body a pull down has nothing to scroll.\n stopPan ||= pulledDown;\n } else if (bodyCannotScroll()) {\n // Dropped as not ours, and the body has nothing to scroll: keep the page still.\n holdPage = true;\n stopPan = true;\n }\n }\n if (stopPan && e.cancelable) e.preventDefault();\n };\n const onTouchEnd = () => {\n holdPage = false;\n if (drag?.pointerId === 'touch') end();\n };\n const onTouchCancel = () => {\n holdPage = false;\n cancel();\n };\n\n // Mouse and pen (touch is handled above)\n const onPointerDown = (e: PointerEvent) => {\n if (e.pointerType === 'touch' || e.button !== 0) return;\n begin(e.pointerId, e.clientX, e.clientY, e.target);\n };\n const onPointerMove = (e: PointerEvent) => {\n if (drag?.pointerId !== e.pointerId) return;\n if (move(e.clientX, e.clientY)) e.preventDefault();\n };\n const onPointerUp = (e: PointerEvent) => {\n if (drag?.pointerId === e.pointerId) end();\n };\n const onPointerCancel = (e: PointerEvent) => {\n if (drag?.pointerId === e.pointerId) cancel();\n };\n\n // A mouse drag ends with a click on whatever is under it; that click must not count.\n const onClickCapture = (e: MouseEvent) => {\n if (!suppressClick) return;\n suppressClick = false;\n e.preventDefault();\n e.stopPropagation();\n };\n const clearSuppress = () => {\n suppressClick = false;\n };\n\n sheet.addEventListener('touchstart', onTouchStart, { passive: true });\n sheet.addEventListener('touchmove', onTouchMove, { passive: false });\n sheet.addEventListener('touchend', onTouchEnd);\n sheet.addEventListener('touchcancel', onTouchCancel);\n sheet.addEventListener('pointerdown', onPointerDown);\n sheet.addEventListener('click', onClickCapture, true);\n window.addEventListener('pointermove', onPointerMove);\n window.addEventListener('pointerup', onPointerUp);\n window.addEventListener('pointercancel', onPointerCancel);\n window.addEventListener('pointerdown', clearSuppress, true);\n\n return () => {\n alive = false;\n clearTimer();\n // Never change the sheet in the frame it closes: moving it or restarting its open\n // animation together with dialog.close() is the suspected cause of the backdrop staying\n // painted on iOS Safari. Tidy up a moment later (styles and `data-closing`), unless the\n // sheet is in use again.\n const mine = runs.get(sheet);\n setTimeout(() => {\n if (runs.get(sheet) !== mine) return;\n resetStyles();\n sheet.style.animation = '';\n }, SLIDE_AWAY_MS);\n sheet.removeEventListener('touchstart', onTouchStart);\n sheet.removeEventListener('touchmove', onTouchMove);\n sheet.removeEventListener('touchend', onTouchEnd);\n sheet.removeEventListener('touchcancel', onTouchCancel);\n sheet.removeEventListener('pointerdown', onPointerDown);\n sheet.removeEventListener('click', onClickCapture, true);\n window.removeEventListener('pointermove', onPointerMove);\n window.removeEventListener('pointerup', onPointerUp);\n window.removeEventListener('pointercancel', onPointerCancel);\n window.removeEventListener('pointerdown', clearSuppress, true);\n };\n }, [enabled, media, scrollRef, sheetRef]);\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAOK;;;ACPA,SAAS,MAAM,OAAyD;AAC7E,SAAO,MAAM,OAAO,OAAO,EAAE,KAAK,GAAG;AACvC;;;AD0FI;AA9EJ,IAAM,aAAoD;AAAA,EACxD,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,oBAAoB;AAAA,EACpB,QAAQ;AACV;AAEA,IAAM,kBAA8D;AAAA,EAClE,MAAM;AAAA,EACN,SAAS;AAAA,EACT,OAAO;AACT;AAEA,IAAM,cAAsD;AAAA,EAC1D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR;AAeO,SAAS,aAAa;AAAA,EAC3B,OAAO;AAAA,EACP,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,cAAc;AAAA,EACd,OAAO;AAAA,EACP,UAAU;AACZ,IAAkB,CAAC,GAAW;AAC5B,SAAO;AAAA,IACL;AAAA,IACA,WAAW,IAAI;AAAA,IACf,gBAAgB,SAAS;AAAA,IACzB,YAAY,KAAK;AAAA,IACjB,eAAe;AAAA,IACf,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AACF;AAQA,SAAS,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useEffect","useRef","useEffect","jsx","jsxs","useRef","useEffect"]}
1
+ {"version":3,"sources":["../../src/react/Glass.tsx","../../src/react/cx.ts","../../src/react/GlassButton.tsx","../../src/react/GlassConfirm.tsx","../../src/react/dialog.ts","../../src/react/node.ts","../../src/react/GlassField.tsx","../../src/react/GlassFilter.tsx","../../src/react/GlassSheet.tsx","../../src/react/CloseIcon.tsx","../../src/react/swipe.ts","../../src/react/GlassTabs.tsx","../../src/react/GlassToast.tsx"],"sourcesContent":["import {\n forwardRef,\n type ComponentPropsWithoutRef,\n type ElementType,\n type ForwardedRef,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\nimport { cx } from './cx';\n\nexport type GlassTone = 'light' | 'dark' | 'clear' | 'tinted' | 'tinted-secondary' | 'danger';\nexport type GlassThickness = 'thin' | 'regular' | 'thick';\nexport type GlassShape = 'sm' | 'md' | 'lg' | 'xl' | 'pill';\n\nconst TONE_CLASS: Record<GlassTone, string | undefined> = {\n light: undefined,\n dark: 'glass-dark',\n clear: 'glass-clear',\n tinted: 'glass-tinted',\n 'tinted-secondary': 'glass-tinted-secondary',\n danger: 'glass-danger',\n};\n\nconst THICKNESS_CLASS: Record<GlassThickness, string | undefined> = {\n thin: 'glass-thin',\n regular: undefined,\n thick: 'glass-thick',\n};\n\nconst SHAPE_CLASS: Record<GlassShape, string | undefined> = {\n sm: 'glass-sm',\n md: undefined,\n lg: 'glass-lg',\n xl: 'glass-xl',\n pill: 'glass-pill',\n};\n\nexport interface GlassOptions {\n tone?: GlassTone;\n thickness?: GlassThickness;\n shape?: GlassShape;\n /** Hover fill, press-scale and focus ring. Use for clickable surfaces. */\n interactive?: boolean;\n /** Float upward on hover. Use for cards. */\n lift?: boolean;\n /** Chromium-only SVG refraction (no-op elsewhere). Needs <GlassFilter /> mounted once. */\n refract?: boolean;\n}\n\n/** The class list for a glass surface, for elements you can't swap for <Glass>. */\nexport function glassClasses({\n tone = 'light',\n thickness = 'regular',\n shape = 'md',\n interactive = false,\n lift = false,\n refract = false,\n}: GlassOptions = {}): string {\n return cx(\n 'glass',\n TONE_CLASS[tone],\n THICKNESS_CLASS[thickness],\n SHAPE_CLASS[shape],\n interactive && 'glass-interactive',\n lift && 'glass-lift',\n refract && 'glass-refract',\n );\n}\n\nexport type GlassProps<T extends ElementType = 'div'> = GlassOptions & {\n as?: T;\n className?: string;\n children?: ReactNode;\n} & Omit<ComponentPropsWithoutRef<T>, keyof GlassOptions | 'as' | 'className' | 'children'>;\n\nfunction GlassInner<T extends ElementType = 'div'>(\n {\n as,\n tone,\n thickness,\n shape,\n interactive,\n lift,\n refract,\n className,\n children,\n ...rest\n }: GlassProps<T>,\n ref: ForwardedRef<Element>,\n) {\n const Component: ElementType = as ?? 'div';\n return (\n <Component\n ref={ref}\n className={cx(\n glassClasses({ tone, thickness, shape, interactive, lift, refract }),\n className,\n )}\n {...rest}\n >\n {children}\n </Component>\n );\n}\n\n/** A Liquid Glass surface. Polymorphic: `<Glass as=\"nav\" tone=\"dark\" shape=\"pill\">`. */\nexport const Glass = forwardRef(GlassInner) as <T extends ElementType = 'div'>(\n props: GlassProps<T> & { ref?: Ref<Element> },\n) => ReactElement | null;\n","/** Join class names, skipping falsy values. */\nexport function cx(...parts: Array<string | false | null | undefined>): string {\n return parts.filter(Boolean).join(' ');\n}\n","import { forwardRef, type ButtonHTMLAttributes } from 'react';\nimport { cx } from './cx';\n\nexport type GlassButtonVariant = 'glass' | 'dark' | 'clear' | 'primary' | 'secondary' | 'danger';\nexport type GlassButtonSize = 'sm' | 'md' | 'lg';\n\nconst VARIANT_CLASS: Record<GlassButtonVariant, string | undefined> = {\n glass: undefined,\n dark: 'glass-dark',\n clear: 'glass-clear',\n primary: 'glass-tinted',\n secondary: 'glass-tinted-secondary',\n danger: 'glass-danger',\n};\n\nconst SIZE_CLASS: Record<GlassButtonSize, string | undefined> = {\n sm: 'glass-btn-sm',\n md: undefined,\n lg: 'glass-btn-lg',\n};\n\nexport interface GlassButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: GlassButtonVariant;\n size?: GlassButtonSize;\n /** Stretch to the container width. */\n block?: boolean;\n}\n\n/** A glass button with a 44px touch target. Defaults to `type=\"button\"`. */\nexport const GlassButton = forwardRef<HTMLButtonElement, GlassButtonProps>(function GlassButton(\n { variant = 'glass', size = 'md', block = false, className, type = 'button', ...rest },\n ref,\n) {\n return (\n <button\n ref={ref}\n type={type}\n className={cx(\n 'glass-btn',\n VARIANT_CLASS[variant],\n SIZE_CLASS[size],\n block && 'glass-block',\n className,\n )}\n {...rest}\n />\n );\n});\n","import {\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type KeyboardEvent,\n type ReactNode,\n type SyntheticEvent,\n} from 'react';\nimport { cx } from './cx';\nimport { canShowModal, closeDialog, openDialog } from './dialog';\nimport { GlassButton } from './GlassButton';\nimport { renders } from './node';\n\nexport type GlassConfirmTone = 'neutral' | 'danger';\n\nexport interface GlassConfirmProps {\n open: boolean;\n /** The confirm button. */\n onConfirm: () => void;\n /** The cancel button, Esc, or any other way the dialog is closed without confirming. */\n onCancel: () => void;\n /** The question. Names the dialog (aria-labelledby). */\n title: ReactNode;\n /** What happens if they confirm. Describes the dialog (aria-describedby). */\n message?: ReactNode;\n confirmLabel?: string;\n cancelLabel?: string;\n /** `danger` for what is hard to undo: a red confirm button, and focus starts on Cancel. */\n tone?: GlassConfirmTone;\n confirmDisabled?: boolean;\n /** Shown between the message and the buttons: more details, or an input. */\n children?: ReactNode;\n className?: string;\n}\n\n/** What `confirm()` of `useGlassConfirm` takes: the dialog's text and tone, and `details`. */\nexport interface GlassConfirmOptions extends Pick<\n GlassConfirmProps,\n 'title' | 'message' | 'confirmLabel' | 'cancelLabel' | 'tone'\n> {\n /** Shown between the message and the buttons, like `children` of <GlassConfirm>. */\n details?: ReactNode;\n}\n\nexport interface GlassConfirmHook {\n /** Asks, and resolves with the answer: true for confirm, false for anything else. */\n confirm: (options: GlassConfirmOptions) => Promise<boolean>;\n /** Render it once, anywhere in the component. */\n dialog: ReactNode;\n}\n\n// A layout effect opens the dialog before the browser paints, so its content never shows in\n// a closed dialog for a frame. On the server, where layout effects never run, a plain effect\n// avoids React 18's warning about them.\nconst useIsomorphicLayoutEffect = typeof document === 'undefined' ? useEffect : useLayoutEffect;\n\n/**\n * A confirmation on a native <dialog> (APG alertdialog): the page goes inert, focus stays\n * inside and returns to the opener on close. It must be answered: Esc cancels, a tap on the\n * backdrop does nothing.\n *\n * Focus starts on the confirm button, or on Cancel when `tone` is `danger` (or confirm is\n * disabled), so a stray Enter never does the irreversible thing. An element in `children`\n * with `autoFocus` (or `autofocus`) keeps focus instead.\n */\nexport function GlassConfirm({\n open,\n onConfirm,\n onCancel,\n title,\n message,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n tone = 'neutral',\n confirmDisabled = false,\n children,\n className,\n}: GlassConfirmProps) {\n const dialogRef = useRef<HTMLDialogElement>(null);\n const detailsRef = useRef<HTMLDivElement>(null);\n const confirmRef = useRef<HTMLButtonElement>(null);\n const cancelRef = useRef<HTMLButtonElement>(null);\n const titleId = useId();\n const messageId = useId();\n const hasMessage = renders(message);\n // The content mounts only once the dialog is open. React focuses an `autoFocus` element as\n // it mounts, and that fails in a closed dialog.\n const [shown, setShown] = useState(false);\n\n useIsomorphicLayoutEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog) return;\n const isOpen = dialog.hasAttribute('open');\n if (open && !isOpen) openDialog(dialog);\n if (!open && isOpen) closeDialog(dialog);\n setShown(open);\n }, [open]);\n\n // Initial focus, once the content is in. Only when it opens: later renders leave focus be.\n useIsomorphicLayoutEffect(() => {\n if (!shown) return;\n const details = detailsRef.current;\n if (details?.contains(document.activeElement)) return; // `autoFocus` in children\n const marked = details?.querySelector<HTMLElement>('[autofocus]');\n if (marked) {\n marked.focus();\n return;\n }\n const safest = tone === 'danger' || confirmDisabled ? cancelRef : confirmRef;\n safest.current?.focus();\n }, [shown]);\n\n // Esc and other close requests: keep the dialog open and let the owner close it via `open`.\n const handleCancel = (e: SyntheticEvent<HTMLDialogElement>) => {\n e.preventDefault();\n onCancel();\n };\n\n // Closed anyway while `open` is still true: the browser may refuse to keep it open (Chrome\n // after repeated Esc presses), or a <form method=\"dialog\"> inside closed it. The attribute\n // check skips a stale close event when the dialog was closed and opened again in one go.\n const handleClose = () => {\n if (open && !dialogRef.current?.hasAttribute('open')) onCancel();\n };\n\n // Without showModal there is no native Esc, so it is done here.\n const handleKeyDown = (e: KeyboardEvent<HTMLDialogElement>) => {\n if (e.key !== 'Escape' || e.defaultPrevented || canShowModal(e.currentTarget)) return;\n e.preventDefault();\n onCancel();\n };\n\n return (\n <dialog\n ref={dialogRef}\n role=\"alertdialog\"\n aria-modal=\"true\"\n aria-labelledby={titleId}\n aria-describedby={hasMessage ? messageId : undefined}\n tabIndex={-1}\n onCancel={handleCancel}\n onClose={handleClose}\n onKeyDown={handleKeyDown}\n className={cx('glass-confirm', className)}\n >\n {shown && (\n <>\n <h2 id={titleId} className=\"glass-confirm-title\">\n {title}\n </h2>\n {hasMessage && (\n <div id={messageId} className=\"glass-confirm-message\">\n {message}\n </div>\n )}\n {renders(children) && (\n <div ref={detailsRef} className=\"glass-confirm-details\">\n {children}\n </div>\n )}\n <div className=\"glass-confirm-actions\">\n <GlassButton ref={cancelRef} onClick={onCancel}>\n {cancelLabel}\n </GlassButton>\n <GlassButton\n ref={confirmRef}\n variant={tone === 'danger' ? 'danger' : 'primary'}\n disabled={confirmDisabled}\n onClick={onConfirm}\n >\n {confirmLabel}\n </GlassButton>\n </div>\n </>\n )}\n </dialog>\n );\n}\n\ninterface ConfirmRequest {\n options: GlassConfirmOptions;\n resolve: (confirmed: boolean) => void;\n}\n\n/**\n * `await confirm({ title })` instead of wiring `open` state. Render `dialog` once.\n *\n * Each promise resolves exactly once: true on confirm, false on cancel, when a newer\n * `confirm()` replaces it, or when the component unmounts.\n */\nexport function useGlassConfirm(): GlassConfirmHook {\n // The options stay after the dialog closes, so nothing in it changes in the frame it closes.\n const [state, setState] = useState<{ open: boolean; options: GlassConfirmOptions }>({\n open: false,\n options: { title: '' },\n });\n // The request waiting for an answer, and one waiting for the dialog to close first.\n const pending = useRef<ConfirmRequest | null>(null);\n const queued = useRef<ConfirmRequest | null>(null);\n\n const answer = useCallback((confirmed: boolean) => {\n const request = pending.current;\n if (!request) return;\n pending.current = null;\n request.resolve(confirmed);\n setState((s) => ({ ...s, open: false }));\n }, []);\n\n const confirm = useCallback(\n (options: GlassConfirmOptions) =>\n new Promise<boolean>((resolve) => {\n const request = { options, resolve };\n const previous = pending.current;\n pending.current = request;\n if (!previous) {\n setState({ open: true, options });\n return;\n }\n // One question at a time: the earlier one counts as cancelled. The dialog closes and\n // opens again, so focus starts over and still returns to the opener in the end.\n previous.resolve(false);\n queued.current = request;\n setState((s) => ({ ...s, open: false }));\n }),\n [],\n );\n\n // Every commit, not on `open` alone: two calls in one batch never commit an open dialog.\n useIsomorphicLayoutEffect(() => {\n const next = queued.current;\n if (state.open || !next) return;\n queued.current = null;\n setState({ open: true, options: next.options });\n });\n\n useEffect(\n () => () => {\n pending.current?.resolve(false);\n pending.current = null;\n queued.current = null;\n },\n [],\n );\n\n const { title, message, confirmLabel, cancelLabel, tone, details } = state.options;\n const dialog = (\n <GlassConfirm\n open={state.open}\n onConfirm={() => answer(true)}\n onCancel={() => answer(false)}\n title={title}\n message={message}\n confirmLabel={confirmLabel}\n cancelLabel={cancelLabel}\n tone={tone}\n >\n {details}\n </GlassConfirm>\n );\n return { confirm, dialog };\n}\n","/**\n * Opens a <dialog> as a modal. Feature-checked: older engines and jsdom lack showModal, so\n * there it only gets the `open` attribute (no top layer, no inert page).\n */\nexport function openDialog(dialog: HTMLDialogElement): void {\n if (typeof dialog.showModal === 'function') dialog.showModal();\n else dialog.setAttribute('open', '');\n}\n\n/** Closes a <dialog> opened with `openDialog`, with the same feature check. */\nexport function closeDialog(dialog: HTMLDialogElement): void {\n if (typeof dialog.close === 'function') dialog.close();\n else dialog.removeAttribute('open');\n}\n\n/** Whether the browser can open this dialog as a real modal (top layer, Esc, inert page). */\nexport const canShowModal = (dialog: HTMLDialogElement) => typeof dialog.showModal === 'function';\n","import type { ReactNode } from 'react';\n\n/** Whether React renders anything for `node`: not null, undefined, a boolean or ''. */\nexport const renders = (node: ReactNode): boolean =>\n node !== null && node !== undefined && typeof node !== 'boolean' && node !== '';\n","import {\n forwardRef,\n useId,\n type AriaAttributes,\n type ComponentPropsWithoutRef,\n type ReactNode,\n} from 'react';\nimport { cx } from './cx';\nimport { renders } from './node';\n\nexport interface GlassFieldProps {\n /** Names the control (a <label for>). Shown above it unless `hideLabel`. */\n label: ReactNode;\n /** Help under the control, read with it (aria-describedby). */\n hint?: ReactNode;\n /** What is wrong. Marks the control invalid and is read with it (aria-describedby). */\n error?: ReactNode;\n /** Hide the label visually; screen readers still read it. */\n hideLabel?: boolean;\n /** On the wrapper. */\n className?: string;\n /** On the control. */\n inputClassName?: string;\n}\n\nexport interface GlassInputProps\n extends GlassFieldProps, Omit<ComponentPropsWithoutRef<'input'>, 'className'> {}\n\nexport interface GlassTextareaProps\n extends GlassFieldProps, Omit<ComponentPropsWithoutRef<'textarea'>, 'className'> {}\n\nexport interface GlassSelectProps\n extends GlassFieldProps, Omit<ComponentPropsWithoutRef<'select'>, 'className'> {}\n\ninterface FieldIds {\n /** The caller's `id`, else a generated one. */\n id?: string;\n hint: ReactNode;\n error: ReactNode;\n /** The caller's own `aria-describedby`, kept in front of the hint and error. */\n describedBy?: string;\n /** The caller's own `aria-invalid`, used while there is no error. */\n invalid?: AriaAttributes['aria-invalid'];\n}\n\n/** The ids that tie the label, hint and error to the control, and the control's ARIA. */\nfunction useField({ id, hint, error, describedBy, invalid }: FieldIds) {\n const generated = useId();\n const controlId = id || generated;\n const hintId = renders(hint) ? `${controlId}-hint` : undefined;\n const errorId = renders(error) ? `${controlId}-error` : undefined;\n return {\n controlId,\n hintId,\n errorId,\n control: {\n id: controlId,\n 'aria-describedby': [describedBy, hintId, errorId].filter(Boolean).join(' ') || undefined,\n // Only once there is an error (WCAG 3.3.1, ARIA21): an untouched field is not invalid.\n 'aria-invalid': errorId ? true : invalid,\n },\n };\n}\n\ninterface FieldShellProps extends Omit<GlassFieldProps, 'inputClassName'> {\n field: ReturnType<typeof useField>;\n required?: boolean;\n children: ReactNode;\n}\n\n/** Wrapper, label, then the control, the hint and the error. */\nfunction FieldShell({\n field,\n label,\n hint,\n error,\n hideLabel,\n required,\n className,\n children,\n}: FieldShellProps) {\n return (\n <div className={cx('glass-field', className)}>\n <label\n htmlFor={field.controlId}\n className={cx('glass-field-label', hideLabel && 'glass-field-label-hidden')}\n >\n {label}\n {/* Decoration only: the control's `required` is what assistive tech reads. */}\n {required && (\n <span className=\"glass-field-required\" aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n {children}\n {field.hintId && (\n <div id={field.hintId} className=\"glass-field-hint\">\n {hint}\n </div>\n )}\n {field.errorId && (\n <div id={field.errorId} className=\"glass-field-error\">\n {error}\n </div>\n )}\n </div>\n );\n}\n\n/** A labelled text input with an optional hint and error. Takes every <input> prop. */\nexport const GlassInput = forwardRef<HTMLInputElement, GlassInputProps>(function GlassInput(\n {\n label,\n hint,\n error,\n hideLabel,\n className,\n inputClassName,\n id,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n ...rest\n },\n ref,\n) {\n const field = useField({ id, hint, error, describedBy, invalid });\n return (\n <FieldShell\n field={field}\n label={label}\n hint={hint}\n error={error}\n hideLabel={hideLabel}\n required={rest.required}\n className={className}\n >\n <input ref={ref} {...rest} {...field.control} className={cx('glass-input', inputClassName)} />\n </FieldShell>\n );\n});\n\n/** A labelled <textarea> with an optional hint and error. Takes every <textarea> prop. */\nexport const GlassTextarea = forwardRef<HTMLTextAreaElement, GlassTextareaProps>(\n function GlassTextarea(\n {\n label,\n hint,\n error,\n hideLabel,\n className,\n inputClassName,\n id,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n ...rest\n },\n ref,\n ) {\n const field = useField({ id, hint, error, describedBy, invalid });\n return (\n <FieldShell\n field={field}\n label={label}\n hint={hint}\n error={error}\n hideLabel={hideLabel}\n required={rest.required}\n className={className}\n >\n <textarea\n ref={ref}\n {...rest}\n {...field.control}\n className={cx('glass-input', inputClassName)}\n />\n </FieldShell>\n );\n },\n);\n\n/**\n * A labelled <select> with an optional hint and error. Takes every <select> prop. A\n * drop-down gets a chevron (`glass-select`); a list box (`multiple`, `size` > 1) shows none.\n */\nexport const GlassSelect = forwardRef<HTMLSelectElement, GlassSelectProps>(function GlassSelect(\n {\n label,\n hint,\n error,\n hideLabel,\n className,\n inputClassName,\n id,\n 'aria-describedby': describedBy,\n 'aria-invalid': invalid,\n ...rest\n },\n ref,\n) {\n const field = useField({ id, hint, error, describedBy, invalid });\n const listBox = rest.multiple || (rest.size ?? 1) > 1;\n const select = (\n <select ref={ref} {...rest} {...field.control} className={cx('glass-input', inputClassName)} />\n );\n return (\n <FieldShell\n field={field}\n label={label}\n hint={hint}\n error={error}\n hideLabel={hideLabel}\n required={rest.required}\n className={className}\n >\n {listBox ? select : <div className=\"glass-select\">{select}</div>}\n </FieldShell>\n );\n});\n","import { useEffect } from 'react';\n\n/**\n * True when the browser renders SVG filters inside `backdrop-filter`\n * (currently Chromium only). Safari and Firefox accept the syntax but either\n * ignore it or drop the whole backdrop, so we gate on the engine instead.\n */\nexport function supportsBackdropRefraction(): boolean {\n if (typeof navigator === 'undefined' || typeof CSS === 'undefined') return false;\n const uaData = (navigator as Navigator & { userAgentData?: { brands?: { brand: string }[] } })\n .userAgentData;\n const isChromium = !!uaData?.brands?.some((b) => b.brand === 'Chromium');\n return isChromium && CSS.supports('backdrop-filter', 'url(#lg-refract)');\n}\n\n/**\n * Mount once near the app root. Provides the `#lg-refract` displacement filter\n * used by `.glass-refract` and flags support on <html data-lg-refract>.\n */\nexport function GlassFilter() {\n useEffect(() => {\n if (!supportsBackdropRefraction()) return;\n const root = document.documentElement;\n root.setAttribute('data-lg-refract', '');\n return () => {\n root.removeAttribute('data-lg-refract');\n };\n }, []);\n\n return (\n <svg\n aria-hidden=\"true\"\n focusable=\"false\"\n width=\"0\"\n height=\"0\"\n style={{ position: 'absolute', width: 0, height: 0, overflow: 'hidden' }}\n >\n <filter\n id=\"lg-refract\"\n x=\"0\"\n y=\"0\"\n width=\"100%\"\n height=\"100%\"\n colorInterpolationFilters=\"sRGB\"\n >\n <feTurbulence\n type=\"fractalNoise\"\n baseFrequency=\"0.008 0.012\"\n numOctaves=\"2\"\n seed=\"7\"\n result=\"noise\"\n />\n <feGaussianBlur in=\"noise\" stdDeviation=\"2\" result=\"softNoise\" />\n <feDisplacementMap\n in=\"SourceGraphic\"\n in2=\"softNoise\"\n scale=\"18\"\n xChannelSelector=\"R\"\n yChannelSelector=\"G\"\n />\n </filter>\n </svg>\n );\n}\n","import {\n useEffect,\n useId,\n useRef,\n type MouseEvent as ReactMouseEvent,\n type ReactNode,\n} from 'react';\nimport { CloseIcon } from './CloseIcon';\nimport { cx } from './cx';\nimport { closeDialog, openDialog } from './dialog';\nimport { useSwipeToClose } from './swipe';\n\nexport interface GlassSheetProps {\n open: boolean;\n /** Called when the person closes it: the close button, a swipe down, Esc or a tap outside. */\n onClose: () => void;\n /** Names the dialog (aria-labelledby). */\n title: ReactNode;\n /** Small line above the title, e.g. \"About event\". */\n eyebrow?: ReactNode;\n /** Accessible name of the close button. Translate it. */\n closeLabel?: string;\n /** Pull down to close in the phone (bottom sheet) layout. Default true. */\n swipeToClose?: boolean;\n /** Content pinned under the scrolling body, e.g. actions. */\n footer?: ReactNode;\n children?: ReactNode;\n className?: string;\n bodyClassName?: string;\n}\n\n/** Light dismiss is native where `closedby` is supported; elsewhere it is done below. */\nconst needsLightDismissFallback = () =>\n typeof HTMLDialogElement !== 'undefined' && !('closedBy' in HTMLDialogElement.prototype);\n\nconst isOutside = (e: ReactMouseEvent<HTMLDialogElement>) => {\n const r = e.currentTarget.getBoundingClientRect();\n return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;\n};\n\n/**\n * A modal sheet on a native <dialog>: the browser makes the page inert, keeps focus inside,\n * closes on Esc and returns focus to the opener. Centred from 640px up; on phones a bottom\n * sheet with a grabber that can be pulled down to close. On phones the ✕ is hidden, like a\n * native sheet: a tap outside is the single-tap alternative to the swipe (WCAG 2.5.1 and\n * 2.5.7), and the button stays for screen readers and keyboards.\n *\n * Opening focuses the dialog itself rather than the close button, so screen readers start\n * at the title and no focus ring flashes on the ✕ for touch users.\n */\nexport function GlassSheet({\n open,\n onClose,\n title,\n eyebrow,\n closeLabel = 'Close',\n swipeToClose = true,\n footer,\n children,\n className,\n bodyClassName,\n}: GlassSheetProps) {\n const dialogRef = useRef<HTMLDialogElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n const titleId = useId();\n const pressedOutside = useRef(false);\n\n useEffect(() => {\n const dialog = dialogRef.current;\n if (!dialog || open === dialog.hasAttribute('open')) return;\n if (open) {\n openDialog(dialog);\n dialog.focus({ preventScroll: true });\n if (bodyRef.current) bodyRef.current.scrollTop = 0;\n } else {\n closeDialog(dialog);\n }\n }, [open]);\n\n useSwipeToClose(dialogRef, { enabled: open && swipeToClose, scrollRef: bodyRef, onClose });\n\n return (\n <dialog\n ref={dialogRef}\n // Not yet in React's types; React passes it through as an attribute.\n {...{ closedby: 'any' }}\n tabIndex={-1}\n aria-labelledby={titleId}\n // Esc or light dismiss closed it; when `open` is already false the page closed it.\n onClose={() => {\n if (open) onClose();\n }}\n // Without `closedby`: close only when both the press and the release are outside the\n // box, so a text selection dragged onto the backdrop does not dismiss.\n onPointerDown={(e) => {\n pressedOutside.current = needsLightDismissFallback() && isOutside(e);\n }}\n onPointerUp={(e) => {\n if (pressedOutside.current && isOutside(e)) onClose();\n pressedOutside.current = false;\n }}\n className={cx('glass-dialog', className)}\n >\n {swipeToClose && <div className=\"glass-dialog-grabber\" aria-hidden=\"true\" />}\n <header className=\"glass-dialog-header\">\n <div className=\"glass-dialog-heading\">\n {eyebrow && <p className=\"glass-dialog-eyebrow\">{eyebrow}</p>}\n <h2 id={titleId} className=\"glass-dialog-title\">\n {title}\n </h2>\n </div>\n <button\n type=\"button\"\n onClick={onClose}\n aria-label={closeLabel}\n className=\"glass-dialog-close\"\n >\n <CloseIcon />\n </button>\n </header>\n <div ref={bodyRef} className={cx('glass-dialog-body', bodyClassName)}>\n {children}\n </div>\n {footer && <div className=\"glass-dialog-footer\">{footer}</div>}\n </dialog>\n );\n}\n","/** The ✕ glyph of close and dismiss buttons. Decorative: the button carries the name. */\nexport function CloseIcon() {\n return (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" aria-hidden=\"true\">\n <path\n d=\"M6 18 18 6M6 6l12 12\"\n stroke=\"currentColor\"\n strokeWidth=\"1.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n );\n}\n","import { useEffect, useRef, type RefObject } from 'react';\n\n/** Movement (px) before a press counts as a drag, so taps and small jitters stay taps. */\nexport const DRAG_SLOP_PX = 8;\n/** Pull further than this share of the sheet's height and it closes on release. */\nexport const CLOSE_DISTANCE_RATIO = 0.25;\n/** Or flick downward at least this fast (px per ms), however short the pull. */\nexport const CLOSE_VELOCITY = 0.5;\n/** A flick only counts once the sheet has moved this far, so a twitch doesn't close it. */\nexport const MIN_FLICK_PX = 24;\n/** How long the sheet takes to slide away or settle back (ms). */\nexport const SETTLE_MS = 220;\n/**\n * How long after release the owner is asked to close (ms): the slide-away plus a margin, so\n * the transition has really finished. Closing a dialog while its transform is still moving\n * is one more thing iOS Safari may get wrong.\n */\nexport const SLIDE_AWAY_MS = SETTLE_MS + 60;\n/**\n * After `onClose`, how long the sheet waits off-screen for its owner to close it (ms). If it\n * is still open by then (the owner kept it, e.g. to ask \"discard changes?\"), it comes back.\n */\nexport const REOPEN_AFTER_MS = 250;\n\nconst SETTLE_EASE = 'cubic-bezier(0.22, 1, 0.36, 1)';\n\nexport interface ReleaseState {\n /** How far the sheet is pulled down (px). */\n offset: number;\n /** The sheet's height (px). */\n height: number;\n /** Downward speed at release (px per ms; negative means moving up). */\n velocity: number;\n}\n\n/** Whether a released drag should close the sheet or let it settle back. */\nexport function shouldClose({ offset, height, velocity }: ReleaseState): boolean {\n if (offset <= 0) return false;\n if (height > 0 && offset >= height * CLOSE_DISTANCE_RATIO) return true;\n return velocity >= CLOSE_VELOCITY && offset >= MIN_FLICK_PX;\n}\n\n/** Controls a press should leave alone: a drag starting on one would steal its tap. */\nconst INTERACTIVE =\n 'button, a[href], input, select, textarea, label, summary, [contenteditable=\"\"], [contenteditable=\"true\"], [role=\"button\"], [role=\"slider\"], [data-glass-no-drag]';\n\n/** Computed `overflow-y` values a person can scroll (`overlay` is a legacy alias of `auto`). */\nconst SCROLLING_OVERFLOW = new Set(['auto', 'scroll', 'overlay']);\n\n/**\n * Whether a person can scroll `el` vertically: it has more content than fits and its\n * `overflow-y` lets them. `hidden` does not count: only a script can scroll that.\n */\nconst scrollsVertically = (el: Element) =>\n el.scrollHeight > el.clientHeight && SCROLLING_OVERFLOW.has(getComputedStyle(el).overflowY);\n\n/** Whether a pan in any of `scrollers` has something to scroll, rather than chaining on. */\nconst anyCanScroll = (scrollers: readonly Element[]) =>\n scrollers.some((el) => el.scrollHeight > el.clientHeight);\n\n/** Counts the hook runs per sheet, so a late tidy-up never touches a sheet that is in use again. */\nconst runs = new WeakMap<HTMLElement, number>();\n\nconst prefersReducedMotion = () =>\n typeof window !== 'undefined' &&\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n\nexport interface SwipeToCloseOptions {\n /** Turn the gesture on or off (e.g. only while open, only in the bottom-sheet layout). */\n enabled: boolean;\n /**\n * Optional. The scrolling areas under the finger are found by themselves: every element\n * from the press up to the sheet (itself included) with `overflow-y` auto, scroll or\n * overlay and more content than fits. A press inside one drags only while all of them are\n * scrolled to the top. Pass a scroller here only when that test misses it, e.g. one with\n * `overflow-y: hidden` that a script scrolls; it then counts whenever it holds the press.\n */\n scrollRef?: RefObject<HTMLElement | null>;\n /**\n * Called once the sheet has slid away. The sheet stays off-screen until `enabled` turns\n * false; if that has not happened `REOPEN_AFTER_MS` later, it slides back.\n *\n * From release until the sheet is closed and tidied up (or comes back) it carries\n * `data-closing`. Style the backdrop with it, so the dim is gone before the close.\n */\n onClose: () => void;\n /** Media query for when the gesture applies. Default: the phone bottom-sheet layout. */\n media?: string;\n}\n\ninterface Drag {\n pointerId: number | 'touch';\n startX: number;\n startY: number;\n lastY: number;\n lastT: number;\n velocity: number;\n /** Null until the press has moved past the slop and we know whether it is our drag. */\n active: boolean | null;\n /** The scrollers under the press (see `scrollersUnder`), all at the top when it began. */\n scrollers: Element[];\n}\n\n/**\n * Pull-down-to-close for a sheet. Touch uses touch events, because a pointer-events drag\n * over scrollable content is cancelled by the browser as soon as it starts to pan; with\n * a non-passive touchmove we can stop that pan. Mouse and pen use pointer events. The sheet\n * follows the finger via an inline transform and either slides away (then `onClose`) or\n * settles back.\n *\n * The scrolling areas need no wiring: at each press the hook walks from the element under\n * the finger up to the sheet and takes every element a person can scroll vertically. If any\n * of them is scrolled down, the gesture is theirs (a pull down scrolls back up) and no drag\n * starts. A sideways scroller does not block a drag (only vertical scrolling counts), and a\n * sideways move lets go of one. Outside every vertical scroller the page is held (below),\n * which stops a sideways scroller there too: mark it `data-glass-no-drag`.\n *\n * iOS Safari decides at the first touchmove of a gesture whether the page pans, and later\n * moves can no longer stop it. So wherever nothing in the sheet would scroll for that touch\n * (outside every scroller, such as the header, grabber and backdrop; a downward pull at the\n * top of a scroller; a scroller with nothing to scroll), touchmoves are cancelled from the\n * first one; taps still click.\n *\n * After a slide-away the inline transform is kept until the effect is torn down (the owner\n * closed the sheet and `enabled` turned false). Clearing it earlier would show the sheet at\n * rest for a frame before the close is committed.\n *\n * From release until the sheet is closed and tidied up, or comes back, the sheet has the\n * attribute `data-closing`. Fade the backdrop out with it (`[data-closing]::backdrop`): iOS\n * Safari can leave a dialog's backdrop painted after it closes, so it must be clear by then.\n */\nexport function useSwipeToClose(\n sheetRef: RefObject<HTMLElement | null>,\n { enabled, scrollRef, onClose, media = '(max-width: 639.98px)' }: SwipeToCloseOptions,\n): void {\n const onCloseRef = useRef(onClose);\n onCloseRef.current = onClose;\n\n useEffect(() => {\n const sheet = sheetRef.current;\n if (!enabled || !sheet) return;\n\n let drag: Drag | null = null;\n // Cancel every touchmove until this touch ends: nothing under it scrolls, so a pan would\n // move the page behind the dialog. Cleared on touchstart, touchend and touchcancel.\n let holdPage = false;\n let suppressClick = false;\n // False once the effect is torn down, so nothing is scheduled on a sheet we let go of.\n let alive = true;\n // True from release until the owner closes the sheet or it comes back.\n let closing = false;\n // The release phases (slide away, wait for the owner, settle back) run one after\n // another, so a single timer handle covers them.\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const clearTimer = () => {\n clearTimeout(timer);\n timer = undefined;\n };\n\n const applies = () =>\n typeof window.matchMedia !== 'function' || window.matchMedia(media).matches;\n\n const resetStyles = () => {\n sheet.style.transform = '';\n sheet.style.transition = '';\n sheet.removeAttribute('data-dragging');\n sheet.removeAttribute('data-closing');\n };\n\n // Start clean: an earlier run may have left its inline styles (see the cleanup).\n runs.set(sheet, (runs.get(sheet) ?? 0) + 1);\n resetStyles();\n sheet.style.animation = '';\n\n /** Animate back to rest, then drop the inline styles. */\n const settleBack = () => {\n // Now, not once it has settled: the backdrop fades back in while the sheet slides up.\n sheet.removeAttribute('data-closing');\n sheet.style.transition = `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;\n sheet.style.transform = '';\n // A timer, not transitionend: that event never fires if nothing moved or the tab hid.\n timer = setTimeout(resetStyles, SETTLE_MS);\n };\n\n /**\n * Ask the owner to close, leaving the sheet where it is. The effect cleanup clears the\n * styles once the sheet really closes; if it is still open after REOPEN_AFTER_MS,\n * `comeBack` runs.\n */\n const requestClose = (comeBack: () => void) => {\n try {\n onCloseRef.current();\n } finally {\n // The owner may have closed the sheet synchronously, tearing this effect down.\n if (alive) {\n timer = setTimeout(() => {\n closing = false;\n comeBack();\n }, REOPEN_AFTER_MS);\n }\n }\n };\n\n /**\n * The scrollers under a press: every element from `target` up to the sheet (itself\n * included) that a person can scroll vertically, plus `scrollRef` when it holds `target`.\n * Once per press, a handful of elements: read on the spot, nothing cached or observed.\n */\n const scrollersUnder = (target: Element): Element[] => {\n const found: Element[] = [];\n for (let el: Element | null = target; el; el = el.parentElement) {\n if (scrollsVertically(el)) found.push(el);\n if (el === sheet) break;\n }\n const given = scrollRef?.current;\n if (given?.contains(target) && !found.includes(given)) found.push(given);\n return found;\n };\n\n const begin = (id: Drag['pointerId'], x: number, y: number, target: EventTarget | null) => {\n // While closing, the sheet is sliding away or waiting for its owner: leave it be.\n if (drag || closing || !applies()) return;\n const el = target instanceof Element ? target : null;\n if (!el || !sheet.contains(el) || el.closest(INTERACTIVE)) return;\n const scrollers = scrollersUnder(el);\n // A scroller under the finger is scrolled down: the gesture scrolls it, not the sheet.\n if (scrollers.some((s) => s.scrollTop > 0)) return;\n // Text selected inside a scroller: the press is probably adjusting it.\n if (scrollers.length > 0 && window.getSelection()?.isCollapsed === false) return;\n clearTimer();\n drag = {\n pointerId: id,\n startX: x,\n startY: y,\n lastY: y,\n lastT: performance.now(),\n velocity: 0,\n active: null,\n scrollers,\n };\n };\n\n /** Returns true while the move belongs to the drag (so the caller can stop scrolling). */\n const move = (x: number, y: number): boolean => {\n if (!drag) return false;\n const dy = y - drag.startY;\n const dx = x - drag.startX;\n if (drag.active === null) {\n if (Math.abs(dy) < DRAG_SLOP_PX && Math.abs(dx) < DRAG_SLOP_PX) return false;\n // Upward or sideways: a scroll or a swipe for something else. Let it go.\n if (dy <= 0 || Math.abs(dx) > Math.abs(dy)) {\n drag = null;\n return false;\n }\n drag.active = true;\n sheet.setAttribute('data-dragging', '');\n sheet.style.transition = 'none';\n // Off until the sheet closes (see cleanup). An open animation with a fill mode would\n // override the inline transform, and switching it off only for the drag would replay\n // it on release.\n sheet.style.animation = 'none';\n }\n const now = performance.now();\n const dt = now - drag.lastT;\n if (dt > 0) drag.velocity = (y - drag.lastY) / dt;\n drag.lastY = y;\n drag.lastT = now;\n sheet.style.transform = `translate3d(0, ${Math.max(0, dy - DRAG_SLOP_PX)}px, 0)`;\n return true;\n };\n\n const end = () => {\n if (!drag) return;\n const wasActive = drag.active === true;\n const wasTouch = drag.pointerId === 'touch';\n const offset = Math.max(0, drag.lastY - drag.startY - DRAG_SLOP_PX);\n // A long pause before letting go means the flick is over.\n const velocity = performance.now() - drag.lastT > 100 ? 0 : drag.velocity;\n drag = null;\n if (!wasActive) return;\n // Only a mouse or pen drag ends in a click to swallow. A touch drag does not, and the\n // flag would then eat the next real activation (e.g. from a screen reader).\n suppressClick = !wasTouch;\n sheet.removeAttribute('data-dragging');\n\n const close = shouldClose({ offset, height: sheet.getBoundingClientRect().height, velocity });\n const reduceMotion = prefersReducedMotion();\n if (!close) {\n if (reduceMotion) resetStyles();\n else settleBack();\n return;\n }\n closing = true;\n // The backdrop fades out from now, so nothing dark is left to repaint at the close.\n sheet.setAttribute('data-closing', '');\n // Reduced motion: no slide, the sheet goes at once. The close still waits, so it never\n // lands in the frame the backdrop changes.\n sheet.style.transition = reduceMotion ? 'none' : `transform ${SETTLE_MS}ms ${SETTLE_EASE}`;\n sheet.style.transform = 'translate3d(0, 100%, 0)';\n // A timer, not transitionend: that event never fires if nothing moved or the tab hid.\n const comeBack = reduceMotion ? resetStyles : settleBack;\n timer = setTimeout(() => requestClose(comeBack), SLIDE_AWAY_MS);\n };\n\n const cancel = () => {\n const wasActive = drag?.active === true;\n drag = null;\n if (wasActive) resetStyles();\n };\n\n // Touch\n const onTouchStart = (e: TouchEvent) => {\n holdPage = false;\n const t = e.touches[0];\n if (e.touches.length !== 1 || !t) return cancel();\n begin('touch', t.clientX, t.clientY, e.target);\n // Outside every scroller (header, grabber, footer, the backdrop) nothing scrolls\n // natively; nor in scrollers whose content fits. Hold from the start: the first move\n // decides.\n holdPage = drag?.pointerId === 'touch' && !anyCanScroll(drag.scrollers);\n };\n const onTouchMove = (e: TouchEvent) => {\n const t = e.touches[0];\n let stopPan = holdPage;\n if (t && drag?.pointerId === 'touch') {\n const { startY, scrollers } = drag;\n const pulledDown = t.clientY > startY;\n if (move(t.clientX, t.clientY)) {\n stopPan = true; // our drag\n } else if (drag) {\n // Within the slop. At the top of a scroller a pull down has nothing to scroll.\n stopPan ||= pulledDown;\n } else if (!anyCanScroll(scrollers)) {\n // Dropped as not ours, and nothing under it can scroll: keep the page still.\n holdPage = true;\n stopPan = true;\n }\n }\n if (stopPan && e.cancelable) e.preventDefault();\n };\n const onTouchEnd = () => {\n holdPage = false;\n if (drag?.pointerId === 'touch') end();\n };\n const onTouchCancel = () => {\n holdPage = false;\n cancel();\n };\n\n // Mouse and pen (touch is handled above)\n const onPointerDown = (e: PointerEvent) => {\n if (e.pointerType === 'touch' || e.button !== 0) return;\n begin(e.pointerId, e.clientX, e.clientY, e.target);\n };\n const onPointerMove = (e: PointerEvent) => {\n if (drag?.pointerId !== e.pointerId) return;\n if (move(e.clientX, e.clientY)) e.preventDefault();\n };\n const onPointerUp = (e: PointerEvent) => {\n if (drag?.pointerId === e.pointerId) end();\n };\n const onPointerCancel = (e: PointerEvent) => {\n if (drag?.pointerId === e.pointerId) cancel();\n };\n\n // A mouse drag ends with a click on whatever is under it; that click must not count.\n const onClickCapture = (e: MouseEvent) => {\n if (!suppressClick) return;\n suppressClick = false;\n e.preventDefault();\n e.stopPropagation();\n };\n const clearSuppress = () => {\n suppressClick = false;\n };\n\n sheet.addEventListener('touchstart', onTouchStart, { passive: true });\n sheet.addEventListener('touchmove', onTouchMove, { passive: false });\n sheet.addEventListener('touchend', onTouchEnd);\n sheet.addEventListener('touchcancel', onTouchCancel);\n sheet.addEventListener('pointerdown', onPointerDown);\n sheet.addEventListener('click', onClickCapture, true);\n window.addEventListener('pointermove', onPointerMove);\n window.addEventListener('pointerup', onPointerUp);\n window.addEventListener('pointercancel', onPointerCancel);\n window.addEventListener('pointerdown', clearSuppress, true);\n\n return () => {\n alive = false;\n clearTimer();\n // Never change the sheet in the frame it closes: moving it or restarting its open\n // animation together with dialog.close() is the suspected cause of the backdrop staying\n // painted on iOS Safari. Tidy up a moment later (styles and `data-closing`), unless the\n // sheet is in use again.\n const mine = runs.get(sheet);\n setTimeout(() => {\n if (runs.get(sheet) !== mine) return;\n resetStyles();\n sheet.style.animation = '';\n }, SLIDE_AWAY_MS);\n sheet.removeEventListener('touchstart', onTouchStart);\n sheet.removeEventListener('touchmove', onTouchMove);\n sheet.removeEventListener('touchend', onTouchEnd);\n sheet.removeEventListener('touchcancel', onTouchCancel);\n sheet.removeEventListener('pointerdown', onPointerDown);\n sheet.removeEventListener('click', onClickCapture, true);\n window.removeEventListener('pointermove', onPointerMove);\n window.removeEventListener('pointerup', onPointerUp);\n window.removeEventListener('pointercancel', onPointerCancel);\n window.removeEventListener('pointerdown', clearSuppress, true);\n };\n }, [enabled, media, scrollRef, sheetRef]);\n}\n","import {\n createContext,\n useContext,\n useId,\n useMemo,\n type KeyboardEvent,\n type ReactNode,\n} from 'react';\nimport { cx } from './cx';\n\nexport type GlassTabsOrientation = 'horizontal' | 'vertical';\n\nexport interface GlassTabsProps {\n /** The selected tab's `value`. */\n value: string;\n onChange: (value: string) => void;\n /** Names the tab list (aria-label). Translate it. */\n label: string;\n /** Default `horizontal`: Left and Right move between tabs. `vertical`: Up and Down. */\n orientation?: GlassTabsOrientation;\n children?: ReactNode;\n}\n\nexport interface GlassTabListProps {\n children?: ReactNode;\n className?: string;\n}\n\nexport interface GlassTabProps {\n /** Matches the `value` of its <GlassTabPanel>. */\n value: string;\n disabled?: boolean;\n children?: ReactNode;\n className?: string;\n}\n\nexport interface GlassTabPanelProps {\n /** Matches the `value` of its <GlassTab>. */\n value: string;\n children?: ReactNode;\n className?: string;\n}\n\ninterface TabsContextValue {\n value: string;\n onChange: (value: string) => void;\n label: string;\n orientation: GlassTabsOrientation;\n idPrefix: string;\n}\n\nconst TabsContext = createContext<TabsContextValue | null>(null);\n\nfunction useTabs(component: string): TabsContextValue {\n const tabs = useContext(TabsContext);\n if (!tabs) throw new Error(`<${component}> must be inside <GlassTabs>.`);\n return tabs;\n}\n\n/**\n * Makes a value safe inside an id: an id (and so `aria-controls`) cannot hold whitespace.\n * Whitespace and `%` become `%` plus four hex digits, so two values never share an id.\n */\nconst idPart = (value: string) =>\n value.replace(/[\\s%]/g, (c) => `%${c.charCodeAt(0).toString(16).padStart(4, '0')}`);\n\nconst tabId = (prefix: string, value: string) => `${prefix}-tab-${idPart(value)}`;\nconst panelId = (prefix: string, value: string) => `${prefix}-panel-${idPart(value)}`;\n\n/** Each tab's value, so the keyboard handler can select the tab it moves to. */\nconst tabValues = new WeakMap<Element, string>();\n\n/** Where a key moves focus, as an index into the enabled tabs; undefined when it does not. */\nfunction moveTo(\n key: string,\n from: number,\n count: number,\n vertical: boolean,\n rtl: () => boolean,\n): number | undefined {\n switch (key) {\n case 'Home':\n return 0;\n case 'End':\n return count - 1;\n case 'ArrowDown':\n return vertical ? (from + 1) % count : undefined;\n case 'ArrowUp':\n return vertical ? (from - 1 + count) % count : undefined;\n case 'ArrowRight':\n case 'ArrowLeft': {\n if (vertical) return undefined;\n // In a right-to-left layout the next tab is on the left.\n const forward = (key === 'ArrowRight') !== rtl();\n return (from + (forward ? 1 : -1) + count) % count;\n }\n default:\n return undefined;\n }\n}\n\n/**\n * Tabs (APG tabs pattern, automatic activation): the arrow keys move focus along the tabs\n * and select the tab they land on, wrapping at the ends and skipping disabled tabs. Home and\n * End go to the first and last. Only the selected tab is in the Tab order.\n *\n * Holds the state for <GlassTabList>, <GlassTab> and <GlassTabPanel>, and renders only its\n * children, so the layout around them is yours.\n */\nexport function GlassTabs({\n value,\n onChange,\n label,\n orientation = 'horizontal',\n children,\n}: GlassTabsProps) {\n const idPrefix = useId();\n const context = useMemo(\n () => ({ value, onChange, label, orientation, idPrefix }),\n [value, onChange, label, orientation, idPrefix],\n );\n return <TabsContext.Provider value={context}>{children}</TabsContext.Provider>;\n}\n\n/**\n * The row (or column) of tabs: a glass track that scrolls sideways when the tabs do not fit.\n * Marked `data-glass-no-drag`, so in a sheet a sideways swipe along it never pulls the sheet.\n */\nexport function GlassTabList({ children, className }: GlassTabListProps) {\n const { value, onChange, label, orientation } = useTabs('GlassTabList');\n const vertical = orientation === 'vertical';\n\n const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {\n if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey) return;\n const list = e.currentTarget;\n const tabs = Array.from(list.querySelectorAll<HTMLButtonElement>('[role=\"tab\"]')).filter(\n (tab) => !tab.disabled && tab.closest('[role=\"tablist\"]') === list,\n );\n const from = tabs.findIndex((tab) => tab.contains(e.target as Node));\n if (from === -1) return;\n const rtl = () => getComputedStyle(list).direction === 'rtl';\n const to = moveTo(e.key, from, tabs.length, vertical, rtl);\n const tab = to === undefined ? undefined : tabs[to];\n if (!tab) return;\n e.preventDefault();\n tab.focus();\n const next = tabValues.get(tab);\n if (next !== undefined && next !== value) onChange(next);\n };\n\n return (\n <div\n role=\"tablist\"\n aria-label={label}\n aria-orientation={vertical ? 'vertical' : undefined}\n data-glass-no-drag=\"\"\n onKeyDown={onKeyDown}\n className={cx('glass-tabs', className)}\n >\n {children}\n </div>\n );\n}\n\n/** One tab. Selected when its `value` is the value of <GlassTabs>. */\nexport function GlassTab({ value, disabled, children, className }: GlassTabProps) {\n const tabs = useTabs('GlassTab');\n const selected = tabs.value === value;\n return (\n <button\n ref={(el) => {\n if (el) tabValues.set(el, value);\n }}\n type=\"button\"\n role=\"tab\"\n id={tabId(tabs.idPrefix, value)}\n aria-selected={selected}\n aria-controls={panelId(tabs.idPrefix, value)}\n tabIndex={selected ? 0 : -1}\n disabled={disabled}\n onClick={() => {\n if (!selected) tabs.onChange(value);\n }}\n className={cx('glass-tab', className)}\n >\n {children}\n </button>\n );\n}\n\n/**\n * The content of one tab. Hidden (not unmounted) while its tab is not selected, so its state\n * and scroll position survive a switch. Focusable, so keyboard users can reach content that\n * has nothing focusable in it.\n */\nexport function GlassTabPanel({ value, children, className }: GlassTabPanelProps) {\n const tabs = useTabs('GlassTabPanel');\n return (\n <div\n role=\"tabpanel\"\n id={panelId(tabs.idPrefix, value)}\n aria-labelledby={tabId(tabs.idPrefix, value)}\n hidden={tabs.value !== value}\n tabIndex={0}\n className={cx('glass-tab-panel', className)}\n >\n {children}\n </div>\n );\n}\n","import {\n useEffect,\n useRef,\n useState,\n useSyncExternalStore,\n type FocusEvent,\n type ReactNode,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { CloseIcon } from './CloseIcon';\nimport { cx } from './cx';\n\nexport type GlassToastTone = 'neutral' | 'danger';\n\nexport interface GlassToastOptions {\n /** `danger` is announced at once (role=\"alert\") and stays until dismissed. */\n tone?: GlassToastTone;\n /**\n * How long a neutral toast stays (ms). Default 5000. `Infinity` or 0 keeps it until it is\n * dismissed. Ignored for `danger`, which always stays.\n */\n duration?: number;\n}\n\nexport interface GlassToastsProps {\n /** Accessible name of the dismiss button. Translate it. */\n dismissLabel?: string;\n /** Where the stack sits. Default `top`. */\n position?: 'top' | 'bottom';\n className?: string;\n}\n\ninterface ToastRecord {\n id: number;\n message: ReactNode;\n tone: GlassToastTone;\n duration: number;\n}\n\n/** Toasts on screen at once. A fourth pushes one out (see `trim`). */\nconst MAX_TOASTS = 3;\nconst DEFAULT_DURATION_MS = 5000;\n/** setTimeout fires at once for anything longer (it overflows a 32-bit int). */\nconst MAX_TIMEOUT_MS = 2 ** 31 - 1;\n\n// One store per page: `toast()` can be called from anywhere, without a context.\nlet toasts: readonly ToastRecord[] = [];\nlet nextId = 1;\nconst listeners = new Set<() => void>();\nconst NONE: readonly ToastRecord[] = [];\n\nconst emit = () => {\n for (const listener of listeners) listener();\n};\nconst subscribe = (listener: () => void) => {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n};\nconst getSnapshot = () => toasts;\n// The server never has toasts: they come from what a person does in the browser.\nconst getServerSnapshot = () => NONE;\n\n/**\n * Keeps the stack to MAX_TOASTS. The oldest neutral toast goes first, so news never pushes\n * out an error nobody has dismissed; only when all are errors does the oldest error go.\n */\nfunction trim(list: ToastRecord[]): ToastRecord[] {\n while (list.length > MAX_TOASTS) {\n const neutral = list.findIndex((t) => t.tone !== 'danger');\n list.splice(neutral === -1 ? 0 : neutral, 1);\n }\n return list;\n}\n\n/** Shows a toast in the mounted <GlassToasts />. Returns its id, for `dismissToast(id)`. */\nexport function toast(message: ReactNode, options: GlassToastOptions = {}): number {\n const { tone = 'neutral', duration = DEFAULT_DURATION_MS } = options;\n const id = nextId++;\n toasts = trim([...toasts, { id, message, tone, duration }]);\n emit();\n return id;\n}\n\n/** Removes the toast with this id, or every toast when called without one. */\nexport function dismissToast(id?: number): void {\n const next = id === undefined ? NONE : toasts.filter((t) => t.id !== id);\n if (next.length === toasts.length) return;\n toasts = next;\n emit();\n}\n\n/** Whether a toast leaves by itself. Danger never does: APG, \"avoid alerts that disappear\". */\nconst leavesByItself = ({ tone, duration }: ToastRecord) =>\n tone !== 'danger' && Number.isFinite(duration) && duration > 0;\n\nfunction Toast({ item, dismissLabel }: { item: ToastRecord; dismissLabel: string }) {\n const { id, tone, message } = item;\n const timed = leavesByItself(item);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n // Time left on the clock, so a pause resumes where it stopped rather than starting over.\n const remaining = useRef(item.duration);\n // Paused while read or used (WCAG 2.2.1): the pointer is on it, or focus is inside it.\n const paused = hovered || focused;\n\n useEffect(() => {\n if (!timed || paused) return;\n const started = Date.now();\n const timer = setTimeout(() => dismissToast(id), Math.min(remaining.current, MAX_TIMEOUT_MS));\n return () => {\n clearTimeout(timer);\n remaining.current -= Date.now() - started;\n };\n }, [id, timed, paused]);\n\n const onBlur = (e: FocusEvent<HTMLDivElement>) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setFocused(false);\n };\n\n return (\n <div\n className={cx('glass-toast', tone === 'danger' && 'glass-toast-danger')}\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n onFocus={() => setFocused(true)}\n onBlur={onBlur}\n >\n <div className=\"glass-toast-message\">{message}</div>\n {/* A toast that stays needs a way to go. One that leaves by itself needs none. */}\n {!timed && (\n <button\n type=\"button\"\n className=\"glass-toast-dismiss\"\n aria-label={dismissLabel}\n onClick={() => dismissToast(id)}\n >\n <CloseIcon />\n </button>\n )}\n </div>\n );\n}\n\n/**\n * Where `toast()` shows up. Mount it once, near the root of the app.\n *\n * Two live regions are always in the page, so assistive tech is already listening when a\n * toast arrives: neutral toasts go in `role=\"status\"` (read when the person is idle), danger\n * toasts in `role=\"alert\"` (read at once). `aria-atomic=\"false\"` overrides the roles' default,\n * so a new toast is read on its own rather than with the ones already showing.\n *\n * Toasts never take focus. Neutral ones leave after `duration`, pausing while hovered or\n * focused; danger ones stay until dismissed. Rendered into <body> after mount, so the server\n * render and hydration match.\n */\nexport function GlassToasts({\n dismissLabel = 'Dismiss',\n position = 'top',\n className,\n}: GlassToastsProps) {\n const items = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);\n const [mounted, setMounted] = useState(false);\n useEffect(() => setMounted(true), []);\n if (!mounted) return null;\n\n const renderToast = (item: ToastRecord) => (\n <Toast key={item.id} item={item} dismissLabel={dismissLabel} />\n );\n return createPortal(\n <div className={cx('glass-toasts', position === 'bottom' && 'glass-toasts-bottom', className)}>\n <div role=\"status\" aria-atomic=\"false\" className=\"glass-toasts-region\">\n {items.filter((t) => t.tone !== 'danger').map(renderToast)}\n </div>\n <div role=\"alert\" aria-atomic=\"false\" className=\"glass-toasts-region\">\n {items.filter((t) => t.tone === 'danger').map(renderToast)}\n </div>\n </div>,\n document.body,\n );\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAOK;;;ACPA,SAAS,MAAM,OAAyD;AAC7E,SAAO,MAAM,OAAO,OAAO,EA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AE;AAAA,YAE9B,0BAAAA,KAAC,aAAU;AAAA;AAAA,QACb;AAAA;AAAA;AAAA,EAEJ;AAEJ;AAcO,SAAS,YAAY;AAAA,EAC1B,eAAe;AAAA,EACf,WAAW;AAAA,EACX;AACF,GAAqB;AACnB,QAAM,QAAQ,qBAAqB,WAAW,aAAa,iBAAiB;AAC5E,QAAM,CAAC,SAAS,UAAU,IAAIE,UAAS,KAAK;AAC5C,EAAAE,WAAU,MAAM,WAAW,IAAI,GAAG,CAAC,CAAC;AACpC,MAAI,CAAC,QAAS,QAAO;AAErB,QAAM,cAAc,CAAC,SACnB,gBAAAJ,KAAC,SAAoB,MAAY,gBAArB,KAAK,EAA4C;AAE/D,SAAO;AAAA,IACL,gBAAAC,MAAC,SAAI,WAAW,GAAG,gBAAgB,aAAa,YAAY,uBAAuB,SAAS,GAC1F;AAAA,sBAAAD,KAAC,SAAI,MAAK,UAAS,eAAY,SAAQ,WAAU,uBAC9C,gBAAM,OAAO,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,IAAI,WAAW,GAC3D;AAAA,MACA,gBAAAA,KAAC,SAAI,MAAK,SAAQ,eAAY,SAAQ,WAAU,uBAC7C,gBAAM,OAAO,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,IAAI,WAAW,GAC3D;AAAA,OACF;AAAA,IACA,SAAS;AAAA,EACX;AACF;","names":["forwardRef","jsx","forwardRef","GlassButton","jsx","forwardRef","useId","jsx","jsxs","useId","forwardRef","GlassInput","GlassTextarea","GlassSelect","useEffect","jsx","jsxs","useEffect","useId","useRef","jsx","useEffect","useRef","jsx","jsxs","useRef","useId","useEffect","useId","jsx","useId","tab","useEffect","useRef","useState","jsx","jsxs","useState","useRef","useEffect"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sofyan/glass",
3
- "version": "0.1.6",
3
+ "version": "0.3.0",
4
4
  "description": "Liquid Glass material for the web: CSS (Tailwind v4 friendly) and React components, including a swipe-to-close sheet.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -28,20 +28,14 @@
28
28
  "./glass.css": "./dist/glass.css",
29
29
  "./tailwind.css": "./dist/tailwind.css",
30
30
  "./dark.css": "./dist/dark.css",
31
+ "./glass.unlayered.css": "./dist/glass.unlayered.css",
32
+ "./dark.unlayered.css": "./dist/dark.unlayered.css",
31
33
  "./react": {
32
34
  "types": "./dist/react/index.d.ts",
33
35
  "import": "./dist/react/index.js"
34
36
  },
35
37
  "./package.json": "./package.json"
36
38
  },
37
- "scripts": {
38
- "build": "tsup && node scripts/copy-css.mjs",
39
- "typecheck": "tsc --noEmit",
40
- "test": "vitest run",
41
- "format": "prettier -w .",
42
- "format:check": "prettier -c .",
43
- "prepublishOnly": "pnpm typecheck && pnpm test && pnpm build"
44
- },
45
39
  "peerDependencies": {
46
40
  "react": ">=18",
47
41
  "react-dom": ">=18"
@@ -61,6 +55,7 @@
61
55
  "@types/react": "^19.2.0",
62
56
  "@types/react-dom": "^19.2.0",
63
57
  "jsdom": "^25.0.1",
58
+ "postcss": "^8.5.34",
64
59
  "prettier": "^3.6.0",
65
60
  "react": "^19.2.0",
66
61
  "react-dom": "^19.2.0",
@@ -68,5 +63,11 @@
68
63
  "typescript": "^5.9.3",
69
64
  "vitest": "^4.1.12"
70
65
  },
71
- "packageManager": "pnpm@10.2.0"
72
- }
66
+ "scripts": {
67
+ "build": "tsup && node scripts/build-css.mjs",
68
+ "typecheck": "tsc --noEmit",
69
+ "test": "vitest run",
70
+ "format": "prettier -w .",
71
+ "format:check": "prettier -c ."
72
+ }
73
+ }