@vamos-ui/react 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +27 -2
- package/dist/blocks/block-heading.d.ts +29 -0
- package/dist/blocks/block-heading.js +39 -0
- package/dist/blocks/block-image.d.ts +52 -0
- package/dist/blocks/block-image.js +48 -0
- package/dist/blocks/block-link.d.ts +30 -0
- package/dist/blocks/block-link.js +36 -0
- package/dist/blocks/create-blocks.d.ts +54 -0
- package/dist/blocks/create-blocks.js +52 -0
- package/dist/blocks/index.d.ts +55 -0
- package/dist/blocks/index.js +59 -0
- package/dist/blocks/json-ld.d.ts +18 -0
- package/dist/blocks/json-ld.js +44 -0
- package/dist/blocks/labels.d.ts +20 -0
- package/dist/blocks/labels.js +43 -0
- package/dist/blocks/rich-text.d.ts +36 -0
- package/dist/blocks/rich-text.js +106 -0
- package/dist/blocks/schema/define-block.d.ts +151 -0
- package/dist/blocks/schema/define-block.js +120 -0
- package/dist/blocks/schema/emphasis.d.ts +17 -0
- package/dist/blocks/schema/emphasis.js +69 -0
- package/dist/blocks/schema/fields.d.ts +497 -0
- package/dist/blocks/schema/fields.js +240 -0
- package/dist/blocks/schema/icons.d.ts +2 -0
- package/dist/blocks/schema/icons.js +26 -0
- package/dist/blocks/schema/index.d.ts +18 -0
- package/dist/blocks/schema/index.js +21 -0
- package/dist/blocks/schema/lint-types.d.ts +16 -0
- package/dist/blocks/schema/lint-types.js +2 -0
- package/dist/blocks/schema/lint.d.ts +32 -0
- package/dist/blocks/schema/lint.js +164 -0
- package/dist/blocks/schema/localize.d.ts +20 -0
- package/dist/blocks/schema/localize.js +29 -0
- package/dist/blocks/schema/localized.d.ts +25 -0
- package/dist/blocks/schema/localized.js +53 -0
- package/dist/blocks/schema/migrate.d.ts +24 -0
- package/dist/blocks/schema/migrate.js +75 -0
- package/dist/blocks/schema/nodes.d.ts +196 -0
- package/dist/blocks/schema/nodes.js +78 -0
- package/dist/blocks/schema/rich-doc-schema.d.ts +32 -0
- package/dist/blocks/schema/rich-doc-schema.js +66 -0
- package/dist/blocks/schema/rich-doc.d.ts +90 -0
- package/dist/blocks/schema/rich-doc.js +62 -0
- package/dist/blocks/schema/safety.d.ts +20 -0
- package/dist/blocks/schema/safety.js +49 -0
- package/dist/blocks/schema/types.d.ts +172 -0
- package/dist/blocks/schema/types.js +3 -0
- package/dist/blocks/schema/validate.d.ts +17 -0
- package/dist/blocks/schema/validate.js +32 -0
- package/dist/blocks/schema/walk.d.ts +22 -0
- package/dist/blocks/schema/walk.js +60 -0
- package/dist/blocks/section-header.d.ts +38 -0
- package/dist/blocks/section-header.js +22 -0
- package/dist/blocks/section.d.ts +59 -0
- package/dist/blocks/section.js +66 -0
- package/dist/blocks/site/_kit-1.d.ts +100 -0
- package/dist/blocks/site/_kit-1.js +135 -0
- package/dist/blocks/site/_site-icon-1.d.ts +6 -0
- package/dist/blocks/site/_site-icon-1.js +15 -0
- package/dist/blocks/site/announcement-bar.d.ts +42 -0
- package/dist/blocks/site/announcement-bar.js +38 -0
- package/dist/blocks/site/announcement-dismiss.d.ts +18 -0
- package/dist/blocks/site/announcement-dismiss.js +28 -0
- package/dist/blocks/site/article-layout.d.ts +65 -0
- package/dist/blocks/site/article-layout.js +88 -0
- package/dist/blocks/site/blog-list.d.ts +79 -0
- package/dist/blocks/site/blog-list.js +78 -0
- package/dist/blocks/site/comparison-table.d.ts +54 -0
- package/dist/blocks/site/comparison-table.js +38 -0
- package/dist/blocks/site/consent-banner.d.ts +52 -0
- package/dist/blocks/site/consent-banner.js +33 -0
- package/dist/blocks/site/contact-dock.d.ts +52 -0
- package/dist/blocks/site/contact-dock.js +55 -0
- package/dist/blocks/site/contact-form.d.ts +60 -0
- package/dist/blocks/site/contact-form.js +45 -0
- package/dist/blocks/site/cta-booking.d.ts +43 -0
- package/dist/blocks/site/cta-booking.js +69 -0
- package/dist/blocks/site/cta.d.ts +74 -0
- package/dist/blocks/site/cta.js +112 -0
- package/dist/blocks/site/embed-facade.d.ts +20 -0
- package/dist/blocks/site/embed-facade.js +21 -0
- package/dist/blocks/site/faq.d.ts +48 -0
- package/dist/blocks/site/faq.js +51 -0
- package/dist/blocks/site/feature-grid.d.ts +46 -0
- package/dist/blocks/site/feature-grid.js +49 -0
- package/dist/blocks/site/feature-tabs.d.ts +22 -0
- package/dist/blocks/site/feature-tabs.js +11 -0
- package/dist/blocks/site/footer.d.ts +68 -0
- package/dist/blocks/site/footer.js +61 -0
- package/dist/blocks/site/gallery-section.d.ts +42 -0
- package/dist/blocks/site/gallery-section.js +47 -0
- package/dist/blocks/site/hero-video.d.ts +15 -0
- package/dist/blocks/site/hero-video.js +31 -0
- package/dist/blocks/site/hero.d.ts +64 -0
- package/dist/blocks/site/hero.js +67 -0
- package/dist/blocks/site/logo-strip.d.ts +42 -0
- package/dist/blocks/site/logo-strip.js +26 -0
- package/dist/blocks/site/map-hours.d.ts +83 -0
- package/dist/blocks/site/map-hours.js +125 -0
- package/dist/blocks/site/media-text.d.ts +45 -0
- package/dist/blocks/site/media-text.js +55 -0
- package/dist/blocks/site/menu-list.d.ts +74 -0
- package/dist/blocks/site/menu-list.js +84 -0
- package/dist/blocks/site/navbar-submenu.d.ts +18 -0
- package/dist/blocks/site/navbar-submenu.js +51 -0
- package/dist/blocks/site/navbar.d.ts +67 -0
- package/dist/blocks/site/navbar.js +64 -0
- package/dist/blocks/site/not-found.d.ts +40 -0
- package/dist/blocks/site/not-found.js +38 -0
- package/dist/blocks/site/page-intro.d.ts +46 -0
- package/dist/blocks/site/page-intro.js +44 -0
- package/dist/blocks/site/pricing-table.d.ts +67 -0
- package/dist/blocks/site/pricing-table.js +82 -0
- package/dist/blocks/site/process.d.ts +36 -0
- package/dist/blocks/site/process.js +41 -0
- package/dist/blocks/site/registry-1.d.ts +720 -0
- package/dist/blocks/site/registry-1.js +783 -0
- package/dist/blocks/site/registry-2.d.ts +914 -0
- package/dist/blocks/site/registry-2.js +563 -0
- package/dist/blocks/site/rich-text-section.d.ts +34 -0
- package/dist/blocks/site/rich-text-section.js +32 -0
- package/dist/blocks/site/shared/brand-icons.d.ts +21 -0
- package/dist/blocks/site/shared/brand-icons.js +56 -0
- package/dist/blocks/site/shared/consent-gate.d.ts +41 -0
- package/dist/blocks/site/shared/consent-gate.js +43 -0
- package/dist/blocks/site/shared/consent-island.d.ts +38 -0
- package/dist/blocks/site/shared/consent-island.js +63 -0
- package/dist/blocks/site/shared/consent.d.ts +49 -0
- package/dist/blocks/site/shared/consent.js +130 -0
- package/dist/blocks/site/shared/contact-form-island.d.ts +41 -0
- package/dist/blocks/site/shared/contact-form-island.js +100 -0
- package/dist/blocks/site/shared/copy-link.d.ts +10 -0
- package/dist/blocks/site/shared/copy-link.js +25 -0
- package/dist/blocks/site/shared/dock-avoid.d.ts +15 -0
- package/dist/blocks/site/shared/dock-avoid.js +107 -0
- package/dist/blocks/site/shared/dock-hours.d.ts +13 -0
- package/dist/blocks/site/shared/dock-hours.js +25 -0
- package/dist/blocks/site/shared/gallery-lightbox.d.ts +12 -0
- package/dist/blocks/site/shared/gallery-lightbox.js +10 -0
- package/dist/blocks/site/shared/island-keys.d.ts +10 -0
- package/dist/blocks/site/shared/island-keys.js +44 -0
- package/dist/blocks/site/shared/kit-2.d.ts +55 -0
- package/dist/blocks/site/shared/kit-2.js +84 -0
- package/dist/blocks/site/shared/labels-2.d.ts +209 -0
- package/dist/blocks/site/shared/labels-2.js +427 -0
- package/dist/blocks/site/shared/open-now.d.ts +22 -0
- package/dist/blocks/site/shared/open-now.js +27 -0
- package/dist/blocks/site/shared/opening-hours.d.ts +117 -0
- package/dist/blocks/site/shared/opening-hours.js +245 -0
- package/dist/blocks/site/shared/site-accent.d.ts +48 -0
- package/dist/blocks/site/shared/site-accent.js +249 -0
- package/dist/blocks/site/shared/site-form.d.ts +79 -0
- package/dist/blocks/site/shared/site-form.js +111 -0
- package/dist/blocks/site/shared/site-routing.d.ts +54 -0
- package/dist/blocks/site/shared/site-routing.js +86 -0
- package/dist/blocks/site/shared/testimonials-carousel.d.ts +17 -0
- package/dist/blocks/site/shared/testimonials-carousel.js +64 -0
- package/dist/blocks/site/site-shell.d.ts +97 -0
- package/dist/blocks/site/site-shell.js +227 -0
- package/dist/blocks/site/stats-band.d.ts +40 -0
- package/dist/blocks/site/stats-band.js +41 -0
- package/dist/blocks/site/team.d.ts +44 -0
- package/dist/blocks/site/team.js +48 -0
- package/dist/blocks/site/testimonials.d.ts +68 -0
- package/dist/blocks/site/testimonials.js +65 -0
- package/dist/blocks/types.d.ts +63 -0
- package/dist/blocks/types.js +2 -0
- package/dist/business/approval-flow.d.ts +152 -0
- package/dist/business/approval-flow.js +221 -0
- package/dist/business/export-core.d.ts +55 -0
- package/dist/business/export-core.js +101 -0
- package/dist/business/export.d.ts +148 -0
- package/dist/business/export.js +264 -0
- package/dist/business/import-core.d.ts +104 -0
- package/dist/business/import-core.js +281 -0
- package/dist/business/import-wizard.d.ts +186 -0
- package/dist/business/import-wizard.js +401 -0
- package/dist/business/index.d.ts +11 -0
- package/dist/business/index.js +20 -0
- package/dist/business/line-items-core.d.ts +129 -0
- package/dist/business/line-items-core.js +183 -0
- package/dist/business/line-items.d.ts +119 -0
- package/dist/business/line-items.js +299 -0
- package/dist/business/multi-step-form.d.ts +131 -0
- package/dist/business/multi-step-form.js +337 -0
- package/dist/business/permission-core.d.ts +59 -0
- package/dist/business/permission-core.js +99 -0
- package/dist/business/permission-matrix.d.ts +158 -0
- package/dist/business/permission-matrix.js +341 -0
- package/dist/business/setup-checklist.d.ts +80 -0
- package/dist/business/setup-checklist.js +92 -0
- package/dist/charts/area-chart.d.ts +35 -0
- package/dist/charts/area-chart.js +33 -0
- package/dist/charts/bar-chart.d.ts +27 -0
- package/dist/charts/bar-chart.js +42 -0
- package/dist/charts/bar-list.d.ts +47 -0
- package/dist/charts/bar-list.js +60 -0
- package/dist/charts/chart-shell.d.ts +173 -0
- package/dist/charts/chart-shell.js +205 -0
- package/dist/charts/chart.d.ts +73 -0
- package/dist/charts/chart.js +106 -0
- package/dist/charts/combo-chart.d.ts +29 -0
- package/dist/charts/combo-chart.js +47 -0
- package/dist/charts/donut-chart.d.ts +33 -0
- package/dist/charts/donut-chart.js +113 -0
- package/dist/charts/funnel.d.ts +51 -0
- package/dist/charts/funnel.js +69 -0
- package/dist/charts/gauge.d.ts +62 -0
- package/dist/charts/gauge.js +104 -0
- package/dist/charts/heatmap.d.ts +81 -0
- package/dist/charts/heatmap.js +338 -0
- package/dist/charts/index.d.ts +12 -0
- package/dist/charts/index.js +14 -0
- package/dist/charts/line-chart.d.ts +21 -0
- package/dist/charts/line-chart.js +36 -0
- package/dist/charts/test-utils.d.ts +2 -0
- package/dist/charts/test-utils.js +38 -0
- package/dist/charts/utils.d.ts +130 -0
- package/dist/charts/utils.js +262 -0
- package/dist/components/accordion.d.ts +47 -0
- package/dist/components/accordion.js +70 -0
- package/dist/components/activity-timeline.d.ts +149 -0
- package/dist/components/activity-timeline.js +122 -0
- package/dist/components/address-field.d.ts +116 -0
- package/dist/components/address-field.js +219 -0
- package/dist/components/alert-dialog.d.ts +99 -0
- package/dist/components/alert-dialog.js +192 -0
- package/dist/components/alert.d.ts +42 -0
- package/dist/components/alert.js +82 -0
- package/dist/components/app-shell.d.ts +159 -0
- package/dist/components/app-shell.js +289 -0
- package/dist/components/attachment-list.d.ts +96 -0
- package/dist/components/attachment-list.js +196 -0
- package/dist/components/audit-log.d.ts +150 -0
- package/dist/components/audit-log.js +205 -0
- package/dist/components/avatar.d.ts +87 -0
- package/dist/components/avatar.js +126 -0
- package/dist/components/badge.d.ts +41 -0
- package/dist/components/badge.js +68 -0
- package/dist/components/breadcrumb.d.ts +78 -0
- package/dist/components/breadcrumb.js +106 -0
- package/dist/components/button-group.d.ts +52 -0
- package/dist/components/button-group.js +77 -0
- package/dist/components/button.d.ts +58 -0
- package/dist/components/button.js +107 -0
- package/dist/components/calendar.d.ts +240 -0
- package/dist/components/calendar.js +483 -0
- package/dist/components/card.d.ts +66 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +170 -0
- package/dist/components/carousel.js +348 -0
- package/dist/components/checkbox.d.ts +78 -0
- package/dist/components/checkbox.js +138 -0
- package/dist/components/color-picker.d.ts +112 -0
- package/dist/components/color-picker.js +235 -0
- package/dist/components/combobox.d.ts +136 -0
- package/dist/components/combobox.js +294 -0
- package/dist/components/command.d.ts +275 -0
- package/dist/components/command.js +493 -0
- package/dist/components/comment-thread.d.ts +252 -0
- package/dist/components/comment-thread.js +449 -0
- package/dist/components/context-menu.d.ts +77 -0
- package/dist/components/context-menu.js +82 -0
- package/dist/components/currency-input.d.ts +43 -0
- package/dist/components/currency-input.js +85 -0
- package/dist/components/date-picker.d.ts +141 -0
- package/dist/components/date-picker.js +241 -0
- package/dist/components/date-range-picker.d.ts +91 -0
- package/dist/components/date-range-picker.js +251 -0
- package/dist/components/description-list.d.ts +92 -0
- package/dist/components/description-list.js +42 -0
- package/dist/components/dialog.d.ts +139 -0
- package/dist/components/dialog.js +185 -0
- package/dist/components/dropdown-menu.d.ts +100 -0
- package/dist/components/dropdown-menu.js +102 -0
- package/dist/components/editor-layout.d.ts +166 -0
- package/dist/components/editor-layout.js +237 -0
- package/dist/components/empty-state.d.ts +49 -0
- package/dist/components/empty-state.js +68 -0
- package/dist/components/entity-card.d.ts +83 -0
- package/dist/components/entity-card.js +92 -0
- package/dist/components/file-upload.d.ts +256 -0
- package/dist/components/file-upload.js +490 -0
- package/dist/components/formatted-input.d.ts +177 -0
- package/dist/components/formatted-input.js +399 -0
- package/dist/components/hierarchy-chart.d.ts +190 -0
- package/dist/components/hierarchy-chart.js +890 -0
- package/dist/components/hover-card.d.ts +21 -0
- package/dist/components/hover-card.js +32 -0
- package/dist/components/iban-input.d.ts +38 -0
- package/dist/components/iban-input.js +112 -0
- package/dist/components/id-input.d.ts +65 -0
- package/dist/components/id-input.js +130 -0
- package/dist/components/image.d.ts +130 -0
- package/dist/components/image.js +168 -0
- package/dist/components/input-otp.d.ts +62 -0
- package/dist/components/input-otp.js +73 -0
- package/dist/components/input.d.ts +141 -0
- package/dist/components/input.js +187 -0
- package/dist/components/item.d.ts +96 -0
- package/dist/components/item.js +113 -0
- package/dist/components/kbd.d.ts +64 -0
- package/dist/components/kbd.js +119 -0
- package/dist/components/list-layout.d.ts +144 -0
- package/dist/components/list-layout.js +210 -0
- package/dist/components/native-select.d.ts +33 -0
- package/dist/components/native-select.js +48 -0
- package/dist/components/navigation-menu.d.ts +127 -0
- package/dist/components/navigation-menu.js +129 -0
- package/dist/components/notification-center.d.ts +164 -0
- package/dist/components/notification-center.js +399 -0
- package/dist/components/page-header.d.ts +60 -0
- package/dist/components/page-header.js +60 -0
- package/dist/components/pagination.d.ts +121 -0
- package/dist/components/pagination.js +174 -0
- package/dist/components/phone-input.d.ts +49 -0
- package/dist/components/phone-input.js +266 -0
- package/dist/components/popover.d.ts +38 -0
- package/dist/components/popover.js +69 -0
- package/dist/components/progress.d.ts +79 -0
- package/dist/components/progress.js +97 -0
- package/dist/components/radio-group.d.ts +43 -0
- package/dist/components/radio-group.js +81 -0
- package/dist/components/record-detail-layout.d.ts +167 -0
- package/dist/components/record-detail-layout.js +233 -0
- package/dist/components/record-picker.d.ts +199 -0
- package/dist/components/record-picker.js +650 -0
- package/dist/components/resizable.d.ts +50 -0
- package/dist/components/resizable.js +88 -0
- package/dist/components/scroll-area.d.ts +40 -0
- package/dist/components/scroll-area.js +56 -0
- package/dist/components/select.d.ts +126 -0
- package/dist/components/select.js +137 -0
- package/dist/components/separator.d.ts +31 -0
- package/dist/components/separator.js +41 -0
- package/dist/components/settings-layout.d.ts +134 -0
- package/dist/components/settings-layout.js +180 -0
- package/dist/components/sheet.d.ts +103 -0
- package/dist/components/sheet.js +165 -0
- package/dist/components/sidebar.d.ts +171 -0
- package/dist/components/sidebar.js +421 -0
- package/dist/components/signature-pad.d.ts +85 -0
- package/dist/components/signature-pad.js +283 -0
- package/dist/components/skeleton.d.ts +64 -0
- package/dist/components/skeleton.js +53 -0
- package/dist/components/slider.d.ts +57 -0
- package/dist/components/slider.js +133 -0
- package/dist/components/slug-input.d.ts +69 -0
- package/dist/components/slug-input.js +201 -0
- package/dist/components/sparkline.d.ts +54 -0
- package/dist/components/sparkline.js +122 -0
- package/dist/components/spinner.d.ts +34 -0
- package/dist/components/spinner.js +34 -0
- package/dist/components/stat.d.ts +135 -0
- package/dist/components/stat.js +130 -0
- package/dist/components/status-picker.d.ts +107 -0
- package/dist/components/status-picker.js +175 -0
- package/dist/components/stepper.d.ts +86 -0
- package/dist/components/stepper.js +103 -0
- package/dist/components/switch.d.ts +34 -0
- package/dist/components/switch.js +70 -0
- package/dist/components/table.d.ts +101 -0
- package/dist/components/table.js +72 -0
- package/dist/components/tabs.d.ts +103 -0
- package/dist/components/tabs.js +173 -0
- package/dist/components/tag-input.d.ts +77 -0
- package/dist/components/tag-input.js +305 -0
- package/dist/components/task-list.d.ts +89 -0
- package/dist/components/task-list.js +238 -0
- package/dist/components/time-picker.d.ts +119 -0
- package/dist/components/time-picker.js +399 -0
- package/dist/components/toast.d.ts +87 -0
- package/dist/components/toast.js +142 -0
- package/dist/components/toggle.d.ts +77 -0
- package/dist/components/toggle.js +109 -0
- package/dist/components/tooltip.d.ts +69 -0
- package/dist/components/tooltip.js +105 -0
- package/dist/components/top-bar.d.ts +87 -0
- package/dist/components/top-bar.js +99 -0
- package/dist/components/tree-select.d.ts +89 -0
- package/dist/components/tree-select.js +243 -0
- package/dist/components/tree-view.d.ts +109 -0
- package/dist/components/tree-view.js +170 -0
- package/dist/components/typography.d.ts +107 -0
- package/dist/components/typography.js +128 -0
- package/dist/components/user-picker.d.ts +89 -0
- package/dist/components/user-picker.js +162 -0
- package/dist/components/version-history.d.ts +191 -0
- package/dist/components/version-history.js +431 -0
- package/dist/data-table/csv.d.ts +27 -0
- package/dist/data-table/csv.js +68 -0
- package/dist/data-table/data-table.d.ts +423 -0
- package/dist/data-table/data-table.js +1259 -0
- package/dist/data-table/filter-bar.d.ts +146 -0
- package/dist/data-table/filter-bar.js +569 -0
- package/dist/data-table/filter-fns.d.ts +65 -0
- package/dist/data-table/filter-fns.js +382 -0
- package/dist/data-table/index.d.ts +8 -0
- package/dist/data-table/index.js +9 -0
- package/dist/data-table/saved-views.d.ts +100 -0
- package/dist/data-table/saved-views.js +251 -0
- package/dist/data-table/types.d.ts +168 -0
- package/dist/data-table/types.js +87 -0
- package/dist/data-table/url-state.d.ts +94 -0
- package/dist/data-table/url-state.js +303 -0
- package/dist/data-table/view-state.d.ts +16 -0
- package/dist/data-table/view-state.js +81 -0
- package/dist/editor/_test-setup.d.ts +1 -0
- package/dist/editor/_test-setup.js +33 -0
- package/dist/editor/block-editor.d.ts +137 -0
- package/dist/editor/block-editor.js +280 -0
- package/dist/editor/commands.d.ts +31 -0
- package/dist/editor/commands.js +150 -0
- package/dist/editor/context.d.ts +108 -0
- package/dist/editor/context.js +30 -0
- package/dist/editor/convert.d.ts +66 -0
- package/dist/editor/convert.js +567 -0
- package/dist/editor/drag-handle.d.ts +10 -0
- package/dist/editor/drag-handle.js +69 -0
- package/dist/editor/extensions.d.ts +34 -0
- package/dist/editor/extensions.js +239 -0
- package/dist/editor/index.d.ts +14 -0
- package/dist/editor/index.js +17 -0
- package/dist/editor/inserter.d.ts +12 -0
- package/dist/editor/inserter.js +88 -0
- package/dist/editor/inspector.d.ts +17 -0
- package/dist/editor/inspector.js +65 -0
- package/dist/editor/items.d.ts +62 -0
- package/dist/editor/items.js +195 -0
- package/dist/editor/labels.d.ts +119 -0
- package/dist/editor/labels.js +130 -0
- package/dist/editor/markdown.d.ts +14 -0
- package/dist/editor/markdown.js +209 -0
- package/dist/editor/menus.d.ts +20 -0
- package/dist/editor/menus.js +236 -0
- package/dist/editor/nodes.d.ts +14 -0
- package/dist/editor/nodes.js +201 -0
- package/dist/editor/outline.d.ts +11 -0
- package/dist/editor/outline.js +52 -0
- package/dist/editor/schema-form.d.ts +64 -0
- package/dist/editor/schema-form.js +290 -0
- package/dist/editor/slash-menu.d.ts +15 -0
- package/dist/editor/slash-menu.js +119 -0
- package/dist/fonts/catalog.d.ts +53 -0
- package/dist/fonts/catalog.js +121 -0
- package/dist/fonts/font-picker.d.ts +70 -0
- package/dist/fonts/font-picker.js +225 -0
- package/dist/fonts/index.d.ts +6 -0
- package/dist/fonts/index.js +7 -0
- package/dist/fonts/loader.d.ts +66 -0
- package/dist/fonts/loader.js +161 -0
- package/dist/fonts/pairing-picker.d.ts +31 -0
- package/dist/fonts/pairing-picker.js +81 -0
- package/dist/fonts/pairings.d.ts +84 -0
- package/dist/fonts/pairings.js +149 -0
- package/dist/fonts/provider.d.ts +34 -0
- package/dist/fonts/provider.js +51 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/form/index.js +1 -0
- package/dist/format/core.d.ts +149 -0
- package/dist/format/core.js +357 -0
- package/dist/format/index.d.ts +4 -0
- package/dist/format/index.js +5 -0
- package/dist/format/use-format.d.ts +1 -0
- package/dist/format/use-format.js +3 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +87 -0
- package/dist/lib/cn.d.ts +3 -0
- package/dist/lib/cn.js +16 -0
- package/dist/lib/color.d.ts +64 -0
- package/dist/lib/color.js +177 -0
- package/dist/lib/compose-refs.d.ts +24 -0
- package/dist/lib/compose-refs.js +45 -0
- package/dist/lib/data-islands.d.ts +194 -0
- package/dist/lib/data-islands.js +368 -0
- package/dist/lib/date.d.ts +129 -0
- package/dist/lib/date.js +386 -0
- package/dist/lib/field-context.d.ts +64 -0
- package/dist/lib/field-context.js +62 -0
- package/dist/lib/floating-arrow.d.ts +18 -0
- package/dist/lib/floating-arrow.js +15 -0
- package/dist/lib/islands.d.ts +38 -0
- package/dist/lib/islands.js +40 -0
- package/dist/lib/labels.d.ts +51 -0
- package/dist/lib/labels.js +56 -0
- package/dist/lib/layer.d.ts +36 -0
- package/dist/lib/layer.js +42 -0
- package/dist/lib/locale.d.ts +85 -0
- package/dist/lib/locale.js +105 -0
- package/dist/lib/menu.d.ts +58 -0
- package/dist/lib/menu.js +99 -0
- package/dist/lib/message-format.d.ts +20 -0
- package/dist/lib/message-format.js +116 -0
- package/dist/lib/nav.d.ts +132 -0
- package/dist/lib/nav.js +178 -0
- package/dist/lib/provider.d.ts +100 -0
- package/dist/lib/provider.js +105 -0
- package/dist/lib/public.d.ts +22 -0
- package/dist/lib/public.js +33 -0
- package/dist/lib/sr-name.d.ts +18 -0
- package/dist/lib/sr-name.js +17 -0
- package/dist/lib/text.d.ts +100 -0
- package/dist/lib/text.js +233 -0
- package/dist/lib/theme-scope.d.ts +58 -0
- package/dist/lib/theme-scope.js +59 -0
- package/dist/lib/use-async-list.d.ts +60 -0
- package/dist/lib/use-async-list.js +119 -0
- package/dist/lib/use-container-width.d.ts +19 -0
- package/dist/lib/use-container-width.js +39 -0
- package/dist/lib/use-controllable-state.d.ts +33 -0
- package/dist/lib/use-controllable-state.js +56 -0
- package/dist/lib/use-edge-fade.d.ts +13 -0
- package/dist/lib/use-edge-fade.js +43 -0
- package/dist/lib/use-formatted-input.d.ts +69 -0
- package/dist/lib/use-formatted-input.js +152 -0
- package/dist/lib/use-hotkeys.d.ts +80 -0
- package/dist/lib/use-hotkeys.js +221 -0
- package/dist/lib/use-hover-intent.d.ts +44 -0
- package/dist/lib/use-hover-intent.js +119 -0
- package/dist/lib/use-media-query.d.ts +21 -0
- package/dist/lib/use-media-query.js +28 -0
- package/dist/lib/use-reduced-motion.d.ts +8 -0
- package/dist/lib/use-reduced-motion.js +13 -0
- package/dist/lib/use-tree.d.ts +153 -0
- package/dist/lib/use-tree.js +534 -0
- package/dist/lib/value-format.d.ts +25 -0
- package/dist/lib/value-format.js +56 -0
- package/dist/lib/variants.d.ts +131 -0
- package/dist/lib/variants.js +109 -0
- package/dist/locale-data/core/date.d.ts +24 -0
- package/dist/locale-data/core/date.js +68 -0
- package/dist/locale-data/core/decimal.d.ts +19 -0
- package/dist/locale-data/core/decimal.js +79 -0
- package/dist/locale-data/core/holidays.d.ts +30 -0
- package/dist/locale-data/core/holidays.js +79 -0
- package/dist/locale-data/core/iban.d.ts +29 -0
- package/dist/locale-data/core/iban.js +74 -0
- package/dist/locale-data/core/index.d.ts +7 -0
- package/dist/locale-data/core/index.js +6 -0
- package/dist/locale-data/core/types.d.ts +173 -0
- package/dist/locale-data/core/types.js +6 -0
- package/dist/locale-data/core/week-info.d.ts +23 -0
- package/dist/locale-data/core/week-info.js +85 -0
- package/dist/locale-data/core/working-days.d.ts +27 -0
- package/dist/locale-data/core/working-days.js +133 -0
- package/dist/locale-data/index.d.ts +2 -0
- package/dist/locale-data/index.js +4 -0
- package/dist/locale-data/tr/address-tr.json +1 -0
- package/dist/locale-data/tr/address.d.ts +23 -0
- package/dist/locale-data/tr/address.js +52 -0
- package/dist/locale-data/tr/holidays.d.ts +31 -0
- package/dist/locale-data/tr/holidays.js +81 -0
- package/dist/locale-data/tr/iban.d.ts +21 -0
- package/dist/locale-data/tr/iban.js +45 -0
- package/dist/locale-data/tr/id.d.ts +36 -0
- package/dist/locale-data/tr/id.js +120 -0
- package/dist/locale-data/tr/index.d.ts +12 -0
- package/dist/locale-data/tr/index.js +33 -0
- package/dist/locale-data/tr/kdv.d.ts +91 -0
- package/dist/locale-data/tr/kdv.js +222 -0
- package/dist/locales/en.d.ts +2102 -0
- package/dist/locales/en.js +2088 -0
- package/dist/locales/tr.d.ts +2086 -0
- package/dist/locales/tr.js +2087 -0
- package/dist/media/focal-point.d.ts +42 -0
- package/dist/media/focal-point.js +96 -0
- package/dist/media/gallery-layout.d.ts +19 -0
- package/dist/media/gallery-layout.js +61 -0
- package/dist/media/gallery.d.ts +64 -0
- package/dist/media/gallery.js +138 -0
- package/dist/media/image-cropper.d.ts +86 -0
- package/dist/media/image-cropper.js +170 -0
- package/dist/media/image-field.d.ts +115 -0
- package/dist/media/image-field.js +212 -0
- package/dist/media/index.d.ts +19 -0
- package/dist/media/index.js +23 -0
- package/dist/media/lightbox.d.ts +82 -0
- package/dist/media/lightbox.js +171 -0
- package/dist/media/link-preview.d.ts +97 -0
- package/dist/media/link-preview.js +177 -0
- package/dist/media/media-library.d.ts +244 -0
- package/dist/media/media-library.js +776 -0
- package/dist/media/media-picker.d.ts +96 -0
- package/dist/media/media-picker.js +209 -0
- package/dist/media/media-provider.d.ts +23 -0
- package/dist/media/media-provider.js +44 -0
- package/dist/media/media-utils.d.ts +39 -0
- package/dist/media/media-utils.js +145 -0
- package/dist/media/memory-adapter.d.ts +22 -0
- package/dist/media/memory-adapter.js +162 -0
- package/dist/media/rest-adapter.d.ts +90 -0
- package/dist/media/rest-adapter.js +208 -0
- package/dist/media/serp.d.ts +62 -0
- package/dist/media/serp.js +108 -0
- package/dist/media/test-fixtures.d.ts +3 -0
- package/dist/media/test-fixtures.js +37 -0
- package/dist/media/types.d.ts +183 -0
- package/dist/media/types.js +3 -0
- package/dist/media/use-pan-zoom.d.ts +51 -0
- package/dist/media/use-pan-zoom.js +156 -0
- package/dist/media/use-upload-queue.d.ts +64 -0
- package/dist/media/use-upload-queue.js +115 -0
- package/dist/media/video-player.d.ts +135 -0
- package/dist/media/video-player.js +319 -0
- package/dist/next/index.d.ts +42 -0
- package/dist/next/index.js +36 -0
- package/dist/render/block-renderer.d.ts +56 -0
- package/dist/render/block-renderer.js +137 -0
- package/dist/render/index.d.ts +6 -0
- package/dist/render/index.js +7 -0
- package/dist/render/prepare.d.ts +61 -0
- package/dist/render/prepare.js +119 -0
- package/dist/scheduler/core/duration.d.ts +83 -0
- package/dist/scheduler/core/duration.js +174 -0
- package/dist/scheduler/core/gantt.d.ts +63 -0
- package/dist/scheduler/core/gantt.js +226 -0
- package/dist/scheduler/core/index.d.ts +6 -0
- package/dist/scheduler/core/index.js +7 -0
- package/dist/scheduler/core/layout.d.ts +97 -0
- package/dist/scheduler/core/layout.js +249 -0
- package/dist/scheduler/core/time-scale.d.ts +89 -0
- package/dist/scheduler/core/time-scale.js +173 -0
- package/dist/scheduler/gantt.d.ts +125 -0
- package/dist/scheduler/gantt.js +532 -0
- package/dist/scheduler/index.d.ts +6 -0
- package/dist/scheduler/index.js +7 -0
- package/dist/scheduler/resource-calendar.d.ts +218 -0
- package/dist/scheduler/resource-calendar.js +661 -0
- package/dist/scheduler/scheduler.d.ts +168 -0
- package/dist/scheduler/scheduler.js +768 -0
- package/dist/scheduler/shared.d.ts +63 -0
- package/dist/scheduler/shared.js +145 -0
- package/dist/scheduler/time-tracker.d.ts +138 -0
- package/dist/scheduler/time-tracker.js +403 -0
- package/dist/sortable/core.d.ts +67 -0
- package/dist/sortable/core.js +167 -0
- package/dist/sortable/index.d.ts +8 -0
- package/dist/sortable/index.js +10 -0
- package/dist/sortable/kanban-core.d.ts +70 -0
- package/dist/sortable/kanban-core.js +67 -0
- package/dist/sortable/kanban.d.ts +147 -0
- package/dist/sortable/kanban.js +472 -0
- package/dist/sortable/sortable-list.d.ts +71 -0
- package/dist/sortable/sortable-list.js +76 -0
- package/dist/sortable/sortable-tree.d.ts +101 -0
- package/dist/sortable/sortable-tree.js +450 -0
- package/dist/sortable/sortable.d.ts +188 -0
- package/dist/sortable/sortable.js +485 -0
- package/dist/sortable/use-pointer-drag.d.ts +75 -0
- package/dist/sortable/use-pointer-drag.js +173 -0
- package/dist/sortable/use-time-scale.d.ts +11 -0
- package/dist/sortable/use-time-scale.js +19 -0
- package/dist/styles/base.css +51 -0
- package/dist/styles/blocks.css +949 -0
- package/dist/styles/calendar.css +642 -0
- package/dist/styles/charts.css +264 -0
- package/dist/styles/data.css +474 -0
- package/dist/styles/editors.css +1022 -0
- package/dist/styles/forms.css +406 -0
- package/dist/styles/media.css +515 -0
- package/dist/styles/navigation.css +293 -0
- package/dist/styles/overlays.css +244 -0
- package/dist/styles.css +742 -0
- package/package.json +156 -4
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { AtSign, Check, CornerDownRight, Eye, Hash, Heart, HelpCircle, Link2, MoreHorizontal, Paperclip, Pencil, RotateCcw, SmilePlus, ThumbsUp, Trash2 } from "lucide-react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { useLabels } from "../lib/labels.js";
|
|
7
|
+
import { useFormat, useLocale } from "../lib/locale.js";
|
|
8
|
+
import { foldText } from "../lib/text.js";
|
|
9
|
+
import { RelativeTime } from "../lib/data-islands.js";
|
|
10
|
+
import { Avatar } from "./avatar.js";
|
|
11
|
+
import { Badge } from "./badge.js";
|
|
12
|
+
import { Button, IconButton } from "./button.js";
|
|
13
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from "./dropdown-menu.js";
|
|
14
|
+
import { Spinner } from "./spinner.js";
|
|
15
|
+
import { AttachmentList } from "./attachment-list.js";
|
|
16
|
+
const MENTION_RE = /([@#])\[([^\]\n]{1,120})\]\((user|team|record):([^)\s]{1,120})\)/g;
|
|
17
|
+
/** Turns a mention into its stored form: `@[Jane Cooper](user:42)`. */
|
|
18
|
+
export function serializeMention(m, trigger = m.kind === "record" ? "#" : "@") {
|
|
19
|
+
return `${trigger}[${m.label.replace(/[[\]]/g, "")}](${m.kind}:${m.id})`;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Reads a stored comment body. `text` is what people see ("@Jane Cooper can you check?");
|
|
23
|
+
* `mentions` carries ids and offsets into `text`. Locale-independent.
|
|
24
|
+
*/
|
|
25
|
+
export function parseMentions(body) {
|
|
26
|
+
const mentions = [];
|
|
27
|
+
let text = "";
|
|
28
|
+
let last = 0;
|
|
29
|
+
for (const m of body.matchAll(MENTION_RE)) {
|
|
30
|
+
text += body.slice(last, m.index);
|
|
31
|
+
const shown = `${m[1]}${m[2]}`;
|
|
32
|
+
mentions.push({ id: m[4], kind: m[3], label: m[2], start: text.length, end: text.length + shown.length, trigger: m[1] });
|
|
33
|
+
text += shown;
|
|
34
|
+
last = m.index + m[0].length;
|
|
35
|
+
}
|
|
36
|
+
text += body.slice(last);
|
|
37
|
+
return { text, mentions };
|
|
38
|
+
}
|
|
39
|
+
/** Re-serializes composer text: every `@Label` of a picked mention becomes its stored token. */
|
|
40
|
+
function serializeComposer(text, picked) {
|
|
41
|
+
const used = [];
|
|
42
|
+
let body = text;
|
|
43
|
+
const sorted = [...picked].sort((a, b) => b.label.length - a.label.length);
|
|
44
|
+
const tokens = [];
|
|
45
|
+
for (const m of sorted) {
|
|
46
|
+
const trigger = m.kind === "record" ? "#" : "@";
|
|
47
|
+
const shown = `${trigger}${m.label}`;
|
|
48
|
+
if (!body.includes(shown))
|
|
49
|
+
continue;
|
|
50
|
+
if (!used.some((u) => u.id === m.id && u.kind === m.kind))
|
|
51
|
+
used.push(m);
|
|
52
|
+
// Placeholder first so a shorter label inside a longer one isn't replaced twice.
|
|
53
|
+
const ph = `\u0000${tokens.length}\u0000`;
|
|
54
|
+
tokens.push(serializeMention(m, trigger));
|
|
55
|
+
body = body.split(shown).join(ph);
|
|
56
|
+
}
|
|
57
|
+
body = body.replace(/\u0000(\d+)\u0000/g, (_, i) => tokens[Number(i)]);
|
|
58
|
+
return { body, mentions: used };
|
|
59
|
+
}
|
|
60
|
+
/** Default reaction set — icons, not emoji, so they follow the theme. */
|
|
61
|
+
export const defaultReactions = [
|
|
62
|
+
{ key: "like", label: "Like", icon: ThumbsUp },
|
|
63
|
+
{ key: "agree", label: "Agree", icon: Check },
|
|
64
|
+
{ key: "love", label: "Love", icon: Heart },
|
|
65
|
+
{ key: "question", label: "Question", icon: HelpCircle },
|
|
66
|
+
{ key: "seen", label: "Seen", icon: Eye },
|
|
67
|
+
];
|
|
68
|
+
export const commentLabels = {
|
|
69
|
+
thread: "Comments",
|
|
70
|
+
empty: "Start the conversation",
|
|
71
|
+
emptyHint: "Mention a teammate with @ to bring them in.",
|
|
72
|
+
placeholder: "Write a comment… Use @ to mention",
|
|
73
|
+
replyPlaceholder: "Write a reply…",
|
|
74
|
+
comment: "Comment",
|
|
75
|
+
reply: "Reply",
|
|
76
|
+
replyTo: "Reply to {name}",
|
|
77
|
+
edit: "Edit",
|
|
78
|
+
save: "Save",
|
|
79
|
+
cancel: "Cancel",
|
|
80
|
+
delete: "Delete",
|
|
81
|
+
copyLink: "Copy link",
|
|
82
|
+
linkCopied: "Link copied",
|
|
83
|
+
resolve: "Resolve",
|
|
84
|
+
reopen: "Reopen",
|
|
85
|
+
resolved: "Resolved",
|
|
86
|
+
resolvedBy: "Resolved by {name}",
|
|
87
|
+
show: "Show",
|
|
88
|
+
hide: "Hide",
|
|
89
|
+
replies: "{count, plural, one {# reply} other {# replies}}",
|
|
90
|
+
edited: "edited",
|
|
91
|
+
editedAt: "Edited {time}",
|
|
92
|
+
deleted: "This comment was deleted",
|
|
93
|
+
sending: "Sending…",
|
|
94
|
+
failed: "Not sent",
|
|
95
|
+
retry: "Retry",
|
|
96
|
+
discard: "Discard",
|
|
97
|
+
more: "More actions for {name}'s comment",
|
|
98
|
+
attach: "Attach files",
|
|
99
|
+
mention: "Mention someone",
|
|
100
|
+
submitHint: "{key}+Enter to send",
|
|
101
|
+
submitError: "Couldn't post your comment. Try again.",
|
|
102
|
+
suggestions: "{count, plural, =0 {No matches} one {# suggestion} other {# suggestions}}",
|
|
103
|
+
searching: "Searching…",
|
|
104
|
+
noMatch: "No one matches “{query}”",
|
|
105
|
+
react: "Add reaction",
|
|
106
|
+
reaction: "{label}: {count}",
|
|
107
|
+
you: "You",
|
|
108
|
+
commentBy: "Comment by {name}",
|
|
109
|
+
};
|
|
110
|
+
/** Inline mention token inside a comment body. */
|
|
111
|
+
export function MentionChip({ mention, self, className, ...props }) {
|
|
112
|
+
const trigger = mention.trigger ?? (mention.kind === "record" ? "#" : "@");
|
|
113
|
+
return (_jsxs("span", { "data-slot": "mention", "data-kind": mention.kind, "data-self": self ? "" : undefined, className: cn("inline rounded-[5px] px-1 py-px font-medium [box-decoration-break:clone]", mention.kind === "record" ? "bg-selected text-fg" : "bg-accent-soft text-accent-ink", self && "ring-1 ring-inset ring-[color-mix(in_srgb,var(--accent-ink)_40%,transparent)]", className), ...props, children: [trigger, mention.label] }));
|
|
114
|
+
}
|
|
115
|
+
/** A comment's text: line breaks kept, mentions rendered as chips, mixed directions handled (`dir="auto"`). */
|
|
116
|
+
export function CommentBody({ body, currentUserId, renderMention, className, ...props }) {
|
|
117
|
+
const { text, mentions } = React.useMemo(() => parseMentions(body), [body]);
|
|
118
|
+
const parts = [];
|
|
119
|
+
let pos = 0;
|
|
120
|
+
mentions.forEach((m, i) => {
|
|
121
|
+
if (m.start > pos)
|
|
122
|
+
parts.push(text.slice(pos, m.start));
|
|
123
|
+
parts.push(_jsx(React.Fragment, { children: renderMention ? renderMention(m) : _jsx(MentionChip, { mention: m, self: m.kind === "user" && m.id === currentUserId }) }, `m${i}`));
|
|
124
|
+
pos = m.end;
|
|
125
|
+
});
|
|
126
|
+
if (pos < text.length)
|
|
127
|
+
parts.push(text.slice(pos));
|
|
128
|
+
return (_jsx("div", { "data-slot": "comment-body", dir: "auto", className: cn("whitespace-pre-wrap break-words text-[13.5px] leading-relaxed text-fg", className), ...props, children: parts }));
|
|
129
|
+
}
|
|
130
|
+
function findTrigger(value, caret, triggers) {
|
|
131
|
+
const before = value.slice(0, caret);
|
|
132
|
+
for (let i = before.length - 1; i >= 0 && before.length - i <= 32; i--) {
|
|
133
|
+
const ch = before[i];
|
|
134
|
+
if (ch === "\n")
|
|
135
|
+
return null;
|
|
136
|
+
if (triggers.includes(ch) && (i === 0 || /\s|[(\[{"'“]/.test(before[i - 1]))) {
|
|
137
|
+
const query = before.slice(i + 1);
|
|
138
|
+
if (/^\s/.test(query) || /\s$/.test(query))
|
|
139
|
+
return null;
|
|
140
|
+
return { trigger: ch, start: i, query };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The comment box: a plain textarea with an `@` / `#` mention picker (combobox pattern:
|
|
147
|
+
* ↑/↓ move, Enter or Tab insert, Esc close), optional attachments, and ⌘/Ctrl+Enter to send.
|
|
148
|
+
* Picked mentions are stored as `@[Name](user:id)` in the submitted body.
|
|
149
|
+
*/
|
|
150
|
+
export const CommentComposer = React.forwardRef(function CommentComposer({ onSubmit, onCancel, defaultValue, parentId, mentionSources, allowAttachments, placeholder, submitLabel, author, autoFocus, variant = "inline", compact, labels, className, ...props }, ref) {
|
|
151
|
+
const t = useLabels("comments", commentLabels, labels);
|
|
152
|
+
const { locale } = useLocale();
|
|
153
|
+
const initial = React.useMemo(() => (defaultValue ? parseMentions(defaultValue) : null), [defaultValue]);
|
|
154
|
+
const [value, setValue] = React.useState(initial?.text ?? "");
|
|
155
|
+
const [picked, setPicked] = React.useState(() => initial?.mentions.map((m) => ({ id: m.id, kind: m.kind, label: m.label })) ?? []);
|
|
156
|
+
const [files, setFiles] = React.useState([]);
|
|
157
|
+
const [busy, setBusy] = React.useState(false);
|
|
158
|
+
const [error, setError] = React.useState(null);
|
|
159
|
+
const [picker, setPicker] = React.useState(null);
|
|
160
|
+
const [results, setResults] = React.useState([]);
|
|
161
|
+
const [searching, setSearching] = React.useState(false);
|
|
162
|
+
const [active, setActive] = React.useState(0);
|
|
163
|
+
const areaRef = React.useRef(null);
|
|
164
|
+
const fileRef = React.useRef(null);
|
|
165
|
+
const searchSeq = React.useRef(0);
|
|
166
|
+
const listId = React.useId();
|
|
167
|
+
const hintId = React.useId();
|
|
168
|
+
const triggers = React.useMemo(() => (mentionSources ?? []).map((s) => s.trigger ?? "@"), [mentionSources]);
|
|
169
|
+
// Platform is read after mount so the server and first client render agree.
|
|
170
|
+
const [isMac, setIsMac] = React.useState(false);
|
|
171
|
+
React.useEffect(() => setIsMac(/Mac|iPhone|iPad/.test(navigator.platform)), []);
|
|
172
|
+
React.useImperativeHandle(ref, () => areaRef.current, []);
|
|
173
|
+
React.useEffect(() => {
|
|
174
|
+
if (autoFocus)
|
|
175
|
+
areaRef.current?.focus();
|
|
176
|
+
}, [autoFocus]);
|
|
177
|
+
// Grow with content (up to ~10 lines) and place the caret after a programmatic insert —
|
|
178
|
+
// synchronously, so keys typed right after an insert land in the right place.
|
|
179
|
+
const pendingCaret = React.useRef(null);
|
|
180
|
+
React.useLayoutEffect(() => {
|
|
181
|
+
const el = areaRef.current;
|
|
182
|
+
if (!el)
|
|
183
|
+
return;
|
|
184
|
+
el.style.height = "auto";
|
|
185
|
+
el.style.height = `${Math.min(el.scrollHeight, 240)}px`;
|
|
186
|
+
if (pendingCaret.current !== null) {
|
|
187
|
+
const pos = pendingCaret.current;
|
|
188
|
+
pendingCaret.current = null;
|
|
189
|
+
el.focus();
|
|
190
|
+
el.setSelectionRange(pos, pos);
|
|
191
|
+
}
|
|
192
|
+
}, [value]);
|
|
193
|
+
// Run the mention search for the current query (latest request wins).
|
|
194
|
+
React.useEffect(() => {
|
|
195
|
+
if (!picker)
|
|
196
|
+
return;
|
|
197
|
+
const source = mentionSources?.find((s) => (s.trigger ?? "@") === picker.trigger);
|
|
198
|
+
if (!source)
|
|
199
|
+
return;
|
|
200
|
+
const seq = ++searchSeq.current;
|
|
201
|
+
setSearching(true);
|
|
202
|
+
Promise.resolve(source.search(picker.query))
|
|
203
|
+
.then((items) => {
|
|
204
|
+
if (seq !== searchSeq.current)
|
|
205
|
+
return;
|
|
206
|
+
const q = foldText(picker.query, locale);
|
|
207
|
+
// Locale-aware fallback ranking: prefix matches first.
|
|
208
|
+
const ranked = [...items].sort((a, b) => Number(!foldText(a.label, locale).startsWith(q)) - Number(!foldText(b.label, locale).startsWith(q)));
|
|
209
|
+
setResults(ranked.slice(0, 8));
|
|
210
|
+
setActive(0);
|
|
211
|
+
})
|
|
212
|
+
.catch(() => seq === searchSeq.current && setResults([]))
|
|
213
|
+
.finally(() => seq === searchSeq.current && setSearching(false));
|
|
214
|
+
}, [picker?.trigger, picker?.query, mentionSources, locale]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
215
|
+
const updatePicker = (el) => {
|
|
216
|
+
if (!triggers.length)
|
|
217
|
+
return;
|
|
218
|
+
const p = findTrigger(el.value, el.selectionStart ?? el.value.length, triggers);
|
|
219
|
+
setPicker(p);
|
|
220
|
+
if (!p)
|
|
221
|
+
setResults([]);
|
|
222
|
+
};
|
|
223
|
+
const insert = (item) => {
|
|
224
|
+
if (!picker)
|
|
225
|
+
return;
|
|
226
|
+
const el = areaRef.current;
|
|
227
|
+
const trigger = item.kind === "record" ? "#" : picker.trigger;
|
|
228
|
+
const caret = el?.selectionStart ?? picker.start + 1 + picker.query.length;
|
|
229
|
+
const token = `${trigger}${item.label} `;
|
|
230
|
+
const next = value.slice(0, picker.start) + token + value.slice(caret);
|
|
231
|
+
setValue(next);
|
|
232
|
+
setPicked((p) => (p.some((x) => x.id === item.id && x.kind === item.kind) ? p : [...p, item]));
|
|
233
|
+
setPicker(null);
|
|
234
|
+
setResults([]);
|
|
235
|
+
pendingCaret.current = picker.start + token.length;
|
|
236
|
+
};
|
|
237
|
+
const canSubmit = (value.trim().length > 0 || files.length > 0) && !busy;
|
|
238
|
+
const submit = async () => {
|
|
239
|
+
if (!canSubmit)
|
|
240
|
+
return;
|
|
241
|
+
const { body, mentions } = serializeComposer(value.trim(), picked);
|
|
242
|
+
setBusy(true);
|
|
243
|
+
setError(null);
|
|
244
|
+
try {
|
|
245
|
+
await onSubmit({ body, parentId, attachments: files, mentions });
|
|
246
|
+
setValue("");
|
|
247
|
+
setPicked([]);
|
|
248
|
+
setFiles([]);
|
|
249
|
+
}
|
|
250
|
+
catch {
|
|
251
|
+
setError(t("submitError"));
|
|
252
|
+
}
|
|
253
|
+
finally {
|
|
254
|
+
setBusy(false);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
const open = Boolean(picker) && (results.length > 0 || searching || picker.query.length > 0);
|
|
258
|
+
const onKeyDown = (e) => {
|
|
259
|
+
if (open && results.length > 0) {
|
|
260
|
+
if (e.key === "ArrowDown") {
|
|
261
|
+
e.preventDefault();
|
|
262
|
+
setActive((a) => (a + 1) % results.length);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
if (e.key === "ArrowUp") {
|
|
266
|
+
e.preventDefault();
|
|
267
|
+
setActive((a) => (a - 1 + results.length) % results.length);
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if ((e.key === "Enter" && !e.metaKey && !e.ctrlKey) || e.key === "Tab") {
|
|
271
|
+
e.preventDefault();
|
|
272
|
+
insert(results[active]);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (e.key === "Escape") {
|
|
277
|
+
if (picker) {
|
|
278
|
+
e.preventDefault();
|
|
279
|
+
e.stopPropagation();
|
|
280
|
+
setPicker(null);
|
|
281
|
+
setResults([]);
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (onCancel) {
|
|
285
|
+
e.preventDefault();
|
|
286
|
+
onCancel();
|
|
287
|
+
}
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
|
|
291
|
+
e.preventDefault();
|
|
292
|
+
void submit();
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
const fileItems = files.map((f, i) => ({ id: `${i}-${f.name}`, name: f.name, size: f.size, mime: f.type }));
|
|
296
|
+
return (_jsxs("form", { "data-slot": "comment-composer", "data-variant": variant, className: cn("flex gap-2.5", variant === "sticky-bottom" && "sticky bottom-0 z-(--z-sticky) -mx-[var(--composer-bleed,0px)] border-t border-line bg-[color-mix(in_srgb,var(--surface-solid)_94%,transparent)] px-[var(--composer-bleed,0px)] py-3", className), onSubmit: (e) => {
|
|
297
|
+
e.preventDefault();
|
|
298
|
+
void submit();
|
|
299
|
+
}, ...props, children: [author ? _jsx(Avatar, { name: author.name, src: author.avatar, size: compact ? "sm" : "md", className: "mt-1" }) : null, _jsxs("div", { className: "relative min-w-0 flex-1", children: [_jsxs("div", { className: cn("rounded-ui border border-field-border bg-field transition-[border-color,box-shadow]", "focus-within:border-field-border-hover focus-within:shadow-[0_0_0_3px_color-mix(in_srgb,var(--ring)_18%,transparent)]", error && "border-[color-mix(in_srgb,var(--danger)_55%,transparent)]"), children: [_jsx("textarea", { ref: areaRef, dir: "auto", rows: compact ? 1 : 2, value: value, placeholder: placeholder ?? t(parentId ? "replyPlaceholder" : "placeholder"), "aria-label": placeholder ?? t(parentId ? "replyPlaceholder" : "placeholder"), "aria-describedby": hintId, "aria-autocomplete": triggers.length ? "list" : undefined, "aria-controls": open ? listId : undefined, "aria-activedescendant": open && results[active] ? `${listId}-${active}` : undefined, "aria-invalid": error ? true : undefined, disabled: busy, onChange: (e) => {
|
|
300
|
+
setValue(e.target.value);
|
|
301
|
+
updatePicker(e.target);
|
|
302
|
+
}, onSelect: (e) => updatePicker(e.currentTarget), onKeyDown: onKeyDown, onBlur: () => setTimeout(() => setPicker(null), 120), className: cn("block w-full resize-none bg-transparent px-3 pt-2.5 text-[13.5px] leading-relaxed text-fg outline-none placeholder:text-fg-subtle disabled:opacity-60", compact ? "min-h-9" : "min-h-16") }), files.length ? (_jsx(AttachmentList, { layout: "chips", items: fileItems, className: "px-2 pb-1", onRemove: (f) => setFiles((all) => all.filter((_, i) => `${i}-${all[i].name}` !== f.id)) })) : null, _jsxs("div", { className: "flex items-center gap-1 px-1.5 pb-1.5", children: [triggers.includes("@") ? (_jsx(IconButton, { label: t("mention"), tooltip: false, size: "xs", tabIndex: -1, onMouseDown: (e) => e.preventDefault(), onClick: () => {
|
|
303
|
+
const el = areaRef.current;
|
|
304
|
+
const caret = el.selectionStart ?? value.length;
|
|
305
|
+
const pad = caret > 0 && !/\s/.test(value[caret - 1]) ? " " : "";
|
|
306
|
+
const next = value.slice(0, caret) + pad + "@" + value.slice(caret);
|
|
307
|
+
setValue(next);
|
|
308
|
+
const pos = caret + pad.length + 1;
|
|
309
|
+
setPicker({ trigger: "@", start: pos - 1, query: "" });
|
|
310
|
+
pendingCaret.current = pos;
|
|
311
|
+
}, children: _jsx(AtSign, {}) })) : null, allowAttachments ? (_jsxs(_Fragment, { children: [_jsx("input", { ref: fileRef, type: "file", multiple: true, hidden: true, tabIndex: -1, "aria-hidden": true, onChange: (e) => {
|
|
312
|
+
const list = Array.from(e.currentTarget.files ?? []);
|
|
313
|
+
setFiles((f) => [...f, ...list]);
|
|
314
|
+
e.currentTarget.value = "";
|
|
315
|
+
} }), _jsx(IconButton, { label: t("attach"), tooltip: false, size: "xs", onClick: () => fileRef.current?.click(), children: _jsx(Paperclip, {}) })] })) : null, _jsx("span", { id: hintId, className: "ms-1 hidden truncate text-[11px] text-fg-subtle sm:inline", children: t("submitHint", { key: isMac ? "⌘" : "Ctrl" }) }), _jsxs("span", { className: "ms-auto flex items-center gap-1.5", children: [onCancel ? (_jsx(Button, { size: "xs", variant: "ghost", onClick: onCancel, children: t("cancel") })) : null, _jsx(Button, { size: "xs", variant: "primary", type: "submit", disabled: !canSubmit, loading: busy, children: submitLabel ?? t(parentId ? "reply" : "comment") })] })] })] }), error ? (_jsx("p", { role: "alert", className: "mt-1.5 text-xs text-danger", children: error })) : null, open ? (_jsxs("div", { "data-slot": "mention-picker", className: "absolute inset-x-0 top-full z-(--z-popover) mt-1 max-w-80 overflow-hidden rounded-ui border border-popover-border bg-popover-nested p-1 shadow-(--popover-shadow)", children: [_jsx("ul", { id: listId, role: "listbox", "aria-label": t("suggestions", { count: results.length }), children: results.map((item, i) => {
|
|
316
|
+
const Icon = item.kind === "record" ? Hash : null;
|
|
317
|
+
return (_jsxs("li", { id: `${listId}-${i}`, role: "option", "aria-selected": i === active, onMouseDown: (e) => e.preventDefault(), onMouseEnter: () => setActive(i), onClick: () => insert(item), className: cn("flex cursor-pointer items-center gap-2.5 rounded-ui-sm px-2 py-1.5 text-[13px]", i === active && "bg-hover"), children: [Icon ? (_jsx("span", { "aria-hidden": true, className: "inline-flex size-6 items-center justify-center rounded-ui-sm bg-selected text-fg-muted [&_svg]:size-3.5", children: _jsx(Icon, {}) })) : (_jsx(Avatar, { name: item.label, src: item.avatar, size: "sm", shape: item.kind === "team" ? "square" : "circle", "aria-hidden": true })), _jsxs("span", { className: "grid min-w-0", children: [_jsx("span", { className: "truncate font-medium text-fg", children: item.label }), item.description ? _jsx("span", { className: "truncate text-[11.5px] text-fg-muted", children: item.description }) : null] })] }, `${item.kind}:${item.id}`));
|
|
318
|
+
}) }), results.length === 0 ? (_jsx("p", { className: "flex items-center gap-2 px-2 py-1.5 text-[13px] text-fg-muted", children: searching ? (_jsxs(_Fragment, { children: [_jsx(Spinner, { size: "xs" }), " ", t("searching")] })) : (t("noMatch", { query: picker.query })) })) : null] })) : null, _jsx("span", { className: "sr-only", "aria-live": "polite", children: open && !searching ? t("suggestions", { count: results.length }) : "" })] })] }));
|
|
319
|
+
});
|
|
320
|
+
/** One comment: avatar, author and time, body with mention chips, attachments, reactions and actions. An `<article>` labelled by its header. */
|
|
321
|
+
export const Comment = React.forwardRef(function Comment({ comment: c, currentUserId, isReply, onReply, onEdit, onDelete, onResolve, onRetry, onDiscard, onReact, getLink, reactions = defaultReactions, mentionSources, renderMention, onPreviewAttachment, readOnly, compact, now, labels, className, children, ...props }, ref) {
|
|
322
|
+
const t = useLabels("comments", commentLabels, labels);
|
|
323
|
+
const f = useFormat();
|
|
324
|
+
const headId = React.useId();
|
|
325
|
+
const [editing, setEditing] = React.useState(false);
|
|
326
|
+
const [copied, setCopied] = React.useState(false);
|
|
327
|
+
const own = c.author.id === currentUserId;
|
|
328
|
+
const canEdit = own && !readOnly && onEdit && !c.status && !c.deleted;
|
|
329
|
+
const canDelete = own && !readOnly && onDelete && !c.status && !c.deleted;
|
|
330
|
+
const canResolve = !isReply && !readOnly && onResolve && !c.status && !c.deleted;
|
|
331
|
+
if (c.deleted) {
|
|
332
|
+
return (_jsxs("article", { ref: ref, "data-slot": "comment", "data-deleted": "", "aria-label": t("deleted"), tabIndex: -1, className: cn("flex flex-col gap-3 outline-none", className), ...props, children: [_jsx("p", { className: "flex items-center gap-2 rounded-ui-sm border border-dashed border-line px-3 py-2 text-[13px] italic text-fg-subtle", children: t("deleted") }), children] }));
|
|
333
|
+
}
|
|
334
|
+
const copyLink = async () => {
|
|
335
|
+
if (!getLink)
|
|
336
|
+
return;
|
|
337
|
+
try {
|
|
338
|
+
await navigator.clipboard.writeText(getLink(c));
|
|
339
|
+
setCopied(true);
|
|
340
|
+
setTimeout(() => setCopied(false), 1600);
|
|
341
|
+
}
|
|
342
|
+
catch {
|
|
343
|
+
/* clipboard blocked */
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
const menu = canEdit || canDelete || getLink;
|
|
347
|
+
return (_jsxs("article", { ref: ref, "data-slot": "comment", "data-status": c.status, "data-own": own ? "" : undefined, "aria-labelledby": headId, tabIndex: -1, className: cn("group/comment relative flex gap-2.5 outline-none focus-visible:rounded-ui-sm focus-visible:ring-2 focus-visible:ring-(--ring) focus-visible:ring-offset-4 focus-visible:ring-offset-(--surface-solid)", className), ...props, children: [_jsx(Avatar, { name: c.author.name, src: c.author.avatar, size: isReply || compact ? "sm" : "md", className: cn(isReply || compact ? "mt-0.5" : "mt-px") }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsxs("header", { className: "flex min-h-6 flex-wrap items-baseline gap-x-2 gap-y-0.5", children: [_jsxs("h4", { id: headId, className: "contents", children: [_jsx("span", { className: "text-[13.5px] font-semibold text-fg", children: c.author.name }), own ? _jsxs("span", { className: "sr-only", children: [" (", t("you"), ")"] }) : null, _jsx("span", { className: "sr-only", children: ", " }), _jsx(RelativeTime, { value: c.createdAt, now: now, className: "text-xs text-fg-subtle" })] }), c.editedAt ? (_jsxs("span", { className: "text-xs text-fg-subtle", title: t("editedAt", { time: f.dateTime(c.editedAt) }), children: ["\u00B7 ", t("edited")] })) : null, c.status === "sending" ? (_jsxs("span", { className: "inline-flex items-center gap-1 text-xs text-fg-subtle", children: [_jsx(Spinner, { size: "xs" }), " ", t("sending")] })) : null, c.resolved && !isReply ? (_jsxs(Badge, { tone: "success", size: "sm", children: [_jsx(Check, { "aria-hidden": true }), " ", c.resolvedBy ? t("resolvedBy", { name: c.resolvedBy }) : t("resolved")] })) : null, !readOnly && !editing && (menu || canResolve) && !c.status ? (_jsxs("span", { className: "ms-auto flex items-center gap-0.5 self-center opacity-100 transition-opacity sm:opacity-0 sm:group-hover/comment:opacity-100 sm:group-focus-within/comment:opacity-100 [@media(hover:none)]:opacity-100", children: [canResolve ? (_jsxs(Button, { size: "xs", variant: "ghost", onClick: () => onResolve(c.id, !c.resolved), className: "text-fg-muted", children: [c.resolved ? _jsx(RotateCcw, { "aria-hidden": true }) : _jsx(Check, { "aria-hidden": true }), c.resolved ? t("reopen") : t("resolve")] })) : null, menu ? (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(IconButton, { label: t("more", { name: c.author.name }), size: "xs", tooltip: false, children: _jsx(MoreHorizontal, {}) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [canEdit ? (_jsx(DropdownMenuItem, { icon: _jsx(Pencil, {}), onSelect: () => setEditing(true), children: t("edit") })) : null, getLink ? (_jsx(DropdownMenuItem, { icon: _jsx(Link2, {}), onSelect: () => void copyLink(), children: t("copyLink") })) : null, canDelete ? (_jsxs(_Fragment, { children: [canEdit || getLink ? _jsx(DropdownMenuSeparator, {}) : null, _jsx(DropdownMenuItem, { icon: _jsx(Trash2, {}), tone: "danger", onSelect: () => void onDelete(c.id), children: t("delete") })] })) : null] })] })) : null] })) : null] }), editing ? (_jsx(CommentComposer, { className: "mt-1.5", defaultValue: c.body, mentionSources: mentionSources, autoFocus: true, compact: true, submitLabel: t("save"), labels: labels, onCancel: () => setEditing(false), onSubmit: async ({ body }) => {
|
|
348
|
+
await onEdit(c.id, body);
|
|
349
|
+
setEditing(false);
|
|
350
|
+
} })) : (_jsx(CommentBody, { body: c.body, currentUserId: currentUserId, renderMention: renderMention, className: cn("mt-0.5", c.status === "sending" && "text-fg-muted") })), c.attachments?.length ? _jsx(AttachmentList, { layout: "chips", readOnly: true, items: c.attachments, onPreview: onPreviewAttachment, className: "mt-2" }) : null, c.status === "failed" ? (_jsxs("p", { role: "alert", className: "mt-1.5 flex items-center gap-2 text-xs text-danger", children: [t("failed"), onRetry ? (_jsx(Button, { size: "xs", variant: "link", onClick: () => onRetry(c), className: "text-xs", children: t("retry") })) : null, onDiscard ? (_jsx(Button, { size: "xs", variant: "link", onClick: () => onDiscard(c), className: "text-xs text-fg-muted!", children: t("discard") })) : null] })) : null, !editing && !c.status && (onReply || onReact || c.reactions?.length) ? (_jsxs("div", { className: "mt-1.5 flex flex-wrap items-center gap-1", children: [(c.reactions ?? [])
|
|
351
|
+
.filter((r) => r.count > 0)
|
|
352
|
+
.map((r) => {
|
|
353
|
+
const opt = reactions.find((o) => o.key === r.key);
|
|
354
|
+
if (!opt)
|
|
355
|
+
return null;
|
|
356
|
+
const Icon = opt.icon;
|
|
357
|
+
return (_jsxs("button", { type: "button", "aria-pressed": Boolean(r.reacted), "aria-label": t("reaction", { label: opt.label, count: r.count }), title: r.users?.join(", "), disabled: readOnly || !onReact, onClick: () => onReact?.(c.id, r.key, !r.reacted), className: cn("inline-flex h-6 cursor-pointer items-center gap-1 rounded-full border px-2 text-[11.5px] tabular transition-colors focus-ring disabled:cursor-default [&_svg]:size-3", r.reacted ? "border-[color-mix(in_srgb,var(--accent-ink)_35%,transparent)] bg-accent-soft text-accent-ink" : "border-line text-fg-muted hover:bg-hover"), children: [_jsx(Icon, { "aria-hidden": true, strokeWidth: 2.2 }), r.count] }, r.key));
|
|
358
|
+
}), onReact && !readOnly ? _jsx(ReactionPicker, { reactions: reactions, current: c.reactions, onPick: (key, on) => onReact(c.id, key, on), t: t }) : null, onReply && !readOnly ? (_jsxs(Button, { size: "xs", variant: "ghost", onClick: onReply, className: "text-fg-muted", "aria-label": t("replyTo", { name: c.author.name }), children: [_jsx(CornerDownRight, { "aria-hidden": true }), t("reply")] })) : null] })) : null, _jsx("span", { className: "sr-only", "aria-live": "polite", children: copied ? t("linkCopied") : "" }), children] })] }));
|
|
359
|
+
});
|
|
360
|
+
function ReactionPicker({ reactions, current, onPick, t }) {
|
|
361
|
+
return (_jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(IconButton, { label: t("react"), size: "xs", tooltip: false, className: "size-6 rounded-full text-fg-subtle", children: _jsx(SmilePlus, {}) }) }), _jsx(DropdownMenuContent, { align: "start", className: "flex min-w-0 gap-0.5 p-1", children: reactions.map((r) => {
|
|
362
|
+
const on = Boolean(current?.find((c) => c.key === r.key)?.reacted);
|
|
363
|
+
const Icon = r.icon;
|
|
364
|
+
return (_jsx(DropdownMenuItem, { "aria-label": r.label, title: r.label, onSelect: () => onPick(r.key, !on), className: cn("size-8 justify-center p-0 [&_svg]:size-4", on && "bg-accent-soft text-accent-ink"), children: _jsx(Icon, { "aria-hidden": true }) }, r.key));
|
|
365
|
+
}) })] }));
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Threaded discussion on a record: editorial notes on a post, CRM notes on a deal, feedback on
|
|
369
|
+
* a candidate. One reply level, @mentions with a picker, attachments, reactions, edit / delete,
|
|
370
|
+
* resolve & collapse, and optimistic sending / failed states. ARIA feed: PageUp / PageDown
|
|
371
|
+
* move between comments.
|
|
372
|
+
*
|
|
373
|
+
* ```tsx
|
|
374
|
+
* <CommentThread
|
|
375
|
+
* comments={comments}
|
|
376
|
+
* currentUserId="u1"
|
|
377
|
+
* mentionSources={[{ search: searchPeople }]}
|
|
378
|
+
* onSubmit={({ body, parentId }) => api.comment(dealId, { body, parentId })}
|
|
379
|
+
* onResolve={(id, resolved) => api.resolve(id, resolved)}
|
|
380
|
+
* />
|
|
381
|
+
* ```
|
|
382
|
+
*/
|
|
383
|
+
export const CommentThread = React.forwardRef(function CommentThread({ comments, currentUserId, currentUser, onSubmit, onEdit, onDelete, onResolve, onRetry, onDiscard, onReact, reactions, getLink, mentionSources, renderMention, onPreviewAttachment, allowAttachments, order = "oldest-first", layout = "thread", composer = "inline", readOnly, now, labels, className, ...props }, ref) {
|
|
384
|
+
const t = useLabels("comments", commentLabels, labels);
|
|
385
|
+
const compact = layout === "compact";
|
|
386
|
+
const [replyTo, setReplyTo] = React.useState(null);
|
|
387
|
+
const [shown, setShown] = React.useState(() => new Set());
|
|
388
|
+
const replyButtons = React.useRef(new Map());
|
|
389
|
+
const feedRef = React.useRef(null);
|
|
390
|
+
const { roots, replies } = React.useMemo(() => {
|
|
391
|
+
const byTime = (a, b) => a.createdAt.localeCompare(b.createdAt);
|
|
392
|
+
const replies = new Map();
|
|
393
|
+
const roots = [];
|
|
394
|
+
for (const c of comments) {
|
|
395
|
+
if (c.parentId)
|
|
396
|
+
replies.set(c.parentId, [...(replies.get(c.parentId) ?? []), c]);
|
|
397
|
+
else
|
|
398
|
+
roots.push(c);
|
|
399
|
+
}
|
|
400
|
+
replies.forEach((list) => list.sort(byTime));
|
|
401
|
+
roots.sort(byTime);
|
|
402
|
+
if (order === "newest-first")
|
|
403
|
+
roots.reverse();
|
|
404
|
+
// Deleted with no replies → hidden.
|
|
405
|
+
return { roots: roots.filter((r) => !r.deleted || (replies.get(r.id)?.length ?? 0) > 0), replies };
|
|
406
|
+
}, [comments, order]);
|
|
407
|
+
const canPost = Boolean(onSubmit) && !readOnly;
|
|
408
|
+
const onFeedKey = (e) => {
|
|
409
|
+
if (e.key !== "PageDown" && e.key !== "PageUp")
|
|
410
|
+
return;
|
|
411
|
+
const articles = Array.from(feedRef.current?.querySelectorAll(":scope > [data-slot=comment-group] > [data-slot=comment]") ?? []);
|
|
412
|
+
if (!articles.length)
|
|
413
|
+
return;
|
|
414
|
+
const current = articles.findIndex((a) => a.contains(document.activeElement));
|
|
415
|
+
const next = e.key === "PageDown" ? Math.min(articles.length - 1, current + 1) : Math.max(0, current - 1);
|
|
416
|
+
e.preventDefault();
|
|
417
|
+
articles[next]?.focus();
|
|
418
|
+
};
|
|
419
|
+
const shared = { currentUserId, onEdit, onDelete, onRetry, onDiscard, onReact, reactions, getLink, mentionSources, renderMention, onPreviewAttachment, readOnly, compact, now, labels };
|
|
420
|
+
const newComposer = canPost ? (_jsx(CommentComposer, { onSubmit: onSubmit, mentionSources: mentionSources, allowAttachments: allowAttachments, author: currentUser, compact: compact, variant: composer === "sticky-bottom" ? "sticky-bottom" : "inline", labels: labels })) : null;
|
|
421
|
+
return (_jsxs("div", { ref: ref, "data-slot": "comment-thread", "data-layout": layout, className: cn("flex flex-col", compact ? "gap-4" : "gap-5", className), ...props, children: [composer === "top" ? newComposer : null, roots.length === 0 ? (_jsxs("div", { "data-slot": "comment-empty", className: "flex flex-col items-start gap-1 border-s-2 border-line ps-3", children: [_jsx("p", { className: "text-sm font-medium text-fg", children: t("empty") }), canPost && mentionSources?.length ? _jsx("p", { className: "text-[13px] text-fg-muted", children: t("emptyHint") }) : null] })) : (_jsx("div", { ref: feedRef, role: "feed", "aria-label": t("thread"), "aria-busy": comments.some((c) => c.status === "sending") || undefined, onKeyDown: onFeedKey, className: cn("flex flex-col", compact ? "gap-4" : "gap-6"), children: roots.map((root, i) => {
|
|
422
|
+
const kids = replies.get(root.id) ?? [];
|
|
423
|
+
const collapsed = root.resolved && !shown.has(root.id);
|
|
424
|
+
return (_jsx("div", { "data-slot": "comment-group", "data-resolved": root.resolved ? "" : undefined, className: "contents", children: _jsxs(Comment, { ...shared, comment: root, "aria-posinset": i + 1, "aria-setsize": roots.length, onResolve: onResolve, className: cn(root.resolved && "[&_[data-slot=comment-body]]:text-fg-muted"), onReply: canPost && !root.resolved
|
|
425
|
+
? () => {
|
|
426
|
+
setReplyTo(root.id);
|
|
427
|
+
}
|
|
428
|
+
: undefined, ref: (el) => {
|
|
429
|
+
if (el)
|
|
430
|
+
replyButtons.current.set(root.id, el);
|
|
431
|
+
}, children: [root.resolved && kids.length > 0 ? (_jsxs("button", { type: "button", "aria-expanded": !collapsed, onClick: () => setShown((s) => {
|
|
432
|
+
const n = new Set(s);
|
|
433
|
+
if (n.has(root.id))
|
|
434
|
+
n.delete(root.id);
|
|
435
|
+
else
|
|
436
|
+
n.add(root.id);
|
|
437
|
+
return n;
|
|
438
|
+
}), className: "mt-2 inline-flex cursor-pointer items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-ring", children: [collapsed ? t("show") : t("hide"), " \u00B7 ", t("replies", { count: kids.length })] })) : null, !collapsed && (kids.length > 0 || replyTo === root.id) ? (_jsxs("div", { "data-slot": "comment-replies", className: cn("mt-3 flex flex-col gap-3.5 border-s border-line", compact ? "ps-3" : "ps-4"), children: [kids
|
|
439
|
+
.filter((k) => !k.deleted)
|
|
440
|
+
.map((reply) => (_jsx(Comment, { ...shared, comment: reply, isReply: true, onReply: canPost && !root.resolved ? () => setReplyTo(root.id) : undefined }, reply.id))), replyTo === root.id && canPost ? (_jsx(CommentComposer, { parentId: root.id, mentionSources: mentionSources, allowAttachments: allowAttachments, compact: true, autoFocus: true, labels: labels, onCancel: () => {
|
|
441
|
+
setReplyTo(null);
|
|
442
|
+
replyButtons.current.get(root.id)?.focus();
|
|
443
|
+
}, onSubmit: async (d) => {
|
|
444
|
+
await onSubmit(d);
|
|
445
|
+
setReplyTo(null);
|
|
446
|
+
replyButtons.current.get(root.id)?.focus();
|
|
447
|
+
} })) : null] })) : null] }) }, root.id));
|
|
448
|
+
}) })), composer !== "top" ? newComposer : null] }));
|
|
449
|
+
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { ContextMenu as ContextMenuPrimitive } from "radix-ui";
|
|
3
|
+
import type { MenuEntry } from "../lib/variants.js";
|
|
4
|
+
export declare const ContextMenuRoot: React.FC<ContextMenuPrimitive.ContextMenuProps>;
|
|
5
|
+
export declare const ContextMenuTrigger: React.ForwardRefExoticComponent<ContextMenuPrimitive.ContextMenuTriggerProps & React.RefAttributes<HTMLSpanElement>>;
|
|
6
|
+
export declare const ContextMenuGroup: React.ForwardRefExoticComponent<ContextMenuPrimitive.ContextMenuGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export declare const ContextMenuSub: React.FC<ContextMenuPrimitive.ContextMenuSubProps>;
|
|
8
|
+
export declare const ContextMenuRadioGroup: React.ForwardRefExoticComponent<ContextMenuPrimitive.ContextMenuRadioGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
export interface ContextMenuContentProps extends React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content> {
|
|
10
|
+
/** Minimum width: `sm` 180px, `md` 220px. Item size follows. */
|
|
11
|
+
size?: "sm" | "md";
|
|
12
|
+
}
|
|
13
|
+
/** The menu panel, opened at the pointer. Portals into the nearest `ThemeScope`. */
|
|
14
|
+
export declare const ContextMenuContent: React.ForwardRefExoticComponent<ContextMenuContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
15
|
+
export interface ContextMenuItemProps extends React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item> {
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
description?: React.ReactNode;
|
|
18
|
+
/** Shortcut hint, e.g. `"mod+d"` (rendered with Kbd). Display only. */
|
|
19
|
+
shortcut?: string | string[];
|
|
20
|
+
badge?: React.ReactNode;
|
|
21
|
+
tone?: "default" | "danger";
|
|
22
|
+
inset?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** One action. Same API as `DropdownMenuItem`. */
|
|
25
|
+
export declare const ContextMenuItem: React.ForwardRefExoticComponent<ContextMenuItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
26
|
+
export interface ContextMenuCheckboxItemProps extends React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.CheckboxItem> {
|
|
27
|
+
shortcut?: string | string[];
|
|
28
|
+
description?: React.ReactNode;
|
|
29
|
+
}
|
|
30
|
+
export declare const ContextMenuCheckboxItem: React.ForwardRefExoticComponent<ContextMenuCheckboxItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
31
|
+
export interface ContextMenuRadioItemProps extends React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.RadioItem> {
|
|
32
|
+
shortcut?: string | string[];
|
|
33
|
+
description?: React.ReactNode;
|
|
34
|
+
}
|
|
35
|
+
export declare const ContextMenuRadioItem: React.ForwardRefExoticComponent<ContextMenuRadioItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
36
|
+
export declare const ContextMenuLabel: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
37
|
+
inset?: boolean;
|
|
38
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
39
|
+
export declare const ContextMenuSeparator: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
40
|
+
export interface ContextMenuSubTriggerProps extends React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.SubTrigger> {
|
|
41
|
+
icon?: React.ReactNode;
|
|
42
|
+
inset?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare const ContextMenuSubTrigger: React.ForwardRefExoticComponent<ContextMenuSubTriggerProps & React.RefAttributes<HTMLDivElement>>;
|
|
45
|
+
export declare const ContextMenuSubContent: React.ForwardRefExoticComponent<Omit<ContextMenuPrimitive.ContextMenuSubContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
46
|
+
size?: "sm" | "md";
|
|
47
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
48
|
+
/** Renders `MenuEntry[]` as context-menu items (use inside your own `ContextMenuContent`). */
|
|
49
|
+
export declare function ContextMenuEntries({ items }: {
|
|
50
|
+
items: MenuEntry[];
|
|
51
|
+
}): React.JSX.Element;
|
|
52
|
+
export interface ContextMenuProps extends Omit<React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Root>, "children"> {
|
|
53
|
+
/**
|
|
54
|
+
* Data-driven mode: the menu model (shared with `ActionMenu`). `children` is then the area
|
|
55
|
+
* that opens it on right-click / long-press / Shift+F10.
|
|
56
|
+
* Without `items`, `ContextMenu` is the compound root: put `ContextMenuTrigger` + `ContextMenuContent` inside.
|
|
57
|
+
*/
|
|
58
|
+
items?: MenuEntry[];
|
|
59
|
+
children: React.ReactNode;
|
|
60
|
+
/** Let the native browser menu through (no custom menu). */
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
/** Content size in data-driven mode. */
|
|
63
|
+
size?: "sm" | "md";
|
|
64
|
+
/** Extra props for the content in data-driven mode. */
|
|
65
|
+
contentProps?: Omit<ContextMenuContentProps, "children">;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A right-click menu. Never the only way to an action: give every entry a keyboard/touch path too,
|
|
69
|
+
* e.g. the same `MenuEntry[]` in the row's `ActionMenu`.
|
|
70
|
+
*
|
|
71
|
+
* ```tsx
|
|
72
|
+
* <ContextMenu items={fileActions}>
|
|
73
|
+
* <FileTile file={file} />
|
|
74
|
+
* </ContextMenu>
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export declare function ContextMenu({ items, children, disabled, size, contentProps, ...rootProps }: ContextMenuProps): React.JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ContextMenu as ContextMenuPrimitive } from "radix-ui";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { usePortalContainer } from "../lib/theme-scope.js";
|
|
7
|
+
import { Layer } from "../lib/layer.js";
|
|
8
|
+
import { MenuCheckIcon, MenuEntries, MenuItemContent, MenuRadioDot, MenuSizeContext, menuContentVariants, menuIndicatorClass, menuItemClass, menuLabelClass, menuSeparatorClass, useVisibleEntries, } from "../lib/menu.js";
|
|
9
|
+
export const ContextMenuRoot = ContextMenuPrimitive.Root;
|
|
10
|
+
export const ContextMenuTrigger = ContextMenuPrimitive.Trigger;
|
|
11
|
+
export const ContextMenuGroup = ContextMenuPrimitive.Group;
|
|
12
|
+
export const ContextMenuSub = ContextMenuPrimitive.Sub;
|
|
13
|
+
export const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup;
|
|
14
|
+
/** The menu panel, opened at the pointer. Portals into the nearest `ThemeScope`. */
|
|
15
|
+
export const ContextMenuContent = React.forwardRef(function ContextMenuContent({ className, size = "md", collisionPadding = 12, ...props }, ref) {
|
|
16
|
+
const container = usePortalContainer();
|
|
17
|
+
return (_jsx(ContextMenuPrimitive.Portal, { container: container, children: _jsx(MenuSizeContext.Provider, { value: size, children: _jsx(Layer, { asChild: true, children: _jsx(ContextMenuPrimitive.Content, { ref: ref, "data-slot": "context-menu-content", collisionPadding: collisionPadding, className: cn(menuContentVariants({ size }), "max-h-(--radix-context-menu-content-available-height)", className), ...props }) }) }) }));
|
|
18
|
+
});
|
|
19
|
+
/** One action. Same API as `DropdownMenuItem`. */
|
|
20
|
+
export const ContextMenuItem = React.forwardRef(function ContextMenuItem({ className, icon, description, shortcut, badge, tone = "default", inset, asChild, children, ...props }, ref) {
|
|
21
|
+
const size = React.useContext(MenuSizeContext);
|
|
22
|
+
return (_jsx(ContextMenuPrimitive.Item, { ref: ref, "data-slot": "context-menu-item", "data-tone": tone, asChild: asChild, className: menuItemClass({ size, tone, inset, className }), ...props, children: asChild ? (children) : (_jsx(MenuItemContent, { icon: icon, description: description, shortcut: shortcut, badge: badge, children: children })) }));
|
|
23
|
+
});
|
|
24
|
+
export const ContextMenuCheckboxItem = React.forwardRef(function ContextMenuCheckboxItem({ className, shortcut, description, children, ...props }, ref) {
|
|
25
|
+
const size = React.useContext(MenuSizeContext);
|
|
26
|
+
return (_jsxs(ContextMenuPrimitive.CheckboxItem, { ref: ref, "data-slot": "context-menu-checkbox-item", className: menuItemClass({ size, inset: true, className }), ...props, children: [_jsx("span", { className: menuIndicatorClass, children: _jsx(ContextMenuPrimitive.ItemIndicator, { children: _jsx(MenuCheckIcon, {}) }) }), _jsx(MenuItemContent, { shortcut: shortcut, description: description, children: children })] }));
|
|
27
|
+
});
|
|
28
|
+
export const ContextMenuRadioItem = React.forwardRef(function ContextMenuRadioItem({ className, shortcut, description, children, ...props }, ref) {
|
|
29
|
+
const size = React.useContext(MenuSizeContext);
|
|
30
|
+
return (_jsxs(ContextMenuPrimitive.RadioItem, { ref: ref, "data-slot": "context-menu-radio-item", className: menuItemClass({ size, inset: true, className }), ...props, children: [_jsx("span", { className: menuIndicatorClass, children: _jsx(ContextMenuPrimitive.ItemIndicator, { children: _jsx(MenuRadioDot, {}) }) }), _jsx(MenuItemContent, { shortcut: shortcut, description: description, children: children })] }));
|
|
31
|
+
});
|
|
32
|
+
export const ContextMenuLabel = React.forwardRef(function ContextMenuLabel({ className, inset, ...props }, ref) {
|
|
33
|
+
return _jsx(ContextMenuPrimitive.Label, { ref: ref, "data-slot": "context-menu-label", className: cn(menuLabelClass, inset && "ps-8", className), ...props });
|
|
34
|
+
});
|
|
35
|
+
export const ContextMenuSeparator = React.forwardRef(function ContextMenuSeparator({ className, ...props }, ref) {
|
|
36
|
+
return _jsx(ContextMenuPrimitive.Separator, { ref: ref, "data-slot": "context-menu-separator", className: cn(menuSeparatorClass, className), ...props });
|
|
37
|
+
});
|
|
38
|
+
export const ContextMenuSubTrigger = React.forwardRef(function ContextMenuSubTrigger({ className, icon, inset, children, ...props }, ref) {
|
|
39
|
+
const size = React.useContext(MenuSizeContext);
|
|
40
|
+
return (_jsx(ContextMenuPrimitive.SubTrigger, { ref: ref, "data-slot": "context-menu-sub-trigger", className: menuItemClass({ size, inset, className: cn("data-[state=open]:bg-hover", className) }), ...props, children: _jsx(MenuItemContent, { icon: icon, chevron: true, children: children }) }));
|
|
41
|
+
});
|
|
42
|
+
export const ContextMenuSubContent = React.forwardRef(function ContextMenuSubContent({ className, size: sizeProp, sideOffset = 4, collisionPadding = 12, ...props }, ref) {
|
|
43
|
+
const container = usePortalContainer();
|
|
44
|
+
const parentSize = React.useContext(MenuSizeContext);
|
|
45
|
+
const size = sizeProp ?? parentSize;
|
|
46
|
+
return (_jsx(ContextMenuPrimitive.Portal, { container: container, children: _jsx(Layer, { asChild: true, children: _jsx(ContextMenuPrimitive.SubContent, { ref: ref, "data-slot": "context-menu-sub-content", sideOffset: sideOffset, alignOffset: -5, collisionPadding: collisionPadding, className: cn(menuContentVariants({ size }), "max-h-(--radix-context-menu-content-available-height)", className), ...props }) }) }));
|
|
47
|
+
});
|
|
48
|
+
/* ------------------------------------------------------------------ */
|
|
49
|
+
/* Data-driven root */
|
|
50
|
+
/* ------------------------------------------------------------------ */
|
|
51
|
+
const contextParts = {
|
|
52
|
+
Item: ContextMenuItem,
|
|
53
|
+
CheckboxItem: ContextMenuCheckboxItem,
|
|
54
|
+
RadioGroup: ContextMenuRadioGroup,
|
|
55
|
+
RadioItem: ContextMenuRadioItem,
|
|
56
|
+
Label: ContextMenuLabel,
|
|
57
|
+
Separator: ContextMenuSeparator,
|
|
58
|
+
Group: ContextMenuGroup,
|
|
59
|
+
Sub: ContextMenuSub,
|
|
60
|
+
SubTrigger: ContextMenuSubTrigger,
|
|
61
|
+
SubContent: ContextMenuSubContent,
|
|
62
|
+
};
|
|
63
|
+
/** Renders `MenuEntry[]` as context-menu items (use inside your own `ContextMenuContent`). */
|
|
64
|
+
export function ContextMenuEntries({ items }) {
|
|
65
|
+
const visible = useVisibleEntries(items);
|
|
66
|
+
return _jsx(MenuEntries, { entries: visible, parts: contextParts });
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A right-click menu. Never the only way to an action: give every entry a keyboard/touch path too,
|
|
70
|
+
* e.g. the same `MenuEntry[]` in the row's `ActionMenu`.
|
|
71
|
+
*
|
|
72
|
+
* ```tsx
|
|
73
|
+
* <ContextMenu items={fileActions}>
|
|
74
|
+
* <FileTile file={file} />
|
|
75
|
+
* </ContextMenu>
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export function ContextMenu({ items, children, disabled, size, contentProps, ...rootProps }) {
|
|
79
|
+
if (!items)
|
|
80
|
+
return _jsx(ContextMenuPrimitive.Root, { ...rootProps, children: children });
|
|
81
|
+
return (_jsxs(ContextMenuPrimitive.Root, { ...rootProps, children: [_jsx(ContextMenuPrimitive.Trigger, { asChild: true, disabled: disabled, children: children }), _jsx(ContextMenuContent, { size: size, ...contentProps, children: _jsx(ContextMenuEntries, { items: items }) })] }));
|
|
82
|
+
}
|