@vamos-ui/react 0.0.0-stage → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/blocks/block-heading.d.ts +29 -0
- package/dist/blocks/block-heading.js +39 -0
- package/dist/blocks/block-image.d.ts +52 -0
- package/dist/blocks/block-image.js +48 -0
- package/dist/blocks/block-link.d.ts +30 -0
- package/dist/blocks/block-link.js +36 -0
- package/dist/blocks/create-blocks.d.ts +54 -0
- package/dist/blocks/create-blocks.js +52 -0
- package/dist/blocks/index.d.ts +55 -0
- package/dist/blocks/index.js +59 -0
- package/dist/blocks/json-ld.d.ts +18 -0
- package/dist/blocks/json-ld.js +44 -0
- package/dist/blocks/labels.d.ts +20 -0
- package/dist/blocks/labels.js +43 -0
- package/dist/blocks/rich-text.d.ts +36 -0
- package/dist/blocks/rich-text.js +106 -0
- package/dist/blocks/schema/define-block.d.ts +151 -0
- package/dist/blocks/schema/define-block.js +120 -0
- package/dist/blocks/schema/emphasis.d.ts +17 -0
- package/dist/blocks/schema/emphasis.js +69 -0
- package/dist/blocks/schema/fields.d.ts +497 -0
- package/dist/blocks/schema/fields.js +240 -0
- package/dist/blocks/schema/icons.d.ts +2 -0
- package/dist/blocks/schema/icons.js +26 -0
- package/dist/blocks/schema/index.d.ts +18 -0
- package/dist/blocks/schema/index.js +21 -0
- package/dist/blocks/schema/lint-types.d.ts +16 -0
- package/dist/blocks/schema/lint-types.js +2 -0
- package/dist/blocks/schema/lint.d.ts +32 -0
- package/dist/blocks/schema/lint.js +164 -0
- package/dist/blocks/schema/localize.d.ts +20 -0
- package/dist/blocks/schema/localize.js +29 -0
- package/dist/blocks/schema/localized.d.ts +25 -0
- package/dist/blocks/schema/localized.js +53 -0
- package/dist/blocks/schema/migrate.d.ts +24 -0
- package/dist/blocks/schema/migrate.js +75 -0
- package/dist/blocks/schema/nodes.d.ts +196 -0
- package/dist/blocks/schema/nodes.js +78 -0
- package/dist/blocks/schema/rich-doc-schema.d.ts +32 -0
- package/dist/blocks/schema/rich-doc-schema.js +66 -0
- package/dist/blocks/schema/rich-doc.d.ts +90 -0
- package/dist/blocks/schema/rich-doc.js +62 -0
- package/dist/blocks/schema/safety.d.ts +20 -0
- package/dist/blocks/schema/safety.js +49 -0
- package/dist/blocks/schema/types.d.ts +172 -0
- package/dist/blocks/schema/types.js +3 -0
- package/dist/blocks/schema/validate.d.ts +17 -0
- package/dist/blocks/schema/validate.js +32 -0
- package/dist/blocks/schema/walk.d.ts +22 -0
- package/dist/blocks/schema/walk.js +60 -0
- package/dist/blocks/section-header.d.ts +38 -0
- package/dist/blocks/section-header.js +22 -0
- package/dist/blocks/section.d.ts +59 -0
- package/dist/blocks/section.js +66 -0
- package/dist/blocks/site/_kit-1.d.ts +101 -0
- package/dist/blocks/site/_kit-1.js +137 -0
- package/dist/blocks/site/_site-icon-1.d.ts +6 -0
- package/dist/blocks/site/_site-icon-1.js +15 -0
- package/dist/blocks/site/announcement-bar.d.ts +42 -0
- package/dist/blocks/site/announcement-bar.js +38 -0
- package/dist/blocks/site/announcement-dismiss.d.ts +18 -0
- package/dist/blocks/site/announcement-dismiss.js +28 -0
- package/dist/blocks/site/article-layout.d.ts +65 -0
- package/dist/blocks/site/article-layout.js +88 -0
- package/dist/blocks/site/blog-list.d.ts +79 -0
- package/dist/blocks/site/blog-list.js +78 -0
- package/dist/blocks/site/comparison-table.d.ts +54 -0
- package/dist/blocks/site/comparison-table.js +38 -0
- package/dist/blocks/site/consent-banner.d.ts +52 -0
- package/dist/blocks/site/consent-banner.js +33 -0
- package/dist/blocks/site/contact-dock.d.ts +52 -0
- package/dist/blocks/site/contact-dock.js +55 -0
- package/dist/blocks/site/contact-form.d.ts +60 -0
- package/dist/blocks/site/contact-form.js +45 -0
- package/dist/blocks/site/cta-booking.d.ts +43 -0
- package/dist/blocks/site/cta-booking.js +69 -0
- package/dist/blocks/site/cta.d.ts +74 -0
- package/dist/blocks/site/cta.js +113 -0
- package/dist/blocks/site/embed-facade.d.ts +20 -0
- package/dist/blocks/site/embed-facade.js +21 -0
- package/dist/blocks/site/faq.d.ts +48 -0
- package/dist/blocks/site/faq.js +52 -0
- package/dist/blocks/site/feature-grid.d.ts +46 -0
- package/dist/blocks/site/feature-grid.js +50 -0
- package/dist/blocks/site/feature-tabs.d.ts +22 -0
- package/dist/blocks/site/feature-tabs.js +11 -0
- package/dist/blocks/site/footer.d.ts +68 -0
- package/dist/blocks/site/footer.js +61 -0
- package/dist/blocks/site/gallery-section.d.ts +42 -0
- package/dist/blocks/site/gallery-section.js +48 -0
- package/dist/blocks/site/hero-video.d.ts +15 -0
- package/dist/blocks/site/hero-video.js +31 -0
- package/dist/blocks/site/hero.d.ts +64 -0
- package/dist/blocks/site/hero.js +73 -0
- package/dist/blocks/site/logo-strip.d.ts +44 -0
- package/dist/blocks/site/logo-strip.js +27 -0
- package/dist/blocks/site/map-hours.d.ts +83 -0
- package/dist/blocks/site/map-hours.js +125 -0
- package/dist/blocks/site/media-text.d.ts +45 -0
- package/dist/blocks/site/media-text.js +56 -0
- package/dist/blocks/site/menu-list.d.ts +74 -0
- package/dist/blocks/site/menu-list.js +84 -0
- package/dist/blocks/site/navbar-submenu.d.ts +18 -0
- package/dist/blocks/site/navbar-submenu.js +51 -0
- package/dist/blocks/site/navbar.d.ts +67 -0
- package/dist/blocks/site/navbar.js +64 -0
- package/dist/blocks/site/not-found.d.ts +40 -0
- package/dist/blocks/site/not-found.js +38 -0
- package/dist/blocks/site/page-intro.d.ts +46 -0
- package/dist/blocks/site/page-intro.js +44 -0
- package/dist/blocks/site/pricing-table.d.ts +67 -0
- package/dist/blocks/site/pricing-table.js +83 -0
- package/dist/blocks/site/process.d.ts +36 -0
- package/dist/blocks/site/process.js +42 -0
- package/dist/blocks/site/registry-1.d.ts +720 -0
- package/dist/blocks/site/registry-1.js +783 -0
- package/dist/blocks/site/registry-2.d.ts +914 -0
- package/dist/blocks/site/registry-2.js +563 -0
- package/dist/blocks/site/rich-text-section.d.ts +34 -0
- package/dist/blocks/site/rich-text-section.js +32 -0
- package/dist/blocks/site/shared/brand-icons.d.ts +21 -0
- package/dist/blocks/site/shared/brand-icons.js +56 -0
- package/dist/blocks/site/shared/consent-gate.d.ts +41 -0
- package/dist/blocks/site/shared/consent-gate.js +43 -0
- package/dist/blocks/site/shared/consent-island.d.ts +38 -0
- package/dist/blocks/site/shared/consent-island.js +63 -0
- package/dist/blocks/site/shared/consent.d.ts +49 -0
- package/dist/blocks/site/shared/consent.js +130 -0
- package/dist/blocks/site/shared/contact-form-island.d.ts +41 -0
- package/dist/blocks/site/shared/contact-form-island.js +100 -0
- package/dist/blocks/site/shared/copy-link.d.ts +10 -0
- package/dist/blocks/site/shared/copy-link.js +25 -0
- package/dist/blocks/site/shared/dock-avoid.d.ts +15 -0
- package/dist/blocks/site/shared/dock-avoid.js +107 -0
- package/dist/blocks/site/shared/dock-hours.d.ts +13 -0
- package/dist/blocks/site/shared/dock-hours.js +25 -0
- package/dist/blocks/site/shared/gallery-lightbox.d.ts +12 -0
- package/dist/blocks/site/shared/gallery-lightbox.js +10 -0
- package/dist/blocks/site/shared/island-keys.d.ts +10 -0
- package/dist/blocks/site/shared/island-keys.js +44 -0
- package/dist/blocks/site/shared/kit-2.d.ts +55 -0
- package/dist/blocks/site/shared/kit-2.js +84 -0
- package/dist/blocks/site/shared/labels-2.d.ts +209 -0
- package/dist/blocks/site/shared/labels-2.js +427 -0
- package/dist/blocks/site/shared/open-now.d.ts +22 -0
- package/dist/blocks/site/shared/open-now.js +27 -0
- package/dist/blocks/site/shared/opening-hours.d.ts +117 -0
- package/dist/blocks/site/shared/opening-hours.js +245 -0
- package/dist/blocks/site/shared/site-accent.d.ts +48 -0
- package/dist/blocks/site/shared/site-accent.js +249 -0
- package/dist/blocks/site/shared/site-form.d.ts +79 -0
- package/dist/blocks/site/shared/site-form.js +111 -0
- package/dist/blocks/site/shared/site-routing.d.ts +54 -0
- package/dist/blocks/site/shared/site-routing.js +86 -0
- package/dist/blocks/site/shared/testimonials-carousel.d.ts +17 -0
- package/dist/blocks/site/shared/testimonials-carousel.js +64 -0
- package/dist/blocks/site/site-shell.d.ts +108 -0
- package/dist/blocks/site/site-shell.js +254 -0
- package/dist/blocks/site/stats-band.d.ts +42 -0
- package/dist/blocks/site/stats-band.js +45 -0
- package/dist/blocks/site/team.d.ts +44 -0
- package/dist/blocks/site/team.js +48 -0
- package/dist/blocks/site/testimonials.d.ts +68 -0
- package/dist/blocks/site/testimonials.js +66 -0
- package/dist/blocks/types.d.ts +63 -0
- package/dist/blocks/types.js +2 -0
- package/dist/business/approval-flow.d.ts +152 -0
- package/dist/business/approval-flow.js +221 -0
- package/dist/business/export-core.d.ts +55 -0
- package/dist/business/export-core.js +101 -0
- package/dist/business/export.d.ts +148 -0
- package/dist/business/export.js +264 -0
- package/dist/business/import-core.d.ts +104 -0
- package/dist/business/import-core.js +281 -0
- package/dist/business/import-wizard.d.ts +186 -0
- package/dist/business/import-wizard.js +401 -0
- package/dist/business/index.d.ts +12 -0
- package/dist/business/index.js +22 -0
- package/dist/business/line-items-core.d.ts +129 -0
- package/dist/business/line-items-core.js +183 -0
- package/dist/business/line-items.d.ts +119 -0
- package/dist/business/line-items.js +299 -0
- package/dist/business/multi-step-form.d.ts +131 -0
- package/dist/business/multi-step-form.js +337 -0
- package/dist/business/permission-core.d.ts +59 -0
- package/dist/business/permission-core.js +99 -0
- package/dist/business/permission-matrix.d.ts +158 -0
- package/dist/business/permission-matrix.js +341 -0
- package/dist/business/setup-checklist.d.ts +80 -0
- package/dist/business/setup-checklist.js +92 -0
- package/dist/business/signer-status.d.ts +53 -0
- package/dist/business/signer-status.js +76 -0
- package/dist/charts/area-chart.d.ts +35 -0
- package/dist/charts/area-chart.js +33 -0
- package/dist/charts/bar-chart.d.ts +27 -0
- package/dist/charts/bar-chart.js +46 -0
- package/dist/charts/bar-list.d.ts +47 -0
- package/dist/charts/bar-list.js +60 -0
- package/dist/charts/chart-shell.d.ts +173 -0
- package/dist/charts/chart-shell.js +205 -0
- package/dist/charts/chart.d.ts +73 -0
- package/dist/charts/chart.js +106 -0
- package/dist/charts/combo-chart.d.ts +29 -0
- package/dist/charts/combo-chart.js +47 -0
- package/dist/charts/donut-chart.d.ts +33 -0
- package/dist/charts/donut-chart.js +113 -0
- package/dist/charts/funnel.d.ts +51 -0
- package/dist/charts/funnel.js +69 -0
- package/dist/charts/gauge.d.ts +62 -0
- package/dist/charts/gauge.js +104 -0
- package/dist/charts/heatmap.d.ts +81 -0
- package/dist/charts/heatmap.js +338 -0
- package/dist/charts/index.d.ts +12 -0
- package/dist/charts/index.js +14 -0
- package/dist/charts/line-chart.d.ts +21 -0
- package/dist/charts/line-chart.js +36 -0
- package/dist/charts/test-utils.d.ts +2 -0
- package/dist/charts/test-utils.js +38 -0
- package/dist/charts/utils.d.ts +130 -0
- package/dist/charts/utils.js +262 -0
- package/dist/components/_qr-core.d.ts +26 -0
- package/dist/components/_qr-core.js +376 -0
- package/dist/components/accordion.d.ts +47 -0
- package/dist/components/accordion.js +70 -0
- package/dist/components/activity-timeline.d.ts +149 -0
- package/dist/components/activity-timeline.js +122 -0
- package/dist/components/address-field.d.ts +116 -0
- package/dist/components/address-field.js +219 -0
- package/dist/components/alert-dialog.d.ts +99 -0
- package/dist/components/alert-dialog.js +192 -0
- package/dist/components/alert.d.ts +42 -0
- package/dist/components/alert.js +82 -0
- package/dist/components/app-shell.d.ts +159 -0
- package/dist/components/app-shell.js +289 -0
- package/dist/components/attachment-list.d.ts +96 -0
- package/dist/components/attachment-list.js +196 -0
- package/dist/components/audit-log.d.ts +150 -0
- package/dist/components/audit-log.js +205 -0
- package/dist/components/avatar.d.ts +87 -0
- package/dist/components/avatar.js +126 -0
- package/dist/components/backup-codes.d.ts +42 -0
- package/dist/components/backup-codes.js +67 -0
- package/dist/components/badge.d.ts +41 -0
- package/dist/components/badge.js +68 -0
- package/dist/components/breadcrumb.d.ts +78 -0
- package/dist/components/breadcrumb.js +106 -0
- package/dist/components/button-group.d.ts +52 -0
- package/dist/components/button-group.js +77 -0
- package/dist/components/button.d.ts +58 -0
- package/dist/components/button.js +107 -0
- package/dist/components/calendar.d.ts +240 -0
- package/dist/components/calendar.js +483 -0
- package/dist/components/card.d.ts +66 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +170 -0
- package/dist/components/carousel.js +348 -0
- package/dist/components/checkbox.d.ts +78 -0
- package/dist/components/checkbox.js +138 -0
- package/dist/components/color-picker.d.ts +112 -0
- package/dist/components/color-picker.js +235 -0
- package/dist/components/combobox.d.ts +136 -0
- package/dist/components/combobox.js +294 -0
- package/dist/components/command.d.ts +281 -0
- package/dist/components/command.js +498 -0
- package/dist/components/comment-thread.d.ts +252 -0
- package/dist/components/comment-thread.js +449 -0
- package/dist/components/context-menu.d.ts +77 -0
- package/dist/components/context-menu.js +82 -0
- package/dist/components/currency-input.d.ts +43 -0
- package/dist/components/currency-input.js +85 -0
- package/dist/components/date-picker.d.ts +141 -0
- package/dist/components/date-picker.js +241 -0
- package/dist/components/date-range-picker.d.ts +91 -0
- package/dist/components/date-range-picker.js +251 -0
- package/dist/components/description-list.d.ts +92 -0
- package/dist/components/description-list.js +42 -0
- package/dist/components/dialog.d.ts +139 -0
- package/dist/components/dialog.js +185 -0
- package/dist/components/dropdown-menu.d.ts +100 -0
- package/dist/components/dropdown-menu.js +102 -0
- package/dist/components/editor-layout.d.ts +166 -0
- package/dist/components/editor-layout.js +237 -0
- package/dist/components/empty-state.d.ts +49 -0
- package/dist/components/empty-state.js +68 -0
- package/dist/components/entity-card.d.ts +83 -0
- package/dist/components/entity-card.js +92 -0
- package/dist/components/file-upload.d.ts +256 -0
- package/dist/components/file-upload.js +490 -0
- package/dist/components/formatted-input.d.ts +177 -0
- package/dist/components/formatted-input.js +399 -0
- package/dist/components/hierarchy-chart.d.ts +190 -0
- package/dist/components/hierarchy-chart.js +890 -0
- package/dist/components/hover-card.d.ts +21 -0
- package/dist/components/hover-card.js +32 -0
- package/dist/components/iban-input.d.ts +38 -0
- package/dist/components/iban-input.js +112 -0
- package/dist/components/id-input.d.ts +65 -0
- package/dist/components/id-input.js +130 -0
- package/dist/components/image.d.ts +130 -0
- package/dist/components/image.js +168 -0
- package/dist/components/input-otp.d.ts +62 -0
- package/dist/components/input-otp.js +73 -0
- package/dist/components/input.d.ts +141 -0
- package/dist/components/input.js +187 -0
- package/dist/components/item.d.ts +96 -0
- package/dist/components/item.js +113 -0
- package/dist/components/kbd.d.ts +64 -0
- package/dist/components/kbd.js +119 -0
- package/dist/components/list-layout.d.ts +144 -0
- package/dist/components/list-layout.js +210 -0
- package/dist/components/native-select.d.ts +33 -0
- package/dist/components/native-select.js +48 -0
- package/dist/components/navigation-menu.d.ts +127 -0
- package/dist/components/navigation-menu.js +129 -0
- package/dist/components/notification-center.d.ts +164 -0
- package/dist/components/notification-center.js +399 -0
- package/dist/components/page-header.d.ts +60 -0
- package/dist/components/page-header.js +60 -0
- package/dist/components/pagination.d.ts +121 -0
- package/dist/components/pagination.js +174 -0
- package/dist/components/phone-input.d.ts +49 -0
- package/dist/components/phone-input.js +266 -0
- package/dist/components/pin-map.d.ts +58 -0
- package/dist/components/pin-map.js +167 -0
- package/dist/components/popover.d.ts +38 -0
- package/dist/components/popover.js +69 -0
- package/dist/components/progress.d.ts +79 -0
- package/dist/components/progress.js +97 -0
- package/dist/components/qr-code.d.ts +36 -0
- package/dist/components/qr-code.js +27 -0
- package/dist/components/radio-group.d.ts +43 -0
- package/dist/components/radio-group.js +81 -0
- package/dist/components/record-detail-layout.d.ts +167 -0
- package/dist/components/record-detail-layout.js +233 -0
- package/dist/components/record-picker.d.ts +199 -0
- package/dist/components/record-picker.js +650 -0
- package/dist/components/resizable.d.ts +50 -0
- package/dist/components/resizable.js +88 -0
- package/dist/components/scroll-area.d.ts +40 -0
- package/dist/components/scroll-area.js +56 -0
- package/dist/components/select.d.ts +126 -0
- package/dist/components/select.js +137 -0
- package/dist/components/separator.d.ts +31 -0
- package/dist/components/separator.js +41 -0
- package/dist/components/settings-layout.d.ts +134 -0
- package/dist/components/settings-layout.js +180 -0
- package/dist/components/sheet.d.ts +103 -0
- package/dist/components/sheet.js +165 -0
- package/dist/components/sidebar.d.ts +171 -0
- package/dist/components/sidebar.js +421 -0
- package/dist/components/signature-pad.d.ts +85 -0
- package/dist/components/signature-pad.js +283 -0
- package/dist/components/skeleton.d.ts +64 -0
- package/dist/components/skeleton.js +53 -0
- package/dist/components/sla-timer.d.ts +75 -0
- package/dist/components/sla-timer.js +142 -0
- package/dist/components/slider.d.ts +57 -0
- package/dist/components/slider.js +133 -0
- package/dist/components/slug-input.d.ts +69 -0
- package/dist/components/slug-input.js +201 -0
- package/dist/components/sparkline.d.ts +54 -0
- package/dist/components/sparkline.js +122 -0
- package/dist/components/spinner.d.ts +34 -0
- package/dist/components/spinner.js +34 -0
- package/dist/components/stat.d.ts +135 -0
- package/dist/components/stat.js +130 -0
- package/dist/components/status-picker.d.ts +107 -0
- package/dist/components/status-picker.js +175 -0
- package/dist/components/stepper.d.ts +86 -0
- package/dist/components/stepper.js +103 -0
- package/dist/components/switch.d.ts +34 -0
- package/dist/components/switch.js +70 -0
- package/dist/components/table.d.ts +101 -0
- package/dist/components/table.js +72 -0
- package/dist/components/tabs.d.ts +103 -0
- package/dist/components/tabs.js +173 -0
- package/dist/components/tag-input.d.ts +77 -0
- package/dist/components/tag-input.js +305 -0
- package/dist/components/task-list.d.ts +89 -0
- package/dist/components/task-list.js +238 -0
- package/dist/components/time-picker.d.ts +119 -0
- package/dist/components/time-picker.js +399 -0
- package/dist/components/toast.d.ts +87 -0
- package/dist/components/toast.js +142 -0
- package/dist/components/toggle.d.ts +77 -0
- package/dist/components/toggle.js +109 -0
- package/dist/components/tooltip.d.ts +69 -0
- package/dist/components/tooltip.js +105 -0
- package/dist/components/top-bar.d.ts +87 -0
- package/dist/components/top-bar.js +99 -0
- package/dist/components/tour.d.ts +60 -0
- package/dist/components/tour.js +139 -0
- package/dist/components/tree-select.d.ts +89 -0
- package/dist/components/tree-select.js +243 -0
- package/dist/components/tree-view.d.ts +109 -0
- package/dist/components/tree-view.js +170 -0
- package/dist/components/typography.d.ts +107 -0
- package/dist/components/typography.js +128 -0
- package/dist/components/user-picker.d.ts +89 -0
- package/dist/components/user-picker.js +162 -0
- package/dist/components/version-history.d.ts +191 -0
- package/dist/components/version-history.js +431 -0
- package/dist/data-table/csv.d.ts +27 -0
- package/dist/data-table/csv.js +68 -0
- package/dist/data-table/data-table.d.ts +423 -0
- package/dist/data-table/data-table.js +1259 -0
- package/dist/data-table/filter-bar.d.ts +146 -0
- package/dist/data-table/filter-bar.js +569 -0
- package/dist/data-table/filter-fns.d.ts +65 -0
- package/dist/data-table/filter-fns.js +382 -0
- package/dist/data-table/index.d.ts +8 -0
- package/dist/data-table/index.js +9 -0
- package/dist/data-table/saved-views.d.ts +100 -0
- package/dist/data-table/saved-views.js +251 -0
- package/dist/data-table/types.d.ts +168 -0
- package/dist/data-table/types.js +87 -0
- package/dist/data-table/url-state.d.ts +94 -0
- package/dist/data-table/url-state.js +303 -0
- package/dist/data-table/view-state.d.ts +16 -0
- package/dist/data-table/view-state.js +81 -0
- package/dist/editor/_test-setup.d.ts +1 -0
- package/dist/editor/_test-setup.js +33 -0
- package/dist/editor/block-editor.d.ts +137 -0
- package/dist/editor/block-editor.js +280 -0
- package/dist/editor/commands.d.ts +31 -0
- package/dist/editor/commands.js +150 -0
- package/dist/editor/context.d.ts +108 -0
- package/dist/editor/context.js +30 -0
- package/dist/editor/convert.d.ts +66 -0
- package/dist/editor/convert.js +567 -0
- package/dist/editor/drag-handle.d.ts +10 -0
- package/dist/editor/drag-handle.js +69 -0
- package/dist/editor/extensions.d.ts +34 -0
- package/dist/editor/extensions.js +239 -0
- package/dist/editor/index.d.ts +14 -0
- package/dist/editor/index.js +17 -0
- package/dist/editor/inserter.d.ts +12 -0
- package/dist/editor/inserter.js +88 -0
- package/dist/editor/inspector.d.ts +17 -0
- package/dist/editor/inspector.js +65 -0
- package/dist/editor/items.d.ts +62 -0
- package/dist/editor/items.js +195 -0
- package/dist/editor/labels.d.ts +119 -0
- package/dist/editor/labels.js +130 -0
- package/dist/editor/markdown.d.ts +14 -0
- package/dist/editor/markdown.js +209 -0
- package/dist/editor/menus.d.ts +20 -0
- package/dist/editor/menus.js +236 -0
- package/dist/editor/nodes.d.ts +14 -0
- package/dist/editor/nodes.js +201 -0
- package/dist/editor/outline.d.ts +11 -0
- package/dist/editor/outline.js +52 -0
- package/dist/editor/schema-form.d.ts +64 -0
- package/dist/editor/schema-form.js +290 -0
- package/dist/editor/slash-menu.d.ts +15 -0
- package/dist/editor/slash-menu.js +119 -0
- package/dist/fonts/catalog.d.ts +53 -0
- package/dist/fonts/catalog.js +121 -0
- package/dist/fonts/font-picker.d.ts +70 -0
- package/dist/fonts/font-picker.js +225 -0
- package/dist/fonts/index.d.ts +6 -0
- package/dist/fonts/index.js +7 -0
- package/dist/fonts/loader.d.ts +66 -0
- package/dist/fonts/loader.js +161 -0
- package/dist/fonts/pairing-picker.d.ts +31 -0
- package/dist/fonts/pairing-picker.js +81 -0
- package/dist/fonts/pairings.d.ts +84 -0
- package/dist/fonts/pairings.js +149 -0
- package/dist/fonts/provider.d.ts +34 -0
- package/dist/fonts/provider.js +51 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.js +1 -0
- package/dist/format/core.d.ts +149 -0
- package/dist/format/core.js +357 -0
- package/dist/format/index.d.ts +4 -0
- package/dist/format/index.js +5 -0
- package/dist/format/use-format.d.ts +1 -0
- package/dist/format/use-format.js +3 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +92 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.js +16 -0
- package/dist/lib/color.d.ts +64 -0
- package/dist/lib/color.js +177 -0
- package/dist/lib/compose-refs.d.ts +24 -0
- package/dist/lib/compose-refs.js +45 -0
- package/dist/lib/data-islands.d.ts +194 -0
- package/dist/lib/data-islands.js +368 -0
- package/dist/lib/date.d.ts +129 -0
- package/dist/lib/date.js +386 -0
- package/dist/lib/field-context.d.ts +64 -0
- package/dist/lib/field-context.js +62 -0
- package/dist/lib/floating-arrow.d.ts +18 -0
- package/dist/lib/floating-arrow.js +15 -0
- package/dist/lib/islands.d.ts +38 -0
- package/dist/lib/islands.js +40 -0
- package/dist/lib/labels.d.ts +51 -0
- package/dist/lib/labels.js +56 -0
- package/dist/lib/layer.d.ts +36 -0
- package/dist/lib/layer.js +42 -0
- package/dist/lib/locale.d.ts +85 -0
- package/dist/lib/locale.js +105 -0
- package/dist/lib/menu.d.ts +58 -0
- package/dist/lib/menu.js +99 -0
- package/dist/lib/message-format.d.ts +20 -0
- package/dist/lib/message-format.js +116 -0
- package/dist/lib/nav.d.ts +132 -0
- package/dist/lib/nav.js +178 -0
- package/dist/lib/provider.d.ts +100 -0
- package/dist/lib/provider.js +105 -0
- package/dist/lib/public.d.ts +23 -0
- package/dist/lib/public.js +34 -0
- package/dist/lib/sr-name.d.ts +18 -0
- package/dist/lib/sr-name.js +17 -0
- package/dist/lib/text.d.ts +100 -0
- package/dist/lib/text.js +233 -0
- package/dist/lib/theme-scope.d.ts +58 -0
- package/dist/lib/theme-scope.js +59 -0
- package/dist/lib/use-async-list.d.ts +60 -0
- package/dist/lib/use-async-list.js +119 -0
- package/dist/lib/use-container-width.d.ts +19 -0
- package/dist/lib/use-container-width.js +39 -0
- package/dist/lib/use-controllable-state.d.ts +33 -0
- package/dist/lib/use-controllable-state.js +56 -0
- package/dist/lib/use-edge-fade.d.ts +13 -0
- package/dist/lib/use-edge-fade.js +43 -0
- package/dist/lib/use-formatted-input.d.ts +69 -0
- package/dist/lib/use-formatted-input.js +152 -0
- package/dist/lib/use-hotkeys.d.ts +80 -0
- package/dist/lib/use-hotkeys.js +221 -0
- package/dist/lib/use-hover-intent.d.ts +44 -0
- package/dist/lib/use-hover-intent.js +119 -0
- package/dist/lib/use-media-query.d.ts +21 -0
- package/dist/lib/use-media-query.js +28 -0
- package/dist/lib/use-reduced-motion.d.ts +8 -0
- package/dist/lib/use-reduced-motion.js +13 -0
- package/dist/lib/use-tree.d.ts +153 -0
- package/dist/lib/use-tree.js +534 -0
- package/dist/lib/value-format.d.ts +25 -0
- package/dist/lib/value-format.js +56 -0
- package/dist/lib/variants.d.ts +131 -0
- package/dist/lib/variants.js +109 -0
- package/dist/locale-data/core/date.d.ts +24 -0
- package/dist/locale-data/core/date.js +68 -0
- package/dist/locale-data/core/decimal.d.ts +19 -0
- package/dist/locale-data/core/decimal.js +79 -0
- package/dist/locale-data/core/holidays.d.ts +30 -0
- package/dist/locale-data/core/holidays.js +79 -0
- package/dist/locale-data/core/iban.d.ts +29 -0
- package/dist/locale-data/core/iban.js +74 -0
- package/dist/locale-data/core/index.d.ts +7 -0
- package/dist/locale-data/core/index.js +6 -0
- package/dist/locale-data/core/types.d.ts +173 -0
- package/dist/locale-data/core/types.js +6 -0
- package/dist/locale-data/core/week-info.d.ts +23 -0
- package/dist/locale-data/core/week-info.js +85 -0
- package/dist/locale-data/core/working-days.d.ts +27 -0
- package/dist/locale-data/core/working-days.js +133 -0
- package/dist/locale-data/index.d.ts +2 -0
- package/dist/locale-data/index.js +4 -0
- package/dist/locale-data/tr/address-tr.json +1 -0
- package/dist/locale-data/tr/address.d.ts +23 -0
- package/dist/locale-data/tr/address.js +52 -0
- package/dist/locale-data/tr/holidays.d.ts +31 -0
- package/dist/locale-data/tr/holidays.js +81 -0
- package/dist/locale-data/tr/iban.d.ts +21 -0
- package/dist/locale-data/tr/iban.js +45 -0
- package/dist/locale-data/tr/id.d.ts +36 -0
- package/dist/locale-data/tr/id.js +120 -0
- package/dist/locale-data/tr/index.d.ts +12 -0
- package/dist/locale-data/tr/index.js +33 -0
- package/dist/locale-data/tr/kdv.d.ts +91 -0
- package/dist/locale-data/tr/kdv.js +222 -0
- package/dist/locales/en.d.ts +2102 -0
- package/dist/locales/en.js +2088 -0
- package/dist/locales/tr.d.ts +2086 -0
- package/dist/locales/tr.js +2087 -0
- package/dist/media/focal-point.d.ts +42 -0
- package/dist/media/focal-point.js +96 -0
- package/dist/media/gallery-layout.d.ts +19 -0
- package/dist/media/gallery-layout.js +61 -0
- package/dist/media/gallery.d.ts +64 -0
- package/dist/media/gallery.js +140 -0
- package/dist/media/image-cropper.d.ts +86 -0
- package/dist/media/image-cropper.js +170 -0
- package/dist/media/image-field.d.ts +115 -0
- package/dist/media/image-field.js +212 -0
- package/dist/media/index.d.ts +19 -0
- package/dist/media/index.js +23 -0
- package/dist/media/lightbox.d.ts +82 -0
- package/dist/media/lightbox.js +171 -0
- package/dist/media/link-preview.d.ts +97 -0
- package/dist/media/link-preview.js +177 -0
- package/dist/media/media-library.d.ts +244 -0
- package/dist/media/media-library.js +776 -0
- package/dist/media/media-picker.d.ts +96 -0
- package/dist/media/media-picker.js +209 -0
- package/dist/media/media-provider.d.ts +23 -0
- package/dist/media/media-provider.js +44 -0
- package/dist/media/media-utils.d.ts +39 -0
- package/dist/media/media-utils.js +145 -0
- package/dist/media/memory-adapter.d.ts +22 -0
- package/dist/media/memory-adapter.js +162 -0
- package/dist/media/rest-adapter.d.ts +90 -0
- package/dist/media/rest-adapter.js +208 -0
- package/dist/media/serp.d.ts +62 -0
- package/dist/media/serp.js +108 -0
- package/dist/media/test-fixtures.d.ts +3 -0
- package/dist/media/test-fixtures.js +37 -0
- package/dist/media/types.d.ts +183 -0
- package/dist/media/types.js +3 -0
- package/dist/media/use-pan-zoom.d.ts +51 -0
- package/dist/media/use-pan-zoom.js +156 -0
- package/dist/media/use-upload-queue.d.ts +64 -0
- package/dist/media/use-upload-queue.js +115 -0
- package/dist/media/video-player.d.ts +135 -0
- package/dist/media/video-player.js +319 -0
- package/dist/motion/core.d.ts +32 -0
- package/dist/motion/core.js +77 -0
- package/dist/motion/count-up.d.ts +29 -0
- package/dist/motion/count-up.js +92 -0
- package/dist/motion/index.d.ts +11 -0
- package/dist/motion/index.js +13 -0
- package/dist/motion/motion-scope.d.ts +17 -0
- package/dist/motion/motion-scope.js +16 -0
- package/dist/motion/page-transition.d.ts +33 -0
- package/dist/motion/page-transition.js +61 -0
- package/dist/motion/parallax.d.ts +37 -0
- package/dist/motion/parallax.js +90 -0
- package/dist/motion/pointer.d.ts +38 -0
- package/dist/motion/pointer.js +117 -0
- package/dist/motion/reveal.d.ts +72 -0
- package/dist/motion/reveal.js +133 -0
- package/dist/motion/scroll-shrink.d.ts +18 -0
- package/dist/motion/scroll-shrink.js +47 -0
- package/dist/motion/skeleton-swap.d.ts +17 -0
- package/dist/motion/skeleton-swap.js +43 -0
- package/dist/motion/text-reveal.d.ts +30 -0
- package/dist/motion/text-reveal.js +29 -0
- package/dist/motion/ticker.d.ts +35 -0
- package/dist/motion/ticker.js +16 -0
- package/dist/next/index.d.ts +42 -0
- package/dist/next/index.js +36 -0
- package/dist/render/block-renderer.d.ts +56 -0
- package/dist/render/block-renderer.js +137 -0
- package/dist/render/index.d.ts +6 -0
- package/dist/render/index.js +7 -0
- package/dist/render/prepare.d.ts +61 -0
- package/dist/render/prepare.js +119 -0
- package/dist/scheduler/core/duration.d.ts +83 -0
- package/dist/scheduler/core/duration.js +174 -0
- package/dist/scheduler/core/gantt.d.ts +63 -0
- package/dist/scheduler/core/gantt.js +226 -0
- package/dist/scheduler/core/index.d.ts +6 -0
- package/dist/scheduler/core/index.js +7 -0
- package/dist/scheduler/core/layout.d.ts +97 -0
- package/dist/scheduler/core/layout.js +249 -0
- package/dist/scheduler/core/time-scale.d.ts +89 -0
- package/dist/scheduler/core/time-scale.js +173 -0
- package/dist/scheduler/gantt.d.ts +125 -0
- package/dist/scheduler/gantt.js +532 -0
- package/dist/scheduler/index.d.ts +6 -0
- package/dist/scheduler/index.js +7 -0
- package/dist/scheduler/resource-calendar.d.ts +218 -0
- package/dist/scheduler/resource-calendar.js +661 -0
- package/dist/scheduler/scheduler.d.ts +168 -0
- package/dist/scheduler/scheduler.js +768 -0
- package/dist/scheduler/shared.d.ts +63 -0
- package/dist/scheduler/shared.js +145 -0
- package/dist/scheduler/time-tracker.d.ts +138 -0
- package/dist/scheduler/time-tracker.js +403 -0
- package/dist/sortable/core.d.ts +67 -0
- package/dist/sortable/core.js +167 -0
- package/dist/sortable/index.d.ts +8 -0
- package/dist/sortable/index.js +10 -0
- package/dist/sortable/kanban-core.d.ts +70 -0
- package/dist/sortable/kanban-core.js +67 -0
- package/dist/sortable/kanban.d.ts +147 -0
- package/dist/sortable/kanban.js +472 -0
- package/dist/sortable/sortable-list.d.ts +71 -0
- package/dist/sortable/sortable-list.js +76 -0
- package/dist/sortable/sortable-tree.d.ts +105 -0
- package/dist/sortable/sortable-tree.js +462 -0
- package/dist/sortable/sortable.d.ts +188 -0
- package/dist/sortable/sortable.js +485 -0
- package/dist/sortable/use-pointer-drag.d.ts +75 -0
- package/dist/sortable/use-pointer-drag.js +173 -0
- package/dist/sortable/use-time-scale.d.ts +11 -0
- package/dist/sortable/use-time-scale.js +19 -0
- package/dist/styles/base.css +51 -0
- package/dist/styles/blocks.css +949 -0
- package/dist/styles/calendar.css +642 -0
- package/dist/styles/charts.css +264 -0
- package/dist/styles/data.css +474 -0
- package/dist/styles/editors.css +1022 -0
- package/dist/styles/forms.css +406 -0
- package/dist/styles/media.css +515 -0
- package/dist/styles/motion.css +389 -0
- package/dist/styles/navigation.css +293 -0
- package/dist/styles/overlays.css +244 -0
- package/dist/styles.css +743 -0
- package/package.json +160 -4
|
@@ -0,0 +1,99 @@
|
|
|
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 { ChevronDown, Menu, Search } from "lucide-react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { useLabels } from "../lib/labels.js";
|
|
7
|
+
import { IconButton } from "./button.js";
|
|
8
|
+
import { KbdGroup } from "./kbd.js";
|
|
9
|
+
import { Avatar } from "./avatar.js";
|
|
10
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuEntries, DropdownMenuTrigger } from "./dropdown-menu.js";
|
|
11
|
+
import { useCommandPalette } from "./command.js";
|
|
12
|
+
const topBarLabels = {
|
|
13
|
+
search: "Search or run a command…",
|
|
14
|
+
searchShort: "Search",
|
|
15
|
+
menu: "Open menu",
|
|
16
|
+
account: "Account menu for {name}",
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Bridge between the top bar and the App shell (mobile nav button). App shell provides it; outside
|
|
20
|
+
* a shell the menu button needs its own `onClick`.
|
|
21
|
+
*/
|
|
22
|
+
export const TopBarShellContext = React.createContext(null);
|
|
23
|
+
/**
|
|
24
|
+
* The sticky bar above the content: mobile menu button, ⌘K search, contextual actions,
|
|
25
|
+
* notifications and the user menu. The same in every app.
|
|
26
|
+
*
|
|
27
|
+
* ```tsx
|
|
28
|
+
* <TopBar>
|
|
29
|
+
* <TopBarStart><TopBarMenuButton /></TopBarStart>
|
|
30
|
+
* <TopBarSearch />
|
|
31
|
+
* <TopBarSpacer />
|
|
32
|
+
* <TopBarActions><NotificationCenter adapter={inbox} /><UserMenu name="Ada Lovelace" items={account} /></TopBarActions>
|
|
33
|
+
* </TopBar>
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export const TopBar = React.forwardRef(function TopBar({ sticky = true, variant = "bar", scrollTarget, className, role, ...props }, ref) {
|
|
37
|
+
const [scrolled, setScrolled] = React.useState(false);
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
if (typeof window === "undefined")
|
|
40
|
+
return;
|
|
41
|
+
const el = scrollTarget?.current;
|
|
42
|
+
const read = () => setScrolled((el ? el.scrollTop : window.scrollY) > 4);
|
|
43
|
+
read();
|
|
44
|
+
const target = el ?? window;
|
|
45
|
+
target.addEventListener("scroll", read, { passive: true });
|
|
46
|
+
return () => target.removeEventListener("scroll", read);
|
|
47
|
+
}, [scrollTarget]);
|
|
48
|
+
return (_jsx("header", { ref: ref, role: role ?? "banner", "data-slot": "top-bar", "data-variant": variant, "data-scrolled": scrolled ? "" : undefined, className: cn("vui-top-bar surface-bar @container/topbar flex h-(--topbar-h) min-w-0 shrink-0 items-center gap-2 px-3 sm:gap-3 sm:px-5 lg:px-6", "transition-[background-color,border-color] duration-200", sticky && "sticky top-0 z-(--z-sticky)", className), ...props }));
|
|
49
|
+
});
|
|
50
|
+
/** Leading slot: menu button, breadcrumb. */
|
|
51
|
+
export function TopBarStart({ className, ...props }) {
|
|
52
|
+
return _jsx("div", { "data-slot": "top-bar-start", className: cn("flex min-w-0 items-center gap-2", className), ...props });
|
|
53
|
+
}
|
|
54
|
+
/** Pushes the following slots to the end. */
|
|
55
|
+
export function TopBarSpacer({ className }) {
|
|
56
|
+
return _jsx("div", { "aria-hidden": true, "data-slot": "top-bar-spacer", className: cn("min-w-0 flex-1", className) });
|
|
57
|
+
}
|
|
58
|
+
/** Trailing slot: theme switch, notifications, "New", user menu. */
|
|
59
|
+
export function TopBarActions({ className, ...props }) {
|
|
60
|
+
return _jsx("div", { "data-slot": "top-bar-actions", className: cn("flex shrink-0 items-center gap-1 sm:gap-1.5", className), ...props });
|
|
61
|
+
}
|
|
62
|
+
/** A short vertical rule between action groups. */
|
|
63
|
+
export function TopBarSeparator({ className }) {
|
|
64
|
+
return _jsx("span", { "aria-hidden": true, "data-slot": "top-bar-separator", className: cn("mx-1 h-5 w-px shrink-0 bg-line", className) });
|
|
65
|
+
}
|
|
66
|
+
/** Opens the App shell's mobile navigation. Visible only below 768px. */
|
|
67
|
+
export const TopBarMenuButton = React.forwardRef(function TopBarMenuButton({ className, onClick, labels, ...props }, ref) {
|
|
68
|
+
const shell = React.useContext(TopBarShellContext);
|
|
69
|
+
const t = useLabels("topBar", topBarLabels, labels);
|
|
70
|
+
return (_jsx(IconButton, { ref: ref, label: t("menu"), size: "sm", tooltip: false, "aria-expanded": shell ? shell.mobileNavOpen : undefined, "aria-haspopup": "dialog", onClick: (e) => {
|
|
71
|
+
onClick?.(e);
|
|
72
|
+
if (!e.defaultPrevented)
|
|
73
|
+
shell?.openMobileNav();
|
|
74
|
+
}, className: cn(shell ? "@min-[768px]/shell:hidden" : "md:hidden", "-ms-1", className), ...props, children: _jsx(Menu, {}) }));
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* The ⌘K trigger: a real button that looks like a field. Collapses to an icon button when the bar is
|
|
78
|
+
* narrower than 560px.
|
|
79
|
+
*/
|
|
80
|
+
export const TopBarSearch = React.forwardRef(function TopBarSearch({ placeholder, shortcut = "mod+k", onOpen, onClick, className, labels, ...props }, ref) {
|
|
81
|
+
const t = useLabels("topBar", topBarLabels, labels);
|
|
82
|
+
const palette = useCommandPalette();
|
|
83
|
+
const open = (e) => {
|
|
84
|
+
onClick?.(e);
|
|
85
|
+
if (e.defaultPrevented)
|
|
86
|
+
return;
|
|
87
|
+
if (onOpen)
|
|
88
|
+
onOpen();
|
|
89
|
+
else
|
|
90
|
+
palette.open();
|
|
91
|
+
};
|
|
92
|
+
const text = placeholder ?? t("search");
|
|
93
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { ref: ref, type: "button", "aria-haspopup": "dialog", "aria-keyshortcuts": shortcut ? "Meta+K Control+K" : undefined, onClick: open, "data-slot": "top-bar-search", className: cn("group flex h-[calc(var(--control-h)-0.5rem)] w-full max-w-80 min-w-0 items-center gap-2 rounded-full border border-field-border bg-field ps-3 pe-1.5 text-[13px] text-fg-subtle", "transition-[border-color,background-color] hover:border-field-border-hover focus-ring @max-[560px]/topbar:hidden", className), ...props, children: [_jsx(Search, { "aria-hidden": true, className: "size-3.5 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1 truncate text-start", children: text }), shortcut ? _jsx(KbdGroup, { keys: shortcut, size: "sm", className: "shrink-0" }) : null] }), _jsx(IconButton, { label: t("searchShort"), size: "sm", tooltip: false, "aria-haspopup": "dialog", onClick: open, className: "hidden @max-[560px]/topbar:inline-flex", children: _jsx(Search, {}) })] }));
|
|
94
|
+
});
|
|
95
|
+
/** The avatar button with the account menu. */
|
|
96
|
+
export function UserMenu({ name, email, avatar, items, showName, children, align = "end", className, labels }) {
|
|
97
|
+
const t = useLabels("topBar", topBarLabels, labels);
|
|
98
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { type: "button", "data-slot": "user-menu-trigger", className: cn("flex shrink-0 items-center gap-2 rounded-full p-0.5 transition-colors hover:bg-hover focus-ring", showName && "pe-2", className), children: [_jsx("span", { className: "sr-only", children: t("account", { name }) }), _jsx(Avatar, { name: name, src: avatar, size: "sm", "aria-hidden": true }), showName ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: "max-w-32 truncate text-[13px] font-medium text-fg", children: name }), _jsx(ChevronDown, { "aria-hidden": true, className: "size-3.5 text-fg-subtle" })] })) : null] }) }), _jsxs(DropdownMenuContent, { align: align, className: "min-w-60", children: [_jsxs("div", { className: "flex items-center gap-2.5 px-2 pt-1.5 pb-2", children: [_jsx(Avatar, { name: name, src: avatar, size: "md", "aria-hidden": true }), _jsxs("div", { className: "min-w-0 leading-tight", children: [_jsx("p", { className: "truncate text-[13.5px] font-medium text-fg", children: name }), email ? _jsx("p", { className: "truncate text-xs text-fg-subtle", children: email }) : null] })] }), children, _jsx("div", { role: "none", className: "-mx-1 my-1 h-px bg-line" }), _jsx(DropdownMenuEntries, { items: items })] })] }));
|
|
99
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export declare const tourLabels: {
|
|
3
|
+
next: string;
|
|
4
|
+
back: string;
|
|
5
|
+
done: string;
|
|
6
|
+
skip: string;
|
|
7
|
+
progress: string;
|
|
8
|
+
};
|
|
9
|
+
export type TourLabels = typeof tourLabels;
|
|
10
|
+
export interface TourStep {
|
|
11
|
+
/** Stable key (defaults to the index). */
|
|
12
|
+
id?: string;
|
|
13
|
+
/**
|
|
14
|
+
* What to highlight: a CSS selector (`"[data-tour=new-order]"`), a ref, or a function.
|
|
15
|
+
* Missing or not found → the card shows centred without a spotlight.
|
|
16
|
+
*/
|
|
17
|
+
target?: string | React.RefObject<Element | null> | (() => Element | null);
|
|
18
|
+
title: React.ReactNode;
|
|
19
|
+
description?: React.ReactNode;
|
|
20
|
+
/** Extra body under the description (an illustration, a shortcut hint). */
|
|
21
|
+
content?: React.ReactNode;
|
|
22
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
23
|
+
align?: "start" | "center" | "end";
|
|
24
|
+
/** Space between the target and the spotlight edge, px. Default `6`. */
|
|
25
|
+
padding?: number;
|
|
26
|
+
/** Spotlight corner radius, px. Default `10`. */
|
|
27
|
+
radius?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface TourProps {
|
|
30
|
+
steps: TourStep[];
|
|
31
|
+
open?: boolean;
|
|
32
|
+
defaultOpen?: boolean;
|
|
33
|
+
onOpenChange?: (open: boolean) => void;
|
|
34
|
+
/** Current step index (controlled). */
|
|
35
|
+
step?: number;
|
|
36
|
+
defaultStep?: number;
|
|
37
|
+
onStepChange?: (step: number) => void;
|
|
38
|
+
/** "Done" on the last step. The tour closes afterwards. */
|
|
39
|
+
onComplete?: () => void;
|
|
40
|
+
/** Closed early (skip button or Escape) on step `index`. */
|
|
41
|
+
onSkip?: (index: number) => void;
|
|
42
|
+
/** Clicking the dimmed page closes the tour. Default `false`. */
|
|
43
|
+
dismissible?: boolean;
|
|
44
|
+
/** Card class (width, etc.). */
|
|
45
|
+
className?: string;
|
|
46
|
+
labels?: Partial<TourLabels>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Guided product tour: dims the page, cuts a spotlight around each target and anchors a step
|
|
50
|
+
* card to it. Back / Next / Done, arrow keys between steps, Escape to skip. The card is a modal
|
|
51
|
+
* dialog labelled by the step title; focus returns to where it was when the tour ends.
|
|
52
|
+
*
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <Tour open={open} onOpenChange={setOpen} steps={[
|
|
55
|
+
* { target: "[data-tour=search]", title: "Search everything", description: "Press ⌘K from any page." },
|
|
56
|
+
* { target: "[data-tour=new]", title: "Create", description: "Orders, customers and products start here.", side: "left" },
|
|
57
|
+
* ]} />
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function Tour({ steps, open: openProp, defaultOpen, onOpenChange, step: stepProp, defaultStep, onStepChange, onComplete, onSkip, dismissible, className, labels }: TourProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
5
|
+
import { X } from "lucide-react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { useLabels } from "../lib/labels.js";
|
|
8
|
+
import { useControllableState } from "../lib/use-controllable-state.js";
|
|
9
|
+
import { useReducedMotion } from "../lib/use-reduced-motion.js";
|
|
10
|
+
import { usePortalContainer } from "../lib/theme-scope.js";
|
|
11
|
+
import { Layer } from "../lib/layer.js";
|
|
12
|
+
import { Button } from "./button.js";
|
|
13
|
+
export const tourLabels = {
|
|
14
|
+
next: "Next",
|
|
15
|
+
back: "Back",
|
|
16
|
+
done: "Done",
|
|
17
|
+
skip: "Skip tour",
|
|
18
|
+
progress: "Step {current} of {total}",
|
|
19
|
+
};
|
|
20
|
+
function resolveTarget(target) {
|
|
21
|
+
if (!target || typeof document === "undefined")
|
|
22
|
+
return null;
|
|
23
|
+
if (typeof target === "string")
|
|
24
|
+
return document.querySelector(target);
|
|
25
|
+
if (typeof target === "function")
|
|
26
|
+
return target();
|
|
27
|
+
return target.current;
|
|
28
|
+
}
|
|
29
|
+
const sameBox = (a, b) => a === b || (!!a && !!b && a.top === b.top && a.left === b.left && a.width === b.width && a.height === b.height);
|
|
30
|
+
/**
|
|
31
|
+
* Guided product tour: dims the page, cuts a spotlight around each target and anchors a step
|
|
32
|
+
* card to it. Back / Next / Done, arrow keys between steps, Escape to skip. The card is a modal
|
|
33
|
+
* dialog labelled by the step title; focus returns to where it was when the tour ends.
|
|
34
|
+
*
|
|
35
|
+
* ```tsx
|
|
36
|
+
* <Tour open={open} onOpenChange={setOpen} steps={[
|
|
37
|
+
* { target: "[data-tour=search]", title: "Search everything", description: "Press ⌘K from any page." },
|
|
38
|
+
* { target: "[data-tour=new]", title: "Create", description: "Orders, customers and products start here.", side: "left" },
|
|
39
|
+
* ]} />
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export function Tour({ steps, open: openProp, defaultOpen = false, onOpenChange, step: stepProp, defaultStep = 0, onStepChange, onComplete, onSkip, dismissible = false, className, labels }) {
|
|
43
|
+
const t = useLabels("tour", tourLabels, labels);
|
|
44
|
+
const [open, setOpen] = useControllableState({ value: openProp, defaultValue: defaultOpen, onChange: onOpenChange, name: "Tour" });
|
|
45
|
+
const [rawIndex, setIndex] = useControllableState({ value: stepProp, defaultValue: defaultStep, onChange: onStepChange, name: "Tour" });
|
|
46
|
+
const index = Math.max(0, Math.min(steps.length - 1, rawIndex));
|
|
47
|
+
const current = steps[index];
|
|
48
|
+
const reduced = useReducedMotion();
|
|
49
|
+
const container = usePortalContainer();
|
|
50
|
+
const titleId = React.useId();
|
|
51
|
+
const descId = React.useId();
|
|
52
|
+
const [box, setBox] = React.useState(null);
|
|
53
|
+
const boxRef = React.useRef(null);
|
|
54
|
+
const contentRef = React.useRef(null);
|
|
55
|
+
const pad = current?.padding ?? 6;
|
|
56
|
+
const radius = current?.radius ?? 10;
|
|
57
|
+
// Track the target's position every frame while open (layout shifts, scrolling, resizes).
|
|
58
|
+
React.useEffect(() => {
|
|
59
|
+
if (!open || !current)
|
|
60
|
+
return;
|
|
61
|
+
let frame = 0;
|
|
62
|
+
let scrolled = false;
|
|
63
|
+
const measure = () => {
|
|
64
|
+
const el = resolveTarget(current.target);
|
|
65
|
+
let next = null;
|
|
66
|
+
if (el) {
|
|
67
|
+
const r = el.getBoundingClientRect();
|
|
68
|
+
if (r.width || r.height)
|
|
69
|
+
next = { top: r.top - pad, left: r.left - pad, width: r.width + pad * 2, height: r.height + pad * 2 };
|
|
70
|
+
if (!scrolled) {
|
|
71
|
+
scrolled = true;
|
|
72
|
+
const vh = window.innerHeight;
|
|
73
|
+
const vw = window.innerWidth;
|
|
74
|
+
if (r.top < 0 || r.bottom > vh || r.left < 0 || r.right > vw)
|
|
75
|
+
el.scrollIntoView({ block: "center", inline: "nearest", behavior: reduced ? "auto" : "smooth" });
|
|
76
|
+
}
|
|
77
|
+
el.setAttribute("data-tour-active", "");
|
|
78
|
+
}
|
|
79
|
+
if (!sameBox(boxRef.current, next)) {
|
|
80
|
+
boxRef.current = next;
|
|
81
|
+
setBox(next);
|
|
82
|
+
}
|
|
83
|
+
frame = requestAnimationFrame(measure);
|
|
84
|
+
};
|
|
85
|
+
measure();
|
|
86
|
+
return () => {
|
|
87
|
+
cancelAnimationFrame(frame);
|
|
88
|
+
resolveTarget(current.target)?.removeAttribute("data-tour-active");
|
|
89
|
+
};
|
|
90
|
+
}, [open, current, pad, reduced]);
|
|
91
|
+
// The card anchors to the spotlight, or to the viewport centre when there is no target.
|
|
92
|
+
const anchorRef = React.useRef({
|
|
93
|
+
getBoundingClientRect: () => {
|
|
94
|
+
const b = boxRef.current;
|
|
95
|
+
if (b)
|
|
96
|
+
return DOMRect.fromRect({ x: b.left, y: b.top, width: b.width, height: b.height });
|
|
97
|
+
return DOMRect.fromRect({ x: window.innerWidth / 2, y: window.innerHeight * 0.3, width: 0, height: 0 });
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
if (!current)
|
|
101
|
+
return null;
|
|
102
|
+
const last = index === steps.length - 1;
|
|
103
|
+
const close = (completed) => {
|
|
104
|
+
setOpen(false);
|
|
105
|
+
if (completed)
|
|
106
|
+
onComplete?.();
|
|
107
|
+
else
|
|
108
|
+
onSkip?.(index);
|
|
109
|
+
};
|
|
110
|
+
const go = (to) => {
|
|
111
|
+
if (to < 0)
|
|
112
|
+
return;
|
|
113
|
+
if (to >= steps.length)
|
|
114
|
+
return close(true);
|
|
115
|
+
setIndex(to);
|
|
116
|
+
};
|
|
117
|
+
const onKeyDown = (e) => {
|
|
118
|
+
const tag = e.target.tagName;
|
|
119
|
+
if (tag === "INPUT" || tag === "TEXTAREA" || e.target.isContentEditable)
|
|
120
|
+
return;
|
|
121
|
+
const rtl = getComputedStyle(e.currentTarget).direction === "rtl";
|
|
122
|
+
if (e.key === (rtl ? "ArrowLeft" : "ArrowRight")) {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
go(index + 1);
|
|
125
|
+
}
|
|
126
|
+
else if (e.key === (rtl ? "ArrowRight" : "ArrowLeft")) {
|
|
127
|
+
e.preventDefault();
|
|
128
|
+
go(index - 1);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const transition = reduced ? undefined : "top 280ms cubic-bezier(.2,.7,.2,1), left 280ms cubic-bezier(.2,.7,.2,1), width 280ms cubic-bezier(.2,.7,.2,1), height 280ms cubic-bezier(.2,.7,.2,1)";
|
|
132
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: (o) => (!o ? close(false) : setOpen(true)), modal: true, children: [_jsx(PopoverPrimitive.Anchor, { virtualRef: anchorRef }), open ? (_jsx(PopoverPrimitive.Portal, { container: container, children: _jsx("div", { "data-slot": "tour-overlay", "aria-hidden": "true", className: "ui-fade pointer-events-auto fixed inset-0 z-(--z-overlay)", children: box ? (_jsx("div", { "data-slot": "tour-spotlight", className: "absolute outline-2 outline-offset-0 outline-[var(--ring)]", style: { top: box.top, left: box.left, width: box.width, height: box.height, borderRadius: radius, boxShadow: "0 0 0 200vmax var(--overlay)", transition } })) : (_jsx("div", { className: "absolute inset-0 bg-overlay" })) }) })) : null, _jsx(PopoverPrimitive.Portal, { container: container, children: _jsx(Layer, { asChild: true, children: _jsxs(PopoverPrimitive.Content, { ref: contentRef, "data-slot": "tour-card", side: box ? (current.side ?? "bottom") : "bottom", align: box ? (current.align ?? "center") : "center", sideOffset: box ? 12 : 0, collisionPadding: 16, updatePositionStrategy: "always", "aria-labelledby": titleId, "aria-describedby": current.description ? descId : undefined, onOpenAutoFocus: (e) => {
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
contentRef.current?.focus();
|
|
135
|
+
}, onInteractOutside: (e) => {
|
|
136
|
+
if (!dismissible)
|
|
137
|
+
e.preventDefault();
|
|
138
|
+
}, onKeyDown: onKeyDown, className: cn("surface-popover ui-pop z-(--z-popover) w-80 max-w-[calc(100vw-2rem)] rounded-ui-lg p-4 outline-none", className), children: [_jsxs("div", { className: "flex items-start gap-3", children: [_jsxs("div", { className: "grid min-w-0 flex-1 gap-1", children: [_jsx("p", { className: "text-[11px] font-medium tracking-[0.06em] text-fg-subtle uppercase tabular", children: t("progress", { current: index + 1, total: steps.length }) }), _jsx("h2", { id: titleId, className: "text-[15px] leading-snug font-semibold tracking-[-0.01em] text-fg", children: current.title })] }), _jsx(PopoverPrimitive.Close, { asChild: true, children: _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": t("skip"), title: t("skip"), className: "-me-1.5 -mt-1 shrink-0", children: _jsx(X, { "aria-hidden": "true" }) }) })] }), current.description ? (_jsx("p", { id: descId, className: "mt-2 text-[13px] leading-relaxed text-fg-muted", children: current.description })) : null, current.content ? _jsx("div", { className: "mt-3", children: current.content }) : null, _jsxs("div", { className: "mt-4 flex items-center gap-2", children: [_jsx("ol", { "aria-hidden": "true", className: "me-auto flex items-center gap-1", children: steps.map((s, i) => (_jsx("li", { className: cn("h-1.5 rounded-full transition-[width,background-color] duration-300 motion-reduce:transition-none", i === index ? "w-4 bg-accent" : i < index ? "w-1.5 bg-fg-muted" : "w-1.5 bg-track") }, s.id ?? i))) }), index > 0 ? (_jsx(Button, { size: "sm", variant: "ghost", onClick: () => go(index - 1), children: t("back") })) : null, _jsx(Button, { size: "sm", variant: "primary", onClick: () => go(index + 1), children: last ? t("done") : t("next") })] })] }, current.id ?? index) }) })] }));
|
|
139
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type TreeCheckValueMode, type TreeNode } from "../lib/use-tree.js";
|
|
3
|
+
declare const treeSelectLabels: {
|
|
4
|
+
placeholder: string;
|
|
5
|
+
placeholderMultiple: string;
|
|
6
|
+
search: string;
|
|
7
|
+
empty: string;
|
|
8
|
+
noMatches: string;
|
|
9
|
+
results: string;
|
|
10
|
+
addChild: string;
|
|
11
|
+
addUnder: string;
|
|
12
|
+
addRoot: string;
|
|
13
|
+
newName: string;
|
|
14
|
+
create: string;
|
|
15
|
+
cancel: string;
|
|
16
|
+
clear: string;
|
|
17
|
+
selectedCount: string;
|
|
18
|
+
};
|
|
19
|
+
export type TreeSelectLabels = typeof treeSelectLabels;
|
|
20
|
+
interface TreeSelectBaseProps {
|
|
21
|
+
/** The hierarchy (categories, departments, folders, accounts). */
|
|
22
|
+
nodes: TreeNode[];
|
|
23
|
+
/** Loads children of nodes with `hasChildren` on first expand. */
|
|
24
|
+
loadChildren?: (node: TreeNode, signal: AbortSignal) => Promise<TreeNode[]>;
|
|
25
|
+
/** Can parents be chosen, or only leaves? Default `"any"`. */
|
|
26
|
+
selectable?: "leaf" | "any";
|
|
27
|
+
/** Trigger shows the full path ("Electronics › Phones"). Default `true`. */
|
|
28
|
+
showPath?: boolean;
|
|
29
|
+
/** Initially expanded ids, or `"selected"` to open the branches of the value. Default `"selected"`. */
|
|
30
|
+
defaultExpanded?: string[] | "selected";
|
|
31
|
+
/** "Add category": create under the focused node (or at the top level). Add the returned node to `nodes` too. */
|
|
32
|
+
onCreate?: (parentId: string | null, label: string) => TreeNode | Promise<TreeNode>;
|
|
33
|
+
/** Show the search box. Default `true`. */
|
|
34
|
+
searchable?: boolean;
|
|
35
|
+
/** `"inline"` renders the tree without a popover (category box in an editor side panel). */
|
|
36
|
+
mode?: "popover" | "inline";
|
|
37
|
+
/** Max height of the tree list in px. Default 288. */
|
|
38
|
+
height?: number;
|
|
39
|
+
size?: "sm" | "md" | "lg";
|
|
40
|
+
placeholder?: string;
|
|
41
|
+
searchPlaceholder?: string;
|
|
42
|
+
/** Hidden input name(s) (multi → repeated). */
|
|
43
|
+
name?: string;
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
readOnly?: boolean;
|
|
46
|
+
invalid?: boolean;
|
|
47
|
+
required?: boolean;
|
|
48
|
+
open?: boolean;
|
|
49
|
+
defaultOpen?: boolean;
|
|
50
|
+
onOpenChange?: (open: boolean) => void;
|
|
51
|
+
labels?: Partial<TreeSelectLabels>;
|
|
52
|
+
id?: string;
|
|
53
|
+
className?: string;
|
|
54
|
+
"aria-label"?: string;
|
|
55
|
+
"aria-labelledby"?: string;
|
|
56
|
+
"aria-describedby"?: string;
|
|
57
|
+
"aria-invalid"?: boolean | "true" | "false";
|
|
58
|
+
}
|
|
59
|
+
export interface TreeSelectSingleProps extends TreeSelectBaseProps {
|
|
60
|
+
multiple?: false;
|
|
61
|
+
value?: string | null;
|
|
62
|
+
defaultValue?: string | null;
|
|
63
|
+
onValueChange?: (id: string | null, node: TreeNode | null) => void;
|
|
64
|
+
cascade?: never;
|
|
65
|
+
valueMode?: never;
|
|
66
|
+
}
|
|
67
|
+
export interface TreeSelectMultipleProps extends TreeSelectBaseProps {
|
|
68
|
+
multiple: true;
|
|
69
|
+
value?: string[];
|
|
70
|
+
defaultValue?: string[];
|
|
71
|
+
onValueChange?: (ids: string[]) => void;
|
|
72
|
+
/** Checking a parent checks its descendants (tri-state). Default `true`. */
|
|
73
|
+
cascade?: boolean;
|
|
74
|
+
/** What a fully-checked branch yields. Default `"all"`. */
|
|
75
|
+
valueMode?: TreeCheckValueMode;
|
|
76
|
+
}
|
|
77
|
+
export type TreeSelectProps = TreeSelectSingleProps | TreeSelectMultipleProps;
|
|
78
|
+
/**
|
|
79
|
+
* Pick from hierarchical data — product categories, departments, locations and warehouses,
|
|
80
|
+
* folder destinations, chart of accounts. A searchable tree in a popover (or inline), single or
|
|
81
|
+
* multi with tri-state cascade, lazy branches, search that keeps ancestors, and "Add category".
|
|
82
|
+
*
|
|
83
|
+
* ```tsx
|
|
84
|
+
* <Field label="Category"><TreeSelect nodes={categories} selectable="leaf" value={categoryId} onValueChange={setCategoryId} /></Field>
|
|
85
|
+
* <TreeSelect multiple nodes={regions} valueMode="parent" value={territories} onValueChange={setTerritories} />
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare const TreeSelect: React.ForwardRefExoticComponent<TreeSelectProps & React.RefAttributes<HTMLDivElement>>;
|
|
89
|
+
export {};
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Popover as PopoverPrimitive } from "radix-ui";
|
|
5
|
+
import { ChevronsUpDown, Plus, Search, X } from "lucide-react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { FieldContextReset, useFieldControl } from "../lib/field-context.js";
|
|
8
|
+
import { ChipRemoveButton } from "../lib/islands.js";
|
|
9
|
+
import { useLabels } from "../lib/labels.js";
|
|
10
|
+
import { Layer } from "../lib/layer.js";
|
|
11
|
+
import { useLocale } from "../lib/locale.js";
|
|
12
|
+
import { usePortalContainer } from "../lib/theme-scope.js";
|
|
13
|
+
import { useControllableState, useLatest } from "../lib/use-controllable-state.js";
|
|
14
|
+
import { useTree } from "../lib/use-tree.js";
|
|
15
|
+
import { controlVariants } from "../lib/variants.js";
|
|
16
|
+
import { Button } from "./button.js";
|
|
17
|
+
import { Spinner } from "./spinner.js";
|
|
18
|
+
import { TreeViewRow } from "./tree-view.js";
|
|
19
|
+
const treeSelectLabels = {
|
|
20
|
+
placeholder: "Select…",
|
|
21
|
+
placeholderMultiple: "Add…",
|
|
22
|
+
search: "Search…",
|
|
23
|
+
empty: "Nothing to choose from",
|
|
24
|
+
noMatches: "No matches for “{query}”",
|
|
25
|
+
results: "{count, plural, =0 {No matches} one {# match} other {# matches}}",
|
|
26
|
+
addChild: "Add",
|
|
27
|
+
addUnder: "New item in {parent}",
|
|
28
|
+
addRoot: "New top-level item",
|
|
29
|
+
newName: "Name",
|
|
30
|
+
create: "Create",
|
|
31
|
+
cancel: "Cancel",
|
|
32
|
+
clear: "Clear selection",
|
|
33
|
+
selectedCount: "{count, plural, one {# selected} other {# selected}}",
|
|
34
|
+
};
|
|
35
|
+
const EMPTY = [];
|
|
36
|
+
function ancestorsOf(nodes, ids) {
|
|
37
|
+
const want = new Set(ids);
|
|
38
|
+
const out = new Set();
|
|
39
|
+
const walk = (list, path) => {
|
|
40
|
+
for (const n of list) {
|
|
41
|
+
if (want.has(n.id))
|
|
42
|
+
path.forEach((p) => out.add(p));
|
|
43
|
+
if (n.children)
|
|
44
|
+
walk(n.children, [...path, n.id]);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
walk(nodes, []);
|
|
48
|
+
return [...out];
|
|
49
|
+
}
|
|
50
|
+
function PathSeparator() {
|
|
51
|
+
return (_jsx("span", { "aria-hidden": true, className: "inline-block px-1 text-fg-subtle rtl:-scale-x-100", children: "\u203A" }));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Pick from hierarchical data — product categories, departments, locations and warehouses,
|
|
55
|
+
* folder destinations, chart of accounts. A searchable tree in a popover (or inline), single or
|
|
56
|
+
* multi with tri-state cascade, lazy branches, search that keeps ancestors, and "Add category".
|
|
57
|
+
*
|
|
58
|
+
* ```tsx
|
|
59
|
+
* <Field label="Category"><TreeSelect nodes={categories} selectable="leaf" value={categoryId} onValueChange={setCategoryId} /></Field>
|
|
60
|
+
* <TreeSelect multiple nodes={regions} valueMode="parent" value={territories} onValueChange={setTerritories} />
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
export const TreeSelect = React.forwardRef(function TreeSelect(props, ref) {
|
|
64
|
+
const { nodes, loadChildren, selectable = "any", showPath = true, defaultExpanded = "selected", onCreate, searchable = true, mode = "popover", height = 288, size = "md", placeholder, searchPlaceholder, labels, className, } = props;
|
|
65
|
+
const multiple = props.multiple === true;
|
|
66
|
+
const t = useLabels("treeSelect", treeSelectLabels, labels);
|
|
67
|
+
const { locale, dir } = useLocale();
|
|
68
|
+
const container = usePortalContainer();
|
|
69
|
+
const control = useFieldControl({
|
|
70
|
+
id: props.id,
|
|
71
|
+
name: props.name,
|
|
72
|
+
disabled: props.disabled,
|
|
73
|
+
readOnly: props.readOnly,
|
|
74
|
+
required: props.required,
|
|
75
|
+
"aria-describedby": props["aria-describedby"],
|
|
76
|
+
"aria-labelledby": props["aria-labelledby"],
|
|
77
|
+
"aria-invalid": props["aria-invalid"] ?? (props.invalid ? true : undefined),
|
|
78
|
+
});
|
|
79
|
+
const disabled = Boolean(control.disabled);
|
|
80
|
+
const readOnly = Boolean(control.readOnly);
|
|
81
|
+
const toArray = (v) => (v === undefined ? undefined : Array.isArray(v) ? v : v === null ? [] : [v]);
|
|
82
|
+
const [ids, setIdsRaw] = useControllableState({
|
|
83
|
+
value: toArray(props.value),
|
|
84
|
+
defaultValue: () => toArray(props.defaultValue) ?? EMPTY,
|
|
85
|
+
name: "TreeSelect",
|
|
86
|
+
});
|
|
87
|
+
const onChangeRef = useLatest(props.onValueChange);
|
|
88
|
+
const [open, setOpen] = useControllableState({ value: props.open, defaultValue: props.defaultOpen ?? false, onChange: props.onOpenChange, name: "TreeSelect" });
|
|
89
|
+
const [query, setQuery] = React.useState("");
|
|
90
|
+
const [initialExpanded] = React.useState(() => (defaultExpanded === "selected" ? ancestorsOf(nodes, ids) : defaultExpanded));
|
|
91
|
+
const triggerRef = React.useRef(null);
|
|
92
|
+
const searchRef = React.useRef(null);
|
|
93
|
+
const tree = useTree({
|
|
94
|
+
nodes,
|
|
95
|
+
loadChildren,
|
|
96
|
+
defaultExpanded: initialExpanded,
|
|
97
|
+
filter: query,
|
|
98
|
+
locale,
|
|
99
|
+
dir,
|
|
100
|
+
selectionMode: multiple ? "none" : "single",
|
|
101
|
+
selected: multiple ? undefined : ids,
|
|
102
|
+
onSelectedChange: multiple
|
|
103
|
+
? undefined
|
|
104
|
+
: (next) => {
|
|
105
|
+
const id = next[next.length - 1] ?? null;
|
|
106
|
+
setIdsRaw(id ? [id] : []);
|
|
107
|
+
onChangeRef.current?.(id, id ? (tree.getNode(id) ?? null) : null);
|
|
108
|
+
if (mode === "popover") {
|
|
109
|
+
setOpen(false);
|
|
110
|
+
setQuery("");
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
isSelectable: selectable === "leaf" ? (_n, hasChildren) => !hasChildren : undefined,
|
|
114
|
+
checkable: multiple,
|
|
115
|
+
checked: multiple ? ids : undefined,
|
|
116
|
+
onCheckedChange: multiple
|
|
117
|
+
? (next) => {
|
|
118
|
+
setIdsRaw(next);
|
|
119
|
+
onChangeRef.current?.(next);
|
|
120
|
+
}
|
|
121
|
+
: undefined,
|
|
122
|
+
cascade: multiple ? (props.cascade ?? true) : undefined,
|
|
123
|
+
checkValueMode: multiple ? (props.valueMode ?? "all") : undefined,
|
|
124
|
+
});
|
|
125
|
+
const setIds = (next) => {
|
|
126
|
+
setIdsRaw(next);
|
|
127
|
+
if (multiple)
|
|
128
|
+
onChangeRef.current?.(next);
|
|
129
|
+
else
|
|
130
|
+
onChangeRef.current?.(next[0] ?? null, next[0] ? (tree.getNode(next[0]) ?? null) : null);
|
|
131
|
+
};
|
|
132
|
+
/* ---------- create ---------- */
|
|
133
|
+
const [creating, setCreating] = React.useState(null);
|
|
134
|
+
const [newName, setNewName] = React.useState("");
|
|
135
|
+
const [saving, setSaving] = React.useState(false);
|
|
136
|
+
const submitCreate = async () => {
|
|
137
|
+
if (!onCreate || !creating || !newName.trim())
|
|
138
|
+
return;
|
|
139
|
+
setSaving(true);
|
|
140
|
+
try {
|
|
141
|
+
const node = await onCreate(creating.parentId, newName.trim());
|
|
142
|
+
if (creating.parentId)
|
|
143
|
+
tree.toggleExpanded(creating.parentId, true);
|
|
144
|
+
setCreating(null);
|
|
145
|
+
setNewName("");
|
|
146
|
+
if (multiple)
|
|
147
|
+
setIds([...ids, node.id]);
|
|
148
|
+
else
|
|
149
|
+
setIds([node.id]);
|
|
150
|
+
requestAnimationFrame(() => tree.focusItem(node.id));
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
setSaving(false);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
/* ---------- tree panel ---------- */
|
|
157
|
+
const onRowClick = (item) => {
|
|
158
|
+
if (multiple)
|
|
159
|
+
tree.toggleChecked(item.id);
|
|
160
|
+
else if (selectable === "leaf" && item.hasChildren)
|
|
161
|
+
tree.toggleExpanded(item.id);
|
|
162
|
+
else
|
|
163
|
+
tree.select(item.id);
|
|
164
|
+
};
|
|
165
|
+
const treeProps = tree.getTreeProps();
|
|
166
|
+
const treeLabel = props["aria-label"] ?? searchPlaceholder ?? t("search");
|
|
167
|
+
const focusedParent = tree.focusedId ? tree.getNode(tree.focusedId) : undefined;
|
|
168
|
+
const panel = (_jsxs("div", { "data-slot": "tree-select-panel", className: "flex min-h-0 flex-col", children: [searchable ? (_jsxs("div", { className: "flex items-center gap-2 border-b border-line px-3", children: [_jsx(Search, { "aria-hidden": true, className: "size-4 shrink-0 text-fg-subtle" }), _jsx("input", { ref: searchRef, type: "search", "aria-label": searchPlaceholder ?? t("search"), placeholder: searchPlaceholder ?? t("search"), autoComplete: "off", spellCheck: false, value: query, disabled: disabled || readOnly, onChange: (e) => setQuery(e.target.value), onKeyDown: (e) => {
|
|
169
|
+
if (e.key === "ArrowDown" && tree.items[0]) {
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
tree.focusItem(tree.items[0].id);
|
|
172
|
+
}
|
|
173
|
+
else if (e.key === "Enter" && tree.filtering) {
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
const first = tree.items.find((i) => i.match && !i.disabled);
|
|
176
|
+
if (first)
|
|
177
|
+
onRowClick(first);
|
|
178
|
+
}
|
|
179
|
+
}, className: "h-10 min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle [&::-webkit-search-cancel-button]:hidden" })] })) : null, tree.filtering ? (_jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: t("results", { count: tree.matchCount }) })) : null, nodes.length === 0 ? (_jsx("p", { className: "px-3 py-6 text-center text-sm text-fg-muted", children: t("empty") })) : tree.items.length === 0 ? (_jsx("p", { className: "px-3 py-6 text-center text-sm text-fg-muted", children: t("noMatches", { query }) })) : (_jsx("div", { ...treeProps, "aria-label": treeLabel, "aria-labelledby": mode === "inline" ? control["aria-labelledby"] : undefined, "aria-describedby": mode === "inline" ? control["aria-describedby"] : undefined, "aria-invalid": mode === "inline" ? control["aria-invalid"] : undefined, "aria-readonly": readOnly || undefined, className: cn("grid gap-px overflow-y-auto overscroll-contain p-1 outline-none", readOnly && "pointer-events-none"), style: { maxHeight: height }, onKeyDown: (e) => {
|
|
180
|
+
if (readOnly && (e.key === " " || e.key === "Enter"))
|
|
181
|
+
return;
|
|
182
|
+
treeProps.onKeyDown(e);
|
|
183
|
+
}, children: tree.items.map((item) => (_jsx(TreeViewRow, { item: item, tree: tree, size: size === "lg" ? "md" : "sm", checkbox: multiple, query: query, indent: 14, onRowClick: onRowClick }, item.id))) })), onCreate && !readOnly ? (_jsx("div", { className: "border-t border-line p-1.5", children: creating ? (_jsxs("form", { className: "grid gap-1.5 p-1", onSubmit: (e) => {
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
void submitCreate();
|
|
186
|
+
}, children: [_jsx("label", { className: "text-xs text-fg-muted", htmlFor: `${control.id ?? "tree-select"}-new`, children: creating.parentId ? t("addUnder", { parent: tree.getNode(creating.parentId)?.label ?? "" }) : t("addRoot") }), _jsxs("div", { className: "flex gap-1.5", children: [_jsx("input", { id: `${control.id ?? "tree-select"}-new`, autoFocus: true, value: newName, placeholder: t("newName"), onChange: (e) => setNewName(e.target.value), onKeyDown: (e) => {
|
|
187
|
+
if (e.key === "Escape") {
|
|
188
|
+
e.preventDefault();
|
|
189
|
+
e.stopPropagation();
|
|
190
|
+
setCreating(null);
|
|
191
|
+
}
|
|
192
|
+
}, className: cn(controlVariants({ size: "sm" }), "flex-1") }), _jsx(Button, { type: "submit", size: "sm", variant: "primary", loading: saving, disabled: !newName.trim(), children: t("create") })] })] })) : (_jsxs(Button, { size: "xs", variant: "ghost", onMouseDown: (e) => e.preventDefault(), onClick: () => setCreating({ parentId: focusedParent && !focusedParent.disabled ? focusedParent.id : null }), children: [_jsx(Plus, { "aria-hidden": true }), focusedParent ? t("addUnder", { parent: focusedParent.label }) : t("addRoot")] })) })) : null] }));
|
|
193
|
+
const hidden = control.name
|
|
194
|
+
? ids.map((id) => _jsx("input", { type: "hidden", name: control.name, value: id }, id)).concat(ids.length === 0 && !multiple ? [_jsx("input", { type: "hidden", name: control.name, value: "" }, "__empty")] : [])
|
|
195
|
+
: null;
|
|
196
|
+
if (mode === "inline") {
|
|
197
|
+
return (_jsxs("div", { ref: ref, "data-slot": "tree-select", "data-mode": "inline", "aria-invalid": control["aria-invalid"], className: cn("surface-2 overflow-hidden rounded-ui border border-line aria-invalid:border-danger", disabled && "pointer-events-none opacity-50", className), children: [panel, multiple && ids.length ? (_jsx("div", { className: "border-t border-line px-3 py-1.5 text-xs text-fg-subtle", children: t("selectedCount", { count: ids.length }) })) : null, hidden] }));
|
|
198
|
+
}
|
|
199
|
+
const labelFor = (id) => {
|
|
200
|
+
const path = tree.getPath(id);
|
|
201
|
+
if (!path.length)
|
|
202
|
+
return { text: id, parts: [id] };
|
|
203
|
+
const parts = showPath ? path.map((n) => n.label) : [path[path.length - 1].label];
|
|
204
|
+
return { text: parts.join(" › "), parts };
|
|
205
|
+
};
|
|
206
|
+
const triggerA11y = {
|
|
207
|
+
id: control.id,
|
|
208
|
+
"aria-label": props["aria-label"],
|
|
209
|
+
"aria-labelledby": control["aria-labelledby"],
|
|
210
|
+
"aria-describedby": control["aria-describedby"],
|
|
211
|
+
"aria-invalid": control["aria-invalid"],
|
|
212
|
+
// No aria-required: not allowed on a button (axe aria-allowed-attr). The Field marks the label.
|
|
213
|
+
"aria-haspopup": "tree",
|
|
214
|
+
disabled: disabled || readOnly,
|
|
215
|
+
};
|
|
216
|
+
const content = (_jsx(PopoverPrimitive.Portal, { container: container, children: _jsx(Layer, { asChild: true, children: _jsx(PopoverPrimitive.Content, { "data-slot": "tree-select-content", "aria-label": treeLabel, align: "start", sideOffset: 6, collisionPadding: 12, className: "surface-popover ui-pop z-(--z-popover) w-(--radix-popover-trigger-width) min-w-72 max-w-[calc(100vw-1.5rem)] overflow-hidden rounded-ui-lg outline-none", onOpenAutoFocus: (e) => {
|
|
217
|
+
e.preventDefault();
|
|
218
|
+
if (searchRef.current)
|
|
219
|
+
searchRef.current.focus();
|
|
220
|
+
else {
|
|
221
|
+
const first = tree.items.find((i) => i.selected || i.checked === true) ?? tree.items[0];
|
|
222
|
+
if (first)
|
|
223
|
+
tree.focusItem(first.id);
|
|
224
|
+
}
|
|
225
|
+
}, onCloseAutoFocus: () => {
|
|
226
|
+
setQuery("");
|
|
227
|
+
setCreating(null);
|
|
228
|
+
}, children: _jsx(FieldContextReset, { children: panel }) }) }) }));
|
|
229
|
+
if (multiple) {
|
|
230
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Anchor, { asChild: true, children: _jsxs("div", { ref: ref, "data-slot": "tree-select", "data-state": open ? "open" : "closed", "data-readonly": readOnly || undefined, "aria-invalid": control["aria-invalid"], "aria-disabled": disabled || undefined, className: cn(controlVariants({ size, multiline: true }), "min-h-(--control-h) flex-wrap items-center gap-1.5 py-1.5 ps-1.5", className), children: [ids.map((id) => {
|
|
231
|
+
const l = labelFor(id);
|
|
232
|
+
const leaf = l.parts[l.parts.length - 1];
|
|
233
|
+
return (_jsxs("span", { title: l.text, className: "inline-flex h-6 max-w-full min-w-0 items-center gap-1 rounded-full bg-selected ps-2 pe-1.5 text-xs font-medium text-fg", children: [_jsx("span", { className: "truncate", children: leaf }), !readOnly && !disabled ? _jsx(ChipRemoveButton, { itemLabel: leaf, onRemove: () => tree.toggleChecked(id, false) }) : null] }, id));
|
|
234
|
+
}), !readOnly ? (_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs("button", { ref: triggerRef, type: "button", ...triggerA11y, className: "inline-flex h-6 min-w-0 flex-1 items-center gap-1 rounded-ui-sm px-1.5 text-start text-fg-subtle outline-none hover:text-fg focus-visible:text-fg disabled:cursor-not-allowed [&_svg]:size-3.5", children: [_jsx(Plus, { "aria-hidden": true }), _jsx("span", { className: "truncate", children: placeholder ?? t("placeholderMultiple") })] }) })) : null, hidden] }) }), content] }));
|
|
235
|
+
}
|
|
236
|
+
const current = ids[0] ? labelFor(ids[0]) : null;
|
|
237
|
+
const showClear = current && !control.required && !disabled && !readOnly;
|
|
238
|
+
const loadingAny = tree.items.some((i) => i.loading);
|
|
239
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Anchor, { asChild: true, children: _jsxs("div", { ref: ref, "data-slot": "tree-select", "data-state": open ? "open" : "closed", "data-readonly": readOnly || undefined, "aria-invalid": control["aria-invalid"], "aria-disabled": disabled || undefined, className: cn(controlVariants({ size }), "p-0", className), children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs("button", { ref: triggerRef, type: "button", ...triggerA11y, className: cn("flex h-full min-w-0 flex-1 items-center gap-2 rounded-[inherit] ps-3 text-start outline-none disabled:cursor-not-allowed", showClear ? "pe-1" : "pe-3"), children: [current ? (_jsx("span", { className: "flex min-w-0 flex-1 items-center truncate", children: current.parts.map((p, i) => (_jsxs(React.Fragment, { children: [i > 0 ? _jsx(PathSeparator, {}) : null, _jsx("span", { className: cn("truncate", i < current.parts.length - 1 ? "shrink text-fg-muted" : "shrink-0 text-fg"), children: p })] }, i))) })) : (_jsx("span", { className: "min-w-0 flex-1 truncate text-fg-subtle", children: placeholder ?? t("placeholder") })), loadingAny && !open ? _jsx(Spinner, { size: "xs", tone: "muted" }) : null, !showClear && !readOnly ? _jsx(ChevronsUpDown, { "aria-hidden": true, className: "ms-auto size-4 shrink-0 text-fg-subtle" }) : null] }) }), showClear ? (_jsx("button", { type: "button", "aria-label": t("clear"), onClick: () => {
|
|
240
|
+
setIds([]);
|
|
241
|
+
triggerRef.current?.focus();
|
|
242
|
+
}, className: "me-1.5 inline-flex size-6 shrink-0 items-center justify-center rounded-ui-sm text-fg-subtle hover:bg-hover hover:text-fg focus-ring [&_svg]:size-3.5", children: _jsx(X, { "aria-hidden": true }) })) : null, hidden] }) }), content] }));
|
|
243
|
+
});
|