@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,138 @@
|
|
|
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 { Button, ButtonContext, Select as AriaSelect, SelectValue, useLocale, } from "react-aria-components";
|
|
5
|
+
import { IconGlyph } from "../display/icon.js";
|
|
6
|
+
import { cn } from "../utils.js";
|
|
7
|
+
import { fieldRadiusClass, useRadius } from "../defaults.js";
|
|
8
|
+
import { ControlFieldError, FieldDescription, FieldLabel, forwardedInvalid, useErrorRowLink } from "../form/field-parts.js";
|
|
9
|
+
import { FIELD_ICON, FIELD_STACK } from "../form/styles.js";
|
|
10
|
+
import { useRequiredChoice } from "../form/validation.js";
|
|
11
|
+
import { moreCountLabel, removeItemLabel, selectAllLabel, selectPlaceholder, selectedCountLabel } from "../i18n.js";
|
|
12
|
+
import { hasContent } from "./choice-text.js";
|
|
13
|
+
import { ITEM_ICON, SelectPopover } from "./listbox.js";
|
|
14
|
+
import { SELECT_TRIGGER } from "./select.js";
|
|
15
|
+
/** 24px tag on `ds-radius-small`. */
|
|
16
|
+
export const TAG = "inline-flex h-6 max-w-full items-center gap-ds-050 rounded-ds-control-small bg-ds-background-neutral ps-ds-100 pe-ds-075 text-body-small text-ds-text";
|
|
17
|
+
export const TAG_REMOVE = "grid size-4 shrink-0 cursor-pointer place-items-center rounded-[max(var(--ds-radius-xsmall),calc(var(--ds-radius-control-small,var(--ds-radius-small))-4px))] text-ds-icon-subtle outline-hidden " +
|
|
18
|
+
"data-[hovered]:bg-ds-background-neutral-pressed data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused";
|
|
19
|
+
/**
|
|
20
|
+
* The frame around tags and trigger, drawn like a TextField: hover fill,
|
|
21
|
+
* the 2px focused edge while the trigger has keyboard focus or the menu is
|
|
22
|
+
* open, and the danger edge, which stays red while focused or open (compound
|
|
23
|
+
* variants sort after the single ones). The vertical padding centres a 24px
|
|
24
|
+
* tag row in the 36px control (1px borders).
|
|
25
|
+
*/
|
|
26
|
+
export const MULTI_FIELD = "flex min-h-ds-control w-full flex-wrap items-center gap-ds-050 rounded-ds-medium border border-ds-border-bold bg-ds-background-input py-[5px] ps-ds-100 pe-ds-075 " +
|
|
27
|
+
"transition-colors duration-(--ds-duration-instant) ease-ds-standard hover:bg-ds-background-input-hovered " +
|
|
28
|
+
"has-[[data-slot=multi-select-trigger][data-focus-visible]]:border-ds-border-focused has-[[data-slot=multi-select-trigger][data-focus-visible]]:outline-1 " +
|
|
29
|
+
"has-[[data-slot=multi-select-trigger][data-focus-visible]]:outline-solid has-[[data-slot=multi-select-trigger][data-focus-visible]]:-outline-offset-2 " +
|
|
30
|
+
"has-[[data-slot=multi-select-trigger][data-focus-visible]]:outline-ds-border-focused " +
|
|
31
|
+
"group-data-[open]:border-ds-border-focused group-data-[open]:outline-1 group-data-[open]:outline-solid group-data-[open]:-outline-offset-2 group-data-[open]:outline-ds-border-focused " +
|
|
32
|
+
"group-data-[invalid]:border-ds-border-danger group-data-[invalid]:outline-1 group-data-[invalid]:outline-solid group-data-[invalid]:-outline-offset-2 group-data-[invalid]:outline-ds-border-danger " +
|
|
33
|
+
"group-data-[invalid]:group-data-[open]:border-ds-border-danger group-data-[invalid]:group-data-[open]:outline-ds-border-danger " +
|
|
34
|
+
"group-data-[invalid]:has-[[data-slot=multi-select-trigger][data-focus-visible]]:border-ds-border-danger " +
|
|
35
|
+
"group-data-[invalid]:has-[[data-slot=multi-select-trigger][data-focus-visible]]:outline-ds-border-danger " +
|
|
36
|
+
"data-[disabled]:border-transparent data-[disabled]:bg-ds-background-disabled data-[disabled]:text-ds-text-disabled data-[disabled]:hover:bg-ds-background-disabled";
|
|
37
|
+
export const MULTI_FOOTER = "-mx-ds-050 -mb-ds-050 mt-ds-050 flex shrink-0 items-center justify-between gap-ds-200 border-t border-ds-border p-ds-050 ps-ds-100";
|
|
38
|
+
export const SELECT_ALL = "h-ds-control-compact cursor-pointer px-ds-050 text-body-strong text-ds-link outline-hidden underline-offset-3 data-[hovered]:underline " +
|
|
39
|
+
"data-[focus-visible]:underline data-[focus-visible]:decoration-2 data-[focus-visible]:decoration-ds-border-focused";
|
|
40
|
+
/** A plain button inside the Select: React Aria would otherwise wire every Button in it as the trigger. */
|
|
41
|
+
function OwnButton(props) {
|
|
42
|
+
return (_jsx(ButtonContext.Provider, { value: null, children: _jsx(Button, { ...props }) }));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Several values from a known list. Chosen values show as removable tags in
|
|
46
|
+
* the field; the menu stays open while picking (Esc or a click outside
|
|
47
|
+
* closes it); Backspace on the field removes the last visible tag. Named by a
|
|
48
|
+
* visible `label` or, where the context names it, an `aria-label`; an item's
|
|
49
|
+
* `icon` (a country flag) shows before its label in the list and in its tag
|
|
50
|
+
*.
|
|
51
|
+
*/
|
|
52
|
+
export function MultiSelect({ label, "aria-label": ariaLabel, items, selectedKeys, defaultSelectedKeys, onSelectionChange, maxVisibleTags, allowsSelectAll, placeholder, description, errorMessage: errorMessageProp, "aria-invalid": ariaInvalid, requiredValidation, isInvalid: isInvalidProp, ...rest }) {
|
|
53
|
+
const frameRadius = useRadius(undefined);
|
|
54
|
+
const { locale } = useLocale();
|
|
55
|
+
// Named as Select is: a non-empty aria-label replaces the visible label; an empty one counts as none.
|
|
56
|
+
const named = ariaLabel ? ariaLabel : undefined;
|
|
57
|
+
const showLabel = named === undefined && (ariaLabel === undefined || label != null);
|
|
58
|
+
const unnamed = named === undefined && label == null && !rest["aria-labelledby"];
|
|
59
|
+
React.useEffect(() => {
|
|
60
|
+
if (process.env.NODE_ENV !== "production" && unnamed) {
|
|
61
|
+
console.warn("MultiSelect: no accessible name. Give a label, or a non-empty aria-label where the context names the field.");
|
|
62
|
+
}
|
|
63
|
+
}, [unnamed]);
|
|
64
|
+
// The menu opens under the whole field (tags included), not under the trigger at its end.
|
|
65
|
+
const fieldRef = React.useRef(null);
|
|
66
|
+
const triggerRef = React.useRef(null);
|
|
67
|
+
// The last key pressed anywhere, to tell an Esc close from a Tab out of the menu.
|
|
68
|
+
const lastKey = React.useRef(null);
|
|
69
|
+
React.useEffect(() => {
|
|
70
|
+
const remember = (event) => {
|
|
71
|
+
lastKey.current = event.key;
|
|
72
|
+
};
|
|
73
|
+
document.addEventListener("keydown", remember, true);
|
|
74
|
+
return () => document.removeEventListener("keydown", remember, true);
|
|
75
|
+
}, []);
|
|
76
|
+
const [own, setOwn] = React.useState([...(selectedKeys ?? defaultSelectedKeys ?? [])]);
|
|
77
|
+
const value = selectedKeys !== undefined ? [...selectedKeys] : own;
|
|
78
|
+
const change = (keys) => {
|
|
79
|
+
setOwn(keys);
|
|
80
|
+
onSelectionChange?.(keys);
|
|
81
|
+
};
|
|
82
|
+
// Tags follow the item order, so "the last tag" is the last one in that order.
|
|
83
|
+
const chosen = items.filter((item) => value.includes(item.id));
|
|
84
|
+
const visible = maxVisibleTags === undefined ? chosen : chosen.slice(0, maxVisibleTags);
|
|
85
|
+
const hidden = chosen.length - visible.length;
|
|
86
|
+
const selectable = items.filter((item) => !item.isDisabled).map((item) => item.id);
|
|
87
|
+
// React Aria never finds an empty selection missing under `aria` validation; the DS does.
|
|
88
|
+
const required = useRequiredChoice({
|
|
89
|
+
filled: value.length > 0, isRequired: rest.isRequired, requiredValidation, isInvalid: isInvalidProp, errorMessage: errorMessageProp,
|
|
90
|
+
onBlur: rest.onBlur,
|
|
91
|
+
});
|
|
92
|
+
const errorMessage = required.errorMessage;
|
|
93
|
+
const forwarded = forwardedInvalid(ariaInvalid);
|
|
94
|
+
const errorRowLink = useErrorRowLink(forwarded.invalid, errorMessage);
|
|
95
|
+
/** After a tag goes away, focus the next tag's remove button, else the trigger, never the page. */
|
|
96
|
+
const focusAfterRemove = (index) => {
|
|
97
|
+
requestAnimationFrame(() => {
|
|
98
|
+
const buttons = fieldRef.current?.querySelectorAll('[data-slot="multi-select-tag-remove"]');
|
|
99
|
+
const next = buttons?.[Math.min(index, (buttons?.length ?? 1) - 1)];
|
|
100
|
+
(next ?? triggerRef.current)?.focus();
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
return (_jsx(AriaSelect, { ...rest, ...forwarded.fieldProps, ...errorRowLink, isInvalid: required.isInvalid, onBlur: required.onBlur, selectionMode: "multiple",
|
|
104
|
+
// The spoken placeholder (hidden SelectValue) matches the visible one.
|
|
105
|
+
placeholder: placeholder ?? selectPlaceholder(locale), value: value,
|
|
106
|
+
// Form reset goes back to the defaults, not to an empty selection.
|
|
107
|
+
defaultValue: [...(defaultSelectedKeys ?? [])], onChange: (keys) => change([...keys]), onOpenChange: (open) => {
|
|
108
|
+
if (open) {
|
|
109
|
+
lastKey.current = null;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// Esc from the footer button can leave focus on the page; put it back on the field.
|
|
113
|
+
// Tab out of the menu is left alone.
|
|
114
|
+
if (lastKey.current === "Escape") {
|
|
115
|
+
requestAnimationFrame(() => {
|
|
116
|
+
if (document.activeElement === document.body)
|
|
117
|
+
triggerRef.current?.focus();
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}, "aria-label": named, "data-slot": "multi-select", className: cn("group", FIELD_STACK), children: ({ isDisabled }) => (_jsxs(_Fragment, { children: [showLabel && _jsx(FieldLabel, { isRequired: rest.isRequired, children: label }), _jsxs("div", { ref: fieldRef, "data-slot": "multi-select-field", "data-disabled": isDisabled || undefined, className: cn(MULTI_FIELD, fieldRadiusClass(frameRadius)), children: [visible.map((item, index) => (_jsxs("span", { "data-slot": "multi-select-tag", className: TAG, children: [hasContent(item.icon) ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", "data-slot": "multi-select-tag-icon", className: ITEM_ICON, children: item.icon }), _jsx("span", { className: "truncate", children: item.label })] })) : (_jsx("span", { className: "truncate", children: item.label })), !isDisabled && (_jsx(OwnButton, { "aria-label": removeItemLabel(locale, item.label), "data-slot": "multi-select-tag-remove", className: TAG_REMOVE, onPress: () => {
|
|
121
|
+
change(value.filter((key) => key !== item.id));
|
|
122
|
+
focusAfterRemove(index);
|
|
123
|
+
}, children: _jsx(IconGlyph, { name: "x", size: "small", "data-slot": "multi-select-tag-remove-icon" }) }))] }, String(item.id)))), hidden > 0 && (_jsxs("span", { "data-slot": "multi-select-more", className: cn(TAG, "pe-ds-100 tabular-nums"), children: [_jsxs("span", { "aria-hidden": "true", children: ["+", hidden] }), _jsx("span", { className: "sr-only", children: moreCountLabel(locale, hidden) })] })), _jsxs(Button, { ref: triggerRef, "data-slot": "multi-select-trigger", onKeyDown: (event) => {
|
|
124
|
+
// The last tag the user can see; with "+N" shown, that is the last visible one.
|
|
125
|
+
const last = visible.at(-1);
|
|
126
|
+
if (event.key === "Backspace" && last)
|
|
127
|
+
change(value.filter((key) => key !== last.id));
|
|
128
|
+
}, className: cn(SELECT_TRIGGER,
|
|
129
|
+
// The frame is drawn by the field around the tags; the trigger only fills the rest of the row.
|
|
130
|
+
"min-h-6 min-w-20 flex-1 border-0 bg-transparent px-ds-050 outline-0 data-[hovered]:bg-transparent", "data-[focus-visible]:outline-0 group-data-[open]:outline-0 group-data-[invalid]:outline-0"), children: [_jsx(SelectValue, { "data-slot": "multi-select-value", className: "sr-only", children: ({ selectedText, defaultChildren, isPlaceholder }) => (isPlaceholder ? defaultChildren : selectedText) }), _jsx("span", { "aria-hidden": "true", "data-slot": "multi-select-placeholder", className: "min-w-0 flex-1 truncate text-ds-text-subtlest", children: placeholder ?? selectPlaceholder(locale) }), _jsx(IconGlyph, { name: "chevron-down", className: FIELD_ICON, "data-slot": "select-chevron" })] })] }), description && _jsx(FieldDescription, { children: description }), _jsx(ControlFieldError, { forwardedInvalid: forwarded.invalid, children: errorMessage }), _jsx(SelectPopover, { items: items, multiple: true, triggerRef: fieldRef, footer: allowsSelectAll ? (_jsxs("div", { "data-slot": "multi-select-footer", className: MULTI_FOOTER, children: [_jsx(OwnButton
|
|
131
|
+
// Never disabled: a control that disables itself under focus drops focus to the page,
|
|
132
|
+
// and Esc would no longer close the menu. Pressing it again is a no-op.
|
|
133
|
+
, {
|
|
134
|
+
// Never disabled: a control that disables itself under focus drops focus to the page,
|
|
135
|
+
// and Esc would no longer close the menu. Pressing it again is a no-op.
|
|
136
|
+
onPress: () => change([...new Set([...value, ...selectable])]), className: SELECT_ALL, children: selectAllLabel(locale) }), _jsx("span", { "data-slot": "multi-select-count", className: "text-body-small text-ds-text-subtlest tabular-nums", children: selectedCountLabel(locale, value.length) })] })) : undefined })] })) }));
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=multi-select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multi-select.js","sourceRoot":"","sources":["../../src/selection/multi-select.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,MAAM,EACN,aAAa,EACb,MAAM,IAAI,UAAU,EACpB,WAAW,EACX,SAAS,GAEV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACzH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAA2B,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,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AC,MAAM,CAAC,GACpC,EACP,KAAC,SAAS,IAAC,IAAI,EAAC,cAAc,EAAC,SAAS,EAAE,UAAU,eAAY,gBAAgB,GAAG,IAC5E,IACL,EACL,WAAW,IAAI,KAAC,gBAAgB,cAAE,WAAW,GAAoB,EAClE,KAAC,iBAAiB,IAAC,gBAAgB,EAAE,SAAS,CAAC,OAAO,YAAG,YAAY,GAAqB,EAC1F,KAAC,aAAa,IACZ,KAAK,EAAE,KAAK,EACZ,QAAQ,QACR,UAAU,EAAE,QAAQ,EACpB,MAAM,EACJ,eAAe,CAAC,CAAC,CAAC,CAChB,4BAAe,qBAAqB,EAAC,SAAS,EAAE,YAAY,aAC1D,KAAC,SAAS;4BACR,sFAAsF;4BACtF,wEAAwE;;gCADxE,sFAAsF;gCACtF,wEAAwE;gCACxE,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,EAC9D,SAAS,EAAE,UAAU,YAEpB,cAAc,CAAC,MAAM,CAAC,GACb,EACZ,4BAAgB,oBAAoB,EAAC,SAAS,EAAC,oDAAoD,YAChG,kBAAkB,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GACpC,IACH,CACP,CAAC,CAAC,CAAC,SAAS,GAEf,IACD,CACJ,GACU,CACd,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n Button,\n ButtonContext,\n Select as AriaSelect,\n SelectValue,\n useLocale,\n type Key,\n} from \"react-aria-components\";\nimport { IconGlyph } from \"../display/icon\";\n\nimport { cn } from \"../utils\";\nimport { fieldRadiusClass, useRadius } from \"../defaults\";\nimport { ControlFieldError, FieldDescription, FieldLabel, forwardedInvalid, useErrorRowLink } from \"../form/field-parts\";\nimport { FIELD_ICON, FIELD_STACK } from \"../form/styles\";\nimport { useRequiredChoice, type RequiredValidation } from \"../form/validation\";\nimport { moreCountLabel, removeItemLabel, selectAllLabel, selectPlaceholder, selectedCountLabel } from \"../i18n\";\nimport { hasContent } from \"./choice-text\";\nimport { ITEM_ICON, SelectPopover, type SelectItem } from \"./listbox\";\nimport { SELECT_TRIGGER, type SelectLabelProps } from \"./select\";\n\n/**\n * A visible `label` above the field, or an `aria-label` where the context already names it (a table cell, a\n * dialog row headed by its own text): Select's `SelectLabelProps`, here.\n */\nexport type MultiSelectProps = SelectLabelProps & {\n /**\n * A known list of up to ~15 options; more → a searchable ComboBox with multiple selection. An item's `icon`\n * (a flag) shows before its label in the list and in its tag.\n */\n items: readonly SelectItem[];\n /** Controlled; may start undefined and become set later (never flips control). */\n selectedKeys?: readonly Key[];\n defaultSelectedKeys?: readonly Key[];\n onSelectionChange?: (keys: Key[]) => void;\n /** Tags shown before the rest collapse into \"+3\". */\n maxVisibleTags?: number;\n /** Adds the \"Select all\" footer with the selected count. */\n allowsSelectAll?: boolean;\n /** Shown after the tags (\"Add location\"); defaults to \"Select\". */\n placeholder?: string;\n description?: React.ReactNode;\n errorMessage?: React.ReactNode;\n isInvalid?: boolean;\n /**\n * Set by a form row that owns the error text (the shared `Field` hands its control `aria-invalid`): the field\n * shows its invalid state as with `isInvalid`, and without an `errorMessage` of its own draws no error row,\n * so the row's message is the only one. The trigger is a button, on which React Aria sets no\n * `aria-invalid`: the forwarded invalid state shows as `data-invalid` on the field (its danger border) and\n * through the row's own error text, not as `aria-invalid` on the trigger. It marks the field invalid for styling and\n * assistive tech only: unlike `isInvalid` it never becomes the field's native validity (React Aria's default\n * outside a DS Form), so it never blocks a form's submit.\n */\n \"aria-invalid\"?: boolean | \"true\" | \"false\";\n isRequired?: boolean;\n /**\n * Who says a required MultiSelect with nothing chosen is missing: `field` (default) shows\n * \"Fill in this field.\" on blur and on a DS Form submit, which it then blocks; `app` only marks the field.\n * See {@link RequiredValidation}.\n * The app's `isInvalid` (`true` with its `errorMessage`, or `false`) overrides the check, as on TextField. Disabled,\n * empty and required, it still blocks a DS Form's submit and cannot take focus (as TextField).\n */\n requiredValidation?: RequiredValidation;\n isDisabled?: boolean;\n name?: string;\n};\n\n/** 24px tag on `ds-radius-small`. */\nexport const TAG =\n \"inline-flex h-6 max-w-full items-center gap-ds-050 rounded-ds-control-small bg-ds-background-neutral ps-ds-100 pe-ds-075 text-body-small text-ds-text\";\nexport const TAG_REMOVE =\n \"grid size-4 shrink-0 cursor-pointer place-items-center rounded-[max(var(--ds-radius-xsmall),calc(var(--ds-radius-control-small,var(--ds-radius-small))-4px))] text-ds-icon-subtle outline-hidden \" +\n \"data-[hovered]:bg-ds-background-neutral-pressed data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\";\n\n/**\n * The frame around tags and trigger, drawn like a TextField: hover fill,\n * the 2px focused edge while the trigger has keyboard focus or the menu is\n * open, and the danger edge, which stays red while focused or open (compound\n * variants sort after the single ones). The vertical padding centres a 24px\n * tag row in the 36px control (1px borders).\n */\nexport const MULTI_FIELD =\n \"flex min-h-ds-control w-full flex-wrap items-center gap-ds-050 rounded-ds-medium border border-ds-border-bold bg-ds-background-input py-[5px] ps-ds-100 pe-ds-075 \" +\n \"transition-colors duration-(--ds-duration-instant) ease-ds-standard hover:bg-ds-background-input-hovered \" +\n \"has-[[data-slot=multi-select-trigger][data-focus-visible]]:border-ds-border-focused has-[[data-slot=multi-select-trigger][data-focus-visible]]:outline-1 \" +\n \"has-[[data-slot=multi-select-trigger][data-focus-visible]]:outline-solid has-[[data-slot=multi-select-trigger][data-focus-visible]]:-outline-offset-2 \" +\n \"has-[[data-slot=multi-select-trigger][data-focus-visible]]:outline-ds-border-focused \" +\n \"group-data-[open]:border-ds-border-focused group-data-[open]:outline-1 group-data-[open]:outline-solid group-data-[open]:-outline-offset-2 group-data-[open]:outline-ds-border-focused \" +\n \"group-data-[invalid]:border-ds-border-danger group-data-[invalid]:outline-1 group-data-[invalid]:outline-solid group-data-[invalid]:-outline-offset-2 group-data-[invalid]:outline-ds-border-danger \" +\n \"group-data-[invalid]:group-data-[open]:border-ds-border-danger group-data-[invalid]:group-data-[open]:outline-ds-border-danger \" +\n \"group-data-[invalid]:has-[[data-slot=multi-select-trigger][data-focus-visible]]:border-ds-border-danger \" +\n \"group-data-[invalid]:has-[[data-slot=multi-select-trigger][data-focus-visible]]:outline-ds-border-danger \" +\n \"data-[disabled]:border-transparent data-[disabled]:bg-ds-background-disabled data-[disabled]:text-ds-text-disabled data-[disabled]:hover:bg-ds-background-disabled\";\n\nexport const MULTI_FOOTER =\n \"-mx-ds-050 -mb-ds-050 mt-ds-050 flex shrink-0 items-center justify-between gap-ds-200 border-t border-ds-border p-ds-050 ps-ds-100\";\nexport const SELECT_ALL =\n \"h-ds-control-compact cursor-pointer px-ds-050 text-body-strong text-ds-link outline-hidden underline-offset-3 data-[hovered]:underline \" +\n \"data-[focus-visible]:underline data-[focus-visible]:decoration-2 data-[focus-visible]:decoration-ds-border-focused\";\n\n/** A plain button inside the Select: React Aria would otherwise wire every Button in it as the trigger. */\nfunction OwnButton(props: React.ComponentProps<typeof Button>) {\n return (\n <ButtonContext.Provider value={null}>\n <Button {...props} />\n </ButtonContext.Provider>\n );\n}\n\n/**\n * Several values from a known list. Chosen values show as removable tags in\n * the field; the menu stays open while picking (Esc or a click outside\n * closes it); Backspace on the field removes the last visible tag. Named by a\n * visible `label` or, where the context names it, an `aria-label`; an item's\n * `icon` (a country flag) shows before its label in the list and in its tag\n *.\n */\nexport function MultiSelect({\n label, \"aria-label\": ariaLabel, items, selectedKeys, defaultSelectedKeys, onSelectionChange, maxVisibleTags, allowsSelectAll, placeholder,\n description, errorMessage: errorMessageProp, \"aria-invalid\": ariaInvalid, requiredValidation, isInvalid: isInvalidProp, ...rest\n}: MultiSelectProps) {\n const frameRadius = useRadius(undefined);\n const { locale } = useLocale();\n // Named as Select is: a non-empty aria-label replaces the visible label; an empty one counts as none.\n const named = ariaLabel ? ariaLabel : undefined;\n const showLabel = named === undefined && (ariaLabel === undefined || label != null);\n const unnamed = named === undefined && label == null && !(rest as { \"aria-labelledby\"?: string })[\"aria-labelledby\"];\n React.useEffect(() => {\n if (process.env.NODE_ENV !== \"production\" && unnamed) {\n console.warn(\"MultiSelect: no accessible name. Give a label, or a non-empty aria-label where the context names the field.\");\n }\n }, [unnamed]);\n // The menu opens under the whole field (tags included), not under the trigger at its end.\n const fieldRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n // The last key pressed anywhere, to tell an Esc close from a Tab out of the menu.\n const lastKey = React.useRef<string | null>(null);\n React.useEffect(() => {\n const remember = (event: KeyboardEvent) => {\n lastKey.current = event.key;\n };\n document.addEventListener(\"keydown\", remember, true);\n return () => document.removeEventListener(\"keydown\", remember, true);\n }, []);\n const [own, setOwn] = React.useState<Key[]>([...(selectedKeys ?? defaultSelectedKeys ?? [])]);\n const value = selectedKeys !== undefined ? [...selectedKeys] : own;\n const change = (keys: Key[]) => {\n setOwn(keys);\n onSelectionChange?.(keys);\n };\n // Tags follow the item order, so \"the last tag\" is the last one in that order.\n const chosen = items.filter((item) => value.includes(item.id));\n const visible = maxVisibleTags === undefined ? chosen : chosen.slice(0, maxVisibleTags);\n const hidden = chosen.length - visible.length;\n const selectable = items.filter((item) => !item.isDisabled).map((item) => item.id);\n // React Aria never finds an empty selection missing under `aria` validation; the DS does.\n const required = useRequiredChoice({\n filled: value.length > 0, isRequired: rest.isRequired, requiredValidation, isInvalid: isInvalidProp, errorMessage: errorMessageProp,\n onBlur: (rest as { onBlur?: (event: React.FocusEvent) => void }).onBlur,\n });\n const errorMessage = required.errorMessage;\n const forwarded = forwardedInvalid(ariaInvalid);\n const errorRowLink = useErrorRowLink(forwarded.invalid, errorMessage);\n\n /** After a tag goes away, focus the next tag's remove button, else the trigger, never the page. */\n const focusAfterRemove = (index: number) => {\n requestAnimationFrame(() => {\n const buttons = fieldRef.current?.querySelectorAll<HTMLElement>('[data-slot=\"multi-select-tag-remove\"]');\n const next = buttons?.[Math.min(index, (buttons?.length ?? 1) - 1)];\n (next ?? triggerRef.current)?.focus();\n });\n };\n\n return (\n <AriaSelect\n {...rest}\n {...forwarded.fieldProps}\n {...errorRowLink}\n isInvalid={required.isInvalid}\n onBlur={required.onBlur}\n selectionMode=\"multiple\"\n // The spoken placeholder (hidden SelectValue) matches the visible one.\n placeholder={placeholder ?? selectPlaceholder(locale)}\n value={value}\n // Form reset goes back to the defaults, not to an empty selection.\n defaultValue={[...(defaultSelectedKeys ?? [])]}\n onChange={(keys) => change([...keys])}\n onOpenChange={(open) => {\n if (open) {\n lastKey.current = null;\n return;\n }\n // Esc from the footer button can leave focus on the page; put it back on the field.\n // Tab out of the menu is left alone.\n if (lastKey.current === \"Escape\") {\n requestAnimationFrame(() => {\n if (document.activeElement === document.body) triggerRef.current?.focus();\n });\n }\n }}\n aria-label={named}\n data-slot=\"multi-select\"\n className={cn(\"group\", FIELD_STACK)}\n >\n {({ isDisabled }) => (\n <>\n {showLabel && <FieldLabel isRequired={rest.isRequired}>{label}</FieldLabel>}\n <div\n ref={fieldRef}\n data-slot=\"multi-select-field\"\n data-disabled={isDisabled || undefined}\n className={cn(MULTI_FIELD, fieldRadiusClass(frameRadius))}\n >\n {visible.map((item, index) => (\n <span key={String(item.id)} data-slot=\"multi-select-tag\" className={TAG}>\n {/* One child either way, so the remove button keeps its place (and its server id) without an icon. */}\n {hasContent(item.icon) ? (\n <>\n <span aria-hidden=\"true\" data-slot=\"multi-select-tag-icon\" className={ITEM_ICON}>{item.icon}</span>\n <span className=\"truncate\">{item.label}</span>\n </>\n ) : (\n <span className=\"truncate\">{item.label}</span>\n )}\n {!isDisabled && (\n <OwnButton\n aria-label={removeItemLabel(locale, item.label)}\n data-slot=\"multi-select-tag-remove\"\n className={TAG_REMOVE}\n onPress={() => {\n change(value.filter((key) => key !== item.id));\n focusAfterRemove(index);\n }}\n >\n <IconGlyph name=\"x\" size=\"small\" data-slot=\"multi-select-tag-remove-icon\" />\n </OwnButton>\n )}\n </span>\n ))}\n {hidden > 0 && (\n <span data-slot=\"multi-select-more\" className={cn(TAG, \"pe-ds-100 tabular-nums\")}>\n <span aria-hidden=\"true\">+{hidden}</span>\n <span className=\"sr-only\">{moreCountLabel(locale, hidden)}</span>\n </span>\n )}\n <Button\n ref={triggerRef}\n data-slot=\"multi-select-trigger\"\n onKeyDown={(event) => {\n // The last tag the user can see; with \"+N\" shown, that is the last visible one.\n const last = visible.at(-1);\n if (event.key === \"Backspace\" && last) change(value.filter((key) => key !== last.id));\n }}\n className={cn(\n SELECT_TRIGGER,\n // The frame is drawn by the field around the tags; the trigger only fills the rest of the row.\n \"min-h-6 min-w-20 flex-1 border-0 bg-transparent px-ds-050 outline-0 data-[hovered]:bg-transparent\",\n \"data-[focus-visible]:outline-0 group-data-[open]:outline-0 group-data-[invalid]:outline-0\",\n )}\n >\n {/* The trigger's name is the chosen labels (or the placeholder) plus the field label. */}\n <SelectValue data-slot=\"multi-select-value\" className=\"sr-only\">\n {/* Labels only (\"A ve B\"), never each option's description or meta. */}\n {({ selectedText, defaultChildren, isPlaceholder }) => (isPlaceholder ? defaultChildren : selectedText)}\n </SelectValue>\n <span aria-hidden=\"true\" data-slot=\"multi-select-placeholder\" className=\"min-w-0 flex-1 truncate text-ds-text-subtlest\">\n {placeholder ?? selectPlaceholder(locale)}\n </span>\n <IconGlyph name=\"chevron-down\" className={FIELD_ICON} data-slot=\"select-chevron\" />\n </Button>\n </div>\n {description && <FieldDescription>{description}</FieldDescription>}\n <ControlFieldError forwardedInvalid={forwarded.invalid}>{errorMessage}</ControlFieldError>\n <SelectPopover\n items={items}\n multiple\n triggerRef={fieldRef}\n footer={\n allowsSelectAll ? (\n <div data-slot=\"multi-select-footer\" className={MULTI_FOOTER}>\n <OwnButton\n // Never disabled: a control that disables itself under focus drops focus to the page,\n // and Esc would no longer close the menu. Pressing it again is a no-op.\n onPress={() => change([...new Set([...value, ...selectable])])}\n className={SELECT_ALL}\n >\n {selectAllLabel(locale)}\n </OwnButton>\n <span data-slot=\"multi-select-count\" className=\"text-body-small text-ds-text-subtlest tabular-nums\">\n {selectedCountLabel(locale, value.length)}\n </span>\n </div>\n ) : undefined\n }\n />\n </>\n )}\n </AriaSelect>\n );\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type RadioGroupProps as AriaRadioGroupProps } from "react-aria-components";
|
|
3
|
+
import type { RequiredValidation } from "../form/validation.js";
|
|
4
|
+
export type RadioCardItem = {
|
|
5
|
+
value: string;
|
|
6
|
+
title: React.ReactNode;
|
|
7
|
+
description?: React.ReactNode;
|
|
8
|
+
price?: React.ReactNode;
|
|
9
|
+
/** Marks the recommended option ("Recommended"), as a brand lozenge. */
|
|
10
|
+
badge?: React.ReactNode;
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type RadioCardProps = Omit<AriaRadioGroupProps, "children" | "className" | "style" | "orientation"> & {
|
|
14
|
+
label: React.ReactNode;
|
|
15
|
+
/** Two to four cards. */
|
|
16
|
+
items: readonly RadioCardItem[];
|
|
17
|
+
description?: React.ReactNode;
|
|
18
|
+
errorMessage?: React.ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* As RadioGroup's: `field` (default) or `app`. See {@link RequiredValidation}. The app's `isInvalid`
|
|
21
|
+
* (`true` with its `errorMessage`, or `false`) overrides the check, as on TextField. Disabled, empty and required,
|
|
22
|
+
* it still blocks a DS Form's submit and cannot take focus (as TextField).
|
|
23
|
+
*/
|
|
24
|
+
requiredValidation?: RequiredValidation;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* A RadioGroup whose options are cards (insurance packages, delivery options).
|
|
28
|
+
* The whole card is the hit target; arrow keys move between cards; cards in a
|
|
29
|
+
* row have equal height.
|
|
30
|
+
*/
|
|
31
|
+
export declare function RadioCard({ label, items, description, errorMessage: errorMessageProp, requiredValidation, ...rest }: RadioCardProps): React.JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Radio as AriaRadio, RadioGroup as AriaRadioGroup } from "react-aria-components";
|
|
5
|
+
import { FieldDescription, FieldError, FieldLabel } from "../form/field-parts.js";
|
|
6
|
+
import { FIELD_STACK } from "../form/styles.js";
|
|
7
|
+
import { hasContent } from "./choice-text.js";
|
|
8
|
+
import { useRadioGroupRequired } from "./radio.js";
|
|
9
|
+
import { CHOICE_DESCRIPTION, RADIO_CARD, RADIO_CARD_BADGE, RADIO_DOT } from "./styles.js";
|
|
10
|
+
/**
|
|
11
|
+
* A RadioGroup whose options are cards (insurance packages, delivery options).
|
|
12
|
+
* The whole card is the hit target; arrow keys move between cards; cards in a
|
|
13
|
+
* row have equal height.
|
|
14
|
+
*/
|
|
15
|
+
export function RadioCard({ label, items, description, errorMessage: errorMessageProp, requiredValidation, ...rest }) {
|
|
16
|
+
const { errorMessage, groupProps } = useRadioGroupRequired({ ...rest, errorMessage: errorMessageProp, requiredValidation });
|
|
17
|
+
return (_jsxs(AriaRadioGroup, { ...rest, ...groupProps, "data-slot": "radio-card-group", className: FIELD_STACK, children: [_jsx(FieldLabel, { isRequired: rest.isRequired, children: label }), _jsx("div", { "data-slot": "radio-card-items", className: "grid grid-cols-[repeat(auto-fit,minmax(min(180px,100%),1fr))] gap-ds-150", children: items.map((item) => (_jsx(RadioCardOption, { item: item }, item.value))) }), description && _jsx(FieldDescription, { children: description }), _jsx(FieldError, { children: errorMessage })] }));
|
|
18
|
+
}
|
|
19
|
+
function RadioCardOption({ item }) {
|
|
20
|
+
const id = React.useId();
|
|
21
|
+
const titleId = `${id}-title`;
|
|
22
|
+
const badgeId = hasContent(item.badge) ? `${id}-badge` : undefined;
|
|
23
|
+
const detailsId = hasContent(item.description) || hasContent(item.price) ? `${id}-details` : undefined;
|
|
24
|
+
const describedBy = [badgeId, detailsId].filter(Boolean).join(" ") || undefined;
|
|
25
|
+
return (_jsxs(AriaRadio, { value: item.value, isDisabled: item.isDisabled, "aria-labelledby": titleId, "aria-describedby": describedBy, "data-slot": "radio-card", className: RADIO_CARD, children: [_jsx("span", { "aria-hidden": "true", "data-slot": "radio-dot", className: RADIO_DOT }), _jsxs("span", { "data-slot": "radio-card-body", className: "flex min-w-0 flex-col gap-ds-050", children: [_jsxs("span", { className: "flex flex-wrap items-center gap-ds-075", children: [_jsx("span", { id: titleId, "data-slot": "radio-card-title", className: "text-body-strong", children: item.title }), badgeId && (
|
|
26
|
+
// A brand Lozenge; swap in the Lozenge component once the display group ships it.
|
|
27
|
+
_jsx("span", { id: badgeId, "data-slot": "radio-card-badge", className: RADIO_CARD_BADGE, children: item.badge }))] }), detailsId && (_jsxs("span", { id: detailsId, className: "flex flex-col gap-ds-050", children: [hasContent(item.description) && (_jsx("span", { "data-slot": "radio-card-description", className: CHOICE_DESCRIPTION, children: item.description })), hasContent(item.price) && (_jsx("span", { "data-slot": "radio-card-price", className: "text-metric-small tabular-nums", children: item.price }))] }))] })] }));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=radio-card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-card.js","sourceRoot":"","sources":["../../src/selection/radio-card.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,UAAU,IAAI,cAAc,EAA+C,MAAM,uBAAuB,CAAC;AAEtI,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE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C,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IACvG,MAAM,WAAW,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC;IAChF,OAAO,CACL,MAAC,SAAS,IACR,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,UAAU,EAAE,IAAI,CAAC,UAAU,qBAEV,OAAO,sBACN,WAAW,eACnB,YAAY,EACtB,SAAS,EAAE,UAAU,aAErB,8BAAkB,MAAM,eAAW,WAAW,EAAC,SAAS,EAAE,SAAS,GAAI,EACvE,6BAAgB,iBAAiB,EAAC,SAAS,EAAC,kCAAkC,aAC5E,gBAAM,SAAS,EAAC,wCAAwC,aACtD,eAAM,EAAE,EAAE,OAAO,eAAY,kBAAkB,EAAC,SAAS,EAAC,kBAAkB,YAAE,IAAI,CAAC,KAAK,GAAQ,EAC/F,OAAO,IAAI;4BACV,kFAAkF;4BAClF,eAAM,EAAE,EAAE,OAAO,eAAY,kBAAkB,EAAC,SAAS,EAAE,gBAAgB,YACxE,IAAI,CAAC,KAAK,GACN,CACR,IACI,EACN,SAAS,IAAI,CACZ,gBAAM,EAAE,EAAE,SAAS,EAAE,SAAS,EAAC,0BAA0B,aACtD,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAC/B,4BAAgB,wBAAwB,EAAC,SAAS,EAAE,kBAAkB,YAAG,IAAI,CAAC,WAAW,GAAQ,CAClG,EACA,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CACzB,4BAAgB,kBAAkB,EAAC,SAAS,EAAC,gCAAgC,YAAE,IAAI,CAAC,KAAK,GAAQ,CAClG,IACI,CACR,IACI,IACG,CACb,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Radio as AriaRadio, RadioGroup as AriaRadioGroup, type RadioGroupProps as AriaRadioGroupProps } from \"react-aria-components\";\n\nimport { FieldDescription, FieldError, FieldLabel } from \"../form/field-parts\";\nimport { FIELD_STACK } from \"../form/styles\";\nimport type { RequiredValidation } from \"../form/validation\";\nimport { hasContent } from \"./choice-text\";\nimport { useRadioGroupRequired } from \"./radio\";\nimport { CHOICE_DESCRIPTION, RADIO_CARD, RADIO_CARD_BADGE, RADIO_DOT } from \"./styles\";\n\nexport type RadioCardItem = {\n value: string;\n title: React.ReactNode;\n description?: React.ReactNode;\n price?: React.ReactNode;\n /** Marks the recommended option (\"Recommended\"), as a brand lozenge. */\n badge?: React.ReactNode;\n isDisabled?: boolean;\n};\n\nexport type RadioCardProps = Omit<AriaRadioGroupProps, \"children\" | \"className\" | \"style\" | \"orientation\"> & {\n label: React.ReactNode;\n /** Two to four cards. */\n items: readonly RadioCardItem[];\n description?: React.ReactNode;\n errorMessage?: React.ReactNode;\n /**\n * As RadioGroup's: `field` (default) or `app`. See {@link RequiredValidation}. The app's `isInvalid`\n * (`true` with its `errorMessage`, or `false`) overrides the check, as on TextField. Disabled, empty and required,\n * it still blocks a DS Form's submit and cannot take focus (as TextField).\n */\n requiredValidation?: RequiredValidation;\n};\n\n/**\n * A RadioGroup whose options are cards (insurance packages, delivery options).\n * The whole card is the hit target; arrow keys move between cards; cards in a\n * row have equal height.\n */\nexport function RadioCard({ label, items, description, errorMessage: errorMessageProp, requiredValidation, ...rest }: RadioCardProps) {\n const { errorMessage, groupProps } = useRadioGroupRequired({ ...rest, errorMessage: errorMessageProp, requiredValidation });\n return (\n <AriaRadioGroup {...rest} {...groupProps} data-slot=\"radio-card-group\" className={FIELD_STACK}>\n <FieldLabel isRequired={rest.isRequired}>{label}</FieldLabel>\n <div data-slot=\"radio-card-items\" className=\"grid grid-cols-[repeat(auto-fit,minmax(min(180px,100%),1fr))] gap-ds-150\">\n {items.map((item) => (\n <RadioCardOption key={item.value} item={item} />\n ))}\n </div>\n {description && <FieldDescription>{description}</FieldDescription>}\n <FieldError>{errorMessage}</FieldError>\n </AriaRadioGroup>\n );\n}\n\nfunction RadioCardOption({ item }: { item: RadioCardItem }) {\n const id = React.useId();\n const titleId = `${id}-title`;\n const badgeId = hasContent(item.badge) ? `${id}-badge` : undefined;\n const detailsId = hasContent(item.description) || hasContent(item.price) ? `${id}-details` : undefined;\n const describedBy = [badgeId, detailsId].filter(Boolean).join(\" \") || undefined;\n return (\n <AriaRadio\n value={item.value}\n isDisabled={item.isDisabled}\n // Named by the title alone; badge, detail and price stay visible text and describe it.\n aria-labelledby={titleId}\n aria-describedby={describedBy}\n data-slot=\"radio-card\"\n className={RADIO_CARD}\n >\n <span aria-hidden=\"true\" data-slot=\"radio-dot\" className={RADIO_DOT} />\n <span data-slot=\"radio-card-body\" className=\"flex min-w-0 flex-col gap-ds-050\">\n <span className=\"flex flex-wrap items-center gap-ds-075\">\n <span id={titleId} data-slot=\"radio-card-title\" className=\"text-body-strong\">{item.title}</span>\n {badgeId && (\n // A brand Lozenge; swap in the Lozenge component once the display group ships it.\n <span id={badgeId} data-slot=\"radio-card-badge\" className={RADIO_CARD_BADGE}>\n {item.badge}\n </span>\n )}\n </span>\n {detailsId && (\n <span id={detailsId} className=\"flex flex-col gap-ds-050\">\n {hasContent(item.description) && (\n <span data-slot=\"radio-card-description\" className={CHOICE_DESCRIPTION}>{item.description}</span>\n )}\n {hasContent(item.price) && (\n <span data-slot=\"radio-card-price\" className=\"text-metric-small tabular-nums\">{item.price}</span>\n )}\n </span>\n )}\n </span>\n </AriaRadio>\n );\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type RadioGroupProps as AriaRadioGroupProps } from "react-aria-components";
|
|
3
|
+
import { type RequiredValidation } from "../form/validation.js";
|
|
4
|
+
import { type ChoiceSize } from "./choice-size.js";
|
|
5
|
+
/** How a RadioGroup draws its options: rows with a dot, or cards (the whole card is the hit target). */
|
|
6
|
+
export type RadioGroupVariant = "default" | "card";
|
|
7
|
+
export type RadioProps = {
|
|
8
|
+
value: string;
|
|
9
|
+
/** `small`, `medium` (default) or `large`; a group's size, then the provider default, otherwise. */
|
|
10
|
+
size?: ChoiceSize;
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
description?: React.ReactNode;
|
|
13
|
+
isDisabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* One option of a RadioGroup; the whole row (or card) is the hit target. Named by its children, described by
|
|
17
|
+
* `description`; in a card group the children can hold any content (a title with a Badge, a price).
|
|
18
|
+
*/
|
|
19
|
+
export declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLLabelElement>>;
|
|
20
|
+
export type RadioItem = {
|
|
21
|
+
value: string;
|
|
22
|
+
label: React.ReactNode;
|
|
23
|
+
description?: React.ReactNode;
|
|
24
|
+
isDisabled?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type RadioGroupProps = Omit<AriaRadioGroupProps, "children" | "className" | "style"> & {
|
|
27
|
+
/** The size of every Radio in the group. */
|
|
28
|
+
size?: ChoiceSize;
|
|
29
|
+
/** The group legend, required. */
|
|
30
|
+
label: React.ReactNode;
|
|
31
|
+
/** The options as data, or `Radio` children. */
|
|
32
|
+
items?: readonly RadioItem[];
|
|
33
|
+
children?: React.ReactNode;
|
|
34
|
+
description?: React.ReactNode;
|
|
35
|
+
errorMessage?: React.ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Who says a required group with no option chosen is missing: `field` (default) shows
|
|
38
|
+
* "Fill in this field." when focus leaves the group and on a DS Form submit, which it then blocks; `app` only
|
|
39
|
+
* marks the group. See {@link RequiredValidation}.
|
|
40
|
+
* The app's `isInvalid` (`true` with its `errorMessage`, or `false`) overrides the check, as on TextField. Disabled,
|
|
41
|
+
* empty and required, it still blocks a DS Form's submit and cannot take focus (as TextField).
|
|
42
|
+
*/
|
|
43
|
+
requiredValidation?: RequiredValidation;
|
|
44
|
+
/**
|
|
45
|
+
* `default`: rows with a dot. `card`: each option a card in a grid of equal columns (no narrower than 180px), for
|
|
46
|
+
* choices that need a line of detail each (a plan, a delivery option, a time slot).
|
|
47
|
+
*/
|
|
48
|
+
variant?: RadioGroupVariant;
|
|
49
|
+
};
|
|
50
|
+
type GroupRequiredProps = Pick<AriaRadioGroupProps, "value" | "defaultValue" | "onChange" | "onBlur" | "isRequired" | "isInvalid" | "validationBehavior"> & {
|
|
51
|
+
errorMessage?: React.ReactNode;
|
|
52
|
+
requiredValidation?: RequiredValidation;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* RadioGroup's required check: React Aria never finds a group with nothing chosen
|
|
56
|
+
* missing under `aria` validation. The chosen value is followed (the app's, or the one React Aria reports, a form
|
|
57
|
+
* reset included) without taking control of the group. Not a public export.
|
|
58
|
+
*/
|
|
59
|
+
export declare function useRadioGroupRequired({ value, defaultValue, onChange, onBlur, isRequired, isInvalid, validationBehavior, errorMessage, requiredValidation, }: GroupRequiredProps): {
|
|
60
|
+
errorMessage: React.ReactNode;
|
|
61
|
+
groupProps: {
|
|
62
|
+
isInvalid: boolean | undefined;
|
|
63
|
+
onBlur: AriaRadioGroupProps["onBlur"];
|
|
64
|
+
onChange: (next: string) => void;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Exactly one of two to seven always-visible options. Tab enters and leaves
|
|
69
|
+
* the group; arrow keys move the selection; focusing never selects by itself.
|
|
70
|
+
*/
|
|
71
|
+
export declare function RadioGroup({ label, items, children, description, errorMessage: errorMessageProp, orientation, requiredValidation, variant, size, ...rest }: RadioGroupProps): React.JSX.Element;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Radio as AriaRadio, RadioGroup as AriaRadioGroup } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { FieldDescription, FieldError, FieldLabel } from "../form/field-parts.js";
|
|
7
|
+
import { FIELD_STACK } from "../form/styles.js";
|
|
8
|
+
import { useRequiredChoice } from "../form/validation.js";
|
|
9
|
+
import { useChoiceText } from "./choice-text.js";
|
|
10
|
+
import { CHOICE_ROW, RADIO_CARD, RADIO_DOT } from "./styles.js";
|
|
11
|
+
import { CHOICE_ROW_SIZE, ChoiceSizeContext, INDICATOR_SIZE, RADIO_RING_SIZE, useChoiceSize } from "./choice-size.js";
|
|
12
|
+
const RadioVariant = React.createContext("default");
|
|
13
|
+
/**
|
|
14
|
+
* One option of a RadioGroup; the whole row (or card) is the hit target. Named by its children, described by
|
|
15
|
+
* `description`; in a card group the children can hold any content (a title with a Badge, a price).
|
|
16
|
+
*/
|
|
17
|
+
export const Radio = React.forwardRef(function Radio({ children, description, size: ownSize, ...rest }, ref) {
|
|
18
|
+
const size = useChoiceSize(ownSize);
|
|
19
|
+
const text = useChoiceText(description, undefined);
|
|
20
|
+
const variant = React.useContext(RadioVariant);
|
|
21
|
+
return (_jsxs(AriaRadio, { ...rest, ref: ref, "aria-labelledby": text.labelId, "aria-describedby": text.describedBy, "data-slot": "radio", "data-variant": variant, className: variant === "card" ? RADIO_CARD : cn(CHOICE_ROW, CHOICE_ROW_SIZE[size]), children: [_jsx("span", { "aria-hidden": "true", "data-slot": "radio-dot", className: cn(RADIO_DOT, INDICATOR_SIZE[size], RADIO_RING_SIZE[size]) }), text.render(children)] }));
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* RadioGroup's required check: React Aria never finds a group with nothing chosen
|
|
25
|
+
* missing under `aria` validation. The chosen value is followed (the app's, or the one React Aria reports, a form
|
|
26
|
+
* reset included) without taking control of the group. Not a public export.
|
|
27
|
+
*/
|
|
28
|
+
export function useRadioGroupRequired({ value, defaultValue, onChange, onBlur, isRequired, isInvalid, validationBehavior, errorMessage, requiredValidation, }) {
|
|
29
|
+
const [own, setOwn] = React.useState(value ?? defaultValue ?? null);
|
|
30
|
+
const current = value !== undefined ? value : own;
|
|
31
|
+
const required = useRequiredChoice({
|
|
32
|
+
filled: current !== null && current !== "",
|
|
33
|
+
isRequired,
|
|
34
|
+
requiredValidation,
|
|
35
|
+
isInvalid,
|
|
36
|
+
errorMessage,
|
|
37
|
+
validationBehavior,
|
|
38
|
+
onBlur: onBlur,
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
errorMessage: required.errorMessage,
|
|
42
|
+
groupProps: {
|
|
43
|
+
isInvalid: required.isInvalid,
|
|
44
|
+
onBlur: required.onBlur,
|
|
45
|
+
onChange: (next) => {
|
|
46
|
+
setOwn(next);
|
|
47
|
+
onChange?.(next);
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Exactly one of two to seven always-visible options. Tab enters and leaves
|
|
54
|
+
* the group; arrow keys move the selection; focusing never selects by itself.
|
|
55
|
+
*/
|
|
56
|
+
export function RadioGroup({ label, items, children, description, errorMessage: errorMessageProp, orientation = "vertical", requiredValidation, variant = "default", size, ...rest }) {
|
|
57
|
+
const { errorMessage, groupProps } = useRadioGroupRequired({ ...rest, errorMessage: errorMessageProp, requiredValidation });
|
|
58
|
+
return (_jsxs(AriaRadioGroup, { ...rest, ...groupProps, orientation: orientation, "data-slot": "radio-group", "data-variant": variant, className: FIELD_STACK, children: [_jsx(FieldLabel, { isRequired: rest.isRequired, children: label }), _jsx(RadioVariant.Provider, { value: variant, children: _jsx(ChoiceSizeContext.Provider, { value: size, children: _jsx("div", { "data-slot": "radio-group-items", className: cn(variant === "card"
|
|
59
|
+
? "grid grid-cols-[repeat(auto-fit,minmax(min(180px,100%),1fr))] gap-ds-150"
|
|
60
|
+
: cn("flex gap-ds-100", orientation === "vertical" ? "flex-col items-start" : "flex-wrap gap-x-ds-300")), children: items
|
|
61
|
+
? items.map((item) => (_jsx(Radio, { value: item.value, description: item.description, isDisabled: item.isDisabled, children: item.label }, item.value)))
|
|
62
|
+
: children }) }) }), description && _jsx(FieldDescription, { children: description }), _jsx(FieldError, { children: errorMessage })] }));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=radio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio.js","sourceRoot":"","sources":["../../src/selection/radio.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,UAAU,IAAI,cAAc,EAA+C,MAAM,uBAAuB,CAAC;AAEtI,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAA2B,MAAM,oBAAoB,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,aAAa,EAAmB,MAAM,eAAe,CAAC;AAIpI,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAAoB,SAAS,CAAC,CAAC;AAWvE;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAA+B,SAAS,KAAK,CAAC,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG;IACvI,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,KAAK,CAAC,UA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AC,WAAW,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,YAClG,IAAI,CAAC,KAAK,IADD,IAAI,CAAC,KAAK,CAEd,CACT,CAAC;4BACJ,CAAC,CAAC,QAAQ,GACR,GACuB,GACP,EACvB,WAAW,IAAI,KAAC,gBAAgB,cAAE,WAAW,GAAoB,EAClE,KAAC,UAAU,cAAE,YAAY,GAAc,IACxB,CAClB,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Radio as AriaRadio, RadioGroup as AriaRadioGroup, type RadioGroupProps as AriaRadioGroupProps } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { FieldDescription, FieldError, FieldLabel } from \"../form/field-parts\";\nimport { FIELD_STACK } from \"../form/styles\";\nimport { useRequiredChoice, type RequiredValidation } from \"../form/validation\";\nimport { useChoiceText } from \"./choice-text\";\nimport { CHOICE_ROW, RADIO_CARD, RADIO_DOT } from \"./styles\";\nimport { CHOICE_ROW_SIZE, ChoiceSizeContext, INDICATOR_SIZE, RADIO_RING_SIZE, useChoiceSize, type ChoiceSize } from \"./choice-size\";\n\n/** How a RadioGroup draws its options: rows with a dot, or cards (the whole card is the hit target). */\nexport type RadioGroupVariant = \"default\" | \"card\";\nconst RadioVariant = React.createContext<RadioGroupVariant>(\"default\");\n\nexport type RadioProps = {\n value: string;\n /** `small`, `medium` (default) or `large`; a group's size, then the provider default, otherwise. */\n size?: ChoiceSize;\n children: React.ReactNode;\n description?: React.ReactNode;\n isDisabled?: boolean;\n};\n\n/**\n * One option of a RadioGroup; the whole row (or card) is the hit target. Named by its children, described by\n * `description`; in a card group the children can hold any content (a title with a Badge, a price).\n */\nexport const Radio = React.forwardRef<HTMLLabelElement, RadioProps>(function Radio({ children, description, size: ownSize, ...rest }, ref) {\n const size = useChoiceSize(ownSize);\n const text = useChoiceText(description, undefined);\n const variant = React.useContext(RadioVariant);\n return (\n <AriaRadio\n {...rest}\n ref={ref}\n aria-labelledby={text.labelId}\n aria-describedby={text.describedBy}\n data-slot=\"radio\"\n data-variant={variant}\n className={variant === \"card\" ? RADIO_CARD : cn(CHOICE_ROW, CHOICE_ROW_SIZE[size])}\n >\n <span aria-hidden=\"true\" data-slot=\"radio-dot\" className={cn(RADIO_DOT, INDICATOR_SIZE[size], RADIO_RING_SIZE[size])} />\n {text.render(children)}\n </AriaRadio>\n );\n});\n\nexport type RadioItem = { value: string; label: React.ReactNode; description?: React.ReactNode; isDisabled?: boolean };\n\nexport type RadioGroupProps = Omit<AriaRadioGroupProps, \"children\" | \"className\" | \"style\"> & {\n /** The size of every Radio in the group. */\n size?: ChoiceSize;\n /** The group legend, required. */\n label: React.ReactNode;\n /** The options as data, or `Radio` children. */\n items?: readonly RadioItem[];\n children?: React.ReactNode;\n description?: React.ReactNode;\n errorMessage?: React.ReactNode;\n /**\n * Who says a required group with no option chosen is missing: `field` (default) shows\n * \"Fill in this field.\" when focus leaves the group and on a DS Form submit, which it then blocks; `app` only\n * marks the group. See {@link RequiredValidation}.\n * The app's `isInvalid` (`true` with its `errorMessage`, or `false`) overrides the check, as on TextField. Disabled,\n * empty and required, it still blocks a DS Form's submit and cannot take focus (as TextField).\n */\n requiredValidation?: RequiredValidation;\n /**\n * `default`: rows with a dot. `card`: each option a card in a grid of equal columns (no narrower than 180px), for\n * choices that need a line of detail each (a plan, a delivery option, a time slot).\n */\n variant?: RadioGroupVariant;\n};\n\ntype GroupRequiredProps = Pick<\n AriaRadioGroupProps,\n \"value\" | \"defaultValue\" | \"onChange\" | \"onBlur\" | \"isRequired\" | \"isInvalid\" | \"validationBehavior\"\n> & {\n errorMessage?: React.ReactNode;\n requiredValidation?: RequiredValidation;\n};\n\n/**\n * RadioGroup's required check: React Aria never finds a group with nothing chosen\n * missing under `aria` validation. The chosen value is followed (the app's, or the one React Aria reports, a form\n * reset included) without taking control of the group. Not a public export.\n */\nexport function useRadioGroupRequired({\n value,\n defaultValue,\n onChange,\n onBlur,\n isRequired,\n isInvalid,\n validationBehavior,\n errorMessage,\n requiredValidation,\n}: GroupRequiredProps) {\n const [own, setOwn] = React.useState<string | null>(value ?? defaultValue ?? null);\n const current = value !== undefined ? value : own;\n const required = useRequiredChoice({\n filled: current !== null && current !== \"\",\n isRequired,\n requiredValidation,\n isInvalid,\n errorMessage,\n validationBehavior,\n onBlur: onBlur as ((event: React.FocusEvent) => void) | undefined,\n });\n return {\n errorMessage: required.errorMessage,\n groupProps: {\n isInvalid: required.isInvalid,\n onBlur: required.onBlur as AriaRadioGroupProps[\"onBlur\"],\n onChange: (next: string) => {\n setOwn(next);\n onChange?.(next);\n },\n },\n };\n}\n\n/**\n * Exactly one of two to seven always-visible options. Tab enters and leaves\n * the group; arrow keys move the selection; focusing never selects by itself.\n */\nexport function RadioGroup({\n label,\n items,\n children,\n description,\n errorMessage: errorMessageProp,\n orientation = \"vertical\",\n requiredValidation,\n variant = \"default\",\n size,\n ...rest\n}: RadioGroupProps) {\n const { errorMessage, groupProps } = useRadioGroupRequired({ ...rest, errorMessage: errorMessageProp, requiredValidation });\n return (\n <AriaRadioGroup\n {...rest}\n {...groupProps}\n orientation={orientation}\n data-slot=\"radio-group\"\n data-variant={variant}\n className={FIELD_STACK}\n >\n <FieldLabel isRequired={rest.isRequired}>{label}</FieldLabel>\n <RadioVariant.Provider value={variant}>\n <ChoiceSizeContext.Provider value={size}>\n <div\n data-slot=\"radio-group-items\"\n className={cn(\n variant === \"card\"\n ? \"grid grid-cols-[repeat(auto-fit,minmax(min(180px,100%),1fr))] gap-ds-150\"\n : cn(\"flex gap-ds-100\", orientation === \"vertical\" ? \"flex-col items-start\" : \"flex-wrap gap-x-ds-300\"),\n )}\n >\n {items\n ? items.map((item) => (\n <Radio key={item.value} value={item.value} description={item.description} isDisabled={item.isDisabled}>\n {item.label}\n </Radio>\n ))\n : children}\n </div>\n </ChoiceSizeContext.Provider>\n </RadioVariant.Provider>\n {description && <FieldDescription>{description}</FieldDescription>}\n <FieldError>{errorMessage}</FieldError>\n </AriaRadioGroup>\n );\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type WithRadius } from "../defaults.js";
|
|
3
|
+
import { type MultiSelectProps } from "./multi-select.js";
|
|
4
|
+
import { type SelectProps as SingleSelectProps } from "./select.js";
|
|
5
|
+
export type SelectSingleProps = SingleSelectProps & {
|
|
6
|
+
/** `single` (default): one choice from a known list. */
|
|
7
|
+
selectionMode?: "single";
|
|
8
|
+
};
|
|
9
|
+
export type SelectMultipleProps = MultiSelectProps & {
|
|
10
|
+
/** `multiple`: several choices, shown as removable tags, with an optional select-all. */
|
|
11
|
+
selectionMode: "multiple";
|
|
12
|
+
};
|
|
13
|
+
export type SelectProps = (SelectSingleProps | SelectMultipleProps) & WithRadius;
|
|
14
|
+
/**
|
|
15
|
+
* A choice from a known list in a dropdown: one (`selectionMode="single"`, the default) or several
|
|
16
|
+
* (`selectionMode="multiple"`, shown as tags), as HeroUI and Ant Design model it. For a long list to search, use
|
|
17
|
+
* ComboBox, which takes the same `selectionMode`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ComponentDefaultsProvider, splitRadius } from "../defaults.js";
|
|
5
|
+
import { MultiSelect } from "./multi-select.js";
|
|
6
|
+
import { Select as SingleSelect } from "./select.js";
|
|
7
|
+
/**
|
|
8
|
+
* A choice from a known list in a dropdown: one (`selectionMode="single"`, the default) or several
|
|
9
|
+
* (`selectionMode="multiple"`, shown as tags), as HeroUI and Ant Design model it. For a long list to search, use
|
|
10
|
+
* ComboBox, which takes the same `selectionMode`.
|
|
11
|
+
*/
|
|
12
|
+
export const Select = React.forwardRef(function Select(allProps, ref) {
|
|
13
|
+
const [radius, props] = splitRadius(allProps);
|
|
14
|
+
return _jsx(ComponentDefaultsProvider, { value: { radius }, children: choose(props, ref) });
|
|
15
|
+
});
|
|
16
|
+
function choose(props, ref) {
|
|
17
|
+
if (props.selectionMode === "multiple") {
|
|
18
|
+
const { selectionMode: _mode, ...rest } = props;
|
|
19
|
+
return _jsx(MultiSelect, { ...rest });
|
|
20
|
+
}
|
|
21
|
+
const { selectionMode: _mode, ...rest } = props;
|
|
22
|
+
return _jsx(SingleSelect, { ...rest, ref: ref });
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=select-public.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-public.js","sourceRoot":"","sources":["../../src/selection/select-public.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAmB,MAAM,aAAa,CAAC;AACtF,OAAO,EAAE,WAAW,EAAyB,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,MAAM,IAAI,YAAY,EAAyC,MAAM,UAAU,CAAC;AAYzF;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,UAAU,CAAiC,SAAS,MAAM,CAAC,QAAQ,EAAE,GAAG;IAClG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAyC,CAAC;IACtF,OAAO,KAAC,yBAAyB,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,YAAG,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAA6B,CAAC;AACxG,CAAC,CAAC,CAAC;AAEH,SAAS,MAAM,CAAC,KAAkB,EAAE,GAA0C;IAC5E,IAAI,KAAK,CAAC,aAAa,KAAK,UAAU,EAAE,CAAC;QACvC,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;QAChD,OAAO,KAAC,WAAW,OAAK,IAAI,GAAI,CAAC;IACnC,CAAC;IACD,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,CAAC;IAChD,OAAO,KAAC,YAAY,OAAK,IAAI,EAAE,GAAG,EAAE,GAAG,GAAI,CAAC;AAC9C,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\n\nimport { ComponentDefaultsProvider, splitRadius, type WithRadius } from \"../defaults\";\nimport { MultiSelect, type MultiSelectProps } from \"./multi-select\";\nimport { Select as SingleSelect, type SelectProps as SingleSelectProps } from \"./select\";\n\nexport type SelectSingleProps = SingleSelectProps & {\n /** `single` (default): one choice from a known list. */\n selectionMode?: \"single\";\n};\nexport type SelectMultipleProps = MultiSelectProps & {\n /** `multiple`: several choices, shown as removable tags, with an optional select-all. */\n selectionMode: \"multiple\";\n};\nexport type SelectProps = (SelectSingleProps | SelectMultipleProps) & WithRadius;\n\n/**\n * A choice from a known list in a dropdown: one (`selectionMode=\"single\"`, the default) or several\n * (`selectionMode=\"multiple\"`, shown as tags), as HeroUI and Ant Design model it. For a long list to search, use\n * ComboBox, which takes the same `selectionMode`.\n */\nexport const Select = React.forwardRef<HTMLButtonElement, SelectProps>(function Select(allProps, ref) {\n const [radius, props] = splitRadius(allProps) as [SelectProps[\"radius\"], SelectProps];\n return <ComponentDefaultsProvider value={{ radius }}>{choose(props, ref)}</ComponentDefaultsProvider>;\n});\n\nfunction choose(props: SelectProps, ref: React.ForwardedRef<HTMLButtonElement>) {\n if (props.selectionMode === \"multiple\") {\n const { selectionMode: _mode, ...rest } = props;\n return <MultiSelect {...rest} />;\n }\n const { selectionMode: _mode, ...rest } = props;\n return <SingleSelect {...rest} ref={ref} />;\n}\n"]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type Key } from "react-aria-components";
|
|
3
|
+
import { type FieldSize } from "../form/styles.js";
|
|
4
|
+
import { type RequiredValidation } from "../form/validation.js";
|
|
5
|
+
import { type SelectItem } from "./listbox.js";
|
|
6
|
+
/**
|
|
7
|
+
* The trigger looks like a TextField frame. It is a button, so the field
|
|
8
|
+
* states come from the button and the Select root: keyboard focus or an
|
|
9
|
+
* open menu draw the 2px focused edge (border + 1px inner line), invalid the
|
|
10
|
+
* same in `ds-border-danger`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SELECT_TRIGGER: string;
|
|
13
|
+
/**
|
|
14
|
+
* A visible `label` above the field, or, where the context already names it
|
|
15
|
+
* (a toolbar filter next to its heading, a table cell), an `aria-label`
|
|
16
|
+
* instead. Exactly one of the two is given.
|
|
17
|
+
*/
|
|
18
|
+
export type SelectLabelProps = {
|
|
19
|
+
/** The label sits above the field. */
|
|
20
|
+
label: React.ReactNode;
|
|
21
|
+
"aria-label"?: never;
|
|
22
|
+
} | {
|
|
23
|
+
label?: never;
|
|
24
|
+
/** Names the field for assistive technology when no visible label is shown. */
|
|
25
|
+
"aria-label": string;
|
|
26
|
+
};
|
|
27
|
+
export type SelectProps = SelectLabelProps & {
|
|
28
|
+
/** Up to ~15 options; more, or options people know by name → ComboBox. */
|
|
29
|
+
items: readonly SelectItem[];
|
|
30
|
+
/** Controlled value; `null` is "nothing chosen". It may start undefined and become set later. */
|
|
31
|
+
selectedKey?: Key | null;
|
|
32
|
+
defaultSelectedKey?: Key | null;
|
|
33
|
+
onSelectionChange?: (key: Key | null) => void;
|
|
34
|
+
/** Defaults to "Select" in the provider locale. */
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
description?: React.ReactNode;
|
|
37
|
+
errorMessage?: React.ReactNode;
|
|
38
|
+
isInvalid?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Set by a form row that owns the error text (the shared `Field` hands its control `aria-invalid`): the field
|
|
41
|
+
* shows its invalid state as with `isInvalid`, and without an `errorMessage` of its own draws no error row,
|
|
42
|
+
* so the row's message is the only one. The trigger is a button, on which React Aria sets no
|
|
43
|
+
* `aria-invalid`: the forwarded invalid state shows as `data-invalid` on the field (its danger border) and
|
|
44
|
+
* through the row's own error text, not as `aria-invalid` on the trigger. It marks the field invalid for styling and
|
|
45
|
+
* assistive tech only: unlike `isInvalid` it never becomes the field's native validity (React Aria's default
|
|
46
|
+
* outside a DS Form), so it never blocks a form's submit.
|
|
47
|
+
*/
|
|
48
|
+
"aria-invalid"?: boolean | "true" | "false";
|
|
49
|
+
isRequired?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Who says an empty required Select is missing: `field` (default)
|
|
52
|
+
* shows "Fill in this field." on blur and on a DS Form submit, which it then blocks; `app` only marks the field
|
|
53
|
+
* (`*`, `aria-required`) and the app shows its own error. See {@link RequiredValidation}.
|
|
54
|
+
* The app's `isInvalid` (`true` with its `errorMessage`, or `false`) overrides the check, as on TextField. Disabled,
|
|
55
|
+
* empty and required, it still blocks a DS Form's submit and cannot take focus (as TextField).
|
|
56
|
+
*/
|
|
57
|
+
requiredValidation?: RequiredValidation;
|
|
58
|
+
isDisabled?: boolean;
|
|
59
|
+
/** `compact` (32px) for table filters and toolbars. */
|
|
60
|
+
size?: FieldSize;
|
|
61
|
+
name?: string;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* One value from a short list without typing. The menu opens below, at least
|
|
65
|
+
* as wide as the field; arrows move, typing jumps to the first match, Enter
|
|
66
|
+
* selects, Esc closes and returns focus to the field.
|
|
67
|
+
*
|
|
68
|
+
*: the underlying Select is always controlled by this wrapper, so
|
|
69
|
+
* a consumer passing `selectedKey={undefined}` first and a value later never
|
|
70
|
+
* flips React between uncontrolled and controlled.
|
|
71
|
+
*/
|
|
72
|
+
export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|