@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,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sortable: the kit's reordering primitive. A drag-and-drop engine (dnd-kit) is wrapped behind
|
|
3
|
+
* kit-owned props, so no engine type appears in the public API and the engine can be swapped.
|
|
4
|
+
*
|
|
5
|
+
* - Pointer, touch (long press) and keyboard dragging (Space / Enter lifts, arrows move,
|
|
6
|
+
* Space / Enter drops, Esc cancels).
|
|
7
|
+
* - Localized screen-reader announcements ("Picked up About us. Position 2 of 6.").
|
|
8
|
+
* - A Move menu on every item: the single-pointer, non-drag alternative (WCAG 2.2 · 2.5.7).
|
|
9
|
+
* - Single list, grid, or several containers (boards).
|
|
10
|
+
*/
|
|
11
|
+
import * as React from "react";
|
|
12
|
+
export declare const sortableLabels: {
|
|
13
|
+
handle: string;
|
|
14
|
+
roleDescription: string;
|
|
15
|
+
instructions: string;
|
|
16
|
+
pickedUp: string;
|
|
17
|
+
movedOver: string;
|
|
18
|
+
movedToContainer: string;
|
|
19
|
+
dropped: string;
|
|
20
|
+
droppedInContainer: string;
|
|
21
|
+
cancelled: string;
|
|
22
|
+
moveMenu: string;
|
|
23
|
+
moveUp: string;
|
|
24
|
+
moveDown: string;
|
|
25
|
+
moveTop: string;
|
|
26
|
+
moveBottom: string;
|
|
27
|
+
moveEarlier: string;
|
|
28
|
+
moveLater: string;
|
|
29
|
+
moveStart: string;
|
|
30
|
+
moveEnd: string;
|
|
31
|
+
moveTo: string;
|
|
32
|
+
moveToHeading: string;
|
|
33
|
+
dropHere: string;
|
|
34
|
+
};
|
|
35
|
+
export type SortableLabels = typeof sortableLabels;
|
|
36
|
+
export type SortableOrientation = "vertical" | "horizontal" | "grid";
|
|
37
|
+
/** A list inside a multi-container Sortable (a board column, a "Selected" / "Available" pair). */
|
|
38
|
+
export interface SortableContainerSpec {
|
|
39
|
+
id: string;
|
|
40
|
+
/** Spoken in announcements and shown in the Move menu ("In review"). */
|
|
41
|
+
label?: string;
|
|
42
|
+
/** Item ids in order. */
|
|
43
|
+
items: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface SortableMoveEvent {
|
|
46
|
+
id: string;
|
|
47
|
+
from: number;
|
|
48
|
+
to: number;
|
|
49
|
+
}
|
|
50
|
+
export interface SortableMoveBetweenEvent {
|
|
51
|
+
id: string;
|
|
52
|
+
/** Container ids. Equal when the item was reordered within its container. */
|
|
53
|
+
from: string;
|
|
54
|
+
to: string;
|
|
55
|
+
/** Final index in `to`. */
|
|
56
|
+
index: number;
|
|
57
|
+
/** Index in `from` before the move. */
|
|
58
|
+
fromIndex: number;
|
|
59
|
+
}
|
|
60
|
+
/** Id of the item being dragged, or `null`. For virtualized lists (`keepMountedRange`). */
|
|
61
|
+
export declare function useSortableActiveId(): string | null;
|
|
62
|
+
export interface SortableProps<T> {
|
|
63
|
+
items: readonly T[];
|
|
64
|
+
/** Stable id of an item. Default: `item.id`, or the item itself for strings. */
|
|
65
|
+
getId?: (item: T) => string;
|
|
66
|
+
/** Spoken name of an item. Default: `label` / `title` / `name`, then the id. */
|
|
67
|
+
getLabel?: (item: T) => string;
|
|
68
|
+
/** Single-list reorder. Called with the reordered array. */
|
|
69
|
+
onReorder?: (next: T[], event: SortableMoveEvent) => void;
|
|
70
|
+
/** `"grid"` uses 2-D keyboard movement and rect sorting. Default `"vertical"`. */
|
|
71
|
+
orientation?: SortableOrientation;
|
|
72
|
+
/** Drag only from a `SortableHandle`. Default `true`. */
|
|
73
|
+
handle?: boolean;
|
|
74
|
+
disabled?: boolean | ((item: T) => boolean);
|
|
75
|
+
/** Multi-container mode: lists of item ids. `items` must contain every item. */
|
|
76
|
+
containers?: SortableContainerSpec[];
|
|
77
|
+
/** Multi-container mode: called once on drop (also for moves within one container). */
|
|
78
|
+
onMoveBetween?: (event: SortableMoveBetweenEvent) => void;
|
|
79
|
+
onDragStart?: (id: string) => void;
|
|
80
|
+
onDragEnd?: (id: string, cancelled: boolean) => void;
|
|
81
|
+
/** Built-in strings (announcements, Move menu). */
|
|
82
|
+
labels?: Partial<SortableLabels>;
|
|
83
|
+
/** Default overlay content for `<SortableOverlay/>` without children. */
|
|
84
|
+
renderOverlay?: (item: T) => React.ReactNode;
|
|
85
|
+
children?: React.ReactNode;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Context, sensors and announcements for reordering. Renders no DOM of its own besides a
|
|
89
|
+
* visually hidden live region for Move-menu moves.
|
|
90
|
+
*
|
|
91
|
+
* ```tsx
|
|
92
|
+
* <Sortable items={pages} onReorder={setPages}>
|
|
93
|
+
* {pages.map((p) => (
|
|
94
|
+
* <SortableItem key={p.id} id={p.id}><SortableHandle /> {p.title}</SortableItem>
|
|
95
|
+
* ))}
|
|
96
|
+
* <SortableOverlay />
|
|
97
|
+
* </Sortable>
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function Sortable<T>(props: SortableProps<T>): React.JSX.Element;
|
|
101
|
+
export interface SortableContainerProps extends Omit<React.HTMLAttributes<HTMLElement>, "children"> {
|
|
102
|
+
id: string;
|
|
103
|
+
/** Element to render. Default `"div"`. */
|
|
104
|
+
as?: "div" | "ul" | "ol" | "section";
|
|
105
|
+
/** Receives the live (preview) item ids of this container. */
|
|
106
|
+
children: (ids: string[], state: {
|
|
107
|
+
isOver: boolean;
|
|
108
|
+
isEmpty: boolean;
|
|
109
|
+
}) => React.ReactNode;
|
|
110
|
+
}
|
|
111
|
+
/** One list in a multi-container Sortable. Also the drop target when it is empty. */
|
|
112
|
+
export declare function SortableContainer({ id, as: Comp, className, children, ...props }: SortableContainerProps): React.JSX.Element;
|
|
113
|
+
/** Live item ids of a container (multi mode). */
|
|
114
|
+
export declare function useSortableContainerItems(id: string): string[];
|
|
115
|
+
export interface UseSortableItemResult {
|
|
116
|
+
/** Ref for the item's root element. */
|
|
117
|
+
ref: (node: HTMLElement | null) => void;
|
|
118
|
+
/** Spread on the drag activator: the handle, or the item itself when `handle={false}`. */
|
|
119
|
+
handleProps: React.HTMLAttributes<HTMLElement> & {
|
|
120
|
+
ref: (node: HTMLElement | null) => void;
|
|
121
|
+
};
|
|
122
|
+
/** Transform + transition for the item root. */
|
|
123
|
+
style: React.CSSProperties;
|
|
124
|
+
isDragging: boolean;
|
|
125
|
+
/** The item is the dragged one and an overlay renders the clone: show a placeholder. */
|
|
126
|
+
isPlaceholder: boolean;
|
|
127
|
+
isSorting: boolean;
|
|
128
|
+
disabled: boolean;
|
|
129
|
+
index: number;
|
|
130
|
+
label: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Low-level hook for kit consumers (Data Table columns, Line items rows, Gallery…).
|
|
134
|
+
*
|
|
135
|
+
* ```tsx
|
|
136
|
+
* const s = useSortableItem(row.id);
|
|
137
|
+
* <tr ref={s.ref} style={s.style}><td><button {...s.handleProps}><GripVertical /></button></td>…</tr>
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare function useSortableItem(id: string, options?: {
|
|
141
|
+
disabled?: boolean;
|
|
142
|
+
}): UseSortableItemResult;
|
|
143
|
+
/** The current item (inside `SortableItem`). */
|
|
144
|
+
export declare function useSortableItemContext(): (UseSortableItemResult & {
|
|
145
|
+
id: string;
|
|
146
|
+
}) | null;
|
|
147
|
+
export interface SortableItemProps extends React.HTMLAttributes<HTMLElement> {
|
|
148
|
+
id: string;
|
|
149
|
+
/** Element to render. Default `"div"`. Use `"li"` inside a list (keep `handle` on). */
|
|
150
|
+
as?: "div" | "li" | "tr" | "section" | "article";
|
|
151
|
+
disabled?: boolean;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* A sortable element. With `handle` (default) put a `SortableHandle` inside; with
|
|
155
|
+
* `handle={false}` the whole item is the activator.
|
|
156
|
+
*/
|
|
157
|
+
export declare const SortableItem: React.ForwardRefExoticComponent<SortableItemProps & React.RefAttributes<HTMLElement>>;
|
|
158
|
+
export interface SortableHandleProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
159
|
+
/** Item id; default: the surrounding `SortableItem`. */
|
|
160
|
+
id?: string;
|
|
161
|
+
size?: "sm" | "md";
|
|
162
|
+
}
|
|
163
|
+
/** The drag handle: a button named "Reorder {item}". Hidden for disabled items. */
|
|
164
|
+
export declare const SortableHandle: React.ForwardRefExoticComponent<SortableHandleProps & React.RefAttributes<HTMLButtonElement>>;
|
|
165
|
+
export interface SortableOverlayProps {
|
|
166
|
+
/** Overlay content: a node or a function of the dragged id. Default: the root `renderOverlay`. */
|
|
167
|
+
children?: React.ReactNode | ((id: string) => React.ReactNode);
|
|
168
|
+
className?: string;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The dragged clone, portaled so a blurred container can't clip or offset it. Opaque
|
|
172
|
+
* `surface-popover` without blur: it looks the same in glass and solid.
|
|
173
|
+
*/
|
|
174
|
+
export declare function SortableOverlay({ children, className }: SortableOverlayProps): React.ReactPortal | null;
|
|
175
|
+
export interface SortableMoveMenuProps {
|
|
176
|
+
/** Item id; default: the surrounding `SortableItem`. */
|
|
177
|
+
id?: string;
|
|
178
|
+
/** Custom trigger (rendered with `asChild`). */
|
|
179
|
+
trigger?: React.ReactElement;
|
|
180
|
+
size?: "xs" | "sm" | "md";
|
|
181
|
+
align?: "start" | "end";
|
|
182
|
+
className?: string;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Move up / down / to top / to bottom (and "Move to {list}" with containers) without dragging.
|
|
186
|
+
* The result is announced politely.
|
|
187
|
+
*/
|
|
188
|
+
export declare function SortableMoveMenu({ id: idProp, trigger, size, align, className }: SortableMoveMenuProps): React.JSX.Element;
|
|
@@ -0,0 +1,485 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Sortable: the kit's reordering primitive. A drag-and-drop engine (dnd-kit) is wrapped behind
|
|
5
|
+
* kit-owned props, so no engine type appears in the public API and the engine can be swapped.
|
|
6
|
+
*
|
|
7
|
+
* - Pointer, touch (long press) and keyboard dragging (Space / Enter lifts, arrows move,
|
|
8
|
+
* Space / Enter drops, Esc cancels).
|
|
9
|
+
* - Localized screen-reader announcements ("Picked up About us. Position 2 of 6.").
|
|
10
|
+
* - A Move menu on every item: the single-pointer, non-drag alternative (WCAG 2.2 · 2.5.7).
|
|
11
|
+
* - Single list, grid, or several containers (boards).
|
|
12
|
+
*/
|
|
13
|
+
import * as React from "react";
|
|
14
|
+
import { createPortal } from "react-dom";
|
|
15
|
+
import { DndContext, DragOverlay, KeyboardSensor, MeasuringStrategy, MouseSensor, TouchSensor, closestCenter, closestCorners, useDroppable, useSensor, useSensors, } from "@dnd-kit/core";
|
|
16
|
+
import { SortableContext, horizontalListSortingStrategy, rectSortingStrategy, sortableKeyboardCoordinates, useSortable, verticalListSortingStrategy, } from "@dnd-kit/sortable";
|
|
17
|
+
import { restrictToHorizontalAxis, restrictToVerticalAxis } from "@dnd-kit/modifiers";
|
|
18
|
+
import { CSS } from "@dnd-kit/utilities";
|
|
19
|
+
import { GripVertical, ArrowUpDown, ArrowUp, ArrowDown, ArrowUpToLine, ArrowDownToLine, CornerDownRight } from "lucide-react";
|
|
20
|
+
import { cn } from "../lib/cn.js";
|
|
21
|
+
import { useLabels } from "../lib/labels.js";
|
|
22
|
+
import { usePortalContainer } from "../lib/theme-scope.js";
|
|
23
|
+
import { useReducedMotion } from "../lib/use-reduced-motion.js";
|
|
24
|
+
import { useLatest } from "../lib/use-controllable-state.js";
|
|
25
|
+
import { IconButton } from "../components/button.js";
|
|
26
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "../components/dropdown-menu.js";
|
|
27
|
+
import { arrayMove, findContainer, moveBetweenContainers, moveTargetIndex } from "./core.js";
|
|
28
|
+
// ---------------------------------------------------------------------------------------------
|
|
29
|
+
// Labels
|
|
30
|
+
// ---------------------------------------------------------------------------------------------
|
|
31
|
+
export const sortableLabels = {
|
|
32
|
+
handle: "Reorder {item}",
|
|
33
|
+
roleDescription: "sortable",
|
|
34
|
+
instructions: "To pick up an item, press Space or Enter. Use the arrow keys to move it, then press Space or Enter to drop it, or Escape to cancel.",
|
|
35
|
+
pickedUp: "Picked up {item}. Position {position} of {total}.",
|
|
36
|
+
movedOver: "{item} moved to position {position} of {total}.",
|
|
37
|
+
movedToContainer: "{item} moved to {container}, position {position} of {total}.",
|
|
38
|
+
dropped: "{item} dropped at position {position} of {total}.",
|
|
39
|
+
droppedInContainer: "{item} dropped in {container} at position {position} of {total}.",
|
|
40
|
+
cancelled: "Moving {item} cancelled. It is back at position {position} of {total}.",
|
|
41
|
+
moveMenu: "Move {item}",
|
|
42
|
+
moveUp: "Move up",
|
|
43
|
+
moveDown: "Move down",
|
|
44
|
+
moveTop: "Move to top",
|
|
45
|
+
moveBottom: "Move to bottom",
|
|
46
|
+
moveEarlier: "Move earlier",
|
|
47
|
+
moveLater: "Move later",
|
|
48
|
+
moveStart: "Move to start",
|
|
49
|
+
moveEnd: "Move to end",
|
|
50
|
+
moveTo: "Move to {container}",
|
|
51
|
+
moveToHeading: "Move to list",
|
|
52
|
+
dropHere: "Drop items here",
|
|
53
|
+
};
|
|
54
|
+
const SortableRootContext = React.createContext(null);
|
|
55
|
+
function useSortableRoot(component) {
|
|
56
|
+
const ctx = React.useContext(SortableRootContext);
|
|
57
|
+
if (!ctx)
|
|
58
|
+
throw new Error(`<${component}> must be used inside <Sortable>.`);
|
|
59
|
+
return ctx;
|
|
60
|
+
}
|
|
61
|
+
/** Id of the item being dragged, or `null`. For virtualized lists (`keepMountedRange`). */
|
|
62
|
+
export function useSortableActiveId() {
|
|
63
|
+
return React.useContext(SortableRootContext)?.activeId ?? null;
|
|
64
|
+
}
|
|
65
|
+
// ---------------------------------------------------------------------------------------------
|
|
66
|
+
// Keyboard coordinates (orientation-aware; arrows follow the visual layout, so they mirror in RTL)
|
|
67
|
+
// ---------------------------------------------------------------------------------------------
|
|
68
|
+
function keyboardCoordinates(orientation) {
|
|
69
|
+
return (event, args) => {
|
|
70
|
+
const code = event.code;
|
|
71
|
+
if (orientation === "vertical" && (code === "ArrowLeft" || code === "ArrowRight"))
|
|
72
|
+
return undefined;
|
|
73
|
+
if (orientation === "horizontal" && (code === "ArrowUp" || code === "ArrowDown"))
|
|
74
|
+
return undefined;
|
|
75
|
+
return sortableKeyboardCoordinates(event, args);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const MODIFIERS = {
|
|
79
|
+
vertical: [restrictToVerticalAxis],
|
|
80
|
+
horizontal: [restrictToHorizontalAxis],
|
|
81
|
+
grid: [],
|
|
82
|
+
};
|
|
83
|
+
const STRATEGY = { vertical: verticalListSortingStrategy, horizontal: horizontalListSortingStrategy, grid: rectSortingStrategy };
|
|
84
|
+
const defaultGetId = (item) => typeof item === "string" ? item : typeof item === "number" ? String(item) : String(item.id);
|
|
85
|
+
const defaultGetLabel = (item) => {
|
|
86
|
+
if (typeof item === "string")
|
|
87
|
+
return item;
|
|
88
|
+
const o = item;
|
|
89
|
+
const v = o && (o.label ?? o.title ?? o.name);
|
|
90
|
+
return typeof v === "string" ? v : undefined;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Context, sensors and announcements for reordering. Renders no DOM of its own besides a
|
|
94
|
+
* visually hidden live region for Move-menu moves.
|
|
95
|
+
*
|
|
96
|
+
* ```tsx
|
|
97
|
+
* <Sortable items={pages} onReorder={setPages}>
|
|
98
|
+
* {pages.map((p) => (
|
|
99
|
+
* <SortableItem key={p.id} id={p.id}><SortableHandle /> {p.title}</SortableItem>
|
|
100
|
+
* ))}
|
|
101
|
+
* <SortableOverlay />
|
|
102
|
+
* </Sortable>
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export function Sortable(props) {
|
|
106
|
+
const { items, getId = defaultGetId, getLabel, onReorder, orientation = "vertical", handle = true, disabled, containers, onMoveBetween, onDragStart, onDragEnd, labels, renderOverlay, children, } = props;
|
|
107
|
+
const t = useLabels("sortable", sortableLabels, labels);
|
|
108
|
+
const reducedMotion = useReducedMotion();
|
|
109
|
+
const multi = !!containers;
|
|
110
|
+
const byId = React.useMemo(() => {
|
|
111
|
+
const m = new Map();
|
|
112
|
+
for (const it of items)
|
|
113
|
+
m.set(getId(it), it);
|
|
114
|
+
return m;
|
|
115
|
+
}, [items, getId]);
|
|
116
|
+
const ids = React.useMemo(() => items.map(getId), [items, getId]);
|
|
117
|
+
const [activeId, setActiveId] = React.useState(null);
|
|
118
|
+
const [live, setLive] = React.useState(null);
|
|
119
|
+
const [overlayCount, setOverlayCount] = React.useState(0);
|
|
120
|
+
const [status, setStatus] = React.useState("");
|
|
121
|
+
const snapshot = React.useRef(null);
|
|
122
|
+
const movedRef = React.useRef(false);
|
|
123
|
+
// Stable across server and client render (the engine's own counter is not).
|
|
124
|
+
const dndId = React.useId();
|
|
125
|
+
const baseContainers = React.useMemo(() => (containers ?? []).map((c) => ({ id: c.id, items: c.items })), [containers]);
|
|
126
|
+
const current = live ?? baseContainers;
|
|
127
|
+
const containerLabelMap = React.useMemo(() => new Map((containers ?? []).map((c) => [c.id, c.label ?? c.id])), [containers]);
|
|
128
|
+
const labelOf = React.useCallback((id) => {
|
|
129
|
+
const it = byId.get(id);
|
|
130
|
+
if (it === undefined)
|
|
131
|
+
return containerLabelMap.get(id) ?? id;
|
|
132
|
+
return (getLabel ? getLabel(it) : defaultGetLabel(it)) ?? id;
|
|
133
|
+
}, [byId, getLabel, containerLabelMap]);
|
|
134
|
+
const isDisabled = React.useCallback((id) => {
|
|
135
|
+
if (typeof disabled === "function") {
|
|
136
|
+
const it = byId.get(id);
|
|
137
|
+
return it !== undefined && disabled(it);
|
|
138
|
+
}
|
|
139
|
+
return !!disabled;
|
|
140
|
+
}, [disabled, byId]);
|
|
141
|
+
const positionOf = React.useCallback((id, state = current) => {
|
|
142
|
+
if (multi) {
|
|
143
|
+
const c = findContainer(state, id);
|
|
144
|
+
if (!c)
|
|
145
|
+
return { index: -1, total: 0 };
|
|
146
|
+
return { index: c.id === id ? c.items.length : c.items.indexOf(id), total: c.items.length, container: c.id };
|
|
147
|
+
}
|
|
148
|
+
return { index: ids.indexOf(id), total: ids.length };
|
|
149
|
+
}, [multi, current, ids]);
|
|
150
|
+
// Refs for dnd-kit callbacks (announcements are read on demand).
|
|
151
|
+
const latest = useLatest({ positionOf, labelOf, current, ids, items, byId, onReorder, onMoveBetween, multi, containerLabelMap, t });
|
|
152
|
+
const announce = React.useCallback((msg) => {
|
|
153
|
+
// Re-set so identical consecutive messages are spoken again.
|
|
154
|
+
setStatus("");
|
|
155
|
+
requestAnimationFrame(() => setStatus(msg));
|
|
156
|
+
}, []);
|
|
157
|
+
const move = React.useCallback((id, target) => {
|
|
158
|
+
const L = latest.current;
|
|
159
|
+
if (L.multi) {
|
|
160
|
+
const from = findContainer(L.current, id);
|
|
161
|
+
if (!from)
|
|
162
|
+
return;
|
|
163
|
+
const fromIndex = from.items.indexOf(id);
|
|
164
|
+
let toId = from.id;
|
|
165
|
+
let index;
|
|
166
|
+
if (typeof target === "string") {
|
|
167
|
+
const to = moveTargetIndex(fromIndex, from.items.length, target);
|
|
168
|
+
if (to === null)
|
|
169
|
+
return;
|
|
170
|
+
index = to;
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
toId = target.container;
|
|
174
|
+
const dest = L.current.find((c) => c.id === toId);
|
|
175
|
+
if (!dest)
|
|
176
|
+
return;
|
|
177
|
+
index = target.index ?? (toId === from.id ? from.items.length - 1 : dest.items.length);
|
|
178
|
+
}
|
|
179
|
+
L.onMoveBetween?.({ id, from: from.id, to: toId, index, fromIndex });
|
|
180
|
+
const total = toId === from.id ? from.items.length : (L.current.find((c) => c.id === toId)?.items.length ?? 0) + 1;
|
|
181
|
+
announce(toId === from.id
|
|
182
|
+
? L.t("movedOver", { item: L.labelOf(id), position: index + 1, total })
|
|
183
|
+
: L.t("movedToContainer", { item: L.labelOf(id), container: L.containerLabelMap.get(toId) ?? toId, position: index + 1, total }));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (typeof target !== "string")
|
|
187
|
+
return;
|
|
188
|
+
const from = L.ids.indexOf(id);
|
|
189
|
+
const to = from === -1 ? null : moveTargetIndex(from, L.ids.length, target);
|
|
190
|
+
if (to === null)
|
|
191
|
+
return;
|
|
192
|
+
L.onReorder?.(arrayMove(L.items, from, to), { id, from, to });
|
|
193
|
+
announce(L.t("movedOver", { item: L.labelOf(id), position: to + 1, total: L.ids.length }));
|
|
194
|
+
}, [latest, announce]);
|
|
195
|
+
const sensors = useSensors(useSensor(MouseSensor, { activationConstraint: { distance: 4 } }), useSensor(TouchSensor, { activationConstraint: { delay: 220, tolerance: 6 } }), useSensor(KeyboardSensor, { coordinateGetter: keyboardCoordinates(orientation) }));
|
|
196
|
+
const setDragging = (on) => {
|
|
197
|
+
if (typeof document === "undefined")
|
|
198
|
+
return;
|
|
199
|
+
if (on)
|
|
200
|
+
document.documentElement.setAttribute("data-dragging", "");
|
|
201
|
+
else
|
|
202
|
+
document.documentElement.removeAttribute("data-dragging");
|
|
203
|
+
};
|
|
204
|
+
const handleDragStart = (e) => {
|
|
205
|
+
const id = String(e.active.id);
|
|
206
|
+
setActiveId(id);
|
|
207
|
+
if (multi) {
|
|
208
|
+
snapshot.current = baseContainers;
|
|
209
|
+
setLive(baseContainers);
|
|
210
|
+
}
|
|
211
|
+
setDragging(true);
|
|
212
|
+
onDragStart?.(id);
|
|
213
|
+
};
|
|
214
|
+
const handleDragOver = (e) => {
|
|
215
|
+
if (!multi || !e.over)
|
|
216
|
+
return;
|
|
217
|
+
const id = String(e.active.id);
|
|
218
|
+
const overId = String(e.over.id);
|
|
219
|
+
setLive((prev) => {
|
|
220
|
+
const state = prev ?? baseContainers;
|
|
221
|
+
const from = findContainer(state, id);
|
|
222
|
+
const to = findContainer(state, overId);
|
|
223
|
+
if (!from || !to || from.id === to.id)
|
|
224
|
+
return state;
|
|
225
|
+
const overIndex = to.id === overId ? to.items.length : to.items.indexOf(overId);
|
|
226
|
+
return moveBetweenContainers(state, id, to.id, overIndex < 0 ? to.items.length : overIndex);
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
const finish = (id, cancelled) => {
|
|
230
|
+
setActiveId(null);
|
|
231
|
+
setLive(null);
|
|
232
|
+
snapshot.current = null;
|
|
233
|
+
setDragging(false);
|
|
234
|
+
onDragEnd?.(id, cancelled);
|
|
235
|
+
};
|
|
236
|
+
const handleDragEnd = (e) => {
|
|
237
|
+
const id = String(e.active.id);
|
|
238
|
+
const overId = e.over ? String(e.over.id) : null;
|
|
239
|
+
if (multi) {
|
|
240
|
+
const start = snapshot.current ?? baseContainers;
|
|
241
|
+
const state = live ?? baseContainers;
|
|
242
|
+
const from = findContainer(start, id);
|
|
243
|
+
const c = findContainer(state, id);
|
|
244
|
+
if (from && c && overId) {
|
|
245
|
+
let index = c.items.indexOf(id);
|
|
246
|
+
if (overId !== c.id && c.items.includes(overId))
|
|
247
|
+
index = c.items.indexOf(overId);
|
|
248
|
+
const fromIndex = from.items.indexOf(id);
|
|
249
|
+
if (from.id !== c.id || index !== fromIndex)
|
|
250
|
+
onMoveBetween?.({ id, from: from.id, to: c.id, index, fromIndex });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (overId && overId !== id) {
|
|
254
|
+
const from = ids.indexOf(id);
|
|
255
|
+
const to = ids.indexOf(overId);
|
|
256
|
+
if (from !== -1 && to !== -1)
|
|
257
|
+
onReorder?.(arrayMove(items, from, to), { id, from, to });
|
|
258
|
+
}
|
|
259
|
+
finish(id, false);
|
|
260
|
+
};
|
|
261
|
+
const handleDragCancel = (e) => finish(String(e.active.id), true);
|
|
262
|
+
const announcements = React.useMemo(() => {
|
|
263
|
+
const pos = (id, overId) => {
|
|
264
|
+
const L = latest.current;
|
|
265
|
+
if (L.multi) {
|
|
266
|
+
const c = findContainer(L.current, overId ?? id);
|
|
267
|
+
if (!c)
|
|
268
|
+
return { position: 0, total: 0 };
|
|
269
|
+
const i = overId && overId !== c.id ? c.items.indexOf(overId) : c.items.indexOf(id);
|
|
270
|
+
return { position: (i < 0 ? c.items.length : i) + 1, total: c.items.length, container: L.containerLabelMap.get(c.id) ?? c.id, containerId: c.id };
|
|
271
|
+
}
|
|
272
|
+
const p = L.ids.indexOf(overId ?? id);
|
|
273
|
+
return { position: p + 1, total: L.ids.length };
|
|
274
|
+
};
|
|
275
|
+
return {
|
|
276
|
+
onDragStart: ({ active }) => {
|
|
277
|
+
movedRef.current = false;
|
|
278
|
+
return latest.current.t("pickedUp", { item: latest.current.labelOf(String(active.id)), ...pos(String(active.id)) });
|
|
279
|
+
},
|
|
280
|
+
onDragOver: ({ active, over }) => {
|
|
281
|
+
if (!over)
|
|
282
|
+
return undefined;
|
|
283
|
+
// Right after pick-up the item is over itself: keep the "Picked up" message.
|
|
284
|
+
if (over.id === active.id && !movedRef.current)
|
|
285
|
+
return undefined;
|
|
286
|
+
movedRef.current = true;
|
|
287
|
+
const L = latest.current;
|
|
288
|
+
const p = pos(String(active.id), String(over.id));
|
|
289
|
+
if (L.multi && "container" in p) {
|
|
290
|
+
const start = snapshot.current ? findContainer(snapshot.current, String(active.id)) : undefined;
|
|
291
|
+
if (start && start.id !== p.containerId)
|
|
292
|
+
return L.t("movedToContainer", { item: L.labelOf(String(active.id)), ...p });
|
|
293
|
+
}
|
|
294
|
+
return L.t("movedOver", { item: L.labelOf(String(active.id)), ...p });
|
|
295
|
+
},
|
|
296
|
+
onDragEnd: ({ active, over }) => {
|
|
297
|
+
if (!over)
|
|
298
|
+
return undefined;
|
|
299
|
+
const L = latest.current;
|
|
300
|
+
const p = pos(String(active.id), String(over.id));
|
|
301
|
+
return L.multi && "container" in p
|
|
302
|
+
? L.t("droppedInContainer", { item: L.labelOf(String(active.id)), ...p })
|
|
303
|
+
: L.t("dropped", { item: L.labelOf(String(active.id)), ...p });
|
|
304
|
+
},
|
|
305
|
+
onDragCancel: ({ active }) => {
|
|
306
|
+
const L = latest.current;
|
|
307
|
+
const id = String(active.id);
|
|
308
|
+
const start = snapshot.current;
|
|
309
|
+
if (L.multi && start) {
|
|
310
|
+
const c = findContainer(start, id);
|
|
311
|
+
return L.t("cancelled", { item: L.labelOf(id), position: (c?.items.indexOf(id) ?? 0) + 1, total: c?.items.length ?? 0 });
|
|
312
|
+
}
|
|
313
|
+
return L.t("cancelled", { item: L.labelOf(id), ...pos(id) });
|
|
314
|
+
},
|
|
315
|
+
};
|
|
316
|
+
}, [latest]);
|
|
317
|
+
const collision = multi ? closestCorners : closestCenter;
|
|
318
|
+
const ctx = React.useMemo(() => ({
|
|
319
|
+
handle,
|
|
320
|
+
orientation,
|
|
321
|
+
t,
|
|
322
|
+
labelOf,
|
|
323
|
+
isDisabled,
|
|
324
|
+
activeId,
|
|
325
|
+
hasOverlay: overlayCount > 0,
|
|
326
|
+
registerOverlay: () => {
|
|
327
|
+
setOverlayCount((n) => n + 1);
|
|
328
|
+
return () => setOverlayCount((n) => n - 1);
|
|
329
|
+
},
|
|
330
|
+
multi,
|
|
331
|
+
containers: current,
|
|
332
|
+
containerLabel: (id) => containerLabelMap.get(id) ?? id,
|
|
333
|
+
ids,
|
|
334
|
+
move,
|
|
335
|
+
positionOf: (id) => positionOf(id),
|
|
336
|
+
renderOverlay: renderOverlay
|
|
337
|
+
? (id) => {
|
|
338
|
+
const it = byId.get(id);
|
|
339
|
+
return it === undefined ? null : renderOverlay(it);
|
|
340
|
+
}
|
|
341
|
+
: undefined,
|
|
342
|
+
reducedMotion,
|
|
343
|
+
}), [handle, orientation, t, labelOf, isDisabled, activeId, overlayCount, multi, current, containerLabelMap, ids, move, positionOf, renderOverlay, byId, reducedMotion]);
|
|
344
|
+
return (_jsx(DndContext, { id: dndId, sensors: sensors, collisionDetection: collision, modifiers: multi ? [] : MODIFIERS[orientation], measuring: multi ? { droppable: { strategy: MeasuringStrategy.Always } } : undefined, onDragStart: handleDragStart, onDragOver: handleDragOver, onDragEnd: handleDragEnd, onDragCancel: handleDragCancel, accessibility: { announcements, screenReaderInstructions: { draggable: t("instructions") } }, children: _jsxs(SortableRootContext.Provider, { value: ctx, children: [multi ? (children) : (_jsx(SortableContext, { items: ids, strategy: STRATEGY[orientation], children: children })), _jsx("span", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", "data-slot": "sortable-status", children: status })] }) }));
|
|
345
|
+
}
|
|
346
|
+
/** One list in a multi-container Sortable. Also the drop target when it is empty. */
|
|
347
|
+
export function SortableContainer({ id, as: Comp = "div", className, children, ...props }) {
|
|
348
|
+
const ctx = useSortableRoot("SortableContainer");
|
|
349
|
+
const ids = ctx.containers.find((c) => c.id === id)?.items ?? [];
|
|
350
|
+
const { setNodeRef, isOver } = useDroppable({ id, data: { type: "container" } });
|
|
351
|
+
// Highlight the list the dragged item would land in.
|
|
352
|
+
const overThis = isOver || (ctx.activeId !== null && ids.includes(ctx.activeId));
|
|
353
|
+
return (_jsx(SortableContext, { id: id, items: ids, strategy: STRATEGY[ctx.orientation], children: _jsx(Comp, { ref: setNodeRef, "data-slot": "sortable-container", "data-over": overThis ? "" : undefined, "data-empty": ids.length === 0 ? "" : undefined, className: cn("vui-sortable-container", className), ...props, children: children(ids, { isOver: overThis, isEmpty: ids.length === 0 }) }) }));
|
|
354
|
+
}
|
|
355
|
+
/** Live item ids of a container (multi mode). */
|
|
356
|
+
export function useSortableContainerItems(id) {
|
|
357
|
+
const ctx = useSortableRoot("useSortableContainerItems");
|
|
358
|
+
return ctx.containers.find((c) => c.id === id)?.items ?? [];
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Low-level hook for kit consumers (Data Table columns, Line items rows, Gallery…).
|
|
362
|
+
*
|
|
363
|
+
* ```tsx
|
|
364
|
+
* const s = useSortableItem(row.id);
|
|
365
|
+
* <tr ref={s.ref} style={s.style}><td><button {...s.handleProps}><GripVertical /></button></td>…</tr>
|
|
366
|
+
* ```
|
|
367
|
+
*/
|
|
368
|
+
export function useSortableItem(id, options = {}) {
|
|
369
|
+
const ctx = useSortableRoot("useSortableItem");
|
|
370
|
+
const disabled = options.disabled ?? ctx.isDisabled(id);
|
|
371
|
+
const label = ctx.labelOf(id);
|
|
372
|
+
const s = useSortable({
|
|
373
|
+
id,
|
|
374
|
+
disabled,
|
|
375
|
+
attributes: { roleDescription: ctx.t("roleDescription") },
|
|
376
|
+
transition: ctx.reducedMotion ? null : { duration: 180, easing: "cubic-bezier(0.2, 0.8, 0.2, 1)" },
|
|
377
|
+
});
|
|
378
|
+
const handleProps = React.useMemo(() => ({
|
|
379
|
+
...s.attributes,
|
|
380
|
+
...(s.listeners ?? {}),
|
|
381
|
+
ref: s.setActivatorNodeRef,
|
|
382
|
+
...(ctx.handle ? { "aria-label": ctx.t("handle", { item: label }) } : {}),
|
|
383
|
+
}), [s.attributes, s.listeners, s.setActivatorNodeRef, ctx, label]);
|
|
384
|
+
const style = {
|
|
385
|
+
transform: CSS.Translate.toString(s.transform),
|
|
386
|
+
transition: ctx.reducedMotion ? undefined : s.transition,
|
|
387
|
+
};
|
|
388
|
+
return {
|
|
389
|
+
ref: s.setNodeRef,
|
|
390
|
+
handleProps,
|
|
391
|
+
style,
|
|
392
|
+
isDragging: s.isDragging,
|
|
393
|
+
isPlaceholder: s.isDragging && ctx.hasOverlay,
|
|
394
|
+
isSorting: s.isSorting,
|
|
395
|
+
disabled,
|
|
396
|
+
index: s.index,
|
|
397
|
+
label,
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
const SortableItemContext = React.createContext(null);
|
|
401
|
+
/** The current item (inside `SortableItem`). */
|
|
402
|
+
export function useSortableItemContext() {
|
|
403
|
+
return React.useContext(SortableItemContext);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* A sortable element. With `handle` (default) put a `SortableHandle` inside; with
|
|
407
|
+
* `handle={false}` the whole item is the activator.
|
|
408
|
+
*/
|
|
409
|
+
export const SortableItem = React.forwardRef(function SortableItem({ id, as: Comp = "div", disabled, className, style, children, ...props }, ref) {
|
|
410
|
+
const ctx = useSortableRoot("SortableItem");
|
|
411
|
+
const item = useSortableItem(id, { disabled });
|
|
412
|
+
const setRef = React.useCallback((node) => {
|
|
413
|
+
item.ref(node);
|
|
414
|
+
if (typeof ref === "function")
|
|
415
|
+
ref(node);
|
|
416
|
+
else if (ref)
|
|
417
|
+
ref.current = node;
|
|
418
|
+
},
|
|
419
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
420
|
+
[item.ref, ref]);
|
|
421
|
+
const activator = ctx.handle ? null : item.handleProps;
|
|
422
|
+
const { ref: activatorRef, ...activatorProps } = activator ?? { ref: undefined };
|
|
423
|
+
const value = React.useMemo(() => ({ ...item, id }), [item, id]);
|
|
424
|
+
return (_jsx(SortableItemContext.Provider, { value: value, children: _jsx(Comp, { ref: (node) => {
|
|
425
|
+
setRef(node);
|
|
426
|
+
activatorRef?.(node);
|
|
427
|
+
}, "data-slot": "sortable-item", "data-dragging": item.isDragging ? "" : undefined, "data-placeholder": item.isPlaceholder ? "" : undefined, "data-disabled": item.disabled ? "" : undefined, className: cn("vui-sortable-item", !ctx.handle && !item.disabled && "focus-ring cursor-grab", className), style: { ...item.style, ...style }, ...activatorProps, ...props, children: children }) }));
|
|
428
|
+
});
|
|
429
|
+
/** The drag handle: a button named "Reorder {item}". Hidden for disabled items. */
|
|
430
|
+
export const SortableHandle = React.forwardRef(function SortableHandle({ id: _id, size = "md", className, children, ...props }, ref) {
|
|
431
|
+
const item = useSortableItemContext();
|
|
432
|
+
if (!item)
|
|
433
|
+
throw new Error("<SortableHandle> must be used inside <SortableItem> (or pass the handle props from useSortableItem).");
|
|
434
|
+
if (item.disabled)
|
|
435
|
+
return _jsx("span", { "aria-hidden": true, className: cn(size === "sm" ? "w-6" : "w-7", "shrink-0"), "data-slot": "sortable-handle-spacer" });
|
|
436
|
+
const { ref: activatorRef, ...handleProps } = item.handleProps;
|
|
437
|
+
return (_jsx("button", { type: "button", ref: (node) => {
|
|
438
|
+
activatorRef(node);
|
|
439
|
+
if (typeof ref === "function")
|
|
440
|
+
ref(node);
|
|
441
|
+
else if (ref)
|
|
442
|
+
ref.current = node;
|
|
443
|
+
}, "data-slot": "sortable-handle", className: cn("vui-sortable-handle focus-ring inline-flex shrink-0 cursor-grab touch-none items-center justify-center rounded-ui-sm text-fg-subtle", "transition-colors hover:bg-hover hover:text-fg active:cursor-grabbing", size === "sm" ? "size-6 [&_svg]:size-3.5" : "size-7 [&_svg]:size-4", className), ...handleProps, ...props, children: children ?? _jsx(GripVertical, { "aria-hidden": true }) }));
|
|
444
|
+
});
|
|
445
|
+
/**
|
|
446
|
+
* The dragged clone, portaled so a blurred container can't clip or offset it. Opaque
|
|
447
|
+
* `surface-popover` without blur: it looks the same in glass and solid.
|
|
448
|
+
*/
|
|
449
|
+
export function SortableOverlay({ children, className }) {
|
|
450
|
+
const ctx = useSortableRoot("SortableOverlay");
|
|
451
|
+
const container = usePortalContainer();
|
|
452
|
+
const { registerOverlay } = ctx;
|
|
453
|
+
React.useEffect(() => registerOverlay(), [registerOverlay]);
|
|
454
|
+
const [mounted, setMounted] = React.useState(false);
|
|
455
|
+
React.useEffect(() => setMounted(true), []);
|
|
456
|
+
const id = ctx.activeId;
|
|
457
|
+
const content = id === null ? null : typeof children === "function" ? children(id) : (children ?? ctx.renderOverlay?.(id) ?? null);
|
|
458
|
+
const overlay = (_jsx(DragOverlay, { dropAnimation: ctx.reducedMotion ? null : { duration: 180, easing: "cubic-bezier(0.2, 0.8, 0.2, 1)" }, zIndex: 1000, children: content ? (_jsx("div", { "data-slot": "sortable-overlay", className: cn("vui-sortable-overlay", className), children: content })) : null }));
|
|
459
|
+
if (!mounted)
|
|
460
|
+
return null;
|
|
461
|
+
return createPortal(overlay, container ?? document.body);
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Move up / down / to top / to bottom (and "Move to {list}" with containers) without dragging.
|
|
465
|
+
* The result is announced politely.
|
|
466
|
+
*/
|
|
467
|
+
export function SortableMoveMenu({ id: idProp, trigger, size = "sm", align = "end", className }) {
|
|
468
|
+
const ctx = useSortableRoot("SortableMoveMenu");
|
|
469
|
+
const item = useSortableItemContext();
|
|
470
|
+
const id = idProp ?? item?.id;
|
|
471
|
+
if (!id)
|
|
472
|
+
throw new Error("<SortableMoveMenu> needs an `id` outside <SortableItem>.");
|
|
473
|
+
const label = ctx.labelOf(id);
|
|
474
|
+
const { index, total, container } = ctx.positionOf(id);
|
|
475
|
+
const disabled = ctx.isDisabled(id);
|
|
476
|
+
const vertical = ctx.orientation === "vertical";
|
|
477
|
+
const ops = [
|
|
478
|
+
{ op: "up", label: ctx.t(vertical ? "moveUp" : "moveEarlier"), icon: _jsx(ArrowUp, {}) },
|
|
479
|
+
{ op: "down", label: ctx.t(vertical ? "moveDown" : "moveLater"), icon: _jsx(ArrowDown, {}) },
|
|
480
|
+
{ op: "top", label: ctx.t(vertical ? "moveTop" : "moveStart"), icon: _jsx(ArrowUpToLine, {}) },
|
|
481
|
+
{ op: "bottom", label: ctx.t(vertical ? "moveBottom" : "moveEnd"), icon: _jsx(ArrowDownToLine, {}) },
|
|
482
|
+
];
|
|
483
|
+
const others = ctx.multi ? ctx.containers.filter((c) => c.id !== container) : [];
|
|
484
|
+
return (_jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { asChild: true, disabled: disabled, children: trigger ?? (_jsx(IconButton, { label: ctx.t("moveMenu", { item: label }), size: size, tooltip: false, className: cn("text-fg-subtle", className), "data-slot": "sortable-move-menu", children: _jsx(ArrowUpDown, {}) })) }), _jsxs(DropdownMenuContent, { align: align, size: "sm", children: [ops.map((o) => (_jsx(DropdownMenuItem, { icon: o.icon, disabled: moveTargetIndex(index, total, o.op) === null, onSelect: () => ctx.move(id, o.op), children: o.label }, o.op))), others.length > 0 && (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuLabel, { children: ctx.t("moveToHeading") }), others.map((c) => (_jsx(DropdownMenuItem, { icon: _jsx(CornerDownRight, {}), onSelect: () => ctx.move(id, { container: c.id }), children: ctx.t("moveTo", { container: ctx.containerLabel(c.id) }) }, c.id)))] }))] })] }));
|
|
485
|
+
}
|