@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,650 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, 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 { Check, ChevronsUpDown, ExternalLink, LayoutList, Plus, RotateCw, Search, TriangleAlert, X } from "lucide-react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { mergeIds } from "../lib/compose-refs.js";
|
|
8
|
+
import { FieldContextReset, useFieldControl } from "../lib/field-context.js";
|
|
9
|
+
import { useLabels } from "../lib/labels.js";
|
|
10
|
+
import { useLocale } from "../lib/locale.js";
|
|
11
|
+
import { SmartLink } from "../lib/provider.js";
|
|
12
|
+
import { highlightParts, matchText } from "../lib/text.js";
|
|
13
|
+
import { usePortalContainer } from "../lib/theme-scope.js";
|
|
14
|
+
import { Layer } from "../lib/layer.js";
|
|
15
|
+
import { ChipRemoveButton } from "../lib/islands.js";
|
|
16
|
+
import { useControllableState, useLatest } from "../lib/use-controllable-state.js";
|
|
17
|
+
import { controlVariants, itemSlots, itemVariants } from "../lib/variants.js";
|
|
18
|
+
import { Avatar } from "./avatar.js";
|
|
19
|
+
import { Button, IconButton } from "./button.js";
|
|
20
|
+
import { Checkbox } from "./checkbox.js";
|
|
21
|
+
import { Dialog, DialogBody, DialogContent, DialogFooter, DialogHeader } from "./dialog.js";
|
|
22
|
+
import { Skeleton } from "./skeleton.js";
|
|
23
|
+
import { Spinner } from "./spinner.js";
|
|
24
|
+
/**
|
|
25
|
+
* A `RecordSource` over an in-memory array, searched with locale folding (İ/ı, accents).
|
|
26
|
+
* Good for small sets, tests and prototypes; switch to a server `search` later without
|
|
27
|
+
* touching the picker.
|
|
28
|
+
*/
|
|
29
|
+
export function arrayRecordSource(key, items, options) {
|
|
30
|
+
const { getKeywords, pageSize = 50, delay = 0, ...rest } = options;
|
|
31
|
+
const wait = (signal) => new Promise((resolve, reject) => {
|
|
32
|
+
if (!delay)
|
|
33
|
+
return resolve();
|
|
34
|
+
const timer = setTimeout(resolve, delay);
|
|
35
|
+
signal.addEventListener("abort", () => {
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
reject(new DOMException("Aborted", "AbortError"));
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
key,
|
|
42
|
+
...rest,
|
|
43
|
+
async search(query, { signal, cursor, locale }) {
|
|
44
|
+
await wait(signal);
|
|
45
|
+
const q = query.trim();
|
|
46
|
+
const all = q
|
|
47
|
+
? items.filter((r) => matchText([rest.getLabel(r), rest.getDescription?.(r) ?? "", ...(getKeywords?.(r) ?? [])].join(" "), q, locale))
|
|
48
|
+
: items;
|
|
49
|
+
const start = cursor ? Number(cursor) : 0;
|
|
50
|
+
const end = start + pageSize;
|
|
51
|
+
return { items: all.slice(start, end), nextCursor: end < all.length ? String(end) : undefined };
|
|
52
|
+
},
|
|
53
|
+
async getByIds(ids, signal) {
|
|
54
|
+
await wait(signal);
|
|
55
|
+
const set = new Set(ids);
|
|
56
|
+
return items.filter((r) => set.has(rest.getId(r)));
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/* ------------------------------------------------------------------ */
|
|
61
|
+
/* Session caches (per source key) */
|
|
62
|
+
/* ------------------------------------------------------------------ */
|
|
63
|
+
const recordCache = new Map();
|
|
64
|
+
const recentCache = new Map();
|
|
65
|
+
const pageCache = new Map();
|
|
66
|
+
const PAGE_TTL = 30_000;
|
|
67
|
+
function remember(source, records) {
|
|
68
|
+
let m = recordCache.get(source.key);
|
|
69
|
+
if (!m)
|
|
70
|
+
recordCache.set(source.key, (m = new Map()));
|
|
71
|
+
for (const r of records)
|
|
72
|
+
m.set(source.getId(r), r);
|
|
73
|
+
}
|
|
74
|
+
function cached(source, id) {
|
|
75
|
+
return recordCache.get(source.key)?.get(id);
|
|
76
|
+
}
|
|
77
|
+
function pushRecent(source, ids) {
|
|
78
|
+
const prev = recentCache.get(source.key) ?? [];
|
|
79
|
+
recentCache.set(source.key, [...ids, ...prev.filter((x) => !ids.includes(x))].slice(0, 5));
|
|
80
|
+
}
|
|
81
|
+
/** Clears the picker's session caches (after a logout, or in tests). Pass a key to clear one collection. */
|
|
82
|
+
export function clearRecordPickerCache(key) {
|
|
83
|
+
if (key === undefined) {
|
|
84
|
+
recordCache.clear();
|
|
85
|
+
recentCache.clear();
|
|
86
|
+
pageCache.clear();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
recordCache.delete(key);
|
|
90
|
+
recentCache.delete(key);
|
|
91
|
+
for (const k of pageCache.keys())
|
|
92
|
+
if (k.startsWith(`${key}\u0000`))
|
|
93
|
+
pageCache.delete(k);
|
|
94
|
+
}
|
|
95
|
+
const isAbort = (e) => e instanceof DOMException && e.name === "AbortError";
|
|
96
|
+
/** Debounced, abortable, paged search against a source. */
|
|
97
|
+
function useRecordSearch(source, query, enabled, locale) {
|
|
98
|
+
const sourceRef = useLatest(source);
|
|
99
|
+
const [state, setState] = React.useState({
|
|
100
|
+
items: [],
|
|
101
|
+
loading: false,
|
|
102
|
+
loadingMore: false,
|
|
103
|
+
error: null,
|
|
104
|
+
query: "",
|
|
105
|
+
});
|
|
106
|
+
const [attempt, setAttempt] = React.useState(0);
|
|
107
|
+
const ctrlRef = React.useRef(null);
|
|
108
|
+
React.useEffect(() => {
|
|
109
|
+
if (!enabled)
|
|
110
|
+
return;
|
|
111
|
+
const src = sourceRef.current;
|
|
112
|
+
const cacheKey = `${src.key}\u0000${query.trim()}`;
|
|
113
|
+
const hit = pageCache.get(cacheKey);
|
|
114
|
+
if (hit && Date.now() - hit.at < PAGE_TTL && attempt === 0) {
|
|
115
|
+
setState({ items: hit.items, nextCursor: hit.nextCursor, loading: false, loadingMore: false, error: null, query });
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
setState((s) => ({ ...s, loading: true, error: null }));
|
|
119
|
+
const ctrl = new AbortController();
|
|
120
|
+
ctrlRef.current?.abort();
|
|
121
|
+
ctrlRef.current = ctrl;
|
|
122
|
+
const timer = setTimeout(() => {
|
|
123
|
+
src
|
|
124
|
+
.search(query.trim(), { signal: ctrl.signal, locale })
|
|
125
|
+
.then((res) => {
|
|
126
|
+
if (ctrl.signal.aborted)
|
|
127
|
+
return;
|
|
128
|
+
remember(src, res.items);
|
|
129
|
+
pageCache.set(cacheKey, { items: res.items, nextCursor: res.nextCursor, at: Date.now() });
|
|
130
|
+
setState({ items: res.items, nextCursor: res.nextCursor, loading: false, loadingMore: false, error: null, query });
|
|
131
|
+
})
|
|
132
|
+
.catch((e) => {
|
|
133
|
+
if (ctrl.signal.aborted || isAbort(e))
|
|
134
|
+
return;
|
|
135
|
+
setState((s) => ({ ...s, loading: false, error: e instanceof Error ? e.message : String(e) }));
|
|
136
|
+
});
|
|
137
|
+
}, query.trim() ? 200 : 0);
|
|
138
|
+
return () => {
|
|
139
|
+
clearTimeout(timer);
|
|
140
|
+
ctrl.abort();
|
|
141
|
+
};
|
|
142
|
+
}, [enabled, query, attempt, locale, sourceRef, source.key]);
|
|
143
|
+
const loadMore = React.useCallback(() => {
|
|
144
|
+
const src = sourceRef.current;
|
|
145
|
+
if (!state.nextCursor || state.loadingMore)
|
|
146
|
+
return;
|
|
147
|
+
const ctrl = new AbortController();
|
|
148
|
+
ctrlRef.current = ctrl;
|
|
149
|
+
setState((s) => ({ ...s, loadingMore: true }));
|
|
150
|
+
src
|
|
151
|
+
.search(query.trim(), { signal: ctrl.signal, cursor: state.nextCursor, locale })
|
|
152
|
+
.then((res) => {
|
|
153
|
+
if (ctrl.signal.aborted)
|
|
154
|
+
return;
|
|
155
|
+
remember(src, res.items);
|
|
156
|
+
setState((s) => ({ ...s, items: [...s.items, ...res.items], nextCursor: res.nextCursor, loadingMore: false }));
|
|
157
|
+
})
|
|
158
|
+
.catch((e) => {
|
|
159
|
+
if (ctrl.signal.aborted || isAbort(e))
|
|
160
|
+
return;
|
|
161
|
+
setState((s) => ({ ...s, loadingMore: false, error: e instanceof Error ? e.message : String(e) }));
|
|
162
|
+
});
|
|
163
|
+
}, [locale, query, sourceRef, state.loadingMore, state.nextCursor]);
|
|
164
|
+
const retry = React.useCallback(() => {
|
|
165
|
+
pageCache.delete(`${sourceRef.current.key}\u0000${query.trim()}`);
|
|
166
|
+
setAttempt((n) => n + 1);
|
|
167
|
+
}, [query, sourceRef]);
|
|
168
|
+
return { ...state, loadMore, retry };
|
|
169
|
+
}
|
|
170
|
+
/** Resolves ids → records through the cache, `known` records and `getByIds`. */
|
|
171
|
+
function useResolvedRecords(source, ids, known) {
|
|
172
|
+
const sourceRef = useLatest(source);
|
|
173
|
+
const [, bump] = React.useReducer((n) => n + 1, 0);
|
|
174
|
+
const [pending, setPending] = React.useState(() => new Set());
|
|
175
|
+
const [missing, setMissing] = React.useState(() => new Set());
|
|
176
|
+
if (known?.length)
|
|
177
|
+
remember(source, known);
|
|
178
|
+
const idsKey = ids.join("\u0000");
|
|
179
|
+
React.useEffect(() => {
|
|
180
|
+
const src = sourceRef.current;
|
|
181
|
+
const unresolved = ids.filter((id) => !cached(src, id) && !missing.has(id));
|
|
182
|
+
if (unresolved.length === 0)
|
|
183
|
+
return;
|
|
184
|
+
if (!src.getByIds) {
|
|
185
|
+
setMissing((m) => new Set([...m, ...unresolved]));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const ctrl = new AbortController();
|
|
189
|
+
setPending(new Set(unresolved));
|
|
190
|
+
src
|
|
191
|
+
.getByIds(unresolved, ctrl.signal)
|
|
192
|
+
.then((rs) => {
|
|
193
|
+
if (ctrl.signal.aborted)
|
|
194
|
+
return;
|
|
195
|
+
remember(src, rs);
|
|
196
|
+
const found = new Set(rs.map((r) => src.getId(r)));
|
|
197
|
+
const gone = unresolved.filter((id) => !found.has(id));
|
|
198
|
+
if (gone.length)
|
|
199
|
+
setMissing((m) => new Set([...m, ...gone]));
|
|
200
|
+
setPending(new Set());
|
|
201
|
+
bump();
|
|
202
|
+
})
|
|
203
|
+
.catch((e) => {
|
|
204
|
+
if (ctrl.signal.aborted || isAbort(e))
|
|
205
|
+
return;
|
|
206
|
+
setPending(new Set());
|
|
207
|
+
setMissing((m) => new Set([...m, ...unresolved]));
|
|
208
|
+
});
|
|
209
|
+
return () => ctrl.abort();
|
|
210
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
211
|
+
}, [idsKey, source.key]);
|
|
212
|
+
return ids.map((id) => ({ id, record: cached(source, id), pending: pending.has(id), missing: missing.has(id) && !cached(source, id) }));
|
|
213
|
+
}
|
|
214
|
+
/* ------------------------------------------------------------------ */
|
|
215
|
+
/* Props */
|
|
216
|
+
/* ------------------------------------------------------------------ */
|
|
217
|
+
const recordPickerLabels = {
|
|
218
|
+
placeholder: "Select…",
|
|
219
|
+
placeholderMultiple: "Add…",
|
|
220
|
+
search: "Search…",
|
|
221
|
+
searching: "Searching…",
|
|
222
|
+
empty: "No results",
|
|
223
|
+
noResultsFor: "No results for “{query}”",
|
|
224
|
+
create: "Create “{query}”",
|
|
225
|
+
creating: "Creating…",
|
|
226
|
+
browse: "Browse all",
|
|
227
|
+
recent: "Recent",
|
|
228
|
+
results: "{count, plural, =0 {No results} one {# result} other {# results}}",
|
|
229
|
+
loadMore: "Load more",
|
|
230
|
+
unknown: "Unknown record",
|
|
231
|
+
max: "{max, plural, one {You can pick # record} other {You can pick up to # records}}",
|
|
232
|
+
error: "Couldn't load results",
|
|
233
|
+
retry: "Try again",
|
|
234
|
+
clear: "Clear selection",
|
|
235
|
+
add: "Add",
|
|
236
|
+
change: "Change",
|
|
237
|
+
open: "Open {label}",
|
|
238
|
+
remove: "Remove {label}",
|
|
239
|
+
browseTitle: "Browse",
|
|
240
|
+
selectCount: "{count, plural, =0 {Select} one {Select # record} other {Select # records}}",
|
|
241
|
+
cancel: "Cancel",
|
|
242
|
+
resolving: "Loading selection…",
|
|
243
|
+
selectedCount: "{count, plural, one {# selected} other {# selected}}",
|
|
244
|
+
};
|
|
245
|
+
const EMPTY_IDS = [];
|
|
246
|
+
/* ------------------------------------------------------------------ */
|
|
247
|
+
/* Pieces */
|
|
248
|
+
/* ------------------------------------------------------------------ */
|
|
249
|
+
function Highlight({ text, query, locale }) {
|
|
250
|
+
if (!query.trim())
|
|
251
|
+
return _jsx(_Fragment, { children: text });
|
|
252
|
+
return (_jsx(_Fragment, { children: highlightParts(text, query, locale).map((p, i) => p.match ? (_jsx("mark", { className: "bg-transparent font-semibold text-fg", children: p.text }, i)) : (_jsx(React.Fragment, { children: p.text }, i))) }));
|
|
253
|
+
}
|
|
254
|
+
function RecordAvatar({ source, record, size }) {
|
|
255
|
+
const a = source.getAvatar?.(record);
|
|
256
|
+
if (!a)
|
|
257
|
+
return null;
|
|
258
|
+
return _jsx(Avatar, { name: a.name, src: a.src, shape: a.shape, size: size, "aria-hidden": true });
|
|
259
|
+
}
|
|
260
|
+
/** Option look: highlight follows the active descendant, not `aria-selected` (that marks the picked records). */
|
|
261
|
+
function optionClass(active, extra, size = "md") {
|
|
262
|
+
return cn(itemVariants({ size }), "aria-selected:bg-transparent", active && "bg-hover aria-selected:bg-hover", extra);
|
|
263
|
+
}
|
|
264
|
+
/** Default option row. */
|
|
265
|
+
function DefaultRecordRow({ source, record, query, locale }) {
|
|
266
|
+
const desc = source.getDescription?.(record);
|
|
267
|
+
return (_jsxs(_Fragment, { children: [_jsx(RecordAvatar, { source: source, record: record, size: "sm" }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate", children: _jsx(Highlight, { text: source.getLabel(record), query: query, locale: locale }) }), desc ? (_jsx("span", { className: cn(itemSlots.description, "truncate"), children: _jsx(Highlight, { text: desc, query: query, locale: locale }) })) : null] })] }));
|
|
268
|
+
}
|
|
269
|
+
/** The search box + listbox, shared by the popover and inline modes. */
|
|
270
|
+
function RecordPickerPanel(props) {
|
|
271
|
+
const { source, multiple, selectedIds, max, t, close } = props;
|
|
272
|
+
const { locale } = useLocale();
|
|
273
|
+
const [query, setQuery] = React.useState("");
|
|
274
|
+
const [creating, setCreating] = React.useState(false);
|
|
275
|
+
const search = useRecordSearch(source, query, true, locale);
|
|
276
|
+
const listId = React.useId();
|
|
277
|
+
const optionId = (key) => `${listId}-${key.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
|
|
278
|
+
const selectedSet = React.useMemo(() => new Set(selectedIds), [selectedIds]);
|
|
279
|
+
const atMax = multiple && max !== undefined && selectedIds.length >= max;
|
|
280
|
+
const recentRecords = React.useMemo(() => {
|
|
281
|
+
if (props.recent === false || query.trim())
|
|
282
|
+
return [];
|
|
283
|
+
if (props.recent)
|
|
284
|
+
return props.recent;
|
|
285
|
+
return (recentCache.get(source.key) ?? []).map((id) => cached(source, id)).filter((r) => r !== undefined);
|
|
286
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
287
|
+
}, [props.recent, query, source.key, search.items]);
|
|
288
|
+
const entries = React.useMemo(() => {
|
|
289
|
+
const out = [];
|
|
290
|
+
const searching = query.trim().length > 0;
|
|
291
|
+
for (const a of props.actions ?? []) {
|
|
292
|
+
if (searching && a.hideWhileSearching !== false)
|
|
293
|
+
continue;
|
|
294
|
+
out.push({ kind: "action", key: `action:${a.id}`, action: a });
|
|
295
|
+
}
|
|
296
|
+
const recentIds = new Set();
|
|
297
|
+
for (const r of recentRecords) {
|
|
298
|
+
const id = source.getId(r);
|
|
299
|
+
recentIds.add(id);
|
|
300
|
+
const disabled = Boolean(props.getDisabled?.(r)) || (atMax && !selectedSet.has(id));
|
|
301
|
+
out.push({ kind: "record", key: `recent:${id}`, record: r, group: t("recent"), disabled });
|
|
302
|
+
}
|
|
303
|
+
for (const r of search.items) {
|
|
304
|
+
const id = source.getId(r);
|
|
305
|
+
if (recentIds.has(id))
|
|
306
|
+
continue;
|
|
307
|
+
const disabled = Boolean(props.getDisabled?.(r)) || (atMax && !selectedSet.has(id));
|
|
308
|
+
out.push({ kind: "record", key: `r:${id}`, record: r, group: props.getGroup?.(r) ?? (recentIds.size ? "\u0000all" : undefined), disabled });
|
|
309
|
+
}
|
|
310
|
+
if (props.onCreate && searching && !search.loading && !atMax) {
|
|
311
|
+
const exact = search.items.some((r) => source.getLabel(r).trim().toLocaleLowerCase(locale) === query.trim().toLocaleLowerCase(locale));
|
|
312
|
+
if (!exact)
|
|
313
|
+
out.push({ kind: "create", key: "create" });
|
|
314
|
+
}
|
|
315
|
+
if (search.nextCursor && !search.loading)
|
|
316
|
+
out.push({ kind: "more", key: "more" });
|
|
317
|
+
return out;
|
|
318
|
+
}, [atMax, locale, props, query, recentRecords, search.items, search.loading, search.nextCursor, selectedSet, source, t]);
|
|
319
|
+
const enabled = entries.filter((e) => !(e.kind === "record" && e.disabled));
|
|
320
|
+
const [activeKey, setActiveKey] = React.useState(null);
|
|
321
|
+
const active = enabled.find((e) => e.key === activeKey) ?? enabled[0] ?? null;
|
|
322
|
+
const listRef = React.useRef(null);
|
|
323
|
+
React.useEffect(() => {
|
|
324
|
+
if (!active)
|
|
325
|
+
return;
|
|
326
|
+
const els = listRef.current?.querySelectorAll("[data-key]") ?? [];
|
|
327
|
+
for (const el of els)
|
|
328
|
+
if (el.dataset.key === active.key)
|
|
329
|
+
el.scrollIntoView?.({ block: "nearest" });
|
|
330
|
+
}, [active]);
|
|
331
|
+
const activate = async (e) => {
|
|
332
|
+
if (!e)
|
|
333
|
+
return;
|
|
334
|
+
if (e.kind === "action") {
|
|
335
|
+
e.action.onSelect({ select: (r) => void props.onPick(r), close, query });
|
|
336
|
+
}
|
|
337
|
+
else if (e.kind === "record") {
|
|
338
|
+
if (e.disabled)
|
|
339
|
+
return;
|
|
340
|
+
await props.onPick(e.record);
|
|
341
|
+
}
|
|
342
|
+
else if (e.kind === "create" && props.onCreate) {
|
|
343
|
+
setCreating(true);
|
|
344
|
+
try {
|
|
345
|
+
const r = await props.onCreate(query.trim());
|
|
346
|
+
remember(source, [r]);
|
|
347
|
+
setQuery("");
|
|
348
|
+
await props.onPick(r);
|
|
349
|
+
}
|
|
350
|
+
finally {
|
|
351
|
+
setCreating(false);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
else if (e.kind === "more") {
|
|
355
|
+
search.loadMore();
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
const move = (delta) => {
|
|
359
|
+
if (!enabled.length)
|
|
360
|
+
return;
|
|
361
|
+
const i = active ? enabled.indexOf(active) : -1;
|
|
362
|
+
const next = enabled[Math.max(0, Math.min(enabled.length - 1, i + delta))];
|
|
363
|
+
if (next)
|
|
364
|
+
setActiveKey(next.key);
|
|
365
|
+
};
|
|
366
|
+
const onKeyDown = (e) => {
|
|
367
|
+
switch (e.key) {
|
|
368
|
+
case "ArrowDown":
|
|
369
|
+
e.preventDefault();
|
|
370
|
+
move(1);
|
|
371
|
+
break;
|
|
372
|
+
case "ArrowUp":
|
|
373
|
+
e.preventDefault();
|
|
374
|
+
move(-1);
|
|
375
|
+
break;
|
|
376
|
+
case "PageDown":
|
|
377
|
+
e.preventDefault();
|
|
378
|
+
move(8);
|
|
379
|
+
break;
|
|
380
|
+
case "PageUp":
|
|
381
|
+
e.preventDefault();
|
|
382
|
+
move(-8);
|
|
383
|
+
break;
|
|
384
|
+
case "Enter":
|
|
385
|
+
e.preventDefault();
|
|
386
|
+
void activate(active);
|
|
387
|
+
break;
|
|
388
|
+
case "Backspace":
|
|
389
|
+
if (multiple && query === "" && props.onRemoveLast) {
|
|
390
|
+
e.preventDefault();
|
|
391
|
+
props.onRemoveLast();
|
|
392
|
+
}
|
|
393
|
+
break;
|
|
394
|
+
default:
|
|
395
|
+
break;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
// Group consecutive entries for rendering.
|
|
399
|
+
const blocks = [];
|
|
400
|
+
for (const e of entries) {
|
|
401
|
+
const g = e.kind === "record" ? e.group : undefined;
|
|
402
|
+
const last = blocks[blocks.length - 1];
|
|
403
|
+
if (last && last.group === g)
|
|
404
|
+
last.entries.push(e);
|
|
405
|
+
else
|
|
406
|
+
blocks.push({ group: g, entries: [e] });
|
|
407
|
+
}
|
|
408
|
+
const renderEntry = (e) => {
|
|
409
|
+
const isActive = active?.key === e.key;
|
|
410
|
+
const common = {
|
|
411
|
+
id: optionId(e.key),
|
|
412
|
+
role: "option",
|
|
413
|
+
"data-key": e.key,
|
|
414
|
+
"data-active": isActive || undefined,
|
|
415
|
+
onMouseMove: () => setActiveKey(e.key),
|
|
416
|
+
onMouseDown: (ev) => ev.preventDefault(),
|
|
417
|
+
onClick: () => void activate(e),
|
|
418
|
+
};
|
|
419
|
+
if (e.kind === "record") {
|
|
420
|
+
const id = source.getId(e.record);
|
|
421
|
+
const selected = selectedSet.has(id);
|
|
422
|
+
return (_jsxs("div", { ...common, "aria-selected": selected, "aria-disabled": e.disabled || undefined, "data-state": selected ? "checked" : undefined, className: optionClass(isActive, "data-[state=checked]:font-normal min-h-9 gap-2.5 pe-2"), children: [props.renderItem ? props.renderItem(e.record, { selected, disabled: e.disabled, query }) : _jsx(DefaultRecordRow, { source: source, record: e.record, query: query, locale: locale }), _jsx(Check, { "aria-hidden": true, className: cn("ms-auto size-4 shrink-0 text-accent-ink transition-opacity", selected ? "opacity-100" : "opacity-0"), strokeWidth: 2.5 })] }, e.key));
|
|
423
|
+
}
|
|
424
|
+
if (e.kind === "action") {
|
|
425
|
+
return (_jsxs("div", { ...common, "aria-selected": false, className: optionClass(isActive, "font-medium text-accent-ink [&_svg]:text-accent-ink"), children: [e.action.icon ?? null, _jsx("span", { className: itemSlots.label, children: e.action.label })] }, e.key));
|
|
426
|
+
}
|
|
427
|
+
if (e.kind === "create") {
|
|
428
|
+
return (_jsxs("div", { ...common, "aria-selected": false, className: optionClass(isActive), children: [creating ? _jsx(Spinner, { size: "xs", tone: "muted" }) : _jsx(Plus, { "aria-hidden": true }), _jsx("span", { className: itemSlots.label, children: creating ? t("creating") : t("create", { query: query.trim() }) })] }, e.key));
|
|
429
|
+
}
|
|
430
|
+
return (_jsxs("div", { ...common, "aria-selected": false, className: optionClass(isActive, "justify-center text-fg-muted", "sm"), children: [search.loadingMore ? _jsx(Spinner, { size: "xs", tone: "muted" }) : null, t("loadMore")] }, e.key));
|
|
431
|
+
};
|
|
432
|
+
const resultCount = search.items.length;
|
|
433
|
+
const showEmpty = !search.loading && !search.error && entries.length === 0;
|
|
434
|
+
return (_jsxs("div", { "data-slot": "record-picker-panel", className: "flex min-h-0 flex-col", children: [props.header, _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", { role: "combobox", "aria-expanded": true, "aria-controls": listId, "aria-autocomplete": "list", "aria-activedescendant": active ? optionId(active.key) : undefined, "aria-label": props.ariaLabel ?? props.searchPlaceholder ?? t("search"), "aria-busy": search.loading || undefined, autoComplete: "off", spellCheck: false, disabled: props.disabled, placeholder: props.searchPlaceholder ?? t("search"), value: query, onChange: (e) => {
|
|
435
|
+
setQuery(e.target.value);
|
|
436
|
+
setActiveKey(null);
|
|
437
|
+
}, onKeyDown: onKeyDown, ...props.inputProps, className: "h-10 min-w-0 flex-1 bg-transparent text-sm text-fg outline-none placeholder:text-fg-subtle" }), search.loading ? _jsx(Spinner, { size: "xs", tone: "muted" }) : null] }), _jsxs("div", { ref: listRef, id: listId, role: "listbox", "aria-multiselectable": multiple || undefined, "aria-label": props.ariaLabel ?? t("search"), className: cn("overflow-y-auto overscroll-contain p-1", props.inline ? "max-h-80" : "max-h-72"), children: [blocks.map((b, i) => b.group && b.group !== "\u0000all" ? (_jsxs("div", { role: "group", "aria-labelledby": `${listId}-g${i}`, children: [_jsx("div", { id: `${listId}-g${i}`, role: "presentation", className: itemSlots.groupLabel, children: b.group }), b.entries.map(renderEntry)] }, `g${i}`)) : b.group === "\u0000all" ? (_jsx("div", { role: "group", "aria-label": t("results", { count: resultCount }), className: "mt-1 border-t border-line pt-1", children: b.entries.map(renderEntry) }, `g${i}`)) : (_jsx(React.Fragment, { children: b.entries.map(renderEntry) }, `g${i}`))), search.loading && entries.length === 0 ? (_jsx("div", { className: "grid gap-2 p-2", "aria-hidden": true, children: [0, 1, 2].map((i) => (_jsxs("div", { className: "flex items-center gap-2.5", children: [_jsx(Skeleton, { shape: "circle", className: "size-6" }), _jsx(Skeleton, { className: "h-3 flex-1", style: { maxWidth: `${70 - i * 15}%` } })] }, i))) })) : null] }), showEmpty ? _jsx("p", { className: "px-3 pb-4 pt-2 text-center text-sm text-fg-muted", children: query.trim() ? t("noResultsFor", { query: query.trim() }) : t("empty") }) : null, search.error ? (_jsxs("div", { className: "flex items-center gap-2 px-3 pb-3 pt-1 text-sm text-fg-muted", children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "size-4 text-warning" }), _jsx("span", { className: "flex-1", children: t("error") }), _jsxs(Button, { size: "xs", variant: "ghost", onClick: search.retry, children: [_jsx(RotateCw, { "aria-hidden": true }), " ", t("retry")] })] })) : null, atMax ? _jsx("p", { className: "px-3 pb-2 text-xs text-fg-muted", children: t("max", { max }) }) : null, _jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: search.loading ? t("searching") : t("results", { count: resultCount }) }), props.onBrowse ? (_jsxs("div", { className: "flex items-center justify-between gap-2 border-t border-line px-2 py-1.5", children: [_jsx("span", { className: "ps-1 text-xs text-fg-subtle", children: multiple && selectedIds.length ? t("selectedCount", { count: selectedIds.length }) : null }), _jsxs(Button, { size: "xs", variant: "ghost", onClick: props.onBrowse, children: [_jsx(LayoutList, { "aria-hidden": true }), " ", t("browse")] })] })) : null] }));
|
|
438
|
+
}
|
|
439
|
+
/** Built-in browse dialog: bigger search list with checkboxes, load more and a confirm step. */
|
|
440
|
+
function RecordPickerBrowse({ source, open, onOpenChange, multiple, selectedIds, max, onPick, getDisabled, t, onCloseAutoFocus, }) {
|
|
441
|
+
const { locale } = useLocale();
|
|
442
|
+
const [query, setQuery] = React.useState("");
|
|
443
|
+
const [draft, setDraft] = React.useState(selectedIds);
|
|
444
|
+
const search = useRecordSearch(source, query, open, locale);
|
|
445
|
+
React.useEffect(() => {
|
|
446
|
+
if (open) {
|
|
447
|
+
setDraft(selectedIds);
|
|
448
|
+
setQuery("");
|
|
449
|
+
}
|
|
450
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
451
|
+
}, [open]);
|
|
452
|
+
const atMax = max !== undefined && draft.length >= max;
|
|
453
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { size: "lg", onCloseAutoFocus: onCloseAutoFocus, children: [_jsx(DialogHeader, { title: t("browseTitle") }), _jsxs(DialogBody, { className: "grid gap-3", children: [_jsxs("div", { className: cn(controlVariants({ size: "md" })), children: [_jsx(Search, { "aria-hidden": true, className: "text-fg-subtle" }), _jsx("input", { "data-autofocus": true, "aria-label": t("search"), placeholder: t("search"), value: query, onChange: (e) => setQuery(e.target.value), className: "h-full min-w-0 flex-1 bg-transparent outline-none placeholder:text-fg-subtle" }), search.loading ? _jsx(Spinner, { size: "xs", tone: "muted" }) : null] }), _jsxs("ul", { className: "grid max-h-[min(26rem,55vh)] overflow-y-auto overscroll-contain rounded-ui border border-line", "aria-busy": search.loading || undefined, children: [search.items.map((r) => {
|
|
454
|
+
const id = source.getId(r);
|
|
455
|
+
const checked = draft.includes(id);
|
|
456
|
+
const disabled = Boolean(getDisabled?.(r)) || (multiple && atMax && !checked);
|
|
457
|
+
const desc = source.getDescription?.(r);
|
|
458
|
+
const body = (_jsxs(_Fragment, { children: [_jsx(RecordAvatar, { source: source, record: r, size: "md" }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate text-sm font-medium text-fg", children: _jsx(Highlight, { text: source.getLabel(r), query: query, locale: locale }) }), desc ? _jsx("span", { className: "block truncate text-xs text-fg-subtle", children: desc }) : null] })] }));
|
|
459
|
+
return (_jsx("li", { className: "border-b border-line last:border-b-0", children: multiple ? (_jsxs("label", { className: cn("flex cursor-pointer items-center gap-3 px-3 py-2.5 hover:bg-hover", disabled && "pointer-events-none opacity-45"), children: [_jsx(Checkbox, { size: "sm", checked: checked, disabled: disabled, "aria-label": source.getLabel(r), onCheckedChange: (c) => setDraft((d) => (c === true ? [...d, id] : d.filter((x) => x !== id))) }), body] })) : (_jsxs("button", { type: "button", disabled: disabled, "aria-pressed": checked, onClick: () => {
|
|
460
|
+
onPick([r]);
|
|
461
|
+
onOpenChange(false);
|
|
462
|
+
}, className: "flex w-full items-center gap-3 px-3 py-2.5 text-start hover:bg-hover focus-ring disabled:opacity-45 aria-pressed:bg-selected", children: [body, checked ? _jsx(Check, { "aria-hidden": true, className: "size-4 text-accent-ink" }) : null] })) }, id));
|
|
463
|
+
}), !search.loading && search.items.length === 0 ? (_jsx("li", { className: "px-3 py-8 text-center text-sm text-fg-muted", children: query.trim() ? t("noResultsFor", { query: query.trim() }) : t("empty") })) : null, search.nextCursor ? (_jsx("li", { className: "p-1.5", children: _jsx(Button, { size: "sm", variant: "ghost", block: true, loading: search.loadingMore, onClick: search.loadMore, children: t("loadMore") }) })) : null] })] }), multiple ? (_jsxs(DialogFooter, { children: [_jsx(Button, { onClick: () => onOpenChange(false), children: t("cancel") }), _jsx(Button, { variant: "primary", onClick: () => {
|
|
464
|
+
onPick(draft.map((id) => cached(source, id)).filter((r) => r !== undefined));
|
|
465
|
+
onOpenChange(false);
|
|
466
|
+
}, children: t("selectCount", { count: draft.length }) })] })) : null] }) }));
|
|
467
|
+
}
|
|
468
|
+
/* ------------------------------------------------------------------ */
|
|
469
|
+
/* RecordPicker */
|
|
470
|
+
/* ------------------------------------------------------------------ */
|
|
471
|
+
const chipClass = "inline-flex h-6 max-w-full min-w-0 shrink-0 items-center gap-1.5 rounded-full bg-selected ps-1 pe-2 text-xs font-medium leading-none text-fg";
|
|
472
|
+
function RecordPickerInner(props, forwardedRef) {
|
|
473
|
+
const { source, renderItem, getDisabled, getGroup, onCreate, browse, recent, actions, resolveSelection, selectedRecords, display = "chip", mode = "popover", size = "md", placeholder, searchPlaceholder, renderTrigger, header, labels, className, contentClassName, clearable, } = props;
|
|
474
|
+
const multiple = props.multiple === true;
|
|
475
|
+
const control = useFieldControl({
|
|
476
|
+
id: props.id,
|
|
477
|
+
name: props.name,
|
|
478
|
+
disabled: props.disabled,
|
|
479
|
+
readOnly: props.readOnly,
|
|
480
|
+
required: props.required,
|
|
481
|
+
"aria-describedby": props["aria-describedby"],
|
|
482
|
+
"aria-labelledby": props["aria-labelledby"],
|
|
483
|
+
"aria-invalid": props["aria-invalid"] ?? (props.invalid ? true : undefined),
|
|
484
|
+
});
|
|
485
|
+
const cardTriggerId = React.useId();
|
|
486
|
+
const disabled = Boolean(control.disabled);
|
|
487
|
+
const readOnly = Boolean(control.readOnly);
|
|
488
|
+
const t = useLabels("recordPicker", recordPickerLabels, labels);
|
|
489
|
+
const container = usePortalContainer();
|
|
490
|
+
const triggerRef = React.useRef(null);
|
|
491
|
+
// value as an array internally
|
|
492
|
+
const toArray = (v) => (v === undefined ? undefined : Array.isArray(v) ? v : v === null ? [] : [v]);
|
|
493
|
+
const [ids, setIdsRaw] = useControllableState({
|
|
494
|
+
value: toArray(props.value),
|
|
495
|
+
defaultValue: () => toArray(props.defaultValue) ?? EMPTY_IDS,
|
|
496
|
+
name: "RecordPicker",
|
|
497
|
+
});
|
|
498
|
+
const onValueChangeRef = useLatest(props.onValueChange);
|
|
499
|
+
const setIds = (next) => {
|
|
500
|
+
setIdsRaw(next);
|
|
501
|
+
const rs = next.map((id) => cached(source, id)).filter((r) => r !== undefined);
|
|
502
|
+
if (multiple)
|
|
503
|
+
onValueChangeRef.current?.(next, rs);
|
|
504
|
+
else
|
|
505
|
+
onValueChangeRef.current?.(next[0] ?? null, rs[0] ?? null);
|
|
506
|
+
};
|
|
507
|
+
const [open, setOpen] = useControllableState({ value: props.open, defaultValue: props.defaultOpen ?? false, onChange: props.onOpenChange, name: "RecordPicker" });
|
|
508
|
+
const [browseOpen, setBrowseOpen] = React.useState(false);
|
|
509
|
+
const resolved = useResolvedRecords(source, ids, selectedRecords);
|
|
510
|
+
const selected = resolved.filter((x) => x.record).map((x) => x.record);
|
|
511
|
+
const unknownIds = resolved.filter((x) => x.missing).map((x) => x.id);
|
|
512
|
+
const max = multiple ? props.max : undefined;
|
|
513
|
+
const pick = async (r) => {
|
|
514
|
+
let picked = [r];
|
|
515
|
+
if (resolveSelection) {
|
|
516
|
+
const res = await resolveSelection(r);
|
|
517
|
+
picked = Array.isArray(res) ? res : [res];
|
|
518
|
+
}
|
|
519
|
+
remember(source, picked);
|
|
520
|
+
const pickedIds = picked.map((p) => source.getId(p));
|
|
521
|
+
pushRecent(source, pickedIds);
|
|
522
|
+
if (!multiple) {
|
|
523
|
+
setIds(pickedIds.slice(0, 1));
|
|
524
|
+
setOpen(false);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
if (picked.length === 1 && ids.includes(pickedIds[0])) {
|
|
528
|
+
setIds(ids.filter((x) => x !== pickedIds[0]));
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
let next = [...ids, ...pickedIds.filter((x) => !ids.includes(x))];
|
|
532
|
+
if (max !== undefined)
|
|
533
|
+
next = next.slice(0, max);
|
|
534
|
+
setIds(next);
|
|
535
|
+
};
|
|
536
|
+
const remove = (id) => setIds(ids.filter((x) => x !== id));
|
|
537
|
+
const placeholderText = placeholder ?? (multiple ? t("placeholderMultiple") : t("placeholder"));
|
|
538
|
+
const showClear = !multiple && (clearable ?? !control.required) && ids.length > 0 && !disabled && !readOnly;
|
|
539
|
+
const labelOf = (r) => source.getLabel(r);
|
|
540
|
+
const hidden = props.name || control.name ? (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")] : [])) : null;
|
|
541
|
+
const openBrowse = () => {
|
|
542
|
+
setOpen(false);
|
|
543
|
+
setBrowseOpen(true);
|
|
544
|
+
};
|
|
545
|
+
const panel = (_jsx(RecordPickerPanel, { source: source, multiple: multiple, selectedIds: ids, max: max, onPick: pick, onRemoveLast: multiple && ids.length ? () => remove(ids[ids.length - 1]) : undefined, onCreate: onCreate, onBrowse: browse ? openBrowse : undefined, renderItem: renderItem, getDisabled: getDisabled, getGroup: getGroup, recent: recent, actions: actions, close: () => setOpen(false), t: t, searchPlaceholder: searchPlaceholder, header: header, inline: mode === "inline", disabled: disabled || readOnly, ariaLabel: mode === "inline" ? props["aria-label"] : undefined, inputProps: mode === "inline" ? { id: control.id, "aria-labelledby": control["aria-labelledby"], "aria-describedby": control["aria-describedby"] } : undefined }));
|
|
546
|
+
const browseDialog = browse === true ? (_jsx(RecordPickerBrowse, { source: source, open: browseOpen, onOpenChange: setBrowseOpen, multiple: multiple, selectedIds: ids, max: max, getDisabled: getDisabled, t: t, onCloseAutoFocus: (e) => {
|
|
547
|
+
e.preventDefault();
|
|
548
|
+
triggerRef.current?.focus();
|
|
549
|
+
}, onPick: (rs) => {
|
|
550
|
+
remember(source, rs);
|
|
551
|
+
const picked = rs.map((r) => source.getId(r));
|
|
552
|
+
pushRecent(source, picked);
|
|
553
|
+
setIds(multiple ? picked : picked.slice(0, 1));
|
|
554
|
+
} })) : typeof browse === "function" && browseOpen ? (browse({
|
|
555
|
+
selectedIds: ids,
|
|
556
|
+
multiple,
|
|
557
|
+
close: () => setBrowseOpen(false),
|
|
558
|
+
onPick: (rs) => {
|
|
559
|
+
remember(source, rs);
|
|
560
|
+
const picked = rs.map((r) => source.getId(r));
|
|
561
|
+
setIds(multiple ? picked : picked.slice(0, 1));
|
|
562
|
+
setBrowseOpen(false);
|
|
563
|
+
},
|
|
564
|
+
})) : null;
|
|
565
|
+
/* ---------- inline mode ---------- */
|
|
566
|
+
if (mode === "inline") {
|
|
567
|
+
return (_jsxs("div", { ref: forwardedRef, "data-slot": "record-picker", "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, hidden, browseDialog] }));
|
|
568
|
+
}
|
|
569
|
+
/* ---------- selected rendering ---------- */
|
|
570
|
+
const renderChip = (x) => {
|
|
571
|
+
if (x.pending)
|
|
572
|
+
return _jsx(Skeleton, { className: "h-6 w-24 rounded-full", "aria-hidden": true }, x.id);
|
|
573
|
+
if (!x.record) {
|
|
574
|
+
return (_jsxs("span", { "data-slot": "record-chip", "data-unknown": "", title: x.id, className: cn(chipClass, "tone-warning tone-soft ps-2"), children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "size-3" }), t("unknown"), !readOnly && !disabled ? _jsx(ChipRemoveButton, { onRemove: () => remove(x.id), itemLabel: t("unknown") }) : null] }, x.id));
|
|
575
|
+
}
|
|
576
|
+
const r = x.record;
|
|
577
|
+
const label = labelOf(r);
|
|
578
|
+
const href = source.href?.(r);
|
|
579
|
+
const a = source.getAvatar?.(r);
|
|
580
|
+
return (_jsxs("span", { "data-slot": "record-chip", className: cn(chipClass, !a && "ps-2"), children: [a ? _jsx(Avatar, { name: a.name, src: a.src, shape: a.shape, size: "xs", "aria-hidden": true }) : null, href ? (_jsx(SmartLink, { href: href, className: "min-w-0 truncate underline-offset-2 hover:underline focus-ring rounded-sm", children: label })) : (_jsx("span", { className: "min-w-0 truncate", children: label })), !readOnly && !disabled ? _jsx(ChipRemoveButton, { onRemove: () => remove(x.id), itemLabel: label, labels: { remove: t.labels.remove } }) : null] }, x.id));
|
|
581
|
+
};
|
|
582
|
+
const renderCard = (x) => {
|
|
583
|
+
if (x.pending) {
|
|
584
|
+
return (_jsxs("div", { className: "flex items-center gap-3 rounded-ui border border-line bg-surface-2 p-3", "aria-hidden": true, children: [_jsx(Skeleton, { shape: "circle", className: "size-10" }), _jsxs("div", { className: "grid flex-1 gap-1.5", children: [_jsx(Skeleton, { className: "h-3 w-1/2" }), _jsx(Skeleton, { className: "h-2.5 w-1/3" })] })] }, x.id));
|
|
585
|
+
}
|
|
586
|
+
const r = x.record;
|
|
587
|
+
const label = r ? labelOf(r) : t("unknown");
|
|
588
|
+
const href = r ? source.href?.(r) : undefined;
|
|
589
|
+
const desc = r ? source.getDescription?.(r) : x.id;
|
|
590
|
+
return (_jsxs("div", { "data-slot": "record-card", "data-unknown": r ? undefined : "", className: cn("group/card relative flex items-center gap-3 rounded-ui border border-line bg-surface-2 p-3", !r && "tone-warning tone-soft border-transparent"), children: [r ? _jsx(RecordAvatar, { source: source, record: r, size: "lg" }) : _jsx(TriangleAlert, { "aria-hidden": true, className: "size-5 text-warning" }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "truncate text-sm font-medium text-fg", children: label }), desc ? _jsx("div", { className: "truncate text-xs text-fg-muted", children: desc }) : null] }), href ? (_jsx(IconButton, { asChild: true, label: t("open", { label }), size: "sm", variant: "ghost", tooltip: false, children: _jsx(SmartLink, { href: href, children: _jsx(ExternalLink, {}) }) })) : null, !readOnly && !disabled ? (_jsx(IconButton, { label: t("remove", { label }), size: "sm", variant: "ghost", tooltip: false, onClick: () => remove(x.id), children: _jsx(X, {}) })) : null] }, x.id));
|
|
591
|
+
};
|
|
592
|
+
/* ---------- trigger ---------- */
|
|
593
|
+
const triggerA11y = {
|
|
594
|
+
id: control.id,
|
|
595
|
+
"aria-label": props["aria-label"],
|
|
596
|
+
"aria-labelledby": control["aria-labelledby"],
|
|
597
|
+
"aria-describedby": mergeIds(control["aria-describedby"]),
|
|
598
|
+
"aria-invalid": control["aria-invalid"],
|
|
599
|
+
// No aria-required: the triggers are buttons, where it isn't allowed (axe aria-allowed-attr).
|
|
600
|
+
// The Field marks the label as required and the hidden input carries the constraint.
|
|
601
|
+
"aria-haspopup": "listbox",
|
|
602
|
+
disabled,
|
|
603
|
+
};
|
|
604
|
+
let body;
|
|
605
|
+
if (readOnly) {
|
|
606
|
+
body =
|
|
607
|
+
display === "card" ? (_jsxs("div", { ref: forwardedRef, "data-slot": "record-picker", "data-readonly": "", className: cn("grid gap-2", className), children: [resolved.map(renderCard), hidden] })) : (_jsxs("div", { ref: forwardedRef, id: control.id, "data-slot": "record-picker", "data-readonly": "", role: "group", "aria-labelledby": control["aria-labelledby"], "aria-describedby": control["aria-describedby"], className: cn(controlVariants({ size, multiline: multiple || undefined }), "flex-wrap gap-1.5", className), children: [resolved.length ? resolved.map(renderChip) : _jsx("span", { className: "text-fg-subtle", children: "\u2014" }), hidden] }));
|
|
608
|
+
return body;
|
|
609
|
+
}
|
|
610
|
+
const content = (_jsx(PopoverPrimitive.Portal, { container: container, children: _jsx(Layer, { asChild: true, children: _jsx(PopoverPrimitive.Content, { "data-slot": "record-picker-content", "aria-label": props["aria-label"] ?? searchPlaceholder ?? t("search"), align: "start", sideOffset: 6, collisionPadding: 12, className: cn("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", contentClassName), onOpenAutoFocus: (e) => {
|
|
611
|
+
e.preventDefault();
|
|
612
|
+
e.currentTarget?.querySelector("input[role=combobox]")?.focus();
|
|
613
|
+
}, children: _jsx(FieldContextReset, { children: panel }) }) }) }));
|
|
614
|
+
if (renderTrigger) {
|
|
615
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, ref: triggerRef, ...triggerA11y, children: renderTrigger({ selected, unknownIds, open, disabled, placeholder: placeholderText, getLabel: labelOf }) }), content, hidden, browseDialog] }));
|
|
616
|
+
}
|
|
617
|
+
if (display === "card") {
|
|
618
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsxs("div", { ref: forwardedRef, "data-slot": "record-picker", "data-display": "card", className: cn("grid gap-2", className), children: [resolved.map(renderCard), (multiple && (max === undefined || ids.length < max)) || !multiple ? (_jsx(PopoverPrimitive.Anchor, { asChild: true, children: _jsx("div", { children: _jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs(Button, { ref: triggerRef, size: "sm", variant: "secondary", ...triggerA11y, "aria-label": props["aria-label"],
|
|
619
|
+
// The visible text ("Add", "Change") must stay part of the name next to the label.
|
|
620
|
+
id: control.id ?? cardTriggerId, "aria-labelledby": control["aria-labelledby"] ? `${control["aria-labelledby"]} ${control.id ?? cardTriggerId}` : undefined, children: [_jsx(Plus, { "aria-hidden": true }), " ", !multiple && ids.length ? t("change") : placeholder ?? t("add")] }) }) }) })) : null, hidden] }), content, browseDialog] }));
|
|
621
|
+
}
|
|
622
|
+
if (multiple) {
|
|
623
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Anchor, { asChild: true, children: _jsxs("div", { ref: forwardedRef, "data-slot": "record-picker", "data-state": open ? "open" : "closed", "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), onClick: (e) => {
|
|
624
|
+
if (e.target === e.currentTarget && !disabled)
|
|
625
|
+
triggerRef.current?.click();
|
|
626
|
+
}, children: [resolved.map(renderChip), _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: placeholderText })] }) }), hidden] }) }), content, browseDialog] }));
|
|
627
|
+
}
|
|
628
|
+
const current = resolved[0];
|
|
629
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Anchor, { asChild: true, children: _jsxs("div", { ref: forwardedRef, "data-slot": "record-picker", "data-state": open ? "open" : "closed", "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, "aria-label": undefined, 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: [props["aria-label"] && !control["aria-labelledby"] ? _jsxs("span", { className: "sr-only", children: [props["aria-label"], ", "] }) : null, current?.pending ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: t("resolving") }), _jsx(Skeleton, { "aria-hidden": true, className: "h-3 w-32" })] })) : current?.record ? (_jsxs(_Fragment, { children: [_jsx(RecordAvatar, { source: source, record: current.record, size: size === "lg" ? "sm" : "xs" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: labelOf(current.record) })] })) : current?.missing ? (_jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-1.5 truncate text-warning", children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "size-3.5" }), " ", t("unknown")] })) : (_jsx("span", { className: "min-w-0 flex-1 truncate text-fg-subtle", children: placeholderText })), !showClear ? _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: () => {
|
|
630
|
+
setIds([]);
|
|
631
|
+
triggerRef.current?.focus();
|
|
632
|
+
}, 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, browseDialog] }));
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Link one or many related records from any collection: a contact to a company, a post to its
|
|
636
|
+
* author, an order to a customer, a task to a project. Async search with debounce, abort and
|
|
637
|
+
* paging; recent picks; inline create; a browse dialog for big sets; chips or cards; ids → labels
|
|
638
|
+
* resolution with a skeleton and an "Unknown record" state for deleted records.
|
|
639
|
+
*
|
|
640
|
+
* ```tsx
|
|
641
|
+
* const companies: RecordSource<Company> = {
|
|
642
|
+
* key: "companies",
|
|
643
|
+
* search: (q, { signal, cursor }) => api.companies.search({ q, cursor }, { signal }),
|
|
644
|
+
* getByIds: (ids, signal) => api.companies.byIds(ids, { signal }),
|
|
645
|
+
* getId: (c) => c.id, getLabel: (c) => c.name, getDescription: (c) => c.domain,
|
|
646
|
+
* };
|
|
647
|
+
* <Field label="Company"><RecordPicker source={companies} value={companyId} onValueChange={setCompanyId} /></Field>
|
|
648
|
+
* ```
|
|
649
|
+
*/
|
|
650
|
+
export const RecordPicker = React.forwardRef(RecordPickerInner);
|