@vamos-ui/react 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/blocks/block-heading.d.ts +29 -0
- package/dist/blocks/block-heading.js +39 -0
- package/dist/blocks/block-image.d.ts +52 -0
- package/dist/blocks/block-image.js +48 -0
- package/dist/blocks/block-link.d.ts +30 -0
- package/dist/blocks/block-link.js +36 -0
- package/dist/blocks/create-blocks.d.ts +54 -0
- package/dist/blocks/create-blocks.js +52 -0
- package/dist/blocks/index.d.ts +55 -0
- package/dist/blocks/index.js +59 -0
- package/dist/blocks/json-ld.d.ts +18 -0
- package/dist/blocks/json-ld.js +44 -0
- package/dist/blocks/labels.d.ts +20 -0
- package/dist/blocks/labels.js +43 -0
- package/dist/blocks/rich-text.d.ts +36 -0
- package/dist/blocks/rich-text.js +106 -0
- package/dist/blocks/schema/define-block.d.ts +151 -0
- package/dist/blocks/schema/define-block.js +120 -0
- package/dist/blocks/schema/emphasis.d.ts +17 -0
- package/dist/blocks/schema/emphasis.js +69 -0
- package/dist/blocks/schema/fields.d.ts +497 -0
- package/dist/blocks/schema/fields.js +240 -0
- package/dist/blocks/schema/icons.d.ts +2 -0
- package/dist/blocks/schema/icons.js +26 -0
- package/dist/blocks/schema/index.d.ts +18 -0
- package/dist/blocks/schema/index.js +21 -0
- package/dist/blocks/schema/lint-types.d.ts +16 -0
- package/dist/blocks/schema/lint-types.js +2 -0
- package/dist/blocks/schema/lint.d.ts +32 -0
- package/dist/blocks/schema/lint.js +164 -0
- package/dist/blocks/schema/localize.d.ts +20 -0
- package/dist/blocks/schema/localize.js +29 -0
- package/dist/blocks/schema/localized.d.ts +25 -0
- package/dist/blocks/schema/localized.js +53 -0
- package/dist/blocks/schema/migrate.d.ts +24 -0
- package/dist/blocks/schema/migrate.js +75 -0
- package/dist/blocks/schema/nodes.d.ts +196 -0
- package/dist/blocks/schema/nodes.js +78 -0
- package/dist/blocks/schema/rich-doc-schema.d.ts +32 -0
- package/dist/blocks/schema/rich-doc-schema.js +66 -0
- package/dist/blocks/schema/rich-doc.d.ts +90 -0
- package/dist/blocks/schema/rich-doc.js +62 -0
- package/dist/blocks/schema/safety.d.ts +20 -0
- package/dist/blocks/schema/safety.js +49 -0
- package/dist/blocks/schema/types.d.ts +172 -0
- package/dist/blocks/schema/types.js +3 -0
- package/dist/blocks/schema/validate.d.ts +17 -0
- package/dist/blocks/schema/validate.js +32 -0
- package/dist/blocks/schema/walk.d.ts +22 -0
- package/dist/blocks/schema/walk.js +60 -0
- package/dist/blocks/section-header.d.ts +38 -0
- package/dist/blocks/section-header.js +22 -0
- package/dist/blocks/section.d.ts +59 -0
- package/dist/blocks/section.js +66 -0
- package/dist/blocks/site/_kit-1.d.ts +101 -0
- package/dist/blocks/site/_kit-1.js +137 -0
- package/dist/blocks/site/_site-icon-1.d.ts +6 -0
- package/dist/blocks/site/_site-icon-1.js +15 -0
- package/dist/blocks/site/announcement-bar.d.ts +42 -0
- package/dist/blocks/site/announcement-bar.js +38 -0
- package/dist/blocks/site/announcement-dismiss.d.ts +18 -0
- package/dist/blocks/site/announcement-dismiss.js +28 -0
- package/dist/blocks/site/article-layout.d.ts +65 -0
- package/dist/blocks/site/article-layout.js +88 -0
- package/dist/blocks/site/blog-list.d.ts +79 -0
- package/dist/blocks/site/blog-list.js +78 -0
- package/dist/blocks/site/comparison-table.d.ts +54 -0
- package/dist/blocks/site/comparison-table.js +38 -0
- package/dist/blocks/site/consent-banner.d.ts +52 -0
- package/dist/blocks/site/consent-banner.js +33 -0
- package/dist/blocks/site/contact-dock.d.ts +52 -0
- package/dist/blocks/site/contact-dock.js +55 -0
- package/dist/blocks/site/contact-form.d.ts +60 -0
- package/dist/blocks/site/contact-form.js +45 -0
- package/dist/blocks/site/cta-booking.d.ts +43 -0
- package/dist/blocks/site/cta-booking.js +69 -0
- package/dist/blocks/site/cta.d.ts +74 -0
- package/dist/blocks/site/cta.js +113 -0
- package/dist/blocks/site/embed-facade.d.ts +20 -0
- package/dist/blocks/site/embed-facade.js +21 -0
- package/dist/blocks/site/faq.d.ts +48 -0
- package/dist/blocks/site/faq.js +52 -0
- package/dist/blocks/site/feature-grid.d.ts +46 -0
- package/dist/blocks/site/feature-grid.js +50 -0
- package/dist/blocks/site/feature-tabs.d.ts +22 -0
- package/dist/blocks/site/feature-tabs.js +11 -0
- package/dist/blocks/site/footer.d.ts +68 -0
- package/dist/blocks/site/footer.js +61 -0
- package/dist/blocks/site/gallery-section.d.ts +42 -0
- package/dist/blocks/site/gallery-section.js +48 -0
- package/dist/blocks/site/hero-video.d.ts +15 -0
- package/dist/blocks/site/hero-video.js +31 -0
- package/dist/blocks/site/hero.d.ts +64 -0
- package/dist/blocks/site/hero.js +73 -0
- package/dist/blocks/site/logo-strip.d.ts +44 -0
- package/dist/blocks/site/logo-strip.js +27 -0
- package/dist/blocks/site/map-hours.d.ts +83 -0
- package/dist/blocks/site/map-hours.js +125 -0
- package/dist/blocks/site/media-text.d.ts +45 -0
- package/dist/blocks/site/media-text.js +56 -0
- package/dist/blocks/site/menu-list.d.ts +74 -0
- package/dist/blocks/site/menu-list.js +84 -0
- package/dist/blocks/site/navbar-submenu.d.ts +18 -0
- package/dist/blocks/site/navbar-submenu.js +51 -0
- package/dist/blocks/site/navbar.d.ts +67 -0
- package/dist/blocks/site/navbar.js +64 -0
- package/dist/blocks/site/not-found.d.ts +40 -0
- package/dist/blocks/site/not-found.js +38 -0
- package/dist/blocks/site/page-intro.d.ts +46 -0
- package/dist/blocks/site/page-intro.js +44 -0
- package/dist/blocks/site/pricing-table.d.ts +67 -0
- package/dist/blocks/site/pricing-table.js +83 -0
- package/dist/blocks/site/process.d.ts +36 -0
- package/dist/blocks/site/process.js +42 -0
- package/dist/blocks/site/registry-1.d.ts +720 -0
- package/dist/blocks/site/registry-1.js +783 -0
- package/dist/blocks/site/registry-2.d.ts +914 -0
- package/dist/blocks/site/registry-2.js +563 -0
- package/dist/blocks/site/rich-text-section.d.ts +34 -0
- package/dist/blocks/site/rich-text-section.js +32 -0
- package/dist/blocks/site/shared/brand-icons.d.ts +21 -0
- package/dist/blocks/site/shared/brand-icons.js +56 -0
- package/dist/blocks/site/shared/consent-gate.d.ts +41 -0
- package/dist/blocks/site/shared/consent-gate.js +43 -0
- package/dist/blocks/site/shared/consent-island.d.ts +38 -0
- package/dist/blocks/site/shared/consent-island.js +63 -0
- package/dist/blocks/site/shared/consent.d.ts +49 -0
- package/dist/blocks/site/shared/consent.js +130 -0
- package/dist/blocks/site/shared/contact-form-island.d.ts +41 -0
- package/dist/blocks/site/shared/contact-form-island.js +100 -0
- package/dist/blocks/site/shared/copy-link.d.ts +10 -0
- package/dist/blocks/site/shared/copy-link.js +25 -0
- package/dist/blocks/site/shared/dock-avoid.d.ts +15 -0
- package/dist/blocks/site/shared/dock-avoid.js +107 -0
- package/dist/blocks/site/shared/dock-hours.d.ts +13 -0
- package/dist/blocks/site/shared/dock-hours.js +25 -0
- package/dist/blocks/site/shared/gallery-lightbox.d.ts +12 -0
- package/dist/blocks/site/shared/gallery-lightbox.js +10 -0
- package/dist/blocks/site/shared/island-keys.d.ts +10 -0
- package/dist/blocks/site/shared/island-keys.js +44 -0
- package/dist/blocks/site/shared/kit-2.d.ts +55 -0
- package/dist/blocks/site/shared/kit-2.js +84 -0
- package/dist/blocks/site/shared/labels-2.d.ts +209 -0
- package/dist/blocks/site/shared/labels-2.js +427 -0
- package/dist/blocks/site/shared/open-now.d.ts +22 -0
- package/dist/blocks/site/shared/open-now.js +27 -0
- package/dist/blocks/site/shared/opening-hours.d.ts +117 -0
- package/dist/blocks/site/shared/opening-hours.js +245 -0
- package/dist/blocks/site/shared/site-accent.d.ts +48 -0
- package/dist/blocks/site/shared/site-accent.js +249 -0
- package/dist/blocks/site/shared/site-form.d.ts +79 -0
- package/dist/blocks/site/shared/site-form.js +111 -0
- package/dist/blocks/site/shared/site-routing.d.ts +54 -0
- package/dist/blocks/site/shared/site-routing.js +86 -0
- package/dist/blocks/site/shared/testimonials-carousel.d.ts +17 -0
- package/dist/blocks/site/shared/testimonials-carousel.js +64 -0
- package/dist/blocks/site/site-shell.d.ts +108 -0
- package/dist/blocks/site/site-shell.js +254 -0
- package/dist/blocks/site/stats-band.d.ts +42 -0
- package/dist/blocks/site/stats-band.js +45 -0
- package/dist/blocks/site/team.d.ts +44 -0
- package/dist/blocks/site/team.js +48 -0
- package/dist/blocks/site/testimonials.d.ts +68 -0
- package/dist/blocks/site/testimonials.js +66 -0
- package/dist/blocks/types.d.ts +63 -0
- package/dist/blocks/types.js +2 -0
- package/dist/business/approval-flow.d.ts +152 -0
- package/dist/business/approval-flow.js +221 -0
- package/dist/business/export-core.d.ts +55 -0
- package/dist/business/export-core.js +101 -0
- package/dist/business/export.d.ts +148 -0
- package/dist/business/export.js +264 -0
- package/dist/business/import-core.d.ts +104 -0
- package/dist/business/import-core.js +281 -0
- package/dist/business/import-wizard.d.ts +186 -0
- package/dist/business/import-wizard.js +401 -0
- package/dist/business/index.d.ts +12 -0
- package/dist/business/index.js +22 -0
- package/dist/business/line-items-core.d.ts +129 -0
- package/dist/business/line-items-core.js +183 -0
- package/dist/business/line-items.d.ts +119 -0
- package/dist/business/line-items.js +299 -0
- package/dist/business/multi-step-form.d.ts +131 -0
- package/dist/business/multi-step-form.js +337 -0
- package/dist/business/permission-core.d.ts +59 -0
- package/dist/business/permission-core.js +99 -0
- package/dist/business/permission-matrix.d.ts +158 -0
- package/dist/business/permission-matrix.js +341 -0
- package/dist/business/setup-checklist.d.ts +80 -0
- package/dist/business/setup-checklist.js +92 -0
- package/dist/business/signer-status.d.ts +53 -0
- package/dist/business/signer-status.js +76 -0
- package/dist/charts/area-chart.d.ts +35 -0
- package/dist/charts/area-chart.js +33 -0
- package/dist/charts/bar-chart.d.ts +27 -0
- package/dist/charts/bar-chart.js +46 -0
- package/dist/charts/bar-list.d.ts +47 -0
- package/dist/charts/bar-list.js +60 -0
- package/dist/charts/chart-shell.d.ts +173 -0
- package/dist/charts/chart-shell.js +205 -0
- package/dist/charts/chart.d.ts +73 -0
- package/dist/charts/chart.js +106 -0
- package/dist/charts/combo-chart.d.ts +29 -0
- package/dist/charts/combo-chart.js +47 -0
- package/dist/charts/donut-chart.d.ts +33 -0
- package/dist/charts/donut-chart.js +113 -0
- package/dist/charts/funnel.d.ts +51 -0
- package/dist/charts/funnel.js +69 -0
- package/dist/charts/gauge.d.ts +62 -0
- package/dist/charts/gauge.js +104 -0
- package/dist/charts/heatmap.d.ts +81 -0
- package/dist/charts/heatmap.js +338 -0
- package/dist/charts/index.d.ts +12 -0
- package/dist/charts/index.js +14 -0
- package/dist/charts/line-chart.d.ts +21 -0
- package/dist/charts/line-chart.js +36 -0
- package/dist/charts/test-utils.d.ts +2 -0
- package/dist/charts/test-utils.js +38 -0
- package/dist/charts/utils.d.ts +130 -0
- package/dist/charts/utils.js +262 -0
- package/dist/components/_qr-core.d.ts +26 -0
- package/dist/components/_qr-core.js +376 -0
- package/dist/components/accordion.d.ts +47 -0
- package/dist/components/accordion.js +70 -0
- package/dist/components/activity-timeline.d.ts +149 -0
- package/dist/components/activity-timeline.js +122 -0
- package/dist/components/address-field.d.ts +116 -0
- package/dist/components/address-field.js +219 -0
- package/dist/components/alert-dialog.d.ts +99 -0
- package/dist/components/alert-dialog.js +192 -0
- package/dist/components/alert.d.ts +42 -0
- package/dist/components/alert.js +82 -0
- package/dist/components/app-shell.d.ts +159 -0
- package/dist/components/app-shell.js +289 -0
- package/dist/components/attachment-list.d.ts +96 -0
- package/dist/components/attachment-list.js +196 -0
- package/dist/components/audit-log.d.ts +150 -0
- package/dist/components/audit-log.js +205 -0
- package/dist/components/avatar.d.ts +87 -0
- package/dist/components/avatar.js +126 -0
- package/dist/components/backup-codes.d.ts +42 -0
- package/dist/components/backup-codes.js +67 -0
- package/dist/components/badge.d.ts +41 -0
- package/dist/components/badge.js +68 -0
- package/dist/components/breadcrumb.d.ts +78 -0
- package/dist/components/breadcrumb.js +106 -0
- package/dist/components/button-group.d.ts +52 -0
- package/dist/components/button-group.js +77 -0
- package/dist/components/button.d.ts +58 -0
- package/dist/components/button.js +107 -0
- package/dist/components/calendar.d.ts +240 -0
- package/dist/components/calendar.js +483 -0
- package/dist/components/card.d.ts +66 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +170 -0
- package/dist/components/carousel.js +348 -0
- package/dist/components/checkbox.d.ts +78 -0
- package/dist/components/checkbox.js +138 -0
- package/dist/components/color-picker.d.ts +112 -0
- package/dist/components/color-picker.js +235 -0
- package/dist/components/combobox.d.ts +136 -0
- package/dist/components/combobox.js +294 -0
- package/dist/components/command.d.ts +281 -0
- package/dist/components/command.js +498 -0
- package/dist/components/comment-thread.d.ts +252 -0
- package/dist/components/comment-thread.js +449 -0
- package/dist/components/context-menu.d.ts +77 -0
- package/dist/components/context-menu.js +82 -0
- package/dist/components/currency-input.d.ts +43 -0
- package/dist/components/currency-input.js +85 -0
- package/dist/components/date-picker.d.ts +141 -0
- package/dist/components/date-picker.js +241 -0
- package/dist/components/date-range-picker.d.ts +91 -0
- package/dist/components/date-range-picker.js +251 -0
- package/dist/components/description-list.d.ts +92 -0
- package/dist/components/description-list.js +42 -0
- package/dist/components/dialog.d.ts +139 -0
- package/dist/components/dialog.js +185 -0
- package/dist/components/dropdown-menu.d.ts +100 -0
- package/dist/components/dropdown-menu.js +102 -0
- package/dist/components/editor-layout.d.ts +166 -0
- package/dist/components/editor-layout.js +237 -0
- package/dist/components/empty-state.d.ts +49 -0
- package/dist/components/empty-state.js +68 -0
- package/dist/components/entity-card.d.ts +83 -0
- package/dist/components/entity-card.js +92 -0
- package/dist/components/file-upload.d.ts +256 -0
- package/dist/components/file-upload.js +490 -0
- package/dist/components/formatted-input.d.ts +177 -0
- package/dist/components/formatted-input.js +399 -0
- package/dist/components/hierarchy-chart.d.ts +190 -0
- package/dist/components/hierarchy-chart.js +890 -0
- package/dist/components/hover-card.d.ts +21 -0
- package/dist/components/hover-card.js +32 -0
- package/dist/components/iban-input.d.ts +38 -0
- package/dist/components/iban-input.js +112 -0
- package/dist/components/id-input.d.ts +65 -0
- package/dist/components/id-input.js +130 -0
- package/dist/components/image.d.ts +130 -0
- package/dist/components/image.js +168 -0
- package/dist/components/input-otp.d.ts +62 -0
- package/dist/components/input-otp.js +73 -0
- package/dist/components/input.d.ts +141 -0
- package/dist/components/input.js +187 -0
- package/dist/components/item.d.ts +96 -0
- package/dist/components/item.js +113 -0
- package/dist/components/kbd.d.ts +64 -0
- package/dist/components/kbd.js +119 -0
- package/dist/components/list-layout.d.ts +144 -0
- package/dist/components/list-layout.js +210 -0
- package/dist/components/native-select.d.ts +33 -0
- package/dist/components/native-select.js +48 -0
- package/dist/components/navigation-menu.d.ts +127 -0
- package/dist/components/navigation-menu.js +129 -0
- package/dist/components/notification-center.d.ts +164 -0
- package/dist/components/notification-center.js +399 -0
- package/dist/components/page-header.d.ts +60 -0
- package/dist/components/page-header.js +60 -0
- package/dist/components/pagination.d.ts +121 -0
- package/dist/components/pagination.js +174 -0
- package/dist/components/phone-input.d.ts +49 -0
- package/dist/components/phone-input.js +266 -0
- package/dist/components/pin-map.d.ts +58 -0
- package/dist/components/pin-map.js +167 -0
- package/dist/components/popover.d.ts +38 -0
- package/dist/components/popover.js +69 -0
- package/dist/components/progress.d.ts +79 -0
- package/dist/components/progress.js +97 -0
- package/dist/components/qr-code.d.ts +36 -0
- package/dist/components/qr-code.js +27 -0
- package/dist/components/radio-group.d.ts +43 -0
- package/dist/components/radio-group.js +81 -0
- package/dist/components/record-detail-layout.d.ts +167 -0
- package/dist/components/record-detail-layout.js +233 -0
- package/dist/components/record-picker.d.ts +199 -0
- package/dist/components/record-picker.js +650 -0
- package/dist/components/resizable.d.ts +50 -0
- package/dist/components/resizable.js +88 -0
- package/dist/components/scroll-area.d.ts +40 -0
- package/dist/components/scroll-area.js +56 -0
- package/dist/components/select.d.ts +126 -0
- package/dist/components/select.js +137 -0
- package/dist/components/separator.d.ts +31 -0
- package/dist/components/separator.js +41 -0
- package/dist/components/settings-layout.d.ts +134 -0
- package/dist/components/settings-layout.js +180 -0
- package/dist/components/sheet.d.ts +103 -0
- package/dist/components/sheet.js +165 -0
- package/dist/components/sidebar.d.ts +171 -0
- package/dist/components/sidebar.js +421 -0
- package/dist/components/signature-pad.d.ts +85 -0
- package/dist/components/signature-pad.js +283 -0
- package/dist/components/skeleton.d.ts +64 -0
- package/dist/components/skeleton.js +53 -0
- package/dist/components/sla-timer.d.ts +75 -0
- package/dist/components/sla-timer.js +142 -0
- package/dist/components/slider.d.ts +57 -0
- package/dist/components/slider.js +133 -0
- package/dist/components/slug-input.d.ts +69 -0
- package/dist/components/slug-input.js +201 -0
- package/dist/components/sparkline.d.ts +54 -0
- package/dist/components/sparkline.js +122 -0
- package/dist/components/spinner.d.ts +34 -0
- package/dist/components/spinner.js +34 -0
- package/dist/components/stat.d.ts +135 -0
- package/dist/components/stat.js +130 -0
- package/dist/components/status-picker.d.ts +107 -0
- package/dist/components/status-picker.js +175 -0
- package/dist/components/stepper.d.ts +86 -0
- package/dist/components/stepper.js +103 -0
- package/dist/components/switch.d.ts +34 -0
- package/dist/components/switch.js +70 -0
- package/dist/components/table.d.ts +101 -0
- package/dist/components/table.js +72 -0
- package/dist/components/tabs.d.ts +103 -0
- package/dist/components/tabs.js +173 -0
- package/dist/components/tag-input.d.ts +77 -0
- package/dist/components/tag-input.js +305 -0
- package/dist/components/task-list.d.ts +89 -0
- package/dist/components/task-list.js +238 -0
- package/dist/components/time-picker.d.ts +119 -0
- package/dist/components/time-picker.js +399 -0
- package/dist/components/toast.d.ts +87 -0
- package/dist/components/toast.js +142 -0
- package/dist/components/toggle.d.ts +77 -0
- package/dist/components/toggle.js +109 -0
- package/dist/components/tooltip.d.ts +69 -0
- package/dist/components/tooltip.js +105 -0
- package/dist/components/top-bar.d.ts +87 -0
- package/dist/components/top-bar.js +99 -0
- package/dist/components/tour.d.ts +60 -0
- package/dist/components/tour.js +139 -0
- package/dist/components/tree-select.d.ts +89 -0
- package/dist/components/tree-select.js +243 -0
- package/dist/components/tree-view.d.ts +109 -0
- package/dist/components/tree-view.js +170 -0
- package/dist/components/typography.d.ts +107 -0
- package/dist/components/typography.js +128 -0
- package/dist/components/user-picker.d.ts +89 -0
- package/dist/components/user-picker.js +162 -0
- package/dist/components/version-history.d.ts +191 -0
- package/dist/components/version-history.js +431 -0
- package/dist/data-table/csv.d.ts +27 -0
- package/dist/data-table/csv.js +68 -0
- package/dist/data-table/data-table.d.ts +423 -0
- package/dist/data-table/data-table.js +1259 -0
- package/dist/data-table/filter-bar.d.ts +146 -0
- package/dist/data-table/filter-bar.js +569 -0
- package/dist/data-table/filter-fns.d.ts +65 -0
- package/dist/data-table/filter-fns.js +382 -0
- package/dist/data-table/index.d.ts +8 -0
- package/dist/data-table/index.js +9 -0
- package/dist/data-table/saved-views.d.ts +100 -0
- package/dist/data-table/saved-views.js +251 -0
- package/dist/data-table/types.d.ts +168 -0
- package/dist/data-table/types.js +87 -0
- package/dist/data-table/url-state.d.ts +94 -0
- package/dist/data-table/url-state.js +303 -0
- package/dist/data-table/view-state.d.ts +16 -0
- package/dist/data-table/view-state.js +81 -0
- package/dist/editor/_test-setup.d.ts +1 -0
- package/dist/editor/_test-setup.js +33 -0
- package/dist/editor/block-editor.d.ts +137 -0
- package/dist/editor/block-editor.js +280 -0
- package/dist/editor/commands.d.ts +31 -0
- package/dist/editor/commands.js +150 -0
- package/dist/editor/context.d.ts +108 -0
- package/dist/editor/context.js +30 -0
- package/dist/editor/convert.d.ts +66 -0
- package/dist/editor/convert.js +567 -0
- package/dist/editor/drag-handle.d.ts +10 -0
- package/dist/editor/drag-handle.js +69 -0
- package/dist/editor/extensions.d.ts +34 -0
- package/dist/editor/extensions.js +239 -0
- package/dist/editor/index.d.ts +14 -0
- package/dist/editor/index.js +17 -0
- package/dist/editor/inserter.d.ts +12 -0
- package/dist/editor/inserter.js +88 -0
- package/dist/editor/inspector.d.ts +17 -0
- package/dist/editor/inspector.js +65 -0
- package/dist/editor/items.d.ts +62 -0
- package/dist/editor/items.js +195 -0
- package/dist/editor/labels.d.ts +119 -0
- package/dist/editor/labels.js +130 -0
- package/dist/editor/markdown.d.ts +14 -0
- package/dist/editor/markdown.js +209 -0
- package/dist/editor/menus.d.ts +20 -0
- package/dist/editor/menus.js +236 -0
- package/dist/editor/nodes.d.ts +14 -0
- package/dist/editor/nodes.js +201 -0
- package/dist/editor/outline.d.ts +11 -0
- package/dist/editor/outline.js +52 -0
- package/dist/editor/schema-form.d.ts +64 -0
- package/dist/editor/schema-form.js +290 -0
- package/dist/editor/slash-menu.d.ts +15 -0
- package/dist/editor/slash-menu.js +119 -0
- package/dist/fonts/catalog.d.ts +53 -0
- package/dist/fonts/catalog.js +121 -0
- package/dist/fonts/font-picker.d.ts +70 -0
- package/dist/fonts/font-picker.js +225 -0
- package/dist/fonts/index.d.ts +6 -0
- package/dist/fonts/index.js +7 -0
- package/dist/fonts/loader.d.ts +66 -0
- package/dist/fonts/loader.js +161 -0
- package/dist/fonts/pairing-picker.d.ts +31 -0
- package/dist/fonts/pairing-picker.js +81 -0
- package/dist/fonts/pairings.d.ts +84 -0
- package/dist/fonts/pairings.js +149 -0
- package/dist/fonts/provider.d.ts +34 -0
- package/dist/fonts/provider.js +51 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.js +1 -0
- package/dist/format/core.d.ts +149 -0
- package/dist/format/core.js +357 -0
- package/dist/format/index.d.ts +4 -0
- package/dist/format/index.js +5 -0
- package/dist/format/use-format.d.ts +1 -0
- package/dist/format/use-format.js +3 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +92 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.js +16 -0
- package/dist/lib/color.d.ts +64 -0
- package/dist/lib/color.js +177 -0
- package/dist/lib/compose-refs.d.ts +24 -0
- package/dist/lib/compose-refs.js +45 -0
- package/dist/lib/data-islands.d.ts +194 -0
- package/dist/lib/data-islands.js +368 -0
- package/dist/lib/date.d.ts +129 -0
- package/dist/lib/date.js +386 -0
- package/dist/lib/field-context.d.ts +64 -0
- package/dist/lib/field-context.js +62 -0
- package/dist/lib/floating-arrow.d.ts +18 -0
- package/dist/lib/floating-arrow.js +15 -0
- package/dist/lib/islands.d.ts +38 -0
- package/dist/lib/islands.js +40 -0
- package/dist/lib/labels.d.ts +51 -0
- package/dist/lib/labels.js +56 -0
- package/dist/lib/layer.d.ts +36 -0
- package/dist/lib/layer.js +42 -0
- package/dist/lib/locale.d.ts +85 -0
- package/dist/lib/locale.js +105 -0
- package/dist/lib/menu.d.ts +58 -0
- package/dist/lib/menu.js +99 -0
- package/dist/lib/message-format.d.ts +20 -0
- package/dist/lib/message-format.js +116 -0
- package/dist/lib/nav.d.ts +132 -0
- package/dist/lib/nav.js +178 -0
- package/dist/lib/provider.d.ts +100 -0
- package/dist/lib/provider.js +105 -0
- package/dist/lib/public.d.ts +23 -0
- package/dist/lib/public.js +34 -0
- package/dist/lib/sr-name.d.ts +18 -0
- package/dist/lib/sr-name.js +17 -0
- package/dist/lib/text.d.ts +100 -0
- package/dist/lib/text.js +233 -0
- package/dist/lib/theme-scope.d.ts +58 -0
- package/dist/lib/theme-scope.js +59 -0
- package/dist/lib/use-async-list.d.ts +60 -0
- package/dist/lib/use-async-list.js +119 -0
- package/dist/lib/use-container-width.d.ts +19 -0
- package/dist/lib/use-container-width.js +39 -0
- package/dist/lib/use-controllable-state.d.ts +33 -0
- package/dist/lib/use-controllable-state.js +56 -0
- package/dist/lib/use-edge-fade.d.ts +13 -0
- package/dist/lib/use-edge-fade.js +43 -0
- package/dist/lib/use-formatted-input.d.ts +69 -0
- package/dist/lib/use-formatted-input.js +152 -0
- package/dist/lib/use-hotkeys.d.ts +80 -0
- package/dist/lib/use-hotkeys.js +221 -0
- package/dist/lib/use-hover-intent.d.ts +44 -0
- package/dist/lib/use-hover-intent.js +119 -0
- package/dist/lib/use-media-query.d.ts +21 -0
- package/dist/lib/use-media-query.js +28 -0
- package/dist/lib/use-reduced-motion.d.ts +8 -0
- package/dist/lib/use-reduced-motion.js +13 -0
- package/dist/lib/use-tree.d.ts +153 -0
- package/dist/lib/use-tree.js +534 -0
- package/dist/lib/value-format.d.ts +25 -0
- package/dist/lib/value-format.js +56 -0
- package/dist/lib/variants.d.ts +131 -0
- package/dist/lib/variants.js +109 -0
- package/dist/locale-data/core/date.d.ts +24 -0
- package/dist/locale-data/core/date.js +68 -0
- package/dist/locale-data/core/decimal.d.ts +19 -0
- package/dist/locale-data/core/decimal.js +79 -0
- package/dist/locale-data/core/holidays.d.ts +30 -0
- package/dist/locale-data/core/holidays.js +79 -0
- package/dist/locale-data/core/iban.d.ts +29 -0
- package/dist/locale-data/core/iban.js +74 -0
- package/dist/locale-data/core/index.d.ts +7 -0
- package/dist/locale-data/core/index.js +6 -0
- package/dist/locale-data/core/types.d.ts +173 -0
- package/dist/locale-data/core/types.js +6 -0
- package/dist/locale-data/core/week-info.d.ts +23 -0
- package/dist/locale-data/core/week-info.js +85 -0
- package/dist/locale-data/core/working-days.d.ts +27 -0
- package/dist/locale-data/core/working-days.js +133 -0
- package/dist/locale-data/index.d.ts +2 -0
- package/dist/locale-data/index.js +4 -0
- package/dist/locale-data/tr/address-tr.json +1 -0
- package/dist/locale-data/tr/address.d.ts +23 -0
- package/dist/locale-data/tr/address.js +52 -0
- package/dist/locale-data/tr/holidays.d.ts +31 -0
- package/dist/locale-data/tr/holidays.js +81 -0
- package/dist/locale-data/tr/iban.d.ts +21 -0
- package/dist/locale-data/tr/iban.js +45 -0
- package/dist/locale-data/tr/id.d.ts +36 -0
- package/dist/locale-data/tr/id.js +120 -0
- package/dist/locale-data/tr/index.d.ts +12 -0
- package/dist/locale-data/tr/index.js +33 -0
- package/dist/locale-data/tr/kdv.d.ts +91 -0
- package/dist/locale-data/tr/kdv.js +222 -0
- package/dist/locales/en.d.ts +2102 -0
- package/dist/locales/en.js +2088 -0
- package/dist/locales/tr.d.ts +2086 -0
- package/dist/locales/tr.js +2087 -0
- package/dist/media/focal-point.d.ts +42 -0
- package/dist/media/focal-point.js +96 -0
- package/dist/media/gallery-layout.d.ts +19 -0
- package/dist/media/gallery-layout.js +61 -0
- package/dist/media/gallery.d.ts +64 -0
- package/dist/media/gallery.js +140 -0
- package/dist/media/image-cropper.d.ts +86 -0
- package/dist/media/image-cropper.js +170 -0
- package/dist/media/image-field.d.ts +115 -0
- package/dist/media/image-field.js +212 -0
- package/dist/media/index.d.ts +19 -0
- package/dist/media/index.js +23 -0
- package/dist/media/lightbox.d.ts +82 -0
- package/dist/media/lightbox.js +171 -0
- package/dist/media/link-preview.d.ts +97 -0
- package/dist/media/link-preview.js +177 -0
- package/dist/media/media-library.d.ts +244 -0
- package/dist/media/media-library.js +776 -0
- package/dist/media/media-picker.d.ts +96 -0
- package/dist/media/media-picker.js +209 -0
- package/dist/media/media-provider.d.ts +23 -0
- package/dist/media/media-provider.js +44 -0
- package/dist/media/media-utils.d.ts +39 -0
- package/dist/media/media-utils.js +145 -0
- package/dist/media/memory-adapter.d.ts +22 -0
- package/dist/media/memory-adapter.js +162 -0
- package/dist/media/rest-adapter.d.ts +90 -0
- package/dist/media/rest-adapter.js +208 -0
- package/dist/media/serp.d.ts +62 -0
- package/dist/media/serp.js +108 -0
- package/dist/media/test-fixtures.d.ts +3 -0
- package/dist/media/test-fixtures.js +37 -0
- package/dist/media/types.d.ts +183 -0
- package/dist/media/types.js +3 -0
- package/dist/media/use-pan-zoom.d.ts +51 -0
- package/dist/media/use-pan-zoom.js +156 -0
- package/dist/media/use-upload-queue.d.ts +64 -0
- package/dist/media/use-upload-queue.js +115 -0
- package/dist/media/video-player.d.ts +135 -0
- package/dist/media/video-player.js +319 -0
- package/dist/motion/core.d.ts +32 -0
- package/dist/motion/core.js +77 -0
- package/dist/motion/count-up.d.ts +29 -0
- package/dist/motion/count-up.js +92 -0
- package/dist/motion/index.d.ts +11 -0
- package/dist/motion/index.js +13 -0
- package/dist/motion/motion-scope.d.ts +17 -0
- package/dist/motion/motion-scope.js +16 -0
- package/dist/motion/page-transition.d.ts +33 -0
- package/dist/motion/page-transition.js +61 -0
- package/dist/motion/parallax.d.ts +37 -0
- package/dist/motion/parallax.js +90 -0
- package/dist/motion/pointer.d.ts +38 -0
- package/dist/motion/pointer.js +117 -0
- package/dist/motion/reveal.d.ts +72 -0
- package/dist/motion/reveal.js +133 -0
- package/dist/motion/scroll-shrink.d.ts +18 -0
- package/dist/motion/scroll-shrink.js +47 -0
- package/dist/motion/skeleton-swap.d.ts +17 -0
- package/dist/motion/skeleton-swap.js +43 -0
- package/dist/motion/text-reveal.d.ts +30 -0
- package/dist/motion/text-reveal.js +29 -0
- package/dist/motion/ticker.d.ts +35 -0
- package/dist/motion/ticker.js +16 -0
- package/dist/next/index.d.ts +42 -0
- package/dist/next/index.js +36 -0
- package/dist/render/block-renderer.d.ts +56 -0
- package/dist/render/block-renderer.js +137 -0
- package/dist/render/index.d.ts +6 -0
- package/dist/render/index.js +7 -0
- package/dist/render/prepare.d.ts +61 -0
- package/dist/render/prepare.js +119 -0
- package/dist/scheduler/core/duration.d.ts +83 -0
- package/dist/scheduler/core/duration.js +174 -0
- package/dist/scheduler/core/gantt.d.ts +63 -0
- package/dist/scheduler/core/gantt.js +226 -0
- package/dist/scheduler/core/index.d.ts +6 -0
- package/dist/scheduler/core/index.js +7 -0
- package/dist/scheduler/core/layout.d.ts +97 -0
- package/dist/scheduler/core/layout.js +249 -0
- package/dist/scheduler/core/time-scale.d.ts +89 -0
- package/dist/scheduler/core/time-scale.js +173 -0
- package/dist/scheduler/gantt.d.ts +125 -0
- package/dist/scheduler/gantt.js +532 -0
- package/dist/scheduler/index.d.ts +6 -0
- package/dist/scheduler/index.js +7 -0
- package/dist/scheduler/resource-calendar.d.ts +218 -0
- package/dist/scheduler/resource-calendar.js +661 -0
- package/dist/scheduler/scheduler.d.ts +168 -0
- package/dist/scheduler/scheduler.js +768 -0
- package/dist/scheduler/shared.d.ts +63 -0
- package/dist/scheduler/shared.js +145 -0
- package/dist/scheduler/time-tracker.d.ts +138 -0
- package/dist/scheduler/time-tracker.js +403 -0
- package/dist/sortable/core.d.ts +67 -0
- package/dist/sortable/core.js +167 -0
- package/dist/sortable/index.d.ts +8 -0
- package/dist/sortable/index.js +10 -0
- package/dist/sortable/kanban-core.d.ts +70 -0
- package/dist/sortable/kanban-core.js +67 -0
- package/dist/sortable/kanban.d.ts +147 -0
- package/dist/sortable/kanban.js +472 -0
- package/dist/sortable/sortable-list.d.ts +71 -0
- package/dist/sortable/sortable-list.js +76 -0
- package/dist/sortable/sortable-tree.d.ts +105 -0
- package/dist/sortable/sortable-tree.js +462 -0
- package/dist/sortable/sortable.d.ts +188 -0
- package/dist/sortable/sortable.js +485 -0
- package/dist/sortable/use-pointer-drag.d.ts +75 -0
- package/dist/sortable/use-pointer-drag.js +173 -0
- package/dist/sortable/use-time-scale.d.ts +11 -0
- package/dist/sortable/use-time-scale.js +19 -0
- package/dist/styles/base.css +51 -0
- package/dist/styles/blocks.css +949 -0
- package/dist/styles/calendar.css +642 -0
- package/dist/styles/charts.css +264 -0
- package/dist/styles/data.css +474 -0
- package/dist/styles/editors.css +1022 -0
- package/dist/styles/forms.css +406 -0
- package/dist/styles/media.css +515 -0
- package/dist/styles/motion.css +389 -0
- package/dist/styles/navigation.css +293 -0
- package/dist/styles/overlays.css +244 -0
- package/dist/styles.css +743 -0
- package/package.json +160 -4
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { MediaItem } from "./types.js";
|
|
3
|
+
declare const lightboxLabels: {
|
|
4
|
+
viewer: string;
|
|
5
|
+
counter: string;
|
|
6
|
+
counterCaption: string;
|
|
7
|
+
close: string;
|
|
8
|
+
previous: string;
|
|
9
|
+
next: string;
|
|
10
|
+
zoomIn: string;
|
|
11
|
+
zoomOut: string;
|
|
12
|
+
resetZoom: string;
|
|
13
|
+
download: string;
|
|
14
|
+
info: string;
|
|
15
|
+
error: string;
|
|
16
|
+
filename: string;
|
|
17
|
+
dimensions: string;
|
|
18
|
+
size: string;
|
|
19
|
+
type: string;
|
|
20
|
+
uploaded: string;
|
|
21
|
+
uploadedBy: string;
|
|
22
|
+
alt: string;
|
|
23
|
+
noAlt: string;
|
|
24
|
+
decorative: string;
|
|
25
|
+
};
|
|
26
|
+
export type LightboxLabels = typeof lightboxLabels;
|
|
27
|
+
interface LightboxContextValue {
|
|
28
|
+
open: (index?: number) => void;
|
|
29
|
+
close: () => void;
|
|
30
|
+
isOpen: boolean;
|
|
31
|
+
index: number;
|
|
32
|
+
}
|
|
33
|
+
/** Open / close the surrounding `Lightbox` from custom triggers. */
|
|
34
|
+
export declare function useLightbox(): LightboxContextValue;
|
|
35
|
+
export interface LightboxProps {
|
|
36
|
+
items: MediaItem[];
|
|
37
|
+
open?: boolean;
|
|
38
|
+
defaultOpen?: boolean;
|
|
39
|
+
onOpenChange?: (open: boolean) => void;
|
|
40
|
+
index?: number;
|
|
41
|
+
defaultIndex?: number;
|
|
42
|
+
onIndexChange?: (index: number) => void;
|
|
43
|
+
/** Pinch / wheel / double-tap / +−0 zoom. Default `true` (max 3×). */
|
|
44
|
+
zoom?: boolean | {
|
|
45
|
+
max?: number;
|
|
46
|
+
};
|
|
47
|
+
/** Thumbnail strip at the bottom. Default `true` with more than one item. */
|
|
48
|
+
thumbnails?: boolean;
|
|
49
|
+
/** Download button (original file). */
|
|
50
|
+
download?: boolean;
|
|
51
|
+
/** File-details side panel toggle (admin). Uses `MediaAsset` fields. */
|
|
52
|
+
info?: boolean;
|
|
53
|
+
/** Wrap around at the ends. Default `true`. */
|
|
54
|
+
loop?: boolean;
|
|
55
|
+
/** `solid` (default) the scene at 96% · `dim` the overlay colour · `blur` overlay + blur. */
|
|
56
|
+
backdrop?: "solid" | "dim" | "blur";
|
|
57
|
+
/** `minimal` hides caption and thumbnails. */
|
|
58
|
+
chrome?: "minimal" | "full";
|
|
59
|
+
labels?: Partial<LightboxLabels>;
|
|
60
|
+
/** Triggers and the gallery that opens the viewer. */
|
|
61
|
+
children?: React.ReactNode;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Full-screen viewer for images and video: swipe / arrows to navigate, pinch / wheel / double-tap
|
|
65
|
+
* zoom with pan, thumbnails, captions and an optional file-details panel. Dialog pattern (focus
|
|
66
|
+
* trap, Esc, focus returns). Keys: ←/→ navigate, Home/End, + / − / 0 zoom.
|
|
67
|
+
*
|
|
68
|
+
* ```tsx
|
|
69
|
+
* <Lightbox items={photos} download>
|
|
70
|
+
* {photos.map((p, i) => <LightboxTrigger key={p.id} index={i}><Image src={p} alt={p.alt} aspect="1/1" /></LightboxTrigger>)}
|
|
71
|
+
* </Lightbox>
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function Lightbox({ items, open: openProp, defaultOpen, onOpenChange, index: indexProp, defaultIndex, onIndexChange, zoom, thumbnails, download, info, loop, backdrop, chrome, labels, children, }: LightboxProps): React.JSX.Element;
|
|
75
|
+
export interface LightboxTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
76
|
+
/** Item to open. */
|
|
77
|
+
index: number;
|
|
78
|
+
asChild?: boolean;
|
|
79
|
+
}
|
|
80
|
+
/** Opens the surrounding Lightbox at `index`. Renders a button (or the child with `asChild`). */
|
|
81
|
+
export declare const LightboxTrigger: React.ForwardRefExoticComponent<LightboxTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Dialog as DialogPrimitive, Slot } from "radix-ui";
|
|
5
|
+
import { Download, ImageOff, Info, X, ZoomIn, ZoomOut } from "lucide-react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { useLabels } from "../lib/labels.js";
|
|
8
|
+
import { useFormat, useLocale } from "../lib/locale.js";
|
|
9
|
+
import { Layer } from "../lib/layer.js";
|
|
10
|
+
import { usePortalContainer } from "../lib/theme-scope.js";
|
|
11
|
+
import { useControllableState } from "../lib/use-controllable-state.js";
|
|
12
|
+
import { IconButton } from "../components/button.js";
|
|
13
|
+
import { Spinner } from "../components/spinner.js";
|
|
14
|
+
import { Carousel, CarouselSlide, CarouselThumbs, CarouselViewport } from "../components/carousel.js";
|
|
15
|
+
import { isMediaAsset, toMediaSource } from "./media-provider.js";
|
|
16
|
+
import { usePanZoom } from "./use-pan-zoom.js";
|
|
17
|
+
import { VideoPlayer } from "./video-player.js";
|
|
18
|
+
const lightboxLabels = {
|
|
19
|
+
viewer: "Image viewer",
|
|
20
|
+
counter: "Image {index} of {total}",
|
|
21
|
+
counterCaption: "Image {index} of {total}: {caption}",
|
|
22
|
+
close: "Close viewer",
|
|
23
|
+
previous: "Previous image",
|
|
24
|
+
next: "Next image",
|
|
25
|
+
zoomIn: "Zoom in",
|
|
26
|
+
zoomOut: "Zoom out",
|
|
27
|
+
resetZoom: "Reset zoom",
|
|
28
|
+
download: "Download",
|
|
29
|
+
info: "File details",
|
|
30
|
+
error: "This image could not be loaded.",
|
|
31
|
+
filename: "File name",
|
|
32
|
+
dimensions: "Dimensions",
|
|
33
|
+
size: "Size",
|
|
34
|
+
type: "Type",
|
|
35
|
+
uploaded: "Uploaded",
|
|
36
|
+
uploadedBy: "Uploaded by",
|
|
37
|
+
alt: "Alt text",
|
|
38
|
+
noAlt: "Missing alt text",
|
|
39
|
+
decorative: "Decorative (no alt text)",
|
|
40
|
+
};
|
|
41
|
+
const LightboxContext = React.createContext(null);
|
|
42
|
+
/** Open / close the surrounding `Lightbox` from custom triggers. */
|
|
43
|
+
export function useLightbox() {
|
|
44
|
+
const ctx = React.useContext(LightboxContext);
|
|
45
|
+
if (!ctx)
|
|
46
|
+
throw new Error("useLightbox must be used inside <Lightbox>.");
|
|
47
|
+
return ctx;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Full-screen viewer for images and video: swipe / arrows to navigate, pinch / wheel / double-tap
|
|
51
|
+
* zoom with pan, thumbnails, captions and an optional file-details panel. Dialog pattern (focus
|
|
52
|
+
* trap, Esc, focus returns). Keys: ←/→ navigate, Home/End, + / − / 0 zoom.
|
|
53
|
+
*
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <Lightbox items={photos} download>
|
|
56
|
+
* {photos.map((p, i) => <LightboxTrigger key={p.id} index={i}><Image src={p} alt={p.alt} aspect="1/1" /></LightboxTrigger>)}
|
|
57
|
+
* </Lightbox>
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export function Lightbox({ items, open: openProp, defaultOpen = false, onOpenChange, index: indexProp, defaultIndex = 0, onIndexChange, zoom = true, thumbnails, download = false, info = false, loop = true, backdrop = "solid", chrome = "full", labels, children, }) {
|
|
61
|
+
const [open, setOpen] = useControllableState({ value: openProp, defaultValue: defaultOpen, onChange: onOpenChange, name: "Lightbox" });
|
|
62
|
+
const [index, setIndex] = useControllableState({ value: indexProp, defaultValue: defaultIndex, onChange: onIndexChange, name: "Lightbox" });
|
|
63
|
+
const returnFocus = React.useRef(null);
|
|
64
|
+
const ctx = React.useMemo(() => ({
|
|
65
|
+
open: (i) => {
|
|
66
|
+
returnFocus.current = typeof document !== "undefined" ? document.activeElement : null;
|
|
67
|
+
if (i !== undefined)
|
|
68
|
+
setIndex(i);
|
|
69
|
+
setOpen(true);
|
|
70
|
+
},
|
|
71
|
+
close: () => setOpen(false),
|
|
72
|
+
isOpen: open,
|
|
73
|
+
index,
|
|
74
|
+
}), [open, index, setIndex, setOpen]);
|
|
75
|
+
return (_jsxs(LightboxContext.Provider, { value: ctx, children: [children, _jsx(DialogPrimitive.Root, { open: open, onOpenChange: setOpen, children: _jsx(LightboxViewer, { items: items, index: Math.min(Math.max(0, index), Math.max(0, items.length - 1)), setIndex: setIndex, zoom: zoom, thumbnails: thumbnails ?? items.length > 1, download: download, info: info, loop: loop, backdrop: backdrop, chrome: chrome, labels: labels, returnFocus: returnFocus }) })] }));
|
|
76
|
+
}
|
|
77
|
+
/** Opens the surrounding Lightbox at `index`. Renders a button (or the child with `asChild`). */
|
|
78
|
+
export const LightboxTrigger = React.forwardRef(function LightboxTrigger({ index, asChild, onClick, className, type, ...props }, ref) {
|
|
79
|
+
const lb = useLightbox();
|
|
80
|
+
const Comp = asChild ? Slot.Root : "button";
|
|
81
|
+
return (_jsx(Comp, { ref: ref, type: asChild ? undefined : type ?? "button", "data-slot": "lightbox-trigger", "aria-haspopup": "dialog", className: cn(!asChild && "focus-ring block cursor-zoom-in rounded-[inherit]", className), onClick: (e) => {
|
|
82
|
+
onClick?.(e);
|
|
83
|
+
if (!e.defaultPrevented)
|
|
84
|
+
lb.open(index);
|
|
85
|
+
}, ...props }));
|
|
86
|
+
});
|
|
87
|
+
function LightboxViewer({ items, index, setIndex, zoom, thumbnails, download, info, loop, backdrop, chrome, labels, returnFocus }) {
|
|
88
|
+
const t = useLabels("lightbox", lightboxLabels, labels);
|
|
89
|
+
const { dir, locale } = useLocale();
|
|
90
|
+
const container = usePortalContainer();
|
|
91
|
+
const sources = React.useMemo(() => items.map((it, i) => toMediaSource(it, i)), [items]);
|
|
92
|
+
const current = sources[index];
|
|
93
|
+
const currentAsset = isMediaAsset(items[index]) ? items[index] : undefined;
|
|
94
|
+
const zoomMax = typeof zoom === "object" ? zoom.max ?? 3 : 3;
|
|
95
|
+
const canZoom = zoom !== false && current?.kind === "image";
|
|
96
|
+
const pz = usePanZoom({ max: zoomMax, disabled: !canZoom });
|
|
97
|
+
const [infoOpen, setInfoOpen] = React.useState(false);
|
|
98
|
+
const [loaded, setLoaded] = React.useState({});
|
|
99
|
+
const nf = React.useMemo(() => new Intl.NumberFormat(locale), [locale]);
|
|
100
|
+
const pct = React.useMemo(() => new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 0 }), [locale]);
|
|
101
|
+
const { reset } = pz;
|
|
102
|
+
React.useEffect(() => reset(), [index, reset]);
|
|
103
|
+
const go = (d) => {
|
|
104
|
+
const n = sources.length;
|
|
105
|
+
if (n < 2)
|
|
106
|
+
return;
|
|
107
|
+
const next = index + d;
|
|
108
|
+
setIndex(loop ? (next + n) % n : Math.min(n - 1, Math.max(0, next)));
|
|
109
|
+
};
|
|
110
|
+
const onKeyDown = (e) => {
|
|
111
|
+
if (e.defaultPrevented || e.metaKey || e.ctrlKey || e.altKey)
|
|
112
|
+
return;
|
|
113
|
+
const target = e.target;
|
|
114
|
+
if (target.closest("input, textarea, [role=slider], [data-slot=video-player]"))
|
|
115
|
+
return;
|
|
116
|
+
const back = dir === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
117
|
+
const fwd = dir === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
118
|
+
if (e.key === back)
|
|
119
|
+
go(-1);
|
|
120
|
+
else if (e.key === fwd)
|
|
121
|
+
go(1);
|
|
122
|
+
else if (e.key === "Home")
|
|
123
|
+
setIndex(0);
|
|
124
|
+
else if (e.key === "End")
|
|
125
|
+
setIndex(sources.length - 1);
|
|
126
|
+
else if (canZoom && (e.key === "+" || e.key === "="))
|
|
127
|
+
pz.zoomIn();
|
|
128
|
+
else if (canZoom && e.key === "-")
|
|
129
|
+
pz.zoomOut();
|
|
130
|
+
else if (canZoom && e.key === "0")
|
|
131
|
+
pz.reset();
|
|
132
|
+
else
|
|
133
|
+
return;
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
};
|
|
136
|
+
const counterText = current
|
|
137
|
+
? current.caption || current.alt
|
|
138
|
+
? t("counterCaption", { index: nf.format(index + 1), total: nf.format(sources.length), caption: current.caption || current.alt })
|
|
139
|
+
: t("counter", { index: nf.format(index + 1), total: nf.format(sources.length) })
|
|
140
|
+
: "";
|
|
141
|
+
const darkChrome = backdrop !== "solid";
|
|
142
|
+
const toolBtn = "text-fg-muted hover:text-fg";
|
|
143
|
+
return (_jsxs(DialogPrimitive.Portal, { container: container, children: [_jsx(DialogPrimitive.Overlay, { "data-slot": "lightbox-overlay", "data-backdrop": backdrop, "data-overlay-blurred": backdrop === "blur" ? "" : undefined, className: "vui-lightbox-overlay ui-fade fixed inset-0 z-(--z-overlay)" }), _jsx(Layer, { asChild: true, children: _jsxs(DialogPrimitive.Content, { "data-slot": "lightbox", "data-backdrop": backdrop, "aria-label": t("viewer"), "aria-describedby": undefined, onKeyDown: onKeyDown, onCloseAutoFocus: (e) => {
|
|
144
|
+
const el = returnFocus.current;
|
|
145
|
+
if (el && el.isConnected) {
|
|
146
|
+
e.preventDefault();
|
|
147
|
+
el.focus();
|
|
148
|
+
}
|
|
149
|
+
}, onOpenAutoFocus: (e) => {
|
|
150
|
+
const close = e.currentTarget?.querySelector("[data-autofocus]");
|
|
151
|
+
if (close) {
|
|
152
|
+
e.preventDefault();
|
|
153
|
+
close.focus();
|
|
154
|
+
}
|
|
155
|
+
}, className: cn("vui-lightbox ui-fade fixed inset-0 z-(--z-overlay) flex flex-col text-fg outline-none", darkChrome && "dark"), children: [_jsx(DialogPrimitive.Title, { className: "sr-only", children: t("viewer") }), _jsxs("div", { "data-slot": "lightbox-toolbar", className: "relative z-20 flex items-center gap-2 px-3 pt-3 sm:px-4", children: [_jsxs("p", { "aria-live": "polite", "aria-atomic": true, className: "tabular min-w-0 flex-1 truncate ps-1 text-[13px] text-fg-muted", children: [_jsx("span", { className: "sr-only", children: counterText }), _jsxs("span", { "aria-hidden": true, children: [_jsx("span", { className: "font-medium text-fg", children: nf.format(index + 1) }), _jsx("span", { className: "mx-1 text-fg-subtle", children: "/" }), nf.format(sources.length), currentAsset?.filename ? _jsx("span", { className: "ms-3 hidden text-fg-subtle sm:inline", children: currentAsset.filename }) : null] })] }), _jsxs("div", { className: "surface-popover flex items-center gap-0.5 rounded-full p-1", children: [canZoom ? (_jsxs(_Fragment, { children: [_jsx(IconButton, { label: t("zoomOut"), tooltip: false, size: "sm", className: cn("rounded-full!", toolBtn), disabled: !pz.canZoomOut, onClick: pz.zoomOut, children: _jsx(ZoomOut, {}) }), _jsx("button", { type: "button", onClick: pz.reset, "aria-label": t("resetZoom"), className: "focus-ring tabular h-8 min-w-12 rounded-full px-1.5 text-[12px] font-medium text-fg-muted hover:bg-hover hover:text-fg", children: pct.format(pz.scale) }), _jsx(IconButton, { label: t("zoomIn"), tooltip: false, size: "sm", className: cn("rounded-full!", toolBtn), disabled: !pz.canZoomIn, onClick: pz.zoomIn, children: _jsx(ZoomIn, {}) }), _jsx("span", { "aria-hidden": true, className: "mx-1 h-4 w-px bg-line" })] })) : null, download && current ? (_jsx(IconButton, { asChild: true, label: t("download"), tooltip: false, size: "sm", className: cn("rounded-full!", toolBtn), children: _jsx("a", { href: current.src, download: currentAsset?.filename ?? "", target: "_blank", rel: "noopener noreferrer", children: _jsx(Download, {}) }) })) : null, info ? (_jsx(IconButton, { label: t("info"), tooltip: false, size: "sm", "aria-pressed": infoOpen, className: cn("rounded-full!", toolBtn, infoOpen && "bg-selected text-fg"), onClick: () => setInfoOpen((o) => !o), children: _jsx(Info, {}) })) : null, _jsx(DialogPrimitive.Close, { asChild: true, children: _jsx(IconButton, { label: t("close"), tooltip: false, size: "sm", className: cn("rounded-full!", toolBtn), "data-autofocus": true, children: _jsx(X, {}) }) })] })] }), _jsxs("div", { className: "flex min-h-0 flex-1", children: [_jsxs(Carousel, { label: t("viewer"), index: index, onIndexChange: setIndex, loop: loop && sources.length > 1, gap: "none", controls: "inside", options: { watchDrag: !pz.zoomed && sources.length > 1 }, className: "flex min-h-0 min-w-0 flex-1 flex-col", labels: { previous: t("previous"), next: t("next") }, children: [_jsx(CarouselViewport, { className: "h-full", containerClassName: "h-full", arrows: sources.length > 1, children: sources.map((s, i) => (_jsx(CarouselSlide, { className: "h-full", children: s.kind === "video" ? (_jsx("div", { className: "flex h-full items-center justify-center p-4 sm:px-16 sm:py-8", children: _jsx("div", { className: "w-full", style: { maxWidth: `calc((100dvh - 12rem) * ${(s.width && s.height ? s.width / s.height : 16 / 9).toFixed(4)})` }, children: Math.abs(i - index) <= 1 ? (_jsx(VideoPlayer, { src: s.src, poster: s.poster, title: s.caption || s.alt, aspect: s.width && s.height ? s.width / s.height : "16/9" })) : null }) })) : (_jsxs("div", { "data-slot": "lightbox-stage", className: "relative flex h-full items-center justify-center overflow-hidden p-3 sm:px-16 sm:py-6", ...(i === index ? pz.bind : null), children: [s.placeholder && loaded[s.id] !== "loaded" ? (_jsx("img", { "aria-hidden": true, alt: "", src: s.placeholder, className: "vui-image-blur pointer-events-none absolute inset-6 m-auto max-h-[calc(100%-3rem)] max-w-[calc(100%-3rem)] object-contain" })) : null, loaded[s.id] === "error" ? (_jsxs("div", { role: "img", "aria-label": s.alt || t("error"), className: "flex flex-col items-center gap-2 text-sm text-fg-muted", children: [_jsx(ImageOff, { "aria-hidden": true, className: "size-7", strokeWidth: 1.5 }), t("error")] })) : Math.abs(i - index) <= 1 || (loop && Math.abs(i - index) === sources.length - 1) ? (_jsx("img", { src: s.src, alt: s.alt, width: s.width, height: s.height, draggable: false, decoding: "async", onLoad: () => setLoaded((m) => ({ ...m, [s.id]: "loaded" })), onError: () => setLoaded((m) => ({ ...m, [s.id]: "error" })), className: cn("vui-lightbox-img relative max-h-full max-w-full object-contain select-none", loaded[s.id] === "loaded" ? "opacity-100" : "opacity-0"), style: i === index && canZoom ? pz.style : undefined })) : null, !loaded[s.id] && i === index ? _jsx(Spinner, { size: "md", className: "absolute text-fg-muted" }) : null] })) }, s.id))) }), chrome === "full" ? (_jsxs("div", { className: "flex flex-none flex-col items-center gap-1 px-4 pb-3", children: [current?.caption ? (_jsx("p", { "data-slot": "lightbox-caption", className: "max-w-[68ch] text-center text-[13.5px] leading-relaxed text-pretty text-fg-muted", children: current.caption })) : null, thumbnails ? _jsx(CarouselThumbs, { aspect: 1, items: sources.map((s) => ({ src: s.kind === "video" ? s.poster ?? "" : s.src, alt: s.alt })), align: "center", className: "mt-1 w-full" }) : null] })) : null] }), info && infoOpen && currentAsset ? _jsx(LightboxInfo, { asset: currentAsset, labels: labels }) : null] })] }) })] }));
|
|
156
|
+
}
|
|
157
|
+
function LightboxInfo({ asset, labels }) {
|
|
158
|
+
const t = useLabels("lightbox", lightboxLabels, labels);
|
|
159
|
+
const f = useFormat();
|
|
160
|
+
const rows = [
|
|
161
|
+
[t("filename"), _jsx("span", { className: "break-all", children: asset.filename })],
|
|
162
|
+
[t("type"), asset.mime],
|
|
163
|
+
[t("size"), f.bytes(asset.size)],
|
|
164
|
+
];
|
|
165
|
+
if (asset.width && asset.height)
|
|
166
|
+
rows.push([t("dimensions"), `${f.number(asset.width)} × ${f.number(asset.height)}`]);
|
|
167
|
+
rows.push([t("uploaded"), f.date(asset.createdAt, "medium")]);
|
|
168
|
+
if (asset.uploadedBy)
|
|
169
|
+
rows.push([t("uploadedBy"), asset.uploadedBy.name]);
|
|
170
|
+
return (_jsxs("aside", { "data-slot": "lightbox-info", "aria-label": t("info"), className: "surface-popover m-3 ms-0 hidden w-80 flex-none flex-col gap-5 overflow-y-auto rounded-ui-lg p-5 md:flex", children: [_jsxs("div", { children: [_jsx("p", { className: "text-[11px] font-medium tracking-[0.08em] text-fg-subtle uppercase", children: t("alt") }), _jsx("p", { className: cn("mt-1.5 text-[13.5px] leading-relaxed", asset.alt ? "text-fg" : "text-warning"), children: asset.alt || (asset.alt === "" ? t("decorative") : t("noAlt")) })] }), asset.description ? _jsx("p", { className: "text-[13.5px] leading-relaxed text-fg-muted", children: asset.description }) : null, _jsx("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-2.5 border-t border-line pt-4 text-[13px]", children: rows.map(([k, v]) => (_jsxs(React.Fragment, { children: [_jsx("dt", { className: "text-fg-subtle", children: k }), _jsx("dd", { className: "tabular text-end text-fg", children: v })] }, k))) })] }));
|
|
171
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type SerpDevice, type SerpField } from "./serp.js";
|
|
3
|
+
import type { MediaAsset } from "./types.js";
|
|
4
|
+
declare const previewLabels: {
|
|
5
|
+
search: string;
|
|
6
|
+
social: string;
|
|
7
|
+
untitled: string;
|
|
8
|
+
noDescription: string;
|
|
9
|
+
noImage: string;
|
|
10
|
+
wrongRatio: string;
|
|
11
|
+
smallImage: string;
|
|
12
|
+
noindex: string;
|
|
13
|
+
tabs: string;
|
|
14
|
+
searchTab: string;
|
|
15
|
+
desktop: string;
|
|
16
|
+
mobile: string;
|
|
17
|
+
meterGood: string;
|
|
18
|
+
meterShort: string;
|
|
19
|
+
meterLong: string;
|
|
20
|
+
meterEmpty: string;
|
|
21
|
+
meterChars: string;
|
|
22
|
+
meterPx: string;
|
|
23
|
+
xFrom: string;
|
|
24
|
+
};
|
|
25
|
+
export type LinkPreviewLabels = typeof previewLabels;
|
|
26
|
+
export interface LinkPreviewData {
|
|
27
|
+
url: string;
|
|
28
|
+
title: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
siteName?: string;
|
|
31
|
+
favicon?: string;
|
|
32
|
+
image?: MediaAsset | string | null;
|
|
33
|
+
/** Date shown before the description (articles). `YYYY-MM-DD` or a Date. */
|
|
34
|
+
publishedAt?: Date | string;
|
|
35
|
+
/** Replaces the URL path in the search breadcrumb. */
|
|
36
|
+
breadcrumbs?: string[];
|
|
37
|
+
twitterCard?: "summary" | "summary_large_image";
|
|
38
|
+
/** Shows the "Hidden from search engines" banner. */
|
|
39
|
+
noindex?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export type SocialPlatform = "facebook" | "linkedin" | "x" | "whatsapp" | "slack";
|
|
42
|
+
export interface PreviewFrameProps {
|
|
43
|
+
/** `auto` follows the surrounding theme; `light` / `dark` force the platform's own theme. */
|
|
44
|
+
appearance?: "light" | "dark" | "auto";
|
|
45
|
+
/** `sm` for sidebars (SEO panel), `md` default. */
|
|
46
|
+
size?: "sm" | "md";
|
|
47
|
+
}
|
|
48
|
+
export interface SearchPreviewProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">, PreviewFrameProps {
|
|
49
|
+
data: LinkPreviewData;
|
|
50
|
+
device?: SerpDevice;
|
|
51
|
+
/** Focus keyword to bold in the description (as search engines do). */
|
|
52
|
+
highlight?: string;
|
|
53
|
+
labels?: Partial<LinkPreviewLabels>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* How a page appears in a search result on desktop or mobile, with pixel-accurate truncation
|
|
57
|
+
* (`measureSerp`) and keyword bolding.
|
|
58
|
+
*/
|
|
59
|
+
export declare const SearchPreview: React.ForwardRefExoticComponent<SearchPreviewProps & React.RefAttributes<HTMLDivElement>>;
|
|
60
|
+
export interface SocialCardPreviewProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title">, PreviewFrameProps {
|
|
61
|
+
data: LinkPreviewData;
|
|
62
|
+
platform: SocialPlatform;
|
|
63
|
+
/** Hide the warnings under the card. */
|
|
64
|
+
hideWarnings?: boolean;
|
|
65
|
+
labels?: Partial<LinkPreviewLabels>;
|
|
66
|
+
}
|
|
67
|
+
/** How a shared link unfurls on Facebook, LinkedIn, X, WhatsApp or Slack, with image warnings. */
|
|
68
|
+
export declare const SocialCardPreview: React.ForwardRefExoticComponent<SocialCardPreviewProps & React.RefAttributes<HTMLDivElement>>;
|
|
69
|
+
export interface LengthMeterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
70
|
+
value: string;
|
|
71
|
+
/** Character limit. Default: the SERP ideal maximum for `field`, else 160. */
|
|
72
|
+
max?: number;
|
|
73
|
+
/** Below this the meter says "too short". */
|
|
74
|
+
min?: number;
|
|
75
|
+
/** Also measure pixel width as a search result `title` / `description`. */
|
|
76
|
+
field?: SerpField;
|
|
77
|
+
device?: SerpDevice;
|
|
78
|
+
/** Field name for the announcement ("SEO title"). */
|
|
79
|
+
label?: string;
|
|
80
|
+
labels?: Partial<LinkPreviewLabels>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Characters (graphemes) and, for SEO fields, rendered pixels against the limit, said in words
|
|
84
|
+
* too ("58 of 60 characters, 540 of 600 px: good"), never by colour alone.
|
|
85
|
+
*/
|
|
86
|
+
export declare const LengthMeter: React.ForwardRefExoticComponent<LengthMeterProps & React.RefAttributes<HTMLDivElement>>;
|
|
87
|
+
export interface LinkPreviewTabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title" | "defaultValue" | "onChange">, PreviewFrameProps {
|
|
88
|
+
data: LinkPreviewData;
|
|
89
|
+
/** Which previews to offer. Default search, Facebook, X, WhatsApp. */
|
|
90
|
+
platforms?: ("search" | SocialPlatform)[];
|
|
91
|
+
defaultValue?: "search" | SocialPlatform;
|
|
92
|
+
highlight?: string;
|
|
93
|
+
labels?: Partial<LinkPreviewLabels>;
|
|
94
|
+
}
|
|
95
|
+
/** Search | Facebook | X | WhatsApp previews of one link in tabs; search has a desktop / mobile switch. */
|
|
96
|
+
export declare function LinkPreviewTabs({ data, platforms, defaultValue, highlight: term, appearance, size, labels, className, ...props }: LinkPreviewTabsProps): React.JSX.Element;
|
|
97
|
+
export {};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
// Link previews imitate third-party UIs (search results, social cards). This file and the
|
|
4
|
+
// `--preview-*` variables in styles/media.css are the kit's one deliberate token exception:
|
|
5
|
+
// the previews follow each platform's look, the frame and meters around them use kit tokens.
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { ImageIcon, TriangleAlert, EyeOff } from "lucide-react";
|
|
8
|
+
import { cn } from "../lib/cn.js";
|
|
9
|
+
import { useLabels } from "../lib/labels.js";
|
|
10
|
+
import { useLocale } from "../lib/locale.js";
|
|
11
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../components/tabs.js";
|
|
12
|
+
import { isMediaAsset } from "./media-provider.js";
|
|
13
|
+
import { countGraphemes, measureSerp, SERP_LIMITS } from "./serp.js";
|
|
14
|
+
const previewLabels = {
|
|
15
|
+
search: "Search result preview",
|
|
16
|
+
social: "{platform} link preview",
|
|
17
|
+
untitled: "Untitled page",
|
|
18
|
+
noDescription: "No description: search engines will pick text from the page.",
|
|
19
|
+
noImage: "No social image. The link will show as a plain card.",
|
|
20
|
+
wrongRatio: "Image is {ratio}:1. {platform} shows {target}:1 and will crop it.",
|
|
21
|
+
smallImage: "Image is {width}×{height}. {platform} recommends at least {minWidth}×{minHeight}.",
|
|
22
|
+
noindex: "Hidden from search engines (noindex)",
|
|
23
|
+
tabs: "Preview",
|
|
24
|
+
searchTab: "Search",
|
|
25
|
+
desktop: "Desktop",
|
|
26
|
+
mobile: "Mobile",
|
|
27
|
+
meterGood: "good",
|
|
28
|
+
meterShort: "too short",
|
|
29
|
+
meterLong: "too long",
|
|
30
|
+
meterEmpty: "missing",
|
|
31
|
+
meterChars: "{count} of {max} characters",
|
|
32
|
+
meterPx: "{px} of {maxPx} px",
|
|
33
|
+
xFrom: "From {host}",
|
|
34
|
+
};
|
|
35
|
+
const PLATFORM_NAME = { facebook: "Facebook", linkedin: "LinkedIn", x: "X", whatsapp: "WhatsApp", slack: "Slack" };
|
|
36
|
+
function parseUrl(url) {
|
|
37
|
+
try {
|
|
38
|
+
const u = new URL(url);
|
|
39
|
+
return { host: u.hostname.replace(/^www\./, ""), path: u.pathname.split("/").filter(Boolean).map(decodeURIComponent) };
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return { host: url.replace(/^https?:\/\//, "").split("/")[0] ?? url, path: [] };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function imageOf(image) {
|
|
46
|
+
if (!image)
|
|
47
|
+
return null;
|
|
48
|
+
if (typeof image === "string")
|
|
49
|
+
return { src: image, alt: "" };
|
|
50
|
+
if (isMediaAsset(image))
|
|
51
|
+
return { src: image.variants?.og?.url ?? image.url, width: image.variants?.og?.width ?? image.width, height: image.variants?.og?.height ?? image.height, alt: image.alt };
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function toDate(d) {
|
|
55
|
+
if (d instanceof Date)
|
|
56
|
+
return d;
|
|
57
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(d);
|
|
58
|
+
return m ? new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])) : new Date(d);
|
|
59
|
+
}
|
|
60
|
+
/** `false` on the server and the first client render, then `true`: canvas measuring runs after hydration. */
|
|
61
|
+
function usePrecise() {
|
|
62
|
+
const [precise, setPrecise] = React.useState(false);
|
|
63
|
+
React.useEffect(() => setPrecise(true), []);
|
|
64
|
+
return precise;
|
|
65
|
+
}
|
|
66
|
+
/** Bolds case-insensitive matches of `term` (locale-aware). */
|
|
67
|
+
function highlight(text, term, locale) {
|
|
68
|
+
if (!term?.trim())
|
|
69
|
+
return text;
|
|
70
|
+
const hay = text.toLocaleLowerCase(locale);
|
|
71
|
+
const needle = term.trim().toLocaleLowerCase(locale);
|
|
72
|
+
const out = [];
|
|
73
|
+
let i = 0;
|
|
74
|
+
let k = 0;
|
|
75
|
+
while (needle && (k = hay.indexOf(needle, i)) !== -1) {
|
|
76
|
+
if (k > i)
|
|
77
|
+
out.push(text.slice(i, k));
|
|
78
|
+
out.push(_jsx("b", { children: text.slice(k, k + needle.length) }, k));
|
|
79
|
+
i = k + needle.length;
|
|
80
|
+
}
|
|
81
|
+
out.push(text.slice(i));
|
|
82
|
+
return out;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* How a page appears in a search result on desktop or mobile, with pixel-accurate truncation
|
|
86
|
+
* (`measureSerp`) and keyword bolding.
|
|
87
|
+
*/
|
|
88
|
+
export const SearchPreview = React.forwardRef(function SearchPreview({ data, device = "desktop", highlight: term, appearance = "auto", size = "md", labels, className, ...props }, ref) {
|
|
89
|
+
const t = useLabels("linkPreview", previewLabels, labels);
|
|
90
|
+
const { locale } = useLocale();
|
|
91
|
+
const { host, path } = parseUrl(data.url);
|
|
92
|
+
const crumbs = data.breadcrumbs ?? path.slice(0, 3);
|
|
93
|
+
const estimate = !usePrecise();
|
|
94
|
+
const title = measureSerp(data.title || t("untitled"), "title", device, locale, { estimate });
|
|
95
|
+
const desc = data.description ? measureSerp(data.description, "description", device, locale, { estimate }) : null;
|
|
96
|
+
const date = data.publishedAt ? new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(toDate(data.publishedAt)) : null;
|
|
97
|
+
const site = data.siteName ?? host;
|
|
98
|
+
return (_jsxs("div", { ref: ref, "data-slot": "search-preview", className: cn("vui-lp-frame", className), ...props, children: [data.noindex ? (_jsxs("p", { className: "mb-2 flex items-center gap-1.5 text-[12.5px] font-medium text-warning", children: [_jsx(EyeOff, { "aria-hidden": true, className: "size-3.5" }), t("noindex")] })) : null, _jsxs("div", { role: "figure", "aria-label": t("search"), "data-appearance": appearance, "data-device": device, "data-size": size, dir: "auto", className: cn("vui-lp vui-lp-serp", data.noindex && "opacity-55"), children: [_jsxs("div", { className: "vui-lp-serp-site", children: [_jsx("span", { className: "vui-lp-favicon", "aria-hidden": true, children: data.favicon ? _jsx("img", { src: data.favicon, alt: "" }) : _jsx("span", { children: site.charAt(0).toUpperCase() }) }), _jsxs("span", { className: "min-w-0", children: [_jsx("span", { className: "vui-lp-serp-sitename", children: site }), _jsxs("span", { className: "vui-lp-serp-url", children: [data.url.startsWith("http") ? `https://${host}` : host, crumbs.map((c, i) => (_jsxs(React.Fragment, { children: [_jsx("span", { "aria-hidden": true, children: " \u203A " }), c] }, i)))] })] })] }), _jsx("p", { className: "vui-lp-serp-title", "data-missing": data.title ? undefined : "", "data-truncated": title.truncated ? "" : undefined, children: title.display }), _jsxs("p", { className: "vui-lp-serp-desc", "data-missing": desc ? undefined : "", children: [date ? _jsxs("span", { className: "vui-lp-serp-date", children: [date, " \u2014 "] }) : null, desc ? highlight(desc.display, term, locale) : t("noDescription")] })] })] }));
|
|
99
|
+
});
|
|
100
|
+
/* ------------------------------------------------------------------ */
|
|
101
|
+
/* Social card */
|
|
102
|
+
/* ------------------------------------------------------------------ */
|
|
103
|
+
const TARGET_RATIO = { facebook: 1.91, linkedin: 1.91, x: 1.91, whatsapp: 1.91, slack: 1.91 };
|
|
104
|
+
const MIN_SIZE = { width: 1200, height: 630 };
|
|
105
|
+
/** How a shared link unfurls on Facebook, LinkedIn, X, WhatsApp or Slack, with image warnings. */
|
|
106
|
+
export const SocialCardPreview = React.forwardRef(function SocialCardPreview({ data, platform, appearance = "auto", size = "md", hideWarnings, labels, className, ...props }, ref) {
|
|
107
|
+
const t = useLabels("linkPreview", previewLabels, labels);
|
|
108
|
+
const { locale } = useLocale();
|
|
109
|
+
const { host } = parseUrl(data.url);
|
|
110
|
+
const img = imageOf(data.image);
|
|
111
|
+
const name = PLATFORM_NAME[platform];
|
|
112
|
+
const nf = new Intl.NumberFormat(locale, { maximumFractionDigits: 2 });
|
|
113
|
+
const large = platform !== "x" || data.twitterCard !== "summary";
|
|
114
|
+
const title = data.title || t("untitled");
|
|
115
|
+
const warnings = [];
|
|
116
|
+
if (!img)
|
|
117
|
+
warnings.push(t("noImage"));
|
|
118
|
+
else if (img.width && img.height) {
|
|
119
|
+
const r = img.width / img.height;
|
|
120
|
+
if (large && Math.abs(r - TARGET_RATIO[platform]) > 0.12)
|
|
121
|
+
warnings.push(t("wrongRatio", { ratio: nf.format(Math.round(r * 100) / 100), platform: name, target: nf.format(TARGET_RATIO[platform]) }));
|
|
122
|
+
if (large && (img.width < MIN_SIZE.width || img.height < MIN_SIZE.height))
|
|
123
|
+
warnings.push(t("smallImage", { width: String(img.width), height: String(img.height), platform: name, minWidth: String(MIN_SIZE.width), minHeight: String(MIN_SIZE.height) }));
|
|
124
|
+
}
|
|
125
|
+
const media = (cls) => img ? (_jsx("span", { className: cn("vui-lp-media", cls), children: _jsx("img", { src: img.src, alt: "", loading: "lazy", decoding: "async" }) })) : (_jsx("span", { className: cn("vui-lp-media vui-lp-media-empty", cls), "aria-hidden": true, children: _jsx(ImageIcon, { strokeWidth: 1.4 }) }));
|
|
126
|
+
const titleEl = (_jsx("span", { className: "vui-lp-title", "data-missing": data.title ? undefined : "", children: title }));
|
|
127
|
+
const descEl = data.description ? _jsx("span", { className: "vui-lp-desc", children: data.description }) : null;
|
|
128
|
+
let card;
|
|
129
|
+
switch (platform) {
|
|
130
|
+
case "facebook":
|
|
131
|
+
card = (_jsxs(_Fragment, { children: [media(), _jsxs("span", { className: "vui-lp-body", children: [_jsx("span", { className: "vui-lp-domain", children: host.toUpperCase() }), titleEl, descEl] })] }));
|
|
132
|
+
break;
|
|
133
|
+
case "linkedin":
|
|
134
|
+
card = (_jsxs(_Fragment, { children: [media(), _jsxs("span", { className: "vui-lp-body", children: [titleEl, _jsx("span", { className: "vui-lp-domain", children: host })] })] }));
|
|
135
|
+
break;
|
|
136
|
+
case "x":
|
|
137
|
+
card = large ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "relative block", children: [media(), _jsx("span", { className: "vui-lp-x-badge", children: host })] }), _jsx("span", { className: "vui-lp-x-below", children: t("xFrom", { host }) })] })) : (_jsxs("span", { className: "vui-lp-x-summary", children: [media("vui-lp-x-thumb"), _jsxs("span", { className: "vui-lp-body", children: [_jsx("span", { className: "vui-lp-domain", children: host }), titleEl, descEl] })] }));
|
|
138
|
+
break;
|
|
139
|
+
case "whatsapp":
|
|
140
|
+
card = (_jsxs("span", { className: "vui-lp-wa-bubble", children: [_jsxs("span", { className: "vui-lp-wa-card", children: [media(), _jsxs("span", { className: "vui-lp-body", children: [titleEl, descEl, _jsx("span", { className: "vui-lp-domain", children: host })] })] }), _jsx("span", { className: "vui-lp-wa-link", children: data.url })] }));
|
|
141
|
+
break;
|
|
142
|
+
case "slack":
|
|
143
|
+
card = (_jsxs("span", { className: "vui-lp-slack", children: [_jsxs("span", { className: "vui-lp-slack-site", children: [data.favicon ? _jsx("img", { src: data.favicon, alt: "", className: "vui-lp-slack-icon" }) : null, data.siteName ?? host] }), titleEl, descEl, media("vui-lp-slack-media")] }));
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
return (_jsxs("div", { ref: ref, "data-slot": "social-card-preview", className: cn("vui-lp-frame", className), ...props, children: [_jsx("div", { role: "figure", "aria-label": t("social", { platform: name }), "data-appearance": appearance, "data-platform": platform, "data-size": size, dir: "auto", className: "vui-lp vui-lp-social", children: card }), !hideWarnings && warnings.length ? (_jsx("ul", { className: "mt-2.5 flex flex-col gap-1", children: warnings.map((w) => (_jsxs("li", { className: "flex items-start gap-1.5 text-[12.5px] leading-snug text-warning", children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "mt-px size-3.5 shrink-0" }), w] }, w))) })) : null] }));
|
|
147
|
+
});
|
|
148
|
+
/**
|
|
149
|
+
* Characters (graphemes) and, for SEO fields, rendered pixels against the limit, said in words
|
|
150
|
+
* too ("58 of 60 characters, 540 of 600 px: good"), never by colour alone.
|
|
151
|
+
*/
|
|
152
|
+
export const LengthMeter = React.forwardRef(function LengthMeter({ value, max: maxProp, min: minProp, field, device = "desktop", label, labels, className, ...props }, ref) {
|
|
153
|
+
const t = useLabels("linkPreview", previewLabels, labels);
|
|
154
|
+
const { locale } = useLocale();
|
|
155
|
+
const nf = new Intl.NumberFormat(locale);
|
|
156
|
+
const spec = field ? SERP_LIMITS[device][field] : null;
|
|
157
|
+
const max = maxProp ?? spec?.idealChars[1] ?? 160;
|
|
158
|
+
const min = minProp ?? spec?.idealChars[0] ?? 0;
|
|
159
|
+
const count = countGraphemes(value, locale);
|
|
160
|
+
const estimate = !usePrecise();
|
|
161
|
+
const m = field ? measureSerp(value, field, device, locale, { estimate }) : null;
|
|
162
|
+
const over = count > max || Boolean(m?.truncated);
|
|
163
|
+
const status = count === 0 ? "empty" : over ? "long" : count < min ? "short" : "good";
|
|
164
|
+
const tone = status === "good" ? "success" : status === "long" || status === "empty" ? "danger" : "warning";
|
|
165
|
+
const ratio = m ? m.px / m.maxPx : count / max;
|
|
166
|
+
const statusText = t(status === "good" ? "meterGood" : status === "short" ? "meterShort" : status === "long" ? "meterLong" : "meterEmpty");
|
|
167
|
+
const chars = t("meterChars", { count: nf.format(count), max: nf.format(max) });
|
|
168
|
+
const px = m ? t("meterPx", { px: nf.format(Math.round(m.px)), maxPx: nf.format(m.maxPx) }) : null;
|
|
169
|
+
const text = `${chars}${px ? `, ${px}` : ""}: ${statusText}`;
|
|
170
|
+
return (_jsxs("div", { ref: ref, "data-slot": "length-meter", "data-status": status, className: cn("flex items-center gap-2.5", className), ...props, children: [_jsx("div", { role: "meter", "aria-label": label, "aria-valuemin": 0, "aria-valuemax": m ? m.maxPx : max, "aria-valuenow": m ? Math.round(m.px) : count, "aria-valuetext": text, className: "relative h-1 min-w-12 flex-1 overflow-hidden rounded-full bg-track", children: _jsx("span", { className: cn("absolute inset-y-0 start-0 rounded-full transition-[width] duration-200", `tone-${tone}`), style: { width: `${Math.min(100, ratio * 100)}%`, background: "var(--tone)" } }) }), _jsxs("span", { "aria-hidden": true, className: "tabular shrink-0 text-[12px] text-fg-muted", children: [_jsx("span", { className: cn(`tone-${tone}`, "text-(--tone)"), children: nf.format(count) }), _jsxs("span", { className: "text-fg-subtle", children: [" / ", nf.format(max)] }), px ? _jsxs("span", { className: "ms-2 text-fg-subtle", children: [nf.format(Math.round(m.px)), " px"] }) : null] })] }));
|
|
171
|
+
});
|
|
172
|
+
/** Search | Facebook | X | WhatsApp previews of one link in tabs; search has a desktop / mobile switch. */
|
|
173
|
+
export function LinkPreviewTabs({ data, platforms = ["search", "facebook", "x", "whatsapp"], defaultValue, highlight: term, appearance, size, labels, className, ...props }) {
|
|
174
|
+
const t = useLabels("linkPreview", previewLabels, labels);
|
|
175
|
+
const [device, setDevice] = React.useState("desktop");
|
|
176
|
+
return (_jsx("div", { "data-slot": "link-preview-tabs", className: className, ...props, children: _jsxs(Tabs, { defaultValue: defaultValue ?? platforms[0], children: [_jsx(TabsList, { "aria-label": t("tabs"), children: platforms.map((p) => (_jsx(TabsTrigger, { value: p, children: p === "search" ? t("searchTab") : PLATFORM_NAME[p] }, p))) }), platforms.map((p) => (_jsx(TabsContent, { value: p, children: p === "search" ? (_jsxs("div", { className: "flex flex-col gap-3", children: [_jsx("div", { role: "group", "aria-label": t("search"), className: "inline-flex self-start rounded-ui-sm bg-surface-2 p-0.5 text-[12.5px]", children: ["desktop", "mobile"].map((d) => (_jsx("button", { type: "button", "aria-pressed": device === d, onClick: () => setDevice(d), className: cn("focus-ring rounded-[calc(var(--radius)-6px)] px-2.5 py-1 font-medium text-fg-muted transition-colors", device === d && "bg-surface text-fg shadow-sm"), children: t(d) }, d))) }), _jsx(SearchPreview, { data: data, device: device, highlight: term, appearance: appearance, size: size, labels: labels })] })) : (_jsx(SocialCardPreview, { data: data, platform: p, appearance: appearance, size: size, labels: labels })) }, p)))] }) }));
|
|
177
|
+
}
|