@vamos-ui/react 0.0.0-stage → 0.2.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 +100 -0
- package/dist/blocks/site/_kit-1.js +135 -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 +112 -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 +51 -0
- package/dist/blocks/site/feature-grid.d.ts +46 -0
- package/dist/blocks/site/feature-grid.js +49 -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 +47 -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 +67 -0
- package/dist/blocks/site/logo-strip.d.ts +42 -0
- package/dist/blocks/site/logo-strip.js +26 -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 +55 -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 +82 -0
- package/dist/blocks/site/process.d.ts +36 -0
- package/dist/blocks/site/process.js +41 -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 +97 -0
- package/dist/blocks/site/site-shell.js +227 -0
- package/dist/blocks/site/stats-band.d.ts +40 -0
- package/dist/blocks/site/stats-band.js +41 -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 +65 -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 +11 -0
- package/dist/business/index.js +20 -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/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 +42 -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/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/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 +275 -0
- package/dist/components/command.js +493 -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/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/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/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/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 +86 -0
- package/dist/index.js +87 -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 +22 -0
- package/dist/lib/public.js +33 -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 +138 -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/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 +101 -0
- package/dist/sortable/sortable-tree.js +450 -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/navigation.css +293 -0
- package/dist/styles/overlays.css +244 -0
- package/dist/styles.css +742 -0
- package/package.json +156 -4
|
@@ -0,0 +1,776 @@
|
|
|
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 { useVirtualizer } from "@tanstack/react-virtual";
|
|
5
|
+
import { Check, Copy, Download, File as FileIcon, FileArchive, FileText, Film, Folder, FolderPlus, LayoutGrid, List as ListIcon, Music, RotateCw, Search, Sparkles, Trash2, TriangleAlert, Upload, X } 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 { useControllableState, useLatest } from "../lib/use-controllable-state.js";
|
|
10
|
+
import { useContainerWidth } from "../lib/use-container-width.js";
|
|
11
|
+
import { Alert } from "../components/alert.js";
|
|
12
|
+
import { ConfirmDialog } from "../components/alert-dialog.js";
|
|
13
|
+
import { Badge } from "../components/badge.js";
|
|
14
|
+
import { Button, IconButton } from "../components/button.js";
|
|
15
|
+
import { Checkbox } from "../components/checkbox.js";
|
|
16
|
+
import { Dialog, DialogBody, DialogContent, DialogHeader } from "../components/dialog.js";
|
|
17
|
+
import { EmptyState } from "../components/empty-state.js";
|
|
18
|
+
import { Image } from "../components/image.js";
|
|
19
|
+
import { Input, Textarea } from "../components/input.js";
|
|
20
|
+
import { NativeSelect } from "../components/native-select.js";
|
|
21
|
+
import { Progress } from "../components/progress.js";
|
|
22
|
+
import { Skeleton } from "../components/skeleton.js";
|
|
23
|
+
import { FocalPointPicker } from "./focal-point.js";
|
|
24
|
+
import { useMedia } from "./media-provider.js";
|
|
25
|
+
import { DECORATIVE_TAG, acceptsMedia, extensionOf, isAltMissing, isDecorative, kindsFromAccept, monthDate, monthKey, thumbUrl } from "./media-utils.js";
|
|
26
|
+
import { countGraphemes } from "./serp.js";
|
|
27
|
+
import { useUploadQueue } from "./use-upload-queue.js";
|
|
28
|
+
/* ------------------------------------------------------------------ */
|
|
29
|
+
/* Labels */
|
|
30
|
+
/* ------------------------------------------------------------------ */
|
|
31
|
+
const libraryLabels = {
|
|
32
|
+
library: "Media library",
|
|
33
|
+
search: "Search files",
|
|
34
|
+
kind: "File type",
|
|
35
|
+
kindAll: "All types",
|
|
36
|
+
kindImage: "Images",
|
|
37
|
+
kindVideo: "Video",
|
|
38
|
+
kindAudio: "Audio",
|
|
39
|
+
kindDocument: "Documents",
|
|
40
|
+
kindArchive: "Archives",
|
|
41
|
+
kindOther: "Other",
|
|
42
|
+
month: "Date",
|
|
43
|
+
monthAll: "All dates",
|
|
44
|
+
folder: "Folder",
|
|
45
|
+
folderAll: "All folders",
|
|
46
|
+
folderRoot: "No folder",
|
|
47
|
+
uploader: "Uploaded by",
|
|
48
|
+
uploaderAll: "Anyone",
|
|
49
|
+
unattached: "Unattached",
|
|
50
|
+
sort: "Sort",
|
|
51
|
+
sortNewest: "Newest first",
|
|
52
|
+
sortOldest: "Oldest first",
|
|
53
|
+
sortName: "Name",
|
|
54
|
+
sortSize: "Largest first",
|
|
55
|
+
view: "View",
|
|
56
|
+
grid: "Grid",
|
|
57
|
+
list: "List",
|
|
58
|
+
upload: "Upload",
|
|
59
|
+
files: "Files",
|
|
60
|
+
emptyTitle: "No files yet",
|
|
61
|
+
emptyDescription: "Drop files here or upload them from your computer.",
|
|
62
|
+
noResults: "No results for “{query}”",
|
|
63
|
+
noResultsFiltered: "No files match these filters",
|
|
64
|
+
noResultsDescription: "Try another search, or clear the filters.",
|
|
65
|
+
clearFilters: "Clear filters",
|
|
66
|
+
error: "The media library could not be loaded.",
|
|
67
|
+
retry: "Retry",
|
|
68
|
+
loadMore: "Load more",
|
|
69
|
+
dropHint: "Drop files to upload",
|
|
70
|
+
count: "{count, plural, one {# file} other {# files}}",
|
|
71
|
+
selected: "{count, plural, one {# selected} other {# selected}}",
|
|
72
|
+
selectedAnnounce: "{count, plural, =0 {No files selected} one {# file selected} other {# files selected}}",
|
|
73
|
+
maxReached: "You can pick up to {max}",
|
|
74
|
+
select: "Select {name}",
|
|
75
|
+
missingAlt: "Missing alt text",
|
|
76
|
+
processing: "Processing",
|
|
77
|
+
failed: "Failed",
|
|
78
|
+
move: "Move to…",
|
|
79
|
+
moveTo: "Move selected files",
|
|
80
|
+
download: "Download",
|
|
81
|
+
delete: "Delete",
|
|
82
|
+
clearSelection: "Clear selection",
|
|
83
|
+
selectAll: "Select all",
|
|
84
|
+
deleteTitle: "{count, plural, one {Delete this file?} other {Delete # files?}}",
|
|
85
|
+
deleteDescription: "Pages that use them will show a broken image. This can't be undone.",
|
|
86
|
+
trashDescription: "They move to the trash and can be restored for 30 days.",
|
|
87
|
+
newFolder: "New folder",
|
|
88
|
+
folderName: "Folder name",
|
|
89
|
+
create: "Create",
|
|
90
|
+
colName: "Name",
|
|
91
|
+
colType: "Type",
|
|
92
|
+
colSize: "Size",
|
|
93
|
+
colDimensions: "Dimensions",
|
|
94
|
+
colUploaded: "Uploaded",
|
|
95
|
+
colAlt: "Alt text",
|
|
96
|
+
altOk: "Set",
|
|
97
|
+
altDecorative: "Decorative",
|
|
98
|
+
details: "File details",
|
|
99
|
+
};
|
|
100
|
+
const queueLabels = {
|
|
101
|
+
title: "Uploads",
|
|
102
|
+
summary: "{done} of {total} uploaded",
|
|
103
|
+
queued: "Waiting",
|
|
104
|
+
uploading: "Uploading",
|
|
105
|
+
processing: "Processing",
|
|
106
|
+
done: "Uploaded",
|
|
107
|
+
error: "Failed",
|
|
108
|
+
canceled: "Canceled",
|
|
109
|
+
cancel: "Cancel upload of {name}",
|
|
110
|
+
retry: "Retry upload of {name}",
|
|
111
|
+
dismiss: "Clear finished",
|
|
112
|
+
typeError: "This file type isn't allowed here",
|
|
113
|
+
sizeError: "File is larger than {max}",
|
|
114
|
+
};
|
|
115
|
+
const detailsLabels = {
|
|
116
|
+
title: "File details",
|
|
117
|
+
alt: "Alt text",
|
|
118
|
+
altHint: "Describe the image for people who can't see it. Leave out “image of”.",
|
|
119
|
+
altCount: "{count} / 125",
|
|
120
|
+
decorative: "Decorative image",
|
|
121
|
+
decorativeHint: "Purely visual: screen readers skip it and the alt text is cleared.",
|
|
122
|
+
suggest: "Suggest",
|
|
123
|
+
suggesting: "Suggesting…",
|
|
124
|
+
fileTitle: "Title",
|
|
125
|
+
caption: "Caption",
|
|
126
|
+
description: "Description",
|
|
127
|
+
focal: "Focal point",
|
|
128
|
+
info: "File info",
|
|
129
|
+
type: "Type",
|
|
130
|
+
size: "Size",
|
|
131
|
+
dimensions: "Dimensions",
|
|
132
|
+
duration: "Duration",
|
|
133
|
+
uploaded: "Uploaded",
|
|
134
|
+
uploadedBy: "{date} by {name}",
|
|
135
|
+
usage: "Used in",
|
|
136
|
+
usageCount: "{count, plural, =0 {Not used anywhere} one {# place} other {# places}}",
|
|
137
|
+
copyUrl: "Copy URL",
|
|
138
|
+
copied: "Copied",
|
|
139
|
+
download: "Download",
|
|
140
|
+
replace: "Replace file",
|
|
141
|
+
delete: "Delete",
|
|
142
|
+
saving: "Saving…",
|
|
143
|
+
saved: "Saved",
|
|
144
|
+
saveError: "Couldn't save. Try again.",
|
|
145
|
+
close: "Close details",
|
|
146
|
+
};
|
|
147
|
+
/* ------------------------------------------------------------------ */
|
|
148
|
+
/* Small parts */
|
|
149
|
+
/* ------------------------------------------------------------------ */
|
|
150
|
+
const KIND_ICON = {
|
|
151
|
+
image: FileIcon,
|
|
152
|
+
video: Film,
|
|
153
|
+
audio: Music,
|
|
154
|
+
document: FileText,
|
|
155
|
+
archive: FileArchive,
|
|
156
|
+
other: FileIcon,
|
|
157
|
+
};
|
|
158
|
+
/** File glyph for non-image assets: an icon over the extension. */
|
|
159
|
+
export function MediaFileGlyph({ asset, className, size = "md" }) {
|
|
160
|
+
const Icon = KIND_ICON[asset.kind];
|
|
161
|
+
return (_jsxs("span", { "data-slot": "media-file-glyph", "aria-hidden": true, className: cn("flex size-full flex-col items-center justify-center gap-1.5 text-fg-subtle", className), children: [_jsx(Icon, { "aria-hidden": true, strokeWidth: 1.4, className: size === "sm" ? "size-4" : "size-7" }), size === "md" ? _jsx("span", { className: "tabular text-[10.5px] font-semibold tracking-[0.08em] text-fg-muted", children: extensionOf(asset.filename) || asset.kind.toUpperCase() }) : null] }));
|
|
162
|
+
}
|
|
163
|
+
/** Square thumbnail for tiles, rows and trays. */
|
|
164
|
+
export function MediaThumb({ asset, className, rounded = "ui" }) {
|
|
165
|
+
const url = thumbUrl(asset);
|
|
166
|
+
return url ? (_jsx(Image, { src: { ...asset, url }, alt: "", aspect: "1/1", rounded: rounded === "ui" ? "ui" : "none", className: cn("size-full", className), sizes: "160px" })) : (_jsx("span", { className: cn("block aspect-square size-full bg-surface-2", rounded === "ui" && "rounded-ui", className), children: _jsx(MediaFileGlyph, { asset: asset, size: "sm" }) }));
|
|
167
|
+
}
|
|
168
|
+
const dimensions = (a, nf) => (a.width && a.height ? `${nf.format(a.width)} × ${nf.format(a.height)}` : "—");
|
|
169
|
+
/** Per-file progress with cancel, retry and the reason a file failed; a polite live summary. */
|
|
170
|
+
export const MediaUploadQueue = React.forwardRef(function MediaUploadQueue({ queue, variant = "inline", labels, className, ...props }, ref) {
|
|
171
|
+
const t = useLabels("mediaUploadQueue", queueLabels, labels);
|
|
172
|
+
const f = useFormat();
|
|
173
|
+
if (!queue.items.length)
|
|
174
|
+
return null;
|
|
175
|
+
const finished = queue.items.some((it) => it.status === "done" || it.status === "error" || it.status === "canceled");
|
|
176
|
+
return (_jsxs("div", { ref: ref, "data-slot": "media-upload-queue", "data-variant": variant, className: cn("surface-2 rounded-ui", variant === "panel" ? "p-4" : "p-3", className), ...props, children: [_jsxs("div", { className: "mb-2 flex items-center gap-3", children: [_jsx("span", { className: "text-[13px] font-semibold text-fg", children: t("title") }), _jsx("span", { role: "status", "aria-live": "polite", className: "tabular text-[12.5px] text-fg-muted", children: t("summary", { done: f.number(queue.done), total: f.number(queue.total) }) }), finished && !queue.active ? (_jsx(Button, { size: "xs", variant: "ghost", className: "ms-auto text-fg-muted", onClick: queue.clearDone, children: t("dismiss") })) : null] }), _jsx("ul", { className: cn("grid gap-1.5", variant === "inline" && "max-h-44 overflow-y-auto overscroll-contain pe-1"), children: queue.items.map((it) => (_jsx(MediaUploadRow, { item: it, queue: queue, t: t }, it.id))) })] }));
|
|
177
|
+
});
|
|
178
|
+
function MediaUploadRow({ item, queue, t }) {
|
|
179
|
+
const f = useFormat();
|
|
180
|
+
const nameId = React.useId();
|
|
181
|
+
const running = item.status === "queued" || item.status === "uploading" || item.status === "processing";
|
|
182
|
+
const tone = item.status === "error" ? "danger" : item.status === "done" ? "success" : "accent";
|
|
183
|
+
return (_jsxs("li", { "data-slot": "media-upload-item", "data-status": item.status, className: "grid grid-cols-[minmax(0,1fr)_auto] items-center gap-x-3 gap-y-1 rounded-ui-sm px-1 py-1", children: [_jsxs("div", { className: "flex min-w-0 items-baseline gap-2", children: [_jsx("span", { id: nameId, className: "truncate text-[13px] text-fg", children: item.file.name }), _jsx("span", { className: "tabular shrink-0 text-[11.5px] text-fg-subtle", children: f.bytes(item.file.size) })] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx("span", { className: cn("text-[12px]", item.status === "error" ? "text-danger" : item.status === "done" ? "text-success" : "text-fg-muted"), children: item.status === "uploading" ? f.percent(item.progress, { maximumFractionDigits: 0 }) : t(item.status) }), running ? (_jsx(IconButton, { label: t("cancel", { name: item.file.name }), tooltip: false, size: "xs", variant: "ghost", className: "text-fg-subtle", onClick: () => queue.cancel(item.id), children: _jsx(X, {}) })) : (item.status === "error" && !item.rejected) || item.status === "canceled" ? (_jsx(IconButton, { label: t("retry", { name: item.file.name }), tooltip: false, size: "xs", variant: "ghost", className: "text-fg-subtle", onClick: () => queue.retry(item.id), children: _jsx(RotateCw, {}) })) : null] }), item.status === "error" ? (_jsx("p", { className: "col-span-2 text-[12px] text-danger", children: item.error })) : item.status !== "canceled" ? (_jsx(Progress, { "aria-labelledby": nameId, className: "col-span-2", value: item.status === "queued" ? 0 : item.status === "processing" ? null : item.progress * 100, tone: tone })) : null] }));
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Preview, editable metadata with autosave (alt text, decorative, title, caption, description),
|
|
187
|
+
* focal point, file info, usage and actions. The body of the library's details panel.
|
|
188
|
+
*/
|
|
189
|
+
export const MediaDetails = React.forwardRef(function MediaDetails({ asset, adapter: adapterProp, onChange, onDelete, onClose, readOnly: readOnlyProp, autosaveDelay = 700, labels, className, ...props }, ref) {
|
|
190
|
+
const t = useLabels("mediaDetails", detailsLabels, labels);
|
|
191
|
+
const f = useFormat();
|
|
192
|
+
const { locale } = useLocale();
|
|
193
|
+
const ctxAdapter = useMedia();
|
|
194
|
+
const adapter = adapterProp ?? ctxAdapter;
|
|
195
|
+
const readOnly = readOnlyProp || !adapter?.capabilities.edit;
|
|
196
|
+
const [draft, setDraft] = React.useState(() => fieldsOf(asset));
|
|
197
|
+
const [save, setSave] = React.useState("idle");
|
|
198
|
+
const [suggesting, setSuggesting] = React.useState(false);
|
|
199
|
+
const [copied, setCopied] = React.useState(false);
|
|
200
|
+
const pending = React.useRef({});
|
|
201
|
+
const timer = React.useRef(undefined);
|
|
202
|
+
const onChangeRef = useLatest(onChange);
|
|
203
|
+
const replaceInput = React.useRef(null);
|
|
204
|
+
const nf = React.useMemo(() => new Intl.NumberFormat(locale), [locale]);
|
|
205
|
+
// A different asset: flush nothing, reset the form.
|
|
206
|
+
React.useEffect(() => {
|
|
207
|
+
setDraft(fieldsOf(asset));
|
|
208
|
+
setSave("idle");
|
|
209
|
+
pending.current = {};
|
|
210
|
+
clearTimeout(timer.current);
|
|
211
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
212
|
+
}, [asset.id]);
|
|
213
|
+
const flush = React.useCallback(async () => {
|
|
214
|
+
clearTimeout(timer.current);
|
|
215
|
+
const patch = pending.current;
|
|
216
|
+
if (!adapter || !Object.keys(patch).length)
|
|
217
|
+
return;
|
|
218
|
+
pending.current = {};
|
|
219
|
+
setSave("saving");
|
|
220
|
+
try {
|
|
221
|
+
const next = await adapter.update(asset.id, patch);
|
|
222
|
+
setSave("saved");
|
|
223
|
+
onChangeRef.current?.(next);
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
pending.current = { ...patch, ...pending.current };
|
|
227
|
+
setSave("error");
|
|
228
|
+
}
|
|
229
|
+
}, [adapter, asset.id, onChangeRef]);
|
|
230
|
+
React.useEffect(() => () => void flush(), [flush]);
|
|
231
|
+
const queue = (patch, immediate = false) => {
|
|
232
|
+
pending.current = { ...pending.current, ...patch };
|
|
233
|
+
clearTimeout(timer.current);
|
|
234
|
+
if (immediate)
|
|
235
|
+
void flush();
|
|
236
|
+
else
|
|
237
|
+
timer.current = setTimeout(() => void flush(), autosaveDelay);
|
|
238
|
+
};
|
|
239
|
+
const setField = (key, value) => {
|
|
240
|
+
setDraft((d) => ({ ...d, [key]: value }));
|
|
241
|
+
queue({ [key]: value });
|
|
242
|
+
};
|
|
243
|
+
const decorative = draft.tags.includes(DECORATIVE_TAG);
|
|
244
|
+
const toggleDecorative = (on) => {
|
|
245
|
+
const tags = on ? [...draft.tags.filter((x) => x !== DECORATIVE_TAG), DECORATIVE_TAG] : draft.tags.filter((x) => x !== DECORATIVE_TAG);
|
|
246
|
+
setDraft((d) => ({ ...d, tags, alt: on ? "" : d.alt }));
|
|
247
|
+
queue(on ? { tags, alt: "" } : { tags }, true);
|
|
248
|
+
};
|
|
249
|
+
const suggest = async () => {
|
|
250
|
+
if (!adapter?.suggestAlt)
|
|
251
|
+
return;
|
|
252
|
+
setSuggesting(true);
|
|
253
|
+
try {
|
|
254
|
+
const alt = await adapter.suggestAlt(asset.id);
|
|
255
|
+
setField("alt", alt);
|
|
256
|
+
}
|
|
257
|
+
finally {
|
|
258
|
+
setSuggesting(false);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
const copy = async () => {
|
|
262
|
+
try {
|
|
263
|
+
await navigator.clipboard?.writeText(asset.url);
|
|
264
|
+
setCopied(true);
|
|
265
|
+
setTimeout(() => setCopied(false), 1600);
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
/* clipboard blocked */
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
const replace = async (file) => {
|
|
272
|
+
if (!file || !adapter?.replace)
|
|
273
|
+
return;
|
|
274
|
+
setSave("saving");
|
|
275
|
+
try {
|
|
276
|
+
const next = await adapter.replace(asset.id, file, { signal: new AbortController().signal, onProgress: () => { } });
|
|
277
|
+
setSave("saved");
|
|
278
|
+
onChangeRef.current?.(next);
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
setSave("error");
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
const isImage = asset.kind === "image";
|
|
285
|
+
const altCount = countGraphemes(draft.alt, locale);
|
|
286
|
+
const altId = React.useId();
|
|
287
|
+
const altHintId = React.useId();
|
|
288
|
+
return (_jsxs("div", { ref: ref, "data-slot": "media-details", className: cn("grid content-start gap-5", className), ...props, children: [_jsxs("div", { className: "grid gap-3", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx("h3", { className: "min-w-0 flex-1 text-[14px] leading-snug font-semibold break-all text-fg", children: asset.filename }), _jsx("span", { "aria-live": "polite", className: cn("tabular shrink-0 pt-0.5 text-[11.5px]", save === "error" ? "text-danger" : "text-fg-subtle"), children: save === "saving" ? t("saving") : save === "saved" ? t("saved") : save === "error" ? t("saveError") : null }), onClose ? (_jsx(IconButton, { label: t("close"), tooltip: false, size: "xs", variant: "ghost", className: "-me-1 -mt-0.5 text-fg-subtle", onClick: onClose, children: _jsx(X, {}) })) : null] }), _jsx("div", { className: "overflow-hidden rounded-ui bg-scene", children: isImage ? (_jsx(Image, { src: asset, alt: "", fit: "contain", aspect: asset.width && asset.height && asset.width / asset.height < 0.8 ? "1/1" : "4/3", placeholder: "none", className: "w-full", sizes: "320px" })) : (_jsx("div", { className: "aspect-[4/3]", children: _jsx(MediaFileGlyph, { asset: asset }) })) })] }), isImage ? (_jsxs("div", { className: "grid gap-2", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("label", { htmlFor: altId, className: "text-[13px] font-medium text-fg", children: t("alt") }), adapter?.suggestAlt && !readOnly && !decorative ? (_jsxs(Button, { size: "xs", variant: "ghost", className: "text-fg-muted", loading: suggesting, loadingText: t("suggesting"), onClick: suggest, children: [_jsx(Sparkles, {}), t("suggest")] })) : null] }), _jsx(Textarea, { id: altId, rows: 3, value: draft.alt, disabled: decorative, readOnly: readOnly, "aria-describedby": altHintId, onChange: (e) => setField("alt", e.target.value), onBlur: () => void flush(), className: "resize-none" }), _jsxs("div", { id: altHintId, className: "flex items-start justify-between gap-3 text-[12px] text-fg-muted", children: [_jsx("span", { className: cn(!decorative && !draft.alt.trim() && "text-warning"), children: !decorative && !draft.alt.trim() ? (_jsxs("span", { className: "inline-flex items-center gap-1", children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "size-3.5" }), t("altHint")] })) : (t("altHint")) }), _jsx("span", { className: cn("tabular shrink-0", altCount > 125 && "text-warning"), children: t("altCount", { count: nf.format(altCount) }) })] }), _jsx(Checkbox, { size: "sm", label: t("decorative"), description: t("decorativeHint"), checked: decorative, disabled: readOnly, onCheckedChange: (c) => toggleDecorative(c === true) })] })) : null, _jsxs("div", { className: "grid gap-3", children: [_jsx(DetailsText, { label: t("fileTitle"), value: draft.title, readOnly: readOnly, onChange: (v) => setField("title", v), onBlur: flush }), _jsx(DetailsText, { label: t("caption"), value: draft.caption, readOnly: readOnly, multiline: true, onChange: (v) => setField("caption", v), onBlur: flush }), _jsx(DetailsText, { label: t("description"), value: draft.description, readOnly: readOnly, multiline: true, onChange: (v) => setField("description", v), onBlur: flush })] }), isImage && !readOnly ? (_jsxs("div", { className: "grid gap-2", children: [_jsx("span", { className: "text-[13px] font-medium text-fg", children: t("focal") }), _jsx(FocalPointPicker, { src: asset, previews: ["1/1", "16/9", "4/5"], maxHeight: "12rem", onValueCommit: (focalPoint) => queue({ focalPoint }, true) }, asset.id)] })) : null, _jsx("section", { "aria-label": t("info"), className: "grid gap-2", children: _jsxs("dl", { className: "grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1.5 text-[12.5px]", children: [_jsx("dt", { className: "text-fg-muted", children: t("type") }), _jsx("dd", { className: "m-0 truncate text-fg", children: asset.mime }), _jsx("dt", { className: "text-fg-muted", children: t("size") }), _jsx("dd", { className: "tabular m-0 text-fg", children: f.bytes(asset.size) }), asset.width && asset.height ? (_jsxs(_Fragment, { children: [_jsx("dt", { className: "text-fg-muted", children: t("dimensions") }), _jsxs("dd", { className: "tabular m-0 text-fg", children: [dimensions(asset, nf), " px"] })] })) : null, asset.duration ? (_jsxs(_Fragment, { children: [_jsx("dt", { className: "text-fg-muted", children: t("duration") }), _jsx("dd", { className: "tabular m-0 text-fg", children: f.duration(asset.duration) })] })) : null, _jsx("dt", { className: "text-fg-muted", children: t("uploaded") }), _jsx("dd", { className: "m-0 text-fg", children: asset.uploadedBy ? t("uploadedBy", { date: f.date(asset.createdAt), name: asset.uploadedBy.name }) : f.date(asset.createdAt) }), asset.usage ? (_jsxs(_Fragment, { children: [_jsx("dt", { className: "text-fg-muted", children: t("usage") }), _jsx("dd", { className: "m-0 text-fg", children: asset.usage.items?.length ? (_jsx("ul", { className: "grid gap-0.5", children: asset.usage.items.map((u) => (_jsxs("li", { className: "truncate", children: [u.href ? (_jsx("a", { href: u.href, className: "focus-ring rounded-sm text-fg underline decoration-line underline-offset-2 hover:decoration-fg", children: u.title })) : (u.title), _jsx("span", { className: "ms-1.5 text-fg-subtle", children: u.type })] }, u.type + u.id))) })) : (t("usageCount", { count: asset.usage.count })) })] })) : null] }) }), _jsxs("div", { className: "flex flex-wrap gap-1.5 border-t border-line pt-4", children: [_jsxs(Button, { size: "sm", onClick: copy, children: [copied ? _jsx(Check, {}) : _jsx(Copy, {}), copied ? t("copied") : t("copyUrl")] }), _jsx(Button, { size: "sm", asChild: true, children: _jsxs("a", { href: asset.url, download: asset.filename, children: [_jsx(Download, {}), t("download")] }) }), !readOnly && adapter?.replace && adapter.capabilities.replace ? (_jsxs(_Fragment, { children: [_jsxs(Button, { size: "sm", onClick: () => replaceInput.current?.click(), children: [_jsx(RotateCw, {}), t("replace")] }), _jsx("input", { ref: replaceInput, type: "file", hidden: true, tabIndex: -1, accept: asset.mime, onChange: (e) => void replace(e.target.files?.[0]) })] })) : null, onDelete && !readOnly ? (_jsxs(Button, { size: "sm", variant: "danger-ghost", className: "ms-auto", onClick: () => onDelete(asset), children: [_jsx(Trash2, {}), t("delete")] })) : null] })] }));
|
|
289
|
+
});
|
|
290
|
+
function fieldsOf(a) {
|
|
291
|
+
return { alt: a.alt ?? "", title: a.title ?? "", caption: a.caption ?? "", description: a.description ?? "", tags: a.tags ?? [] };
|
|
292
|
+
}
|
|
293
|
+
function DetailsText({ label, value, onChange, onBlur, readOnly, multiline }) {
|
|
294
|
+
const id = React.useId();
|
|
295
|
+
return (_jsxs("div", { className: "grid gap-1.5", children: [_jsx("label", { htmlFor: id, className: "text-[13px] font-medium text-fg", children: label }), multiline ? (_jsx(Textarea, { id: id, rows: 2, value: value, readOnly: readOnly, onChange: (e) => onChange(e.target.value), onBlur: onBlur, className: "resize-none" })) : (_jsx(Input, { id: id, size: "sm", value: value, readOnly: readOnly, onChange: (e) => onChange(e.target.value), onBlur: onBlur }))] }));
|
|
296
|
+
}
|
|
297
|
+
const TILE_MIN = { sm: 104, md: 148, lg: 212 };
|
|
298
|
+
const GRID_GAP = 12;
|
|
299
|
+
/**
|
|
300
|
+
* Browse, search, filter, upload, edit and delete files through any `MediaAdapter`: grid or list,
|
|
301
|
+
* folders, an upload queue with progress, a details panel with alt text and focal point, bulk
|
|
302
|
+
* actions, and a virtualised grid for large libraries. Also the body of Media picker.
|
|
303
|
+
*
|
|
304
|
+
* ```tsx
|
|
305
|
+
* <MediaProvider adapter={createRestAdapter({ baseUrl: "/api" })}>
|
|
306
|
+
* <MediaLibrary selection="multiple" detailsPanel="side" onQueryChange={syncToUrl} />
|
|
307
|
+
* </MediaProvider>
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* Keyboard (grid): arrows move, Space selects, Shift + arrows extends, Ctrl/⌘ + A selects all,
|
|
311
|
+
* Enter opens details, Delete asks to delete, Esc clears the selection.
|
|
312
|
+
*/
|
|
313
|
+
export const MediaLibrary = React.forwardRef(function MediaLibrary({ adapter: adapterProp, view: viewProp, defaultView = "grid", onViewChange, query: queryProp, defaultQuery, onQueryChange, selection = "multiple", selected: selectedProp, defaultSelected, onSelectedChange, accept, max, detailsPanel = "side", folders: foldersMode, pageSize = 60, tileSize = "md", height = "34rem", virtualizeAfter = 120, readOnly: readOnlyProp, selectUploaded = false, maxDimension, emptyState, searchRef, toolbar = true, onDeleted, handleRef, labels, queueLabels: queueLabelsProp, detailsLabels: detailsLabelsProp, className, ...props }, ref) {
|
|
314
|
+
const t = useLabels("mediaLibrary", libraryLabels, labels);
|
|
315
|
+
const tq = useLabels("mediaUploadQueue", queueLabels, queueLabelsProp);
|
|
316
|
+
const f = useFormat();
|
|
317
|
+
const { locale } = useLocale();
|
|
318
|
+
const ctxAdapter = useMedia();
|
|
319
|
+
const adapter = adapterProp ?? ctxAdapter;
|
|
320
|
+
const caps = adapter?.capabilities;
|
|
321
|
+
const canUpload = Boolean(adapter) && !readOnlyProp;
|
|
322
|
+
const canEdit = Boolean(caps?.edit) && !readOnlyProp;
|
|
323
|
+
const hasFolders = Boolean(adapter?.folders && caps?.folders);
|
|
324
|
+
const folderMode = foldersMode === undefined ? (hasFolders ? "select" : false) : hasFolders ? foldersMode : false;
|
|
325
|
+
const [view, setView] = useControllableState({ value: viewProp, defaultValue: defaultView, onChange: onViewChange, name: "MediaLibrary" });
|
|
326
|
+
const [query, setQuery] = useControllableState({ value: queryProp, defaultValue: defaultQuery ?? {}, onChange: onQueryChange, name: "MediaLibrary" });
|
|
327
|
+
const known = React.useRef(new Map());
|
|
328
|
+
const emitSelected = React.useCallback((ids) => onSelectedChange?.(ids, ids.map((id) => known.current.get(id)).filter((a) => Boolean(a))), [onSelectedChange]);
|
|
329
|
+
const [selected, setSelectedRaw] = useControllableState({ value: selectedProp, defaultValue: defaultSelected ?? [], onChange: emitSelected, name: "MediaLibrary" });
|
|
330
|
+
const [items, setItems] = React.useState([]);
|
|
331
|
+
const [status, setStatus] = React.useState("loading");
|
|
332
|
+
const [cursor, setCursor] = React.useState();
|
|
333
|
+
const [total, setTotal] = React.useState();
|
|
334
|
+
const [loadingMore, setLoadingMore] = React.useState(false);
|
|
335
|
+
const [reload, setReload] = React.useState(0);
|
|
336
|
+
const [folders, setFolders] = React.useState([]);
|
|
337
|
+
const [months, setMonths] = React.useState([]);
|
|
338
|
+
const [uploaders, setUploaders] = React.useState([]);
|
|
339
|
+
const [activeId, setActiveId] = React.useState(null);
|
|
340
|
+
const [focusIndex, setFocusIndex] = React.useState(0);
|
|
341
|
+
const [anchor, setAnchor] = React.useState(null);
|
|
342
|
+
const [confirm, setConfirm] = React.useState(null);
|
|
343
|
+
const [dragDepth, setDragDepth] = React.useState(0);
|
|
344
|
+
const [search, setSearch] = React.useState(query.search ?? "");
|
|
345
|
+
const fileInput = React.useRef(null);
|
|
346
|
+
const gridRef = React.useRef(null);
|
|
347
|
+
const scrollRef = React.useRef(null);
|
|
348
|
+
const { ref: measureRef, width } = useContainerWidth();
|
|
349
|
+
const remember = React.useCallback((list) => list.forEach((a) => known.current.set(a.id, a)), []);
|
|
350
|
+
const effective = React.useMemo(() => {
|
|
351
|
+
const kinds = query.kind ?? kindsFromAccept(accept);
|
|
352
|
+
return { ...query, kind: kinds, accept: accept ?? query.accept, limit: pageSize, cursor: undefined };
|
|
353
|
+
}, [query, accept, pageSize]);
|
|
354
|
+
const queryKey = JSON.stringify(effective);
|
|
355
|
+
// Load the first page whenever the query changes.
|
|
356
|
+
React.useEffect(() => {
|
|
357
|
+
if (!adapter)
|
|
358
|
+
return;
|
|
359
|
+
const ctrl = new AbortController();
|
|
360
|
+
setStatus("loading");
|
|
361
|
+
adapter
|
|
362
|
+
.list(effective, { signal: ctrl.signal })
|
|
363
|
+
.then((page) => {
|
|
364
|
+
if (ctrl.signal.aborted)
|
|
365
|
+
return;
|
|
366
|
+
remember(page.items);
|
|
367
|
+
setItems(page.items);
|
|
368
|
+
setCursor(page.nextCursor);
|
|
369
|
+
setTotal(page.total);
|
|
370
|
+
setStatus("ready");
|
|
371
|
+
setMonths((m) => [...new Set([...m, ...page.items.map((a) => monthKey(a.createdAt))])].sort().reverse());
|
|
372
|
+
setUploaders((u) => {
|
|
373
|
+
const map = new Map(u.map((x) => [x.id, x]));
|
|
374
|
+
page.items.forEach((a) => a.uploadedBy && map.set(a.uploadedBy.id, { id: a.uploadedBy.id, name: a.uploadedBy.name }));
|
|
375
|
+
return [...map.values()];
|
|
376
|
+
});
|
|
377
|
+
})
|
|
378
|
+
.catch((err) => {
|
|
379
|
+
if (!ctrl.signal.aborted && err?.name !== "AbortError")
|
|
380
|
+
setStatus("error");
|
|
381
|
+
});
|
|
382
|
+
return () => ctrl.abort();
|
|
383
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
384
|
+
}, [adapter, queryKey, reload, remember]);
|
|
385
|
+
React.useEffect(() => {
|
|
386
|
+
if (!adapter?.folders || !hasFolders)
|
|
387
|
+
return;
|
|
388
|
+
let live = true;
|
|
389
|
+
adapter.folders.list().then((list) => live && setFolders(list)).catch(() => { });
|
|
390
|
+
return () => {
|
|
391
|
+
live = false;
|
|
392
|
+
};
|
|
393
|
+
}, [adapter, hasFolders, reload]);
|
|
394
|
+
React.useEffect(() => {
|
|
395
|
+
if (!adapter?.subscribe)
|
|
396
|
+
return;
|
|
397
|
+
return adapter.subscribe((e) => {
|
|
398
|
+
if (e.type === "removed" && e.id)
|
|
399
|
+
setItems((list) => list.filter((a) => a.id !== e.id));
|
|
400
|
+
else if (e.asset) {
|
|
401
|
+
const asset = e.asset;
|
|
402
|
+
remember([asset]);
|
|
403
|
+
setItems((list) => (list.some((a) => a.id === asset.id) ? list.map((a) => (a.id === asset.id ? asset : a)) : list));
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
}, [adapter, remember]);
|
|
407
|
+
const loadMore = React.useCallback(async () => {
|
|
408
|
+
if (!adapter || !cursor || loadingMore)
|
|
409
|
+
return;
|
|
410
|
+
setLoadingMore(true);
|
|
411
|
+
try {
|
|
412
|
+
const page = await adapter.list({ ...effective, cursor });
|
|
413
|
+
remember(page.items);
|
|
414
|
+
setItems((list) => [...list, ...page.items.filter((a) => !list.some((b) => b.id === a.id))]);
|
|
415
|
+
setCursor(page.nextCursor);
|
|
416
|
+
}
|
|
417
|
+
catch {
|
|
418
|
+
/* keep the button; the user can retry */
|
|
419
|
+
}
|
|
420
|
+
finally {
|
|
421
|
+
setLoadingMore(false);
|
|
422
|
+
}
|
|
423
|
+
}, [adapter, cursor, effective, loadingMore, remember]);
|
|
424
|
+
// Debounced search → query.
|
|
425
|
+
const queryRef = useLatest(query);
|
|
426
|
+
React.useEffect(() => {
|
|
427
|
+
if ((queryRef.current.search ?? "") === search)
|
|
428
|
+
return;
|
|
429
|
+
const id = setTimeout(() => setQuery({ ...queryRef.current, search: search || undefined, cursor: undefined }), 250);
|
|
430
|
+
return () => clearTimeout(id);
|
|
431
|
+
}, [search, setQuery, queryRef]);
|
|
432
|
+
React.useEffect(() => {
|
|
433
|
+
setSearch(query.search ?? "");
|
|
434
|
+
}, [query.search]);
|
|
435
|
+
const patchQuery = (p) => setQuery({ ...query, ...p, cursor: undefined });
|
|
436
|
+
const filtered = Boolean(query.search || query.kind || query.month || query.folderId !== undefined || query.uploadedBy || query.unattached);
|
|
437
|
+
/* ---- selection ---- */
|
|
438
|
+
const atMax = selection === "multiple" && max !== undefined && selected.length >= max;
|
|
439
|
+
const setSelected = (ids) => {
|
|
440
|
+
const unique = [...new Set(ids)];
|
|
441
|
+
setSelectedRaw(selection === "single" ? unique.slice(-1) : max !== undefined ? unique.slice(0, max) : unique);
|
|
442
|
+
};
|
|
443
|
+
const isDisabled = (a) => selection !== "none" && ((accept && !acceptsMedia(accept, a)) || (atMax && !selected.includes(a.id)));
|
|
444
|
+
const toggle = (index, range = false) => {
|
|
445
|
+
const a = items[index];
|
|
446
|
+
if (!a || selection === "none" || isDisabled(a))
|
|
447
|
+
return;
|
|
448
|
+
if (selection === "single") {
|
|
449
|
+
setSelected(selected.includes(a.id) ? [] : [a.id]);
|
|
450
|
+
}
|
|
451
|
+
else if (range && anchor !== null) {
|
|
452
|
+
const [from, to] = anchor < index ? [anchor, index] : [index, anchor];
|
|
453
|
+
setSelected([...selected, ...items.slice(from, to + 1).filter((x) => !isDisabled(x) || selected.includes(x.id)).map((x) => x.id)]);
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
setSelected(selected.includes(a.id) ? selected.filter((id) => id !== a.id) : [...selected, a.id]);
|
|
457
|
+
setAnchor(index);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
const openDetails = (a) => {
|
|
461
|
+
if (detailsPanel)
|
|
462
|
+
setActiveId(a.id);
|
|
463
|
+
};
|
|
464
|
+
/* ---- uploads ---- */
|
|
465
|
+
const uploadQueue = useUploadQueue(adapter, {
|
|
466
|
+
accept,
|
|
467
|
+
maxDimension,
|
|
468
|
+
messages: { type: tq("typeError"), size: tq("sizeError", { max: caps?.maxFileSize ? f.bytes(caps.maxFileSize) : "" }) },
|
|
469
|
+
onUploaded: (asset) => {
|
|
470
|
+
remember([asset]);
|
|
471
|
+
setItems((list) => [asset, ...list.filter((a) => a.id !== asset.id)]);
|
|
472
|
+
setTotal((n) => (n === undefined ? n : n + 1));
|
|
473
|
+
if (selectUploaded && selection !== "none")
|
|
474
|
+
setSelectedRaw((prev) => (selection === "single" ? [asset.id] : max !== undefined && prev.length >= max ? prev : [...prev, asset.id]));
|
|
475
|
+
},
|
|
476
|
+
});
|
|
477
|
+
const addFiles = (files) => {
|
|
478
|
+
if (!files || !Array.from(files).length || !canUpload)
|
|
479
|
+
return;
|
|
480
|
+
uploadQueue.add(files, { folderId: query.folderId ?? null });
|
|
481
|
+
};
|
|
482
|
+
React.useImperativeHandle(handleRef, () => ({
|
|
483
|
+
addFiles: (files) => addFiles(files),
|
|
484
|
+
addAssets: (assets, o) => {
|
|
485
|
+
remember(assets);
|
|
486
|
+
setItems((list) => [...assets, ...list.filter((a) => !assets.some((b) => b.id === a.id))]);
|
|
487
|
+
if (o?.select && selection !== "none")
|
|
488
|
+
setSelected(selection === "single" ? assets.slice(-1).map((a) => a.id) : [...selected, ...assets.map((a) => a.id)]);
|
|
489
|
+
},
|
|
490
|
+
openFileDialog: () => fileInput.current?.click(),
|
|
491
|
+
reload: () => setReload((n) => n + 1),
|
|
492
|
+
}));
|
|
493
|
+
/* ---- delete ---- */
|
|
494
|
+
const remove = async (ids) => {
|
|
495
|
+
if (!adapter)
|
|
496
|
+
return;
|
|
497
|
+
await adapter.remove(ids, { permanent: !caps?.trash });
|
|
498
|
+
setItems((list) => list.filter((a) => !ids.includes(a.id)));
|
|
499
|
+
setTotal((n) => (n === undefined ? n : Math.max(0, n - ids.length)));
|
|
500
|
+
setSelected(selected.filter((id) => !ids.includes(id)));
|
|
501
|
+
if (activeId && ids.includes(activeId))
|
|
502
|
+
setActiveId(null);
|
|
503
|
+
onDeleted?.(ids);
|
|
504
|
+
};
|
|
505
|
+
const moveTo = async (folderId) => {
|
|
506
|
+
if (!adapter)
|
|
507
|
+
return;
|
|
508
|
+
const ids = [...selected];
|
|
509
|
+
const updated = await Promise.all(ids.map((id) => adapter.update(id, { folderId })));
|
|
510
|
+
remember(updated);
|
|
511
|
+
setItems((list) => list.map((a) => updated.find((u) => u.id === a.id) ?? a).filter((a) => query.folderId === undefined || (a.folderId ?? null) === query.folderId));
|
|
512
|
+
setReload((n) => (query.folderId === undefined ? n : n + 1));
|
|
513
|
+
};
|
|
514
|
+
const downloadSelected = () => {
|
|
515
|
+
selected.forEach((id) => {
|
|
516
|
+
const a = known.current.get(id);
|
|
517
|
+
if (!a)
|
|
518
|
+
return;
|
|
519
|
+
const link = document.createElement("a");
|
|
520
|
+
link.href = a.url;
|
|
521
|
+
link.download = a.filename;
|
|
522
|
+
link.rel = "noopener";
|
|
523
|
+
document.body.appendChild(link);
|
|
524
|
+
link.click();
|
|
525
|
+
link.remove();
|
|
526
|
+
});
|
|
527
|
+
};
|
|
528
|
+
/* ---- grid geometry ---- */
|
|
529
|
+
const tile = TILE_MIN[tileSize];
|
|
530
|
+
const cols = width ? Math.max(1, Math.floor((width + GRID_GAP) / (tile + GRID_GAP))) : tileSize === "lg" ? 3 : tileSize === "sm" ? 6 : 4;
|
|
531
|
+
const rows = React.useMemo(() => {
|
|
532
|
+
const out = [];
|
|
533
|
+
for (let i = 0; i < items.length; i += cols)
|
|
534
|
+
out.push(items.slice(i, i + cols));
|
|
535
|
+
return out;
|
|
536
|
+
}, [items, cols]);
|
|
537
|
+
const virtual = items.length > virtualizeAfter;
|
|
538
|
+
const colWidth = width ? (width - GRID_GAP * (cols - 1)) / cols : tile;
|
|
539
|
+
const virtualizer = useVirtualizer({
|
|
540
|
+
count: virtual ? rows.length : 0,
|
|
541
|
+
getScrollElement: () => scrollRef.current,
|
|
542
|
+
estimateSize: () => colWidth + 30 + GRID_GAP,
|
|
543
|
+
overscan: 3,
|
|
544
|
+
});
|
|
545
|
+
const focusTile = React.useCallback((index) => {
|
|
546
|
+
const clamped = Math.max(0, Math.min(items.length - 1, index));
|
|
547
|
+
setFocusIndex(clamped);
|
|
548
|
+
if (virtual)
|
|
549
|
+
virtualizer.scrollToIndex(Math.floor(clamped / cols), { align: "auto" });
|
|
550
|
+
requestAnimationFrame(() => {
|
|
551
|
+
const el = gridRef.current?.querySelector(`[data-tile="${clamped}"]`);
|
|
552
|
+
el?.focus({ preventScroll: virtual });
|
|
553
|
+
if (!virtual)
|
|
554
|
+
el?.scrollIntoView?.({ block: "nearest" });
|
|
555
|
+
});
|
|
556
|
+
}, [items.length, virtual, virtualizer, cols]);
|
|
557
|
+
React.useEffect(() => {
|
|
558
|
+
if (focusIndex > items.length - 1)
|
|
559
|
+
setFocusIndex(Math.max(0, items.length - 1));
|
|
560
|
+
}, [items.length, focusIndex]);
|
|
561
|
+
const onGridKeyDown = (e) => {
|
|
562
|
+
const target = e.target.closest("[data-tile]");
|
|
563
|
+
if (!target)
|
|
564
|
+
return;
|
|
565
|
+
const index = Number(target.dataset.tile);
|
|
566
|
+
const mod = e.metaKey || e.ctrlKey;
|
|
567
|
+
let next = null;
|
|
568
|
+
switch (e.key) {
|
|
569
|
+
case "ArrowRight":
|
|
570
|
+
next = index + 1;
|
|
571
|
+
break;
|
|
572
|
+
case "ArrowLeft":
|
|
573
|
+
next = index - 1;
|
|
574
|
+
break;
|
|
575
|
+
case "ArrowDown":
|
|
576
|
+
next = index + cols;
|
|
577
|
+
break;
|
|
578
|
+
case "ArrowUp":
|
|
579
|
+
next = index - cols;
|
|
580
|
+
break;
|
|
581
|
+
case "Home":
|
|
582
|
+
next = mod ? 0 : index - (index % cols);
|
|
583
|
+
break;
|
|
584
|
+
case "End":
|
|
585
|
+
next = mod ? items.length - 1 : Math.min(items.length - 1, index - (index % cols) + cols - 1);
|
|
586
|
+
break;
|
|
587
|
+
case "PageDown":
|
|
588
|
+
next = index + cols * 3;
|
|
589
|
+
break;
|
|
590
|
+
case "PageUp":
|
|
591
|
+
next = index - cols * 3;
|
|
592
|
+
break;
|
|
593
|
+
case " ":
|
|
594
|
+
e.preventDefault();
|
|
595
|
+
if (selection === "none")
|
|
596
|
+
openDetails(items[index]);
|
|
597
|
+
else
|
|
598
|
+
toggle(index, e.shiftKey);
|
|
599
|
+
return;
|
|
600
|
+
case "Enter":
|
|
601
|
+
e.preventDefault();
|
|
602
|
+
if (detailsPanel)
|
|
603
|
+
openDetails(items[index]);
|
|
604
|
+
else
|
|
605
|
+
toggle(index);
|
|
606
|
+
return;
|
|
607
|
+
case "Delete":
|
|
608
|
+
case "Backspace":
|
|
609
|
+
if (!canUpload)
|
|
610
|
+
return;
|
|
611
|
+
e.preventDefault();
|
|
612
|
+
setConfirm(selected.length && selected.includes(items[index].id) ? [...selected] : [items[index].id]);
|
|
613
|
+
return;
|
|
614
|
+
case "Escape":
|
|
615
|
+
if (selected.length && selection !== "none") {
|
|
616
|
+
e.preventDefault();
|
|
617
|
+
e.stopPropagation();
|
|
618
|
+
setSelected([]);
|
|
619
|
+
}
|
|
620
|
+
return;
|
|
621
|
+
case "a":
|
|
622
|
+
case "A":
|
|
623
|
+
if (mod && selection === "multiple") {
|
|
624
|
+
e.preventDefault();
|
|
625
|
+
setSelected(items.filter((a) => !isDisabled(a) || selected.includes(a.id)).map((a) => a.id));
|
|
626
|
+
}
|
|
627
|
+
return;
|
|
628
|
+
default:
|
|
629
|
+
return;
|
|
630
|
+
}
|
|
631
|
+
if (next === null)
|
|
632
|
+
return;
|
|
633
|
+
e.preventDefault();
|
|
634
|
+
next = Math.max(0, Math.min(items.length - 1, next));
|
|
635
|
+
if (e.shiftKey && selection === "multiple") {
|
|
636
|
+
const from = anchor ?? index;
|
|
637
|
+
const [lo, hi] = from < next ? [from, next] : [next, from];
|
|
638
|
+
setAnchor(from);
|
|
639
|
+
setSelected([...selected.filter((id) => !items.slice(lo, hi + 1).some((a) => a.id === id)), ...items.slice(lo, hi + 1).filter((a) => !isDisabled(a)).map((a) => a.id)]);
|
|
640
|
+
}
|
|
641
|
+
else if (!e.shiftKey)
|
|
642
|
+
setAnchor(next);
|
|
643
|
+
focusTile(next);
|
|
644
|
+
};
|
|
645
|
+
const onTileClick = (e, index) => {
|
|
646
|
+
const a = items[index];
|
|
647
|
+
setFocusIndex(index);
|
|
648
|
+
if (selection === "none")
|
|
649
|
+
return openDetails(a);
|
|
650
|
+
if (e.shiftKey)
|
|
651
|
+
toggle(index, true);
|
|
652
|
+
else
|
|
653
|
+
toggle(index);
|
|
654
|
+
if (detailsPanel === "side")
|
|
655
|
+
setActiveId(a.id);
|
|
656
|
+
};
|
|
657
|
+
/* ---- drag & drop / paste ---- */
|
|
658
|
+
const dropHandlers = canUpload
|
|
659
|
+
? {
|
|
660
|
+
onDragEnter: (e) => {
|
|
661
|
+
if (!Array.from(e.dataTransfer?.types ?? []).includes("Files"))
|
|
662
|
+
return;
|
|
663
|
+
e.preventDefault();
|
|
664
|
+
setDragDepth((d) => d + 1);
|
|
665
|
+
},
|
|
666
|
+
onDragOver: (e) => {
|
|
667
|
+
if (Array.from(e.dataTransfer?.types ?? []).includes("Files"))
|
|
668
|
+
e.preventDefault();
|
|
669
|
+
},
|
|
670
|
+
onDragLeave: () => setDragDepth((d) => Math.max(0, d - 1)),
|
|
671
|
+
onDrop: (e) => {
|
|
672
|
+
if (!e.dataTransfer?.files?.length)
|
|
673
|
+
return;
|
|
674
|
+
e.preventDefault();
|
|
675
|
+
setDragDepth(0);
|
|
676
|
+
addFiles(e.dataTransfer.files);
|
|
677
|
+
},
|
|
678
|
+
onPaste: (e) => {
|
|
679
|
+
const target = e.target;
|
|
680
|
+
if (target.closest("input, textarea, [contenteditable=true]"))
|
|
681
|
+
return;
|
|
682
|
+
if (e.clipboardData?.files?.length) {
|
|
683
|
+
e.preventDefault();
|
|
684
|
+
addFiles(e.clipboardData.files);
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
}
|
|
688
|
+
: {};
|
|
689
|
+
const active = activeId ? items.find((a) => a.id === activeId) ?? known.current.get(activeId) : undefined;
|
|
690
|
+
const onAssetChange = (next) => {
|
|
691
|
+
remember([next]);
|
|
692
|
+
setItems((list) => list.map((a) => (a.id === next.id ? next : a)));
|
|
693
|
+
};
|
|
694
|
+
const nf = React.useMemo(() => new Intl.NumberFormat(locale), [locale]);
|
|
695
|
+
const monthFmt = React.useMemo(() => new Intl.DateTimeFormat(locale, { month: "long", year: "numeric", timeZone: "UTC" }), [locale]);
|
|
696
|
+
const kindOptions = [
|
|
697
|
+
{ value: "", label: t("kindAll") },
|
|
698
|
+
{ value: "image", label: t("kindImage") },
|
|
699
|
+
{ value: "video", label: t("kindVideo") },
|
|
700
|
+
{ value: "audio", label: t("kindAudio") },
|
|
701
|
+
{ value: "document", label: t("kindDocument") },
|
|
702
|
+
{ value: "archive", label: t("kindArchive") },
|
|
703
|
+
];
|
|
704
|
+
const lockedKinds = kindsFromAccept(accept);
|
|
705
|
+
const kindValue = Array.isArray(query.kind) ? query.kind[0] ?? "" : query.kind ?? "";
|
|
706
|
+
const monthList = query.month && !months.includes(query.month) ? [query.month, ...months] : months;
|
|
707
|
+
const liveId = React.useId();
|
|
708
|
+
/* ---- render parts ---- */
|
|
709
|
+
const toolbarEl = toolbar ? (_jsxs("div", { "data-slot": "media-toolbar", role: "search", "aria-label": t("library"), className: "flex flex-wrap items-center gap-2 border-b border-line px-4 py-3", children: [_jsx(Input, { ref: searchRef, type: "search", size: "sm", "aria-label": t("search"), placeholder: t("search"), value: search, onChange: (e) => setSearch(e.target.value), leading: _jsx(Search, { "aria-hidden": true }), clearable: true, onClear: () => setSearch(""), className: "min-w-44 flex-[1_1_14rem] @3xl:max-w-[22rem]", "data-autofocus": true }), !lockedKinds || lockedKinds.length > 1 ? (_jsx(NativeSelect, { size: "sm", "aria-label": t("kind"), value: kindValue, onChange: (e) => patchQuery({ kind: (e.target.value || undefined) }), items: lockedKinds ? kindOptions.filter((o) => !o.value || lockedKinds.includes(o.value)) : kindOptions, className: "w-auto" })) : null, _jsx(NativeSelect, { size: "sm", "aria-label": t("month"), value: query.month ?? "", onChange: (e) => patchQuery({ month: e.target.value || undefined }), items: [{ value: "", label: t("monthAll") }, ...monthList.map((m) => ({ value: m, label: monthFmt.format(monthDate(m)) }))], className: "w-auto" }), folderMode === "select" ? (_jsx(NativeSelect, { size: "sm", "aria-label": t("folder"), value: query.folderId === undefined ? "__all" : query.folderId === null ? "__root" : query.folderId, onChange: (e) => patchQuery({ folderId: e.target.value === "__all" ? undefined : e.target.value === "__root" ? null : e.target.value }), items: [{ value: "__all", label: t("folderAll") }, { value: "__root", label: t("folderRoot") }, ...folders.map((fo) => ({ value: fo.id, label: fo.name }))], className: "w-auto" })) : null, uploaders.length > 1 ? (_jsx(NativeSelect, { size: "sm", "aria-label": t("uploader"), value: query.uploadedBy ?? "", onChange: (e) => patchQuery({ uploadedBy: e.target.value || undefined }), items: [{ value: "", label: t("uploaderAll") }, ...uploaders.map((u) => ({ value: u.id, label: u.name }))], className: "w-auto" })) : null, _jsx(Button, { size: "sm", variant: "ghost", "aria-pressed": Boolean(query.unattached), className: cn("text-fg-muted", query.unattached && "bg-selected text-fg"), onClick: () => patchQuery({ unattached: query.unattached ? undefined : true }), children: t("unattached") }), _jsxs("div", { className: "ms-auto flex items-center gap-2", children: [_jsx(NativeSelect, { size: "sm", variant: "ghost", "aria-label": t("sort"), value: query.sort ?? "newest", onChange: (e) => patchQuery({ sort: e.target.value }), items: [
|
|
710
|
+
{ value: "newest", label: t("sortNewest") },
|
|
711
|
+
{ value: "oldest", label: t("sortOldest") },
|
|
712
|
+
{ value: "name", label: t("sortName") },
|
|
713
|
+
{ value: "size", label: t("sortSize") },
|
|
714
|
+
], className: "w-auto min-w-[8.5rem]" }), _jsxs("div", { role: "group", "aria-label": t("view"), className: "flex items-center rounded-ui-sm bg-surface-2 p-0.5", children: [_jsx(IconButton, { label: t("grid"), size: "xs", variant: "ghost", "aria-pressed": view === "grid", className: cn("text-fg-muted", view === "grid" && "bg-surface text-fg shadow-sm"), onClick: () => setView("grid"), children: _jsx(LayoutGrid, {}) }), _jsx(IconButton, { label: t("list"), size: "xs", variant: "ghost", "aria-pressed": view === "list", className: cn("text-fg-muted", view === "list" && "bg-surface text-fg shadow-sm"), onClick: () => setView("list"), children: _jsx(ListIcon, {}) })] }), canUpload ? (_jsxs(Button, { size: "sm", variant: selection === "none" ? "primary" : "secondary", onClick: () => fileInput.current?.click(), children: [_jsx(Upload, {}), t("upload")] })) : null] })] })) : null;
|
|
715
|
+
const bulkBar = selection === "multiple" && selected.length > 0 ? (_jsxs("div", { "data-slot": "media-bulk-bar", className: "flex flex-wrap items-center gap-2 border-b border-line bg-surface-2 px-4 py-2", children: [_jsx("span", { className: "tabular text-[13px] font-medium text-fg", children: t("selected", { count: selected.length }) }), atMax ? _jsxs("span", { className: "text-[12px] text-fg-muted", children: ["\u00B7 ", t("maxReached", { max: nf.format(max) })] }) : null, _jsxs("div", { className: "ms-auto flex flex-wrap items-center gap-1.5", children: [selection === "multiple" && !max ? (_jsx(Button, { size: "xs", variant: "ghost", className: "text-fg-muted", onClick: () => setSelected(items.filter((a) => !isDisabled(a) || selected.includes(a.id)).map((a) => a.id)), children: t("selectAll") })) : null, canEdit && hasFolders && caps?.bulk ? (_jsx(NativeSelect, { size: "sm", variant: "ghost", "aria-label": t("moveTo"), value: "", onChange: (e) => e.target.value && void moveTo(e.target.value === "__root" ? null : e.target.value), items: [{ value: "", label: t("move") }, { value: "__root", label: t("folderRoot") }, ...folders.map((fo) => ({ value: fo.id, label: fo.name }))], className: "w-auto" })) : null, _jsxs(Button, { size: "xs", variant: "ghost", onClick: downloadSelected, children: [_jsx(Download, {}), t("download")] }), canUpload && caps?.bulk !== false ? (_jsxs(Button, { size: "xs", variant: "danger-ghost", onClick: () => setConfirm([...selected]), children: [_jsx(Trash2, {}), t("delete")] })) : null, _jsx(IconButton, { label: t("clearSelection"), tooltip: false, size: "xs", variant: "ghost", className: "text-fg-muted", onClick: () => setSelected([]), children: _jsx(X, {}) })] })] })) : null;
|
|
716
|
+
const renderTile = (a, index) => {
|
|
717
|
+
const isSel = selected.includes(a.id);
|
|
718
|
+
const disabled = isDisabled(a);
|
|
719
|
+
const missing = isAltMissing(a);
|
|
720
|
+
return (_jsxs("div", { role: "gridcell", "data-tile": index, "data-slot": "media-tile", "data-selected": isSel ? "" : undefined, "data-active": activeId === a.id ? "" : undefined, "aria-selected": selection === "none" ? undefined : isSel, "aria-disabled": disabled || undefined, "aria-label": [a.filename, missing ? t("missingAlt") : null, a.status === "processing" ? t("processing") : a.status === "failed" ? t("failed") : null].filter(Boolean).join(", "), tabIndex: index === focusIndex ? 0 : -1, onClick: (e) => onTileClick(e, index), onDoubleClick: () => detailsPanel && openDetails(a), onFocus: () => setFocusIndex(index), className: cn("vui-media-tile group/tile focus-ring relative grid min-w-0 cursor-pointer gap-1.5 rounded-ui outline-none", disabled && "cursor-not-allowed opacity-45"), children: [_jsxs("div", { className: "vui-media-tile-frame relative overflow-hidden rounded-ui bg-surface-2", children: [_jsx(MediaThumb, { asset: a, rounded: "none" }), a.kind === "video" && a.duration ? _jsx("span", { className: "tabular absolute end-1.5 bottom-1.5 rounded-sm bg-[color-mix(in_srgb,var(--scene)_82%,transparent)] px-1.5 py-0.5 text-[10.5px] font-medium text-fg", children: f.duration(a.duration) }) : null, a.status === "failed" ? _jsx(Badge, { tone: "danger", className: "absolute start-1.5 top-1.5", children: t("failed") }) : null, missing ? _jsx("span", { "aria-hidden": true, title: t("missingAlt"), className: "vui-media-alt-dot absolute end-2 top-2 size-2 rounded-full bg-warning" }) : null, selection !== "none" ? (_jsx("span", { "aria-hidden": true, "data-slot": "media-tile-check", className: cn("vui-media-check absolute start-1.5 top-1.5 flex size-5 items-center justify-center rounded-full", isSel ? "bg-accent text-accent-fg" : "border border-[color-mix(in_srgb,var(--fg)_30%,transparent)] bg-[color-mix(in_srgb,var(--scene)_70%,transparent)] text-transparent"), children: _jsx(Check, { className: "size-3", strokeWidth: 3 }) })) : null] }), _jsx("span", { className: cn("truncate px-0.5 text-[12px] leading-tight", isSel ? "text-fg" : "text-fg-muted"), children: a.filename })] }, a.id));
|
|
721
|
+
};
|
|
722
|
+
const gridStyle = { gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`, gap: GRID_GAP };
|
|
723
|
+
const gridEl = (_jsx("div", { ref: gridRef, role: "grid", "aria-label": t("files"), "aria-multiselectable": selection === "multiple" || undefined, "aria-rowcount": virtual ? rows.length : undefined, "aria-describedby": liveId, "data-slot": "media-grid", onKeyDown: onGridKeyDown, className: "relative", style: virtual ? { height: virtualizer.getTotalSize() } : undefined, children: virtual
|
|
724
|
+
? virtualizer.getVirtualItems().map((vr) => (_jsx("div", { role: "row", "aria-rowindex": vr.index + 1, "data-index": vr.index, ref: virtualizer.measureElement, className: "absolute inset-x-0 grid", style: { ...gridStyle, top: 0, transform: `translateY(${vr.start}px)`, paddingBottom: GRID_GAP }, children: rows[vr.index].map((a, i) => renderTile(a, vr.index * cols + i)) }, vr.key)))
|
|
725
|
+
: rows.map((row, r) => (_jsx("div", { role: "row", className: "grid", style: { ...gridStyle, marginBottom: r < rows.length - 1 ? GRID_GAP : 0 }, children: row.map((a, i) => renderTile(a, r * cols + i)) }, r))) }));
|
|
726
|
+
const listEl = (_jsxs("table", { "data-slot": "media-list", "aria-label": t("files"), className: "w-full border-collapse text-[13px]", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-start text-[11.5px] tracking-wide text-fg-subtle uppercase", children: [selection !== "none" ? (_jsx("th", { scope: "col", className: "w-10 pb-2 ps-1 text-start font-medium", children: _jsx("span", { className: "sr-only", children: t("select", { name: "" }) }) })) : null, _jsx("th", { scope: "col", className: "w-full pb-2 text-start font-medium", children: t("colName") }), _jsx("th", { scope: "col", className: "hidden pb-2 ps-4 text-start font-medium whitespace-nowrap @lg:table-cell", children: t("colType") }), _jsx("th", { scope: "col", className: "pb-2 ps-4 text-end font-medium whitespace-nowrap", children: t("colSize") }), _jsx("th", { scope: "col", className: "hidden pb-2 ps-4 text-end font-medium whitespace-nowrap @xl:table-cell", children: t("colDimensions") }), _jsx("th", { scope: "col", className: "hidden pb-2 ps-4 text-end font-medium whitespace-nowrap @md:table-cell", children: t("colUploaded") }), _jsx("th", { scope: "col", className: "hidden pb-2 ps-4 pe-1 text-end font-medium whitespace-nowrap @lg:table-cell", children: t("colAlt") })] }) }), _jsx("tbody", { children: items.map((a, index) => {
|
|
727
|
+
const isSel = selected.includes(a.id);
|
|
728
|
+
const disabled = isDisabled(a);
|
|
729
|
+
return (_jsxs("tr", { "data-slot": "media-row", "aria-selected": selection === "none" ? undefined : isSel, "data-selected": isSel ? "" : undefined, className: cn("border-t border-line transition-colors hover:bg-hover", (isSel || activeId === a.id) && "bg-selected", disabled && "opacity-45"), children: [selection !== "none" ? (_jsx("td", { className: "py-1.5 ps-1", children: _jsx(Checkbox, { size: "sm", "aria-label": t("select", { name: a.filename }), checked: isSel, disabled: Boolean(disabled), onCheckedChange: () => toggle(index) }) })) : null, _jsx("td", { className: "max-w-0 py-1.5", children: _jsxs("button", { type: "button", className: "focus-ring flex w-full min-w-0 items-center gap-3 rounded-ui-sm text-start", onClick: () => (detailsPanel ? openDetails(a) : toggle(index)), children: [_jsx("span", { className: "size-9 shrink-0 overflow-hidden rounded-ui-sm ring-1 ring-line", children: _jsx(MediaThumb, { asset: a, rounded: "none" }) }), _jsx("span", { className: "truncate text-fg", children: a.filename })] }) }), _jsx("td", { className: "hidden py-1.5 ps-4 text-fg-muted @lg:table-cell", children: extensionOf(a.filename) || a.kind }), _jsx("td", { className: "tabular py-1.5 ps-4 text-end whitespace-nowrap text-fg-muted", children: f.bytes(a.size) }), _jsx("td", { className: "tabular hidden py-1.5 ps-4 text-end whitespace-nowrap text-fg-muted @xl:table-cell", children: dimensions(a, nf) }), _jsx("td", { className: "tabular hidden py-1.5 ps-4 text-end whitespace-nowrap text-fg-muted @md:table-cell", children: f.date(a.createdAt) }), _jsx("td", { className: "hidden py-1.5 ps-4 pe-1 text-end whitespace-nowrap @lg:table-cell", children: a.kind !== "image" ? _jsx("span", { className: "text-fg-subtle", children: "\u2014" }) : isAltMissing(a) ? _jsx(Badge, { tone: "warning", children: t("missingAlt") }) : isDecorative(a) ? _jsx("span", { className: "text-fg-subtle", children: t("altDecorative") }) : _jsx("span", { className: "text-fg-muted", children: t("altOk") }) })] }, a.id));
|
|
730
|
+
}) })] }));
|
|
731
|
+
const skeleton = (_jsx("div", { "aria-hidden": true, className: "grid", style: gridStyle, children: Array.from({ length: cols * 2 }, (_, i) => (_jsxs("div", { className: "grid gap-1.5", children: [_jsx(Skeleton, { className: "aspect-square rounded-ui" }), _jsx(Skeleton, { className: "h-3 w-3/4 rounded-sm" })] }, i))) }));
|
|
732
|
+
let body;
|
|
733
|
+
if (!adapter)
|
|
734
|
+
body = null;
|
|
735
|
+
else if (status === "error")
|
|
736
|
+
body = (_jsx(Alert, { tone: "danger", live: "assertive", title: t("error"), actions: _jsx(Button, { size: "sm", onClick: () => setReload((n) => n + 1), children: t("retry") }) }));
|
|
737
|
+
else if (status === "loading")
|
|
738
|
+
body = skeleton;
|
|
739
|
+
else if (!items.length)
|
|
740
|
+
body = filtered ? (_jsx(EmptyState, { kind: "no-results", size: "sm", title: query.search ? t("noResults", { query: query.search }) : t("noResultsFiltered"), description: t("noResultsDescription"), actions: _jsx(Button, { size: "sm", onClick: () => setQuery({ sort: query.sort }), children: t("clearFilters") }) })) : (emptyState ?? (_jsx(EmptyState, { kind: "first-use", size: "sm", framed: true, icon: _jsx(Upload, { "aria-hidden": true }), title: t("emptyTitle"), description: canUpload ? t("emptyDescription") : undefined, actions: canUpload ? (_jsxs(Button, { size: "sm", variant: "primary", onClick: () => fileInput.current?.click(), children: [_jsx(Upload, {}), t("upload")] })) : undefined })));
|
|
741
|
+
else
|
|
742
|
+
body = view === "grid" ? gridEl : listEl;
|
|
743
|
+
const folderSidebar = folderMode === "sidebar" ? (_jsx(MediaFolderNav, { folders: folders, value: query.folderId, onValueChange: (folderId) => patchQuery({ folderId }), adapter: canEdit ? adapter : undefined, onCreated: (fo) => setFolders((l) => [...l, fo]), t: t })) : null;
|
|
744
|
+
const showSide = detailsPanel === "side" && active;
|
|
745
|
+
return (_jsxs("div", { ref: ref, "data-slot": "media-library", "data-view": view, "data-dragging": dragDepth > 0 ? "" : undefined, className: cn("vui-media-library surface @container relative flex flex-col overflow-hidden rounded-ui-lg", className), ...dropHandlers, ...props, children: [toolbarEl, bulkBar, _jsxs("div", { className: "flex min-h-0 flex-1", children: [folderSidebar, _jsxs("div", { ref: scrollRef, className: "vui-media-scroll @container relative min-w-0 flex-1 overflow-y-auto overscroll-contain px-4 py-4", style: { height }, children: [uploadQueue.items.length ? _jsx(MediaUploadQueue, { queue: uploadQueue, labels: queueLabelsProp, className: "mb-4" }) : null, _jsx("div", { ref: measureRef, children: body }), status === "ready" && cursor ? (_jsx("div", { className: "mt-4 flex justify-center", children: _jsx(Button, { size: "sm", variant: "ghost", loading: loadingMore, onClick: () => void loadMore(), children: t("loadMore") }) })) : null, status === "ready" && items.length ? (_jsx("p", { className: "tabular mt-4 text-center text-[11.5px] text-fg-subtle", children: t("count", { count: total ?? items.length }) })) : null] }), showSide ? (_jsx("aside", { "aria-label": t("details"), "data-slot": "media-details-panel", className: "vui-media-side hidden w-[19rem] shrink-0 overflow-y-auto overscroll-contain border-s border-line px-4 py-4 @container md:block", style: { height }, children: _jsx(MediaDetails, { asset: active, adapter: adapter, readOnly: !canEdit, onChange: onAssetChange, onDelete: canUpload ? (a) => setConfirm([a.id]) : undefined, onClose: () => setActiveId(null), labels: detailsLabelsProp }) })) : null] }), _jsx("span", { id: liveId, role: "status", "aria-live": "polite", className: "sr-only", children: selection !== "none" ? t("selectedAnnounce", { count: selected.length }) : "" }), canUpload ? (_jsx("input", { ref: fileInput, type: "file", multiple: selection !== "single", accept: accept, hidden: true, tabIndex: -1, "aria-hidden": true, onChange: (e) => {
|
|
746
|
+
addFiles(e.target.files);
|
|
747
|
+
e.target.value = "";
|
|
748
|
+
} })) : null, canUpload ? (_jsx("div", { "aria-hidden": true, "data-slot": "media-drop-overlay", className: "vui-media-drop pointer-events-none absolute inset-2 z-10 flex items-center justify-center rounded-ui", children: _jsxs("span", { className: "surface-popover inline-flex items-center gap-2 rounded-full px-4 py-2 text-[13px] font-medium", children: [_jsx(Upload, { className: "size-4" }), t("dropHint")] }) })) : null, detailsPanel === "dialog" || detailsPanel === "side" ? (_jsx(Dialog, { open: Boolean(active) && (detailsPanel === "dialog" || narrowViewport()), onOpenChange: (o) => !o && setActiveId(null), children: _jsxs(DialogContent, { size: "md", mobile: "fullscreen", children: [_jsx(DialogHeader, { title: t("details"), srOnly: true }), _jsx(DialogBody, { children: active ? _jsx(MediaDetails, { asset: active, adapter: adapter, readOnly: !canEdit, onChange: onAssetChange, onDelete: canUpload ? (a) => setConfirm([a.id]) : undefined, labels: detailsLabelsProp }) : null })] }) })) : null, _jsx(ConfirmDialog, { open: Boolean(confirm), tone: "danger", title: t("deleteTitle", { count: confirm?.length ?? 1 }), description: caps?.trash ? t("trashDescription") : t("deleteDescription"), confirmLabel: t("delete"), onConfirm: () => (confirm ? remove(confirm) : undefined), onResult: () => setConfirm(null) })] }));
|
|
749
|
+
});
|
|
750
|
+
function narrowViewport() {
|
|
751
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(max-width: 767px)").matches;
|
|
752
|
+
}
|
|
753
|
+
/* ------------------------------------------------------------------ */
|
|
754
|
+
/* Folder sidebar */
|
|
755
|
+
/* ------------------------------------------------------------------ */
|
|
756
|
+
function MediaFolderNav({ folders, value, onValueChange, adapter, onCreated, t, }) {
|
|
757
|
+
const [creating, setCreating] = React.useState(false);
|
|
758
|
+
const [name, setName] = React.useState("");
|
|
759
|
+
const f = useFormat();
|
|
760
|
+
const byParent = (parent) => folders.filter((fo) => (fo.parentId ?? null) === parent);
|
|
761
|
+
const item = (id, label, count, depth = 0) => {
|
|
762
|
+
const current = value === id;
|
|
763
|
+
return (_jsx("li", { children: _jsxs("button", { type: "button", "aria-current": current || undefined, onClick: () => onValueChange(id), className: cn("focus-ring flex h-8 w-full items-center gap-2 rounded-ui-sm px-2 text-start text-[13px] transition-colors hover:bg-hover", current ? "bg-selected font-medium text-fg" : "text-fg-muted"), style: { paddingInlineStart: 8 + depth * 14 }, children: [_jsx(Folder, { "aria-hidden": true, className: "size-3.5 shrink-0" }), _jsx("span", { className: "truncate", children: label }), count !== undefined ? _jsx("span", { className: "tabular ms-auto text-[11.5px] text-fg-subtle", children: f.number(count) }) : null] }) }, String(id)));
|
|
764
|
+
};
|
|
765
|
+
const tree = (parent, depth) => byParent(parent).flatMap((fo) => [item(fo.id, fo.name, fo.count, depth), ...tree(fo.id, depth + 1)]);
|
|
766
|
+
const submit = async (e) => {
|
|
767
|
+
e.preventDefault();
|
|
768
|
+
if (!adapter?.folders || !name.trim())
|
|
769
|
+
return;
|
|
770
|
+
const created = await adapter.folders.create(name.trim(), null);
|
|
771
|
+
onCreated(created);
|
|
772
|
+
setName("");
|
|
773
|
+
setCreating(false);
|
|
774
|
+
};
|
|
775
|
+
return (_jsxs("nav", { "aria-label": t("folder"), "data-slot": "media-folders", className: "hidden w-52 shrink-0 flex-col gap-2 border-e border-line px-2 py-3 sm:flex", children: [_jsxs("ul", { className: "grid gap-0.5", children: [item(undefined, t("folderAll")), item(null, t("folderRoot")), tree(null, 0)] }), adapter?.folders ? (creating ? (_jsxs("form", { onSubmit: submit, className: "grid gap-1.5 px-1", children: [_jsx(Input, { size: "sm", autoFocus: true, "aria-label": t("folderName"), placeholder: t("folderName"), value: name, onChange: (e) => setName(e.target.value), onKeyDown: (e) => e.key === "Escape" && setCreating(false) }), _jsx(Button, { size: "xs", type: "submit", variant: "secondary", disabled: !name.trim(), children: t("create") })] })) : (_jsxs(Button, { size: "xs", variant: "ghost", className: "justify-start text-fg-muted", onClick: () => setCreating(true), children: [_jsx(FolderPlus, {}), t("newFolder")] }))) : null] }));
|
|
776
|
+
}
|