@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,138 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Checkbox as CheckboxPrimitive } from "radix-ui";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { mergeIds } from "../lib/compose-refs.js";
|
|
8
|
+
import { FieldContextReset, useFieldContext, useFieldControl } from "../lib/field-context.js";
|
|
9
|
+
import { useControllableState } from "../lib/use-controllable-state.js";
|
|
10
|
+
export const checkboxVariants = cva([
|
|
11
|
+
"peer relative inline-flex shrink-0 items-center justify-center border bg-field text-accent-fg outline-none",
|
|
12
|
+
// 16–18px boxes need the stronger edge in every material, or they vanish on dark solid
|
|
13
|
+
"border-field-border-hover",
|
|
14
|
+
"transition-[background-color,border-color,box-shadow] duration-150",
|
|
15
|
+
"hover:border-fg-subtle",
|
|
16
|
+
"focus-visible:border-ring focus-visible:shadow-[0_0_0_3px_var(--accent-soft)]",
|
|
17
|
+
"data-[state=checked]:border-transparent data-[state=checked]:bg-accent data-[state=indeterminate]:border-transparent data-[state=indeterminate]:bg-accent",
|
|
18
|
+
"data-[state=checked]:shadow-[inset_0_1px_0_rgb(255_255_255/0.3),0_0_0_1px_color-mix(in_srgb,var(--fg)_10%,transparent)]",
|
|
19
|
+
"data-[state=indeterminate]:shadow-[inset_0_1px_0_rgb(255_255_255/0.3),0_0_0_1px_color-mix(in_srgb,var(--fg)_10%,transparent)]",
|
|
20
|
+
"aria-invalid:border-danger aria-invalid:data-[state=unchecked]:shadow-[0_0_0_3px_color-mix(in_srgb,var(--danger)_14%,transparent)]",
|
|
21
|
+
"disabled:cursor-not-allowed disabled:opacity-45",
|
|
22
|
+
"aria-readonly:cursor-default aria-readonly:data-[state=checked]:bg-fg-subtle aria-readonly:data-[state=indeterminate]:bg-fg-subtle aria-readonly:text-scene",
|
|
23
|
+
], {
|
|
24
|
+
variants: {
|
|
25
|
+
size: {
|
|
26
|
+
sm: "size-4 rounded-[5px] [&_svg]:size-3",
|
|
27
|
+
md: "size-[18px] rounded-[5px] [&_svg]:size-[13px]",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: { size: "md" },
|
|
31
|
+
});
|
|
32
|
+
const CheckboxGroupContext = React.createContext(null);
|
|
33
|
+
function CheckIcon() {
|
|
34
|
+
return (_jsx("svg", { viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, focusable: "false", children: _jsx("path", { className: "ui-check-path", d: "M3 7.4 5.8 10 11 4.2", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }));
|
|
35
|
+
}
|
|
36
|
+
function DashIcon() {
|
|
37
|
+
return (_jsx("svg", { viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, focusable: "false", children: _jsx("path", { d: "M3.5 7h7", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Yes/no and multi-select: "Allow comments", row selection, permissions, consent.
|
|
41
|
+
* Built on Radix Checkbox (tri-state, hidden input with `name`). Reads Field context.
|
|
42
|
+
*
|
|
43
|
+
* ```tsx
|
|
44
|
+
* <Checkbox label="Allow comments" description="Readers can reply below the post." defaultChecked />
|
|
45
|
+
* <Checkbox checked={some ? "indeterminate" : all} onCheckedChange={toggleAll} aria-label="Select all rows" />
|
|
46
|
+
* <Field label="I accept the terms" orientation="horizontal" error={err}><Checkbox name="terms" /></Field>
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export const Checkbox = React.forwardRef(function Checkbox(rawProps, ref) {
|
|
50
|
+
const group = React.useContext(CheckboxGroupContext);
|
|
51
|
+
const { checked: checkedProp, defaultChecked, onCheckedChange, label, description, size = group?.size ?? "md", variant = group?.variant ?? "default", icon, invalid, readOnly: readOnlyProp, className, controlClassName, value, style, ...rest } = rawProps;
|
|
52
|
+
const groupValue = value === undefined ? undefined : String(value);
|
|
53
|
+
const inGroup = Boolean(group && groupValue !== undefined);
|
|
54
|
+
const control = useFieldControl({
|
|
55
|
+
...rest,
|
|
56
|
+
name: rest.name ?? (inGroup ? group.name : undefined),
|
|
57
|
+
disabled: rest.disabled ?? (group?.disabled || undefined),
|
|
58
|
+
readOnly: readOnlyProp ?? (group?.readOnly || undefined),
|
|
59
|
+
"aria-invalid": invalid || group?.invalid ? true : rest["aria-invalid"],
|
|
60
|
+
});
|
|
61
|
+
const { readOnly, required, ...controlProps } = control;
|
|
62
|
+
const [state, setState] = useControllableState({
|
|
63
|
+
value: inGroup ? group.value.includes(groupValue) : checkedProp,
|
|
64
|
+
defaultValue: defaultChecked ?? false,
|
|
65
|
+
onChange: (next) => {
|
|
66
|
+
if (inGroup)
|
|
67
|
+
group.toggle(groupValue, next === true);
|
|
68
|
+
onCheckedChange?.(next);
|
|
69
|
+
},
|
|
70
|
+
name: "Checkbox",
|
|
71
|
+
});
|
|
72
|
+
const autoId = React.useId();
|
|
73
|
+
const id = controlProps.id ?? (label ? `cb${autoId.replace(/:/g, "")}` : undefined);
|
|
74
|
+
const descId = description ? `${id ?? autoId}-desc` : undefined;
|
|
75
|
+
const labelId = label ? `${id ?? autoId}-label` : undefined;
|
|
76
|
+
const labelledBy = controlProps["aria-labelledby"] ?? (label && !controlProps["aria-label"] ? labelId : undefined);
|
|
77
|
+
const box = (_jsx(CheckboxPrimitive.Root, { ref: ref, "data-slot": "checkbox", "data-size": size, ...controlProps, id: id, value: groupValue, required: required, "aria-required": required || undefined, "aria-readonly": readOnly || undefined, "aria-labelledby": labelledBy, "aria-describedby": mergeIds(controlProps["aria-describedby"], descId), checked: state, onCheckedChange: (next) => {
|
|
78
|
+
if (readOnly)
|
|
79
|
+
return;
|
|
80
|
+
setState(next);
|
|
81
|
+
}, onKeyDown: (e) => {
|
|
82
|
+
// Radix ignores Enter on purpose (WAI-ARIA); read-only also swallows Space.
|
|
83
|
+
if (readOnly && e.key === " ")
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
controlProps.onKeyDown?.(e);
|
|
86
|
+
}, className: cn(checkboxVariants({ size }), label ? controlClassName : cn(controlClassName, className)), style: label ? undefined : style, children: _jsx(CheckboxPrimitive.Indicator, { "data-slot": "checkbox-indicator", forceMount: true, className: "flex items-center justify-center data-[state=unchecked]:hidden", children: state === "indeterminate" ? _jsx(DashIcon, {}) : _jsx(CheckIcon, {}) }) }));
|
|
87
|
+
if (!label)
|
|
88
|
+
return box;
|
|
89
|
+
const disabled = controlProps.disabled;
|
|
90
|
+
const text = (_jsxs("span", { className: "grid min-w-0 gap-0.5", children: [_jsx("span", { id: labelId, className: cn("text-fg", size === "sm" ? "text-[13px]" : "text-sm", variant === "card" ? "font-medium" : "leading-5"), children: label }), description ? (_jsx("span", { id: descId, className: cn("text-fg-muted text-pretty", size === "sm" ? "text-[11.5px]" : "text-xs", "leading-[1.45]"), children: description })) : null] }));
|
|
91
|
+
if (variant === "card") {
|
|
92
|
+
return (_jsxs("label", { htmlFor: id, "data-slot": "checkbox-card", "data-state": state === true ? "checked" : state === "indeterminate" ? "indeterminate" : "unchecked", "data-disabled": disabled ? "" : undefined, className: cn("group/cb relative flex cursor-pointer items-start gap-3 rounded-ui border border-field-border bg-field p-3.5 transition-[background-color,border-color,box-shadow] duration-150", "hover:border-field-border-hover glass:border-field-border-hover", "has-[:focus-visible]:border-ring has-[:focus-visible]:shadow-[0_0_0_3px_var(--accent-soft)]", "data-[state=checked]:border-accent-ink data-[state=checked]:bg-[color-mix(in_oklch,var(--accent-base)_11%,transparent)] data-[state=checked]:shadow-[inset_0_0_0_1px_var(--accent-ink)]", "has-[[aria-invalid=true]]:border-danger", "data-disabled:cursor-not-allowed data-disabled:opacity-50", className), style: style, children: [icon ? _jsx("span", { className: "mt-px flex size-8 shrink-0 items-center justify-center rounded-ui-sm bg-surface-2 text-fg-muted [&_svg]:size-4", children: icon }) : null, _jsx("span", { className: "min-w-0 flex-1", children: text }), _jsx("span", { className: "mt-px", children: box })] }));
|
|
93
|
+
}
|
|
94
|
+
return (_jsxs("div", { "data-slot": "checkbox-row", "data-disabled": disabled ? "" : undefined, className: cn("flex items-start gap-2.5", className), style: style, children: [_jsx("span", { className: cn("flex shrink-0 items-center", size === "sm" ? "h-[19.5px]" : "h-5"), children: box }), _jsx("label", { htmlFor: id, className: cn("min-w-0 select-none", disabled ? "cursor-not-allowed opacity-60" : "cursor-pointer"), children: text })] }));
|
|
95
|
+
});
|
|
96
|
+
/**
|
|
97
|
+
* Several checkboxes that share one array value: notification channels, modules, permissions.
|
|
98
|
+
* `role="group"`, labelled by the surrounding Field / Fieldset.
|
|
99
|
+
*
|
|
100
|
+
* ```tsx
|
|
101
|
+
* <Field label="Notify me by">
|
|
102
|
+
* <CheckboxGroup name="channels" defaultValue={["email"]} items={[{ value: "email", label: "Email" }, { value: "sms", label: "SMS" }]} />
|
|
103
|
+
* </Field>
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export const CheckboxGroup = React.forwardRef(function CheckboxGroup({ value, defaultValue, onValueChange, name, items, orientation = "vertical", variant = "default", size, disabled, readOnly, invalid, required, className, children, id, "aria-labelledby": labelledBy, "aria-describedby": describedBy, ...props }, ref) {
|
|
107
|
+
const field = useFieldContext();
|
|
108
|
+
const [current, setCurrent] = useControllableState({ value, defaultValue: defaultValue ?? [], onChange: onValueChange, name: "CheckboxGroup" });
|
|
109
|
+
const order = React.useRef([]);
|
|
110
|
+
order.current = items?.map((i) => i.value) ?? [];
|
|
111
|
+
const toggle = React.useCallback((v, checked) => setCurrent((prev) => {
|
|
112
|
+
if (checked === prev.includes(v))
|
|
113
|
+
return prev;
|
|
114
|
+
const next = checked ? [...prev, v] : prev.filter((x) => x !== v);
|
|
115
|
+
// Keep the order of the items list, so the value is stable regardless of click order.
|
|
116
|
+
return order.current.length ? next.sort((a, b) => order.current.indexOf(a) - order.current.indexOf(b)) : next;
|
|
117
|
+
}), [setCurrent]);
|
|
118
|
+
const ctx = React.useMemo(() => ({
|
|
119
|
+
value: current,
|
|
120
|
+
toggle,
|
|
121
|
+
name: name ?? field?.name,
|
|
122
|
+
disabled: disabled ?? field?.disabled,
|
|
123
|
+
readOnly: readOnly ?? field?.readOnly,
|
|
124
|
+
invalid: invalid ?? field?.invalid,
|
|
125
|
+
size,
|
|
126
|
+
variant,
|
|
127
|
+
}), [current, toggle, name, field?.name, disabled, field?.disabled, readOnly, field?.readOnly, invalid, field?.invalid, size, variant]);
|
|
128
|
+
const isRequired = required ?? field?.required;
|
|
129
|
+
return (_jsx("div", { ...props, ref: ref, role: "group", "data-slot": "checkbox-group", "data-orientation": orientation, "aria-labelledby": labelledBy ?? (props["aria-label"] ? undefined : field?.labelId), "aria-describedby": mergeIds(field?.describedBy, describedBy), "aria-invalid": ctx.invalid || undefined, "aria-required": isRequired || undefined, id: id ?? field?.id, className: cn(variant === "card"
|
|
130
|
+
? "grid gap-2.5 sm:grid-cols-[repeat(auto-fill,minmax(14rem,1fr))]"
|
|
131
|
+
: orientation === "horizontal"
|
|
132
|
+
? "flex flex-wrap items-start gap-x-6 gap-y-2.5"
|
|
133
|
+
: "grid gap-2.5", className), children: _jsx(FieldContextReset, { children: _jsxs(CheckboxGroupContext.Provider, { value: ctx, children: [items?.map((item) => (_jsx(CheckboxGroupItem, { value: item.value, label: item.label, description: item.description, icon: item.icon, disabled: item.disabled }, item.value))), children] }) }) }));
|
|
134
|
+
});
|
|
135
|
+
/** One option inside a `CheckboxGroup`. */
|
|
136
|
+
export const CheckboxGroupItem = React.forwardRef(function CheckboxGroupItem(props, ref) {
|
|
137
|
+
return _jsx(Checkbox, { ref: ref, ...props });
|
|
138
|
+
});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type ColorFormat } from "../lib/color.js";
|
|
3
|
+
declare const colorLabels: {
|
|
4
|
+
dialog: string;
|
|
5
|
+
area: string;
|
|
6
|
+
hue: string;
|
|
7
|
+
alpha: string;
|
|
8
|
+
input: string;
|
|
9
|
+
format: string;
|
|
10
|
+
swatches: string;
|
|
11
|
+
swatch: string;
|
|
12
|
+
eyeDropper: string;
|
|
13
|
+
invalid: string;
|
|
14
|
+
contrast: string;
|
|
15
|
+
ratio: string;
|
|
16
|
+
aaa: string;
|
|
17
|
+
aa: string;
|
|
18
|
+
aaLarge: string;
|
|
19
|
+
fail: string;
|
|
20
|
+
transparent: string;
|
|
21
|
+
};
|
|
22
|
+
export type ColorPickerLabels = typeof colorLabels;
|
|
23
|
+
/** One preset colour. `name` is what screen readers hear ("Lime, #c6f432"). */
|
|
24
|
+
export interface ColorSwatch {
|
|
25
|
+
value: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ColorSwatchPickerProps {
|
|
29
|
+
swatches: ColorSwatch[] | "tokens";
|
|
30
|
+
value?: string | null;
|
|
31
|
+
defaultValue?: string | null;
|
|
32
|
+
onValueChange?: (hex: string) => void;
|
|
33
|
+
size?: "sm" | "md";
|
|
34
|
+
name?: string;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
id?: string;
|
|
37
|
+
"aria-label"?: string;
|
|
38
|
+
"aria-labelledby"?: string;
|
|
39
|
+
className?: string;
|
|
40
|
+
labels?: Partial<ColorPickerLabels>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A row of preset colours as a radio group (one tab stop, arrow keys move and select). For label
|
|
44
|
+
* colours, calendar categories and campaign colours where a free picker is too much.
|
|
45
|
+
*/
|
|
46
|
+
export declare const ColorSwatchPicker: React.ForwardRefExoticComponent<ColorSwatchPickerProps & React.RefAttributes<HTMLDivElement>>;
|
|
47
|
+
export interface ColorPickerPanelProps {
|
|
48
|
+
value: string;
|
|
49
|
+
onValueChange: (hex: string) => void;
|
|
50
|
+
alpha?: boolean;
|
|
51
|
+
swatches?: ColorSwatch[] | "tokens";
|
|
52
|
+
eyeDropper?: boolean;
|
|
53
|
+
format?: ColorFormat;
|
|
54
|
+
onFormatChange?: (format: ColorFormat) => void;
|
|
55
|
+
/** Show a format switch (HEX / RGB / OKLCH) above the input. Default `true`. */
|
|
56
|
+
showFormats?: boolean;
|
|
57
|
+
contrastAgainst?: string;
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
className?: string;
|
|
60
|
+
labels?: Partial<ColorPickerLabels>;
|
|
61
|
+
}
|
|
62
|
+
/** The picker body: saturation/brightness area, hue (and opacity) strip, value input, swatches, contrast. */
|
|
63
|
+
export declare function ColorPickerPanel({ value, onValueChange, alpha, swatches, eyeDropper, format: formatProp, onFormatChange, showFormats, contrastAgainst, disabled, className, labels, }: ColorPickerPanelProps): React.JSX.Element;
|
|
64
|
+
export interface ColorPickerProps {
|
|
65
|
+
/** `"#rrggbb"`, or `"#rrggbbaa"` with `alpha`. */
|
|
66
|
+
value?: string;
|
|
67
|
+
defaultValue?: string;
|
|
68
|
+
onValueChange?: (hex: string) => void;
|
|
69
|
+
/** Add an opacity strip; values become `#rrggbbaa` when not fully opaque. */
|
|
70
|
+
alpha?: boolean;
|
|
71
|
+
/** Preset colours under the picker, or `"tokens"` for the theme palette. */
|
|
72
|
+
swatches?: ColorSwatch[] | "tokens";
|
|
73
|
+
/** Screen colour picker button (only where the EyeDropper API exists). Default `true`. */
|
|
74
|
+
eyeDropper?: boolean;
|
|
75
|
+
/** Display / input format; the value is always hex. Default `"hex"`. */
|
|
76
|
+
format?: ColorFormat;
|
|
77
|
+
defaultFormat?: ColorFormat;
|
|
78
|
+
onFormatChange?: (format: ColorFormat) => void;
|
|
79
|
+
/** Show the HEX / RGB / OKLCH switch. Default `true`. */
|
|
80
|
+
showFormats?: boolean;
|
|
81
|
+
/** Show the WCAG contrast ratio of the colour against this one (e.g. `"#ffffff"` for button text). */
|
|
82
|
+
contrastAgainst?: string;
|
|
83
|
+
/** `"popover"` (default): swatch button + floating panel. `"inline"`: the panel in place. */
|
|
84
|
+
variant?: "popover" | "inline";
|
|
85
|
+
name?: string;
|
|
86
|
+
size?: "sm" | "md" | "lg";
|
|
87
|
+
disabled?: boolean;
|
|
88
|
+
invalid?: boolean;
|
|
89
|
+
readOnly?: boolean;
|
|
90
|
+
open?: boolean;
|
|
91
|
+
defaultOpen?: boolean;
|
|
92
|
+
onOpenChange?: (open: boolean) => void;
|
|
93
|
+
id?: string;
|
|
94
|
+
"aria-label"?: string;
|
|
95
|
+
"aria-labelledby"?: string;
|
|
96
|
+
"aria-describedby"?: string;
|
|
97
|
+
className?: string;
|
|
98
|
+
labels?: Partial<ColorPickerLabels>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Choose a colour: website brand colour, label colours, campaign or chart series colour.
|
|
102
|
+
* Saturation/brightness area and hue strip are keyboard sliders; the value field accepts hex,
|
|
103
|
+
* `rgb()` and `oklch()`; swatches are a radio group; an optional WCAG contrast hint shows whether
|
|
104
|
+
* text on the colour stays readable. The value is always hex.
|
|
105
|
+
*
|
|
106
|
+
* ```tsx
|
|
107
|
+
* <Field label="Brand color"><ColorPicker name="brand" defaultValue="#c6f432" contrastAgainst="#12150f" /></Field>
|
|
108
|
+
* <ColorPicker alpha swatches="tokens" variant="inline" />
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
export declare const ColorPicker: React.ForwardRefExoticComponent<ColorPickerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
112
|
+
export {};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { HexAlphaColorPicker, HexColorPicker } from "react-colorful";
|
|
5
|
+
import { RadioGroup as RadioGroupPrimitive } from "radix-ui";
|
|
6
|
+
import { Check, ChevronDown, Pipette } from "lucide-react";
|
|
7
|
+
import { cn } from "../lib/cn.js";
|
|
8
|
+
import { mergeIds } from "../lib/compose-refs.js";
|
|
9
|
+
import { FieldContextReset, useFieldContext, useFieldControl } from "../lib/field-context.js";
|
|
10
|
+
import { useLabels } from "../lib/labels.js";
|
|
11
|
+
import { useFormat } from "../lib/locale.js";
|
|
12
|
+
import { contrastLevel, contrastRatio, formatColor, parseColor, readableOn, rgbaToHex } from "../lib/color.js";
|
|
13
|
+
import { useControllableState } from "../lib/use-controllable-state.js";
|
|
14
|
+
import { controlVariants } from "../lib/variants.js";
|
|
15
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
16
|
+
import { RadioGroup } from "./radio-group.js";
|
|
17
|
+
const colorLabels = {
|
|
18
|
+
dialog: "Pick a color",
|
|
19
|
+
area: "Saturation and brightness",
|
|
20
|
+
hue: "Hue",
|
|
21
|
+
alpha: "Opacity",
|
|
22
|
+
input: "Color value",
|
|
23
|
+
format: "Color format",
|
|
24
|
+
swatches: "Swatches",
|
|
25
|
+
swatch: "{name}, {value}",
|
|
26
|
+
eyeDropper: "Pick a color from the screen",
|
|
27
|
+
invalid: "Enter a hex, rgb() or oklch() color",
|
|
28
|
+
contrast: "Contrast with {against}",
|
|
29
|
+
ratio: "{ratio}:1",
|
|
30
|
+
aaa: "AAA",
|
|
31
|
+
aa: "AA",
|
|
32
|
+
aaLarge: "AA large text",
|
|
33
|
+
fail: "Fails",
|
|
34
|
+
transparent: "Transparent",
|
|
35
|
+
};
|
|
36
|
+
/** Theme tokens offered by `swatches="tokens"` (resolved to hex in the browser). */
|
|
37
|
+
const TOKEN_SWATCHES = [
|
|
38
|
+
{ token: "--accent", name: "Accent" },
|
|
39
|
+
{ token: "--chart-2", name: "Blue" },
|
|
40
|
+
{ token: "--chart-5", name: "Teal" },
|
|
41
|
+
{ token: "--success", name: "Green" },
|
|
42
|
+
{ token: "--chart-3", name: "Orange" },
|
|
43
|
+
{ token: "--warning", name: "Amber" },
|
|
44
|
+
{ token: "--danger", name: "Red" },
|
|
45
|
+
{ token: "--chart-6", name: "Rose" },
|
|
46
|
+
{ token: "--chart-4", name: "Violet" },
|
|
47
|
+
{ token: "--fg-muted", name: "Gray" },
|
|
48
|
+
];
|
|
49
|
+
/** Resolves `"tokens"` to concrete hex swatches from the current theme. */
|
|
50
|
+
function useSwatches(swatches, probe) {
|
|
51
|
+
const [resolved, setResolved] = React.useState([]);
|
|
52
|
+
React.useEffect(() => {
|
|
53
|
+
if (swatches !== "tokens" || !probe.current)
|
|
54
|
+
return;
|
|
55
|
+
const el = document.createElement("span");
|
|
56
|
+
probe.current.appendChild(el);
|
|
57
|
+
const out = [];
|
|
58
|
+
for (const { token, name } of TOKEN_SWATCHES) {
|
|
59
|
+
el.style.color = `var(${token})`;
|
|
60
|
+
const c = parseColor(getComputedStyle(el).color);
|
|
61
|
+
if (c)
|
|
62
|
+
out.push({ value: rgbaToHex({ ...c, a: 1 }), name });
|
|
63
|
+
}
|
|
64
|
+
el.remove();
|
|
65
|
+
setResolved(out);
|
|
66
|
+
}, [swatches, probe]);
|
|
67
|
+
if (swatches === "tokens")
|
|
68
|
+
return resolved;
|
|
69
|
+
return swatches ?? [];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A row of preset colours as a radio group (one tab stop, arrow keys move and select). For label
|
|
73
|
+
* colours, calendar categories and campaign colours where a free picker is too much.
|
|
74
|
+
*/
|
|
75
|
+
export const ColorSwatchPicker = React.forwardRef(function ColorSwatchPicker({ swatches: swatchesProp, value: valueProp, defaultValue, onValueChange, size = "md", name: nameProp, disabled, id, className, labels, ...aria }, ref) {
|
|
76
|
+
const t = useLabels("colorPicker", colorLabels, labels);
|
|
77
|
+
const field = useFieldContext();
|
|
78
|
+
const probe = React.useRef(null);
|
|
79
|
+
const swatches = useSwatches(swatchesProp, probe);
|
|
80
|
+
const [value, setValue] = useControllableState({
|
|
81
|
+
value: valueProp === undefined ? undefined : (valueProp?.toLowerCase() ?? null),
|
|
82
|
+
defaultValue: defaultValue?.toLowerCase() ?? null,
|
|
83
|
+
onChange: (v) => v && onValueChange?.(v),
|
|
84
|
+
name: "ColorSwatchPicker",
|
|
85
|
+
});
|
|
86
|
+
const isDisabled = disabled ?? field?.disabled;
|
|
87
|
+
return (_jsx(RadioGroupPrimitive.Root, { ref: (node) => {
|
|
88
|
+
probe.current = node;
|
|
89
|
+
if (typeof ref === "function")
|
|
90
|
+
ref(node);
|
|
91
|
+
else if (ref)
|
|
92
|
+
ref.current = node;
|
|
93
|
+
}, "data-slot": "color-swatch-picker", id: id ?? field?.id, name: nameProp ?? field?.name, disabled: isDisabled, value: value ?? "", onValueChange: (v) => setValue(v), orientation: "horizontal", loop: true, "aria-label": aria["aria-label"] ?? (aria["aria-labelledby"] || field?.labelId ? undefined : t("swatches")), "aria-labelledby": aria["aria-labelledby"] ?? (aria["aria-label"] ? undefined : field?.labelId), "aria-describedby": field?.describedBy, className: cn("flex flex-wrap items-center", size === "sm" ? "gap-1.5" : "gap-2", className), children: _jsx(FieldContextReset, { children: swatches.map((s) => {
|
|
94
|
+
const hex = s.value.toLowerCase();
|
|
95
|
+
return (_jsxs(RadioGroupPrimitive.Item, { value: hex, "aria-label": s.name ? t("swatch", { name: s.name, value: hex }) : hex, "data-slot": "color-swatch", className: cn("ui-checker group/swatch relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-full outline-none", "shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--fg)_14%,transparent)] transition-transform duration-100", "hover:scale-110 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-(--surface-solid)", "data-[state=checked]:ring-2 data-[state=checked]:ring-fg data-[state=checked]:ring-offset-2 data-[state=checked]:ring-offset-(--surface-solid)", "disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:scale-100 motion-reduce:transition-none motion-reduce:hover:scale-100", size === "sm" ? "size-5" : "size-7"), children: [_jsx("span", { "aria-hidden": true, className: "absolute inset-0", style: { background: hex } }), _jsx(RadioGroupPrimitive.Indicator, { className: "relative", style: { color: readableOn(hex) }, children: _jsx(Check, { "aria-hidden": true, strokeWidth: 3, className: size === "sm" ? "size-3" : "size-3.5" }) })] }, hex));
|
|
96
|
+
}) }) }));
|
|
97
|
+
});
|
|
98
|
+
/* ------------------------------------------------------------------ */
|
|
99
|
+
/* Contrast hint */
|
|
100
|
+
/* ------------------------------------------------------------------ */
|
|
101
|
+
function ContrastHint({ color, against, t }) {
|
|
102
|
+
const f = useFormat();
|
|
103
|
+
const ratio = contrastRatio(color, against);
|
|
104
|
+
if (ratio === null)
|
|
105
|
+
return null;
|
|
106
|
+
const level = contrastLevel(ratio);
|
|
107
|
+
const levelText = level === "AAA" ? t("aaa") : level === "AA" ? t("aa") : level === "AA-large" ? t("aaLarge") : t("fail");
|
|
108
|
+
const ok = level === "AAA" || level === "AA";
|
|
109
|
+
return (_jsxs("div", { "data-slot": "color-contrast", className: "flex items-center gap-2.5 rounded-ui-sm border border-line bg-surface-2 p-1.5 pe-2.5", children: [_jsxs("span", { "aria-hidden": true, className: "ui-checker relative flex h-7 w-10 shrink-0 items-center justify-center overflow-hidden rounded-[6px] text-[13px] font-semibold", children: [_jsx("span", { className: "absolute inset-0", style: { background: color } }), _jsx("span", { className: "relative", style: { color: against }, children: "Aa" })] }), _jsxs("span", { className: "min-w-0 flex-1 text-xs leading-tight text-fg-muted", children: [t("contrast", { against: formatColor(against) }), _jsx("span", { className: "block font-medium text-fg tabular", children: t("ratio", { ratio: f.number(Math.floor(ratio * 10) / 10, { minimumFractionDigits: 1, maximumFractionDigits: 1 }) }) })] }), _jsx("span", { className: cn("inline-flex h-5 shrink-0 items-center rounded-full px-2 text-[11px] font-medium", ok ? "tone-success tone-soft" : level === "AA-large" ? "tone-warning tone-soft" : "tone-danger tone-soft"), children: levelText })] }));
|
|
110
|
+
}
|
|
111
|
+
/** The picker body: saturation/brightness area, hue (and opacity) strip, value input, swatches, contrast. */
|
|
112
|
+
export function ColorPickerPanel({ value, onValueChange, alpha = false, swatches, eyeDropper = true, format: formatProp, onFormatChange, showFormats = true, contrastAgainst, disabled, className, labels, }) {
|
|
113
|
+
const t = useLabels("colorPicker", colorLabels, labels);
|
|
114
|
+
const [format, setFormat] = useControllableState({ value: formatProp, defaultValue: "hex", onChange: onFormatChange, name: "ColorPicker" });
|
|
115
|
+
const areaRef = React.useRef(null);
|
|
116
|
+
const [draft, setDraft] = React.useState(null);
|
|
117
|
+
const [draftInvalid, setDraftInvalid] = React.useState(false);
|
|
118
|
+
const [canDrop, setCanDrop] = React.useState(false);
|
|
119
|
+
const inputId = React.useId();
|
|
120
|
+
const errorId = React.useId();
|
|
121
|
+
const hasAlpha = alpha;
|
|
122
|
+
const hex = value.toLowerCase();
|
|
123
|
+
React.useEffect(() => setCanDrop(typeof window !== "undefined" && "EyeDropper" in window), []);
|
|
124
|
+
// react-colorful names its sliders in English ("Color", "Hue", "Alpha"): use the dictionary.
|
|
125
|
+
React.useEffect(() => {
|
|
126
|
+
const sliders = areaRef.current?.querySelectorAll('[role="slider"]');
|
|
127
|
+
if (!sliders)
|
|
128
|
+
return;
|
|
129
|
+
const names = [t("area"), t("hue"), t("alpha")];
|
|
130
|
+
sliders.forEach((s, i) => {
|
|
131
|
+
s.setAttribute("aria-label", names[i] ?? "");
|
|
132
|
+
if (disabled)
|
|
133
|
+
s.setAttribute("tabindex", "-1");
|
|
134
|
+
else
|
|
135
|
+
s.setAttribute("tabindex", "0");
|
|
136
|
+
s.setAttribute("aria-disabled", disabled ? "true" : "false");
|
|
137
|
+
});
|
|
138
|
+
}, [t, disabled, hasAlpha]);
|
|
139
|
+
const commitText = (text, final) => {
|
|
140
|
+
const c = parseColor(text);
|
|
141
|
+
if (!c) {
|
|
142
|
+
if (final)
|
|
143
|
+
setDraftInvalid(true);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const raw = text.trim().replace(/^#/, "");
|
|
147
|
+
// While typing hex, wait for a complete value (6 or 8 digits) before applying.
|
|
148
|
+
if (!final && /^[0-9a-f]*$/i.test(raw) && raw.length !== 6 && raw.length !== 8)
|
|
149
|
+
return;
|
|
150
|
+
setDraftInvalid(false);
|
|
151
|
+
onValueChange(rgbaToHex(hasAlpha ? c : { ...c, a: 1 }, hasAlpha && c.a < 1));
|
|
152
|
+
if (final)
|
|
153
|
+
setDraft(null);
|
|
154
|
+
};
|
|
155
|
+
const shown = draft ?? (format === "hex" ? formatColor(hex, "hex").slice(1) : formatColor(hex, format));
|
|
156
|
+
const Picker = hasAlpha ? HexAlphaColorPicker : HexColorPicker;
|
|
157
|
+
const resolvedSwatches = swatches;
|
|
158
|
+
return (_jsxs("div", { "data-slot": "color-picker-panel", className: cn("grid min-w-0 grid-cols-[minmax(0,1fr)] gap-3", disabled && "pointer-events-none opacity-60", className), children: [_jsx("div", { ref: areaRef, "data-slot": "color-picker-area", className: "ui-color-area", children: _jsx(Picker, { color: hex, onChange: (v) => onValueChange(hasAlpha ? (v.length === 9 && v.endsWith("ff") ? v.slice(0, 7) : v) : v) }) }), _jsxs("div", { className: "grid grid-cols-[minmax(0,1fr)] gap-2", children: [showFormats ? (_jsx(RadioGroup, { variant: "segmented", size: "sm", "aria-label": t("format"), value: format, onValueChange: (v) => {
|
|
159
|
+
setFormat(v);
|
|
160
|
+
setDraft(null);
|
|
161
|
+
setDraftInvalid(false);
|
|
162
|
+
}, className: "w-full [&>*]:flex-1", items: [
|
|
163
|
+
{ value: "hex", label: "HEX" },
|
|
164
|
+
{ value: "rgb", label: "RGB" },
|
|
165
|
+
{ value: "oklch", label: "OKLCH" },
|
|
166
|
+
] })) : null, _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { "aria-hidden": true, className: "ui-checker relative size-(--control-h) shrink-0 overflow-hidden rounded-ui border border-field-border", children: _jsx("span", { className: "absolute inset-0", style: { background: hex } }) }), _jsx("label", { htmlFor: inputId, className: "sr-only", children: t("input") }), _jsxs("div", { className: cn(controlVariants({ size: "md" }), "min-w-0 flex-1 gap-0 px-0"), "data-slot": "color-picker-input", children: [format === "hex" ? (_jsx("span", { "aria-hidden": true, className: "ps-3 font-mono text-[13px] text-fg-subtle", children: "#" })) : null, _jsx("input", { id: inputId, value: shown, spellCheck: false, autoComplete: "off", disabled: disabled, "aria-invalid": draftInvalid || undefined, "aria-describedby": draftInvalid ? errorId : undefined, onChange: (e) => {
|
|
167
|
+
setDraft(e.target.value);
|
|
168
|
+
setDraftInvalid(false);
|
|
169
|
+
commitText(e.target.value, false);
|
|
170
|
+
}, onBlur: () => {
|
|
171
|
+
if (draft !== null)
|
|
172
|
+
commitText(draft, true);
|
|
173
|
+
}, onKeyDown: (e) => {
|
|
174
|
+
if (e.key === "Enter" && draft !== null) {
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
commitText(draft, true);
|
|
177
|
+
}
|
|
178
|
+
if (e.key === "Escape" && draft !== null) {
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
setDraft(null);
|
|
181
|
+
setDraftInvalid(false);
|
|
182
|
+
}
|
|
183
|
+
}, className: cn("h-full min-w-0 flex-1 bg-transparent font-mono text-[13px] text-fg outline-none tabular", format === "hex" ? "ps-1 pe-3" : "px-3") })] }), eyeDropper && canDrop ? (_jsx("button", { type: "button", "aria-label": t("eyeDropper"), disabled: disabled, onClick: async () => {
|
|
184
|
+
try {
|
|
185
|
+
const Dropper = window.EyeDropper;
|
|
186
|
+
const res = await new Dropper().open();
|
|
187
|
+
const picked = parseColor(res.sRGBHex);
|
|
188
|
+
if (picked)
|
|
189
|
+
onValueChange(rgbaToHex({ ...picked, a: 1 }));
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
/* cancelled */
|
|
193
|
+
}
|
|
194
|
+
}, className: "inline-flex size-(--control-h) shrink-0 items-center justify-center rounded-ui border border-field-border bg-field text-fg-muted transition-colors hover:border-field-border-hover hover:text-fg focus-ring [&_svg]:size-4", children: _jsx(Pipette, { "aria-hidden": true }) })) : null] }), draftInvalid ? (_jsx("p", { id: errorId, role: "alert", className: "text-xs text-danger", children: t("invalid") })) : null] }), resolvedSwatches && (resolvedSwatches === "tokens" || resolvedSwatches.length > 0) ? (_jsx(ColorSwatchPicker, { swatches: resolvedSwatches, size: "sm", value: hex.slice(0, 7), onValueChange: (v) => onValueChange(v), disabled: disabled, labels: labels, className: "border-t border-line pt-3" })) : null, contrastAgainst ? _jsx(ContrastHint, { color: hex, against: contrastAgainst, t: t }) : null] }));
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Choose a colour: website brand colour, label colours, campaign or chart series colour.
|
|
198
|
+
* Saturation/brightness area and hue strip are keyboard sliders; the value field accepts hex,
|
|
199
|
+
* `rgb()` and `oklch()`; swatches are a radio group; an optional WCAG contrast hint shows whether
|
|
200
|
+
* text on the colour stays readable. The value is always hex.
|
|
201
|
+
*
|
|
202
|
+
* ```tsx
|
|
203
|
+
* <Field label="Brand color"><ColorPicker name="brand" defaultValue="#c6f432" contrastAgainst="#12150f" /></Field>
|
|
204
|
+
* <ColorPicker alpha swatches="tokens" variant="inline" />
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
export const ColorPicker = React.forwardRef(function ColorPicker(props, ref) {
|
|
208
|
+
const { value: valueProp, defaultValue, onValueChange, alpha, swatches, eyeDropper, format: formatProp, defaultFormat, onFormatChange, showFormats, contrastAgainst, variant = "popover", name: nameProp, size = "md", invalid, open: openProp, defaultOpen, onOpenChange, className, labels, } = props;
|
|
209
|
+
const t = useLabels("colorPicker", colorLabels, labels);
|
|
210
|
+
const field = useFieldContext();
|
|
211
|
+
const control = useFieldControl({
|
|
212
|
+
id: props.id,
|
|
213
|
+
name: nameProp,
|
|
214
|
+
disabled: props.disabled,
|
|
215
|
+
readOnly: props.readOnly,
|
|
216
|
+
"aria-invalid": invalid ? true : undefined,
|
|
217
|
+
"aria-label": props["aria-label"],
|
|
218
|
+
"aria-labelledby": props["aria-labelledby"],
|
|
219
|
+
"aria-describedby": props["aria-describedby"],
|
|
220
|
+
});
|
|
221
|
+
const [value, setValue] = useControllableState({ value: valueProp, defaultValue: defaultValue ?? "#000000", onChange: onValueChange, name: "ColorPicker" });
|
|
222
|
+
const [format, setFormat] = useControllableState({ value: formatProp, defaultValue: defaultFormat ?? "hex", onChange: onFormatChange, name: "ColorPicker" });
|
|
223
|
+
const [open, setOpen] = useControllableState({ value: openProp, defaultValue: defaultOpen ?? false, onChange: onOpenChange, name: "ColorPicker" });
|
|
224
|
+
const valueId = React.useId();
|
|
225
|
+
const disabled = Boolean(control.disabled);
|
|
226
|
+
const readOnly = Boolean(control.readOnly);
|
|
227
|
+
const hex = (parseColor(value) ? value : "#000000").toLowerCase();
|
|
228
|
+
const transparent = parseColor(hex)?.a === 0;
|
|
229
|
+
const panel = (_jsx(ColorPickerPanel, { value: hex, onValueChange: setValue, alpha: alpha, swatches: swatches, eyeDropper: eyeDropper, format: format, onFormatChange: setFormat, showFormats: showFormats, contrastAgainst: contrastAgainst, disabled: disabled || readOnly, labels: labels }));
|
|
230
|
+
const hidden = control.name ? _jsx("input", { type: "hidden", name: control.name, value: hex }) : null;
|
|
231
|
+
if (variant === "inline") {
|
|
232
|
+
return (_jsxs("div", { "data-slot": "color-picker", "data-variant": "inline", role: "group", "aria-label": control["aria-label"] ?? (control["aria-labelledby"] || field?.labelId ? undefined : t("dialog")), "aria-labelledby": control["aria-labelledby"] ?? (control["aria-label"] ? undefined : field?.labelId), "aria-describedby": control["aria-describedby"], className: cn("w-72 max-w-full rounded-ui-lg border border-line bg-surface p-3", className), children: [_jsx(FieldContextReset, { children: panel }), hidden] }));
|
|
233
|
+
}
|
|
234
|
+
return (_jsxs(Popover, { open: readOnly || disabled ? false : open, onOpenChange: (o) => !readOnly && !disabled && setOpen(o), children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { ref: ref, type: "button", "data-slot": "color-picker", "data-readonly": readOnly ? "" : undefined, id: control.id, disabled: disabled, "aria-label": control["aria-label"], "aria-labelledby": control["aria-labelledby"], "aria-describedby": mergeIds(control["aria-describedby"], valueId), "aria-invalid": control["aria-invalid"] || undefined, className: cn(controlVariants({ size }), "justify-start text-start font-mono tabular", size === "sm" ? "ps-1" : "ps-1.5", className), children: [_jsx("span", { "aria-hidden": true, className: cn("ui-checker relative shrink-0 overflow-hidden rounded-[calc(var(--radius)-5px)] shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--fg)_14%,transparent)]", size === "sm" ? "size-5" : size === "lg" ? "size-8" : "size-6.5"), children: _jsx("span", { className: "absolute inset-0", style: { background: hex } }) }), _jsx("span", { id: valueId, className: "min-w-0 flex-1 truncate text-[0.95em]", children: transparent ? t("transparent") : formatColor(hex, format) }), readOnly ? null : _jsx(ChevronDown, { "aria-hidden": true, className: "shrink-0 text-fg-subtle" })] }) }), hidden, _jsx(PopoverContent, { size: "auto", align: "start", "aria-label": t("dialog"), className: "w-72", children: _jsx(FieldContextReset, { children: panel }) })] }));
|
|
235
|
+
});
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type AsyncLoader } from "../lib/use-async-list.js";
|
|
3
|
+
declare const comboboxLabels: {
|
|
4
|
+
placeholder: string;
|
|
5
|
+
placeholderMultiple: string;
|
|
6
|
+
search: string;
|
|
7
|
+
empty: string;
|
|
8
|
+
create: string;
|
|
9
|
+
results: string;
|
|
10
|
+
error: string;
|
|
11
|
+
retry: string;
|
|
12
|
+
loading: string;
|
|
13
|
+
loadMore: string;
|
|
14
|
+
clear: string;
|
|
15
|
+
selected: string;
|
|
16
|
+
selectedCount: string;
|
|
17
|
+
remove: string;
|
|
18
|
+
more: string;
|
|
19
|
+
moreLabel: string;
|
|
20
|
+
};
|
|
21
|
+
export type ComboboxLabels = typeof comboboxLabels;
|
|
22
|
+
/** The default item shape. Any other shape works with `getValue` / `getLabel`. */
|
|
23
|
+
export interface ComboboxOption {
|
|
24
|
+
value: string;
|
|
25
|
+
label: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
icon?: React.ReactNode;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/** Extra searchable text (email, code, former name). */
|
|
30
|
+
keywords?: string[];
|
|
31
|
+
/** Items with the same group render under one heading. */
|
|
32
|
+
group?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ComboboxItemState {
|
|
35
|
+
selected: boolean;
|
|
36
|
+
/** The current search text (for your own highlighting). */
|
|
37
|
+
query: string;
|
|
38
|
+
/** The label split into matched / unmatched parts (locale-folded). */
|
|
39
|
+
highlight: React.ReactNode;
|
|
40
|
+
}
|
|
41
|
+
interface ComboboxCommonProps<T> {
|
|
42
|
+
/** Static items (filtered client-side with locale folding: "istanbul" finds "İstanbul"). */
|
|
43
|
+
items?: T[];
|
|
44
|
+
/**
|
|
45
|
+
* Server search. Called (debounced, abortable) with the query; return an array or
|
|
46
|
+
* `{ items, cursor }` for paging. Called with `cursor` for the next page.
|
|
47
|
+
*/
|
|
48
|
+
loadItems?: AsyncLoader<T>;
|
|
49
|
+
/** Debounce for `loadItems` in ms. Default 200. */
|
|
50
|
+
debounce?: number;
|
|
51
|
+
getValue?: (item: T) => string;
|
|
52
|
+
getLabel?: (item: T) => string;
|
|
53
|
+
/** Extra searchable text per item. Default: `item.keywords`. */
|
|
54
|
+
getKeywords?: (item: T) => string[] | undefined;
|
|
55
|
+
getDisabled?: (item: T) => boolean;
|
|
56
|
+
getGroup?: (item: T) => string | undefined;
|
|
57
|
+
/** Custom row content (avatar + email…). The check indicator is added for you. */
|
|
58
|
+
renderItem?: (item: T, state: ComboboxItemState) => React.ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* Shows a "Create “…”" row for unknown text. Return the new item to select it
|
|
61
|
+
* (or a promise of it); return nothing to handle selection yourself.
|
|
62
|
+
*/
|
|
63
|
+
onCreate?: (query: string) => T | void | Promise<T | void>;
|
|
64
|
+
/** Labels for values that aren't in the current list (async initial values). */
|
|
65
|
+
selectedItems?: T[];
|
|
66
|
+
/** Trigger text with no selection. */
|
|
67
|
+
placeholder?: string;
|
|
68
|
+
/** Placeholder of the search box. */
|
|
69
|
+
searchPlaceholder?: string;
|
|
70
|
+
/** Shown when nothing matches. */
|
|
71
|
+
emptyMessage?: React.ReactNode;
|
|
72
|
+
size?: "sm" | "md" | "lg";
|
|
73
|
+
variant?: "default" | "ghost" | "pill";
|
|
74
|
+
/** `"popover"` (default): trigger + floating list. `"inline"`: the search and list in place. */
|
|
75
|
+
mode?: "popover" | "inline";
|
|
76
|
+
/** Static items are still loading. */
|
|
77
|
+
loading?: boolean;
|
|
78
|
+
name?: string;
|
|
79
|
+
disabled?: boolean;
|
|
80
|
+
invalid?: boolean;
|
|
81
|
+
readOnly?: boolean;
|
|
82
|
+
required?: boolean;
|
|
83
|
+
open?: boolean;
|
|
84
|
+
defaultOpen?: boolean;
|
|
85
|
+
onOpenChange?: (open: boolean) => void;
|
|
86
|
+
/** Close after picking. Default: `true` for single, `false` for multiple. */
|
|
87
|
+
closeOnSelect?: boolean;
|
|
88
|
+
id?: string;
|
|
89
|
+
"aria-label"?: string;
|
|
90
|
+
"aria-labelledby"?: string;
|
|
91
|
+
"aria-describedby"?: string;
|
|
92
|
+
/** Classes for the root (trigger box or inline panel). */
|
|
93
|
+
className?: string;
|
|
94
|
+
/** Classes for the popover panel. */
|
|
95
|
+
contentClassName?: string;
|
|
96
|
+
/** Max height of the list. Default 18rem. */
|
|
97
|
+
listClassName?: string;
|
|
98
|
+
/** Built-in string overrides (`combobox` namespace). */
|
|
99
|
+
labels?: Partial<ComboboxLabels>;
|
|
100
|
+
}
|
|
101
|
+
export interface ComboboxSingleProps<T> extends ComboboxCommonProps<T> {
|
|
102
|
+
multiple?: false;
|
|
103
|
+
value?: string | null;
|
|
104
|
+
defaultValue?: string | null;
|
|
105
|
+
onValueChange?: (value: string | null, item: T | null) => void;
|
|
106
|
+
/** Show a clear (×) button while there is a value. */
|
|
107
|
+
clearable?: boolean;
|
|
108
|
+
maxVisibleChips?: never;
|
|
109
|
+
}
|
|
110
|
+
export interface ComboboxMultipleProps<T> extends ComboboxCommonProps<T> {
|
|
111
|
+
multiple: true;
|
|
112
|
+
value?: string[];
|
|
113
|
+
defaultValue?: string[];
|
|
114
|
+
onValueChange?: (value: string[], items: T[]) => void;
|
|
115
|
+
/** Collapse chips beyond this count into "+N". */
|
|
116
|
+
maxVisibleChips?: number;
|
|
117
|
+
clearable?: boolean;
|
|
118
|
+
}
|
|
119
|
+
export type ComboboxProps<T = ComboboxOption> = ComboboxSingleProps<T> | ComboboxMultipleProps<T>;
|
|
120
|
+
/**
|
|
121
|
+
* Searchable selection — single or multiple, static or server-backed, optionally creatable:
|
|
122
|
+
* city, assignee, category, country, tags. WAI-ARIA combobox + listbox in a popover (or inline).
|
|
123
|
+
* Search folds locale characters, so "istanbul" finds "İstanbul" and "cagri" finds "Çağrı";
|
|
124
|
+
* matches are highlighted by weight, not colour (readable on glass).
|
|
125
|
+
*
|
|
126
|
+
* ```tsx
|
|
127
|
+
* <Field label="City"><Combobox name="city" items={cities} /></Field>
|
|
128
|
+
* <Combobox multiple items={labels} defaultValue={["urgent"]} maxVisibleChips={3} />
|
|
129
|
+
* <Combobox loadItems={(q, signal) => fetch(`/api/people?q=${q}`, { signal }).then((r) => r.json())} />
|
|
130
|
+
* <Combobox items={categories} onCreate={async (name) => api.createCategory(name)} />
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare const Combobox: <T = ComboboxOption>(props: ComboboxProps<T> & {
|
|
134
|
+
ref?: React.Ref<HTMLButtonElement>;
|
|
135
|
+
}) => React.ReactElement;
|
|
136
|
+
export {};
|