@senvenli/react 0.0.0-stage → 0.1.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,558 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Dialog as AriaDialog, DialogTrigger as AriaDialogTrigger, Heading, Modal, ModalOverlay, OverlayTriggerStateContext, useLocale, } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { Button } from "../action/button.js";
|
|
7
|
+
import { CloseButton } from "../action/close-button.js";
|
|
8
|
+
import { IconGlyph } from "../display/icon.js";
|
|
9
|
+
import { TextField } from "../form/text-field.js";
|
|
10
|
+
import {
|
|
11
|
+
// The prop of the same name (AlertDialog's `cancelLabel`) takes the plain name in this file.
|
|
12
|
+
cancelLabel as defaultCancelLabel, collapseSheetLabel, discardCloseLabel, expandSheetLabel, keepEditingLabel, typeToConfirmLabel, unsavedBodyLabel, unsavedTitleLabel, } from "../i18n.js";
|
|
13
|
+
const DIALOG_WIDTH = {
|
|
14
|
+
small: "max-w-110",
|
|
15
|
+
medium: "max-w-150",
|
|
16
|
+
large: "max-w-200",
|
|
17
|
+
xlarge: "max-w-288",
|
|
18
|
+
};
|
|
19
|
+
const DRAWER_WIDTH = {
|
|
20
|
+
small: "w-95",
|
|
21
|
+
medium: "w-140",
|
|
22
|
+
large: "w-140",
|
|
23
|
+
};
|
|
24
|
+
/** The scrim: `ds-blanket`, fading in `ds-duration-slow`; still for reduced motion. */
|
|
25
|
+
const BLANKET = "fixed inset-0 z-50 bg-ds-blanket transition-opacity duration-(--ds-duration-slow) ease-ds-enter " +
|
|
26
|
+
"data-[entering]:opacity-0 data-[exiting]:opacity-0 data-[exiting]:ease-ds-exit motion-reduce:transition-none";
|
|
27
|
+
/** Every overlay's inner focus target: React Aria's dialog element, never outlined itself. */
|
|
28
|
+
const DIALOG_ELEMENT = "flex min-h-0 flex-1 flex-col outline-hidden";
|
|
29
|
+
/**
|
|
30
|
+
* The state of the DialogTrigger an overlay belongs to. React Aria's own context is also provided by every
|
|
31
|
+
* open modal, so a Dialog nested in a Drawer would bind to the drawer; this one is set by DialogTrigger only
|
|
32
|
+
* and cleared inside every overlay.
|
|
33
|
+
*/
|
|
34
|
+
const OwnTriggerContext = React.createContext(null);
|
|
35
|
+
function TriggerBridge({ children }) {
|
|
36
|
+
const state = React.useContext(OverlayTriggerStateContext);
|
|
37
|
+
return _jsx(OwnTriggerContext.Provider, { value: state, children: children });
|
|
38
|
+
}
|
|
39
|
+
/** True inside an open overlay's contents, where React Aria's trigger context is that overlay's own. */
|
|
40
|
+
const InsideOverlayContext = React.createContext(false);
|
|
41
|
+
/** Overlay contents: a nested overlay must not see the outer one's trigger. */
|
|
42
|
+
export function OverlayContents({ children }) {
|
|
43
|
+
return (_jsx(InsideOverlayContext.Provider, { value: true, children: _jsx(OwnTriggerContext.Provider, { value: null, children: children }) }));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The button that opens a Dialog, AlertDialog or Drawer: put it first, the overlay after it. Inside another
|
|
47
|
+
* overlay (a Dialog in a Drawer) use this one, not React Aria's own DialogTrigger, which there only sees the
|
|
48
|
+
* outer overlay's state.
|
|
49
|
+
*/
|
|
50
|
+
export function DialogTrigger({ children, ...props }) {
|
|
51
|
+
return (_jsx(AriaDialogTrigger, { ...props, children: _jsx(TriggerBridge, { children: children }) }));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Open state for an overlay that can sit in a DialogTrigger or stand alone. Inside a trigger the trigger's
|
|
55
|
+
* state is used; otherwise `isOpen`/`defaultOpen`. `close` is the one way to close, so `onOpenChange(false)`
|
|
56
|
+
* fires once whichever control asked (button, Esc, scrim).
|
|
57
|
+
*/
|
|
58
|
+
function useOverlayOpen({ isOpen, defaultOpen, onOpenChange }) {
|
|
59
|
+
const ownTrigger = React.useContext(OwnTriggerContext);
|
|
60
|
+
const ariaTrigger = React.useContext(OverlayTriggerStateContext);
|
|
61
|
+
const inside = React.useContext(InsideOverlayContext);
|
|
62
|
+
// Our DialogTrigger first; React Aria's own DialogTrigger also works, except inside another overlay, where
|
|
63
|
+
// that context belongs to the outer overlay.
|
|
64
|
+
const trigger = ownTrigger ?? (inside ? null : ariaTrigger);
|
|
65
|
+
const [own, setOwn] = React.useState(defaultOpen ?? false);
|
|
66
|
+
const open = trigger ? trigger.isOpen : (isOpen ?? own);
|
|
67
|
+
const set = (next) => {
|
|
68
|
+
if (trigger) {
|
|
69
|
+
if (next)
|
|
70
|
+
trigger.open();
|
|
71
|
+
else
|
|
72
|
+
trigger.close();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (isOpen === undefined)
|
|
76
|
+
setOwn(next);
|
|
77
|
+
onOpenChange?.(next);
|
|
78
|
+
};
|
|
79
|
+
return { isOpen: open, open: () => set(true), close: () => set(false) };
|
|
80
|
+
}
|
|
81
|
+
/** The `data-*` entries of a props object, without the DS's own `data-slot`. */
|
|
82
|
+
function dataAttributes(source) {
|
|
83
|
+
const picked = {};
|
|
84
|
+
if (!source)
|
|
85
|
+
return picked;
|
|
86
|
+
for (const [name, value] of Object.entries(source)) {
|
|
87
|
+
if (name.startsWith("data-") && name !== "data-slot")
|
|
88
|
+
picked[name] = value;
|
|
89
|
+
}
|
|
90
|
+
return picked;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Focus on open: the first field of the body, or the secondary action when the primary one destroys
|
|
94
|
+
* something. Runs after React Aria's own first-focus, so it wins. A destructive primary with no secondary
|
|
95
|
+
* (`secondaryAction={null}` on a full-screen dialog) has no safe button to start on, so focus goes to the first
|
|
96
|
+
* field as it does for any other dialog, and to the dialog itself when the body has none. The
|
|
97
|
+
* app's `initialFocusRef`, when it holds an element, comes before every rule.
|
|
98
|
+
*/
|
|
99
|
+
function useInitialFocus(body, secondary, safeFirst, initial) {
|
|
100
|
+
React.useEffect(() => {
|
|
101
|
+
if (initial?.current) {
|
|
102
|
+
initial.current.focus();
|
|
103
|
+
// An element that cannot take focus (a hidden title, which has no tabIndex; UI#528 review, or a
|
|
104
|
+
// container without one) leaves focus where it was, and a focus handler on the ref may move it
|
|
105
|
+
// outside: in both cases the dialog's own rule below picks the target instead (UI#529 review).
|
|
106
|
+
if (initial.current.contains(document.activeElement))
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
if (safeFirst && secondary.current) {
|
|
110
|
+
secondary.current.focus();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const field = [...(body.current?.querySelectorAll(FIRST_FIELD) ?? [])].find(isReachableField);
|
|
114
|
+
field?.focus();
|
|
115
|
+
}, []);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* A field the dialog may start on: a text input, a text area, a native select, a combobox, a date or time segment,
|
|
119
|
+
* or a Select or MultiSelect's button (it opens a listbox). In document order.
|
|
120
|
+
*/
|
|
121
|
+
const FIRST_FIELD = "input:not([type='hidden']):not([disabled]), textarea:not([disabled]), select:not([disabled]), [role='combobox'], [role='spinbutton'][tabindex], " +
|
|
122
|
+
"button[aria-haspopup='listbox']:not([disabled])";
|
|
123
|
+
/**
|
|
124
|
+
* Not the native fields React Aria keeps for forms and autofill behind a Select (its hidden `<select>` and input),
|
|
125
|
+
* which are hidden from assistive tech, marked to take no focus and out of the tab order: the dialog
|
|
126
|
+
* started on that `<select>` and not on the Select's button. Anything under `aria-hidden` or `inert`, or with a
|
|
127
|
+
* negative tabindex on a native field, is passed over.
|
|
128
|
+
*/
|
|
129
|
+
function isReachableField(element) {
|
|
130
|
+
if (element.closest("[aria-hidden='true'], [inert], [data-react-aria-prevent-focus]"))
|
|
131
|
+
return false;
|
|
132
|
+
if (element.matches("input, textarea, select") && element.tabIndex < 0)
|
|
133
|
+
return false;
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
/** React Aria's FocusScope dispatches this on the element it is about to give focus back to; cancelling it stops that. */
|
|
137
|
+
const RESTORE_FOCUS_EVENT = "react-aria-focus-scope-restore";
|
|
138
|
+
/**
|
|
139
|
+
* `returnFocusRef`: when the dialog's contents unmount (it closed), focus goes to the ref's element
|
|
140
|
+
* instead of the opener. React Aria's own return to the opener is cancelled for that one close, so the opener
|
|
141
|
+
* never flashes focus (and its focus handlers never run). Focus the app moved elsewhere on purpose is left alone.
|
|
142
|
+
* Without the ref, or with it empty, nothing here runs and React Aria returns focus to the opener as before.
|
|
143
|
+
*/
|
|
144
|
+
function useReturnFocus(target) {
|
|
145
|
+
const latest = React.useRef(target);
|
|
146
|
+
latest.current = target;
|
|
147
|
+
// The element focused as the dialog opens is the one React Aria would return to.
|
|
148
|
+
const [opener] = React.useState(() => (typeof document === "undefined" ? null : document.activeElement));
|
|
149
|
+
// Strict Mode unmounts and remounts effects once in development: that is not a close.
|
|
150
|
+
const mounted = React.useRef(false);
|
|
151
|
+
React.useLayoutEffect(() => {
|
|
152
|
+
mounted.current = true;
|
|
153
|
+
return () => {
|
|
154
|
+
mounted.current = false;
|
|
155
|
+
if (!latest.current)
|
|
156
|
+
return;
|
|
157
|
+
const ref = latest.current;
|
|
158
|
+
const cancel = (event) => {
|
|
159
|
+
if (!mounted.current && ref.current && event.target === opener)
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
};
|
|
162
|
+
document.addEventListener(RESTORE_FOCUS_EVENT, cancel, true);
|
|
163
|
+
requestAnimationFrame(() => {
|
|
164
|
+
document.removeEventListener(RESTORE_FOCUS_EVENT, cancel, true);
|
|
165
|
+
if (mounted.current)
|
|
166
|
+
return;
|
|
167
|
+
const element = ref.current;
|
|
168
|
+
const active = document.activeElement;
|
|
169
|
+
const unclaimed = !active || active === document.body || active === opener || !active.isConnected;
|
|
170
|
+
if (element?.isConnected && unclaimed)
|
|
171
|
+
element.focus();
|
|
172
|
+
});
|
|
173
|
+
};
|
|
174
|
+
}, [opener]);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A form-submit primary while pending: React Aria turns the button into `type="button"`, so a click
|
|
178
|
+
* no longer submits, but Enter in a form with one field still would (HTML's implicit submission needs no
|
|
179
|
+
* button). Every submit of that form is stopped here until the action settles, before React's `onSubmit` sees it.
|
|
180
|
+
* The listener sits on `document` (capture) and matches the form by its id when the submit happens, so a form
|
|
181
|
+
* remounted with the same id while pending is stopped too; another form still submits. React's capture
|
|
182
|
+
* handlers on the form (`onSubmitCapture`) still run while pending: the event is cancelled on `document` but
|
|
183
|
+
* stopped only on the form itself, after React's root has seen its capture phase and before its bubble.
|
|
184
|
+
*/
|
|
185
|
+
function useBlockedSubmit(formId, blocked) {
|
|
186
|
+
React.useEffect(() => {
|
|
187
|
+
if (!formId || !blocked)
|
|
188
|
+
return;
|
|
189
|
+
const stopAtForm = (event) => event.stopPropagation();
|
|
190
|
+
const block = (event) => {
|
|
191
|
+
const form = event.target;
|
|
192
|
+
if (!(form instanceof HTMLFormElement) || form.id !== formId)
|
|
193
|
+
return;
|
|
194
|
+
event.preventDefault();
|
|
195
|
+
// Added while the event is on its way down, so it runs when the event reaches the form; taken off after this
|
|
196
|
+
// dispatch in case something above stopped the event first (a task, so never in the middle of it).
|
|
197
|
+
form.addEventListener("submit", stopAtForm, { capture: true, once: true });
|
|
198
|
+
setTimeout(() => form.removeEventListener("submit", stopAtForm, { capture: true }), 0);
|
|
199
|
+
};
|
|
200
|
+
document.addEventListener("submit", block, true);
|
|
201
|
+
return () => document.removeEventListener("submit", block, true);
|
|
202
|
+
}, [formId, blocked]);
|
|
203
|
+
}
|
|
204
|
+
const TABBABLE = [
|
|
205
|
+
"button:not([disabled])",
|
|
206
|
+
"[href]",
|
|
207
|
+
"input:not([type='hidden']):not([disabled])",
|
|
208
|
+
"select:not([disabled])",
|
|
209
|
+
"textarea:not([disabled])",
|
|
210
|
+
"[tabindex]:not([tabindex='-1'])",
|
|
211
|
+
"[contenteditable]:not([contenteditable='false'])",
|
|
212
|
+
"summary",
|
|
213
|
+
"audio[controls]",
|
|
214
|
+
"video[controls]",
|
|
215
|
+
].join(", ");
|
|
216
|
+
/**
|
|
217
|
+
* Development only: with the close button hidden and no control a keyboard can reach inside, a
|
|
218
|
+
* keyboard user can neither go on nor, without `isDismissable`, leave; even with it (Esc), a touch user on
|
|
219
|
+
* `fullscreen` has no press outside. So it warns whenever the close button is hidden and nothing inside is
|
|
220
|
+
* tabbable, whatever `isDismissable` says. Checked once it opens.
|
|
221
|
+
*/
|
|
222
|
+
function useStrandedWarning(closeHidden, body) {
|
|
223
|
+
React.useEffect(() => {
|
|
224
|
+
if (process.env.NODE_ENV === "production" || !closeHidden)
|
|
225
|
+
return;
|
|
226
|
+
const dialog = body.current?.closest("[data-slot='dialog']");
|
|
227
|
+
if (dialog && !dialog.querySelector(TABBABLE)) {
|
|
228
|
+
console.warn("Dialog: isCloseButtonHidden leaves no close button, and the dialog has no control a keyboard can reach, so a user may be unable to go on or leave. Give it a primaryAction or a control in the body.");
|
|
229
|
+
}
|
|
230
|
+
}, [closeHidden]);
|
|
231
|
+
}
|
|
232
|
+
function DialogFrame({ size, children, role, isDismissable, escapeCloses, isOpen, onClose, describedBy, rootData }) {
|
|
233
|
+
return (_jsx(ModalOverlay
|
|
234
|
+
// Always controlled here: closing goes through `onClose` only, so it is reported once.
|
|
235
|
+
, {
|
|
236
|
+
// Always controlled here: closing goes through `onClose` only, so it is reported once.
|
|
237
|
+
isOpen: isOpen, onOpenChange: (next) => {
|
|
238
|
+
if (!next)
|
|
239
|
+
onClose();
|
|
240
|
+
}, isDismissable: isDismissable, isKeyboardDismissDisabled: !escapeCloses, "data-slot": "dialog-overlay", className: cn(BLANKET, "grid place-items-center overflow-y-auto p-ds-300 pt-[max(var(--ds-space-300),env(safe-area-inset-top,0px))] pb-[max(var(--ds-space-300),env(safe-area-inset-bottom,0px))]"), children: _jsx(Modal, { "data-slot": "dialog-modal", "data-size": size, className: cn(
|
|
241
|
+
// A default max height with the body scrolling inside, so a small screen never pushes the footer away.
|
|
242
|
+
"flex max-h-[calc(100dvh-2*var(--ds-space-300))] w-full flex-col overflow-hidden rounded-ds-xlarge bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden", "transition-[opacity,translate] duration-(--ds-duration-slow) ease-ds-enter data-[entering]:translate-y-2 data-[entering]:opacity-0 data-[exiting]:opacity-0 data-[exiting]:ease-ds-exit motion-reduce:transition-none", DIALOG_WIDTH[size]), children: _jsx(AriaDialog, { ...rootData, role: role, "aria-describedby": describedBy, "data-slot": "dialog", className: DIALOG_ELEMENT, children: _jsx(OverlayContents, { children: children }) }) }) }));
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The full-screen frame: the modal covers the viewport, edge to edge, at every width. On a phone
|
|
246
|
+
* (below 640px, Drawer's query) it is presented as a sheet sliding up from the bottom edge; above, it fades in.
|
|
247
|
+
* The side insets (landscape notch) pad the modal; the top and bottom ones pad the header and the footer.
|
|
248
|
+
* Small, medium and large never come here: their frame above is unchanged.
|
|
249
|
+
*/
|
|
250
|
+
function FullScreenFrame({ children, isDismissable, isOpen, onClose, describedBy, rootData }) {
|
|
251
|
+
const sheet = useNarrow();
|
|
252
|
+
return (_jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: (next) => {
|
|
253
|
+
if (!next)
|
|
254
|
+
onClose();
|
|
255
|
+
},
|
|
256
|
+
// No scrim to press: a press on something layered above the frame (a toast, a cookie banner) must not
|
|
257
|
+
// close it, so outside presses never dismiss; `isDismissable` decides Esc alone.
|
|
258
|
+
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
|
|
259
|
+
? "transition-[translate] data-[entering]:translate-y-full data-[exiting]:translate-y-full"
|
|
260
|
+
: "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 }) }) }) }));
|
|
261
|
+
}
|
|
262
|
+
/** Pulled into the corner so its icon lines up with the padding, not its 32px hit area. */
|
|
263
|
+
function CornerClose({ onPress, slot, data }) {
|
|
264
|
+
return (_jsx("span", { "data-slot": `${slot}-wrap`, className: "-me-ds-100 -mt-ds-050 flex", children: _jsx(CloseButton, { ...data, "data-slot": slot, onPress: onPress }) }));
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* The full-screen parts. Header and footer never shrink and the body is the one scroll container
|
|
268
|
+
* between them, so they stay at the top and bottom; the header clears the notch, the footer the home indicator.
|
|
269
|
+
*/
|
|
270
|
+
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))]";
|
|
271
|
+
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";
|
|
272
|
+
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))]";
|
|
273
|
+
/** An empty description (`""`, `false`, `true`, `null`) renders nothing, so it is the same as none. */
|
|
274
|
+
function hasDescription(description) {
|
|
275
|
+
return description != null && typeof description !== "boolean" && description !== "";
|
|
276
|
+
}
|
|
277
|
+
/** A node that renders something: the `headerStart` test (`null`, `false`, `true`, `""` count as none). */
|
|
278
|
+
const isRenderable = hasDescription;
|
|
279
|
+
// The full-screen options, each added to the classes above only when used, so a full-screen
|
|
280
|
+
// dialog without them renders exactly as before.
|
|
281
|
+
/** No footer: the body is the last part, so it clears the home indicator itself (as Drawer's body does). */
|
|
282
|
+
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";
|
|
283
|
+
/** `footerLayout="spread"`: the secondary takes the free space after it, so it sits at the start and the primary at the end. */
|
|
284
|
+
const FOOTER_SPREAD = "[&>[data-slot=dialog-secondary]]:me-auto";
|
|
285
|
+
/** A hidden title is out of flow, so the close button is held at the inline end on its own. */
|
|
286
|
+
const HEADER_CLOSE_END = "[&>[data-slot=dialog-close-wrap]]:ms-auto";
|
|
287
|
+
/** With `headerStart` the title side takes the room left between the slot and the close button. */
|
|
288
|
+
const TITLE_SIDE = "min-w-0 flex-1";
|
|
289
|
+
/** Small, medium and large without a footer (`secondaryAction={null}` and no primary): the body takes the footer's bottom padding. */
|
|
290
|
+
const BODY = "min-h-0 flex-1 overflow-y-auto px-ds-300 py-ds-200 text-body text-ds-text-subtle";
|
|
291
|
+
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";
|
|
292
|
+
/**
|
|
293
|
+
* The title with `titleRef`: the DS focus ring, a 2px ds-border-focused inset ring, for keyboard focus
|
|
294
|
+
* only (`:focus-visible`), as on the drawer grip and the scroll area, so a pointer user never sees one. The browser's
|
|
295
|
+
* own outline is hidden; no outline or external ring is hand-written (focus-outline.test.ts, focus-state.test.ts).
|
|
296
|
+
* 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
|
|
297
|
+
* last letters while the text stays exactly where it was. Added only with `titleRef`, and only to a visible title: a
|
|
298
|
+
* hidden one (`isTitleHidden`) keeps `sr-only` alone, takes no tabIndex and is never a focus target (its margin and
|
|
299
|
+
* padding would also partly override `sr-only`'s).
|
|
300
|
+
*/
|
|
301
|
+
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";
|
|
302
|
+
function DialogContent({ title, description, descriptionId, children, primaryAction, secondaryAction, close, fullScreen, footerLayout, headerStart, isTitleHidden, isCloseButtonHidden, initialFocusRef, returnFocusRef, partData, titleRef, }) {
|
|
303
|
+
const { locale } = useLocale();
|
|
304
|
+
const body = React.useRef(null);
|
|
305
|
+
const secondary = React.useRef(null);
|
|
306
|
+
const destructive = primaryAction?.variant === "danger";
|
|
307
|
+
const closeHidden = isCloseButtonHidden === true;
|
|
308
|
+
useInitialFocus(body, secondary, destructive, initialFocusRef);
|
|
309
|
+
useReturnFocus(returnFocusRef);
|
|
310
|
+
useBlockedSubmit(primaryAction?.form, primaryAction?.isPending === true);
|
|
311
|
+
useStrandedWarning(closeHidden, body);
|
|
312
|
+
// The full-screen options below reach this component only for `fullscreen` (Dialog drops them for the other sizes).
|
|
313
|
+
const hasStart = isRenderable(headerStart);
|
|
314
|
+
const hasSecondary = secondaryAction !== null;
|
|
315
|
+
const hasFooter = hasSecondary || primaryAction != null;
|
|
316
|
+
// A hidden title keeps only `sr-only` (its own margin and size would fight it); with a start slot it truncates.
|
|
317
|
+
const titleClass = isTitleHidden ? "sr-only" : hasStart ? "m-0 truncate text-heading-medium" : "m-0 text-heading-medium";
|
|
318
|
+
// The app's data-* attributes come first in every part, so the DS's own data-slot wins.
|
|
319
|
+
// With `titleRef` the heading takes the ref, tabIndex -1 and the focus ring; without it, nothing changes.
|
|
320
|
+
// A hidden title takes the ref only: an sr-only heading would show no focus indicator, so it is never a focus target.
|
|
321
|
+
const hasTitleRef = titleRef !== undefined && titleRef !== null;
|
|
322
|
+
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 }));
|
|
323
|
+
const headerClass = fullScreen ? FULL_HEADER : "flex items-start justify-between gap-ds-200 px-ds-300 pt-ds-300";
|
|
324
|
+
return (_jsxs(_Fragment, { 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: headerStart })), 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: [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) })), primaryAction && (_jsx(Button, { ...dataAttributes(primaryAction), variant: primaryAction.variant ?? "primary", isPending: primaryAction.isPending, isDisabled: primaryAction.isDisabled, iconBefore: primaryAction.iconBefore, iconAfter: primaryAction.iconAfter, onPress: primaryAction.onPress,
|
|
325
|
+
// A form-submit action; without `form` the Button stays type="button".
|
|
326
|
+
type: primaryAction.form ? "submit" : undefined, form: primaryAction.form, "data-slot": "dialog-primary", children: primaryAction.label }))] }))] }));
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Development only: the full-screen options a smaller size was given, which it ignores. Only values that would
|
|
330
|
+
* change a full-screen dialog count: `isTitleHidden={false}`, `footerLayout="end"` or an empty
|
|
331
|
+
* `headerStart` are the defaults there too, so nothing is lost and nothing is said.
|
|
332
|
+
*/
|
|
333
|
+
function useFullScreenOnlyWarning(size, props) {
|
|
334
|
+
const ignored = size === "fullscreen"
|
|
335
|
+
? []
|
|
336
|
+
: [
|
|
337
|
+
props.footerLayout === "spread" && "footerLayout",
|
|
338
|
+
isRenderable(props.headerStart) && "headerStart",
|
|
339
|
+
props.isTitleHidden === true && "isTitleHidden",
|
|
340
|
+
].filter((name) => typeof name === "string");
|
|
341
|
+
const signature = ignored.join(", ");
|
|
342
|
+
// One option named takes the singular ("isTitleHidden only applies … ignores it"), several the plural.
|
|
343
|
+
const one = ignored.length === 1;
|
|
344
|
+
React.useEffect(() => {
|
|
345
|
+
if (process.env.NODE_ENV === "production" || !signature)
|
|
346
|
+
return;
|
|
347
|
+
console.warn(`Dialog: ${signature} only ${one ? "applies" : "apply"} to size="fullscreen"; size="${size}" ignores ${one ? "it" : "them"}.`);
|
|
348
|
+
}, [signature, size, one]);
|
|
349
|
+
}
|
|
350
|
+
/** A title that names nothing: empty, blank or not text at all (`""`, `" "`, `null`, `false`, `true`). */
|
|
351
|
+
function isEmptyTitle(title) {
|
|
352
|
+
return title === null || typeof title === "boolean" || (typeof title === "string" && title.trim() === "");
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Development only: `isTitleHidden` with an empty title leaves the dialog without a name, since the
|
|
356
|
+
* hidden title is what names it. A left-out title (`undefined`) is already a TypeScript error, so only the empty
|
|
357
|
+
* values that type-check are said here. Fullscreen only: the other sizes ignore `isTitleHidden` (the fullscreen-only
|
|
358
|
+
* warning names it), so their title shows and names the dialog.
|
|
359
|
+
*/
|
|
360
|
+
function useHiddenEmptyTitleWarning(isTitleHidden, title, fullScreen) {
|
|
361
|
+
const unnamed = fullScreen && isTitleHidden === true && isEmptyTitle(title);
|
|
362
|
+
React.useEffect(() => {
|
|
363
|
+
if (process.env.NODE_ENV === "production" || !unnamed)
|
|
364
|
+
return;
|
|
365
|
+
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.");
|
|
366
|
+
}, [unnamed]);
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* A decision or a short input that must be resolved before the user goes on. Put it inside a DialogTrigger
|
|
370
|
+
* after its button, or control it with `isOpen`. Focus moves to the first field (to "Cancel" when the
|
|
371
|
+
* primary action is destructive and "Cancel" is there), stays inside, and returns to the trigger on close; Esc closes it.
|
|
372
|
+
* `size="fullscreen"` covers the viewport, a sheet on phones, for a long task like a signup; it
|
|
373
|
+
* also takes a logo before the title (`headerStart`), a visually hidden title (`isTitleHidden`) and a spread footer
|
|
374
|
+
* (`footerLayout`). Every size: a primary action that submits a form
|
|
375
|
+
* (`primaryAction.form`), no secondary action (`secondaryAction={null}`; with no primary either, no footer), no
|
|
376
|
+
* close button (`isCloseButtonHidden`; a locked view adds `isDismissable={false}`), `data-*` attributes on the
|
|
377
|
+
* dialog and its parts (`partData`, the actions' own), and focus hooks (`initialFocusRef`, `returnFocusRef`). A
|
|
378
|
+
* focusable title (`titleRef`), which `initialFocusRef` can name to open on it.
|
|
379
|
+
*/
|
|
380
|
+
export function Dialog({ size = "small", isDismissable = true, isOpen, defaultOpen, onOpenChange, footerLayout, headerStart, isTitleHidden, ...content }) {
|
|
381
|
+
const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });
|
|
382
|
+
const descriptionId = React.useId();
|
|
383
|
+
// Described only when there is a description; otherwise the dialog's DOM is unchanged.
|
|
384
|
+
const describedBy = hasDescription(content.description) ? descriptionId : undefined;
|
|
385
|
+
// The app's data-* props go to the dialog element; none given, nothing is added.
|
|
386
|
+
const rootData = dataAttributes(content);
|
|
387
|
+
useFullScreenOnlyWarning(size, { footerLayout, headerStart, isTitleHidden });
|
|
388
|
+
useHiddenEmptyTitleWarning(isTitleHidden, content.title, size === "fullscreen");
|
|
389
|
+
if (size === "fullscreen") {
|
|
390
|
+
return (_jsx(FullScreenFrame, { isDismissable: isDismissable, isOpen: state.isOpen, onClose: state.close, describedBy: describedBy, rootData: rootData, children: _jsx(DialogContent, { ...content, footerLayout: footerLayout, headerStart: headerStart, isTitleHidden: isTitleHidden, descriptionId: descriptionId, close: state.close, fullScreen: true }) }));
|
|
391
|
+
}
|
|
392
|
+
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 }) }));
|
|
393
|
+
}
|
|
394
|
+
const ALERT_ICON = {
|
|
395
|
+
danger: { name: "trash-2", className: "bg-ds-background-danger text-ds-icon-danger" },
|
|
396
|
+
warning: { name: "triangle-alert", className: "bg-ds-background-warning text-ds-icon-warning" },
|
|
397
|
+
neutral: { name: "info", className: "bg-ds-background-neutral text-ds-icon" },
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* Only with a custom `cancelLabel`: the cancel button may wrap its text and grow in height, at most
|
|
401
|
+
* as wide as the footer, so a long app label never overflows a 320px screen. The default "Cancel" is short and
|
|
402
|
+
* keeps the footer's classes unchanged, and so does a blank label (`" "`), which counts as unset. A word breaks only
|
|
403
|
+
* when it is too long for a line (`break-words`).
|
|
404
|
+
*/
|
|
405
|
+
const CUSTOM_CANCEL_FOOTER = "[&>[data-slot=alert-dialog-cancel]]:h-auto [&>[data-slot=alert-dialog-cancel]]:min-h-ds-control [&>[data-slot=alert-dialog-cancel]]:max-w-full " +
|
|
406
|
+
"[&>[data-slot=alert-dialog-cancel]]:py-ds-075 [&>[data-slot=alert-dialog-cancel]]:whitespace-normal [&>[data-slot=alert-dialog-cancel]]:text-center " +
|
|
407
|
+
"[&>[data-slot=alert-dialog-cancel]]:break-words";
|
|
408
|
+
const ALERT_FOOTER = "flex flex-wrap items-center justify-end gap-ds-100 px-ds-300 pb-ds-300 pt-ds-200";
|
|
409
|
+
function AlertContent({ tone = "danger", title, children, confirmLabel, cancelLabel, onConfirm, requireTypedConfirmation, typedConfirmationLabel, icon, returnFocusRef, isConfirmDisabled, descriptionId, close, pending, setPending, }) {
|
|
410
|
+
const { locale } = useLocale();
|
|
411
|
+
const cancel = React.useRef(null);
|
|
412
|
+
const [typed, setTyped] = React.useState("");
|
|
413
|
+
// "Cancel" first: the destructive button never has default focus.
|
|
414
|
+
React.useEffect(() => cancel.current?.focus(), []);
|
|
415
|
+
// Without the ref nothing runs, so React Aria returns focus to the opener as before.
|
|
416
|
+
useReturnFocus(returnFocusRef);
|
|
417
|
+
const ready = requireTypedConfirmation === undefined || typed.trim() === requireTypedConfirmation;
|
|
418
|
+
const confirm = async () => {
|
|
419
|
+
setPending(true);
|
|
420
|
+
let done = false;
|
|
421
|
+
try {
|
|
422
|
+
await onConfirm();
|
|
423
|
+
done = true;
|
|
424
|
+
}
|
|
425
|
+
catch {
|
|
426
|
+
// The action failed: the dialog stays open so the user can retry or cancel. Saying what went wrong
|
|
427
|
+
// (a Toast, an inline Banner) is the caller's, which knows the error.
|
|
428
|
+
}
|
|
429
|
+
finally {
|
|
430
|
+
setPending(false);
|
|
431
|
+
}
|
|
432
|
+
if (done)
|
|
433
|
+
close();
|
|
434
|
+
};
|
|
435
|
+
const glyph = ALERT_ICON[tone];
|
|
436
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { "data-slot": "alert-dialog-header", className: "flex items-start gap-ds-200 px-ds-300 pt-ds-300", children: [_jsx("span", { "data-slot": "alert-dialog-icon", className: cn("grid size-10 shrink-0 place-items-center rounded-ds-full", glyph.className), children: _jsx(IconGlyph, { name: icon ?? glyph.name }) }), _jsxs("div", { "data-slot": "alert-dialog-text", className: "flex min-w-0 flex-col gap-ds-050", children: [_jsx(Heading, { slot: "title", "data-slot": "alert-dialog-title", className: "m-0 text-heading-medium", children: title }), _jsx("div", { id: descriptionId, "data-slot": "alert-dialog-description", className: "text-body text-ds-text-subtle", children: children })] })] }), requireTypedConfirmation !== undefined && (_jsx("div", { "data-slot": "alert-dialog-body", className: "px-ds-300 pt-ds-200", children: _jsx(TextField, { label: typedConfirmationLabel ?? typeToConfirmLabel(locale, requireTypedConfirmation), value: typed, onChange: setTyped, placeholder: requireTypedConfirmation, appearance: "code", autoComplete: "off", isDisabled: pending }) })), _jsxs("div", { "data-slot": "alert-dialog-footer", className: cancelLabel?.trim() ? `${ALERT_FOOTER} ${CUSTOM_CANCEL_FOOTER}` : ALERT_FOOTER, children: [_jsx(Button, { ref: cancel, variant: "subtle", onPress: close, isDisabled: pending, "data-slot": "alert-dialog-cancel", children: cancelLabel?.trim() || defaultCancelLabel(locale) }), _jsx(Button, { variant: tone === "danger" ? "danger" : "primary", isDisabled: !ready || Boolean(isConfirmDisabled), isPending: pending, onPress: confirm, "data-slot": "alert-dialog-confirm", children: confirmLabel })] })] }));
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Confirms an action that destroys data, costs money or cannot be undone (role="alertdialog"). Not closed
|
|
440
|
+
* by a scrim click; Esc cancels (not while the action runs); "Cancel" (or the app's `cancelLabel`) has the first focus. With
|
|
441
|
+
* `requireTypedConfirmation` the action enables only once the text is typed. If the action can be undone,
|
|
442
|
+
* skip it and offer "Undo" in a Toast. Opened from a menu whose trigger unmounts, or when the confirmed action
|
|
443
|
+
* removes the opener, pass `returnFocusRef` so focus has somewhere to go back to.
|
|
444
|
+
*/
|
|
445
|
+
export function AlertDialog({ isOpen, defaultOpen, onOpenChange, "aria-describedby": ariaDescribedBy, ...content }) {
|
|
446
|
+
const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });
|
|
447
|
+
const descriptionId = React.useId();
|
|
448
|
+
const [pending, setPending] = React.useState(false);
|
|
449
|
+
const describedBy = ariaDescribedBy?.trim() ? `${descriptionId} ${ariaDescribedBy.trim()}` : descriptionId;
|
|
450
|
+
return (
|
|
451
|
+
// No scrim click (a stray tap must not answer it); Esc cancels, except while the action is running.
|
|
452
|
+
_jsx(DialogFrame, { size: "small", role: "alertdialog", isDismissable: false, escapeCloses: !pending, describedBy: describedBy, isOpen: state.isOpen, onClose: state.close, children: _jsx(AlertContent, { ...content, descriptionId: descriptionId, close: state.close, pending: pending, setPending: setPending }) }));
|
|
453
|
+
}
|
|
454
|
+
/** Phones (below 640px) get the bottom sheet whatever the placement; decided after mount. */
|
|
455
|
+
function useNarrow() {
|
|
456
|
+
return React.useSyncExternalStore((notify) => {
|
|
457
|
+
if (typeof window.matchMedia !== "function")
|
|
458
|
+
return () => { };
|
|
459
|
+
const query = window.matchMedia("(max-width: 639px)");
|
|
460
|
+
query.addEventListener("change", notify);
|
|
461
|
+
return () => query.removeEventListener("change", notify);
|
|
462
|
+
}, () => typeof window.matchMedia === "function" && window.matchMedia("(max-width: 639px)").matches, () => false);
|
|
463
|
+
}
|
|
464
|
+
const DrawerCloseContext = React.createContext(() => { });
|
|
465
|
+
/**
|
|
466
|
+
* The drawer's close, for its footer or body. By default it asks first with unsaved edits, like the close
|
|
467
|
+
* button, Esc and the scrim; after saving call `close({ force: true })`.
|
|
468
|
+
*/
|
|
469
|
+
export function useDrawerClose() {
|
|
470
|
+
return React.useContext(DrawerCloseContext);
|
|
471
|
+
}
|
|
472
|
+
/** Drag distance on the grip that counts as a swipe rather than a tap (px). */
|
|
473
|
+
const SWIPE = 40;
|
|
474
|
+
/** The sheet's grip: tap toggles half/full; swipe up expands, swipe down collapses (or closes from half). */
|
|
475
|
+
function Grip({ expanded, onExpand, onCollapse, onDismiss }) {
|
|
476
|
+
const { locale } = useLocale();
|
|
477
|
+
const start = React.useRef(null);
|
|
478
|
+
const moved = React.useRef(false);
|
|
479
|
+
return (_jsx("button", { type: "button", "data-slot": "drawer-grip", "aria-label": expanded ? collapseSheetLabel(locale) : expandSheetLabel(locale), "aria-expanded": expanded, onPointerDown: (event) => {
|
|
480
|
+
start.current = event.clientY;
|
|
481
|
+
moved.current = false;
|
|
482
|
+
// Keep the pointer while it drags past the 24px grip (touch is captured anyway; a mouse is not).
|
|
483
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
484
|
+
}, onPointerUp: (event) => {
|
|
485
|
+
if (start.current === null)
|
|
486
|
+
return;
|
|
487
|
+
const dy = event.clientY - start.current;
|
|
488
|
+
start.current = null;
|
|
489
|
+
if (Math.abs(dy) < SWIPE)
|
|
490
|
+
return;
|
|
491
|
+
moved.current = true;
|
|
492
|
+
if (dy < 0)
|
|
493
|
+
onExpand();
|
|
494
|
+
else if (expanded)
|
|
495
|
+
onCollapse();
|
|
496
|
+
else
|
|
497
|
+
onDismiss();
|
|
498
|
+
}, onClick: () => {
|
|
499
|
+
if (moved.current) {
|
|
500
|
+
moved.current = false;
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (expanded)
|
|
504
|
+
onCollapse();
|
|
505
|
+
else
|
|
506
|
+
onExpand();
|
|
507
|
+
}, 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" }) }));
|
|
508
|
+
}
|
|
509
|
+
/** "Unsaved changes": a real nested modal (focus kept inside, the drawer behind it inert, Esc = keep editing). */
|
|
510
|
+
function UnsavedPrompt({ isOpen, onKeep, onDiscard }) {
|
|
511
|
+
const { locale } = useLocale();
|
|
512
|
+
return (_jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: (next) => {
|
|
513
|
+
if (!next)
|
|
514
|
+
onKeep();
|
|
515
|
+
}, 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: "danger", onPress: onDiscard, "data-slot": "drawer-discard", children: discardCloseLabel(locale) })] })] }) }) }));
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* A panel over the page to show or edit one record without losing the list behind it: on the inline end
|
|
519
|
+
* (380 or 560px, full height), a bottom sheet on phones that snaps between half and full height. Header with
|
|
520
|
+
* title, subtitle and status; a scrolling body; a sticky footer; both keep clear of notches and the home
|
|
521
|
+
* indicator. With unsaved edits every way of closing asks first. The title names the drawer and the
|
|
522
|
+
* subtitle, when there is one, describes it.
|
|
523
|
+
*/
|
|
524
|
+
export function Drawer({ size = "small", placement = "end", isOpen, defaultOpen, onOpenChange, hasUnsavedChanges, title, subtitle, headerActions, children, footer, }) {
|
|
525
|
+
const state = useOverlayOpen({ isOpen, defaultOpen, onOpenChange });
|
|
526
|
+
const subtitleId = React.useId();
|
|
527
|
+
// Described only when there is a subtitle, as Dialog's description; otherwise the drawer's DOM is unchanged.
|
|
528
|
+
const describedBy = hasDescription(subtitle) ? subtitleId : undefined;
|
|
529
|
+
const narrow = useNarrow();
|
|
530
|
+
const bottom = placement === "bottom" || narrow;
|
|
531
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
532
|
+
// A sheet opens at half height every time. Reset as it opens, not as it closes, so the closing slide does
|
|
533
|
+
// not also animate the height down.
|
|
534
|
+
const [wasOpen, setWasOpen] = React.useState(state.isOpen);
|
|
535
|
+
if (wasOpen !== state.isOpen) {
|
|
536
|
+
setWasOpen(state.isOpen);
|
|
537
|
+
if (state.isOpen)
|
|
538
|
+
setExpanded(false);
|
|
539
|
+
}
|
|
540
|
+
const [asking, setAsking] = React.useState(false);
|
|
541
|
+
// Every close request (button, Esc, scrim, grip swipe, useDrawerClose) comes through here.
|
|
542
|
+
const request = () => (hasUnsavedChanges ? setAsking(true) : state.close());
|
|
543
|
+
const close = (options) => (options?.force ? state.close() : request());
|
|
544
|
+
return (_jsx(ModalOverlay, { isOpen: state.isOpen, onOpenChange: (next) => {
|
|
545
|
+
if (!next)
|
|
546
|
+
request();
|
|
547
|
+
}, isDismissable: true, "data-slot": "drawer-overlay", "data-placement": bottom ? "bottom" : "end", 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", bottom
|
|
548
|
+
? cn("inset-x-0 bottom-0 rounded-t-ds-xlarge data-[entering]:translate-y-full data-[exiting]:translate-y-full", expanded ? "h-[calc(100dvh-env(safe-area-inset-top,0px)-var(--ds-space-200))]" : "h-[50dvh]")
|
|
549
|
+
: cn(
|
|
550
|
+
// Clear of a notch at the top and, in landscape, at the inline end.
|
|
551
|
+
"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", 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",
|
|
552
|
+
// Without a footer the body is the last thing above the home indicator.
|
|
553
|
+
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: () => {
|
|
554
|
+
setAsking(false);
|
|
555
|
+
state.close();
|
|
556
|
+
} })] }) }) }));
|
|
557
|
+
}
|
|
558
|
+
//# sourceMappingURL=overlay.js.map
|