@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,170 @@
|
|
|
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 Cropper from "react-easy-crop";
|
|
5
|
+
import { FlipHorizontal2, FlipVertical2, RotateCcw, RotateCcwSquare, RotateCwSquare, ZoomIn, ZoomOut } from "lucide-react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { useLabels } from "../lib/labels.js";
|
|
8
|
+
import { useLocale } from "../lib/locale.js";
|
|
9
|
+
import { useControllableState } from "../lib/use-controllable-state.js";
|
|
10
|
+
import { IconButton } from "../components/button.js";
|
|
11
|
+
import { Slider } from "../components/slider.js";
|
|
12
|
+
import { isMediaAsset } from "./media-provider.js";
|
|
13
|
+
const cropperLabels = {
|
|
14
|
+
cropper: "Crop area",
|
|
15
|
+
toolbar: "Crop tools",
|
|
16
|
+
instructions: "Drag or use the arrow keys to move the image. Scroll, pinch or use the slider to zoom.",
|
|
17
|
+
aspect: "Aspect ratio",
|
|
18
|
+
zoom: "Zoom",
|
|
19
|
+
zoomIn: "Zoom in",
|
|
20
|
+
zoomOut: "Zoom out",
|
|
21
|
+
rotateLeft: "Rotate left",
|
|
22
|
+
rotateRight: "Rotate right",
|
|
23
|
+
flipH: "Flip horizontally",
|
|
24
|
+
flipV: "Flip vertically",
|
|
25
|
+
reset: "Reset crop",
|
|
26
|
+
original: "Original",
|
|
27
|
+
square: "Square",
|
|
28
|
+
social: "Social",
|
|
29
|
+
landscape: "Landscape",
|
|
30
|
+
classic: "Classic",
|
|
31
|
+
portrait: "Portrait",
|
|
32
|
+
story: "Story",
|
|
33
|
+
avatar: "Avatar",
|
|
34
|
+
summary: "{width} × {height} px",
|
|
35
|
+
};
|
|
36
|
+
const RATIO_NAMES = [
|
|
37
|
+
[1, "1:1"],
|
|
38
|
+
[16 / 9, "16:9"],
|
|
39
|
+
[9 / 16, "9:16"],
|
|
40
|
+
[4 / 3, "4:3"],
|
|
41
|
+
[3 / 4, "3:4"],
|
|
42
|
+
[3 / 2, "3:2"],
|
|
43
|
+
[2 / 3, "2:3"],
|
|
44
|
+
[4 / 5, "4:5"],
|
|
45
|
+
[21 / 9, "21:9"],
|
|
46
|
+
];
|
|
47
|
+
/** `1.91` → "1.91:1" (locale decimal: "1,91:1"), `16/9` → "16:9". */
|
|
48
|
+
export function formatAspectRatio(value, locale = "en-US") {
|
|
49
|
+
const known = RATIO_NAMES.find(([v]) => Math.abs(v - value) < 0.005);
|
|
50
|
+
if (known)
|
|
51
|
+
return known[1];
|
|
52
|
+
return `${new Intl.NumberFormat(locale, { maximumFractionDigits: 2 }).format(value)}:1`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Crops an image to a ratio with drag, pinch, wheel and keyboard (arrows move, the slider zooms),
|
|
56
|
+
* plus a toolbar: ratio presets, zoom, rotate ±90°, flip, reset. It outputs a **non-destructive**
|
|
57
|
+
* `CropRect` in source pixels — store it in `asset.crops` and let the loader apply it, or bake a
|
|
58
|
+
* copy with `getCroppedBlob()`.
|
|
59
|
+
*
|
|
60
|
+
* ```tsx
|
|
61
|
+
* <ImageCropper src={asset} defaultAspect={1.91} onChange={(rect) => adapter.update(asset.id, { crops: { ...asset.crops, og: rect } })} />
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export const ImageCropper = React.forwardRef(function ImageCropper({ src, value, defaultValue, onChange, aspect: aspectProp, defaultAspect, onAspectChange, presets: presetsProp, shape = "rect", grid = true, minZoom = 1, maxZoom = 4, toolbar = true, transform = true, height = "22rem", labels, className, ...props }, ref) {
|
|
65
|
+
const t = useLabels("imageCropper", cropperLabels, labels);
|
|
66
|
+
const { locale } = useLocale();
|
|
67
|
+
const url = isMediaAsset(src) ? src.url : src;
|
|
68
|
+
const alt = isMediaAsset(src) ? src.alt : "";
|
|
69
|
+
const initial = value ?? defaultValue ?? null;
|
|
70
|
+
const presets = React.useMemo(() => presetsProp ??
|
|
71
|
+
(shape === "round"
|
|
72
|
+
? [{ label: t("avatar"), value: 1 }]
|
|
73
|
+
: [
|
|
74
|
+
{ label: t("original"), value: "original" },
|
|
75
|
+
{ label: t("square"), value: 1, name: "square" },
|
|
76
|
+
{ label: t("social"), value: 1.91, name: "og" },
|
|
77
|
+
{ label: t("landscape"), value: 16 / 9 },
|
|
78
|
+
{ label: t("classic"), value: 4 / 3 },
|
|
79
|
+
{ label: t("portrait"), value: 4 / 5 },
|
|
80
|
+
]), [presetsProp, shape, t]);
|
|
81
|
+
const [aspectChoice, setAspectChoice] = useControllableState({
|
|
82
|
+
value: aspectProp,
|
|
83
|
+
defaultValue: defaultAspect ?? (initial ? initial.width / initial.height : presets[0]?.value ?? 1),
|
|
84
|
+
onChange: onAspectChange,
|
|
85
|
+
name: "ImageCropper",
|
|
86
|
+
});
|
|
87
|
+
const [natural, setNatural] = React.useState(isMediaAsset(src) && src.width && src.height ? { width: src.width, height: src.height } : null);
|
|
88
|
+
const [crop, setCrop] = React.useState({ x: 0, y: 0 });
|
|
89
|
+
const [zoom, setZoom] = React.useState(1);
|
|
90
|
+
const [rotation, setRotation] = React.useState(initial?.rotation ?? 0);
|
|
91
|
+
const [flip, setFlip] = React.useState(initial?.flip ?? { h: false, v: false });
|
|
92
|
+
const [area, setArea] = React.useState(initial);
|
|
93
|
+
const [resetKey, setResetKey] = React.useState(0);
|
|
94
|
+
const rotatedNatural = natural ? (Math.abs(rotation % 180) === 90 ? { width: natural.height, height: natural.width } : natural) : null;
|
|
95
|
+
const rawAspect = aspectChoice === "original" ? (rotatedNatural ? rotatedNatural.width / rotatedNatural.height : 4 / 3) : aspectChoice;
|
|
96
|
+
const aspect = Number.isFinite(rawAspect) && rawAspect > 0 ? rawAspect : 4 / 3;
|
|
97
|
+
const activePreset = presets.find((p) => (p.value === "original" ? aspectChoice === "original" : typeof aspectChoice === "number" && Math.abs(p.value - aspectChoice) < 0.005));
|
|
98
|
+
const latest = React.useRef({ rotation, flip, activePreset, onChange });
|
|
99
|
+
latest.current = { rotation, flip, activePreset, onChange };
|
|
100
|
+
const emit = React.useCallback((px) => {
|
|
101
|
+
const { rotation: r, flip: f, activePreset: p, onChange: cb } = latest.current;
|
|
102
|
+
const rect = { x: Math.round(px.x), y: Math.round(px.y), width: Math.round(px.width), height: Math.round(px.height), ...(r ? { rotation: r } : null), ...(f.h || f.v ? { flip: f } : null) };
|
|
103
|
+
setArea(rect);
|
|
104
|
+
cb?.(rect, p);
|
|
105
|
+
}, []);
|
|
106
|
+
const reset = () => {
|
|
107
|
+
setCrop({ x: 0, y: 0 });
|
|
108
|
+
setZoom(1);
|
|
109
|
+
setRotation(0);
|
|
110
|
+
setFlip({ h: false, v: false });
|
|
111
|
+
setResetKey((k) => k + 1);
|
|
112
|
+
};
|
|
113
|
+
const rotate = (d) => setRotation((r) => (((r + d) % 360) + 360) % 360);
|
|
114
|
+
const tool = "text-fg-muted hover:text-fg";
|
|
115
|
+
const nf = React.useMemo(() => new Intl.NumberFormat(locale), [locale]);
|
|
116
|
+
const instructionsId = React.useId();
|
|
117
|
+
return (_jsxs("div", { ref: ref, "data-slot": "image-cropper", "data-shape": shape, className: cn("vui-cropper flex flex-col gap-3", className), ...props, children: [_jsxs("div", { "data-slot": "image-cropper-stage", className: "vui-cropper-stage relative overflow-hidden rounded-ui bg-scene", style: { height }, children: [_jsx(Cropper, { image: url, crop: crop, zoom: zoom, rotation: rotation, aspect: aspect, minZoom: minZoom, maxZoom: maxZoom, cropShape: shape, showGrid: grid, zoomSpeed: 0.5, keyboardStep: 8, restrictPosition: true, objectFit: "contain", transform: `translate(${crop.x}px, ${crop.y}px) rotate(${rotation}deg) scale(${zoom * (flip.h ? -1 : 1)}, ${zoom * (flip.v ? -1 : 1)})`, initialCroppedAreaPixels: resetKey === 0 && initial ? { x: initial.x, y: initial.y, width: initial.width, height: initial.height } : undefined, onCropChange: setCrop, onZoomChange: setZoom, onRotationChange: setRotation, onCropComplete: (_, px) => emit(px), onMediaLoaded: (m) => {
|
|
118
|
+
if (m.naturalWidth > 0 && m.naturalHeight > 0)
|
|
119
|
+
setNatural({ width: m.naturalWidth, height: m.naturalHeight });
|
|
120
|
+
}, mediaProps: { alt }, cropperProps: { "aria-label": t("cropper"), "aria-describedby": instructionsId, role: "application" }, classes: { containerClassName: "vui-cropper-container", cropAreaClassName: "vui-cropper-area focus-ring", mediaClassName: "vui-cropper-media" } }, resetKey), _jsx("p", { id: instructionsId, className: "sr-only", children: t("instructions") }), area ? (_jsx("span", { "aria-live": "polite", className: "tabular surface-popover pointer-events-none absolute start-3 bottom-3 rounded-full px-2.5 py-1 text-[11.5px] text-fg-muted", children: t("summary", { width: nf.format(area.width), height: nf.format(area.height) }) })) : null] }), toolbar ? (_jsxs("div", { "data-slot": "image-cropper-toolbar", role: "toolbar", "aria-label": t("toolbar"), className: "flex flex-wrap items-center gap-x-4 gap-y-2.5", children: [presets.length > 1 ? (_jsx("div", { role: "group", "aria-label": t("aspect"), className: "flex flex-wrap items-center gap-1 rounded-ui bg-surface-2 p-1", children: presets.map((p) => {
|
|
121
|
+
const ratio = p.value === "original" ? null : formatAspectRatio(p.value, locale);
|
|
122
|
+
const selected = activePreset === p;
|
|
123
|
+
return (_jsxs("button", { type: "button", "aria-pressed": selected, "data-slot": "image-cropper-preset", onClick: () => setAspectChoice(p.value), className: cn("focus-ring inline-flex h-7 items-center gap-1.5 rounded-ui-sm px-2.5 text-[12.5px] font-medium whitespace-nowrap text-fg-muted transition-colors hover:text-fg", selected && "bg-surface text-fg shadow-sm ring-1 ring-line"), children: [_jsx(PresetGlyph, { ratio: p.value === "original" ? aspect : p.value, round: shape === "round" }), p.label, ratio ? _jsx("span", { className: "tabular font-normal text-fg-subtle", children: ratio }) : null] }, p.label + String(p.value)));
|
|
124
|
+
}) })) : null, _jsxs("div", { className: "flex min-w-48 flex-1 items-center gap-1.5", children: [_jsx(IconButton, { label: t("zoomOut"), tooltip: false, size: "sm", className: tool, disabled: zoom <= minZoom, onClick: () => setZoom((z) => Math.max(minZoom, z - 0.25)), children: _jsx(ZoomOut, {}) }), _jsx(Slider, { "aria-label": t("zoom"), size: "sm", min: minZoom, max: maxZoom, step: 0.01, value: [zoom], onValueChange: ([z]) => z !== undefined && setZoom(z), formatValue: (z) => `${nf.format(Math.round(z * 100))}%`, showValue: "never", className: "flex-1" }), _jsx(IconButton, { label: t("zoomIn"), tooltip: false, size: "sm", className: tool, disabled: zoom >= maxZoom, onClick: () => setZoom((z) => Math.min(maxZoom, z + 0.25)), children: _jsx(ZoomIn, {}) })] }), _jsxs("div", { className: "ms-auto flex items-center gap-0.5", children: [transform ? (_jsxs(_Fragment, { children: [_jsx(IconButton, { label: t("rotateLeft"), tooltip: false, size: "sm", className: tool, onClick: () => rotate(-90), children: _jsx(RotateCcwSquare, {}) }), _jsx(IconButton, { label: t("rotateRight"), tooltip: false, size: "sm", className: tool, onClick: () => rotate(90), children: _jsx(RotateCwSquare, {}) }), _jsx(IconButton, { label: t("flipH"), tooltip: false, size: "sm", "aria-pressed": flip.h, className: cn(tool, flip.h && "bg-selected text-fg"), onClick: () => setFlip((f) => ({ ...f, h: !f.h })), children: _jsx(FlipHorizontal2, {}) }), _jsx(IconButton, { label: t("flipV"), tooltip: false, size: "sm", "aria-pressed": flip.v, className: cn(tool, flip.v && "bg-selected text-fg"), onClick: () => setFlip((f) => ({ ...f, v: !f.v })), children: _jsx(FlipVertical2, {}) }), _jsx("span", { "aria-hidden": true, className: "mx-1 h-4 w-px bg-line" })] })) : null, _jsx(IconButton, { label: t("reset"), tooltip: false, size: "sm", className: tool, onClick: reset, children: _jsx(RotateCcw, {}) })] })] })) : null] }));
|
|
125
|
+
});
|
|
126
|
+
function PresetGlyph({ ratio, round }) {
|
|
127
|
+
const w = ratio >= 1 ? 14 : Math.max(6, 14 * ratio);
|
|
128
|
+
const h = ratio >= 1 ? Math.max(6, 14 / ratio) : 14;
|
|
129
|
+
return _jsx("span", { "aria-hidden": true, className: cn("inline-block border-[1.5px] border-current opacity-70", round ? "rounded-full" : "rounded-[2px]"), style: { width: w, height: h } });
|
|
130
|
+
}
|
|
131
|
+
function loadImage(src) {
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
133
|
+
const img = new window.Image();
|
|
134
|
+
img.crossOrigin = "anonymous";
|
|
135
|
+
img.onload = () => resolve(img);
|
|
136
|
+
img.onerror = () => reject(new Error(`Could not load ${src}`));
|
|
137
|
+
img.src = src;
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Bakes a `CropRect` into a new image (canvas, rotation- and flip-aware) for "Save as copy".
|
|
142
|
+
* The source must be same-origin or served with CORS, or the canvas is tainted.
|
|
143
|
+
*/
|
|
144
|
+
export async function getCroppedBlob(src, rect, options = {}) {
|
|
145
|
+
const { type = "image/webp", quality = 0.9, maxWidth } = options;
|
|
146
|
+
const img = await loadImage(src);
|
|
147
|
+
const rad = ((rect.rotation ?? 0) * Math.PI) / 180;
|
|
148
|
+
const bw = Math.abs(Math.cos(rad) * img.naturalWidth) + Math.abs(Math.sin(rad) * img.naturalHeight);
|
|
149
|
+
const bh = Math.abs(Math.sin(rad) * img.naturalWidth) + Math.abs(Math.cos(rad) * img.naturalHeight);
|
|
150
|
+
const stage = document.createElement("canvas");
|
|
151
|
+
stage.width = Math.round(bw);
|
|
152
|
+
stage.height = Math.round(bh);
|
|
153
|
+
const s = stage.getContext("2d");
|
|
154
|
+
if (!s)
|
|
155
|
+
throw new Error("Canvas is not available");
|
|
156
|
+
s.translate(bw / 2, bh / 2);
|
|
157
|
+
s.rotate(rad);
|
|
158
|
+
s.scale(rect.flip?.h ? -1 : 1, rect.flip?.v ? -1 : 1);
|
|
159
|
+
s.drawImage(img, -img.naturalWidth / 2, -img.naturalHeight / 2);
|
|
160
|
+
const scale = maxWidth && rect.width > maxWidth ? maxWidth / rect.width : 1;
|
|
161
|
+
const out = document.createElement("canvas");
|
|
162
|
+
out.width = Math.round(rect.width * scale);
|
|
163
|
+
out.height = Math.round(rect.height * scale);
|
|
164
|
+
const o = out.getContext("2d");
|
|
165
|
+
if (!o)
|
|
166
|
+
throw new Error("Canvas is not available");
|
|
167
|
+
o.imageSmoothingQuality = "high";
|
|
168
|
+
o.drawImage(stage, rect.x, rect.y, rect.width, rect.height, 0, 0, out.width, out.height);
|
|
169
|
+
return new Promise((resolve, reject) => out.toBlob((b) => (b ? resolve(b) : reject(new Error("Export failed"))), type, quality));
|
|
170
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type ImageAspect } from "../components/image.js";
|
|
3
|
+
import { type FocalPoint } from "./focal-point.js";
|
|
4
|
+
import type { CropRect, MediaAdapter, MediaAsset } from "./types.js";
|
|
5
|
+
declare const fieldLabels: {
|
|
6
|
+
set: string;
|
|
7
|
+
setRound: string;
|
|
8
|
+
hint: string;
|
|
9
|
+
recommended: string;
|
|
10
|
+
replace: string;
|
|
11
|
+
crop: string;
|
|
12
|
+
focal: string;
|
|
13
|
+
remove: string;
|
|
14
|
+
alt: string;
|
|
15
|
+
altMissing: string;
|
|
16
|
+
altAdd: string;
|
|
17
|
+
altEdit: string;
|
|
18
|
+
altDecorative: string;
|
|
19
|
+
altSave: string;
|
|
20
|
+
lowRes: string;
|
|
21
|
+
uploading: string;
|
|
22
|
+
uploadError: string;
|
|
23
|
+
dropHint: string;
|
|
24
|
+
cropTitle: string;
|
|
25
|
+
cropMode: string;
|
|
26
|
+
cropMetadata: string;
|
|
27
|
+
cropMetadataHint: string;
|
|
28
|
+
cropCopy: string;
|
|
29
|
+
cropCopyHint: string;
|
|
30
|
+
cropSave: string;
|
|
31
|
+
cropTainted: string;
|
|
32
|
+
focalTitle: string;
|
|
33
|
+
focalDescription: string;
|
|
34
|
+
focalSave: string;
|
|
35
|
+
cancel: string;
|
|
36
|
+
pickerTitle: string;
|
|
37
|
+
pickerConfirm: string;
|
|
38
|
+
};
|
|
39
|
+
export type ImageFieldLabels = typeof fieldLabels;
|
|
40
|
+
/** The field's value: the asset plus per-use overrides. */
|
|
41
|
+
export interface ImageFieldValue {
|
|
42
|
+
asset: MediaAsset;
|
|
43
|
+
/** Per-use alt text; falls back to `asset.alt`. */
|
|
44
|
+
alt?: string;
|
|
45
|
+
/** Per-use focal point; falls back to `asset.focalPoint`. */
|
|
46
|
+
focal?: FocalPoint;
|
|
47
|
+
/** Named crop (`asset.crops[name]`) or a rect. */
|
|
48
|
+
crop?: string | CropRect;
|
|
49
|
+
}
|
|
50
|
+
export interface ImageFieldCropPreset {
|
|
51
|
+
label: string;
|
|
52
|
+
value: number;
|
|
53
|
+
/** Stored as `asset.crops[name]` and referenced by name from the value. */
|
|
54
|
+
name?: string;
|
|
55
|
+
}
|
|
56
|
+
export declare const imageFieldVariants: (props?: ({
|
|
57
|
+
size?: "full" | "sm" | "md" | null | undefined;
|
|
58
|
+
layout?: "inline" | "stacked" | null | undefined;
|
|
59
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
60
|
+
export interface ImageFieldProps {
|
|
61
|
+
value?: ImageFieldValue | null;
|
|
62
|
+
defaultValue?: ImageFieldValue | null;
|
|
63
|
+
onChange?: (value: ImageFieldValue | null) => void;
|
|
64
|
+
/** Else from `MediaProvider`. */
|
|
65
|
+
adapter?: MediaAdapter;
|
|
66
|
+
/** Preview ratio and default crop ratio. Default `"16/9"` (`"1/1"` for `shape="round"`). */
|
|
67
|
+
aspect?: ImageAspect;
|
|
68
|
+
/** Crop ratio buttons. Default: the field's aspect only. */
|
|
69
|
+
cropPresets?: ImageFieldCropPreset[];
|
|
70
|
+
/** Low-resolution warning below this size (e.g. 1200 × 630 for social cards). */
|
|
71
|
+
recommended?: {
|
|
72
|
+
width: number;
|
|
73
|
+
height: number;
|
|
74
|
+
};
|
|
75
|
+
shape?: "rect" | "round";
|
|
76
|
+
/** `sm` 96px avatar · `md` card · `full` container width. */
|
|
77
|
+
size?: "sm" | "md" | "full";
|
|
78
|
+
/** `inline` puts the actions beside the preview (avatars, logos). */
|
|
79
|
+
layout?: "stacked" | "inline";
|
|
80
|
+
/** Show the focal-point tool. Default `true` (rect). */
|
|
81
|
+
focal?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Crop tool: `true` offers both modes when the adapter can edit, `"metadata"` stores a crop
|
|
84
|
+
* rect (non-destructive), `"copy"` uploads a cropped copy, `false` hides it. Default `true`.
|
|
85
|
+
*/
|
|
86
|
+
crop?: boolean | "copy" | "metadata";
|
|
87
|
+
/** The picker asks for alt text; the field warns while it is missing. */
|
|
88
|
+
requireAlt?: boolean;
|
|
89
|
+
/** Default `"image/*"`. */
|
|
90
|
+
accept?: string;
|
|
91
|
+
disabled?: boolean;
|
|
92
|
+
readOnly?: boolean;
|
|
93
|
+
/** Renders a hidden input with the asset id for native forms. */
|
|
94
|
+
name?: string;
|
|
95
|
+
id?: string;
|
|
96
|
+
required?: boolean;
|
|
97
|
+
invalid?: boolean;
|
|
98
|
+
"aria-describedby"?: string;
|
|
99
|
+
"aria-label"?: string;
|
|
100
|
+
className?: string;
|
|
101
|
+
labels?: Partial<ImageFieldLabels>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* A form field that holds one image: pick from the library or drop a file, preview, replace,
|
|
105
|
+
* remove, crop to a ratio (non-destructive or as a copy), set a focal point and a per-use alt text.
|
|
106
|
+
* Works inside `Field` (label, hint, error, required).
|
|
107
|
+
*
|
|
108
|
+
* ```tsx
|
|
109
|
+
* <Field label="Featured image" hint="Shown on the blog index and social cards">
|
|
110
|
+
* <ImageField aspect="16/9" recommended={{ width: 1200, height: 630 }} value={cover} onChange={setCover} />
|
|
111
|
+
* </Field>
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare const ImageField: React.ForwardRefExoticComponent<ImageFieldProps & React.RefAttributes<HTMLDivElement>>;
|
|
115
|
+
export {};
|
|
@@ -0,0 +1,212 @@
|
|
|
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 { Crop, Crosshair, ImagePlus, Pencil, RefreshCw, Trash2, TriangleAlert } from "lucide-react";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { useLabels } from "../lib/labels.js";
|
|
8
|
+
import { useFormat, useLocale } from "../lib/locale.js";
|
|
9
|
+
import { useFieldControl } from "../lib/field-context.js";
|
|
10
|
+
import { useControllableState } from "../lib/use-controllable-state.js";
|
|
11
|
+
import { Button, IconButton } from "../components/button.js";
|
|
12
|
+
import { Dialog, DialogBody, DialogContent, DialogFooter, DialogHeader } from "../components/dialog.js";
|
|
13
|
+
import { Image, aspectRatioOf } from "../components/image.js";
|
|
14
|
+
import { Input } from "../components/input.js";
|
|
15
|
+
import { Progress } from "../components/progress.js";
|
|
16
|
+
import { RadioGroup, RadioGroupItem } from "../components/radio-group.js";
|
|
17
|
+
import { FocalPointPicker } from "./focal-point.js";
|
|
18
|
+
import { ImageCropper, getCroppedBlob } from "./image-cropper.js";
|
|
19
|
+
import { MediaPicker } from "./media-picker.js";
|
|
20
|
+
import { useMedia } from "./media-provider.js";
|
|
21
|
+
import { isAltMissing } from "./media-utils.js";
|
|
22
|
+
import { useUploadQueue } from "./use-upload-queue.js";
|
|
23
|
+
const fieldLabels = {
|
|
24
|
+
set: "Set image",
|
|
25
|
+
setRound: "Add photo",
|
|
26
|
+
hint: "Drop an image here or choose one from the library",
|
|
27
|
+
recommended: "Recommended {width} × {height} px or larger",
|
|
28
|
+
replace: "Replace image",
|
|
29
|
+
crop: "Crop",
|
|
30
|
+
focal: "Focal point",
|
|
31
|
+
remove: "Remove image",
|
|
32
|
+
alt: "Alt text",
|
|
33
|
+
altMissing: "Missing alt text",
|
|
34
|
+
altAdd: "Add alt text",
|
|
35
|
+
altEdit: "Edit alt text",
|
|
36
|
+
altDecorative: "Decorative image",
|
|
37
|
+
altSave: "Done",
|
|
38
|
+
lowRes: "Low resolution: {width} × {height} px. Recommended at least {minWidth} × {minHeight}.",
|
|
39
|
+
uploading: "Uploading {name}",
|
|
40
|
+
uploadError: "Upload failed: {reason}",
|
|
41
|
+
dropHint: "Drop to upload",
|
|
42
|
+
cropTitle: "Crop image",
|
|
43
|
+
cropMode: "Save the crop",
|
|
44
|
+
cropMetadata: "Keep the original, store the crop",
|
|
45
|
+
cropMetadataHint: "Non-destructive: the original file stays untouched.",
|
|
46
|
+
cropCopy: "Save as a new copy",
|
|
47
|
+
cropCopyHint: "Creates a new file in the library.",
|
|
48
|
+
cropSave: "Apply crop",
|
|
49
|
+
cropTainted: "This image is hosted elsewhere, so it can't be edited here. Upload it to the library to crop it.",
|
|
50
|
+
focalTitle: "Set focal point",
|
|
51
|
+
focalDescription: "Mark the part that must stay in view when layouts crop the image.",
|
|
52
|
+
focalSave: "Save focal point",
|
|
53
|
+
cancel: "Cancel",
|
|
54
|
+
pickerTitle: "Select image",
|
|
55
|
+
pickerConfirm: "Use image",
|
|
56
|
+
};
|
|
57
|
+
export const imageFieldVariants = cva("vui-image-field group/imgfield relative grid min-w-0 gap-2", {
|
|
58
|
+
variants: {
|
|
59
|
+
size: { sm: "w-24", md: "w-full max-w-[22rem]", full: "w-full" },
|
|
60
|
+
layout: { stacked: "", inline: "grid-cols-[auto_minmax(0,1fr)] items-start gap-x-4" },
|
|
61
|
+
},
|
|
62
|
+
// Inline: the preview keeps the size, the row takes the width.
|
|
63
|
+
compoundVariants: [{ layout: "inline", class: "w-full max-w-md" }],
|
|
64
|
+
defaultVariants: { size: "md", layout: "stacked" },
|
|
65
|
+
});
|
|
66
|
+
const ratioOf = (aspect, a) => aspectRatioOf(aspect ?? "auto", a?.width, a?.height) ?? (a?.width && a?.height ? a.width / a.height : 16 / 9);
|
|
67
|
+
/**
|
|
68
|
+
* A form field that holds one image: pick from the library or drop a file, preview, replace,
|
|
69
|
+
* remove, crop to a ratio (non-destructive or as a copy), set a focal point and a per-use alt text.
|
|
70
|
+
* Works inside `Field` (label, hint, error, required).
|
|
71
|
+
*
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <Field label="Featured image" hint="Shown on the blog index and social cards">
|
|
74
|
+
* <ImageField aspect="16/9" recommended={{ width: 1200, height: 630 }} value={cover} onChange={setCover} />
|
|
75
|
+
* </Field>
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export const ImageField = React.forwardRef(function ImageField(props, ref) {
|
|
79
|
+
const { value: valueProp, defaultValue, onChange, adapter: adapterProp, aspect: aspectProp, cropPresets, recommended, shape = "rect", size = "md", layout = "stacked", focal: focalEnabled = shape !== "round", crop: cropMode = true, requireAlt = false, accept = "image/*", name, className, labels, } = props;
|
|
80
|
+
const control = useFieldControl({ id: props.id, "aria-describedby": props["aria-describedby"], disabled: props.disabled, readOnly: props.readOnly, required: props.required, "aria-invalid": props.invalid || undefined });
|
|
81
|
+
const disabled = Boolean(control.disabled);
|
|
82
|
+
const readOnly = Boolean(control.readOnly);
|
|
83
|
+
const t = useLabels("imageField", fieldLabels, labels);
|
|
84
|
+
const f = useFormat();
|
|
85
|
+
const { locale } = useLocale();
|
|
86
|
+
const ctx = useMedia();
|
|
87
|
+
const adapter = adapterProp ?? ctx;
|
|
88
|
+
const aspect = aspectProp ?? (shape === "round" ? "1/1" : "16/9");
|
|
89
|
+
const [value, setValue] = useControllableState({ value: valueProp, defaultValue: defaultValue ?? null, onChange, name: "ImageField" });
|
|
90
|
+
const [pickerOpen, setPickerOpen] = React.useState(false);
|
|
91
|
+
const [cropOpen, setCropOpen] = React.useState(false);
|
|
92
|
+
const [focalOpen, setFocalOpen] = React.useState(false);
|
|
93
|
+
const [editingAlt, setEditingAlt] = React.useState(false);
|
|
94
|
+
const [over, setOver] = React.useState(false);
|
|
95
|
+
const altInput = React.useRef(null);
|
|
96
|
+
const nf = React.useMemo(() => new Intl.NumberFormat(locale), [locale]);
|
|
97
|
+
const interactive = !disabled && !readOnly;
|
|
98
|
+
const queue = useUploadQueue(adapter, {
|
|
99
|
+
accept,
|
|
100
|
+
guardUnload: true,
|
|
101
|
+
onUploaded: (asset) => setValue({ asset }),
|
|
102
|
+
});
|
|
103
|
+
const current = queue.items.find((it) => it.status === "queued" || it.status === "uploading" || it.status === "processing");
|
|
104
|
+
const failed = !current ? queue.items.filter((it) => it.status === "error").at(-1) : undefined;
|
|
105
|
+
const asset = value?.asset;
|
|
106
|
+
const alt = value?.alt ?? asset?.alt ?? "";
|
|
107
|
+
const missingAlt = asset ? isAltMissing(asset, alt) : false;
|
|
108
|
+
const lowRes = asset && recommended && asset.width && asset.height && (asset.width < recommended.width || asset.height < recommended.height);
|
|
109
|
+
const editable = Boolean(adapter?.capabilities.edit);
|
|
110
|
+
const cropAvailable = cropMode !== false;
|
|
111
|
+
const drop = interactive
|
|
112
|
+
? {
|
|
113
|
+
onDragOver: (e) => {
|
|
114
|
+
if (!Array.from(e.dataTransfer?.types ?? []).includes("Files"))
|
|
115
|
+
return;
|
|
116
|
+
e.preventDefault();
|
|
117
|
+
setOver(true);
|
|
118
|
+
},
|
|
119
|
+
onDragLeave: () => setOver(false),
|
|
120
|
+
onDrop: (e) => {
|
|
121
|
+
setOver(false);
|
|
122
|
+
const file = e.dataTransfer?.files?.[0];
|
|
123
|
+
if (!file)
|
|
124
|
+
return;
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
queue.clearDone();
|
|
127
|
+
queue.add([file]);
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
: {};
|
|
131
|
+
const ratio = ratioOf(aspect, asset);
|
|
132
|
+
const round = shape === "round";
|
|
133
|
+
const hintId = React.useId();
|
|
134
|
+
const describedBy = [control["aria-describedby"], hintId].filter(Boolean).join(" ") || undefined;
|
|
135
|
+
const empty = (_jsx("button", { type: "button", id: control.id, "data-slot": "image-field-empty", "data-dragging": over ? "" : undefined, "aria-describedby": describedBy, "aria-invalid": control["aria-invalid"], "data-readonly": readOnly ? "" : undefined, disabled: disabled, onClick: () => interactive && setPickerOpen(true), className: cn("vui-image-field-empty focus-ring relative flex w-full flex-col items-center justify-center gap-1.5 overflow-hidden border border-dashed border-field-border bg-surface-2 px-3 text-center text-fg-muted transition-colors", "hover:border-field-border-hover hover:text-fg disabled:cursor-not-allowed disabled:opacity-50", "aria-[invalid=true]:border-danger", round ? "rounded-full" : "rounded-ui", over && "border-ring bg-accent-soft text-fg"), style: { aspectRatio: String(round ? 1 : ratio) }, children: current ? (_jsxs("span", { className: "grid w-full max-w-[14rem] gap-2 px-2", children: [_jsx("span", { className: "truncate text-[12.5px]", children: t("uploading", { name: current.file.name }) }), _jsx(Progress, { "aria-label": t("uploading", { name: current.file.name }), value: current.status === "uploading" ? current.progress * 100 : current.status === "processing" ? null : 0 })] })) : (_jsxs(_Fragment, { children: [props["aria-label"] ? _jsxs("span", { className: "sr-only", children: [props["aria-label"], ", "] }) : null, _jsx(ImagePlus, { "aria-hidden": true, strokeWidth: 1.5, className: size === "sm" ? "size-5" : "size-6" }), _jsx("span", { className: cn("font-medium text-fg", size === "sm" ? "text-[12px]" : "text-[13.5px]"), children: over ? t("dropHint") : round ? t("setRound") : t("set") }), size !== "sm" ? _jsx("span", { className: "max-w-[16rem] text-[12px] leading-snug text-fg-subtle", children: t("hint") }) : null] })) }));
|
|
136
|
+
const preview = asset ? (_jsx("div", { className: cn("relative", round && "aspect-square"), children: _jsxs("button", { type: "button", id: control.id, "data-slot": "image-field-preview", "data-dragging": over ? "" : undefined, "aria-label": `${t("replace")}${alt ? `: ${alt}` : ""}`, "aria-describedby": describedBy, "aria-invalid": control["aria-invalid"], "data-readonly": readOnly ? "" : undefined, disabled: disabled, onClick: () => interactive && setPickerOpen(true), className: cn("vui-image-field-preview focus-ring group/preview relative block w-full overflow-hidden bg-surface-2 ring-1 ring-line", round ? "rounded-full" : "rounded-ui", interactive ? "cursor-pointer" : "cursor-default", over && "ring-2 ring-ring"), children: [_jsx(Image, { src: asset, alt: "", aspect: round ? "1/1" : aspect, focal: value?.focal ?? asset.focalPoint, crop: value?.crop, sizes: size === "sm" ? "96px" : "(min-width: 768px) 360px, 100vw", placeholder: asset.placeholder ? "blur" : "skeleton" }), interactive ? (_jsx("span", { "aria-hidden": true, className: "vui-image-field-scrim absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover/preview:opacity-100", children: _jsxs("span", { className: "surface-popover inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-[12px] font-medium", children: [_jsx(RefreshCw, { className: "size-3.5" }), size === "sm" ? null : t("replace")] }) })) : null, current ? (_jsx("span", { className: "absolute inset-x-3 bottom-3", children: _jsx(Progress, { "aria-label": t("uploading", { name: current.file.name }), value: current.status === "uploading" ? current.progress * 100 : null }) })) : null] }) })) : null;
|
|
137
|
+
const actions = asset && interactive ? (_jsxs("div", { "data-slot": "image-field-actions", className: cn("flex flex-wrap items-center gap-1", layout === "inline" && "col-start-2"), children: [layout === "inline" ? (_jsxs(Button, { size: "xs", onClick: () => setPickerOpen(true), children: [_jsx(RefreshCw, {}), t("replace")] })) : null, cropAvailable ? (_jsxs(Button, { size: "xs", variant: "ghost", className: "text-fg-muted", onClick: () => setCropOpen(true), children: [_jsx(Crop, {}), t("crop")] })) : null, focalEnabled && !round ? (_jsxs(Button, { size: "xs", variant: "ghost", className: "text-fg-muted", onClick: () => setFocalOpen(true), children: [_jsx(Crosshair, {}), t("focal")] })) : null, _jsx(IconButton, { label: t("remove"), tooltip: false, size: "xs", variant: "ghost", className: "ms-auto text-fg-muted hover:text-danger", onClick: () => setValue(null), children: _jsx(Trash2, {}) })] })) : null;
|
|
138
|
+
const altLine = asset ? (_jsxs("div", { "data-slot": "image-field-alt", className: cn("grid gap-1 text-[12.5px]", layout === "inline" && "col-start-2"), children: [editingAlt ? (_jsxs("form", { className: "flex items-center gap-1.5", onSubmit: (e) => {
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
setValue({ ...value, alt: altInput.current?.value ?? "" });
|
|
141
|
+
setEditingAlt(false);
|
|
142
|
+
}, children: [_jsx(Input, { ref: altInput, size: "sm", autoFocus: true, "aria-label": t("alt"), defaultValue: alt, className: "flex-1", onKeyDown: (e) => e.key === "Escape" && (e.stopPropagation(), setEditingAlt(false)) }), _jsx(Button, { size: "sm", type: "submit", children: t("altSave") })] })) : missingAlt ? (_jsxs("p", { className: cn("flex items-center gap-1.5", requireAlt ? "text-warning" : "text-fg-muted"), children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "size-3.5 shrink-0" }), _jsx("span", { children: t("altMissing") }), interactive ? (_jsx(Button, { size: "xs", variant: "link", className: "ms-1", onClick: () => setEditingAlt(true), children: t("altAdd") })) : null] })) : (_jsxs("p", { className: "flex min-w-0 items-baseline gap-1.5 text-fg-muted", children: [_jsx("span", { className: "shrink-0 text-[11px] font-medium tracking-[0.06em] text-fg-subtle uppercase", children: t("alt") }), _jsx("span", { className: "min-w-0 truncate text-fg", children: alt || t("altDecorative") }), interactive ? (_jsx(IconButton, { label: t("altEdit"), tooltip: false, size: "xs", variant: "ghost", className: "-my-1 shrink-0 text-fg-subtle", onClick: () => setEditingAlt(true), children: _jsx(Pencil, {}) })) : null] })), lowRes ? (_jsxs("p", { className: "flex items-start gap-1.5 text-warning", children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "mt-px size-3.5 shrink-0" }), t("lowRes", { width: nf.format(asset.width), height: nf.format(asset.height), minWidth: nf.format(recommended.width), minHeight: nf.format(recommended.height) })] })) : null] })) : null;
|
|
143
|
+
return (_jsxs("div", { ref: ref, "data-slot": "image-field", "data-shape": shape, "data-state": asset ? "filled" : "empty", className: cn(imageFieldVariants({ size, layout }), className), ...drop, children: [_jsx("div", { className: cn(layout === "inline" && (size === "sm" ? "w-24" : "w-40"), layout === "inline" && "row-span-3 self-start"), children: asset ? preview : empty }), actions, altLine, _jsx("p", { id: hintId, className: cn("text-[12px]", failed ? "text-danger" : "sr-only"), children: failed ? t("uploadError", { reason: failed.error ?? "" }) : recommended ? t("recommended", { width: nf.format(recommended.width), height: nf.format(recommended.height) }) : null }), !asset && recommended && size !== "sm" && !failed ? (_jsx("p", { "aria-hidden": true, className: cn("tabular text-[12px] text-fg-subtle", layout === "inline" && "col-start-2"), children: t("recommended", { width: f.number(recommended.width), height: f.number(recommended.height) }) })) : null, name ? _jsx("input", { type: "hidden", name: name, value: asset?.id ?? "" }) : null, interactive ? (_jsx(MediaPicker, { open: pickerOpen, onOpenChange: setPickerOpen, adapter: adapter, accept: accept, value: asset ? [asset.id] : undefined, requireAlt: requireAlt, title: t("pickerTitle"), confirmLabel: t("pickerConfirm"), onSelect: ([picked]) => picked && setValue({ asset: picked }) })) : null, asset && interactive && cropAvailable ? (_jsx(ImageFieldCropDialog, { open: cropOpen, onOpenChange: setCropOpen, asset: asset, adapter: adapter, aspect: ratio, presets: cropPresets, shape: shape, mode: cropMode === true ? (editable ? "both" : "copy") : cropMode === "metadata" ? "metadata" : "copy", initial: typeof value?.crop === "object" ? value.crop : typeof value?.crop === "string" ? asset.crops?.[value.crop] : undefined, t: t, onApply: (result) => {
|
|
144
|
+
if (result.kind === "copy")
|
|
145
|
+
setValue({ asset: result.asset, alt: value?.alt });
|
|
146
|
+
else
|
|
147
|
+
setValue({ ...value, asset: result.asset ?? asset, crop: result.crop });
|
|
148
|
+
} })) : null, asset && interactive && focalEnabled && !round ? (_jsx(Dialog, { open: focalOpen, onOpenChange: setFocalOpen, children: _jsxs(DialogContent, { size: "lg", children: [_jsx(DialogHeader, { title: t("focalTitle"), description: t("focalDescription") }), focalOpen ? _jsx(ImageFieldFocalBody, { asset: asset, initial: value?.focal ?? asset.focalPoint, t: t, onSave: (focal) => {
|
|
149
|
+
setValue({ ...value, focal });
|
|
150
|
+
setFocalOpen(false);
|
|
151
|
+
}, onCancel: () => setFocalOpen(false) }) : null] }) })) : null] }));
|
|
152
|
+
});
|
|
153
|
+
function ImageFieldFocalBody({ asset, initial, onSave, onCancel, t }) {
|
|
154
|
+
const [point, setPoint] = React.useState(initial ?? { x: 0.5, y: 0.5 });
|
|
155
|
+
return (_jsxs(_Fragment, { children: [_jsx(DialogBody, { children: _jsx(FocalPointPicker, { src: asset, value: point, onValueChange: setPoint }) }), _jsxs(DialogFooter, { children: [_jsx(Button, { onClick: onCancel, children: t("cancel") }), _jsx(Button, { variant: "primary", onClick: () => onSave(point), children: t("focalSave") })] })] }));
|
|
156
|
+
}
|
|
157
|
+
/** The crop dialog of Image field: Image cropper + save mode (non-destructive rect or a new copy). */
|
|
158
|
+
function ImageFieldCropDialog({ open, onOpenChange, asset, adapter, aspect, presets, shape, mode, initial, onApply, t, }) {
|
|
159
|
+
const [rect, setRect] = React.useState(initial ?? null);
|
|
160
|
+
const [preset, setPreset] = React.useState();
|
|
161
|
+
const [choice, setChoice] = React.useState(mode === "copy" ? "copy" : "metadata");
|
|
162
|
+
const [busy, setBusy] = React.useState(false);
|
|
163
|
+
const [error, setError] = React.useState(null);
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
if (open) {
|
|
166
|
+
setError(null);
|
|
167
|
+
setRect(initial ?? null);
|
|
168
|
+
}
|
|
169
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
|
+
}, [open]);
|
|
171
|
+
const cropperPresets = presets?.map((p) => ({ label: p.label, value: p.value, name: p.name }));
|
|
172
|
+
const apply = async () => {
|
|
173
|
+
if (!rect)
|
|
174
|
+
return;
|
|
175
|
+
setError(null);
|
|
176
|
+
if (choice === "metadata") {
|
|
177
|
+
let saved;
|
|
178
|
+
if (preset?.name && adapter?.capabilities.edit) {
|
|
179
|
+
try {
|
|
180
|
+
saved = await adapter.update(asset.id, { crops: { ...asset.crops, [preset.name]: rect } });
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
/* keep the per-use rect */
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
onApply({ kind: "metadata", crop: preset?.name && saved ? preset.name : rect, asset: saved });
|
|
187
|
+
onOpenChange(false);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (!adapter)
|
|
191
|
+
return;
|
|
192
|
+
setBusy(true);
|
|
193
|
+
try {
|
|
194
|
+
const blob = await getCroppedBlob(asset.url, rect, { type: asset.mime === "image/png" ? "image/png" : "image/webp" });
|
|
195
|
+
const ext = blob.type === "image/png" ? "png" : "webp";
|
|
196
|
+
const file = new File([blob], asset.filename.replace(/\.[^.]+$/, "") + `-crop.${ext}`, { type: blob.type });
|
|
197
|
+
const copy = await adapter.upload(file, { folderId: asset.folderId ?? null, alt: asset.alt, signal: new AbortController().signal, onProgress: () => { } });
|
|
198
|
+
onApply({ kind: "copy", asset: copy });
|
|
199
|
+
onOpenChange(false);
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
setError(t("cropTainted"));
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
setBusy(false);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { size: "xl", mobile: "fullscreen", children: [_jsx(DialogHeader, { title: t("cropTitle") }), _jsxs(DialogBody, { className: "grid gap-4", children: [open ? (_jsx(ImageCropper, { src: asset, defaultValue: initial, defaultAspect: shape === "round" ? 1 : aspect, presets: cropperPresets ?? (shape === "round" ? undefined : []), shape: shape, height: "min(24rem, 50dvh)", onChange: (r, p) => {
|
|
209
|
+
setRect(r);
|
|
210
|
+
setPreset(p);
|
|
211
|
+
} })) : null, mode === "both" ? (_jsxs(RadioGroup, { "aria-label": t("cropMode"), value: choice, onValueChange: (v) => setChoice(v), className: "grid gap-2 sm:grid-cols-2", children: [_jsx(RadioGroupItem, { value: "metadata", label: t("cropMetadata"), description: t("cropMetadataHint") }), _jsx(RadioGroupItem, { value: "copy", label: t("cropCopy"), description: t("cropCopyHint") })] })) : null, error ? (_jsxs("p", { role: "alert", className: "flex items-start gap-1.5 text-[13px] text-danger", children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "mt-0.5 size-3.5 shrink-0" }), error] })) : null] }), _jsxs(DialogFooter, { children: [_jsx(Button, { onClick: () => onOpenChange(false), children: t("cancel") }), _jsx(Button, { variant: "primary", disabled: !rect, loading: busy, onClick: () => void apply(), children: t("cropSave") })] })] }) }));
|
|
212
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type { MediaKind, MediaAsset, MediaVariant, MediaFolder, MediaQuery, MediaPage, MediaPatch, MediaEvent, MediaCapabilities, MediaAdapter, MediaSource, MediaItem, CropRect, UploadOptions, ImageLoader, } from "./types.js";
|
|
2
|
+
export { MediaProvider, useMedia, isMediaAsset, toMediaSource } from "./media-provider.js";
|
|
3
|
+
export { createMemoryAdapter, type MemoryAdapterOptions } from "./memory-adapter.js";
|
|
4
|
+
export { usePanZoom, type UsePanZoomOptions, type PanZoomState } from "./use-pan-zoom.js";
|
|
5
|
+
export { Gallery, galleryVariants, type GalleryProps, type GalleryLabels } from "./gallery.js";
|
|
6
|
+
export { masonryColumns, justifyRows, responsiveValue, type JustifiedRow, type Responsive } from "./gallery-layout.js";
|
|
7
|
+
export { Lightbox, LightboxTrigger, useLightbox, type LightboxProps, type LightboxTriggerProps, type LightboxLabels } from "./lightbox.js";
|
|
8
|
+
export { VideoPlayer, VideoEmbed, BackgroundVideo, videoPlayerVariants, formatMediaTime, type VideoPlayerProps, type VideoEmbedProps, type BackgroundVideoProps, type VideoSource, type VideoTrack, type HlsConstructor, type VideoPlayerLabels, } from "./video-player.js";
|
|
9
|
+
export { SearchPreview, SocialCardPreview, LengthMeter, LinkPreviewTabs, type LinkPreviewData, type SearchPreviewProps, type SocialCardPreviewProps, type LengthMeterProps, type LinkPreviewTabsProps, type SocialPlatform, type LinkPreviewLabels, } from "./link-preview.js";
|
|
10
|
+
export { measureSerp, measureText, countGraphemes, graphemes, SERP_LIMITS, type SerpMeasure, type SerpField, type SerpDevice } from "./serp.js";
|
|
11
|
+
export { ImageCropper, getCroppedBlob, formatAspectRatio, type ImageCropperProps, type CropPreset, type CroppedBlobOptions, type ImageCropperLabels, } from "./image-cropper.js";
|
|
12
|
+
export { Image, Figure, FigureCaption, ImageLoaderProvider, useImageLoader, useImageSources, getImageSources, type ImageProps } from "../components/image.js";
|
|
13
|
+
export { createRestAdapter, createPresignedUpload, xhrUpload, toSearchParams, type RestAdapterOptions, type PresignedTarget, type PresignedUploadOptions, type XhrUploadOptions } from "./rest-adapter.js";
|
|
14
|
+
export { useUploadQueue, type UploadQueue, type UploadQueueItem, type UploadStatus, type UseUploadQueueOptions } from "./use-upload-queue.js";
|
|
15
|
+
export { mediaKindOf, acceptsMedia, kindsFromAccept, isAltMissing, isDecorative, downscaleImage, DECORATIVE_TAG } from "./media-utils.js";
|
|
16
|
+
export { FocalPointPicker, type FocalPointPickerProps, type FocalPoint, type FocalPointLabels } from "./focal-point.js";
|
|
17
|
+
export { MediaLibrary, MediaDetails, MediaUploadQueue, MediaThumb, MediaFileGlyph, type MediaLibraryProps, type MediaLibraryHandle, type MediaLibraryView, type MediaSelectionMode, type MediaDetailsProps, type MediaUploadQueueProps, type MediaLibraryLabels, type MediaDetailsLabels, type MediaUploadQueueLabels, } from "./media-library.js";
|
|
18
|
+
export { MediaPicker, MediaPickerProvider, useMediaPicker, type MediaPickerProps, type MediaPickerTab, type MediaPickOptions, type MediaPickerLabels } from "./media-picker.js";
|
|
19
|
+
export { ImageField, imageFieldVariants, type ImageFieldProps, type ImageFieldValue, type ImageFieldCropPreset, type ImageFieldLabels } from "./image-field.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Public API of @vamos-ui/react/media — media contract, adapters and viewers.
|
|
2
|
+
// `Image`, `Figure` and `Carousel` live in the package root (they are light); this subpath holds
|
|
3
|
+
// the heavier media parts and the storage-agnostic MediaAdapter contract (plan 05 · D2).
|
|
4
|
+
export { MediaProvider, useMedia, isMediaAsset, toMediaSource } from "./media-provider.js";
|
|
5
|
+
export { createMemoryAdapter } from "./memory-adapter.js";
|
|
6
|
+
export { usePanZoom } from "./use-pan-zoom.js";
|
|
7
|
+
export { Gallery, galleryVariants } from "./gallery.js";
|
|
8
|
+
export { masonryColumns, justifyRows, responsiveValue } from "./gallery-layout.js";
|
|
9
|
+
export { Lightbox, LightboxTrigger, useLightbox } from "./lightbox.js";
|
|
10
|
+
export { VideoPlayer, VideoEmbed, BackgroundVideo, videoPlayerVariants, formatMediaTime, } from "./video-player.js";
|
|
11
|
+
export { SearchPreview, SocialCardPreview, LengthMeter, LinkPreviewTabs, } from "./link-preview.js";
|
|
12
|
+
export { measureSerp, measureText, countGraphemes, graphemes, SERP_LIMITS } from "./serp.js";
|
|
13
|
+
export { ImageCropper, getCroppedBlob, formatAspectRatio, } from "./image-cropper.js";
|
|
14
|
+
// Convenience re-exports so media code can import everything from one place.
|
|
15
|
+
export { Image, Figure, FigureCaption, ImageLoaderProvider, useImageLoader, useImageSources, getImageSources } from "../components/image.js";
|
|
16
|
+
// Media library · Media picker · Image field (+ adapters, upload queue, focal point)
|
|
17
|
+
export { createRestAdapter, createPresignedUpload, xhrUpload, toSearchParams } from "./rest-adapter.js";
|
|
18
|
+
export { useUploadQueue } from "./use-upload-queue.js";
|
|
19
|
+
export { mediaKindOf, acceptsMedia, kindsFromAccept, isAltMissing, isDecorative, downscaleImage, DECORATIVE_TAG } from "./media-utils.js";
|
|
20
|
+
export { FocalPointPicker } from "./focal-point.js";
|
|
21
|
+
export { MediaLibrary, MediaDetails, MediaUploadQueue, MediaThumb, MediaFileGlyph, } from "./media-library.js";
|
|
22
|
+
export { MediaPicker, MediaPickerProvider, useMediaPicker } from "./media-picker.js";
|
|
23
|
+
export { ImageField, imageFieldVariants } from "./image-field.js";
|