@senvenli/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 +32 -2
- package/dist/action/button-group.d.ts +26 -0
- package/dist/action/button-group.js +12 -0
- package/dist/action/button-group.js.map +1 -0
- package/dist/action/button.d.ts +42 -0
- package/dist/action/button.js +58 -0
- package/dist/action/button.js.map +1 -0
- package/dist/action/close-button.d.ts +12 -0
- package/dist/action/close-button.js +13 -0
- package/dist/action/close-button.js.map +1 -0
- package/dist/action/copy-button.d.ts +21 -0
- package/dist/action/copy-button.js +38 -0
- package/dist/action/copy-button.js.map +1 -0
- package/dist/action/fab.d.ts +29 -0
- package/dist/action/fab.js +57 -0
- package/dist/action/fab.js.map +1 -0
- package/dist/action/files.d.ts +70 -0
- package/dist/action/files.js +156 -0
- package/dist/action/files.js.map +1 -0
- package/dist/action/index.d.ts +23 -0
- package/dist/action/index.js +16 -0
- package/dist/action/index.js.map +1 -0
- package/dist/action/language-names.d.ts +19 -0
- package/dist/action/language-names.js +79 -0
- package/dist/action/language-names.js.map +1 -0
- package/dist/action/language-switcher.d.ts +57 -0
- package/dist/action/language-switcher.js +53 -0
- package/dist/action/language-switcher.js.map +1 -0
- package/dist/action/link-button.d.ts +57 -0
- package/dist/action/link-button.js +48 -0
- package/dist/action/link-button.js.map +1 -0
- package/dist/action/link.d.ts +24 -0
- package/dist/action/link.js +18 -0
- package/dist/action/link.js.map +1 -0
- package/dist/action/pressable.d.ts +40 -0
- package/dist/action/pressable.js +65 -0
- package/dist/action/pressable.js.map +1 -0
- package/dist/action/styles.d.ts +60 -0
- package/dist/action/styles.js +109 -0
- package/dist/action/styles.js.map +1 -0
- package/dist/action/theme-script.d.ts +12 -0
- package/dist/action/theme-script.js +23 -0
- package/dist/action/theme-script.js.map +1 -0
- package/dist/action/theme-switcher.d.ts +43 -0
- package/dist/action/theme-switcher.js +260 -0
- package/dist/action/theme-switcher.js.map +1 -0
- package/dist/action/theme-toggle.d.ts +43 -0
- package/dist/action/theme-toggle.js +259 -0
- package/dist/action/theme-toggle.js.map +1 -0
- package/dist/action/toggle.d.ts +44 -0
- package/dist/action/toggle.js +28 -0
- package/dist/action/toggle.js.map +1 -0
- package/dist/action/touch-target.d.ts +9 -0
- package/dist/action/touch-target.js +14 -0
- package/dist/action/touch-target.js.map +1 -0
- package/dist/charts/axis-width.d.ts +186 -0
- package/dist/charts/axis-width.js +1262 -0
- package/dist/charts/axis-width.js.map +1 -0
- package/dist/charts/bar-public.d.ts +16 -0
- package/dist/charts/bar-public.js +16 -0
- package/dist/charts/bar-public.js.map +1 -0
- package/dist/charts/chart-parts.d.ts +136 -0
- package/dist/charts/chart-parts.js +160 -0
- package/dist/charts/chart-parts.js.map +1 -0
- package/dist/charts/core-charts.d.ts +157 -0
- package/dist/charts/core-charts.js +505 -0
- package/dist/charts/core-charts.js.map +1 -0
- package/dist/charts/index.d.ts +12 -0
- package/dist/charts/index.js +8 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/charts/list-charts.d.ts +124 -0
- package/dist/charts/list-charts.js +308 -0
- package/dist/charts/list-charts.js.map +1 -0
- package/dist/charts/more-charts.d.ts +138 -0
- package/dist/charts/more-charts.js +284 -0
- package/dist/charts/more-charts.js.map +1 -0
- package/dist/charts/report-charts.d.ts +138 -0
- package/dist/charts/report-charts.js +370 -0
- package/dist/charts/report-charts.js.map +1 -0
- package/dist/charts/value-tick.d.ts +178 -0
- package/dist/charts/value-tick.js +240 -0
- package/dist/charts/value-tick.js.map +1 -0
- package/dist/collection/data-table-url-hook.d.ts +34 -0
- package/dist/collection/data-table-url-hook.js +70 -0
- package/dist/collection/data-table-url-hook.js.map +1 -0
- package/dist/collection/data-table-url.d.ts +30 -0
- package/dist/collection/data-table-url.js +48 -0
- package/dist/collection/data-table-url.js.map +1 -0
- package/dist/collection/data-table.d.ts +112 -0
- package/dist/collection/data-table.js +188 -0
- package/dist/collection/data-table.js.map +1 -0
- package/dist/collection/grid-list-public.d.ts +18 -0
- package/dist/collection/grid-list-public.js +19 -0
- package/dist/collection/grid-list-public.js.map +1 -0
- package/dist/collection/grid-list.d.ts +73 -0
- package/dist/collection/grid-list.js +46 -0
- package/dist/collection/grid-list.js.map +1 -0
- package/dist/collection/index.d.ts +14 -0
- package/dist/collection/index.js +8 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/list.d.ts +61 -0
- package/dist/collection/list.js +38 -0
- package/dist/collection/list.js.map +1 -0
- package/dist/collection/selection-checkbox.d.ts +5 -0
- package/dist/collection/selection-checkbox.js +13 -0
- package/dist/collection/selection-checkbox.js.map +1 -0
- package/dist/collection/table.d.ts +91 -0
- package/dist/collection/table.js +183 -0
- package/dist/collection/table.js.map +1 -0
- package/dist/collection/tree.d.ts +31 -0
- package/dist/collection/tree.js +22 -0
- package/dist/collection/tree.js.map +1 -0
- package/dist/color/color.d.ts +87 -0
- package/dist/color/color.js +200 -0
- package/dist/color/color.js.map +1 -0
- package/dist/color/contrast.d.ts +34 -0
- package/dist/color/contrast.js +44 -0
- package/dist/color/contrast.js.map +1 -0
- package/dist/color/index.d.ts +4 -0
- package/dist/color/index.js +5 -0
- package/dist/color/index.js.map +1 -0
- package/dist/date/calendar.d.ts +71 -0
- package/dist/date/calendar.js +291 -0
- package/dist/date/calendar.js.map +1 -0
- package/dist/date/fields.d.ts +174 -0
- package/dist/date/fields.js +250 -0
- package/dist/date/fields.js.map +1 -0
- package/dist/date/index.d.ts +7 -0
- package/dist/date/index.js +6 -0
- package/dist/date/index.js.map +1 -0
- package/dist/date/month-grid.d.ts +31 -0
- package/dist/date/month-grid.js +115 -0
- package/dist/date/month-grid.js.map +1 -0
- package/dist/date/pickers.d.ts +118 -0
- package/dist/date/pickers.js +176 -0
- package/dist/date/pickers.js.map +1 -0
- package/dist/date/public.d.ts +25 -0
- package/dist/date/public.js +24 -0
- package/dist/date/public.js.map +1 -0
- package/dist/date/segments.d.ts +153 -0
- package/dist/date/segments.js +433 -0
- package/dist/date/segments.js.map +1 -0
- package/dist/defaults.d.ts +74 -0
- package/dist/defaults.js +100 -0
- package/dist/defaults.js.map +1 -0
- package/dist/density.d.ts +2 -0
- package/dist/density.js +2 -0
- package/dist/density.js.map +1 -0
- package/dist/display/avatar.d.ts +29 -0
- package/dist/display/avatar.js +71 -0
- package/dist/display/avatar.js.map +1 -0
- package/dist/display/badge.d.ts +65 -0
- package/dist/display/badge.js +99 -0
- package/dist/display/badge.js.map +1 -0
- package/dist/display/card.d.ts +72 -0
- package/dist/display/card.js +91 -0
- package/dist/display/card.js.map +1 -0
- package/dist/display/carousel.d.ts +47 -0
- package/dist/display/carousel.js +214 -0
- package/dist/display/carousel.js.map +1 -0
- package/dist/display/description-list.d.ts +25 -0
- package/dist/display/description-list.js +36 -0
- package/dist/display/description-list.js.map +1 -0
- package/dist/display/icon-aliases.d.ts +1 -0
- package/dist/display/icon-aliases.js +259 -0
- package/dist/display/icon-aliases.js.map +1 -0
- package/dist/display/icon-names.d.ts +4 -0
- package/dist/display/icon-names.js +2 -0
- package/dist/display/icon-names.js.map +1 -0
- package/dist/display/icon.d.ts +51 -0
- package/dist/display/icon.js +96 -0
- package/dist/display/icon.js.map +1 -0
- package/dist/display/image-crop.d.ts +106 -0
- package/dist/display/image-crop.js +117 -0
- package/dist/display/image-crop.js.map +1 -0
- package/dist/display/image-cropper.d.ts +68 -0
- package/dist/display/image-cropper.js +284 -0
- package/dist/display/image-cropper.js.map +1 -0
- package/dist/display/image-viewer.d.ts +54 -0
- package/dist/display/image-viewer.js +84 -0
- package/dist/display/image-viewer.js.map +1 -0
- package/dist/display/image.d.ts +26 -0
- package/dist/display/image.js +17 -0
- package/dist/display/image.js.map +1 -0
- package/dist/display/index.d.ts +29 -0
- package/dist/display/index.js +16 -0
- package/dist/display/index.js.map +1 -0
- package/dist/display/iso-chip.d.ts +19 -0
- package/dist/display/iso-chip.js +21 -0
- package/dist/display/iso-chip.js.map +1 -0
- package/dist/display/kbd.d.ts +11 -0
- package/dist/display/kbd.js +33 -0
- package/dist/display/kbd.js.map +1 -0
- package/dist/display/lozenge.d.ts +30 -0
- package/dist/display/lozenge.js +55 -0
- package/dist/display/lozenge.js.map +1 -0
- package/dist/display/scroll-area.d.ts +29 -0
- package/dist/display/scroll-area.js +95 -0
- package/dist/display/scroll-area.js.map +1 -0
- package/dist/display/separator.d.ts +13 -0
- package/dist/display/separator.js +24 -0
- package/dist/display/separator.js.map +1 -0
- package/dist/display/stat.d.ts +35 -0
- package/dist/display/stat.js +41 -0
- package/dist/display/stat.js.map +1 -0
- package/dist/display/timeline.d.ts +44 -0
- package/dist/display/timeline.js +111 -0
- package/dist/display/timeline.js.map +1 -0
- package/dist/display/typography.d.ts +37 -0
- package/dist/display/typography.js +53 -0
- package/dist/display/typography.js.map +1 -0
- package/dist/display/visually-hidden.d.ts +14 -0
- package/dist/display/visually-hidden.js +10 -0
- package/dist/display/visually-hidden.js.map +1 -0
- package/dist/feedback/banner.d.ts +46 -0
- package/dist/feedback/banner.js +157 -0
- package/dist/feedback/banner.js.map +1 -0
- package/dist/feedback/cooldown.d.ts +17 -0
- package/dist/feedback/cooldown.js +59 -0
- package/dist/feedback/cooldown.js.map +1 -0
- package/dist/feedback/empty-state.d.ts +35 -0
- package/dist/feedback/empty-state.js +39 -0
- package/dist/feedback/empty-state.js.map +1 -0
- package/dist/feedback/index.d.ts +12 -0
- package/dist/feedback/index.js +11 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/feedback/meter.d.ts +33 -0
- package/dist/feedback/meter.js +42 -0
- package/dist/feedback/meter.js.map +1 -0
- package/dist/feedback/motion.d.ts +9 -0
- package/dist/feedback/motion.js +57 -0
- package/dist/feedback/motion.js.map +1 -0
- package/dist/feedback/progress.d.ts +39 -0
- package/dist/feedback/progress.js +68 -0
- package/dist/feedback/progress.js.map +1 -0
- package/dist/feedback/skeleton.d.ts +48 -0
- package/dist/feedback/skeleton.js +61 -0
- package/dist/feedback/skeleton.js.map +1 -0
- package/dist/feedback/spinner.d.ts +19 -0
- package/dist/feedback/spinner.js +29 -0
- package/dist/feedback/spinner.js.map +1 -0
- package/dist/feedback/status-dot.d.ts +23 -0
- package/dist/feedback/status-dot.js +37 -0
- package/dist/feedback/status-dot.js.map +1 -0
- package/dist/form/countries.d.ts +34 -0
- package/dist/form/countries.js +273 -0
- package/dist/form/countries.js.map +1 -0
- package/dist/form/data-attributes.d.ts +11 -0
- package/dist/form/data-attributes.js +22 -0
- package/dist/form/data-attributes.js.map +1 -0
- package/dist/form/field-parts.d.ts +113 -0
- package/dist/form/field-parts.js +178 -0
- package/dist/form/field-parts.js.map +1 -0
- package/dist/form/field.d.ts +36 -0
- package/dist/form/field.js +65 -0
- package/dist/form/field.js.map +1 -0
- package/dist/form/files.d.ts +70 -0
- package/dist/form/files.js +156 -0
- package/dist/form/files.js.map +1 -0
- package/dist/form/form.d.ts +40 -0
- package/dist/form/form.js +74 -0
- package/dist/form/form.js.map +1 -0
- package/dist/form/image-crop.d.ts +106 -0
- package/dist/form/image-crop.js +117 -0
- package/dist/form/image-crop.js.map +1 -0
- package/dist/form/image-cropper.d.ts +68 -0
- package/dist/form/image-cropper.js +284 -0
- package/dist/form/image-cropper.js.map +1 -0
- package/dist/form/index.d.ts +24 -0
- package/dist/form/index.js +15 -0
- package/dist/form/index.js.map +1 -0
- package/dist/form/input-group.d.ts +63 -0
- package/dist/form/input-group.js +63 -0
- package/dist/form/input-group.js.map +1 -0
- package/dist/form/input-otp.d.ts +35 -0
- package/dist/form/input-otp.js +83 -0
- package/dist/form/input-otp.js.map +1 -0
- package/dist/form/input.d.ts +36 -0
- package/dist/form/input.js +41 -0
- package/dist/form/input.js.map +1 -0
- package/dist/form/number-field.d.ts +84 -0
- package/dist/form/number-field.js +81 -0
- package/dist/form/number-field.js.map +1 -0
- package/dist/form/otp-field.d.ts +37 -0
- package/dist/form/otp-field.js +116 -0
- package/dist/form/otp-field.js.map +1 -0
- package/dist/form/password-field.d.ts +61 -0
- package/dist/form/password-field.js +61 -0
- package/dist/form/password-field.js.map +1 -0
- package/dist/form/phone-field.d.ts +104 -0
- package/dist/form/phone-field.js +275 -0
- package/dist/form/phone-field.js.map +1 -0
- package/dist/form/phone-paste.d.ts +24 -0
- package/dist/form/phone-paste.js +40 -0
- package/dist/form/phone-paste.js.map +1 -0
- package/dist/form/phone.d.ts +159 -0
- package/dist/form/phone.js +309 -0
- package/dist/form/phone.js.map +1 -0
- package/dist/form/search-field.d.ts +29 -0
- package/dist/form/search-field.js +23 -0
- package/dist/form/search-field.js.map +1 -0
- package/dist/form/styles.d.ts +31 -0
- package/dist/form/styles.js +43 -0
- package/dist/form/styles.js.map +1 -0
- package/dist/form/text-area.d.ts +70 -0
- package/dist/form/text-area.js +93 -0
- package/dist/form/text-area.js.map +1 -0
- package/dist/form/text-field.d.ts +131 -0
- package/dist/form/text-field.js +59 -0
- package/dist/form/text-field.js.map +1 -0
- package/dist/form/validation.d.ts +145 -0
- package/dist/form/validation.js +136 -0
- package/dist/form/validation.js.map +1 -0
- package/dist/i18n.d.ts +438 -0
- package/dist/i18n.js +948 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/intl-locale.d.ts +30 -0
- package/dist/intl-locale.js +83 -0
- package/dist/intl-locale.js.map +1 -0
- package/dist/layers.d.ts +32 -0
- package/dist/layers.js +33 -0
- package/dist/layers.js.map +1 -0
- package/dist/layout/auth-form-layout.d.ts +71 -0
- package/dist/layout/auth-form-layout.js +61 -0
- package/dist/layout/auth-form-layout.js.map +1 -0
- package/dist/layout/auth-layout.d.ts +59 -0
- package/dist/layout/auth-layout.js +26 -0
- package/dist/layout/auth-layout.js.map +1 -0
- package/dist/layout/box.d.ts +26 -0
- package/dist/layout/box.js +16 -0
- package/dist/layout/box.js.map +1 -0
- package/dist/layout/grid.d.ts +27 -0
- package/dist/layout/grid.js +26 -0
- package/dist/layout/grid.js.map +1 -0
- package/dist/layout/index.d.ts +16 -0
- package/dist/layout/index.js +12 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/pressable.d.ts +40 -0
- package/dist/layout/pressable.js +65 -0
- package/dist/layout/pressable.js.map +1 -0
- package/dist/layout/reset-sent-card.d.ts +39 -0
- package/dist/layout/reset-sent-card.js +22 -0
- package/dist/layout/reset-sent-card.js.map +1 -0
- package/dist/layout/scroll-area.d.ts +29 -0
- package/dist/layout/scroll-area.js +95 -0
- package/dist/layout/scroll-area.js.map +1 -0
- package/dist/layout/section.d.ts +41 -0
- package/dist/layout/section.js +22 -0
- package/dist/layout/section.js.map +1 -0
- package/dist/layout/split.d.ts +50 -0
- package/dist/layout/split.js +35 -0
- package/dist/layout/split.js.map +1 -0
- package/dist/layout/stack.d.ts +44 -0
- package/dist/layout/stack.js +36 -0
- package/dist/layout/stack.js.map +1 -0
- package/dist/layout/tokens.d.ts +33 -0
- package/dist/layout/tokens.js +85 -0
- package/dist/layout/tokens.js.map +1 -0
- package/dist/layout/toolbar.d.ts +37 -0
- package/dist/layout/toolbar.js +334 -0
- package/dist/layout/toolbar.js.map +1 -0
- package/dist/navigate-context.d.ts +12 -0
- package/dist/navigate-context.js +13 -0
- package/dist/navigate-context.js.map +1 -0
- package/dist/navigation/accordion.d.ts +40 -0
- package/dist/navigation/accordion.js +33 -0
- package/dist/navigation/accordion.js.map +1 -0
- package/dist/navigation/bottom-nav.d.ts +29 -0
- package/dist/navigation/bottom-nav.js +48 -0
- package/dist/navigation/bottom-nav.js.map +1 -0
- package/dist/navigation/brand-link-context.d.ts +8 -0
- package/dist/navigation/brand-link-context.js +9 -0
- package/dist/navigation/brand-link-context.js.map +1 -0
- package/dist/navigation/breadcrumbs.d.ts +36 -0
- package/dist/navigation/breadcrumbs.js +51 -0
- package/dist/navigation/breadcrumbs.js.map +1 -0
- package/dist/navigation/dock.d.ts +27 -0
- package/dist/navigation/dock.js +47 -0
- package/dist/navigation/dock.js.map +1 -0
- package/dist/navigation/footer.d.ts +43 -0
- package/dist/navigation/footer.js +43 -0
- package/dist/navigation/footer.js.map +1 -0
- package/dist/navigation/index.d.ts +22 -0
- package/dist/navigation/index.js +17 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/navigation/language-names.d.ts +19 -0
- package/dist/navigation/language-names.js +79 -0
- package/dist/navigation/language-names.js.map +1 -0
- package/dist/navigation/language-switcher.d.ts +55 -0
- package/dist/navigation/language-switcher.js +53 -0
- package/dist/navigation/language-switcher.js.map +1 -0
- package/dist/navigation/nav-panel.d.ts +18 -0
- package/dist/navigation/nav-panel.js +51 -0
- package/dist/navigation/nav-panel.js.map +1 -0
- package/dist/navigation/navbar.d.ts +73 -0
- package/dist/navigation/navbar.js +64 -0
- package/dist/navigation/navbar.js.map +1 -0
- package/dist/navigation/page-header.d.ts +37 -0
- package/dist/navigation/page-header.js +50 -0
- package/dist/navigation/page-header.js.map +1 -0
- package/dist/navigation/pagination.d.ts +25 -0
- package/dist/navigation/pagination.js +51 -0
- package/dist/navigation/pagination.js.map +1 -0
- package/dist/navigation/panel-header.d.ts +37 -0
- package/dist/navigation/panel-header.js +50 -0
- package/dist/navigation/panel-header.js.map +1 -0
- package/dist/navigation/sidebar-script.d.ts +12 -0
- package/dist/navigation/sidebar-script.js +20 -0
- package/dist/navigation/sidebar-script.js.map +1 -0
- package/dist/navigation/sidebar.d.ts +149 -0
- package/dist/navigation/sidebar.js +332 -0
- package/dist/navigation/sidebar.js.map +1 -0
- package/dist/navigation/skip-link.d.ts +12 -0
- package/dist/navigation/skip-link.js +30 -0
- package/dist/navigation/skip-link.js.map +1 -0
- package/dist/navigation/stepper.d.ts +50 -0
- package/dist/navigation/stepper.js +96 -0
- package/dist/navigation/stepper.js.map +1 -0
- package/dist/navigation/tabs.d.ts +84 -0
- package/dist/navigation/tabs.js +118 -0
- package/dist/navigation/tabs.js.map +1 -0
- package/dist/navigation/toolbar.d.ts +37 -0
- package/dist/navigation/toolbar.js +334 -0
- package/dist/navigation/toolbar.js.map +1 -0
- package/dist/overlay/alert-dialog.d.ts +63 -0
- package/dist/overlay/alert-dialog.js +76 -0
- package/dist/overlay/alert-dialog.js.map +1 -0
- package/dist/overlay/command-palette.d.ts +53 -0
- package/dist/overlay/command-palette.js +130 -0
- package/dist/overlay/command-palette.js.map +1 -0
- package/dist/overlay/command.d.ts +53 -0
- package/dist/overlay/command.js +129 -0
- package/dist/overlay/command.js.map +1 -0
- package/dist/overlay/context-menu.d.ts +29 -0
- package/dist/overlay/context-menu.js +58 -0
- package/dist/overlay/context-menu.js.map +1 -0
- package/dist/overlay/dialog.d.ts +162 -0
- package/dist/overlay/dialog.js +174 -0
- package/dist/overlay/dialog.js.map +1 -0
- package/dist/overlay/drawer.d.ts +41 -0
- package/dist/overlay/drawer.js +114 -0
- package/dist/overlay/drawer.js.map +1 -0
- package/dist/overlay/floating.d.ts +142 -0
- package/dist/overlay/floating.js +226 -0
- package/dist/overlay/floating.js.map +1 -0
- package/dist/overlay/hover-card.d.ts +19 -0
- package/dist/overlay/hover-card.js +31 -0
- package/dist/overlay/hover-card.js.map +1 -0
- package/dist/overlay/index.d.ts +18 -0
- package/dist/overlay/index.js +12 -0
- package/dist/overlay/index.js.map +1 -0
- package/dist/overlay/overlay-base.d.ts +105 -0
- package/dist/overlay/overlay-base.js +250 -0
- package/dist/overlay/overlay-base.js.map +1 -0
- package/dist/overlay/overlay.d.ts +299 -0
- package/dist/overlay/overlay.js +558 -0
- package/dist/overlay/overlay.js.map +1 -0
- package/dist/overlay/toast.d.ts +58 -0
- package/dist/overlay/toast.js +145 -0
- package/dist/overlay/toast.js.map +1 -0
- package/dist/provider.d.ts +26 -0
- package/dist/provider.js +30 -0
- package/dist/provider.js.map +1 -0
- package/dist/selection/autocomplete.d.ts +54 -0
- package/dist/selection/autocomplete.js +122 -0
- package/dist/selection/autocomplete.js.map +1 -0
- package/dist/selection/checkbox.d.ts +56 -0
- package/dist/selection/checkbox.js +49 -0
- package/dist/selection/checkbox.js.map +1 -0
- package/dist/selection/choice-size.d.ts +26 -0
- package/dist/selection/choice-size.js +50 -0
- package/dist/selection/choice-size.js.map +1 -0
- package/dist/selection/choice-text.d.ts +21 -0
- package/dist/selection/choice-text.js +33 -0
- package/dist/selection/choice-text.js.map +1 -0
- package/dist/selection/combobox.d.ts +173 -0
- package/dist/selection/combobox.js +410 -0
- package/dist/selection/combobox.js.map +1 -0
- package/dist/selection/index.d.ts +20 -0
- package/dist/selection/index.js +13 -0
- package/dist/selection/index.js.map +1 -0
- package/dist/selection/list-box.d.ts +30 -0
- package/dist/selection/list-box.js +16 -0
- package/dist/selection/list-box.js.map +1 -0
- package/dist/selection/listbox.d.ts +44 -0
- package/dist/selection/listbox.js +49 -0
- package/dist/selection/listbox.js.map +1 -0
- package/dist/selection/match.d.ts +20 -0
- package/dist/selection/match.js +57 -0
- package/dist/selection/match.js.map +1 -0
- package/dist/selection/multi-select.d.ts +72 -0
- package/dist/selection/multi-select.js +138 -0
- package/dist/selection/multi-select.js.map +1 -0
- package/dist/selection/radio-card.d.ts +31 -0
- package/dist/selection/radio-card.js +29 -0
- package/dist/selection/radio-card.js.map +1 -0
- package/dist/selection/radio.d.ts +72 -0
- package/dist/selection/radio.js +64 -0
- package/dist/selection/radio.js.map +1 -0
- package/dist/selection/select-public.d.ts +19 -0
- package/dist/selection/select-public.js +24 -0
- package/dist/selection/select-public.js.map +1 -0
- package/dist/selection/select.d.ts +72 -0
- package/dist/selection/select.js +69 -0
- package/dist/selection/select.js.map +1 -0
- package/dist/selection/slider.d.ts +16 -0
- package/dist/selection/slider.js +44 -0
- package/dist/selection/slider.js.map +1 -0
- package/dist/selection/styles.d.ts +26 -0
- package/dist/selection/styles.js +78 -0
- package/dist/selection/styles.js.map +1 -0
- package/dist/selection/switch.d.ts +24 -0
- package/dist/selection/switch.js +27 -0
- package/dist/selection/switch.js.map +1 -0
- package/dist/selection/tag-group.d.ts +38 -0
- package/dist/selection/tag-group.js +45 -0
- package/dist/selection/tag-group.js.map +1 -0
- package/dist/tone.d.ts +6 -0
- package/dist/tone.js +2 -0
- package/dist/tone.js.map +1 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +42 -0
- package/dist/utils.js.map +1 -0
- package/manifest/component.full.schema.json +391 -0
- package/manifest/component.schema.json +279 -0
- package/manifests/accordion.json +299 -0
- package/manifests/alert-dialog.json +261 -0
- package/manifests/area-chart.json +338 -0
- package/manifests/autocomplete.json +299 -0
- package/manifests/avatar.json +253 -0
- package/manifests/badge.json +288 -0
- package/manifests/banner.json +185 -0
- package/manifests/bar-chart.json +454 -0
- package/manifests/bar-list.json +262 -0
- package/manifests/bottom-nav.json +139 -0
- package/manifests/box.json +3450 -0
- package/manifests/breadcrumbs.json +199 -0
- package/manifests/button-group.json +2294 -0
- package/manifests/button.json +1211 -0
- package/manifests/calendar-heatmap.json +218 -0
- package/manifests/calendar.json +299 -0
- package/manifests/card.json +308 -0
- package/manifests/carousel.json +263 -0
- package/manifests/chart-parts.json +309 -0
- package/manifests/checkbox.json +998 -0
- package/manifests/close-button.json +1000 -0
- package/manifests/color-field.json +276 -0
- package/manifests/color-picker.json +161 -0
- package/manifests/color-swatch-picker.json +220 -0
- package/manifests/color-swatch.json +140 -0
- package/manifests/combobox.json +581 -0
- package/manifests/command.json +275 -0
- package/manifests/composed-chart.json +287 -0
- package/manifests/context-menu.json +148 -0
- package/manifests/copy-button.json +192 -0
- package/manifests/data-table.json +334 -0
- package/manifests/date-field.json +302 -0
- package/manifests/date-picker.json +472 -0
- package/manifests/description-list.json +201 -0
- package/manifests/dialog.json +322 -0
- package/manifests/donut-chart.json +264 -0
- package/manifests/drawer.json +211 -0
- package/manifests/empty-state.json +185 -0
- package/manifests/fab.json +172 -0
- package/manifests/field.json +209 -0
- package/manifests/file-upload.json +791 -0
- package/manifests/form.json +829 -0
- package/manifests/funnel-chart.json +223 -0
- package/manifests/gauge-chart.json +252 -0
- package/manifests/grid-list.json +335 -0
- package/manifests/grid.json +3482 -0
- package/manifests/heading.json +183 -0
- package/manifests/heatmap.json +265 -0
- package/manifests/hover-card.json +172 -0
- package/manifests/icon.json +201 -0
- package/manifests/image-cropper.json +295 -0
- package/manifests/image-viewer.json +198 -0
- package/manifests/image.json +193 -0
- package/manifests/index.json +2035 -0
- package/manifests/input-group.json +3571 -0
- package/manifests/input.json +1557 -0
- package/manifests/kbd.json +98 -0
- package/manifests/language-switcher.json +274 -0
- package/manifests/line-chart.json +342 -0
- package/manifests/link.json +867 -0
- package/manifests/list-box.json +213 -0
- package/manifests/menu.json +453 -0
- package/manifests/meter.json +145 -0
- package/manifests/navbar.json +281 -0
- package/manifests/otp-field.json +1029 -0
- package/manifests/page-header.json +164 -0
- package/manifests/pagination.json +181 -0
- package/manifests/popover.json +205 -0
- package/manifests/pressable.json +367 -0
- package/manifests/progress.json +282 -0
- package/manifests/radar-chart.json +229 -0
- package/manifests/radial-chart.json +195 -0
- package/manifests/radio.json +975 -0
- package/manifests/scatter-chart.json +277 -0
- package/manifests/scroll-area.json +127 -0
- package/manifests/section.json +169 -0
- package/manifests/select.json +474 -0
- package/manifests/separator.json +119 -0
- package/manifests/sidebar.json +584 -0
- package/manifests/skeleton.json +235 -0
- package/manifests/skip-link.json +89 -0
- package/manifests/slider.json +706 -0
- package/manifests/sparkline.json +208 -0
- package/manifests/spinner.json +105 -0
- package/manifests/split.json +6618 -0
- package/manifests/stack.json +3541 -0
- package/manifests/stat.json +192 -0
- package/manifests/stepper.json +279 -0
- package/manifests/switch.json +205 -0
- package/manifests/table.json +375 -0
- package/manifests/tabs.json +438 -0
- package/manifests/tag-group.json +264 -0
- package/manifests/text-area.json +1136 -0
- package/manifests/text.json +244 -0
- package/manifests/theme-switcher.json +152 -0
- package/manifests/time-field.json +284 -0
- package/manifests/timeline.json +196 -0
- package/manifests/toast.json +87 -0
- package/manifests/toggle-button.json +1489 -0
- package/manifests/toolbar.json +145 -0
- package/manifests/tooltip.json +181 -0
- package/manifests/tracker.json +192 -0
- package/manifests/tree.json +245 -0
- package/manifests/visually-hidden.json +114 -0
- package/package.json +117 -3
- package/styles/base.css +56 -0
- package/styles/theme.css +154 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Autocomplete, Dialog as AriaDialog, Header, Input, ListBox, ListBoxItem, ListBoxSection, Modal, ModalOverlay, SearchField, useLocale, } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { IconGlyph } from "../display/icon.js";
|
|
7
|
+
import { Kbd } from "../display/kbd.js";
|
|
8
|
+
import { Lozenge } from "../display/lozenge.js";
|
|
9
|
+
import { actionFailedLabel, commandHints, commandPaletteLabel, commandSearchLabel, frequentActionsLabel, loadingLabel, noMatchLabel, recentRecordsLabel } from "../i18n.js";
|
|
10
|
+
import { Highlight, matchesQuery } from "../selection/match.js";
|
|
11
|
+
const SEARCH_DELAY = 150;
|
|
12
|
+
/** Records first, then actions, then pages; a group ranks by its highest kind; equal groups keep their order. */
|
|
13
|
+
function byKind(groups) {
|
|
14
|
+
const order = { record: 0, action: 1, page: 2 };
|
|
15
|
+
const rank = (group) => Math.min(...group.items.map((item) => order[item.kind ?? "action"]));
|
|
16
|
+
return [...groups].sort((a, b) => rank(a) - rank(b));
|
|
17
|
+
}
|
|
18
|
+
/** The server's results for a query, debounced and cancelled when the query moves on. */
|
|
19
|
+
function useSearch(query, search) {
|
|
20
|
+
const [state, setState] = React.useState({
|
|
21
|
+
query: "", groups: [], loading: false, failed: false,
|
|
22
|
+
});
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
if (!search || !query.trim()) {
|
|
25
|
+
setState({ query, groups: [], loading: false, failed: false });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
// The last answer stays (filtered by the caller) while the next one loads, so records do not flicker away.
|
|
30
|
+
setState((current) => ({ ...current, loading: true, failed: false }));
|
|
31
|
+
const timer = setTimeout(() => {
|
|
32
|
+
search(query, controller.signal).then((groups) => !controller.signal.aborted && setState({ query, groups, loading: false, failed: false }), () => !controller.signal.aborted && setState({ query, groups: [], loading: false, failed: true }));
|
|
33
|
+
}, SEARCH_DELAY);
|
|
34
|
+
return () => {
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
controller.abort();
|
|
37
|
+
};
|
|
38
|
+
}, [query, search]);
|
|
39
|
+
return state;
|
|
40
|
+
}
|
|
41
|
+
/** A row's key: group and item, since ids repeat across groups (a product and an order both "12"). */
|
|
42
|
+
const rowKey = (group, item) => `${group.id}\u0000${item.id}`;
|
|
43
|
+
function Row({ item, query, rowId }) {
|
|
44
|
+
return (_jsxs(ListBoxItem, { id: rowId, textValue: item.detail ? `${item.label} ${item.detail}` : item.label, "data-slot": "command-item", "data-kind": item.kind, className: "flex min-h-10 cursor-default items-center gap-ds-150 rounded-ds-medium px-ds-150 text-body text-ds-text outline-hidden data-[focused]:bg-ds-background-selected data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[focused]:data-[hovered]:bg-ds-background-selected", children: [item.icon && _jsx(IconGlyph, { name: item.icon, size: "small", "data-slot": "command-item-icon", className: "text-ds-icon-subtle" }), _jsxs("span", { "data-slot": "command-item-label", className: "min-w-0 flex-1 truncate", children: [_jsx(Highlight, { text: item.label, query: query }), item.detail && (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, children: " \u00B7 " }), _jsx("bdi", { "data-slot": "command-item-detail", className: "font-ds-mono text-code text-ds-text-subtle", children: _jsx(Highlight, { text: item.detail, query: query }) })] }))] }), item.status && _jsx(Lozenge, { tone: item.status.tone, children: item.status.label }), item.shortcut && _jsx(Kbd, { children: item.shortcut })] }));
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* ⌘K / Ctrl K: find any record and run any action from the keyboard. 560px in the top third over the
|
|
48
|
+
* blanket; one field, results grouped (records, then actions, then pages), 40px rows, the active row on
|
|
49
|
+
* ds-background-selected, records with their status. Empty, it shows recent records and the five most used
|
|
50
|
+
* actions. Typing matches labels, codes and keywords without regard to case or accents ("durovic" finds
|
|
51
|
+
* "Đurović"), and asks `search` for records (the last answer stays while the next loads; a failed search says
|
|
52
|
+
* so). Arrows move, Enter opens, Esc closes and returns focus. Rows are keyed by group and id, so ids may repeat
|
|
53
|
+
* across groups. When records arrive after the actions, the active row stays where it was (React Aria's
|
|
54
|
+
* Autocomplete keeps its virtual focus); arrows reach the records first in the list.
|
|
55
|
+
* Everything here must also be reachable through visible UI.
|
|
56
|
+
*/
|
|
57
|
+
export function CommandPalette({ isOpen, defaultOpen, onOpenChange, groups, search, recent = [], onSelect, shortcut }) {
|
|
58
|
+
const { locale } = useLocale();
|
|
59
|
+
const [own, setOwn] = React.useState(defaultOpen ?? false);
|
|
60
|
+
const open = isOpen ?? own;
|
|
61
|
+
const setOpen = (next) => {
|
|
62
|
+
if (isOpen === undefined)
|
|
63
|
+
setOwn(next);
|
|
64
|
+
onOpenChange?.(next);
|
|
65
|
+
};
|
|
66
|
+
const latest = React.useRef({ open, setOpen });
|
|
67
|
+
latest.current = { open, setOpen };
|
|
68
|
+
React.useEffect(() => {
|
|
69
|
+
if (!shortcut)
|
|
70
|
+
return;
|
|
71
|
+
// ⌘K on Apple platforms (Ctrl K there is "delete to end of line" in every field), Ctrl K elsewhere. The
|
|
72
|
+
// physical key counts too, for Cyrillic and Greek layouts; a key an editor already handled is left alone.
|
|
73
|
+
const apple = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
74
|
+
const listener = (event) => {
|
|
75
|
+
if (event.defaultPrevented || event.isComposing || event.repeat || event.altKey || event.shiftKey)
|
|
76
|
+
return;
|
|
77
|
+
const modifier = apple ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
|
|
78
|
+
if (modifier && (event.key.toLowerCase() === "k" || event.code === "KeyK")) {
|
|
79
|
+
event.preventDefault();
|
|
80
|
+
latest.current.setOpen(!latest.current.open);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
document.addEventListener("keydown", listener);
|
|
84
|
+
return () => document.removeEventListener("keydown", listener);
|
|
85
|
+
}, [shortcut]);
|
|
86
|
+
const [query, setQuery] = React.useState("");
|
|
87
|
+
// A new opening starts from an empty query.
|
|
88
|
+
const [wasOpen, setWasOpen] = React.useState(open);
|
|
89
|
+
if (wasOpen !== open) {
|
|
90
|
+
setWasOpen(open);
|
|
91
|
+
if (open)
|
|
92
|
+
setQuery("");
|
|
93
|
+
}
|
|
94
|
+
const remote = useSearch(query, search);
|
|
95
|
+
const empty = !query.trim();
|
|
96
|
+
const shown = React.useMemo(() => {
|
|
97
|
+
if (empty) {
|
|
98
|
+
const actions = groups.flatMap((group) => group.items).filter((item) => (item.kind ?? "action") === "action").slice(0, 5);
|
|
99
|
+
return [
|
|
100
|
+
...(recent.length ? [{ id: "__recent", title: recentRecordsLabel(locale), items: recent }] : []),
|
|
101
|
+
...(actions.length ? [{ id: "__frequent", title: frequentActionsLabel(locale), items: actions }] : []),
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
const local = groups
|
|
105
|
+
.map((group) => ({ ...group, items: group.items.filter((item) => matchesQuery(query, item.label, item.detail, ...(item.keywords ?? []))) }))
|
|
106
|
+
.filter((group) => group.items.length);
|
|
107
|
+
// The newest answer, or the previous one (still matching the query) while the next one loads.
|
|
108
|
+
const found = (remote.query === query ? remote.groups : remote.groups.map((group) => ({ ...group, items: group.items.filter((item) => matchesQuery(query, item.label, item.detail, ...(item.keywords ?? []))) })))
|
|
109
|
+
.filter((group) => group.items.length);
|
|
110
|
+
return byKind([...found, ...local]);
|
|
111
|
+
}, [empty, groups, recent, locale, query, remote]);
|
|
112
|
+
const items = React.useMemo(() => new Map(shown.flatMap((group) => group.items.map((item) => [rowKey(group, item), item]))), [shown]);
|
|
113
|
+
const hints = commandHints(locale);
|
|
114
|
+
return (_jsx(ModalOverlay, { isOpen: open, onOpenChange: setOpen, isDismissable: true, "data-slot": "command-palette-overlay", className: "fixed inset-0 z-50 flex items-start justify-center bg-ds-blanket px-ds-200 pt-[15dvh] transition-opacity duration-(--ds-duration-medium) data-[entering]:opacity-0 data-[exiting]:opacity-0 motion-reduce:transition-none", children: _jsx(Modal, { "data-slot": "command-palette", className: "flex max-h-[70dvh] w-full max-w-140 flex-col overflow-hidden rounded-ds-xlarge bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden", children: _jsx(AriaDialog, { "aria-label": commandPaletteLabel(locale), "data-slot": "command-palette-dialog", className: "flex min-h-0 flex-1 flex-col outline-hidden", children: _jsxs("div", { className: "flex min-h-0 flex-1 flex-col",
|
|
115
|
+
// Esc closes at once, as the footer says (the search field would otherwise clear itself first).
|
|
116
|
+
onKeyDownCapture: (event) => {
|
|
117
|
+
if (event.key === "Escape" && !event.nativeEvent.isComposing) {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
event.stopPropagation();
|
|
120
|
+
setOpen(false);
|
|
121
|
+
}
|
|
122
|
+
}, children: [_jsxs(Autocomplete, { inputValue: query, onInputChange: setQuery, children: [_jsxs(SearchField, { "aria-label": commandSearchLabel(locale), autoFocus: true, "data-slot": "command-palette-search", className: "flex min-h-13 items-center gap-ds-150 border-b border-ds-border px-ds-200", children: [_jsx(IconGlyph, { name: "search", className: "size-5 shrink-0 text-ds-icon-subtle" }), _jsx(Input, { placeholder: commandSearchLabel(locale), "data-slot": "command-palette-input", className: "min-w-0 flex-1 bg-transparent text-body text-ds-text outline-hidden placeholder:text-ds-text-subtlest [&::-webkit-search-cancel-button]:hidden" }), _jsx(Kbd, { children: "Esc" })] }), _jsx(ListBox, { "aria-label": commandPaletteLabel(locale), "data-slot": "command-palette-results", onAction: (key) => {
|
|
123
|
+
const item = items.get(String(key));
|
|
124
|
+
if (!item)
|
|
125
|
+
return;
|
|
126
|
+
setOpen(false);
|
|
127
|
+
onSelect(item);
|
|
128
|
+
}, renderEmptyState: () => (_jsx("div", { "data-slot": "command-palette-empty", className: "px-ds-200 py-ds-300 text-center text-body text-ds-text-subtle", children: remote.loading ? loadingLabel(locale) : remote.failed ? actionFailedLabel(locale) : empty ? null : noMatchLabel(locale, query.trim()) })), className: "min-h-0 flex-1 overflow-y-auto p-ds-100 outline-hidden", children: shown.map((group) => (_jsxs(ListBoxSection, { id: group.id, "data-slot": "command-palette-group", className: "flex flex-col", children: [_jsx(Header, { "data-slot": "command-palette-group-title", className: "px-ds-150 pt-ds-150 pb-ds-050 text-heading-xxsmall text-ds-text-subtle", children: group.title }), group.items.map((item) => _jsx(Row, { rowId: rowKey(group, item), item: item, query: empty ? "" : query }, rowKey(group, item)))] }, group.id))) }), _jsx("span", { "aria-live": "polite", className: "sr-only", "data-slot": "command-palette-status", children: remote.loading ? loadingLabel(locale) : "" })] }), _jsxs("div", { "data-slot": "command-palette-footer", className: "flex flex-wrap items-center gap-ds-300 border-t border-ds-border bg-ds-surface-sunken px-ds-200 py-ds-100 text-body-small text-ds-text-subtle", children: [_jsxs("span", { className: "flex items-center gap-ds-050", children: [_jsx(Kbd, { children: "\u2191" }), _jsx(Kbd, { children: "\u2193" }), hints.move] }), _jsxs("span", { className: "flex items-center gap-ds-050", children: [_jsx(Kbd, { children: "\u21B5" }), hints.open] }), _jsxs("span", { className: "flex items-center gap-ds-050", children: [_jsx(Kbd, { children: "Esc" }), hints.close] })] })] }) }) }) }));
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=command-palette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-palette.js","sourceRoot":"","sources":["../../src/overlay/command-palette.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,YAAY,EACZ,MAAM,IAAI,UAAU,EACpB,MAAM,EACN,KAAK,EACL,OAAO,EACP,WAAW,EACX,cAAc,EACd,KAAK,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AK,IAAQ,IAC7E,IACA,GACK,GACP,GACK,CAChB,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n Autocomplete,\n Dialog as AriaDialog,\n Header,\n Input,\n ListBox,\n ListBoxItem,\n ListBoxSection,\n Modal,\n ModalOverlay,\n SearchField,\n useLocale,\n} from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { IconGlyph, type IconName } from \"../display/icon\";\nimport { Kbd } from \"../display/kbd\";\nimport { Lozenge, type LozengeTone } from \"../display/lozenge\";\nimport { actionFailedLabel, commandHints, commandPaletteLabel, commandSearchLabel, frequentActionsLabel, loadingLabel, noMatchLabel, recentRecordsLabel } from \"../i18n\";\nimport { Highlight, matchesQuery } from \"../selection/match\";\n\nexport type CommandItem = {\n id: string;\n /** \"Pro plan\", \"Create order\". */\n label: string;\n /** Beside the label in mono: a code, an order number (\"ORD-482\"). */\n detail?: string;\n icon?: IconName;\n /** A record's status (\"Available\", success). */\n status?: { label: string; tone: LozengeTone };\n /** An action's shortcut (\"N\"). */\n shortcut?: string;\n /** Extra words it is found by (a customer's phone number, an old name). */\n keywords?: readonly string[];\n /** Records come first, then actions, then pages; \"action\" items fill the \"most used\" list. */\n kind?: \"record\" | \"action\" | \"page\";\n};\n\nexport type CommandGroup = { id: string; title: string; items: readonly CommandItem[] };\n\nexport type CommandPaletteProps = {\n isOpen?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n /** Actions and pages, most used first; matched here, diacritic-insensitive. */\n groups: readonly CommandGroup[];\n /** Records found by the server (codes, order numbers, names, phones); shown before the groups. */\n search?: (query: string, signal: AbortSignal) => Promise<readonly CommandGroup[]>;\n /** Shown while the query is empty, above the five most used actions. */\n recent?: readonly CommandItem[];\n onSelect: (item: CommandItem) => void;\n /** Bind ⌘K / Ctrl K to open and close it. */\n shortcut?: boolean;\n};\n\nconst SEARCH_DELAY = 150;\n\n/** Records first, then actions, then pages; a group ranks by its highest kind; equal groups keep their order. */\nfunction byKind(groups: readonly CommandGroup[]) {\n const order = { record: 0, action: 1, page: 2 } as const;\n const rank = (group: CommandGroup) => Math.min(...group.items.map((item) => order[item.kind ?? \"action\"]));\n return [...groups].sort((a, b) => rank(a) - rank(b));\n}\n\n/** The server's results for a query, debounced and cancelled when the query moves on. */\nfunction useSearch(query: string, search: CommandPaletteProps[\"search\"]) {\n const [state, setState] = React.useState<{ query: string; groups: readonly CommandGroup[]; loading: boolean; failed: boolean }>({\n query: \"\", groups: [], loading: false, failed: false,\n });\n React.useEffect(() => {\n if (!search || !query.trim()) {\n setState({ query, groups: [], loading: false, failed: false });\n return;\n }\n const controller = new AbortController();\n // The last answer stays (filtered by the caller) while the next one loads, so records do not flicker away.\n setState((current) => ({ ...current, loading: true, failed: false }));\n const timer = setTimeout(() => {\n search(query, controller.signal).then(\n (groups) => !controller.signal.aborted && setState({ query, groups, loading: false, failed: false }),\n () => !controller.signal.aborted && setState({ query, groups: [], loading: false, failed: true }),\n );\n }, SEARCH_DELAY);\n return () => {\n clearTimeout(timer);\n controller.abort();\n };\n }, [query, search]);\n return state;\n}\n\n/** A row's key: group and item, since ids repeat across groups (a product and an order both \"12\"). */\nconst rowKey = (group: CommandGroup, item: CommandItem) => `${group.id}\\u0000${item.id}`;\n\nfunction Row({ item, query, rowId }: { item: CommandItem; query: string; rowId: string }) {\n return (\n <ListBoxItem\n id={rowId}\n textValue={item.detail ? `${item.label} ${item.detail}` : item.label}\n data-slot=\"command-item\"\n data-kind={item.kind}\n className=\"flex min-h-10 cursor-default items-center gap-ds-150 rounded-ds-medium px-ds-150 text-body text-ds-text outline-hidden data-[focused]:bg-ds-background-selected data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[focused]:data-[hovered]:bg-ds-background-selected\"\n >\n {item.icon && <IconGlyph name={item.icon} size=\"small\" data-slot=\"command-item-icon\" className=\"text-ds-icon-subtle\" />}\n <span data-slot=\"command-item-label\" className=\"min-w-0 flex-1 truncate\">\n <Highlight text={item.label} query={query} />\n {item.detail && (\n <>\n <span aria-hidden> · </span>\n <bdi data-slot=\"command-item-detail\" className=\"font-ds-mono text-code text-ds-text-subtle\">\n <Highlight text={item.detail} query={query} />\n </bdi>\n </>\n )}\n </span>\n {item.status && <Lozenge tone={item.status.tone}>{item.status.label}</Lozenge>}\n {item.shortcut && <Kbd>{item.shortcut}</Kbd>}\n </ListBoxItem>\n );\n}\n\n/**\n * ⌘K / Ctrl K: find any record and run any action from the keyboard. 560px in the top third over the\n * blanket; one field, results grouped (records, then actions, then pages), 40px rows, the active row on\n * ds-background-selected, records with their status. Empty, it shows recent records and the five most used\n * actions. Typing matches labels, codes and keywords without regard to case or accents (\"durovic\" finds\n * \"Đurović\"), and asks `search` for records (the last answer stays while the next loads; a failed search says\n * so). Arrows move, Enter opens, Esc closes and returns focus. Rows are keyed by group and id, so ids may repeat\n * across groups. When records arrive after the actions, the active row stays where it was (React Aria's\n * Autocomplete keeps its virtual focus); arrows reach the records first in the list.\n * Everything here must also be reachable through visible UI.\n */\nexport function CommandPalette({ isOpen, defaultOpen, onOpenChange, groups, search, recent = [], onSelect, shortcut }: CommandPaletteProps) {\n const { locale } = useLocale();\n const [own, setOwn] = React.useState(defaultOpen ?? false);\n const open = isOpen ?? own;\n const setOpen = (next: boolean) => {\n if (isOpen === undefined) setOwn(next);\n onOpenChange?.(next);\n };\n const latest = React.useRef({ open, setOpen });\n latest.current = { open, setOpen };\n\n React.useEffect(() => {\n if (!shortcut) return;\n // ⌘K on Apple platforms (Ctrl K there is \"delete to end of line\" in every field), Ctrl K elsewhere. The\n // physical key counts too, for Cyrillic and Greek layouts; a key an editor already handled is left alone.\n const apple = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);\n const listener = (event: KeyboardEvent) => {\n if (event.defaultPrevented || event.isComposing || event.repeat || event.altKey || event.shiftKey) return;\n const modifier = apple ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;\n if (modifier && (event.key.toLowerCase() === \"k\" || event.code === \"KeyK\")) {\n event.preventDefault();\n latest.current.setOpen(!latest.current.open);\n }\n };\n document.addEventListener(\"keydown\", listener);\n return () => document.removeEventListener(\"keydown\", listener);\n }, [shortcut]);\n\n const [query, setQuery] = React.useState(\"\");\n // A new opening starts from an empty query.\n const [wasOpen, setWasOpen] = React.useState(open);\n if (wasOpen !== open) {\n setWasOpen(open);\n if (open) setQuery(\"\");\n }\n const remote = useSearch(query, search);\n const empty = !query.trim();\n\n const shown: CommandGroup[] = React.useMemo(() => {\n if (empty) {\n const actions = groups.flatMap((group) => group.items).filter((item) => (item.kind ?? \"action\") === \"action\").slice(0, 5);\n return [\n ...(recent.length ? [{ id: \"__recent\", title: recentRecordsLabel(locale), items: recent }] : []),\n ...(actions.length ? [{ id: \"__frequent\", title: frequentActionsLabel(locale), items: actions }] : []),\n ];\n }\n const local = groups\n .map((group) => ({ ...group, items: group.items.filter((item) => matchesQuery(query, item.label, item.detail, ...(item.keywords ?? []))) }))\n .filter((group) => group.items.length);\n // The newest answer, or the previous one (still matching the query) while the next one loads.\n const found = (remote.query === query ? remote.groups : remote.groups.map((group) => ({ ...group, items: group.items.filter((item) => matchesQuery(query, item.label, item.detail, ...(item.keywords ?? []))) })))\n .filter((group) => group.items.length);\n return byKind([...found, ...local]);\n }, [empty, groups, recent, locale, query, remote]);\n\n const items = React.useMemo(() => new Map(shown.flatMap((group) => group.items.map((item) => [rowKey(group, item), item] as const))), [shown]);\n const hints = commandHints(locale);\n\n return (\n <ModalOverlay\n isOpen={open}\n onOpenChange={setOpen}\n isDismissable\n data-slot=\"command-palette-overlay\"\n className=\"fixed inset-0 z-50 flex items-start justify-center bg-ds-blanket px-ds-200 pt-[15dvh] transition-opacity duration-(--ds-duration-medium) data-[entering]:opacity-0 data-[exiting]:opacity-0 motion-reduce:transition-none\"\n >\n <Modal\n data-slot=\"command-palette\"\n className=\"flex max-h-[70dvh] w-full max-w-140 flex-col overflow-hidden rounded-ds-xlarge bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden\"\n >\n <AriaDialog aria-label={commandPaletteLabel(locale)} data-slot=\"command-palette-dialog\" className=\"flex min-h-0 flex-1 flex-col outline-hidden\">\n <div\n className=\"flex min-h-0 flex-1 flex-col\"\n // Esc closes at once, as the footer says (the search field would otherwise clear itself first).\n onKeyDownCapture={(event) => {\n if (event.key === \"Escape\" && !event.nativeEvent.isComposing) {\n event.preventDefault();\n event.stopPropagation();\n setOpen(false);\n }\n }}\n >\n <Autocomplete inputValue={query} onInputChange={setQuery}>\n <SearchField aria-label={commandSearchLabel(locale)} autoFocus data-slot=\"command-palette-search\" className=\"flex min-h-13 items-center gap-ds-150 border-b border-ds-border px-ds-200\">\n <IconGlyph name=\"search\" className=\"size-5 shrink-0 text-ds-icon-subtle\" />\n <Input\n placeholder={commandSearchLabel(locale)}\n data-slot=\"command-palette-input\"\n className=\"min-w-0 flex-1 bg-transparent text-body text-ds-text outline-hidden placeholder:text-ds-text-subtlest [&::-webkit-search-cancel-button]:hidden\"\n />\n <Kbd>Esc</Kbd>\n </SearchField>\n <ListBox\n aria-label={commandPaletteLabel(locale)}\n data-slot=\"command-palette-results\"\n onAction={(key) => {\n const item = items.get(String(key));\n if (!item) return;\n setOpen(false);\n onSelect(item);\n }}\n renderEmptyState={() => (\n <div data-slot=\"command-palette-empty\" className=\"px-ds-200 py-ds-300 text-center text-body text-ds-text-subtle\">\n {remote.loading ? loadingLabel(locale) : remote.failed ? actionFailedLabel(locale) : empty ? null : noMatchLabel(locale, query.trim())}\n </div>\n )}\n className=\"min-h-0 flex-1 overflow-y-auto p-ds-100 outline-hidden\"\n >\n {shown.map((group) => (\n <ListBoxSection key={group.id} id={group.id} data-slot=\"command-palette-group\" className=\"flex flex-col\">\n <Header data-slot=\"command-palette-group-title\" className=\"px-ds-150 pt-ds-150 pb-ds-050 text-heading-xxsmall text-ds-text-subtle\">\n {group.title}\n </Header>\n {group.items.map((item) => <Row key={rowKey(group, item)} rowId={rowKey(group, item)} item={item} query={empty ? \"\" : query} />)}\n </ListBoxSection>\n ))}\n </ListBox>\n <span aria-live=\"polite\" className=\"sr-only\" data-slot=\"command-palette-status\">\n {remote.loading ? loadingLabel(locale) : \"\"}\n </span>\n </Autocomplete>\n <div data-slot=\"command-palette-footer\" className=\"flex flex-wrap items-center gap-ds-300 border-t border-ds-border bg-ds-surface-sunken px-ds-200 py-ds-100 text-body-small text-ds-text-subtle\">\n <span className=\"flex items-center gap-ds-050\"><Kbd>↑</Kbd><Kbd>↓</Kbd>{hints.move}</span>\n <span className=\"flex items-center gap-ds-050\"><Kbd>↵</Kbd>{hints.open}</span>\n <span className=\"flex items-center gap-ds-050\"><Kbd>Esc</Kbd>{hints.close}</span>\n </div>\n </div>\n </AriaDialog>\n </Modal>\n </ModalOverlay>\n );\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type IconName } from "../display/icon.js";
|
|
3
|
+
import { type BadgeTone } from "../display/badge.js";
|
|
4
|
+
export type CommandItem = {
|
|
5
|
+
id: string;
|
|
6
|
+
/** "Pro plan", "Create order". */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Beside the label in mono: a code, an order number ("ORD-482"). */
|
|
9
|
+
detail?: string;
|
|
10
|
+
icon?: IconName;
|
|
11
|
+
/** A record's status ("Available", success). */
|
|
12
|
+
status?: {
|
|
13
|
+
label: string;
|
|
14
|
+
tone: BadgeTone;
|
|
15
|
+
};
|
|
16
|
+
/** An action's shortcut ("N"). */
|
|
17
|
+
shortcut?: string;
|
|
18
|
+
/** Extra words it is found by (a customer's phone number, an old name). */
|
|
19
|
+
keywords?: readonly string[];
|
|
20
|
+
/** Records come first, then actions, then pages; "action" items fill the "most used" list. */
|
|
21
|
+
kind?: "record" | "action" | "page";
|
|
22
|
+
};
|
|
23
|
+
export type CommandGroup = {
|
|
24
|
+
id: string;
|
|
25
|
+
title: string;
|
|
26
|
+
items: readonly CommandItem[];
|
|
27
|
+
};
|
|
28
|
+
export type CommandProps = {
|
|
29
|
+
isOpen?: boolean;
|
|
30
|
+
defaultOpen?: boolean;
|
|
31
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
32
|
+
/** Actions and pages, most used first; matched here, diacritic-insensitive. */
|
|
33
|
+
groups: readonly CommandGroup[];
|
|
34
|
+
/** Records found by the server (codes, order numbers, names, phones); shown before the groups. */
|
|
35
|
+
search?: (query: string, signal: AbortSignal) => Promise<readonly CommandGroup[]>;
|
|
36
|
+
/** Shown while the query is empty, above the five most used actions. */
|
|
37
|
+
recent?: readonly CommandItem[];
|
|
38
|
+
onSelect: (item: CommandItem) => void;
|
|
39
|
+
/** Bind ⌘K / Ctrl K to open and close it. */
|
|
40
|
+
shortcut?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* ⌘K / Ctrl K: find any record and run any action from the keyboard. 560px in the top third over the
|
|
44
|
+
* blanket; one field, results grouped (records, then actions, then pages), 40px rows, the active row on
|
|
45
|
+
* ds-background-selected, records with their status. Empty, it shows recent records and the five most used
|
|
46
|
+
* actions. Typing matches labels, codes and keywords without regard to case or accents ("durovic" finds
|
|
47
|
+
* "Đurović"), and asks `search` for records (the last answer stays while the next loads; a failed search says
|
|
48
|
+
* so). Arrows move, Enter opens, Esc closes and returns focus. Rows are keyed by group and id, so ids may repeat
|
|
49
|
+
* across groups. When records arrive after the actions, the active row stays where it was (React Aria's
|
|
50
|
+
* Autocomplete keeps its virtual focus); arrows reach the records first in the list.
|
|
51
|
+
* Everything here must also be reachable through visible UI.
|
|
52
|
+
*/
|
|
53
|
+
export declare function Command({ isOpen, defaultOpen, onOpenChange, groups, search, recent, onSelect, shortcut }: CommandProps): React.JSX.Element;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Autocomplete, Dialog as AriaDialog, Header, Input, ListBox, ListBoxItem, ListBoxSection, Modal, ModalOverlay, SearchField, useLocale, } from "react-aria-components";
|
|
5
|
+
import { IconGlyph } from "../display/icon.js";
|
|
6
|
+
import { Kbd } from "../display/kbd.js";
|
|
7
|
+
import { Badge } from "../display/badge.js";
|
|
8
|
+
import { actionFailedLabel, commandHints, commandPaletteLabel, commandSearchLabel, frequentActionsLabel, loadingLabel, noMatchLabel, recentRecordsLabel } from "../i18n.js";
|
|
9
|
+
import { Highlight, matchesQuery } from "../selection/match.js";
|
|
10
|
+
const SEARCH_DELAY = 150;
|
|
11
|
+
/** Records first, then actions, then pages; a group ranks by its highest kind; equal groups keep their order. */
|
|
12
|
+
function byKind(groups) {
|
|
13
|
+
const order = { record: 0, action: 1, page: 2 };
|
|
14
|
+
const rank = (group) => Math.min(...group.items.map((item) => order[item.kind ?? "action"]));
|
|
15
|
+
return [...groups].sort((a, b) => rank(a) - rank(b));
|
|
16
|
+
}
|
|
17
|
+
/** The server's results for a query, debounced and cancelled when the query moves on. */
|
|
18
|
+
function useSearch(query, search) {
|
|
19
|
+
const [state, setState] = React.useState({
|
|
20
|
+
query: "", groups: [], loading: false, failed: false,
|
|
21
|
+
});
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
if (!search || !query.trim()) {
|
|
24
|
+
setState({ query, groups: [], loading: false, failed: false });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const controller = new AbortController();
|
|
28
|
+
// The last answer stays (filtered by the caller) while the next one loads, so records do not flicker away.
|
|
29
|
+
setState((current) => ({ ...current, loading: true, failed: false }));
|
|
30
|
+
const timer = setTimeout(() => {
|
|
31
|
+
search(query, controller.signal).then((groups) => !controller.signal.aborted && setState({ query, groups, loading: false, failed: false }), () => !controller.signal.aborted && setState({ query, groups: [], loading: false, failed: true }));
|
|
32
|
+
}, SEARCH_DELAY);
|
|
33
|
+
return () => {
|
|
34
|
+
clearTimeout(timer);
|
|
35
|
+
controller.abort();
|
|
36
|
+
};
|
|
37
|
+
}, [query, search]);
|
|
38
|
+
return state;
|
|
39
|
+
}
|
|
40
|
+
/** A row's key: group and item, since ids repeat across groups (a product and an order both "12"). */
|
|
41
|
+
const rowKey = (group, item) => `${group.id}\u0000${item.id}`;
|
|
42
|
+
function Row({ item, query, rowId }) {
|
|
43
|
+
return (_jsxs(ListBoxItem, { id: rowId, textValue: item.detail ? `${item.label} ${item.detail}` : item.label, "data-slot": "command-item", "data-kind": item.kind, className: "flex min-h-10 cursor-default items-center gap-ds-150 rounded-ds-medium px-ds-150 text-body text-ds-text outline-hidden data-[focused]:bg-ds-background-selected data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[focused]:data-[hovered]:bg-ds-background-selected", children: [item.icon && _jsx(IconGlyph, { name: item.icon, size: "small", "data-slot": "command-item-icon", className: "text-ds-icon-subtle" }), _jsxs("span", { "data-slot": "command-item-label", className: "min-w-0 flex-1 truncate", children: [_jsx(Highlight, { text: item.label, query: query }), item.detail && (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, children: " \u00B7 " }), _jsx("bdi", { "data-slot": "command-item-detail", className: "font-ds-mono text-code text-ds-text-subtle", children: _jsx(Highlight, { text: item.detail, query: query }) })] }))] }), item.status && _jsx(Badge, { tone: item.status.tone, children: item.status.label }), item.shortcut && _jsx(Kbd, { children: item.shortcut })] }));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* ⌘K / Ctrl K: find any record and run any action from the keyboard. 560px in the top third over the
|
|
47
|
+
* blanket; one field, results grouped (records, then actions, then pages), 40px rows, the active row on
|
|
48
|
+
* ds-background-selected, records with their status. Empty, it shows recent records and the five most used
|
|
49
|
+
* actions. Typing matches labels, codes and keywords without regard to case or accents ("durovic" finds
|
|
50
|
+
* "Đurović"), and asks `search` for records (the last answer stays while the next loads; a failed search says
|
|
51
|
+
* so). Arrows move, Enter opens, Esc closes and returns focus. Rows are keyed by group and id, so ids may repeat
|
|
52
|
+
* across groups. When records arrive after the actions, the active row stays where it was (React Aria's
|
|
53
|
+
* Autocomplete keeps its virtual focus); arrows reach the records first in the list.
|
|
54
|
+
* Everything here must also be reachable through visible UI.
|
|
55
|
+
*/
|
|
56
|
+
export function Command({ isOpen, defaultOpen, onOpenChange, groups, search, recent = [], onSelect, shortcut }) {
|
|
57
|
+
const { locale } = useLocale();
|
|
58
|
+
const [own, setOwn] = React.useState(defaultOpen ?? false);
|
|
59
|
+
const open = isOpen ?? own;
|
|
60
|
+
const setOpen = (next) => {
|
|
61
|
+
if (isOpen === undefined)
|
|
62
|
+
setOwn(next);
|
|
63
|
+
onOpenChange?.(next);
|
|
64
|
+
};
|
|
65
|
+
const latest = React.useRef({ open, setOpen });
|
|
66
|
+
latest.current = { open, setOpen };
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
if (!shortcut)
|
|
69
|
+
return;
|
|
70
|
+
// ⌘K on Apple platforms (Ctrl K there is "delete to end of line" in every field), Ctrl K elsewhere. The
|
|
71
|
+
// physical key counts too, for Cyrillic and Greek layouts; a key an editor already handled is left alone.
|
|
72
|
+
const apple = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
|
|
73
|
+
const listener = (event) => {
|
|
74
|
+
if (event.defaultPrevented || event.isComposing || event.repeat || event.altKey || event.shiftKey)
|
|
75
|
+
return;
|
|
76
|
+
const modifier = apple ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;
|
|
77
|
+
if (modifier && (event.key.toLowerCase() === "k" || event.code === "KeyK")) {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
latest.current.setOpen(!latest.current.open);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
document.addEventListener("keydown", listener);
|
|
83
|
+
return () => document.removeEventListener("keydown", listener);
|
|
84
|
+
}, [shortcut]);
|
|
85
|
+
const [query, setQuery] = React.useState("");
|
|
86
|
+
// A new opening starts from an empty query.
|
|
87
|
+
const [wasOpen, setWasOpen] = React.useState(open);
|
|
88
|
+
if (wasOpen !== open) {
|
|
89
|
+
setWasOpen(open);
|
|
90
|
+
if (open)
|
|
91
|
+
setQuery("");
|
|
92
|
+
}
|
|
93
|
+
const remote = useSearch(query, search);
|
|
94
|
+
const empty = !query.trim();
|
|
95
|
+
const shown = React.useMemo(() => {
|
|
96
|
+
if (empty) {
|
|
97
|
+
const actions = groups.flatMap((group) => group.items).filter((item) => (item.kind ?? "action") === "action").slice(0, 5);
|
|
98
|
+
return [
|
|
99
|
+
...(recent.length ? [{ id: "__recent", title: recentRecordsLabel(locale), items: recent }] : []),
|
|
100
|
+
...(actions.length ? [{ id: "__frequent", title: frequentActionsLabel(locale), items: actions }] : []),
|
|
101
|
+
];
|
|
102
|
+
}
|
|
103
|
+
const local = groups
|
|
104
|
+
.map((group) => ({ ...group, items: group.items.filter((item) => matchesQuery(query, item.label, item.detail, ...(item.keywords ?? []))) }))
|
|
105
|
+
.filter((group) => group.items.length);
|
|
106
|
+
// The newest answer, or the previous one (still matching the query) while the next one loads.
|
|
107
|
+
const found = (remote.query === query ? remote.groups : remote.groups.map((group) => ({ ...group, items: group.items.filter((item) => matchesQuery(query, item.label, item.detail, ...(item.keywords ?? []))) })))
|
|
108
|
+
.filter((group) => group.items.length);
|
|
109
|
+
return byKind([...found, ...local]);
|
|
110
|
+
}, [empty, groups, recent, locale, query, remote]);
|
|
111
|
+
const items = React.useMemo(() => new Map(shown.flatMap((group) => group.items.map((item) => [rowKey(group, item), item]))), [shown]);
|
|
112
|
+
const hints = commandHints(locale);
|
|
113
|
+
return (_jsx(ModalOverlay, { isOpen: open, onOpenChange: setOpen, isDismissable: true, "data-slot": "command-overlay", className: "fixed inset-0 z-50 flex items-start justify-center bg-ds-blanket px-ds-200 pt-[15dvh] transition-opacity duration-(--ds-duration-medium) data-[entering]:opacity-0 data-[exiting]:opacity-0 motion-reduce:transition-none", children: _jsx(Modal, { "data-slot": "command", className: "flex max-h-[70dvh] w-full max-w-140 flex-col overflow-hidden rounded-ds-xlarge bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden", children: _jsx(AriaDialog, { "aria-label": commandPaletteLabel(locale), "data-slot": "command-dialog", className: "flex min-h-0 flex-1 flex-col outline-hidden", children: _jsxs("div", { className: "flex min-h-0 flex-1 flex-col",
|
|
114
|
+
// Esc closes at once, as the footer says (the search field would otherwise clear itself first).
|
|
115
|
+
onKeyDownCapture: (event) => {
|
|
116
|
+
if (event.key === "Escape" && !event.nativeEvent.isComposing) {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
event.stopPropagation();
|
|
119
|
+
setOpen(false);
|
|
120
|
+
}
|
|
121
|
+
}, children: [_jsxs(Autocomplete, { inputValue: query, onInputChange: setQuery, children: [_jsxs(SearchField, { "aria-label": commandSearchLabel(locale), autoFocus: true, "data-slot": "command-search", className: "flex min-h-13 items-center gap-ds-150 border-b border-ds-border px-ds-200", children: [_jsx(IconGlyph, { name: "search", className: "size-5 shrink-0 text-ds-icon-subtle" }), _jsx(Input, { placeholder: commandSearchLabel(locale), "data-slot": "command-input", className: "min-w-0 flex-1 bg-transparent text-body text-ds-text outline-hidden placeholder:text-ds-text-subtlest [&::-webkit-search-cancel-button]:hidden" }), _jsx(Kbd, { children: "Esc" })] }), _jsx(ListBox, { "aria-label": commandPaletteLabel(locale), "data-slot": "command-results", onAction: (key) => {
|
|
122
|
+
const item = items.get(String(key));
|
|
123
|
+
if (!item)
|
|
124
|
+
return;
|
|
125
|
+
setOpen(false);
|
|
126
|
+
onSelect(item);
|
|
127
|
+
}, renderEmptyState: () => (_jsx("div", { "data-slot": "command-empty", className: "px-ds-200 py-ds-300 text-center text-body text-ds-text-subtle", children: remote.loading ? loadingLabel(locale) : remote.failed ? actionFailedLabel(locale) : empty ? null : noMatchLabel(locale, query.trim()) })), className: "min-h-0 flex-1 overflow-y-auto p-ds-100 outline-hidden", children: shown.map((group) => (_jsxs(ListBoxSection, { id: group.id, "data-slot": "command-group", className: "flex flex-col", children: [_jsx(Header, { "data-slot": "command-group-title", className: "px-ds-150 pt-ds-150 pb-ds-050 text-heading-xxsmall text-ds-text-subtle", children: group.title }), group.items.map((item) => _jsx(Row, { rowId: rowKey(group, item), item: item, query: empty ? "" : query }, rowKey(group, item)))] }, group.id))) }), _jsx("span", { "aria-live": "polite", className: "sr-only", "data-slot": "command-status", children: remote.loading ? loadingLabel(locale) : "" })] }), _jsxs("div", { "data-slot": "command-footer", className: "flex flex-wrap items-center gap-ds-300 border-t border-ds-border bg-ds-surface-sunken px-ds-200 py-ds-100 text-body-small text-ds-text-subtle", children: [_jsxs("span", { className: "flex items-center gap-ds-050", children: [_jsx(Kbd, { children: "\u2191" }), _jsx(Kbd, { children: "\u2193" }), hints.move] }), _jsxs("span", { className: "flex items-center gap-ds-050", children: [_jsx(Kbd, { children: "\u21B5" }), hints.open] }), _jsxs("span", { className: "flex items-center gap-ds-050", children: [_jsx(Kbd, { children: "Esc" }), hints.close] })] })] }) }) }) }));
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/overlay/command.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,YAAY,EACZ,MAAM,IAAI,UAAU,EACpB,MAAM,EACN,KAAK,EACL,OAAO,EACP,WAAW,EACX,cAAc,EACd,KAAK,EACL,YAAY,EACZ,WAAW,EACX,SAAS,GACV,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAiB,MAAM,iBAAiB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,KAAK,EAAkB,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,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KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAC,GAAG,IAA2B,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,IAAtF,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAuE,CAAC,KAJ7G,KAAK,CAAC,EAAE,CAKZ,CAClB,CAAC,GACM,EACV,4BAAgB,QAAQ,EAAC,SAAS,EAAC,SAAS,eAAW,gBAAgB,YACpE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,GACtC,IACM,EACf,4BAAe,gBAAgB,EAAC,SAAS,EAAC,+IAA+I,aACvL,gBAAM,SAAS,EAAC,8BAA8B,aAAC,KAAC,GAAG,yBAAQ,EAAA,KAAC,GAAG,yBAAQ,EAAC,KAAK,CAAC,IAAI,IAAQ,EAC1F,gBAAM,SAAS,EAAC,8BAA8B,aAAC,KAAC,GAAG,yBAAQ,EAAC,KAAK,CAAC,IAAI,IAAQ,EAC9E,gBAAM,SAAS,EAAC,8BAA8B,aAAC,KAAC,GAAG,sBAAU,EAAC,KAAK,CAAC,KAAK,IAAQ,IAC7E,IACA,GACK,GACP,GACK,CAChB,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n Autocomplete,\n Dialog as AriaDialog,\n Header,\n Input,\n ListBox,\n ListBoxItem,\n ListBoxSection,\n Modal,\n ModalOverlay,\n SearchField,\n useLocale,\n} from \"react-aria-components\";\n\nimport { IconGlyph, type IconName } from \"../display/icon\";\nimport { Kbd } from \"../display/kbd\";\nimport { Badge, type BadgeTone } from \"../display/badge\";\nimport { actionFailedLabel, commandHints, commandPaletteLabel, commandSearchLabel, frequentActionsLabel, loadingLabel, noMatchLabel, recentRecordsLabel } from \"../i18n\";\nimport { Highlight, matchesQuery } from \"../selection/match\";\n\nexport type CommandItem = {\n id: string;\n /** \"Pro plan\", \"Create order\". */\n label: string;\n /** Beside the label in mono: a code, an order number (\"ORD-482\"). */\n detail?: string;\n icon?: IconName;\n /** A record's status (\"Available\", success). */\n status?: { label: string; tone: BadgeTone };\n /** An action's shortcut (\"N\"). */\n shortcut?: string;\n /** Extra words it is found by (a customer's phone number, an old name). */\n keywords?: readonly string[];\n /** Records come first, then actions, then pages; \"action\" items fill the \"most used\" list. */\n kind?: \"record\" | \"action\" | \"page\";\n};\n\nexport type CommandGroup = { id: string; title: string; items: readonly CommandItem[] };\n\nexport type CommandProps = {\n isOpen?: boolean;\n defaultOpen?: boolean;\n onOpenChange?: (isOpen: boolean) => void;\n /** Actions and pages, most used first; matched here, diacritic-insensitive. */\n groups: readonly CommandGroup[];\n /** Records found by the server (codes, order numbers, names, phones); shown before the groups. */\n search?: (query: string, signal: AbortSignal) => Promise<readonly CommandGroup[]>;\n /** Shown while the query is empty, above the five most used actions. */\n recent?: readonly CommandItem[];\n onSelect: (item: CommandItem) => void;\n /** Bind ⌘K / Ctrl K to open and close it. */\n shortcut?: boolean;\n};\n\nconst SEARCH_DELAY = 150;\n\n/** Records first, then actions, then pages; a group ranks by its highest kind; equal groups keep their order. */\nfunction byKind(groups: readonly CommandGroup[]) {\n const order = { record: 0, action: 1, page: 2 } as const;\n const rank = (group: CommandGroup) => Math.min(...group.items.map((item) => order[item.kind ?? \"action\"]));\n return [...groups].sort((a, b) => rank(a) - rank(b));\n}\n\n/** The server's results for a query, debounced and cancelled when the query moves on. */\nfunction useSearch(query: string, search: CommandProps[\"search\"]) {\n const [state, setState] = React.useState<{ query: string; groups: readonly CommandGroup[]; loading: boolean; failed: boolean }>({\n query: \"\", groups: [], loading: false, failed: false,\n });\n React.useEffect(() => {\n if (!search || !query.trim()) {\n setState({ query, groups: [], loading: false, failed: false });\n return;\n }\n const controller = new AbortController();\n // The last answer stays (filtered by the caller) while the next one loads, so records do not flicker away.\n setState((current) => ({ ...current, loading: true, failed: false }));\n const timer = setTimeout(() => {\n search(query, controller.signal).then(\n (groups) => !controller.signal.aborted && setState({ query, groups, loading: false, failed: false }),\n () => !controller.signal.aborted && setState({ query, groups: [], loading: false, failed: true }),\n );\n }, SEARCH_DELAY);\n return () => {\n clearTimeout(timer);\n controller.abort();\n };\n }, [query, search]);\n return state;\n}\n\n/** A row's key: group and item, since ids repeat across groups (a product and an order both \"12\"). */\nconst rowKey = (group: CommandGroup, item: CommandItem) => `${group.id}\\u0000${item.id}`;\n\nfunction Row({ item, query, rowId }: { item: CommandItem; query: string; rowId: string }) {\n return (\n <ListBoxItem\n id={rowId}\n textValue={item.detail ? `${item.label} ${item.detail}` : item.label}\n data-slot=\"command-item\"\n data-kind={item.kind}\n className=\"flex min-h-10 cursor-default items-center gap-ds-150 rounded-ds-medium px-ds-150 text-body text-ds-text outline-hidden data-[focused]:bg-ds-background-selected data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[focused]:data-[hovered]:bg-ds-background-selected\"\n >\n {item.icon && <IconGlyph name={item.icon} size=\"small\" data-slot=\"command-item-icon\" className=\"text-ds-icon-subtle\" />}\n <span data-slot=\"command-item-label\" className=\"min-w-0 flex-1 truncate\">\n <Highlight text={item.label} query={query} />\n {item.detail && (\n <>\n <span aria-hidden> · </span>\n <bdi data-slot=\"command-item-detail\" className=\"font-ds-mono text-code text-ds-text-subtle\">\n <Highlight text={item.detail} query={query} />\n </bdi>\n </>\n )}\n </span>\n {item.status && <Badge tone={item.status.tone}>{item.status.label}</Badge>}\n {item.shortcut && <Kbd>{item.shortcut}</Kbd>}\n </ListBoxItem>\n );\n}\n\n/**\n * ⌘K / Ctrl K: find any record and run any action from the keyboard. 560px in the top third over the\n * blanket; one field, results grouped (records, then actions, then pages), 40px rows, the active row on\n * ds-background-selected, records with their status. Empty, it shows recent records and the five most used\n * actions. Typing matches labels, codes and keywords without regard to case or accents (\"durovic\" finds\n * \"Đurović\"), and asks `search` for records (the last answer stays while the next loads; a failed search says\n * so). Arrows move, Enter opens, Esc closes and returns focus. Rows are keyed by group and id, so ids may repeat\n * across groups. When records arrive after the actions, the active row stays where it was (React Aria's\n * Autocomplete keeps its virtual focus); arrows reach the records first in the list.\n * Everything here must also be reachable through visible UI.\n */\nexport function Command({ isOpen, defaultOpen, onOpenChange, groups, search, recent = [], onSelect, shortcut }: CommandProps) {\n const { locale } = useLocale();\n const [own, setOwn] = React.useState(defaultOpen ?? false);\n const open = isOpen ?? own;\n const setOpen = (next: boolean) => {\n if (isOpen === undefined) setOwn(next);\n onOpenChange?.(next);\n };\n const latest = React.useRef({ open, setOpen });\n latest.current = { open, setOpen };\n\n React.useEffect(() => {\n if (!shortcut) return;\n // ⌘K on Apple platforms (Ctrl K there is \"delete to end of line\" in every field), Ctrl K elsewhere. The\n // physical key counts too, for Cyrillic and Greek layouts; a key an editor already handled is left alone.\n const apple = /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);\n const listener = (event: KeyboardEvent) => {\n if (event.defaultPrevented || event.isComposing || event.repeat || event.altKey || event.shiftKey) return;\n const modifier = apple ? event.metaKey && !event.ctrlKey : event.ctrlKey && !event.metaKey;\n if (modifier && (event.key.toLowerCase() === \"k\" || event.code === \"KeyK\")) {\n event.preventDefault();\n latest.current.setOpen(!latest.current.open);\n }\n };\n document.addEventListener(\"keydown\", listener);\n return () => document.removeEventListener(\"keydown\", listener);\n }, [shortcut]);\n\n const [query, setQuery] = React.useState(\"\");\n // A new opening starts from an empty query.\n const [wasOpen, setWasOpen] = React.useState(open);\n if (wasOpen !== open) {\n setWasOpen(open);\n if (open) setQuery(\"\");\n }\n const remote = useSearch(query, search);\n const empty = !query.trim();\n\n const shown: CommandGroup[] = React.useMemo(() => {\n if (empty) {\n const actions = groups.flatMap((group) => group.items).filter((item) => (item.kind ?? \"action\") === \"action\").slice(0, 5);\n return [\n ...(recent.length ? [{ id: \"__recent\", title: recentRecordsLabel(locale), items: recent }] : []),\n ...(actions.length ? [{ id: \"__frequent\", title: frequentActionsLabel(locale), items: actions }] : []),\n ];\n }\n const local = groups\n .map((group) => ({ ...group, items: group.items.filter((item) => matchesQuery(query, item.label, item.detail, ...(item.keywords ?? []))) }))\n .filter((group) => group.items.length);\n // The newest answer, or the previous one (still matching the query) while the next one loads.\n const found = (remote.query === query ? remote.groups : remote.groups.map((group) => ({ ...group, items: group.items.filter((item) => matchesQuery(query, item.label, item.detail, ...(item.keywords ?? []))) })))\n .filter((group) => group.items.length);\n return byKind([...found, ...local]);\n }, [empty, groups, recent, locale, query, remote]);\n\n const items = React.useMemo(() => new Map(shown.flatMap((group) => group.items.map((item) => [rowKey(group, item), item] as const))), [shown]);\n const hints = commandHints(locale);\n\n return (\n <ModalOverlay\n isOpen={open}\n onOpenChange={setOpen}\n isDismissable\n data-slot=\"command-overlay\"\n className=\"fixed inset-0 z-50 flex items-start justify-center bg-ds-blanket px-ds-200 pt-[15dvh] transition-opacity duration-(--ds-duration-medium) data-[entering]:opacity-0 data-[exiting]:opacity-0 motion-reduce:transition-none\"\n >\n <Modal\n data-slot=\"command\"\n className=\"flex max-h-[70dvh] w-full max-w-140 flex-col overflow-hidden rounded-ds-xlarge bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden\"\n >\n <AriaDialog aria-label={commandPaletteLabel(locale)} data-slot=\"command-dialog\" className=\"flex min-h-0 flex-1 flex-col outline-hidden\">\n <div\n className=\"flex min-h-0 flex-1 flex-col\"\n // Esc closes at once, as the footer says (the search field would otherwise clear itself first).\n onKeyDownCapture={(event) => {\n if (event.key === \"Escape\" && !event.nativeEvent.isComposing) {\n event.preventDefault();\n event.stopPropagation();\n setOpen(false);\n }\n }}\n >\n <Autocomplete inputValue={query} onInputChange={setQuery}>\n <SearchField aria-label={commandSearchLabel(locale)} autoFocus data-slot=\"command-search\" className=\"flex min-h-13 items-center gap-ds-150 border-b border-ds-border px-ds-200\">\n <IconGlyph name=\"search\" className=\"size-5 shrink-0 text-ds-icon-subtle\" />\n <Input\n placeholder={commandSearchLabel(locale)}\n data-slot=\"command-input\"\n className=\"min-w-0 flex-1 bg-transparent text-body text-ds-text outline-hidden placeholder:text-ds-text-subtlest [&::-webkit-search-cancel-button]:hidden\"\n />\n <Kbd>Esc</Kbd>\n </SearchField>\n <ListBox\n aria-label={commandPaletteLabel(locale)}\n data-slot=\"command-results\"\n onAction={(key) => {\n const item = items.get(String(key));\n if (!item) return;\n setOpen(false);\n onSelect(item);\n }}\n renderEmptyState={() => (\n <div data-slot=\"command-empty\" className=\"px-ds-200 py-ds-300 text-center text-body text-ds-text-subtle\">\n {remote.loading ? loadingLabel(locale) : remote.failed ? actionFailedLabel(locale) : empty ? null : noMatchLabel(locale, query.trim())}\n </div>\n )}\n className=\"min-h-0 flex-1 overflow-y-auto p-ds-100 outline-hidden\"\n >\n {shown.map((group) => (\n <ListBoxSection key={group.id} id={group.id} data-slot=\"command-group\" className=\"flex flex-col\">\n <Header data-slot=\"command-group-title\" className=\"px-ds-150 pt-ds-150 pb-ds-050 text-heading-xxsmall text-ds-text-subtle\">\n {group.title}\n </Header>\n {group.items.map((item) => <Row key={rowKey(group, item)} rowId={rowKey(group, item)} item={item} query={empty ? \"\" : query} />)}\n </ListBoxSection>\n ))}\n </ListBox>\n <span aria-live=\"polite\" className=\"sr-only\" data-slot=\"command-status\">\n {remote.loading ? loadingLabel(locale) : \"\"}\n </span>\n </Autocomplete>\n <div data-slot=\"command-footer\" className=\"flex flex-wrap items-center gap-ds-300 border-t border-ds-border bg-ds-surface-sunken px-ds-200 py-ds-100 text-body-small text-ds-text-subtle\">\n <span className=\"flex items-center gap-ds-050\"><Kbd>↑</Kbd><Kbd>↓</Kbd>{hints.move}</span>\n <span className=\"flex items-center gap-ds-050\"><Kbd>↵</Kbd>{hints.open}</span>\n <span className=\"flex items-center gap-ds-050\"><Kbd>Esc</Kbd>{hints.close}</span>\n </div>\n </div>\n </AriaDialog>\n </Modal>\n </ModalOverlay>\n );\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type Key } from "react-aria-components";
|
|
3
|
+
import { type MenuEntry } from "./floating.js";
|
|
4
|
+
export type ContextMenuProps = {
|
|
5
|
+
/**
|
|
6
|
+
* The region a right-click, a long press or Shift+F10 opens the menu on: a row, a card, a canvas. Or, to compose
|
|
7
|
+
* the menu from parts: a `ContextMenuTrigger` holding that region, followed by `MenuItem`, `MenuSection`,
|
|
8
|
+
* `MenuSubmenu` and `MenuSeparator`.
|
|
9
|
+
*/
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/** The menu as data; leave it out when composing with a `ContextMenuTrigger`. */
|
|
12
|
+
items?: readonly MenuEntry[];
|
|
13
|
+
onAction?: (id: Key) => void;
|
|
14
|
+
disabledKeys?: Iterable<Key>;
|
|
15
|
+
/** Names the menu ("Actions for ORD-482"). */
|
|
16
|
+
"aria-label": string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The actions for what is under the pointer, opened where it was pressed: right-click, a long press on touch, or
|
|
20
|
+
* Shift+F10 / the Menu key on whatever has keyboard focus inside. The same menu as Menu (sections, a destructive
|
|
21
|
+
* item last); focus goes back where it was on close. Never the only way to an action: put it in a visible Menu too.
|
|
22
|
+
*/
|
|
23
|
+
export type ContextMenuTriggerProps = {
|
|
24
|
+
/** The region that opens the menu. */
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
};
|
|
27
|
+
/** The region of a ContextMenu composed from parts; the ContextMenu's other children are the menu. */
|
|
28
|
+
export declare function ContextMenuTrigger({ children }: ContextMenuTriggerProps): React.JSX.Element;
|
|
29
|
+
export declare function ContextMenu({ children, items, onAction, disabledKeys, "aria-label": ariaLabel }: ContextMenuProps): React.JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Menu as AriaMenu, Popover as AriaPopover } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { useMotionAttribute } from "../defaults.js";
|
|
7
|
+
import { MenuBody, SCROLL, SURFACE } from "./floating.js";
|
|
8
|
+
/** How long a touch must rest to open the menu (ms). */
|
|
9
|
+
const LONG_PRESS = 500;
|
|
10
|
+
/** The region of a ContextMenu composed from parts; the ContextMenu's other children are the menu. */
|
|
11
|
+
export function ContextMenuTrigger({ children }) {
|
|
12
|
+
return _jsx(_Fragment, { children: children });
|
|
13
|
+
}
|
|
14
|
+
/** The target and the menu: from a `ContextMenuTrigger` and the parts after it, or the children and `items`. */
|
|
15
|
+
function splitTarget(children, items) {
|
|
16
|
+
const nodes = React.Children.toArray(children);
|
|
17
|
+
const trigger = nodes.find((node) => React.isValidElement(node) && node.type === ContextMenuTrigger);
|
|
18
|
+
if (!trigger)
|
|
19
|
+
return { target: children, menu: _jsx(MenuBody, { entries: items ?? [] }) };
|
|
20
|
+
return { target: trigger.props.children, menu: nodes.filter((node) => node !== trigger) };
|
|
21
|
+
}
|
|
22
|
+
export function ContextMenu({ children, items, onAction, disabledKeys, "aria-label": ariaLabel }) {
|
|
23
|
+
const { target, menu } = splitTarget(children, items);
|
|
24
|
+
const [point, setPoint] = React.useState(null);
|
|
25
|
+
const anchor = React.useRef(null);
|
|
26
|
+
const returnTo = React.useRef(null);
|
|
27
|
+
const timer = React.useRef(undefined);
|
|
28
|
+
const motion = useMotionAttribute();
|
|
29
|
+
const openAt = (x, y) => {
|
|
30
|
+
returnTo.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
31
|
+
setPoint({ x, y });
|
|
32
|
+
};
|
|
33
|
+
const close = () => {
|
|
34
|
+
setPoint(null);
|
|
35
|
+
returnTo.current?.focus();
|
|
36
|
+
};
|
|
37
|
+
const cancelPress = () => window.clearTimeout(timer.current);
|
|
38
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "context-menu-target", className: "contents", onContextMenu: (event) => {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
openAt(event.clientX, event.clientY);
|
|
41
|
+
}, onKeyDown: (event) => {
|
|
42
|
+
if (event.key === "ContextMenu" || (event.key === "F10" && event.shiftKey)) {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
const rect = event.target.getBoundingClientRect();
|
|
45
|
+
openAt(rect.left, rect.bottom);
|
|
46
|
+
}
|
|
47
|
+
}, onPointerDown: (event) => {
|
|
48
|
+
if (event.pointerType !== "touch")
|
|
49
|
+
return;
|
|
50
|
+
const { clientX, clientY } = event;
|
|
51
|
+
cancelPress();
|
|
52
|
+
timer.current = window.setTimeout(() => openAt(clientX, clientY), LONG_PRESS);
|
|
53
|
+
}, onPointerUp: cancelPress, onPointerCancel: cancelPress, onPointerMove: cancelPress, children: target }), point && _jsx("span", { ref: anchor, "aria-hidden": true, "data-slot": "context-menu-anchor", style: { position: "fixed", left: point.x, top: point.y, width: 0, height: 0 } }), _jsx(AriaPopover, { ...motion, triggerRef: anchor, isOpen: point !== null, onOpenChange: (open) => !open && close(), placement: "bottom start", offset: 2, "data-slot": "context-menu-popover", className: cn(SURFACE, "min-w-60 max-w-90"), children: _jsx(AriaMenu, { "aria-label": ariaLabel, autoFocus: "first", onAction: (id) => {
|
|
54
|
+
onAction?.(id);
|
|
55
|
+
close();
|
|
56
|
+
}, onClose: close, disabledKeys: disabledKeys, "data-slot": "context-menu", className: cn(SCROLL, "p-ds-050 outline-hidden"), children: menu }) })] }));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=context-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu.js","sourceRoot":"","sources":["../../src/overlay/context-menu.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,OAAO,I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C,EAAE,EAAE,EAAE;wBACf,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;wBACf,KAAK,EAAE,CAAC;oBACV,CAAC,EACD,OAAO,EAAE,KAAK,EACd,YAAY,EAAE,YAAY,eAChB,cAAc,EACxB,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,yBAAyB,CAAC,YAE/C,IAAI,GACI,GACC,IACb,CACJ,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Menu as AriaMenu, Popover as AriaPopover, type Key } from \"react-aria-components\";\nimport { cn } from \"../utils\";\nimport { useMotionAttribute } from \"../defaults\";\nimport { MenuBody, SCROLL, SURFACE, type MenuEntry } from \"./floating\";\n\nexport type ContextMenuProps = {\n /**\n * The region a right-click, a long press or Shift+F10 opens the menu on: a row, a card, a canvas. Or, to compose\n * the menu from parts: a `ContextMenuTrigger` holding that region, followed by `MenuItem`, `MenuSection`,\n * `MenuSubmenu` and `MenuSeparator`.\n */\n children: React.ReactNode;\n /** The menu as data; leave it out when composing with a `ContextMenuTrigger`. */\n items?: readonly MenuEntry[];\n onAction?: (id: Key) => void;\n disabledKeys?: Iterable<Key>;\n /** Names the menu (\"Actions for ORD-482\"). */\n \"aria-label\": string;\n};\n\n/** How long a touch must rest to open the menu (ms). */\nconst LONG_PRESS = 500;\n\n/**\n * The actions for what is under the pointer, opened where it was pressed: right-click, a long press on touch, or\n * Shift+F10 / the Menu key on whatever has keyboard focus inside. The same menu as Menu (sections, a destructive\n * item last); focus goes back where it was on close. Never the only way to an action: put it in a visible Menu too.\n */\nexport type ContextMenuTriggerProps = {\n /** The region that opens the menu. */\n children: React.ReactNode;\n};\n\n/** The region of a ContextMenu composed from parts; the ContextMenu's other children are the menu. */\nexport function ContextMenuTrigger({ children }: ContextMenuTriggerProps) {\n return <>{children}</>;\n}\n\n/** The target and the menu: from a `ContextMenuTrigger` and the parts after it, or the children and `items`. */\nfunction splitTarget(children: React.ReactNode, items: readonly MenuEntry[] | undefined) {\n const nodes = React.Children.toArray(children);\n const trigger = nodes.find((node) => React.isValidElement(node) && node.type === ContextMenuTrigger) as React.ReactElement<ContextMenuTriggerProps> | undefined;\n if (!trigger) return { target: children, menu: <MenuBody entries={items ?? []} /> };\n return { target: trigger.props.children, menu: nodes.filter((node) => node !== trigger) };\n}\n\nexport function ContextMenu({ children, items, onAction, disabledKeys, \"aria-label\": ariaLabel }: ContextMenuProps) {\n const { target, menu } = splitTarget(children, items);\n const [point, setPoint] = React.useState<{ x: number; y: number } | null>(null);\n const anchor = React.useRef<HTMLSpanElement>(null);\n const returnTo = React.useRef<HTMLElement | null>(null);\n const timer = React.useRef<number | undefined>(undefined);\n const motion = useMotionAttribute();\n const openAt = (x: number, y: number) => {\n returnTo.current = document.activeElement instanceof HTMLElement ? document.activeElement : null;\n setPoint({ x, y });\n };\n const close = () => {\n setPoint(null);\n returnTo.current?.focus();\n };\n const cancelPress = () => window.clearTimeout(timer.current);\n return (\n <>\n <span\n data-slot=\"context-menu-target\"\n className=\"contents\"\n onContextMenu={(event) => {\n event.preventDefault();\n openAt(event.clientX, event.clientY);\n }}\n onKeyDown={(event) => {\n if (event.key === \"ContextMenu\" || (event.key === \"F10\" && event.shiftKey)) {\n event.preventDefault();\n const rect = (event.target as HTMLElement).getBoundingClientRect();\n openAt(rect.left, rect.bottom);\n }\n }}\n onPointerDown={(event) => {\n if (event.pointerType !== \"touch\") return;\n const { clientX, clientY } = event;\n cancelPress();\n timer.current = window.setTimeout(() => openAt(clientX, clientY), LONG_PRESS);\n }}\n onPointerUp={cancelPress}\n onPointerCancel={cancelPress}\n onPointerMove={cancelPress}\n >\n {target}\n </span>\n {point && <span ref={anchor} aria-hidden data-slot=\"context-menu-anchor\" style={{ position: \"fixed\", left: point.x, top: point.y, width: 0, height: 0 }} />}\n <AriaPopover\n {...motion}\n triggerRef={anchor}\n isOpen={point !== null}\n onOpenChange={(open) => !open && close()}\n placement=\"bottom start\"\n offset={2}\n data-slot=\"context-menu-popover\"\n className={cn(SURFACE, \"min-w-60 max-w-90\")}\n >\n <AriaMenu\n aria-label={ariaLabel}\n autoFocus=\"first\"\n onAction={(id) => {\n onAction?.(id);\n close();\n }}\n onClose={close}\n disabledKeys={disabledKeys}\n data-slot=\"context-menu\"\n className={cn(SCROLL, \"p-ds-050 outline-hidden\")}\n >\n {menu}\n </AriaMenu>\n </AriaPopover>\n </>\n );\n}\n\n/* ── HoverCard ───────────────────────────────────────────────────────────── */\n"]}
|