@slipstream-ui/core 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +184 -8
- package/dist/index.d.ts +184 -8
- package/dist/index.js +1609 -887
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1651 -933
- package/dist/index.mjs.map +1 -1
- package/dist/manifests/accordion.manifest.json +2 -2
- package/dist/manifests/alert.manifest.json +1 -1
- package/dist/manifests/announcement-bar.manifest.json +1 -1
- package/dist/manifests/app-shell.manifest.json +1 -1
- package/dist/manifests/applied-filters.manifest.json +1 -1
- package/dist/manifests/article-card.manifest.json +1 -1
- package/dist/manifests/auth-layout.manifest.json +1 -1
- package/dist/manifests/autocomplete.manifest.json +1 -1
- package/dist/manifests/avatar.manifest.json +1 -1
- package/dist/manifests/badge.manifest.json +1 -1
- package/dist/manifests/block.manifest.json +1 -1
- package/dist/manifests/bottom-nav.manifest.json +1 -1
- package/dist/manifests/breadcrumb.manifest.json +1 -1
- package/dist/manifests/button-group.manifest.json +1 -1
- package/dist/manifests/button.manifest.json +1 -1
- package/dist/manifests/calendar.manifest.json +175 -0
- package/dist/manifests/card.manifest.json +1 -1
- package/dist/manifests/checkbox.manifest.json +1 -1
- package/dist/manifests/comparison-table.manifest.json +1 -1
- package/dist/manifests/confirm-dialog.manifest.json +1 -1
- package/dist/manifests/contact-strip.manifest.json +1 -1
- package/dist/manifests/container.manifest.json +1 -1
- package/dist/manifests/cta-section.manifest.json +1 -1
- package/dist/manifests/data-table.manifest.json +8 -1
- package/dist/manifests/date-picker-popover.manifest.json +202 -0
- package/dist/manifests/date-picker.manifest.json +1 -1
- package/dist/manifests/date-range-picker.manifest.json +1 -1
- package/dist/manifests/deal-card.manifest.json +1 -1
- package/dist/manifests/dialog.manifest.json +1 -1
- package/dist/manifests/document-card.manifest.json +1 -1
- package/dist/manifests/drawer.manifest.json +1 -1
- package/dist/manifests/empty-state.manifest.json +1 -1
- package/dist/manifests/entity-card.manifest.json +1 -1
- package/dist/manifests/feature-grid.manifest.json +1 -1
- package/dist/manifests/feature-row.manifest.json +1 -1
- package/dist/manifests/fieldset.manifest.json +1 -1
- package/dist/manifests/file-upload.manifest.json +1 -1
- package/dist/manifests/filter-bar.manifest.json +1 -1
- package/dist/manifests/filter-chips.manifest.json +1 -1
- package/dist/manifests/filter-panel.manifest.json +1 -1
- package/dist/manifests/flex.manifest.json +1 -1
- package/dist/manifests/form-field.manifest.json +1 -1
- package/dist/manifests/form-layout.manifest.json +1 -1
- package/dist/manifests/form.manifest.json +1 -1
- package/dist/manifests/grid.manifest.json +1 -1
- package/dist/manifests/heading.manifest.json +1 -1
- package/dist/manifests/hero.manifest.json +1 -1
- package/dist/manifests/image.manifest.json +142 -0
- package/dist/manifests/input-group.manifest.json +1 -1
- package/dist/manifests/input.manifest.json +1 -1
- package/dist/manifests/label.manifest.json +1 -1
- package/dist/manifests/link-tabs.manifest.json +1 -1
- package/dist/manifests/link.manifest.json +1 -1
- package/dist/manifests/list.manifest.json +1 -1
- package/dist/manifests/load-more.manifest.json +1 -1
- package/dist/manifests/logo-cloud.manifest.json +1 -1
- package/dist/manifests/menu.manifest.json +1 -1
- package/dist/manifests/metric-card.manifest.json +1 -1
- package/dist/manifests/multi-select.manifest.json +1 -1
- package/dist/manifests/newsletter.manifest.json +1 -1
- package/dist/manifests/page-header.manifest.json +1 -1
- package/dist/manifests/pagination.manifest.json +1 -1
- package/dist/manifests/password-input.manifest.json +1 -1
- package/dist/manifests/popover.manifest.json +86 -4
- package/dist/manifests/process-steps.manifest.json +1 -1
- package/dist/manifests/progress.manifest.json +1 -1
- package/dist/manifests/prose.manifest.json +1 -1
- package/dist/manifests/radio.manifest.json +1 -1
- package/dist/manifests/range-slider.manifest.json +1 -1
- package/dist/manifests/search.manifest.json +1 -1
- package/dist/manifests/section-heading.manifest.json +1 -1
- package/dist/manifests/section.manifest.json +1 -1
- package/dist/manifests/segmented-control.manifest.json +1 -1
- package/dist/manifests/select-menu.manifest.json +1 -1
- package/dist/manifests/select.manifest.json +1 -1
- package/dist/manifests/separator.manifest.json +1 -1
- package/dist/manifests/site-footer.manifest.json +1 -1
- package/dist/manifests/site-header.manifest.json +13 -3
- package/dist/manifests/skeleton.manifest.json +1 -1
- package/dist/manifests/spinner.manifest.json +1 -1
- package/dist/manifests/stat-band.manifest.json +1 -1
- package/dist/manifests/stepper.manifest.json +7 -1
- package/dist/manifests/switch.manifest.json +1 -1
- package/dist/manifests/table-card.manifest.json +1 -1
- package/dist/manifests/table-of-contents.manifest.json +1 -1
- package/dist/manifests/table.manifest.json +1 -1
- package/dist/manifests/tabs.manifest.json +1 -1
- package/dist/manifests/testimonial.manifest.json +1 -1
- package/dist/manifests/text.manifest.json +1 -1
- package/dist/manifests/textarea.manifest.json +1 -1
- package/dist/manifests/theme-toggle.manifest.json +1 -1
- package/dist/manifests/time-picker.manifest.json +1 -1
- package/dist/manifests/timeline.manifest.json +1 -1
- package/dist/manifests/toast.manifest.json +1 -1
- package/dist/manifests/tombstone-card.manifest.json +1 -1
- package/dist/manifests/tooltip.manifest.json +1 -1
- package/dist/src/components/alert/Alert.js +1 -1
- package/dist/src/components/alert/Alert.js.map +1 -1
- package/dist/src/components/alert/Alert.mjs +1 -1
- package/dist/src/components/alert/Alert.mjs.map +1 -1
- package/dist/src/components/app-shell/AppShell.js +1 -1
- package/dist/src/components/app-shell/AppShell.js.map +1 -1
- package/dist/src/components/app-shell/AppShell.mjs +1 -1
- package/dist/src/components/app-shell/AppShell.mjs.map +1 -1
- package/dist/src/components/article-card/ArticleCard.js +2 -2
- package/dist/src/components/article-card/ArticleCard.js.map +1 -1
- package/dist/src/components/article-card/ArticleCard.mjs +2 -2
- package/dist/src/components/article-card/ArticleCard.mjs.map +1 -1
- package/dist/src/components/calendar/Calendar.d.ts +34 -0
- package/dist/src/components/calendar/Calendar.js +233 -0
- package/dist/src/components/calendar/Calendar.js.map +1 -0
- package/dist/src/components/calendar/Calendar.mjs +208 -0
- package/dist/src/components/calendar/Calendar.mjs.map +1 -0
- package/dist/src/components/calendar/index.d.ts +1 -0
- package/dist/src/components/calendar/index.js +23 -0
- package/dist/src/components/calendar/index.js.map +1 -0
- package/dist/src/components/calendar/index.mjs +2 -0
- package/dist/src/components/calendar/index.mjs.map +1 -0
- package/dist/src/components/comparison-table/ComparisonTable.js +1 -1
- package/dist/src/components/comparison-table/ComparisonTable.js.map +1 -1
- package/dist/src/components/comparison-table/ComparisonTable.mjs +1 -1
- package/dist/src/components/comparison-table/ComparisonTable.mjs.map +1 -1
- package/dist/src/components/cta-section/CTASection.js +1 -1
- package/dist/src/components/cta-section/CTASection.js.map +1 -1
- package/dist/src/components/cta-section/CTASection.mjs +1 -1
- package/dist/src/components/cta-section/CTASection.mjs.map +1 -1
- package/dist/src/components/data-table/DataTable.d.ts +3 -1
- package/dist/src/components/data-table/DataTable.js +2 -4
- package/dist/src/components/data-table/DataTable.js.map +1 -1
- package/dist/src/components/data-table/DataTable.mjs +2 -4
- package/dist/src/components/data-table/DataTable.mjs.map +1 -1
- package/dist/src/components/date-picker-popover/DatePickerPopover.d.ts +33 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.js +117 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.js.map +1 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.mjs +83 -0
- package/dist/src/components/date-picker-popover/DatePickerPopover.mjs.map +1 -0
- package/dist/src/components/date-picker-popover/index.d.ts +1 -0
- package/dist/src/components/date-picker-popover/index.js +23 -0
- package/dist/src/components/date-picker-popover/index.js.map +1 -0
- package/dist/src/components/date-picker-popover/index.mjs +2 -0
- package/dist/src/components/date-picker-popover/index.mjs.map +1 -0
- package/dist/src/components/image/Image.d.ts +34 -0
- package/dist/src/components/image/Image.js +75 -0
- package/dist/src/components/image/Image.js.map +1 -0
- package/dist/src/components/image/Image.mjs +41 -0
- package/dist/src/components/image/Image.mjs.map +1 -0
- package/dist/src/components/image/index.d.ts +1 -0
- package/dist/src/components/image/index.js +29 -0
- package/dist/src/components/image/index.js.map +1 -0
- package/dist/src/components/image/index.mjs +5 -0
- package/dist/src/components/image/index.mjs.map +1 -0
- package/dist/src/components/link/Link.js +4 -4
- package/dist/src/components/link/Link.js.map +1 -1
- package/dist/src/components/link/Link.mjs +4 -4
- package/dist/src/components/link/Link.mjs.map +1 -1
- package/dist/src/components/page-header/PageHeader.js +1 -1
- package/dist/src/components/page-header/PageHeader.js.map +1 -1
- package/dist/src/components/page-header/PageHeader.mjs +1 -1
- package/dist/src/components/page-header/PageHeader.mjs.map +1 -1
- package/dist/src/components/popover/Popover.d.ts +36 -3
- package/dist/src/components/popover/Popover.js +118 -22
- package/dist/src/components/popover/Popover.js.map +1 -1
- package/dist/src/components/popover/Popover.mjs +117 -22
- package/dist/src/components/popover/Popover.mjs.map +1 -1
- package/dist/src/components/section-heading/SectionHeading.js +1 -1
- package/dist/src/components/section-heading/SectionHeading.js.map +1 -1
- package/dist/src/components/section-heading/SectionHeading.mjs +1 -1
- package/dist/src/components/section-heading/SectionHeading.mjs.map +1 -1
- package/dist/src/components/site-header/SiteHeader.d.ts +25 -3
- package/dist/src/components/site-header/SiteHeader.js +141 -6
- package/dist/src/components/site-header/SiteHeader.js.map +1 -1
- package/dist/src/components/site-header/SiteHeader.mjs +141 -6
- package/dist/src/components/site-header/SiteHeader.mjs.map +1 -1
- package/dist/src/components/stepper/Stepper.d.ts +18 -0
- package/dist/src/components/stepper/Stepper.js +2 -1
- package/dist/src/components/stepper/Stepper.js.map +1 -1
- package/dist/src/components/stepper/Stepper.mjs +2 -1
- package/dist/src/components/stepper/Stepper.mjs.map +1 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/utils/date.d.ts +32 -0
- package/dist/src/utils/date.js +171 -0
- package/dist/src/utils/date.js.map +1 -0
- package/dist/src/utils/date.mjs +134 -0
- package/dist/src/utils/date.mjs.map +1 -0
- package/dist/src/utils/position.d.ts +42 -0
- package/dist/src/utils/position.js +91 -0
- package/dist/src/utils/position.js.map +1 -0
- package/dist/src/utils/position.mjs +67 -0
- package/dist/src/utils/position.mjs.map +1 -0
- package/dist/styles-full.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/alert/Alert.tsx +1 -1
- package/src/components/app-shell/AppShell.tsx +1 -1
- package/src/components/article-card/ArticleCard.tsx +2 -2
- package/src/components/calendar/Calendar.test.tsx +277 -0
- package/src/components/calendar/Calendar.tsx +273 -0
- package/src/components/calendar/index.ts +1 -0
- package/src/components/comparison-table/ComparisonTable.tsx +1 -1
- package/src/components/cta-section/CTASection.tsx +1 -1
- package/src/components/data-table/DataTable.test.tsx +21 -0
- package/src/components/data-table/DataTable.tsx +4 -1
- package/src/components/date-picker-popover/DatePickerPopover.test.tsx +223 -0
- package/src/components/date-picker-popover/DatePickerPopover.tsx +117 -0
- package/src/components/date-picker-popover/index.ts +1 -0
- package/src/components/image/Image.test.tsx +94 -0
- package/src/components/image/Image.tsx +71 -0
- package/src/components/image/index.ts +1 -0
- package/src/components/link/Link.test.tsx +2 -1
- package/src/components/link/Link.tsx +4 -4
- package/src/components/page-header/PageHeader.tsx +1 -1
- package/src/components/popover/Popover.test.tsx +307 -3
- package/src/components/popover/Popover.tsx +228 -91
- package/src/components/section-heading/SectionHeading.tsx +1 -1
- package/src/components/site-header/SiteHeader.test.tsx +103 -1
- package/src/components/site-header/SiteHeader.tsx +220 -16
- package/src/components/stepper/Stepper.test.tsx +12 -0
- package/src/components/stepper/Stepper.tsx +15 -1
- package/src/index.ts +3 -0
- package/src/manifests/accordion.manifest.json +2 -2
- package/src/manifests/alert.manifest.json +1 -1
- package/src/manifests/announcement-bar.manifest.json +1 -1
- package/src/manifests/app-shell.manifest.json +1 -1
- package/src/manifests/applied-filters.manifest.json +1 -1
- package/src/manifests/article-card.manifest.json +1 -1
- package/src/manifests/auth-layout.manifest.json +1 -1
- package/src/manifests/autocomplete.manifest.json +1 -1
- package/src/manifests/avatar.manifest.json +1 -1
- package/src/manifests/badge.manifest.json +1 -1
- package/src/manifests/block.manifest.json +1 -1
- package/src/manifests/bottom-nav.manifest.json +1 -1
- package/src/manifests/breadcrumb.manifest.json +1 -1
- package/src/manifests/button-group.manifest.json +1 -1
- package/src/manifests/button.manifest.json +1 -1
- package/src/manifests/calendar.manifest.json +175 -0
- package/src/manifests/card.manifest.json +1 -1
- package/src/manifests/checkbox.manifest.json +1 -1
- package/src/manifests/comparison-table.manifest.json +1 -1
- package/src/manifests/confirm-dialog.manifest.json +1 -1
- package/src/manifests/contact-strip.manifest.json +1 -1
- package/src/manifests/container.manifest.json +1 -1
- package/src/manifests/cta-section.manifest.json +1 -1
- package/src/manifests/data-table.manifest.json +8 -1
- package/src/manifests/date-picker-popover.manifest.json +202 -0
- package/src/manifests/date-picker.manifest.json +1 -1
- package/src/manifests/date-range-picker.manifest.json +1 -1
- package/src/manifests/deal-card.manifest.json +1 -1
- package/src/manifests/dialog.manifest.json +1 -1
- package/src/manifests/document-card.manifest.json +1 -1
- package/src/manifests/drawer.manifest.json +1 -1
- package/src/manifests/empty-state.manifest.json +1 -1
- package/src/manifests/entity-card.manifest.json +1 -1
- package/src/manifests/feature-grid.manifest.json +1 -1
- package/src/manifests/feature-row.manifest.json +1 -1
- package/src/manifests/fieldset.manifest.json +1 -1
- package/src/manifests/file-upload.manifest.json +1 -1
- package/src/manifests/filter-bar.manifest.json +1 -1
- package/src/manifests/filter-chips.manifest.json +1 -1
- package/src/manifests/filter-panel.manifest.json +1 -1
- package/src/manifests/flex.manifest.json +1 -1
- package/src/manifests/form-field.manifest.json +1 -1
- package/src/manifests/form-layout.manifest.json +1 -1
- package/src/manifests/form.manifest.json +1 -1
- package/src/manifests/grid.manifest.json +1 -1
- package/src/manifests/heading.manifest.json +1 -1
- package/src/manifests/hero.manifest.json +1 -1
- package/src/manifests/image.manifest.json +142 -0
- package/src/manifests/input-group.manifest.json +1 -1
- package/src/manifests/input.manifest.json +1 -1
- package/src/manifests/label.manifest.json +1 -1
- package/src/manifests/link-tabs.manifest.json +1 -1
- package/src/manifests/link.manifest.json +1 -1
- package/src/manifests/list.manifest.json +1 -1
- package/src/manifests/load-more.manifest.json +1 -1
- package/src/manifests/logo-cloud.manifest.json +1 -1
- package/src/manifests/menu.manifest.json +1 -1
- package/src/manifests/metric-card.manifest.json +1 -1
- package/src/manifests/multi-select.manifest.json +1 -1
- package/src/manifests/newsletter.manifest.json +1 -1
- package/src/manifests/page-header.manifest.json +1 -1
- package/src/manifests/pagination.manifest.json +1 -1
- package/src/manifests/password-input.manifest.json +1 -1
- package/src/manifests/popover.manifest.json +86 -4
- package/src/manifests/process-steps.manifest.json +1 -1
- package/src/manifests/progress.manifest.json +1 -1
- package/src/manifests/prose.manifest.json +1 -1
- package/src/manifests/radio.manifest.json +1 -1
- package/src/manifests/range-slider.manifest.json +1 -1
- package/src/manifests/search.manifest.json +1 -1
- package/src/manifests/section-heading.manifest.json +1 -1
- package/src/manifests/section.manifest.json +1 -1
- package/src/manifests/segmented-control.manifest.json +1 -1
- package/src/manifests/select-menu.manifest.json +1 -1
- package/src/manifests/select.manifest.json +1 -1
- package/src/manifests/separator.manifest.json +1 -1
- package/src/manifests/site-footer.manifest.json +1 -1
- package/src/manifests/site-header.manifest.json +13 -3
- package/src/manifests/skeleton.manifest.json +1 -1
- package/src/manifests/spinner.manifest.json +1 -1
- package/src/manifests/stat-band.manifest.json +1 -1
- package/src/manifests/stepper.manifest.json +7 -1
- package/src/manifests/switch.manifest.json +1 -1
- package/src/manifests/table-card.manifest.json +1 -1
- package/src/manifests/table-of-contents.manifest.json +1 -1
- package/src/manifests/table.manifest.json +1 -1
- package/src/manifests/tabs.manifest.json +1 -1
- package/src/manifests/testimonial.manifest.json +1 -1
- package/src/manifests/text.manifest.json +1 -1
- package/src/manifests/textarea.manifest.json +1 -1
- package/src/manifests/theme-toggle.manifest.json +1 -1
- package/src/manifests/time-picker.manifest.json +1 -1
- package/src/manifests/timeline.manifest.json +1 -1
- package/src/manifests/toast.manifest.json +1 -1
- package/src/manifests/tombstone-card.manifest.json +1 -1
- package/src/manifests/tooltip.manifest.json +1 -1
- package/src/utils/date.test.ts +190 -0
- package/src/utils/date.ts +162 -0
- package/src/utils/position.test.ts +227 -0
- package/src/utils/position.ts +129 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/page-header/PageHeader.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type PageHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n title: string;\n description?: string;\n /** Alias for `description` (migration-friendly). */\n subtitle?: string;\n /** Breadcrumbs/eyebrow above the title. */\n breadcrumbs?: React.ReactNode;\n /** Right-aligned actions (buttons, menus). */\n actions?: React.ReactNode;\n /** Small slot under the title row (tabs, filters). */\n children?: React.ReactNode;\n /** Eyebrow/kicker above the title (category, date, overline). */\n eyebrow?: React.ReactNode;\n /** Heading scale - 'hero' is for marketing landing pages. */\n size?: 'sm' | 'md' | 'lg' | 'hero';\n /** Text alignment; hero marketing pages often center. */\n align?: 'left' | 'center';\n /** Extra classes for the h1, for host display typography. */\n titleClassName?: string;\n /** Extra classes for the description. */\n descriptionClassName?: string;\n /** Extra classes for the eyebrow. */\n eyebrowClassName?: string;\n};\n\nconst sizeClasses: Record<NonNullable<PageHeaderProps['size']>, string> = {\n sm: 'text-xl',\n md: 'text-2xl',\n lg: 'text-3xl',\n hero: 'text-4xl sm:text-5xl lg:text-[3.4rem] lg:leading-[1.1]',\n};\n\n/**\n * Standard page heading block: optional breadcrumbs, title, description and\n * a right-aligned action cluster. Pages stop inventing their own spacing\n * and heading hierarchy.\n */\nexport const PageHeader = React.forwardRef<HTMLDivElement, PageHeaderProps>(function PageHeader(\n { title, description, subtitle, breadcrumbs, actions, eyebrow, size = 'md', align = 'left', titleClassName, descriptionClassName, eyebrowClassName, className, children, ...props },\n ref\n) {\n const supporting = description ?? subtitle;\n return (\n <div ref={ref} className={cn('flex flex-col gap-2', align === 'center' && 'items-center text-center', className)} {...props}>\n {breadcrumbs && <div className=\"text-sm text-muted-foreground\">{breadcrumbs}</div>}\n {eyebrow && (\n <div className={cn('text-xs font-medium uppercase tracking-wide text-primary', eyebrowClassName)}>{eyebrow}</div>\n )}\n <div className={cn('flex w-full flex-wrap items-start justify-between gap-3', align === 'center' && 'justify-center')}>\n <div className={cn('min-w-0', align === 'center' && 'flex flex-col items-center')}>\n <h1 className={cn('font-semibold tracking-tight', sizeClasses[size], titleClassName)}>{title}</h1>\n {supporting && <p className={cn('mt-2 max-w-2xl text-base text-muted-foreground', descriptionClassName)}>{supporting}</p>}\n </div>\n {actions && <div className=\"flex shrink-0 items-center gap-2\">{actions}</div>}\n </div>\n {children && <div className=\"mt-2\">{children}</div>}\n </div>\n );\n});\n"],"mappings":"AA+CsB,cAKd,YALc;AA/CtB,YAAY,WAAW;AACvB,SAAS,UAAU;AA2BnB,MAAM,cAAoE;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR;AAOO,MAAM,aAAa,MAAM,WAA4C,SAASA,YACnF,EAAE,OAAO,aAAa,UAAU,aAAa,SAAS,SAAS,OAAO,MAAM,QAAQ,QAAQ,gBAAgB,sBAAsB,kBAAkB,WAAW,UAAU,GAAG,MAAM,GAClL,KACA;AACA,QAAM,aAAa,eAAe;AAClC,SACE,qBAAC,SAAI,KAAU,WAAW,GAAG,uBAAuB,UAAU,YAAY,4BAA4B,SAAS,GAAI,GAAG,OACnH;AAAA,mBAAe,oBAAC,SAAI,WAAU,iCAAiC,uBAAY;AAAA,IAC3E,WACC,oBAAC,SAAI,WAAW,GAAG,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/page-header/PageHeader.tsx"],"sourcesContent":["import * as React from 'react';\nimport { cn } from '../../utils/cn';\n\nexport type PageHeaderProps = React.HTMLAttributes<HTMLDivElement> & {\n title: string;\n description?: string;\n /** Alias for `description` (migration-friendly). */\n subtitle?: string;\n /** Breadcrumbs/eyebrow above the title. */\n breadcrumbs?: React.ReactNode;\n /** Right-aligned actions (buttons, menus). */\n actions?: React.ReactNode;\n /** Small slot under the title row (tabs, filters). */\n children?: React.ReactNode;\n /** Eyebrow/kicker above the title (category, date, overline). */\n eyebrow?: React.ReactNode;\n /** Heading scale - 'hero' is for marketing landing pages. */\n size?: 'sm' | 'md' | 'lg' | 'hero';\n /** Text alignment; hero marketing pages often center. */\n align?: 'left' | 'center';\n /** Extra classes for the h1, for host display typography. */\n titleClassName?: string;\n /** Extra classes for the description. */\n descriptionClassName?: string;\n /** Extra classes for the eyebrow. */\n eyebrowClassName?: string;\n};\n\nconst sizeClasses: Record<NonNullable<PageHeaderProps['size']>, string> = {\n sm: 'text-xl',\n md: 'text-2xl',\n lg: 'text-3xl',\n hero: 'text-4xl sm:text-5xl lg:text-[3.4rem] lg:leading-[1.1]',\n};\n\n/**\n * Standard page heading block: optional breadcrumbs, title, description and\n * a right-aligned action cluster. Pages stop inventing their own spacing\n * and heading hierarchy.\n */\nexport const PageHeader = React.forwardRef<HTMLDivElement, PageHeaderProps>(function PageHeader(\n { title, description, subtitle, breadcrumbs, actions, eyebrow, size = 'md', align = 'left', titleClassName, descriptionClassName, eyebrowClassName, className, children, ...props },\n ref\n) {\n const supporting = description ?? subtitle;\n return (\n <div ref={ref} className={cn('flex flex-col gap-2', align === 'center' && 'items-center text-center', className)} {...props}>\n {breadcrumbs && <div className=\"text-sm text-muted-foreground\">{breadcrumbs}</div>}\n {eyebrow && (\n <div className={cn('text-xs font-medium uppercase tracking-wide text-primary-ink', eyebrowClassName)}>{eyebrow}</div>\n )}\n <div className={cn('flex w-full flex-wrap items-start justify-between gap-3', align === 'center' && 'justify-center')}>\n <div className={cn('min-w-0', align === 'center' && 'flex flex-col items-center')}>\n <h1 className={cn('font-semibold tracking-tight', sizeClasses[size], titleClassName)}>{title}</h1>\n {supporting && <p className={cn('mt-2 max-w-2xl text-base text-muted-foreground', descriptionClassName)}>{supporting}</p>}\n </div>\n {actions && <div className=\"flex shrink-0 items-center gap-2\">{actions}</div>}\n </div>\n {children && <div className=\"mt-2\">{children}</div>}\n </div>\n );\n});\n"],"mappings":"AA+CsB,cAKd,YALc;AA/CtB,YAAY,WAAW;AACvB,SAAS,UAAU;AA2BnB,MAAM,cAAoE;AAAA,EACxE,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,MAAM;AACR;AAOO,MAAM,aAAa,MAAM,WAA4C,SAASA,YACnF,EAAE,OAAO,aAAa,UAAU,aAAa,SAAS,SAAS,OAAO,MAAM,QAAQ,QAAQ,gBAAgB,sBAAsB,kBAAkB,WAAW,UAAU,GAAG,MAAM,GAClL,KACA;AACA,QAAM,aAAa,eAAe;AAClC,SACE,qBAAC,SAAI,KAAU,WAAW,GAAG,uBAAuB,UAAU,YAAY,4BAA4B,SAAS,GAAI,GAAG,OACnH;AAAA,mBAAe,oBAAC,SAAI,WAAU,iCAAiC,uBAAY;AAAA,IAC3E,WACC,oBAAC,SAAI,WAAW,GAAG,gEAAgE,gBAAgB,GAAI,mBAAQ;AAAA,IAEjH,qBAAC,SAAI,WAAW,GAAG,2DAA2D,UAAU,YAAY,gBAAgB,GAClH;AAAA,2BAAC,SAAI,WAAW,GAAG,WAAW,UAAU,YAAY,4BAA4B,GAC9E;AAAA,4BAAC,QAAG,WAAW,GAAG,gCAAgC,YAAY,IAAI,GAAG,cAAc,GAAI,iBAAM;AAAA,QAC5F,cAAc,oBAAC,OAAE,WAAW,GAAG,kDAAkD,oBAAoB,GAAI,sBAAW;AAAA,SACvH;AAAA,MACC,WAAW,oBAAC,SAAI,WAAU,oCAAoC,mBAAQ;AAAA,OACzE;AAAA,IACC,YAAY,oBAAC,SAAI,WAAU,QAAQ,UAAS;AAAA,KAC/C;AAEJ,CAAC;","names":["PageHeader"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { type Align, type Side } from '../../utils/position';
|
|
2
3
|
export type PopoverProps = {
|
|
3
4
|
/** Controlled open state. */
|
|
4
5
|
open?: boolean;
|
|
@@ -16,7 +17,39 @@ declare const Popover: React.ForwardRefExoticComponent<PopoverProps & React.RefA
|
|
|
16
17
|
export type PopoverTriggerProps = React.ButtonHTMLAttributes<HTMLButtonElement>;
|
|
17
18
|
/** The button that toggles the popover. */
|
|
18
19
|
declare const PopoverTrigger: React.ForwardRefExoticComponent<PopoverTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
19
|
-
export type
|
|
20
|
+
export type PopoverAnchorProps = React.HTMLAttributes<HTMLSpanElement>;
|
|
21
|
+
/**
|
|
22
|
+
* Anchors the panel to this element instead of the trigger. Useful when the
|
|
23
|
+
* panel belongs to a field that is not itself the button opening it.
|
|
24
|
+
*/
|
|
25
|
+
declare const PopoverAnchor: React.ForwardRefExoticComponent<PopoverAnchorProps & React.RefAttributes<HTMLSpanElement>>;
|
|
26
|
+
export type PopoverContentProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
27
|
+
/** Preferred side of the anchor. Flips when it cannot fit. */
|
|
28
|
+
side?: Side;
|
|
29
|
+
/** Cross-axis alignment against the anchor. */
|
|
30
|
+
align?: Align;
|
|
31
|
+
/** Gap between anchor and panel. */
|
|
32
|
+
sideOffset?: number;
|
|
33
|
+
/** Nudge along the cross axis. */
|
|
34
|
+
alignOffset?: number;
|
|
35
|
+
/** Minimum distance kept from the viewport edges. */
|
|
36
|
+
collisionPadding?: number;
|
|
37
|
+
/** Match the panel width to the anchor width (select-like panels). */
|
|
38
|
+
matchTriggerWidth?: boolean;
|
|
39
|
+
};
|
|
20
40
|
/** The floating panel with interactive content. */
|
|
21
|
-
declare const PopoverContent: React.ForwardRefExoticComponent<
|
|
22
|
-
|
|
41
|
+
declare const PopoverContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & {
|
|
42
|
+
/** Preferred side of the anchor. Flips when it cannot fit. */
|
|
43
|
+
side?: Side;
|
|
44
|
+
/** Cross-axis alignment against the anchor. */
|
|
45
|
+
align?: Align;
|
|
46
|
+
/** Gap between anchor and panel. */
|
|
47
|
+
sideOffset?: number;
|
|
48
|
+
/** Nudge along the cross axis. */
|
|
49
|
+
alignOffset?: number;
|
|
50
|
+
/** Minimum distance kept from the viewport edges. */
|
|
51
|
+
collisionPadding?: number;
|
|
52
|
+
/** Match the panel width to the anchor width (select-like panels). */
|
|
53
|
+
matchTriggerWidth?: boolean;
|
|
54
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
55
|
+
export { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };
|
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var Popover_exports = {};
|
|
31
31
|
__export(Popover_exports, {
|
|
32
32
|
Popover: () => Popover,
|
|
33
|
+
PopoverAnchor: () => PopoverAnchor,
|
|
33
34
|
PopoverContent: () => PopoverContent,
|
|
34
35
|
PopoverTrigger: () => PopoverTrigger
|
|
35
36
|
});
|
|
@@ -38,13 +39,16 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
38
39
|
var React = __toESM(require("react"));
|
|
39
40
|
var import_react_dom = require("react-dom");
|
|
40
41
|
var import_cn = require("../../utils/cn.js");
|
|
42
|
+
var import_position = require("../../utils/position.js");
|
|
41
43
|
const PopoverContext = React.createContext({
|
|
42
44
|
open: false,
|
|
43
45
|
setOpen: () => {
|
|
44
46
|
},
|
|
45
47
|
triggerId: "",
|
|
46
48
|
contentId: "",
|
|
47
|
-
wrapperRef: { current: null }
|
|
49
|
+
wrapperRef: { current: null },
|
|
50
|
+
anchorRef: { current: null },
|
|
51
|
+
triggerRef: { current: null }
|
|
48
52
|
});
|
|
49
53
|
const Popover = React.forwardRef(
|
|
50
54
|
({ open, onOpenChange, className, children }, ref) => {
|
|
@@ -53,6 +57,8 @@ const Popover = React.forwardRef(
|
|
|
53
57
|
const triggerId = React.useId();
|
|
54
58
|
const contentId = React.useId();
|
|
55
59
|
const wrapperRef = React.useRef(null);
|
|
60
|
+
const anchorRef = React.useRef(null);
|
|
61
|
+
const triggerRef = React.useRef(null);
|
|
56
62
|
const setRefs = React.useCallback(
|
|
57
63
|
(node) => {
|
|
58
64
|
wrapperRef.current = node;
|
|
@@ -71,7 +77,7 @@ const Popover = React.forwardRef(
|
|
|
71
77
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: setRefs, className: (0, import_cn.cn)("relative inline-block", className), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
72
78
|
PopoverContext.Provider,
|
|
73
79
|
{
|
|
74
|
-
value: { open: current, setOpen, triggerId, contentId, wrapperRef },
|
|
80
|
+
value: { open: current, setOpen, triggerId, contentId, wrapperRef, anchorRef, triggerRef },
|
|
75
81
|
children
|
|
76
82
|
}
|
|
77
83
|
) });
|
|
@@ -79,13 +85,21 @@ const Popover = React.forwardRef(
|
|
|
79
85
|
);
|
|
80
86
|
Popover.displayName = "Popover";
|
|
81
87
|
const PopoverTrigger = React.forwardRef(
|
|
82
|
-
({ className, children, onClick, ...props }, ref) => {
|
|
83
|
-
const { open, setOpen, triggerId, contentId } = React.useContext(PopoverContext);
|
|
88
|
+
({ className, children, onClick, id, ...props }, ref) => {
|
|
89
|
+
const { open, setOpen, triggerId, contentId, triggerRef } = React.useContext(PopoverContext);
|
|
90
|
+
const setRefs = React.useCallback(
|
|
91
|
+
(node) => {
|
|
92
|
+
triggerRef.current = node;
|
|
93
|
+
if (typeof ref === "function") ref(node);
|
|
94
|
+
else if (ref) ref.current = node;
|
|
95
|
+
},
|
|
96
|
+
[ref, triggerRef]
|
|
97
|
+
);
|
|
84
98
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
85
99
|
"button",
|
|
86
100
|
{
|
|
87
|
-
ref,
|
|
88
|
-
id: triggerId,
|
|
101
|
+
ref: setRefs,
|
|
102
|
+
id: id ?? triggerId,
|
|
89
103
|
type: "button",
|
|
90
104
|
"aria-haspopup": "dialog",
|
|
91
105
|
"aria-expanded": open,
|
|
@@ -106,31 +120,102 @@ const PopoverTrigger = React.forwardRef(
|
|
|
106
120
|
}
|
|
107
121
|
);
|
|
108
122
|
PopoverTrigger.displayName = "PopoverTrigger";
|
|
123
|
+
const PopoverAnchor = React.forwardRef(
|
|
124
|
+
({ className, children, ...props }, ref) => {
|
|
125
|
+
const { anchorRef } = React.useContext(PopoverContext);
|
|
126
|
+
const setRefs = React.useCallback(
|
|
127
|
+
(node) => {
|
|
128
|
+
anchorRef.current = node;
|
|
129
|
+
if (typeof ref === "function") ref(node);
|
|
130
|
+
else if (ref) ref.current = node;
|
|
131
|
+
},
|
|
132
|
+
[anchorRef, ref]
|
|
133
|
+
);
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { ref: setRefs, className: (0, import_cn.cn)("inline-block", className), ...props, children });
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
PopoverAnchor.displayName = "PopoverAnchor";
|
|
138
|
+
function rectOf(element) {
|
|
139
|
+
const rect = element.getBoundingClientRect();
|
|
140
|
+
return {
|
|
141
|
+
top: rect.top,
|
|
142
|
+
left: rect.left,
|
|
143
|
+
width: rect.width || element.offsetWidth || 0,
|
|
144
|
+
height: rect.height || element.offsetHeight || 0
|
|
145
|
+
};
|
|
146
|
+
}
|
|
109
147
|
const PopoverContent = React.forwardRef(
|
|
110
|
-
({
|
|
111
|
-
|
|
148
|
+
({
|
|
149
|
+
className,
|
|
150
|
+
children,
|
|
151
|
+
onKeyDown,
|
|
152
|
+
style,
|
|
153
|
+
side = "bottom",
|
|
154
|
+
align = "start",
|
|
155
|
+
sideOffset = 8,
|
|
156
|
+
alignOffset = 0,
|
|
157
|
+
collisionPadding = 8,
|
|
158
|
+
matchTriggerWidth = false,
|
|
159
|
+
...props
|
|
160
|
+
}, ref) => {
|
|
161
|
+
const { open, setOpen, contentId, wrapperRef, anchorRef, triggerRef } = React.useContext(PopoverContext);
|
|
162
|
+
const labelledBy = triggerRef.current?.id || void 0;
|
|
112
163
|
const contentRef = React.useRef(null);
|
|
113
164
|
const [pos, setPos] = React.useState(null);
|
|
165
|
+
const [width, setWidth] = React.useState(void 0);
|
|
166
|
+
const updatePosition = React.useCallback(() => {
|
|
167
|
+
const anchorEl = anchorRef.current ?? wrapperRef.current;
|
|
168
|
+
const panel = contentRef.current;
|
|
169
|
+
if (!anchorEl || !panel) return;
|
|
170
|
+
const anchor = rectOf(anchorEl);
|
|
171
|
+
const measured = rectOf(panel);
|
|
172
|
+
setWidth(matchTriggerWidth ? anchor.width : void 0);
|
|
173
|
+
setPos(
|
|
174
|
+
(0, import_position.computePosition)({
|
|
175
|
+
anchor,
|
|
176
|
+
content: { width: measured.width, height: measured.height },
|
|
177
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
178
|
+
side,
|
|
179
|
+
align,
|
|
180
|
+
sideOffset,
|
|
181
|
+
alignOffset,
|
|
182
|
+
collisionPadding
|
|
183
|
+
})
|
|
184
|
+
);
|
|
185
|
+
}, [
|
|
186
|
+
align,
|
|
187
|
+
alignOffset,
|
|
188
|
+
anchorRef,
|
|
189
|
+
collisionPadding,
|
|
190
|
+
matchTriggerWidth,
|
|
191
|
+
side,
|
|
192
|
+
sideOffset,
|
|
193
|
+
wrapperRef
|
|
194
|
+
]);
|
|
114
195
|
React.useLayoutEffect(() => {
|
|
115
196
|
if (!open) {
|
|
116
197
|
setPos(null);
|
|
117
198
|
return;
|
|
118
199
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const onScroll = () =>
|
|
200
|
+
updatePosition();
|
|
201
|
+
}, [open, updatePosition]);
|
|
202
|
+
React.useEffect(() => {
|
|
203
|
+
if (open && !pos) updatePosition();
|
|
204
|
+
}, [open, pos, updatePosition]);
|
|
205
|
+
React.useEffect(() => {
|
|
206
|
+
if (!open) return;
|
|
207
|
+
const onScroll = () => updatePosition();
|
|
127
208
|
window.addEventListener("scroll", onScroll, true);
|
|
128
|
-
window.addEventListener("resize",
|
|
209
|
+
window.addEventListener("resize", onScroll);
|
|
210
|
+
const panel = contentRef.current;
|
|
211
|
+
const observer = typeof ResizeObserver === "undefined" || !panel ? null : new ResizeObserver(onScroll);
|
|
212
|
+
if (panel && observer) observer.observe(panel);
|
|
129
213
|
return () => {
|
|
130
214
|
window.removeEventListener("scroll", onScroll, true);
|
|
131
|
-
window.removeEventListener("resize",
|
|
215
|
+
window.removeEventListener("resize", onScroll);
|
|
216
|
+
observer?.disconnect();
|
|
132
217
|
};
|
|
133
|
-
}, [open,
|
|
218
|
+
}, [open, updatePosition]);
|
|
134
219
|
React.useEffect(() => {
|
|
135
220
|
if (!open) return;
|
|
136
221
|
function onPointerDown(event) {
|
|
@@ -144,7 +229,7 @@ const PopoverContent = React.forwardRef(
|
|
|
144
229
|
contentRef.current.focus();
|
|
145
230
|
}
|
|
146
231
|
}, [open, pos]);
|
|
147
|
-
if (!open ||
|
|
232
|
+
if (!open || typeof document === "undefined") return null;
|
|
148
233
|
return (0, import_react_dom.createPortal)(
|
|
149
234
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
150
235
|
"div",
|
|
@@ -156,16 +241,26 @@ const PopoverContent = React.forwardRef(
|
|
|
156
241
|
},
|
|
157
242
|
id: contentId,
|
|
158
243
|
role: "dialog",
|
|
159
|
-
"aria-labelledby":
|
|
244
|
+
"aria-labelledby": labelledBy,
|
|
160
245
|
tabIndex: -1,
|
|
246
|
+
"data-side": pos?.side ?? side,
|
|
161
247
|
onKeyDown: (event) => {
|
|
162
248
|
onKeyDown?.(event);
|
|
163
249
|
if (event.key === "Escape") {
|
|
164
250
|
event.stopPropagation();
|
|
165
251
|
setOpen(false);
|
|
252
|
+
(triggerRef.current ?? anchorRef.current)?.focus();
|
|
166
253
|
}
|
|
167
254
|
},
|
|
168
|
-
style: {
|
|
255
|
+
style: {
|
|
256
|
+
position: "fixed",
|
|
257
|
+
top: pos?.top ?? 0,
|
|
258
|
+
left: pos?.left ?? 0,
|
|
259
|
+
width,
|
|
260
|
+
visibility: pos ? "visible" : "hidden",
|
|
261
|
+
zIndex: 50,
|
|
262
|
+
...style
|
|
263
|
+
},
|
|
169
264
|
className: (0, import_cn.cn)(
|
|
170
265
|
"w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md outline-none",
|
|
171
266
|
className
|
|
@@ -182,6 +277,7 @@ PopoverContent.displayName = "PopoverContent";
|
|
|
182
277
|
// Annotate the CommonJS export names for ESM import in node:
|
|
183
278
|
0 && (module.exports = {
|
|
184
279
|
Popover,
|
|
280
|
+
PopoverAnchor,
|
|
185
281
|
PopoverContent,
|
|
186
282
|
PopoverTrigger
|
|
187
283
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/popover/Popover.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\n\ntype PopoverContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n triggerId: string;\n contentId: string;\n /** The relative wrapper the popover is anchored to (measured for portal positioning). */\n wrapperRef: React.MutableRefObject<HTMLDivElement | null>;\n};\n\nconst PopoverContext = React.createContext<PopoverContextValue>({\n open: false,\n setOpen: () => {},\n triggerId: '',\n contentId: '',\n wrapperRef: { current: null },\n});\n\nexport type PopoverProps = {\n /** Controlled open state. */\n open?: boolean;\n /** Called when the open state changes. */\n onOpenChange?: (open: boolean) => void;\n className?: string;\n children: React.ReactNode;\n};\n\n/**\n * Floating panel anchored to a trigger. Unlike Tooltip, the content is\n * interactive (links, buttons, forms). Closes on outside click and Escape.\n * Renders as a non-modal dialog with proper aria wiring.\n */\nconst Popover = React.forwardRef<HTMLDivElement, PopoverProps>(\n ({ open, onOpenChange, className, children }, ref) => {\n const [internalOpen, setInternalOpen] = React.useState(false);\n const current = open ?? internalOpen;\n const triggerId = React.useId();\n const contentId = React.useId();\n const wrapperRef = React.useRef<HTMLDivElement | null>(null);\n const setRefs = React.useCallback(\n (node: HTMLDivElement | null) => {\n wrapperRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref]\n );\n\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [open, onOpenChange]\n );\n\n return (\n <div ref={setRefs} className={cn('relative inline-block', className)}>\n <PopoverContext.Provider\n value={{ open: current, setOpen, triggerId, contentId, wrapperRef }}\n >\n {children}\n </PopoverContext.Provider>\n </div>\n );\n }\n);\nPopover.displayName = 'Popover';\n\nexport type PopoverTriggerProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\n\n/** The button that toggles the popover. */\nconst PopoverTrigger = React.forwardRef<HTMLButtonElement, PopoverTriggerProps>(\n ({ className, children, onClick, ...props }, ref) => {\n const { open, setOpen, triggerId, contentId } = React.useContext(PopoverContext);\n return (\n <button\n ref={ref}\n id={triggerId}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? contentId : undefined}\n onClick={(event) => {\n onClick?.(event);\n setOpen(!open);\n }}\n className={cn(\n 'inline-flex items-center justify-center rounded-md border border-border bg-background px-3 py-1.5 text-sm font-medium transition-colors',\n 'hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',\n className\n )}\n {...props}\n >\n {children}\n </button>\n );\n }\n);\nPopoverTrigger.displayName = 'PopoverTrigger';\n\nexport type PopoverContentProps = React.HTMLAttributes<HTMLDivElement>;\n\n /** The floating panel with interactive content. */\n const PopoverContent = React.forwardRef<HTMLDivElement, PopoverContentProps>(\n ({ className, children, onKeyDown, ...props }, ref) => {\n const { open, setOpen, triggerId, contentId, wrapperRef } =\n React.useContext(PopoverContext);\n const contentRef = React.useRef<HTMLDivElement | null>(null);\n // Viewport coordinates measured from the wrapper; the panel portals to\n // document.body with position:fixed so ancestor overflow (scrollable\n // demo frames, clipped containers) can never cut it off.\n const [pos, setPos] = React.useState<{ top: number; right: number } | null>(null);\n\n React.useLayoutEffect(() => {\n if (!open) {\n setPos(null);\n return;\n }\n const GAP = 8; // matches the previous mt-2 spacing\n const measure = () => {\n const rect = wrapperRef.current?.getBoundingClientRect();\n if (!rect) return;\n setPos({ top: rect.bottom + GAP, right: Math.max(8, window.innerWidth - rect.right) });\n };\n measure();\n const onScroll = () => setOpen(false);\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', measure);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', measure);\n };\n }, [open, setOpen, wrapperRef]);\n\n // Close on outside click.\n React.useEffect(() => {\n if (!open) return;\n function onPointerDown(event: PointerEvent) {\n if (!contentRef.current?.contains(event.target as Node)) setOpen(false);\n }\n document.addEventListener('pointerdown', onPointerDown);\n return () => document.removeEventListener('pointerdown', onPointerDown);\n }, [open, setOpen]);\n\n // Focus the content when it opens so Escape reaches it. Depends on\n // `pos` because the panel only mounts once measured.\n React.useEffect(() => {\n if (open && pos && contentRef.current) {\n contentRef.current.focus();\n }\n }, [open, pos]);\n\n if (!open || !pos || typeof document === 'undefined') return null;\n\n return createPortal(\n <div\n ref={(node) => {\n contentRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n id={contentId}\n role=\"dialog\"\n aria-labelledby={triggerId}\n tabIndex={-1}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.key === 'Escape') {\n event.stopPropagation();\n setOpen(false);\n }\n }}\n style={{ position: 'fixed', top: pos.top, right: pos.right, zIndex: 50 }}\n className={cn(\n 'w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md outline-none',\n className\n )}\n {...props}\n >\n {children}\n </div>,\n document.body\n );\n }\n );\nPopoverContent.displayName = 'PopoverContent';\n\nexport { Popover, PopoverTrigger, PopoverContent };\n"],"mappings":";;;;;;;;;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import * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { computePosition, type Align, type PositionResult, type Side } from '../../utils/position';\n\ntype PopoverContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n triggerId: string;\n contentId: string;\n /** The relative wrapper the popover is anchored to by default. */\n wrapperRef: React.MutableRefObject<HTMLDivElement | null>;\n /** Optional explicit anchor, rendered by PopoverAnchor. */\n anchorRef: React.MutableRefObject<HTMLElement | null>;\n /** The rendered trigger, so Escape can restore focus and labels stay valid. */\n triggerRef: React.MutableRefObject<HTMLButtonElement | null>;\n};\n\nconst PopoverContext = React.createContext<PopoverContextValue>({\n open: false,\n setOpen: () => {},\n triggerId: '',\n contentId: '',\n wrapperRef: { current: null },\n anchorRef: { current: null },\n triggerRef: { current: null },\n});\n\nexport type PopoverProps = {\n /** Controlled open state. */\n open?: boolean;\n /** Called when the open state changes. */\n onOpenChange?: (open: boolean) => void;\n className?: string;\n children: React.ReactNode;\n};\n\n/**\n * Floating panel anchored to a trigger. Unlike Tooltip, the content is\n * interactive (links, buttons, forms). Closes on outside click and Escape.\n * Renders as a non-modal dialog with proper aria wiring.\n */\nconst Popover = React.forwardRef<HTMLDivElement, PopoverProps>(\n ({ open, onOpenChange, className, children }, ref) => {\n const [internalOpen, setInternalOpen] = React.useState(false);\n const current = open ?? internalOpen;\n const triggerId = React.useId();\n const contentId = React.useId();\n const wrapperRef = React.useRef<HTMLDivElement | null>(null);\n const anchorRef = React.useRef<HTMLElement | null>(null);\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const setRefs = React.useCallback(\n (node: HTMLDivElement | null) => {\n wrapperRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref]\n );\n\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [open, onOpenChange]\n );\n\n return (\n <div ref={setRefs} className={cn('relative inline-block', className)}>\n <PopoverContext.Provider\n value={{ open: current, setOpen, triggerId, contentId, wrapperRef, anchorRef, triggerRef }}\n >\n {children}\n </PopoverContext.Provider>\n </div>\n );\n }\n);\nPopover.displayName = 'Popover';\n\nexport type PopoverTriggerProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\n\n/** The button that toggles the popover. */\nconst PopoverTrigger = React.forwardRef<HTMLButtonElement, PopoverTriggerProps>(\n ({ className, children, onClick, id, ...props }, ref) => {\n const { open, setOpen, triggerId, contentId, triggerRef } = React.useContext(PopoverContext);\n const setRefs = React.useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref, triggerRef]\n );\n return (\n <button\n ref={setRefs}\n id={id ?? triggerId}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? contentId : undefined}\n onClick={(event) => {\n onClick?.(event);\n setOpen(!open);\n }}\n className={cn(\n 'inline-flex items-center justify-center rounded-md border border-border bg-background px-3 py-1.5 text-sm font-medium transition-colors',\n 'hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',\n className\n )}\n {...props}\n >\n {children}\n </button>\n );\n }\n);\nPopoverTrigger.displayName = 'PopoverTrigger';\n\nexport type PopoverAnchorProps = React.HTMLAttributes<HTMLSpanElement>;\n\n/**\n * Anchors the panel to this element instead of the trigger. Useful when the\n * panel belongs to a field that is not itself the button opening it.\n */\nconst PopoverAnchor = React.forwardRef<HTMLSpanElement, PopoverAnchorProps>(\n ({ className, children, ...props }, ref) => {\n const { anchorRef } = React.useContext(PopoverContext);\n const setRefs = React.useCallback(\n (node: HTMLSpanElement | null) => {\n anchorRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [anchorRef, ref]\n );\n return (\n <span ref={setRefs} className={cn('inline-block', className)} {...props}>\n {children}\n </span>\n );\n }\n);\nPopoverAnchor.displayName = 'PopoverAnchor';\n\nexport type PopoverContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Preferred side of the anchor. Flips when it cannot fit. */\n side?: Side;\n /** Cross-axis alignment against the anchor. */\n align?: Align;\n /** Gap between anchor and panel. */\n sideOffset?: number;\n /** Nudge along the cross axis. */\n alignOffset?: number;\n /** Minimum distance kept from the viewport edges. */\n collisionPadding?: number;\n /** Match the panel width to the anchor width (select-like panels). */\n matchTriggerWidth?: boolean;\n};\n\nfunction rectOf(element: Element) {\n const rect = element.getBoundingClientRect();\n return {\n top: rect.top,\n left: rect.left,\n width: rect.width || (element as HTMLElement).offsetWidth || 0,\n height: rect.height || (element as HTMLElement).offsetHeight || 0,\n };\n}\n\n/** The floating panel with interactive content. */\nconst PopoverContent = React.forwardRef<HTMLDivElement, PopoverContentProps>(\n (\n {\n className,\n children,\n onKeyDown,\n style,\n side = 'bottom',\n align = 'start',\n sideOffset = 8,\n alignOffset = 0,\n collisionPadding = 8,\n matchTriggerWidth = false,\n ...props\n },\n ref\n ) => {\n const { open, setOpen, contentId, wrapperRef, anchorRef, triggerRef } =\n React.useContext(PopoverContext);\n // The trigger may carry a consumer `id`; read the rendered element so the\n // dialog's label always points at something that exists.\n const labelledBy = triggerRef.current?.id || undefined;\n const contentRef = React.useRef<HTMLDivElement | null>(null);\n // Viewport coordinates measured from the anchor; the panel portals to\n // document.body with position:fixed so ancestor overflow can never clip it.\n const [pos, setPos] = React.useState<PositionResult | null>(null);\n const [width, setWidth] = React.useState<number | undefined>(undefined);\n\n const updatePosition = React.useCallback(() => {\n const anchorEl = anchorRef.current ?? wrapperRef.current;\n const panel = contentRef.current;\n if (!anchorEl || !panel) return;\n const anchor = rectOf(anchorEl);\n const measured = rectOf(panel);\n setWidth(matchTriggerWidth ? anchor.width : undefined);\n setPos(\n computePosition({\n anchor,\n content: { width: measured.width, height: measured.height },\n viewport: { width: window.innerWidth, height: window.innerHeight },\n side,\n align,\n sideOffset,\n alignOffset,\n collisionPadding,\n })\n );\n }, [\n align,\n alignOffset,\n anchorRef,\n collisionPadding,\n matchTriggerWidth,\n side,\n sideOffset,\n wrapperRef,\n ]);\n\n React.useLayoutEffect(() => {\n if (!open) {\n setPos(null);\n return;\n }\n updatePosition();\n }, [open, updatePosition]);\n\n // A panel that is already open on first mount measures before the wrapper's\n // ref is attached (child layout effects run first), so measure once more\n // when the refs exist.\n React.useEffect(() => {\n if (open && !pos) updatePosition();\n }, [open, pos, updatePosition]);\n\n // Keep the panel anchored while the page moves: reposition on scroll and\n // resize, and re-measure when the content itself changes size.\n React.useEffect(() => {\n if (!open) return;\n const onScroll = () => updatePosition();\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', onScroll);\n const panel = contentRef.current;\n const observer =\n typeof ResizeObserver === 'undefined' || !panel ? null : new ResizeObserver(onScroll);\n if (panel && observer) observer.observe(panel);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', onScroll);\n observer?.disconnect();\n };\n }, [open, updatePosition]);\n\n // Close on outside click.\n React.useEffect(() => {\n if (!open) return;\n function onPointerDown(event: PointerEvent) {\n if (!contentRef.current?.contains(event.target as Node)) setOpen(false);\n }\n document.addEventListener('pointerdown', onPointerDown);\n return () => document.removeEventListener('pointerdown', onPointerDown);\n }, [open, setOpen]);\n\n // Focus the content when it opens so Escape reaches it. Depends on `pos`\n // because the panel only mounts once measured.\n React.useEffect(() => {\n if (open && pos && contentRef.current) {\n contentRef.current.focus();\n }\n }, [open, pos]);\n\n if (!open || typeof document === 'undefined') return null;\n\n return createPortal(\n <div\n ref={(node) => {\n contentRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n id={contentId}\n role=\"dialog\"\n aria-labelledby={labelledBy}\n tabIndex={-1}\n data-side={pos?.side ?? side}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.key === 'Escape') {\n event.stopPropagation();\n setOpen(false);\n // Escape must hand focus back, or it lands on <body>.\n (triggerRef.current ?? anchorRef.current)?.focus();\n }\n }}\n style={{\n position: 'fixed',\n top: pos?.top ?? 0,\n left: pos?.left ?? 0,\n width,\n visibility: pos ? 'visible' : 'hidden',\n zIndex: 50,\n ...style,\n }}\n className={cn(\n 'w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md outline-none',\n className\n )}\n {...props}\n >\n {children}\n </div>,\n document.body\n );\n }\n);\nPopoverContent.displayName = 'PopoverContent';\n\nexport { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwEQ;AAtER,YAAuB;AACvB,uBAA6B;AAC7B,gBAAmB;AACnB,sBAA4E;AAe5E,MAAM,iBAAiB,MAAM,cAAmC;AAAA,EAC9D,MAAM;AAAA,EACN,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY,EAAE,SAAS,KAAK;AAAA,EAC5B,WAAW,EAAE,SAAS,KAAK;AAAA,EAC3B,YAAY,EAAE,SAAS,KAAK;AAC9B,CAAC;AAgBD,MAAM,UAAU,MAAM;AAAA,EACpB,CAAC,EAAE,MAAM,cAAc,WAAW,SAAS,GAAG,QAAQ;AACpD,UAAM,CAAC,cAAc,eAAe,IAAI,MAAM,SAAS,KAAK;AAC5D,UAAM,UAAU,QAAQ;AACxB,UAAM,YAAY,MAAM,MAAM;AAC9B,UAAM,YAAY,MAAM,MAAM;AAC9B,UAAM,aAAa,MAAM,OAA8B,IAAI;AAC3D,UAAM,YAAY,MAAM,OAA2B,IAAI;AACvD,UAAM,aAAa,MAAM,OAAiC,IAAI;AAC9D,UAAM,UAAU,MAAM;AAAA,MACpB,CAAC,SAAgC;AAC/B,mBAAW,UAAU;AACrB,YAAI,OAAO,QAAQ,WAAY,KAAI,IAAI;AAAA,iBAC9B,IAAK,KAAI,UAAU;AAAA,MAC9B;AAAA,MACA,CAAC,GAAG;AAAA,IACN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names":[]}
|
|
@@ -3,13 +3,16 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
5
|
import { cn } from "../../utils/cn.mjs";
|
|
6
|
+
import { computePosition } from "../../utils/position.mjs";
|
|
6
7
|
const PopoverContext = React.createContext({
|
|
7
8
|
open: false,
|
|
8
9
|
setOpen: () => {
|
|
9
10
|
},
|
|
10
11
|
triggerId: "",
|
|
11
12
|
contentId: "",
|
|
12
|
-
wrapperRef: { current: null }
|
|
13
|
+
wrapperRef: { current: null },
|
|
14
|
+
anchorRef: { current: null },
|
|
15
|
+
triggerRef: { current: null }
|
|
13
16
|
});
|
|
14
17
|
const Popover = React.forwardRef(
|
|
15
18
|
({ open, onOpenChange, className, children }, ref) => {
|
|
@@ -18,6 +21,8 @@ const Popover = React.forwardRef(
|
|
|
18
21
|
const triggerId = React.useId();
|
|
19
22
|
const contentId = React.useId();
|
|
20
23
|
const wrapperRef = React.useRef(null);
|
|
24
|
+
const anchorRef = React.useRef(null);
|
|
25
|
+
const triggerRef = React.useRef(null);
|
|
21
26
|
const setRefs = React.useCallback(
|
|
22
27
|
(node) => {
|
|
23
28
|
wrapperRef.current = node;
|
|
@@ -36,7 +41,7 @@ const Popover = React.forwardRef(
|
|
|
36
41
|
return /* @__PURE__ */ jsx("div", { ref: setRefs, className: cn("relative inline-block", className), children: /* @__PURE__ */ jsx(
|
|
37
42
|
PopoverContext.Provider,
|
|
38
43
|
{
|
|
39
|
-
value: { open: current, setOpen, triggerId, contentId, wrapperRef },
|
|
44
|
+
value: { open: current, setOpen, triggerId, contentId, wrapperRef, anchorRef, triggerRef },
|
|
40
45
|
children
|
|
41
46
|
}
|
|
42
47
|
) });
|
|
@@ -44,13 +49,21 @@ const Popover = React.forwardRef(
|
|
|
44
49
|
);
|
|
45
50
|
Popover.displayName = "Popover";
|
|
46
51
|
const PopoverTrigger = React.forwardRef(
|
|
47
|
-
({ className, children, onClick, ...props }, ref) => {
|
|
48
|
-
const { open, setOpen, triggerId, contentId } = React.useContext(PopoverContext);
|
|
52
|
+
({ className, children, onClick, id, ...props }, ref) => {
|
|
53
|
+
const { open, setOpen, triggerId, contentId, triggerRef } = React.useContext(PopoverContext);
|
|
54
|
+
const setRefs = React.useCallback(
|
|
55
|
+
(node) => {
|
|
56
|
+
triggerRef.current = node;
|
|
57
|
+
if (typeof ref === "function") ref(node);
|
|
58
|
+
else if (ref) ref.current = node;
|
|
59
|
+
},
|
|
60
|
+
[ref, triggerRef]
|
|
61
|
+
);
|
|
49
62
|
return /* @__PURE__ */ jsx(
|
|
50
63
|
"button",
|
|
51
64
|
{
|
|
52
|
-
ref,
|
|
53
|
-
id: triggerId,
|
|
65
|
+
ref: setRefs,
|
|
66
|
+
id: id ?? triggerId,
|
|
54
67
|
type: "button",
|
|
55
68
|
"aria-haspopup": "dialog",
|
|
56
69
|
"aria-expanded": open,
|
|
@@ -71,31 +84,102 @@ const PopoverTrigger = React.forwardRef(
|
|
|
71
84
|
}
|
|
72
85
|
);
|
|
73
86
|
PopoverTrigger.displayName = "PopoverTrigger";
|
|
87
|
+
const PopoverAnchor = React.forwardRef(
|
|
88
|
+
({ className, children, ...props }, ref) => {
|
|
89
|
+
const { anchorRef } = React.useContext(PopoverContext);
|
|
90
|
+
const setRefs = React.useCallback(
|
|
91
|
+
(node) => {
|
|
92
|
+
anchorRef.current = node;
|
|
93
|
+
if (typeof ref === "function") ref(node);
|
|
94
|
+
else if (ref) ref.current = node;
|
|
95
|
+
},
|
|
96
|
+
[anchorRef, ref]
|
|
97
|
+
);
|
|
98
|
+
return /* @__PURE__ */ jsx("span", { ref: setRefs, className: cn("inline-block", className), ...props, children });
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
PopoverAnchor.displayName = "PopoverAnchor";
|
|
102
|
+
function rectOf(element) {
|
|
103
|
+
const rect = element.getBoundingClientRect();
|
|
104
|
+
return {
|
|
105
|
+
top: rect.top,
|
|
106
|
+
left: rect.left,
|
|
107
|
+
width: rect.width || element.offsetWidth || 0,
|
|
108
|
+
height: rect.height || element.offsetHeight || 0
|
|
109
|
+
};
|
|
110
|
+
}
|
|
74
111
|
const PopoverContent = React.forwardRef(
|
|
75
|
-
({
|
|
76
|
-
|
|
112
|
+
({
|
|
113
|
+
className,
|
|
114
|
+
children,
|
|
115
|
+
onKeyDown,
|
|
116
|
+
style,
|
|
117
|
+
side = "bottom",
|
|
118
|
+
align = "start",
|
|
119
|
+
sideOffset = 8,
|
|
120
|
+
alignOffset = 0,
|
|
121
|
+
collisionPadding = 8,
|
|
122
|
+
matchTriggerWidth = false,
|
|
123
|
+
...props
|
|
124
|
+
}, ref) => {
|
|
125
|
+
const { open, setOpen, contentId, wrapperRef, anchorRef, triggerRef } = React.useContext(PopoverContext);
|
|
126
|
+
const labelledBy = triggerRef.current?.id || void 0;
|
|
77
127
|
const contentRef = React.useRef(null);
|
|
78
128
|
const [pos, setPos] = React.useState(null);
|
|
129
|
+
const [width, setWidth] = React.useState(void 0);
|
|
130
|
+
const updatePosition = React.useCallback(() => {
|
|
131
|
+
const anchorEl = anchorRef.current ?? wrapperRef.current;
|
|
132
|
+
const panel = contentRef.current;
|
|
133
|
+
if (!anchorEl || !panel) return;
|
|
134
|
+
const anchor = rectOf(anchorEl);
|
|
135
|
+
const measured = rectOf(panel);
|
|
136
|
+
setWidth(matchTriggerWidth ? anchor.width : void 0);
|
|
137
|
+
setPos(
|
|
138
|
+
computePosition({
|
|
139
|
+
anchor,
|
|
140
|
+
content: { width: measured.width, height: measured.height },
|
|
141
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
142
|
+
side,
|
|
143
|
+
align,
|
|
144
|
+
sideOffset,
|
|
145
|
+
alignOffset,
|
|
146
|
+
collisionPadding
|
|
147
|
+
})
|
|
148
|
+
);
|
|
149
|
+
}, [
|
|
150
|
+
align,
|
|
151
|
+
alignOffset,
|
|
152
|
+
anchorRef,
|
|
153
|
+
collisionPadding,
|
|
154
|
+
matchTriggerWidth,
|
|
155
|
+
side,
|
|
156
|
+
sideOffset,
|
|
157
|
+
wrapperRef
|
|
158
|
+
]);
|
|
79
159
|
React.useLayoutEffect(() => {
|
|
80
160
|
if (!open) {
|
|
81
161
|
setPos(null);
|
|
82
162
|
return;
|
|
83
163
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const onScroll = () =>
|
|
164
|
+
updatePosition();
|
|
165
|
+
}, [open, updatePosition]);
|
|
166
|
+
React.useEffect(() => {
|
|
167
|
+
if (open && !pos) updatePosition();
|
|
168
|
+
}, [open, pos, updatePosition]);
|
|
169
|
+
React.useEffect(() => {
|
|
170
|
+
if (!open) return;
|
|
171
|
+
const onScroll = () => updatePosition();
|
|
92
172
|
window.addEventListener("scroll", onScroll, true);
|
|
93
|
-
window.addEventListener("resize",
|
|
173
|
+
window.addEventListener("resize", onScroll);
|
|
174
|
+
const panel = contentRef.current;
|
|
175
|
+
const observer = typeof ResizeObserver === "undefined" || !panel ? null : new ResizeObserver(onScroll);
|
|
176
|
+
if (panel && observer) observer.observe(panel);
|
|
94
177
|
return () => {
|
|
95
178
|
window.removeEventListener("scroll", onScroll, true);
|
|
96
|
-
window.removeEventListener("resize",
|
|
179
|
+
window.removeEventListener("resize", onScroll);
|
|
180
|
+
observer?.disconnect();
|
|
97
181
|
};
|
|
98
|
-
}, [open,
|
|
182
|
+
}, [open, updatePosition]);
|
|
99
183
|
React.useEffect(() => {
|
|
100
184
|
if (!open) return;
|
|
101
185
|
function onPointerDown(event) {
|
|
@@ -109,7 +193,7 @@ const PopoverContent = React.forwardRef(
|
|
|
109
193
|
contentRef.current.focus();
|
|
110
194
|
}
|
|
111
195
|
}, [open, pos]);
|
|
112
|
-
if (!open ||
|
|
196
|
+
if (!open || typeof document === "undefined") return null;
|
|
113
197
|
return createPortal(
|
|
114
198
|
/* @__PURE__ */ jsx(
|
|
115
199
|
"div",
|
|
@@ -121,16 +205,26 @@ const PopoverContent = React.forwardRef(
|
|
|
121
205
|
},
|
|
122
206
|
id: contentId,
|
|
123
207
|
role: "dialog",
|
|
124
|
-
"aria-labelledby":
|
|
208
|
+
"aria-labelledby": labelledBy,
|
|
125
209
|
tabIndex: -1,
|
|
210
|
+
"data-side": pos?.side ?? side,
|
|
126
211
|
onKeyDown: (event) => {
|
|
127
212
|
onKeyDown?.(event);
|
|
128
213
|
if (event.key === "Escape") {
|
|
129
214
|
event.stopPropagation();
|
|
130
215
|
setOpen(false);
|
|
216
|
+
(triggerRef.current ?? anchorRef.current)?.focus();
|
|
131
217
|
}
|
|
132
218
|
},
|
|
133
|
-
style: {
|
|
219
|
+
style: {
|
|
220
|
+
position: "fixed",
|
|
221
|
+
top: pos?.top ?? 0,
|
|
222
|
+
left: pos?.left ?? 0,
|
|
223
|
+
width,
|
|
224
|
+
visibility: pos ? "visible" : "hidden",
|
|
225
|
+
zIndex: 50,
|
|
226
|
+
...style
|
|
227
|
+
},
|
|
134
228
|
className: cn(
|
|
135
229
|
"w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md outline-none",
|
|
136
230
|
className
|
|
@@ -146,6 +240,7 @@ const PopoverContent = React.forwardRef(
|
|
|
146
240
|
PopoverContent.displayName = "PopoverContent";
|
|
147
241
|
export {
|
|
148
242
|
Popover,
|
|
243
|
+
PopoverAnchor,
|
|
149
244
|
PopoverContent,
|
|
150
245
|
PopoverTrigger
|
|
151
246
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/popover/Popover.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\n\ntype PopoverContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n triggerId: string;\n contentId: string;\n /** The relative wrapper the popover is anchored to (measured for portal positioning). */\n wrapperRef: React.MutableRefObject<HTMLDivElement | null>;\n};\n\nconst PopoverContext = React.createContext<PopoverContextValue>({\n open: false,\n setOpen: () => {},\n triggerId: '',\n contentId: '',\n wrapperRef: { current: null },\n});\n\nexport type PopoverProps = {\n /** Controlled open state. */\n open?: boolean;\n /** Called when the open state changes. */\n onOpenChange?: (open: boolean) => void;\n className?: string;\n children: React.ReactNode;\n};\n\n/**\n * Floating panel anchored to a trigger. Unlike Tooltip, the content is\n * interactive (links, buttons, forms). Closes on outside click and Escape.\n * Renders as a non-modal dialog with proper aria wiring.\n */\nconst Popover = React.forwardRef<HTMLDivElement, PopoverProps>(\n ({ open, onOpenChange, className, children }, ref) => {\n const [internalOpen, setInternalOpen] = React.useState(false);\n const current = open ?? internalOpen;\n const triggerId = React.useId();\n const contentId = React.useId();\n const wrapperRef = React.useRef<HTMLDivElement | null>(null);\n const setRefs = React.useCallback(\n (node: HTMLDivElement | null) => {\n wrapperRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref]\n );\n\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [open, onOpenChange]\n );\n\n return (\n <div ref={setRefs} className={cn('relative inline-block', className)}>\n <PopoverContext.Provider\n value={{ open: current, setOpen, triggerId, contentId, wrapperRef }}\n >\n {children}\n </PopoverContext.Provider>\n </div>\n );\n }\n);\nPopover.displayName = 'Popover';\n\nexport type PopoverTriggerProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\n\n/** The button that toggles the popover. */\nconst PopoverTrigger = React.forwardRef<HTMLButtonElement, PopoverTriggerProps>(\n ({ className, children, onClick, ...props }, ref) => {\n const { open, setOpen, triggerId, contentId } = React.useContext(PopoverContext);\n return (\n <button\n ref={ref}\n id={triggerId}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? contentId : undefined}\n onClick={(event) => {\n onClick?.(event);\n setOpen(!open);\n }}\n className={cn(\n 'inline-flex items-center justify-center rounded-md border border-border bg-background px-3 py-1.5 text-sm font-medium transition-colors',\n 'hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',\n className\n )}\n {...props}\n >\n {children}\n </button>\n );\n }\n);\nPopoverTrigger.displayName = 'PopoverTrigger';\n\nexport type PopoverContentProps = React.HTMLAttributes<HTMLDivElement>;\n\n /** The floating panel with interactive content. */\n const PopoverContent = React.forwardRef<HTMLDivElement, PopoverContentProps>(\n ({ className, children, onKeyDown, ...props }, ref) => {\n const { open, setOpen, triggerId, contentId, wrapperRef } =\n React.useContext(PopoverContext);\n const contentRef = React.useRef<HTMLDivElement | null>(null);\n // Viewport coordinates measured from the wrapper; the panel portals to\n // document.body with position:fixed so ancestor overflow (scrollable\n // demo frames, clipped containers) can never cut it off.\n const [pos, setPos] = React.useState<{ top: number; right: number } | null>(null);\n\n React.useLayoutEffect(() => {\n if (!open) {\n setPos(null);\n return;\n }\n const GAP = 8; // matches the previous mt-2 spacing\n const measure = () => {\n const rect = wrapperRef.current?.getBoundingClientRect();\n if (!rect) return;\n setPos({ top: rect.bottom + GAP, right: Math.max(8, window.innerWidth - rect.right) });\n };\n measure();\n const onScroll = () => setOpen(false);\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', measure);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', measure);\n };\n }, [open, setOpen, wrapperRef]);\n\n // Close on outside click.\n React.useEffect(() => {\n if (!open) return;\n function onPointerDown(event: PointerEvent) {\n if (!contentRef.current?.contains(event.target as Node)) setOpen(false);\n }\n document.addEventListener('pointerdown', onPointerDown);\n return () => document.removeEventListener('pointerdown', onPointerDown);\n }, [open, setOpen]);\n\n // Focus the content when it opens so Escape reaches it. Depends on\n // `pos` because the panel only mounts once measured.\n React.useEffect(() => {\n if (open && pos && contentRef.current) {\n contentRef.current.focus();\n }\n }, [open, pos]);\n\n if (!open || !pos || typeof document === 'undefined') return null;\n\n return createPortal(\n <div\n ref={(node) => {\n contentRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n id={contentId}\n role=\"dialog\"\n aria-labelledby={triggerId}\n tabIndex={-1}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.key === 'Escape') {\n event.stopPropagation();\n setOpen(false);\n }\n }}\n style={{ position: 'fixed', top: pos.top, right: pos.right, zIndex: 50 }}\n className={cn(\n 'w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md outline-none',\n className\n )}\n {...props}\n >\n {children}\n </div>,\n document.body\n );\n }\n );\nPopoverContent.displayName = 'PopoverContent';\n\nexport { Popover, PopoverTrigger, PopoverContent };\n"],"mappings":";AA+DQ;AA7DR,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AAWnB,MAAM,iBAAiB,MAAM,cAAmC;AAAA,EAC9D,MAAM;AAAA,EACN,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY,EAAE,SAAS,KAAK;AAC9B,CAAC;AAgBD,MAAM,UAAU,MAAM;AAAA,EACpB,CAAC,EAAE,MAAM,cAAc,WAAW,SAAS,GAAG,QAAQ;AACpD,UAAM,CAAC,cAAc,eAAe,IAAI,MAAM,SAAS,KAAK;AAC5D,UAAM,UAAU,QAAQ;AACxB,UAAM,YAAY,MAAM,MAAM;AAC9B,UAAM,YAAY,MAAM,MAAM;AAC9B,UAAM,aAAa,MAAM,OAA8B,IAAI;AAC3D,UAAM,UAAU,MAAM;AAAA,MACpB,CAAC,SAAgC;AAC/B,mBAAW,UAAU;AACrB,YAAI,OAAO,QAAQ,WAAY,KAAI,IAAI;AAAA,iBAC9B,IAAK,KAAI,UAAU;AAAA,MAC9B;AAAA,MACA,CAAC,GAAG;AAAA,IACN;AAEA,UAAM,UAAU,MAAM;AAAA,MACpB,CAAC,SAAkB;AACjB,YAAI,SAAS,OAAW,iBAAgB,IAAI;AAC5C,uBAAe,IAAI;AAAA,M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gB;AACtB,sBAAQ,KAAK;AAAA,YACf;AAAA,UACF;AAAA,UACA,OAAO,EAAE,UAAU,SAAS,KAAK,IAAI,KAAK,OAAO,IAAI,OAAO,QAAQ,GAAG;AAAA,UACvE,WAAW;AAAA,YACT;AAAA,YACA;AAAA,UACF;AAAA,UACC,GAAG;AAAA,UAEH;AAAA;AAAA,MACH;AAAA,MACA,SAAS;AAAA,IACX;AAAA,EACF;AACF;AACF,eAAe,cAAc;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/popover/Popover.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { cn } from '../../utils/cn';\nimport { computePosition, type Align, type PositionResult, type Side } from '../../utils/position';\n\ntype PopoverContextValue = {\n open: boolean;\n setOpen: (open: boolean) => void;\n triggerId: string;\n contentId: string;\n /** The relative wrapper the popover is anchored to by default. */\n wrapperRef: React.MutableRefObject<HTMLDivElement | null>;\n /** Optional explicit anchor, rendered by PopoverAnchor. */\n anchorRef: React.MutableRefObject<HTMLElement | null>;\n /** The rendered trigger, so Escape can restore focus and labels stay valid. */\n triggerRef: React.MutableRefObject<HTMLButtonElement | null>;\n};\n\nconst PopoverContext = React.createContext<PopoverContextValue>({\n open: false,\n setOpen: () => {},\n triggerId: '',\n contentId: '',\n wrapperRef: { current: null },\n anchorRef: { current: null },\n triggerRef: { current: null },\n});\n\nexport type PopoverProps = {\n /** Controlled open state. */\n open?: boolean;\n /** Called when the open state changes. */\n onOpenChange?: (open: boolean) => void;\n className?: string;\n children: React.ReactNode;\n};\n\n/**\n * Floating panel anchored to a trigger. Unlike Tooltip, the content is\n * interactive (links, buttons, forms). Closes on outside click and Escape.\n * Renders as a non-modal dialog with proper aria wiring.\n */\nconst Popover = React.forwardRef<HTMLDivElement, PopoverProps>(\n ({ open, onOpenChange, className, children }, ref) => {\n const [internalOpen, setInternalOpen] = React.useState(false);\n const current = open ?? internalOpen;\n const triggerId = React.useId();\n const contentId = React.useId();\n const wrapperRef = React.useRef<HTMLDivElement | null>(null);\n const anchorRef = React.useRef<HTMLElement | null>(null);\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\n const setRefs = React.useCallback(\n (node: HTMLDivElement | null) => {\n wrapperRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref]\n );\n\n const setOpen = React.useCallback(\n (next: boolean) => {\n if (open === undefined) setInternalOpen(next);\n onOpenChange?.(next);\n },\n [open, onOpenChange]\n );\n\n return (\n <div ref={setRefs} className={cn('relative inline-block', className)}>\n <PopoverContext.Provider\n value={{ open: current, setOpen, triggerId, contentId, wrapperRef, anchorRef, triggerRef }}\n >\n {children}\n </PopoverContext.Provider>\n </div>\n );\n }\n);\nPopover.displayName = 'Popover';\n\nexport type PopoverTriggerProps = React.ButtonHTMLAttributes<HTMLButtonElement>;\n\n/** The button that toggles the popover. */\nconst PopoverTrigger = React.forwardRef<HTMLButtonElement, PopoverTriggerProps>(\n ({ className, children, onClick, id, ...props }, ref) => {\n const { open, setOpen, triggerId, contentId, triggerRef } = React.useContext(PopoverContext);\n const setRefs = React.useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [ref, triggerRef]\n );\n return (\n <button\n ref={setRefs}\n id={id ?? triggerId}\n type=\"button\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-controls={open ? contentId : undefined}\n onClick={(event) => {\n onClick?.(event);\n setOpen(!open);\n }}\n className={cn(\n 'inline-flex items-center justify-center rounded-md border border-border bg-background px-3 py-1.5 text-sm font-medium transition-colors',\n 'hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring',\n className\n )}\n {...props}\n >\n {children}\n </button>\n );\n }\n);\nPopoverTrigger.displayName = 'PopoverTrigger';\n\nexport type PopoverAnchorProps = React.HTMLAttributes<HTMLSpanElement>;\n\n/**\n * Anchors the panel to this element instead of the trigger. Useful when the\n * panel belongs to a field that is not itself the button opening it.\n */\nconst PopoverAnchor = React.forwardRef<HTMLSpanElement, PopoverAnchorProps>(\n ({ className, children, ...props }, ref) => {\n const { anchorRef } = React.useContext(PopoverContext);\n const setRefs = React.useCallback(\n (node: HTMLSpanElement | null) => {\n anchorRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n },\n [anchorRef, ref]\n );\n return (\n <span ref={setRefs} className={cn('inline-block', className)} {...props}>\n {children}\n </span>\n );\n }\n);\nPopoverAnchor.displayName = 'PopoverAnchor';\n\nexport type PopoverContentProps = React.HTMLAttributes<HTMLDivElement> & {\n /** Preferred side of the anchor. Flips when it cannot fit. */\n side?: Side;\n /** Cross-axis alignment against the anchor. */\n align?: Align;\n /** Gap between anchor and panel. */\n sideOffset?: number;\n /** Nudge along the cross axis. */\n alignOffset?: number;\n /** Minimum distance kept from the viewport edges. */\n collisionPadding?: number;\n /** Match the panel width to the anchor width (select-like panels). */\n matchTriggerWidth?: boolean;\n};\n\nfunction rectOf(element: Element) {\n const rect = element.getBoundingClientRect();\n return {\n top: rect.top,\n left: rect.left,\n width: rect.width || (element as HTMLElement).offsetWidth || 0,\n height: rect.height || (element as HTMLElement).offsetHeight || 0,\n };\n}\n\n/** The floating panel with interactive content. */\nconst PopoverContent = React.forwardRef<HTMLDivElement, PopoverContentProps>(\n (\n {\n className,\n children,\n onKeyDown,\n style,\n side = 'bottom',\n align = 'start',\n sideOffset = 8,\n alignOffset = 0,\n collisionPadding = 8,\n matchTriggerWidth = false,\n ...props\n },\n ref\n ) => {\n const { open, setOpen, contentId, wrapperRef, anchorRef, triggerRef } =\n React.useContext(PopoverContext);\n // The trigger may carry a consumer `id`; read the rendered element so the\n // dialog's label always points at something that exists.\n const labelledBy = triggerRef.current?.id || undefined;\n const contentRef = React.useRef<HTMLDivElement | null>(null);\n // Viewport coordinates measured from the anchor; the panel portals to\n // document.body with position:fixed so ancestor overflow can never clip it.\n const [pos, setPos] = React.useState<PositionResult | null>(null);\n const [width, setWidth] = React.useState<number | undefined>(undefined);\n\n const updatePosition = React.useCallback(() => {\n const anchorEl = anchorRef.current ?? wrapperRef.current;\n const panel = contentRef.current;\n if (!anchorEl || !panel) return;\n const anchor = rectOf(anchorEl);\n const measured = rectOf(panel);\n setWidth(matchTriggerWidth ? anchor.width : undefined);\n setPos(\n computePosition({\n anchor,\n content: { width: measured.width, height: measured.height },\n viewport: { width: window.innerWidth, height: window.innerHeight },\n side,\n align,\n sideOffset,\n alignOffset,\n collisionPadding,\n })\n );\n }, [\n align,\n alignOffset,\n anchorRef,\n collisionPadding,\n matchTriggerWidth,\n side,\n sideOffset,\n wrapperRef,\n ]);\n\n React.useLayoutEffect(() => {\n if (!open) {\n setPos(null);\n return;\n }\n updatePosition();\n }, [open, updatePosition]);\n\n // A panel that is already open on first mount measures before the wrapper's\n // ref is attached (child layout effects run first), so measure once more\n // when the refs exist.\n React.useEffect(() => {\n if (open && !pos) updatePosition();\n }, [open, pos, updatePosition]);\n\n // Keep the panel anchored while the page moves: reposition on scroll and\n // resize, and re-measure when the content itself changes size.\n React.useEffect(() => {\n if (!open) return;\n const onScroll = () => updatePosition();\n window.addEventListener('scroll', onScroll, true);\n window.addEventListener('resize', onScroll);\n const panel = contentRef.current;\n const observer =\n typeof ResizeObserver === 'undefined' || !panel ? null : new ResizeObserver(onScroll);\n if (panel && observer) observer.observe(panel);\n return () => {\n window.removeEventListener('scroll', onScroll, true);\n window.removeEventListener('resize', onScroll);\n observer?.disconnect();\n };\n }, [open, updatePosition]);\n\n // Close on outside click.\n React.useEffect(() => {\n if (!open) return;\n function onPointerDown(event: PointerEvent) {\n if (!contentRef.current?.contains(event.target as Node)) setOpen(false);\n }\n document.addEventListener('pointerdown', onPointerDown);\n return () => document.removeEventListener('pointerdown', onPointerDown);\n }, [open, setOpen]);\n\n // Focus the content when it opens so Escape reaches it. Depends on `pos`\n // because the panel only mounts once measured.\n React.useEffect(() => {\n if (open && pos && contentRef.current) {\n contentRef.current.focus();\n }\n }, [open, pos]);\n\n if (!open || typeof document === 'undefined') return null;\n\n return createPortal(\n <div\n ref={(node) => {\n contentRef.current = node;\n if (typeof ref === 'function') ref(node);\n else if (ref) ref.current = node;\n }}\n id={contentId}\n role=\"dialog\"\n aria-labelledby={labelledBy}\n tabIndex={-1}\n data-side={pos?.side ?? side}\n onKeyDown={(event) => {\n onKeyDown?.(event);\n if (event.key === 'Escape') {\n event.stopPropagation();\n setOpen(false);\n // Escape must hand focus back, or it lands on <body>.\n (triggerRef.current ?? anchorRef.current)?.focus();\n }\n }}\n style={{\n position: 'fixed',\n top: pos?.top ?? 0,\n left: pos?.left ?? 0,\n width,\n visibility: pos ? 'visible' : 'hidden',\n zIndex: 50,\n ...style,\n }}\n className={cn(\n 'w-72 rounded-md border border-border bg-popover p-4 text-popover-foreground shadow-md outline-none',\n className\n )}\n {...props}\n >\n {children}\n </div>,\n document.body\n );\n }\n);\nPopoverContent.displayName = 'PopoverContent';\n\nexport { Popover, PopoverAnchor, PopoverContent, PopoverTrigger };\n"],"mappings":";AAwEQ;AAtER,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,uBAAmE;AAe5E,MAAM,iBAAiB,MAAM,cAAmC;AAAA,EAC9D,MAAM;AAAA,EACN,SAAS,MAAM;AAAA,EAAC;AAAA,EAChB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,YAAY,EAAE,SAAS,KAAK;AAAA,EAC5B,WAAW,EAAE,SAAS,KAAK;AAAA,EAC3B,YAAY,EAAE,SAAS,KAAK;AAC9B,CAAC;AAgBD,MAAM,UAAU,MAAM;AAAA,EACpB,CAAC,EAAE,MAAM,cAAc,WAAW,SAAS,GAAG,QAAQ;AACpD,UAAM,CAAC,cAAc,eAAe,IAAI,MAAM,SAAS,KAAK;AAC5D,UAAM,UAAU,QAAQ;AACxB,UAAM,YAAY,MAAM,MAAM;AAC9B,UAAM,YAAY,MAAM,MAAM;AAC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