@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,162 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type WithMotion } from "../defaults.js";
|
|
3
|
+
import { type ButtonActionProps } from "../action/button.js";
|
|
4
|
+
import { type DataAttributes, type OpenProps, type OverlaySize } from "./overlay-base.js";
|
|
5
|
+
/**
|
|
6
|
+
* `isDisabled`: the action cannot be pressed yet, e.g. until the form is valid.
|
|
7
|
+
* `iconBefore` / `iconAfter`: a Lucide icon beside the label ("Continue" with `arrow-right`), as on
|
|
8
|
+
* Button. The label is always shown and is the button's name, so the icon is decorative (`aria-hidden`); the
|
|
9
|
+
* button keeps its size and focus ring. Left out, the button's DOM is unchanged.
|
|
10
|
+
*/
|
|
11
|
+
export type DialogAction = Pick<ButtonActionProps, "isPending" | "isDisabled" | "iconBefore" | "iconAfter"> & DataAttributes & {
|
|
12
|
+
/** The verb of the title: "Cancel order", never "OK". */
|
|
13
|
+
label: string;
|
|
14
|
+
/** `danger` for a destructive action (delete, discard): the button turns red. */
|
|
15
|
+
tone?: "neutral" | "danger";
|
|
16
|
+
onPress?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* The `id` of the form this action submits: the button becomes `type="submit"` with that `form`
|
|
19
|
+
* attribute, so it submits the form from the footer, outside the form element, and Enter in one of the form's
|
|
20
|
+
* fields submits it too (the browser's implicit submission). Handle the submit in the form's `onSubmit`;
|
|
21
|
+
* `onPress`, when given, still runs first. `isDisabled` keeps the form from submitting (click or Enter), and
|
|
22
|
+
* so does `isPending`: while pending, a submit of that form is stopped before it reaches `onSubmit`, so the
|
|
23
|
+
* action never runs twice. Left out, the button is `type="button"` as before.
|
|
24
|
+
*
|
|
25
|
+
* The id must be unique on the page. With two forms of that id, the browser's `form=` targets the first one in
|
|
26
|
+
* document order, and the pending block also stops a submit of a same-id form outside the dialog.
|
|
27
|
+
*/
|
|
28
|
+
form?: string;
|
|
29
|
+
};
|
|
30
|
+
/** The secondary action: "Cancel" (closing) unless given a label or a handler. Not exported: DialogProps["secondaryAction"] names it. */
|
|
31
|
+
type DialogSecondaryAction = Pick<ButtonActionProps, "iconBefore" | "iconAfter"> & DataAttributes & {
|
|
32
|
+
label?: string;
|
|
33
|
+
onPress?: () => void;
|
|
34
|
+
isDisabled?: boolean;
|
|
35
|
+
};
|
|
36
|
+
export type DialogProps = OpenProps & DataAttributes & {
|
|
37
|
+
title: React.ReactNode;
|
|
38
|
+
/**
|
|
39
|
+
* One short line under the title: what the dialog is about. When given, the dialog is
|
|
40
|
+
* described by it (`aria-describedby`); without it (or with `""`, `false`, `null`) nothing is rendered.
|
|
41
|
+
*/
|
|
42
|
+
description?: React.ReactNode;
|
|
43
|
+
children: React.ReactNode;
|
|
44
|
+
primaryAction?: DialogAction;
|
|
45
|
+
/**
|
|
46
|
+
* "Cancel" by default, closing the dialog; pass a label or a handler to change it. `isDisabled`
|
|
47
|
+
* blocks it, e.g. while the primary action runs; `iconBefore` / `iconAfter` add a
|
|
48
|
+
* decorative icon. `null` leaves it out: a
|
|
49
|
+
* full-screen dialog whose steps carry their own buttons, or a locked completion view, has no secondary action,
|
|
50
|
+
* and with no `primaryAction` either it has no footer at all (the body then takes the bottom padding, and on
|
|
51
|
+
* `fullscreen` reaches down to the home indicator). With `null` and a `danger` primary there is no safe button
|
|
52
|
+
* to focus first, so focus goes to the body's first field (as for any other dialog), or to the dialog itself
|
|
53
|
+
* when the body has none. `data-*` keys reach the button.
|
|
54
|
+
*/
|
|
55
|
+
secondaryAction?: DialogSecondaryAction | null;
|
|
56
|
+
/**
|
|
57
|
+
* The footer's content, in place of `primaryAction` and `secondaryAction`: a checkbox beside the buttons, three
|
|
58
|
+
* actions, a link. It sits in the same footer (spacing, `footerLayout`, the notch and home-indicator insets);
|
|
59
|
+
* close from it with `useDialogClose()`. As Drawer's `footer`.
|
|
60
|
+
*/
|
|
61
|
+
footer?: React.ReactNode;
|
|
62
|
+
/**
|
|
63
|
+
* Leaves out the close button in the header, and does nothing else: Esc and a press outside
|
|
64
|
+
* still follow `isDismissable`. A locked view the user must not dismiss before the flow ends, such as a
|
|
65
|
+
* completion step, sets both: `isCloseButtonHidden` and `isDismissable={false}`. It then closes only when the
|
|
66
|
+
* app closes it (`isOpen`/`onOpenChange`, or an action whose handler does) or through the secondary action, when
|
|
67
|
+
* there is one; a locked dialog inside a DialogTrigger has no close handle, so control it with `isOpen`. Focus
|
|
68
|
+
* stays trapped inside and the title still names the dialog. Give it a way on (a `primaryAction` or a control
|
|
69
|
+
* in the body): with the close button hidden and nothing a keyboard can reach inside, the dialog warns in
|
|
70
|
+
* development (with `isDismissable` Esc still closes it, but a touch user on `fullscreen` has no press outside).
|
|
71
|
+
*/
|
|
72
|
+
isCloseButtonHidden?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The element that takes focus when the dialog opens, in place of the DS rule (the first field,
|
|
75
|
+
* or the secondary action before a `danger` primary). Pass a ref to an element inside the dialog. Left
|
|
76
|
+
* out, or empty when the dialog opens, the rule applies as before.
|
|
77
|
+
*
|
|
78
|
+
* The ref keeps focus only if, once the dialog calls its `focus()`, focus is on that element or inside it;
|
|
79
|
+
* otherwise the rule applies after all. So a ref to an element that cannot take focus (a container without a
|
|
80
|
+
* `tabIndex`, a hidden title) falls through to the rule, and so does a ref whose own focus handler moves focus
|
|
81
|
+
* to an element outside it: the rule then moves focus again, to the safe action or the first field (with
|
|
82
|
+
* neither, focus stays where the handler put it). A handler that moves focus to an element inside the ref keeps
|
|
83
|
+
* it there. To open on a container, give it `tabIndex={-1}`; to open on another element, pass that element's ref.
|
|
84
|
+
*/
|
|
85
|
+
initialFocusRef?: React.RefObject<HTMLElement | null>;
|
|
86
|
+
/**
|
|
87
|
+
* Where focus goes when the dialog closes, in place of the element that opened it (the
|
|
88
|
+
* trigger): the next step's heading, or a control that stays when the trigger is gone. Read when the dialog
|
|
89
|
+
* closes, so it may point at an element mounted by then. If the app has already moved focus elsewhere on
|
|
90
|
+
* close, it stays there; if the ref is empty, focus returns to the trigger as before.
|
|
91
|
+
*/
|
|
92
|
+
returnFocusRef?: React.RefObject<HTMLElement | null>;
|
|
93
|
+
/**
|
|
94
|
+
* A ref to the title's heading, for an app that puts focus on the title: on open (a completion view,
|
|
95
|
+
* "Password saved"), or when the dialog's content moves to its next step. Given, the heading takes
|
|
96
|
+
* `tabIndex={-1}`: focusable from code (`titleRef.current.focus()`), never a Tab stop, and a pointer press on it
|
|
97
|
+
* focuses it. It stays the dialog's heading (`role` heading, level 2) and its name (`aria-labelledby`), so a screen
|
|
98
|
+
* reader reads "heading" with the title when focus lands on it.
|
|
99
|
+
*
|
|
100
|
+
* To open on the title, pass the same ref as `initialFocusRef` (`initialFocusRef={titleRef}`): that ref comes first
|
|
101
|
+
* on open, before the first field and the safe secondary action, as for any other element. The title shows the DS
|
|
102
|
+
* focus ring only for keyboard focus (`:focus-visible`), never for a pointer user's; focus on close returns as
|
|
103
|
+
* before (`returnFocusRef`, or the trigger). Left out, the heading renders exactly as before.
|
|
104
|
+
*
|
|
105
|
+
* A hidden title (`isTitleHidden`, fullscreen) is never a focus target: it is `sr-only`, so focus on it would show
|
|
106
|
+
* no indicator. With `isTitleHidden` the ref still holds the heading, but it takes no `tabIndex` and no focus ring,
|
|
107
|
+
* so `titleRef.current.focus()` does nothing and `initialFocusRef={titleRef}` falls through to the dialog's own
|
|
108
|
+
* rule (the first field, or the safe secondary action). To land on something there, aim at a visible element
|
|
109
|
+
* instead: the first field (the default), or a visible heading or control in the body via `initialFocusRef`.
|
|
110
|
+
*/
|
|
111
|
+
titleRef?: React.Ref<HTMLHeadingElement>;
|
|
112
|
+
/**
|
|
113
|
+
* `data-*` attributes for the dialog's parts: `header`, `title`, `body`, `footer` and the
|
|
114
|
+
* `close` button. The dialog itself (`role="dialog"`, `data-slot="dialog"`) takes the `data-*` props given to
|
|
115
|
+
* Dialog (`data-testid="set-password"`); the actions take theirs on `primaryAction` / `secondaryAction`. The
|
|
116
|
+
* footer's `data-layout` (`spread`) is the DS's own, like `data-slot`: `partData.footer` cannot set it.
|
|
117
|
+
*/
|
|
118
|
+
partData?: Partial<Record<"header" | "title" | "body" | "footer" | "close", DataAttributes>>;
|
|
119
|
+
/**
|
|
120
|
+
* `small` (default, 440px), `medium` (600px) or `large` (800px); `xlarge` (1152px) for a form in two
|
|
121
|
+
* or three columns over the page it edits, such as an order edit; or `fullscreen` for a long
|
|
122
|
+
* task that needs the whole screen, such as a signup: it fills the viewport at every width, slides up as a sheet
|
|
123
|
+
* on phones (below 640px) and fades in above. The header (title, close) and the footer (actions) stay put, clear
|
|
124
|
+
* of the notch and the home indicator, while the body scrolls between them. Below its width every size but
|
|
125
|
+
* `fullscreen` takes the viewport less 24px a side, and its body scrolls inside 100dvh less 48px. Focus, Esc and
|
|
126
|
+
* naming are the same at every size.
|
|
127
|
+
*/
|
|
128
|
+
size?: OverlaySize | "xlarge" | "fullscreen";
|
|
129
|
+
/**
|
|
130
|
+
* Scrim click and Esc close it (default). Off for destructive flows with typed input. A `fullscreen`
|
|
131
|
+
* dialog has no scrim, so a press outside it (a toast or banner layered above) never closes it; there
|
|
132
|
+
* this prop controls Esc only. It is independent of `isCloseButtonHidden`: a locked view sets
|
|
133
|
+
* both, `isCloseButtonHidden` and `isDismissable={false}`; a locked dialog inside a DialogTrigger has no close
|
|
134
|
+
* handle, so control it with `isOpen`.
|
|
135
|
+
*/
|
|
136
|
+
isDismissable?: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* `fullscreen` only. How the footer places its actions: `end` (default) groups them at the
|
|
139
|
+
* inline end; `spread` puts the secondary action at the inline start and the primary at the inline end
|
|
140
|
+
* ("Back" … "Continue"), mirrored in RTL. A lone primary action stays at the end; a lone secondary action
|
|
141
|
+
* (no `primaryAction`) sits at the inline start.
|
|
142
|
+
*/
|
|
143
|
+
footerLayout?: "end" | "spread";
|
|
144
|
+
/**
|
|
145
|
+
* `fullscreen` only. Shown before the title in the header, such as the product's logo. The
|
|
146
|
+
* title then keeps to one line and truncates with an ellipsis (its full text is still the dialog's name);
|
|
147
|
+
* the close button keeps its place at the inline end.
|
|
148
|
+
*/
|
|
149
|
+
headerLeading?: React.ReactNode;
|
|
150
|
+
/**
|
|
151
|
+
* `fullscreen` only. Hides the title visually, for a frame whose header shows a logo instead;
|
|
152
|
+
* the title stays in the DOM and still names the dialog (`aria-labelledby`), so `title` is still required.
|
|
153
|
+
* A description, when given, stays visible. An empty title (`""`, blank, `null`, `false`) would leave the dialog
|
|
154
|
+
* unnamed, and warns in development.
|
|
155
|
+
*/
|
|
156
|
+
isTitleHidden?: boolean;
|
|
157
|
+
};
|
|
158
|
+
/** The close of the Dialog around it, for a custom `footer` or the body; it does nothing outside a Dialog. */
|
|
159
|
+
export declare function useDialogClose(): () => void;
|
|
160
|
+
/** Dialog with its own `motion` (auto, reduce or none); see DialogBody for the component itself. */
|
|
161
|
+
export declare function Dialog({ motion, ...props }: DialogProps & WithMotion): React.JSX.Element;
|
|
162
|
+
export {};
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Dialog as AriaDialog, Heading, Modal, ModalOverlay, useLocale } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { MotionScope, useMotionAttribute } from "../defaults.js";
|
|
7
|
+
import { Button } from "../action/button.js";
|
|
8
|
+
import { CloseButton } from "../action/close-button.js";
|
|
9
|
+
import { cancelLabel as defaultCancelLabel } from "../i18n.js";
|
|
10
|
+
import { BLANKET, DIALOG_ELEMENT, DialogFrame, OverlayContents, dataAttributes, hasDescription, useBlockedSubmit, useInitialFocus, useNarrow, useOverlayOpen, useReturnFocus, useStrandedWarning } from "./overlay-base.js";
|
|
11
|
+
/**
|
|
12
|
+
* The full-screen frame: the modal covers the viewport, edge to edge, at every width. On a phone
|
|
13
|
+
* (below 640px, Drawer's query) it is presented as a sheet sliding up from the bottom edge; above, it fades in.
|
|
14
|
+
* The side insets (landscape notch) pad the modal; the top and bottom ones pad the header and the footer.
|
|
15
|
+
* Small, medium and large never come here: their frame above is unchanged.
|
|
16
|
+
*/
|
|
17
|
+
function FullScreenFrame({ children, isDismissable, isOpen, onClose, describedBy, rootData }) {
|
|
18
|
+
const sheet = useNarrow();
|
|
19
|
+
return (_jsx(ModalOverlay, { ...useMotionAttribute(), isOpen: isOpen, onOpenChange: (next) => {
|
|
20
|
+
if (!next)
|
|
21
|
+
onClose();
|
|
22
|
+
},
|
|
23
|
+
// No scrim to press: a press on something layered above the frame (a toast, a cookie banner) must not
|
|
24
|
+
// close it, so outside presses never dismiss; `isDismissable` decides Esc alone.
|
|
25
|
+
isDismissable: false, isKeyboardDismissDisabled: !isDismissable, "data-slot": "dialog-overlay", className: BLANKET, children: _jsx(Modal, { "data-slot": "dialog-modal", "data-size": "fullscreen", "data-presentation": sheet ? "sheet" : "fullscreen", className: cn("fixed inset-0 flex flex-col overflow-hidden bg-ds-surface-overlay text-ds-text outline-hidden", "ps-[env(safe-area-inset-left,0px)] pe-[env(safe-area-inset-right,0px)] rtl:ps-[env(safe-area-inset-right,0px)] rtl:pe-[env(safe-area-inset-left,0px)]", "duration-(--ds-duration-slow) ease-ds-enter data-[exiting]:ease-ds-exit motion-reduce:transition-none", sheet
|
|
26
|
+
? "transition-[translate] data-[entering]:translate-y-full data-[exiting]:translate-y-full"
|
|
27
|
+
: "transition-opacity data-[entering]:opacity-0 data-[exiting]:opacity-0"), children: _jsx(AriaDialog, { ...rootData, "aria-describedby": describedBy, "data-slot": "dialog", className: DIALOG_ELEMENT, children: _jsx(OverlayContents, { children: children }) }) }) }));
|
|
28
|
+
}
|
|
29
|
+
/** Pulled into the corner so its icon lines up with the padding, not its 32px hit area. */
|
|
30
|
+
function CornerClose({ onPress, slot, data }) {
|
|
31
|
+
return (_jsx("span", { "data-slot": `${slot}-wrap`, className: "-me-ds-100 -mt-ds-050 flex", children: _jsx(CloseButton, { ...data, "data-slot": slot, onPress: onPress }) }));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The full-screen parts. Header and footer never shrink and the body is the one scroll container
|
|
35
|
+
* between them, so they stay at the top and bottom; the header clears the notch, the footer the home indicator.
|
|
36
|
+
*/
|
|
37
|
+
const FULL_HEADER = "flex shrink-0 items-start justify-between gap-ds-200 border-b border-ds-border px-ds-300 pb-ds-200 pt-[max(var(--ds-space-300),env(safe-area-inset-top,0px))]";
|
|
38
|
+
const FULL_BODY = "min-h-0 flex-1 overflow-y-auto overscroll-contain px-ds-300 py-ds-300 text-body text-ds-text-subtle";
|
|
39
|
+
const FULL_FOOTER = "flex shrink-0 flex-wrap items-center justify-end gap-ds-100 border-t border-ds-border px-ds-300 pt-ds-200 pb-[max(var(--ds-space-300),env(safe-area-inset-bottom,0px))]";
|
|
40
|
+
/** A node that renders something: the `headerLeading` test (`null`, `false`, `true`, `""` count as none). */
|
|
41
|
+
const isRenderable = hasDescription;
|
|
42
|
+
// The full-screen options, each added to the classes above only when used, so a full-screen
|
|
43
|
+
// dialog without them renders exactly as before.
|
|
44
|
+
/** No footer: the body is the last part, so it clears the home indicator itself (as Drawer's body does). */
|
|
45
|
+
const FULL_BODY_NO_FOOTER = "min-h-0 flex-1 overflow-y-auto overscroll-contain px-ds-300 pt-ds-300 pb-[max(var(--ds-space-300),env(safe-area-inset-bottom,0px))] text-body text-ds-text-subtle";
|
|
46
|
+
/** `footerLayout="spread"`: the secondary takes the free space after it, so it sits at the start and the primary at the end. */
|
|
47
|
+
const FOOTER_SPREAD = "[&>[data-slot=dialog-secondary]]:me-auto";
|
|
48
|
+
/** A hidden title is out of flow, so the close button is held at the inline end on its own. */
|
|
49
|
+
const HEADER_CLOSE_END = "[&>[data-slot=dialog-close-wrap]]:ms-auto";
|
|
50
|
+
/** With `headerLeading` the title side takes the room left between the slot and the close button. */
|
|
51
|
+
const TITLE_SIDE = "min-w-0 flex-1";
|
|
52
|
+
/** Small, medium and large without a footer (`secondaryAction={null}` and no primary): the body takes the footer's bottom padding. */
|
|
53
|
+
const BODY = "min-h-0 flex-1 overflow-y-auto px-ds-300 py-ds-200 text-body text-ds-text-subtle";
|
|
54
|
+
const BODY_NO_FOOTER = "min-h-0 flex-1 overflow-y-auto px-ds-300 pt-ds-200 pb-ds-300 text-body text-ds-text-subtle";
|
|
55
|
+
/**
|
|
56
|
+
* The title with `titleRef`: the DS focus ring, a 2px ds-border-focused inset ring, for keyboard focus
|
|
57
|
+
* only (`:focus-visible`), as on the drawer grip and the scroll area, so a pointer user never sees one. The browser's
|
|
58
|
+
* own outline is hidden; no outline or external ring is hand-written (focus-outline.test.ts, focus-state.test.ts).
|
|
59
|
+
* The heading's box reaches 4px past its text on each side (`-mx-ds-050 px-ds-050`), so the ring clears the first and
|
|
60
|
+
* last letters while the text stays exactly where it was. Added only with `titleRef`, and only to a visible title: a
|
|
61
|
+
* hidden one (`isTitleHidden`) keeps `sr-only` alone, takes no tabIndex and is never a focus target (its margin and
|
|
62
|
+
* padding would also partly override `sr-only`'s).
|
|
63
|
+
*/
|
|
64
|
+
const TITLE_FOCUSABLE = "-mx-ds-050 px-ds-050 outline-hidden focus-visible:rounded-ds-small focus-visible:inset-ring-2 focus-visible:inset-ring-ds-border-focused";
|
|
65
|
+
/** Closes the dialog it is called in, from a custom `footer` or the body. */
|
|
66
|
+
const DialogCloseContext = React.createContext(() => { });
|
|
67
|
+
/** The close of the Dialog around it, for a custom `footer` or the body; it does nothing outside a Dialog. */
|
|
68
|
+
export function useDialogClose() {
|
|
69
|
+
return React.useContext(DialogCloseContext);
|
|
70
|
+
}
|
|
71
|
+
function DialogContent({ title, description, descriptionId, children, primaryAction, secondaryAction, footer, close, fullScreen, footerLayout, headerLeading, isTitleHidden, isCloseButtonHidden, initialFocusRef, returnFocusRef, partData, titleRef, }) {
|
|
72
|
+
const { locale } = useLocale();
|
|
73
|
+
const body = React.useRef(null);
|
|
74
|
+
const secondary = React.useRef(null);
|
|
75
|
+
const destructive = primaryAction?.tone === "danger";
|
|
76
|
+
const closeHidden = isCloseButtonHidden === true;
|
|
77
|
+
useInitialFocus(body, secondary, destructive, initialFocusRef);
|
|
78
|
+
useReturnFocus(returnFocusRef);
|
|
79
|
+
useBlockedSubmit(primaryAction?.form, primaryAction?.isPending === true);
|
|
80
|
+
useStrandedWarning(closeHidden, body);
|
|
81
|
+
// The full-screen options below reach this component only for `fullscreen` (Dialog drops them for the other sizes).
|
|
82
|
+
const hasStart = isRenderable(headerLeading);
|
|
83
|
+
const custom = footer !== undefined && footer !== null && footer !== false;
|
|
84
|
+
const hasSecondary = !custom && secondaryAction !== null;
|
|
85
|
+
const hasFooter = custom || hasSecondary || (!custom && primaryAction != null);
|
|
86
|
+
const overridden = custom && (primaryAction != null || secondaryAction != null);
|
|
87
|
+
React.useEffect(() => {
|
|
88
|
+
if (process.env.NODE_ENV !== "production" && overridden) {
|
|
89
|
+
console.warn("Dialog: `footer` replaces primaryAction and secondaryAction; they are not rendered.");
|
|
90
|
+
}
|
|
91
|
+
}, [overridden]);
|
|
92
|
+
// A hidden title keeps only `sr-only` (its own margin and size would fight it); with a start slot it truncates.
|
|
93
|
+
const titleClass = isTitleHidden ? "sr-only" : hasStart ? "m-0 truncate text-heading-medium" : "m-0 text-heading-medium";
|
|
94
|
+
// The app's data-* attributes come first in every part, so the DS's own data-slot wins.
|
|
95
|
+
// With `titleRef` the heading takes the ref, tabIndex -1 and the focus ring; without it, nothing changes.
|
|
96
|
+
// A hidden title takes the ref only: an sr-only heading would show no focus indicator, so it is never a focus target.
|
|
97
|
+
const hasTitleRef = titleRef !== undefined && titleRef !== null;
|
|
98
|
+
const titleText = hasTitleRef && isTitleHidden ? (_jsx(Heading, { ...partData?.title, ref: titleRef, slot: "title", "data-slot": "dialog-title", className: titleClass, children: title })) : hasTitleRef ? (_jsx(Heading, { ...partData?.title, ref: titleRef, tabIndex: -1, slot: "title", "data-slot": "dialog-title", className: `${titleClass} ${TITLE_FOCUSABLE}`, children: title })) : (_jsx(Heading, { ...partData?.title, slot: "title", "data-slot": "dialog-title", className: titleClass, children: title }));
|
|
99
|
+
const headerClass = fullScreen ? FULL_HEADER : "flex items-start justify-between gap-ds-200 px-ds-300 pt-ds-300";
|
|
100
|
+
return (_jsxs(DialogCloseContext.Provider, { value: close, children: [_jsxs("div", { ...partData?.header, "data-slot": "dialog-header", className: isTitleHidden ? `${headerClass} ${HEADER_CLOSE_END}` : headerClass, children: [hasStart && (_jsx("div", { "data-slot": "dialog-header-start", className: "flex shrink-0 items-center", children: headerLeading })), hasDescription(description) ? (_jsxs("div", { "data-slot": "dialog-heading", className: hasStart ? `flex flex-col gap-ds-050 ${TITLE_SIDE}` : "flex min-w-0 flex-col gap-ds-050", children: [titleText, _jsx("div", { id: descriptionId, "data-slot": "dialog-description", className: "text-body text-ds-text-subtle", children: description })] })) : hasStart && !isTitleHidden ? (_jsx("div", { "data-slot": "dialog-heading", className: TITLE_SIDE, children: titleText })) : (titleText), !closeHidden && _jsx(CornerClose, { slot: "dialog-close", onPress: close, data: partData?.close })] }), _jsx("div", { ...partData?.body, ref: body, "data-slot": "dialog-body", className: fullScreen ? (hasFooter ? FULL_BODY : FULL_BODY_NO_FOOTER) : hasFooter ? BODY : BODY_NO_FOOTER, children: children }), hasFooter && (_jsxs("div", { ...partData?.footer, "data-slot": "dialog-footer", "data-layout": footerLayout === "spread" ? "spread" : undefined, className: fullScreen ? (footerLayout === "spread" ? `${FULL_FOOTER} ${FOOTER_SPREAD}` : FULL_FOOTER) : "flex flex-wrap items-center justify-end gap-ds-100 px-ds-300 pb-ds-300 pt-ds-100", children: [custom ? footer : null, hasSecondary && (_jsx(Button, { ...dataAttributes(secondaryAction), ref: secondary, variant: "subtle", "data-slot": "dialog-secondary", isDisabled: secondaryAction?.isDisabled, iconBefore: secondaryAction?.iconBefore, iconAfter: secondaryAction?.iconAfter, onPress: () => (secondaryAction?.onPress ? secondaryAction.onPress() : close()), children: secondaryAction?.label ?? defaultCancelLabel(locale) })), !custom && primaryAction && (_jsx(Button, { ...dataAttributes(primaryAction), variant: "primary", tone: primaryAction.tone === "danger" ? "danger" : "neutral", isPending: primaryAction.isPending, isDisabled: primaryAction.isDisabled, iconBefore: primaryAction.iconBefore, iconAfter: primaryAction.iconAfter, onPress: primaryAction.onPress,
|
|
101
|
+
// A form-submit action; without `form` the Button stays type="button".
|
|
102
|
+
type: primaryAction.form ? "submit" : undefined, form: primaryAction.form, "data-slot": "dialog-primary", children: primaryAction.label }))] }))] }));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Development only: the full-screen options a smaller size was given, which it ignores. Only values that would
|
|
106
|
+
* change a full-screen dialog count: `isTitleHidden={false}`, `footerLayout="end"` or an empty
|
|
107
|
+
* `headerLeading` are the defaults there too, so nothing is lost and nothing is said.
|
|
108
|
+
*/
|
|
109
|
+
function useFullScreenOnlyWarning(size, props) {
|
|
110
|
+
const ignored = size === "fullscreen"
|
|
111
|
+
? []
|
|
112
|
+
: [
|
|
113
|
+
props.footerLayout === "spread" && "footerLayout",
|
|
114
|
+
isRenderable(props.headerLeading) && "headerLeading",
|
|
115
|
+
props.isTitleHidden === true && "isTitleHidden",
|
|
116
|
+
].filter((name) => typeof name === "string");
|
|
117
|
+
const signature = ignored.join(", ");
|
|
118
|
+
// One option named takes the singular ("isTitleHidden only applies … ignores it"), several the plural.
|
|
119
|
+
const one = ignored.length === 1;
|
|
120
|
+
React.useEffect(() => {
|
|
121
|
+
if (process.env.NODE_ENV === "production" || !signature)
|
|
122
|
+
return;
|
|
123
|
+
console.warn(`Dialog: ${signature} only ${one ? "applies" : "apply"} to size="fullscreen"; size="${size}" ignores ${one ? "it" : "them"}.`);
|
|
124
|
+
}, [signature, size, one]);
|
|
125
|
+
}
|
|
126
|
+
/** A title that names nothing: empty, blank or not text at all (`""`, `" "`, `null`, `false`, `true`). */
|
|
127
|
+
function isEmptyTitle(title) {
|
|
128
|
+
return title === null || typeof title === "boolean" || (typeof title === "string" && title.trim() === "");
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Development only: `isTitleHidden` with an empty title leaves the dialog without a name, since the
|
|
132
|
+
* hidden title is what names it. A left-out title (`undefined`) is already a TypeScript error, so only the empty
|
|
133
|
+
* values that type-check are said here. Fullscreen only: the other sizes ignore `isTitleHidden` (the fullscreen-only
|
|
134
|
+
* warning names it), so their title shows and names the dialog.
|
|
135
|
+
*/
|
|
136
|
+
function useHiddenEmptyTitleWarning(isTitleHidden, title, fullScreen) {
|
|
137
|
+
const unnamed = fullScreen && isTitleHidden === true && isEmptyTitle(title);
|
|
138
|
+
React.useEffect(() => {
|
|
139
|
+
if (process.env.NODE_ENV === "production" || !unnamed)
|
|
140
|
+
return;
|
|
141
|
+
console.warn("Dialog: isTitleHidden hides the title, but the title is empty, so the dialog has no accessible name. Give it a title; it stays visually hidden.");
|
|
142
|
+
}, [unnamed]);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* A decision or a short input that must be resolved before the user goes on. Put it inside a DialogTrigger
|
|
146
|
+
* after its button, or control it with `isOpen`. Focus moves to the first field (to "Cancel" when the
|
|
147
|
+
* primary action is destructive and "Cancel" is there), stays inside, and returns to the trigger on close; Esc closes it.
|
|
148
|
+
* `size="fullscreen"` covers the viewport, a sheet on phones, for a long task like a signup; it
|
|
149
|
+
* also takes a logo before the title (`headerLeading`), a visually hidden title (`isTitleHidden`) and a spread footer
|
|
150
|
+
* (`footerLayout`). Every size: a primary action that submits a form
|
|
151
|
+
* (`primaryAction.form`), no secondary action (`secondaryAction={null}`; with no primary either, no footer), no
|
|
152
|
+
* close button (`isCloseButtonHidden`; a locked view adds `isDismissable={false}`), `data-*` attributes on the
|
|
153
|
+
* dialog and its parts (`partData`, the actions' own), and focus hooks (`initialFocusRef`, `returnFocusRef`). A
|
|
154
|
+
* focusable title (`titleRef`), which `initialFocusRef` can name to open on it.
|
|
155
|
+
*/
|
|
156
|
+
function DialogBody({ size = "small", isDismissable = true, isOpen, defaultOpen, onOpenChange, footerLayout, headerLeading, isTitleHidden, ...content }) {
|
|
157
|
+
const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });
|
|
158
|
+
const descriptionId = React.useId();
|
|
159
|
+
// Described only when there is a description; otherwise the dialog's DOM is unchanged.
|
|
160
|
+
const describedBy = hasDescription(content.description) ? descriptionId : undefined;
|
|
161
|
+
// The app's data-* props go to the dialog element; none given, nothing is added.
|
|
162
|
+
const rootData = dataAttributes(content);
|
|
163
|
+
useFullScreenOnlyWarning(size, { footerLayout, headerLeading, isTitleHidden });
|
|
164
|
+
useHiddenEmptyTitleWarning(isTitleHidden, content.title, size === "fullscreen");
|
|
165
|
+
if (size === "fullscreen") {
|
|
166
|
+
return (_jsx(FullScreenFrame, { isDismissable: isDismissable, isOpen: state.isOpen, onClose: state.close, describedBy: describedBy, rootData: rootData, children: _jsx(DialogContent, { ...content, footerLayout: footerLayout, headerLeading: headerLeading, isTitleHidden: isTitleHidden, descriptionId: descriptionId, close: state.close, fullScreen: true }) }));
|
|
167
|
+
}
|
|
168
|
+
return (_jsx(DialogFrame, { size: size, isDismissable: isDismissable, escapeCloses: isDismissable, isOpen: state.isOpen, onClose: state.close, describedBy: describedBy, rootData: rootData, children: _jsx(DialogContent, { ...content, descriptionId: descriptionId, close: state.close }) }));
|
|
169
|
+
}
|
|
170
|
+
/** Dialog with its own `motion` (auto, reduce or none); see DialogBody for the component itself. */
|
|
171
|
+
export function Dialog({ motion, ...props }) {
|
|
172
|
+
return (_jsx(MotionScope, { motion: motion, children: _jsx(DialogBody, { ...props }) }));
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../src/overlay/dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK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AAe,IAAC,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,YACrI,KAAC,aAAa,OACR,OAAO,EACX,YAAY,EAAE,YAAY,EAC1B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,UAAU,SACV,GACc,CACnB,CAAC;IACJ,CAAC;IACD,OAAO,CACL,KAAC,WAAW,IAAC,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,YAE1K,KAAC,aAAa,OAAK,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,GACpE,CACf,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,KAAK,EAA4B;IACnE,OAAO,CACL,KAAC,WAAW,IAAC,MAAM,EAAE,MAAM,YACzB,KAAC,UAAU,OAAM,KAAqB,GAAI,GAC9B,CACf,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Dialog as AriaDialog, Heading, Modal, ModalOverlay, useLocale } from \"react-aria-components\";\nimport { cn } from \"../utils\";\nimport { MotionScope, type WithMotion, useMotionAttribute } from \"../defaults\";\nimport { Button, type ButtonActionProps } from \"../action/button\";\nimport { CloseButton } from \"../action/close-button\";\nimport { cancelLabel as defaultCancelLabel } from \"../i18n\";\nimport { BLANKET, DIALOG_ELEMENT, type DataAttributes, DialogFrame, type DialogWidth, type OpenProps, OverlayContents, type OverlaySize, dataAttributes, hasDescription, useBlockedSubmit, useInitialFocus, useNarrow, useOverlayOpen, useReturnFocus, useStrandedWarning } from \"./overlay-base\";\n\n/**\n * `isDisabled`: the action cannot be pressed yet, e.g. until the form is valid.\n * `iconBefore` / `iconAfter`: a Lucide icon beside the label (\"Continue\" with `arrow-right`), as on\n * Button. The label is always shown and is the button's name, so the icon is decorative (`aria-hidden`); the\n * button keeps its size and focus ring. Left out, the button's DOM is unchanged.\n */\nexport type DialogAction = Pick<ButtonActionProps, \"isPending\" | \"isDisabled\" | \"iconBefore\" | \"iconAfter\"> & DataAttributes & {\n /** The verb of the title: \"Cancel order\", never \"OK\". */\n label: string;\n /** `danger` for a destructive action (delete, discard): the button turns red. */\n tone?: \"neutral\" | \"danger\";\n onPress?: () => void;\n /**\n * The `id` of the form this action submits: the button becomes `type=\"submit\"` with that `form`\n * attribute, so it submits the form from the footer, outside the form element, and Enter in one of the form's\n * fields submits it too (the browser's implicit submission). Handle the submit in the form's `onSubmit`;\n * `onPress`, when given, still runs first. `isDisabled` keeps the form from submitting (click or Enter), and\n * so does `isPending`: while pending, a submit of that form is stopped before it reaches `onSubmit`, so the\n * action never runs twice. Left out, the button is `type=\"button\"` as before.\n *\n * The id must be unique on the page. With two forms of that id, the browser's `form=` targets the first one in\n * document order, and the pending block also stops a submit of a same-id form outside the dialog.\n */\n form?: string;\n};\n\n/** The secondary action: \"Cancel\" (closing) unless given a label or a handler. Not exported: DialogProps[\"secondaryAction\"] names it. */\ntype DialogSecondaryAction = Pick<ButtonActionProps, \"iconBefore\" | \"iconAfter\"> & DataAttributes & {\n label?: string;\n onPress?: () => void;\n isDisabled?: boolean;\n};\n\nexport type DialogProps = OpenProps & DataAttributes & {\n title: React.ReactNode;\n /**\n * One short line under the title: what the dialog is about. When given, the dialog is\n * described by it (`aria-describedby`); without it (or with `\"\"`, `false`, `null`) nothing is rendered.\n */\n description?: React.ReactNode;\n children: React.ReactNode;\n primaryAction?: DialogAction;\n /**\n * \"Cancel\" by default, closing the dialog; pass a label or a handler to change it. `isDisabled`\n * blocks it, e.g. while the primary action runs; `iconBefore` / `iconAfter` add a\n * decorative icon. `null` leaves it out: a\n * full-screen dialog whose steps carry their own buttons, or a locked completion view, has no secondary action,\n * and with no `primaryAction` either it has no footer at all (the body then takes the bottom padding, and on\n * `fullscreen` reaches down to the home indicator). With `null` and a `danger` primary there is no safe button\n * to focus first, so focus goes to the body's first field (as for any other dialog), or to the dialog itself\n * when the body has none. `data-*` keys reach the button.\n */\n secondaryAction?: DialogSecondaryAction | null;\n /**\n * The footer's content, in place of `primaryAction` and `secondaryAction`: a checkbox beside the buttons, three\n * actions, a link. It sits in the same footer (spacing, `footerLayout`, the notch and home-indicator insets);\n * close from it with `useDialogClose()`. As Drawer's `footer`.\n */\n footer?: React.ReactNode;\n /**\n * Leaves out the close button in the header, and does nothing else: Esc and a press outside\n * still follow `isDismissable`. A locked view the user must not dismiss before the flow ends, such as a\n * completion step, sets both: `isCloseButtonHidden` and `isDismissable={false}`. It then closes only when the\n * app closes it (`isOpen`/`onOpenChange`, or an action whose handler does) or through the secondary action, when\n * there is one; a locked dialog inside a DialogTrigger has no close handle, so control it with `isOpen`. Focus\n * stays trapped inside and the title still names the dialog. Give it a way on (a `primaryAction` or a control\n * in the body): with the close button hidden and nothing a keyboard can reach inside, the dialog warns in\n * development (with `isDismissable` Esc still closes it, but a touch user on `fullscreen` has no press outside).\n */\n isCloseButtonHidden?: boolean;\n /**\n * The element that takes focus when the dialog opens, in place of the DS rule (the first field,\n * or the secondary action before a `danger` primary). Pass a ref to an element inside the dialog. Left\n * out, or empty when the dialog opens, the rule applies as before.\n *\n * The ref keeps focus only if, once the dialog calls its `focus()`, focus is on that element or inside it;\n * otherwise the rule applies after all. So a ref to an element that cannot take focus (a container without a\n * `tabIndex`, a hidden title) falls through to the rule, and so does a ref whose own focus handler moves focus\n * to an element outside it: the rule then moves focus again, to the safe action or the first field (with\n * neither, focus stays where the handler put it). A handler that moves focus to an element inside the ref keeps\n * it there. To open on a container, give it `tabIndex={-1}`; to open on another element, pass that element's ref.\n */\n initialFocusRef?: React.RefObject<HTMLElement | null>;\n /**\n * Where focus goes when the dialog closes, in place of the element that opened it (the\n * trigger): the next step's heading, or a control that stays when the trigger is gone. Read when the dialog\n * closes, so it may point at an element mounted by then. If the app has already moved focus elsewhere on\n * close, it stays there; if the ref is empty, focus returns to the trigger as before.\n */\n returnFocusRef?: React.RefObject<HTMLElement | null>;\n /**\n * A ref to the title's heading, for an app that puts focus on the title: on open (a completion view,\n * \"Password saved\"), or when the dialog's content moves to its next step. Given, the heading takes\n * `tabIndex={-1}`: focusable from code (`titleRef.current.focus()`), never a Tab stop, and a pointer press on it\n * focuses it. It stays the dialog's heading (`role` heading, level 2) and its name (`aria-labelledby`), so a screen\n * reader reads \"heading\" with the title when focus lands on it.\n *\n * To open on the title, pass the same ref as `initialFocusRef` (`initialFocusRef={titleRef}`): that ref comes first\n * on open, before the first field and the safe secondary action, as for any other element. The title shows the DS\n * focus ring only for keyboard focus (`:focus-visible`), never for a pointer user's; focus on close returns as\n * before (`returnFocusRef`, or the trigger). Left out, the heading renders exactly as before.\n *\n * A hidden title (`isTitleHidden`, fullscreen) is never a focus target: it is `sr-only`, so focus on it would show\n * no indicator. With `isTitleHidden` the ref still holds the heading, but it takes no `tabIndex` and no focus ring,\n * so `titleRef.current.focus()` does nothing and `initialFocusRef={titleRef}` falls through to the dialog's own\n * rule (the first field, or the safe secondary action). To land on something there, aim at a visible element\n * instead: the first field (the default), or a visible heading or control in the body via `initialFocusRef`.\n */\n titleRef?: React.Ref<HTMLHeadingElement>;\n /**\n * `data-*` attributes for the dialog's parts: `header`, `title`, `body`, `footer` and the\n * `close` button. The dialog itself (`role=\"dialog\"`, `data-slot=\"dialog\"`) takes the `data-*` props given to\n * Dialog (`data-testid=\"set-password\"`); the actions take theirs on `primaryAction` / `secondaryAction`. The\n * footer's `data-layout` (`spread`) is the DS's own, like `data-slot`: `partData.footer` cannot set it.\n */\n partData?: Partial<Record<\"header\" | \"title\" | \"body\" | \"footer\" | \"close\", DataAttributes>>;\n /**\n * `small` (default, 440px), `medium` (600px) or `large` (800px); `xlarge` (1152px) for a form in two\n * or three columns over the page it edits, such as an order edit; or `fullscreen` for a long\n * task that needs the whole screen, such as a signup: it fills the viewport at every width, slides up as a sheet\n * on phones (below 640px) and fades in above. The header (title, close) and the footer (actions) stay put, clear\n * of the notch and the home indicator, while the body scrolls between them. Below its width every size but\n * `fullscreen` takes the viewport less 24px a side, and its body scrolls inside 100dvh less 48px. Focus, Esc and\n * naming are the same at every size.\n */\n size?: OverlaySize | \"xlarge\" | \"fullscreen\";\n /**\n * Scrim click and Esc close it (default). Off for destructive flows with typed input. A `fullscreen`\n * dialog has no scrim, so a press outside it (a toast or banner layered above) never closes it; there\n * this prop controls Esc only. It is independent of `isCloseButtonHidden`: a locked view sets\n * both, `isCloseButtonHidden` and `isDismissable={false}`; a locked dialog inside a DialogTrigger has no close\n * handle, so control it with `isOpen`.\n */\n isDismissable?: boolean;\n /**\n * `fullscreen` only. How the footer places its actions: `end` (default) groups them at the\n * inline end; `spread` puts the secondary action at the inline start and the primary at the inline end\n * (\"Back\" … \"Continue\"), mirrored in RTL. A lone primary action stays at the end; a lone secondary action\n * (no `primaryAction`) sits at the inline start.\n */\n footerLayout?: \"end\" | \"spread\";\n /**\n * `fullscreen` only. Shown before the title in the header, such as the product's logo. The\n * title then keeps to one line and truncates with an ellipsis (its full text is still the dialog's name);\n * the close button keeps its place at the inline end.\n */\n headerLeading?: React.ReactNode;\n /**\n * `fullscreen` only. Hides the title visually, for a frame whose header shows a logo instead;\n * the title stays in the DOM and still names the dialog (`aria-labelledby`), so `title` is still required.\n * A description, when given, stays visible. An empty title (`\"\"`, blank, `null`, `false`) would leave the dialog\n * unnamed, and warns in development.\n */\n isTitleHidden?: boolean;\n};\n\n/**\n * The full-screen frame: the modal covers the viewport, edge to edge, at every width. On a phone\n * (below 640px, Drawer's query) it is presented as a sheet sliding up from the bottom edge; above, it fades in.\n * The side insets (landscape notch) pad the modal; the top and bottom ones pad the header and the footer.\n * Small, medium and large never come here: their frame above is unchanged.\n */\nfunction FullScreenFrame({ children, isDismissable, isOpen, onClose, describedBy, rootData }: {\n children: React.ReactNode; isDismissable: boolean; isOpen: boolean; onClose: () => void; describedBy?: string; rootData?: DataAttributes;\n}) {\n const sheet = useNarrow();\n return (\n <ModalOverlay\n {...useMotionAttribute()}\n isOpen={isOpen}\n onOpenChange={(next) => {\n if (!next) onClose();\n }}\n // No scrim to press: a press on something layered above the frame (a toast, a cookie banner) must not\n // close it, so outside presses never dismiss; `isDismissable` decides Esc alone.\n isDismissable={false}\n isKeyboardDismissDisabled={!isDismissable}\n data-slot=\"dialog-overlay\"\n className={BLANKET}\n >\n <Modal\n data-slot=\"dialog-modal\"\n data-size=\"fullscreen\"\n data-presentation={sheet ? \"sheet\" : \"fullscreen\"}\n className={cn(\n \"fixed inset-0 flex flex-col overflow-hidden bg-ds-surface-overlay text-ds-text outline-hidden\",\n \"ps-[env(safe-area-inset-left,0px)] pe-[env(safe-area-inset-right,0px)] rtl:ps-[env(safe-area-inset-right,0px)] rtl:pe-[env(safe-area-inset-left,0px)]\",\n \"duration-(--ds-duration-slow) ease-ds-enter data-[exiting]:ease-ds-exit motion-reduce:transition-none\",\n sheet\n ? \"transition-[translate] data-[entering]:translate-y-full data-[exiting]:translate-y-full\"\n : \"transition-opacity data-[entering]:opacity-0 data-[exiting]:opacity-0\",\n )}\n >\n <AriaDialog {...rootData} aria-describedby={describedBy} data-slot=\"dialog\" className={DIALOG_ELEMENT}>\n <OverlayContents>{children}</OverlayContents>\n </AriaDialog>\n </Modal>\n </ModalOverlay>\n );\n}\n\n/** Pulled into the corner so its icon lines up with the padding, not its 32px hit area. */\nfunction CornerClose({ onPress, slot, data }: { onPress: () => void; slot: string; data?: DataAttributes }) {\n return (\n <span data-slot={`${slot}-wrap`} className=\"-me-ds-100 -mt-ds-050 flex\">\n <CloseButton {...data} data-slot={slot} onPress={onPress} />\n </span>\n );\n}\n\n/**\n * The full-screen parts. Header and footer never shrink and the body is the one scroll container\n * between them, so they stay at the top and bottom; the header clears the notch, the footer the home indicator.\n */\nconst FULL_HEADER =\n \"flex shrink-0 items-start justify-between gap-ds-200 border-b border-ds-border px-ds-300 pb-ds-200 pt-[max(var(--ds-space-300),env(safe-area-inset-top,0px))]\";\n\nconst FULL_BODY = \"min-h-0 flex-1 overflow-y-auto overscroll-contain px-ds-300 py-ds-300 text-body text-ds-text-subtle\";\n\nconst FULL_FOOTER =\n \"flex shrink-0 flex-wrap items-center justify-end gap-ds-100 border-t border-ds-border px-ds-300 pt-ds-200 pb-[max(var(--ds-space-300),env(safe-area-inset-bottom,0px))]\";\n\n/** A node that renders something: the `headerLeading` test (`null`, `false`, `true`, `\"\"` count as none). */\nconst isRenderable = hasDescription;\n\n// The full-screen options, each added to the classes above only when used, so a full-screen\n// dialog without them renders exactly as before.\n\n/** No footer: the body is the last part, so it clears the home indicator itself (as Drawer's body does). */\nconst FULL_BODY_NO_FOOTER = \"min-h-0 flex-1 overflow-y-auto overscroll-contain px-ds-300 pt-ds-300 pb-[max(var(--ds-space-300),env(safe-area-inset-bottom,0px))] text-body text-ds-text-subtle\";\n\n/** `footerLayout=\"spread\"`: the secondary takes the free space after it, so it sits at the start and the primary at the end. */\nconst FOOTER_SPREAD = \"[&>[data-slot=dialog-secondary]]:me-auto\";\n\n/** A hidden title is out of flow, so the close button is held at the inline end on its own. */\nconst HEADER_CLOSE_END = \"[&>[data-slot=dialog-close-wrap]]:ms-auto\";\n\n/** With `headerLeading` the title side takes the room left between the slot and the close button. */\nconst TITLE_SIDE = \"min-w-0 flex-1\";\n\ntype FullScreenOptions = Pick<DialogProps, \"footerLayout\" | \"headerLeading\" | \"isTitleHidden\">;\n\n/** Small, medium and large without a footer (`secondaryAction={null}` and no primary): the body takes the footer's bottom padding. */\nconst BODY = \"min-h-0 flex-1 overflow-y-auto px-ds-300 py-ds-200 text-body text-ds-text-subtle\";\n\nconst BODY_NO_FOOTER = \"min-h-0 flex-1 overflow-y-auto px-ds-300 pt-ds-200 pb-ds-300 text-body text-ds-text-subtle\";\n\ntype ContentOptions = Pick<DialogProps, \"isCloseButtonHidden\" | \"initialFocusRef\" | \"returnFocusRef\" | \"partData\" | \"titleRef\">;\n\n/**\n * The title with `titleRef`: the DS focus ring, a 2px ds-border-focused inset ring, for keyboard focus\n * only (`:focus-visible`), as on the drawer grip and the scroll area, so a pointer user never sees one. The browser's\n * own outline is hidden; no outline or external ring is hand-written (focus-outline.test.ts, focus-state.test.ts).\n * The heading's box reaches 4px past its text on each side (`-mx-ds-050 px-ds-050`), so the ring clears the first and\n * last letters while the text stays exactly where it was. Added only with `titleRef`, and only to a visible title: a\n * hidden one (`isTitleHidden`) keeps `sr-only` alone, takes no tabIndex and is never a focus target (its margin and\n * padding would also partly override `sr-only`'s).\n */\nconst TITLE_FOCUSABLE =\n \"-mx-ds-050 px-ds-050 outline-hidden focus-visible:rounded-ds-small focus-visible:inset-ring-2 focus-visible:inset-ring-ds-border-focused\";\n\n/** Closes the dialog it is called in, from a custom `footer` or the body. */\nconst DialogCloseContext = React.createContext<() => void>(() => {});\n\n/** The close of the Dialog around it, for a custom `footer` or the body; it does nothing outside a Dialog. */\nexport function useDialogClose(): () => void {\n return React.useContext(DialogCloseContext);\n}\n\nfunction DialogContent({\n title, description, descriptionId, children, primaryAction, secondaryAction, footer, close, fullScreen, footerLayout, headerLeading, isTitleHidden,\n isCloseButtonHidden, initialFocusRef, returnFocusRef, partData, titleRef,\n}: Pick<DialogProps, \"title\" | \"description\" | \"children\" | \"primaryAction\" | \"secondaryAction\" | \"footer\"> & FullScreenOptions & ContentOptions & { descriptionId: string; close: () => void; fullScreen?: boolean }) {\n const { locale } = useLocale();\n const body = React.useRef<HTMLDivElement>(null);\n const secondary = React.useRef<HTMLButtonElement>(null);\n const destructive = primaryAction?.tone === \"danger\";\n const closeHidden = isCloseButtonHidden === true;\n useInitialFocus(body, secondary, destructive, initialFocusRef);\n useReturnFocus(returnFocusRef);\n useBlockedSubmit(primaryAction?.form, primaryAction?.isPending === true);\n useStrandedWarning(closeHidden, body);\n // The full-screen options below reach this component only for `fullscreen` (Dialog drops them for the other sizes).\n const hasStart = isRenderable(headerLeading);\n const custom = footer !== undefined && footer !== null && footer !== false;\n const hasSecondary = !custom && secondaryAction !== null;\n const hasFooter = custom || hasSecondary || (!custom && primaryAction != null);\n const overridden = custom && (primaryAction != null || secondaryAction != null);\n React.useEffect(() => {\n if (process.env.NODE_ENV !== \"production\" && overridden) {\n console.warn(\"Dialog: `footer` replaces primaryAction and secondaryAction; they are not rendered.\");\n }\n }, [overridden]);\n // A hidden title keeps only `sr-only` (its own margin and size would fight it); with a start slot it truncates.\n const titleClass = isTitleHidden ? \"sr-only\" : hasStart ? \"m-0 truncate text-heading-medium\" : \"m-0 text-heading-medium\";\n // The app's data-* attributes come first in every part, so the DS's own data-slot wins.\n // With `titleRef` the heading takes the ref, tabIndex -1 and the focus ring; without it, nothing changes.\n // A hidden title takes the ref only: an sr-only heading would show no focus indicator, so it is never a focus target.\n const hasTitleRef = titleRef !== undefined && titleRef !== null;\n const titleText = hasTitleRef && isTitleHidden ? (\n <Heading {...partData?.title} ref={titleRef} slot=\"title\" data-slot=\"dialog-title\" className={titleClass}>{title}</Heading>\n ) : hasTitleRef ? (\n <Heading {...partData?.title} ref={titleRef} tabIndex={-1} slot=\"title\" data-slot=\"dialog-title\" className={`${titleClass} ${TITLE_FOCUSABLE}`}>{title}</Heading>\n ) : (\n <Heading {...partData?.title} slot=\"title\" data-slot=\"dialog-title\" className={titleClass}>{title}</Heading>\n );\n const headerClass = fullScreen ? FULL_HEADER : \"flex items-start justify-between gap-ds-200 px-ds-300 pt-ds-300\";\n return (\n <DialogCloseContext.Provider value={close}>\n <div {...partData?.header} data-slot=\"dialog-header\" className={isTitleHidden ? `${headerClass} ${HEADER_CLOSE_END}` : headerClass}>\n {hasStart && (\n <div data-slot=\"dialog-header-start\" className=\"flex shrink-0 items-center\">{headerLeading}</div>\n )}\n {hasDescription(description) ? (\n <div data-slot=\"dialog-heading\" className={hasStart ? `flex flex-col gap-ds-050 ${TITLE_SIDE}` : \"flex min-w-0 flex-col gap-ds-050\"}>\n {titleText}\n <div id={descriptionId} data-slot=\"dialog-description\" className=\"text-body text-ds-text-subtle\">{description}</div>\n </div>\n ) : hasStart && !isTitleHidden ? (\n <div data-slot=\"dialog-heading\" className={TITLE_SIDE}>{titleText}</div>\n ) : (\n titleText\n )}\n {!closeHidden && <CornerClose slot=\"dialog-close\" onPress={close} data={partData?.close} />}\n </div>\n <div\n {...partData?.body}\n ref={body}\n data-slot=\"dialog-body\"\n className={fullScreen ? (hasFooter ? FULL_BODY : FULL_BODY_NO_FOOTER) : hasFooter ? BODY : BODY_NO_FOOTER}\n >\n {children}\n </div>\n {hasFooter && (\n <div\n {...partData?.footer}\n data-slot=\"dialog-footer\"\n data-layout={footerLayout === \"spread\" ? \"spread\" : undefined}\n className={fullScreen ? (footerLayout === \"spread\" ? `${FULL_FOOTER} ${FOOTER_SPREAD}` : FULL_FOOTER) : \"flex flex-wrap items-center justify-end gap-ds-100 px-ds-300 pb-ds-300 pt-ds-100\"}\n >\n {custom ? footer : null}\n {hasSecondary && (\n <Button\n {...dataAttributes(secondaryAction)}\n ref={secondary}\n variant=\"subtle\"\n data-slot=\"dialog-secondary\"\n isDisabled={secondaryAction?.isDisabled}\n iconBefore={secondaryAction?.iconBefore}\n iconAfter={secondaryAction?.iconAfter}\n onPress={() => (secondaryAction?.onPress ? secondaryAction.onPress() : close())}\n >\n {secondaryAction?.label ?? defaultCancelLabel(locale)}\n </Button>\n )}\n {!custom && primaryAction && (\n <Button\n {...dataAttributes(primaryAction)}\n variant=\"primary\"\n tone={primaryAction.tone === \"danger\" ? \"danger\" : \"neutral\"}\n isPending={primaryAction.isPending}\n isDisabled={primaryAction.isDisabled}\n iconBefore={primaryAction.iconBefore}\n iconAfter={primaryAction.iconAfter}\n onPress={primaryAction.onPress}\n // A form-submit action; without `form` the Button stays type=\"button\".\n type={primaryAction.form ? \"submit\" : undefined}\n form={primaryAction.form}\n data-slot=\"dialog-primary\"\n >\n {primaryAction.label}\n </Button>\n )}\n </div>\n )}\n </DialogCloseContext.Provider>\n );\n}\n\n/**\n * Development only: the full-screen options a smaller size was given, which it ignores. Only values that would\n * change a full-screen dialog count: `isTitleHidden={false}`, `footerLayout=\"end\"` or an empty\n * `headerLeading` are the defaults there too, so nothing is lost and nothing is said.\n */\nfunction useFullScreenOnlyWarning(size: DialogWidth | \"fullscreen\", props: FullScreenOptions) {\n const ignored =\n size === \"fullscreen\"\n ? []\n : [\n props.footerLayout === \"spread\" && \"footerLayout\",\n isRenderable(props.headerLeading) && \"headerLeading\",\n props.isTitleHidden === true && \"isTitleHidden\",\n ].filter((name): name is string => typeof name === \"string\");\n const signature = ignored.join(\", \");\n // One option named takes the singular (\"isTitleHidden only applies … ignores it\"), several the plural.\n const one = ignored.length === 1;\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\" || !signature) return;\n console.warn(`Dialog: ${signature} only ${one ? \"applies\" : \"apply\"} to size=\"fullscreen\"; size=\"${size}\" ignores ${one ? \"it\" : \"them\"}.`);\n }, [signature, size, one]);\n}\n\n/** A title that names nothing: empty, blank or not text at all (`\"\"`, `\" \"`, `null`, `false`, `true`). */\nfunction isEmptyTitle(title: React.ReactNode) {\n return title === null || typeof title === \"boolean\" || (typeof title === \"string\" && title.trim() === \"\");\n}\n\n/**\n * Development only: `isTitleHidden` with an empty title leaves the dialog without a name, since the\n * hidden title is what names it. A left-out title (`undefined`) is already a TypeScript error, so only the empty\n * values that type-check are said here. Fullscreen only: the other sizes ignore `isTitleHidden` (the fullscreen-only\n * warning names it), so their title shows and names the dialog.\n */\nfunction useHiddenEmptyTitleWarning(isTitleHidden: boolean | undefined, title: React.ReactNode, fullScreen: boolean) {\n const unnamed = fullScreen && isTitleHidden === true && isEmptyTitle(title);\n React.useEffect(() => {\n if (process.env.NODE_ENV === \"production\" || !unnamed) return;\n console.warn(\"Dialog: isTitleHidden hides the title, but the title is empty, so the dialog has no accessible name. Give it a title; it stays visually hidden.\");\n }, [unnamed]);\n}\n\n/**\n * A decision or a short input that must be resolved before the user goes on. Put it inside a DialogTrigger\n * after its button, or control it with `isOpen`. Focus moves to the first field (to \"Cancel\" when the\n * primary action is destructive and \"Cancel\" is there), stays inside, and returns to the trigger on close; Esc closes it.\n * `size=\"fullscreen\"` covers the viewport, a sheet on phones, for a long task like a signup; it\n * also takes a logo before the title (`headerLeading`), a visually hidden title (`isTitleHidden`) and a spread footer\n * (`footerLayout`). Every size: a primary action that submits a form\n * (`primaryAction.form`), no secondary action (`secondaryAction={null}`; with no primary either, no footer), no\n * close button (`isCloseButtonHidden`; a locked view adds `isDismissable={false}`), `data-*` attributes on the\n * dialog and its parts (`partData`, the actions' own), and focus hooks (`initialFocusRef`, `returnFocusRef`). A\n * focusable title (`titleRef`), which `initialFocusRef` can name to open on it.\n */\nfunction DialogBody({\n size = \"small\", isDismissable = true, isOpen, defaultOpen, onOpenChange, footerLayout, headerLeading, isTitleHidden, ...content\n}: DialogProps) {\n const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });\n const descriptionId = React.useId();\n // Described only when there is a description; otherwise the dialog's DOM is unchanged.\n const describedBy = hasDescription(content.description) ? descriptionId : undefined;\n // The app's data-* props go to the dialog element; none given, nothing is added.\n const rootData = dataAttributes(content);\n useFullScreenOnlyWarning(size, { footerLayout, headerLeading, isTitleHidden });\n useHiddenEmptyTitleWarning(isTitleHidden, content.title, size === \"fullscreen\");\n if (size === \"fullscreen\") {\n return (\n <FullScreenFrame isDismissable={isDismissable} isOpen={state.isOpen} onClose={state.close} describedBy={describedBy} rootData={rootData}>\n <DialogContent\n {...content}\n footerLayout={footerLayout}\n headerLeading={headerLeading}\n isTitleHidden={isTitleHidden}\n descriptionId={descriptionId}\n close={state.close}\n fullScreen\n />\n </FullScreenFrame>\n );\n }\n return (\n <DialogFrame size={size} isDismissable={isDismissable} escapeCloses={isDismissable} isOpen={state.isOpen} onClose={state.close} describedBy={describedBy} rootData={rootData}>\n {/* The full-screen options stay with `fullscreen`. */}\n <DialogContent {...content} descriptionId={descriptionId} close={state.close} />\n </DialogFrame>\n );\n}\n\n/** Dialog with its own `motion` (auto, reduce or none); see DialogBody for the component itself. */\nexport function Dialog({ motion, ...props }: DialogProps & WithMotion) {\n return (\n <MotionScope motion={motion}>\n <DialogBody {...(props as DialogProps)} />\n </MotionScope>\n );\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type WithMotion } from "../defaults.js";
|
|
3
|
+
import { type OpenProps, type OverlaySize } from "./overlay-base.js";
|
|
4
|
+
export type DrawerProps = OpenProps & {
|
|
5
|
+
title: React.ReactNode;
|
|
6
|
+
/**
|
|
7
|
+
* Under the title: "Jordan Lee · 14–18 Oct". When given, the drawer is described by it
|
|
8
|
+
* (`aria-describedby`); without it (or with `""`, `false`, `null`) nothing is rendered.
|
|
9
|
+
*/
|
|
10
|
+
description?: React.ReactNode;
|
|
11
|
+
/** Beside the close button: a status Badge, a menu. */
|
|
12
|
+
headerActions?: React.ReactNode;
|
|
13
|
+
children: React.ReactNode;
|
|
14
|
+
/** Sticky at the bottom: the record's actions. */
|
|
15
|
+
footer?: React.ReactNode;
|
|
16
|
+
/** small 380px, large 560px (medium reads as large). */
|
|
17
|
+
size?: OverlaySize;
|
|
18
|
+
/**
|
|
19
|
+
* The edge it slides in from, at every width (the app decides, e.g. `bottom` on phones): `end` (default) and
|
|
20
|
+
* `start` are the inline sides and mirror in right-to-left; `bottom` is a sheet that snaps between half and full
|
|
21
|
+
* height; `top` drops down from above.
|
|
22
|
+
*/
|
|
23
|
+
position?: DrawerPosition;
|
|
24
|
+
/** Closing (button, Esc, scrim, useDrawerClose) asks first: "Unsaved changes". */
|
|
25
|
+
hasUnsavedChanges?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type DrawerPosition = "start" | "end" | "top" | "bottom";
|
|
28
|
+
export type DrawerClose = (options?: {
|
|
29
|
+
/**
|
|
30
|
+
* Close without the unsaved question: after a save ("Save and close"), when the parent's
|
|
31
|
+
* `hasUnsavedChanges` has not re-rendered yet.
|
|
32
|
+
*/
|
|
33
|
+
force?: boolean;
|
|
34
|
+
}) => void;
|
|
35
|
+
/**
|
|
36
|
+
* The drawer's close, for its footer or body. By default it asks first with unsaved edits, like the close
|
|
37
|
+
* button, Esc and the scrim; after saving call `close({ force: true })`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useDrawerClose(): DrawerClose;
|
|
40
|
+
/** Drawer with its own `motion` (auto, reduce or none); see DrawerBody for the component itself. */
|
|
41
|
+
export declare function Drawer({ motion, ...props }: DrawerProps & WithMotion): React.JSX.Element;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Dialog as AriaDialog, Heading, Modal, ModalOverlay, useLocale } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { MotionScope, useMotionAttribute } from "../defaults.js";
|
|
7
|
+
import { Button } from "../action/button.js";
|
|
8
|
+
import { CloseButton } from "../action/close-button.js";
|
|
9
|
+
import { collapseSheetLabel, discardCloseLabel, expandSheetLabel, keepEditingLabel, unsavedBodyLabel, unsavedTitleLabel } from "../i18n.js";
|
|
10
|
+
import { BLANKET, DIALOG_ELEMENT, DRAWER_WIDTH, OverlayContents, hasDescription, useOverlayOpen } from "./overlay-base.js";
|
|
11
|
+
const DrawerCloseContext = React.createContext(() => { });
|
|
12
|
+
/**
|
|
13
|
+
* The drawer's close, for its footer or body. By default it asks first with unsaved edits, like the close
|
|
14
|
+
* button, Esc and the scrim; after saving call `close({ force: true })`.
|
|
15
|
+
*/
|
|
16
|
+
export function useDrawerClose() {
|
|
17
|
+
return React.useContext(DrawerCloseContext);
|
|
18
|
+
}
|
|
19
|
+
/** Where each position sits and the way it slides; the sides use logical edges, so right-to-left mirrors them. */
|
|
20
|
+
const DRAWER_POSITION = {
|
|
21
|
+
end: cn(
|
|
22
|
+
// Clear of a notch at the top and, in landscape, at the inline end.
|
|
23
|
+
"inset-y-0 end-0 max-w-full pt-[env(safe-area-inset-top,0px)] pe-[env(safe-area-inset-right,0px)] rtl:pe-[env(safe-area-inset-left,0px)]", "data-[entering]:translate-x-full data-[exiting]:translate-x-full rtl:data-[entering]:-translate-x-full rtl:data-[exiting]:-translate-x-full"),
|
|
24
|
+
start: cn("inset-y-0 start-0 max-w-full pt-[env(safe-area-inset-top,0px)] ps-[env(safe-area-inset-left,0px)] rtl:ps-[env(safe-area-inset-right,0px)]", "data-[entering]:-translate-x-full data-[exiting]:-translate-x-full rtl:data-[entering]:translate-x-full rtl:data-[exiting]:translate-x-full"),
|
|
25
|
+
bottom: "inset-x-0 bottom-0 rounded-t-ds-xlarge data-[entering]:translate-y-full data-[exiting]:translate-y-full",
|
|
26
|
+
top: "inset-x-0 top-0 max-h-[85dvh] rounded-b-ds-xlarge pt-[env(safe-area-inset-top,0px)] data-[entering]:-translate-y-full data-[exiting]:-translate-y-full",
|
|
27
|
+
};
|
|
28
|
+
/** Drag distance on the grip that counts as a swipe rather than a tap (px). */
|
|
29
|
+
const SWIPE = 40;
|
|
30
|
+
/** The sheet's grip: tap toggles half/full; swipe up expands, swipe down collapses (or closes from half). */
|
|
31
|
+
function Grip({ expanded, onExpand, onCollapse, onDismiss }) {
|
|
32
|
+
const { locale } = useLocale();
|
|
33
|
+
const start = React.useRef(null);
|
|
34
|
+
const moved = React.useRef(false);
|
|
35
|
+
return (_jsx("button", { type: "button", "data-slot": "drawer-grip", "aria-label": expanded ? collapseSheetLabel(locale) : expandSheetLabel(locale), "aria-expanded": expanded, onPointerDown: (event) => {
|
|
36
|
+
start.current = event.clientY;
|
|
37
|
+
moved.current = false;
|
|
38
|
+
// Keep the pointer while it drags past the 24px grip (touch is captured anyway; a mouse is not).
|
|
39
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
40
|
+
}, onPointerUp: (event) => {
|
|
41
|
+
if (start.current === null)
|
|
42
|
+
return;
|
|
43
|
+
const dy = event.clientY - start.current;
|
|
44
|
+
start.current = null;
|
|
45
|
+
if (Math.abs(dy) < SWIPE)
|
|
46
|
+
return;
|
|
47
|
+
moved.current = true;
|
|
48
|
+
if (dy < 0)
|
|
49
|
+
onExpand();
|
|
50
|
+
else if (expanded)
|
|
51
|
+
onCollapse();
|
|
52
|
+
else
|
|
53
|
+
onDismiss();
|
|
54
|
+
}, onClick: () => {
|
|
55
|
+
if (moved.current) {
|
|
56
|
+
moved.current = false;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (expanded)
|
|
60
|
+
onCollapse();
|
|
61
|
+
else
|
|
62
|
+
onExpand();
|
|
63
|
+
}, className: "mx-auto mt-ds-100 grid h-6 w-full shrink-0 cursor-grab touch-none place-items-center outline-hidden focus-visible:inset-ring-2 focus-visible:inset-ring-ds-border-focused", children: _jsx("span", { "aria-hidden": true, className: "h-1 w-9 rounded-ds-full bg-ds-border-bold" }) }));
|
|
64
|
+
}
|
|
65
|
+
/** "Unsaved changes": a real nested modal (focus kept inside, the drawer behind it inert, Esc = keep editing). */
|
|
66
|
+
function UnsavedPrompt({ isOpen, onKeep, onDiscard }) {
|
|
67
|
+
const { locale } = useLocale();
|
|
68
|
+
return (_jsx(ModalOverlay, { ...useMotionAttribute(), isOpen: isOpen, onOpenChange: (next) => {
|
|
69
|
+
if (!next)
|
|
70
|
+
onKeep();
|
|
71
|
+
}, isDismissable: true, "data-slot": "drawer-unsaved-overlay", className: cn(BLANKET, "grid place-items-center p-ds-300"), children: _jsx(Modal, { "data-slot": "drawer-unsaved-modal", className: "w-full max-w-90 rounded-ds-xlarge bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden", children: _jsxs(AriaDialog, { role: "alertdialog", "data-slot": "drawer-unsaved", className: "flex flex-col gap-ds-150 p-ds-300 outline-hidden", children: [_jsx(Heading, { slot: "title", "data-slot": "drawer-unsaved-title", className: "m-0 text-heading-small", children: unsavedTitleLabel(locale) }), _jsx("span", { "data-slot": "drawer-unsaved-body", className: "text-body text-ds-text-subtle", children: unsavedBodyLabel(locale) }), _jsxs("div", { "data-slot": "drawer-unsaved-actions", className: "flex flex-wrap justify-end gap-ds-100", children: [_jsx(Button, { variant: "subtle", autoFocus: true, onPress: onKeep, "data-slot": "drawer-keep-editing", children: keepEditingLabel(locale) }), _jsx(Button, { variant: "primary", tone: "danger", onPress: onDiscard, "data-slot": "drawer-discard", children: discardCloseLabel(locale) })] })] }) }) }));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A panel over the page to show or edit one record without losing the list behind it, from the edge `position`
|
|
75
|
+
* names: an inline side (380 or 560px, full height), the bottom (a sheet that snaps between half and full height)
|
|
76
|
+
* or the top. Header with
|
|
77
|
+
* title, description and status; a scrolling body; a sticky footer; both keep clear of notches and the home
|
|
78
|
+
* indicator. With unsaved edits every way of closing asks first. The title names the drawer and the
|
|
79
|
+
* description, when there is one, describes it.
|
|
80
|
+
*/
|
|
81
|
+
function DrawerBody({ size = "small", position = "end", isOpen, defaultOpen, onOpenChange, hasUnsavedChanges, title, description: subtitle, headerActions, children, footer, }) {
|
|
82
|
+
const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });
|
|
83
|
+
const subtitleId = React.useId();
|
|
84
|
+
// Described only when there is a subtitle, as Dialog's description; otherwise the drawer's DOM is unchanged.
|
|
85
|
+
const describedBy = hasDescription(subtitle) ? subtitleId : undefined;
|
|
86
|
+
const bottom = position === "bottom";
|
|
87
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
88
|
+
// A sheet opens at half height every time. Reset as it opens, not as it closes, so the closing slide does
|
|
89
|
+
// not also animate the height down.
|
|
90
|
+
const [wasOpen, setWasOpen] = React.useState(state.isOpen);
|
|
91
|
+
if (wasOpen !== state.isOpen) {
|
|
92
|
+
setWasOpen(state.isOpen);
|
|
93
|
+
if (state.isOpen)
|
|
94
|
+
setExpanded(false);
|
|
95
|
+
}
|
|
96
|
+
const [asking, setAsking] = React.useState(false);
|
|
97
|
+
// Every close request (button, Esc, scrim, grip swipe, useDrawerClose) comes through here.
|
|
98
|
+
const request = () => (hasUnsavedChanges ? setAsking(true) : state.close());
|
|
99
|
+
const close = (options) => (options?.force ? state.close() : request());
|
|
100
|
+
return (_jsx(ModalOverlay, { ...useMotionAttribute(), isOpen: state.isOpen, onOpenChange: (next) => {
|
|
101
|
+
if (!next)
|
|
102
|
+
request();
|
|
103
|
+
}, isDismissable: true, "data-slot": "drawer-overlay", "data-position": position, className: BLANKET, children: _jsx(Modal, { "data-slot": "drawer", className: cn("fixed flex flex-col overflow-hidden bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden", "transition-[translate,height] duration-(--ds-duration-slow) ease-ds-enter data-[exiting]:ease-ds-exit motion-reduce:transition-none", DRAWER_POSITION[position], bottom && (expanded ? "h-[calc(100dvh-env(safe-area-inset-top,0px)-var(--ds-space-200))]" : "h-[50dvh]"), (position === "start" || position === "end") && DRAWER_WIDTH[size]), children: _jsxs(AriaDialog, { "aria-describedby": describedBy, "data-slot": "drawer-dialog", className: DIALOG_ELEMENT, children: [_jsx(OverlayContents, { children: _jsxs(DrawerCloseContext.Provider, { value: close, children: [bottom && (_jsx(Grip, { expanded: expanded, onExpand: () => setExpanded(true), onCollapse: () => setExpanded(false), onDismiss: request })), _jsxs("div", { "data-slot": "drawer-header", className: "flex items-start justify-between gap-ds-200 border-b border-ds-border px-ds-300 py-ds-200", children: [_jsxs("div", { "data-slot": "drawer-heading", className: "flex min-w-0 flex-col gap-ds-025", children: [_jsx(Heading, { slot: "title", "data-slot": "drawer-title", className: "m-0 text-heading-medium", children: title }), describedBy && _jsx("span", { id: describedBy, "data-slot": "drawer-subtitle", className: "text-body-small text-ds-text-subtle", children: subtitle })] }), _jsxs("div", { "data-slot": "drawer-header-actions", className: "flex shrink-0 items-center gap-ds-100", children: [headerActions, _jsx(CloseButton, { "data-slot": "drawer-close", onPress: request })] })] }), _jsx("div", { "data-slot": "drawer-body", className: cn("min-h-0 flex-1 overflow-y-auto px-ds-300 pt-ds-200 text-body",
|
|
104
|
+
// Without a footer the body is the last thing above the home indicator.
|
|
105
|
+
footer ? "pb-ds-200" : "pb-[max(var(--ds-space-200),env(safe-area-inset-bottom,0px))]"), children: children }), footer && (_jsx("div", { "data-slot": "drawer-footer", className: "flex flex-wrap items-center justify-end gap-ds-100 border-t border-ds-border px-ds-300 pt-ds-150 pb-[max(var(--ds-space-150),env(safe-area-inset-bottom,0px))]", children: footer }))] }) }), _jsx(UnsavedPrompt, { isOpen: asking, onKeep: () => setAsking(false), onDiscard: () => {
|
|
106
|
+
setAsking(false);
|
|
107
|
+
state.close();
|
|
108
|
+
} })] }) }) }));
|
|
109
|
+
}
|
|
110
|
+
/** Drawer with its own `motion` (auto, reduce or none); see DrawerBody for the component itself. */
|
|
111
|
+
export function Drawer({ motion, ...props }) {
|
|
112
|
+
return (_jsx(MotionScope, { motion: motion, children: _jsx(DrawerBody, { ...props }) }));
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=drawer.js.map
|