@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,53 @@
|
|
|
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 { Button as AriaButton, ListBox, ListBoxItem, Popover, Select as AriaSelect, } from "react-aria-components";
|
|
5
|
+
import { BUTTON_BASE, BUTTON_SIZE, buttonVariantClasses, ICON_ONLY_SIZE } from "../action/styles.js";
|
|
6
|
+
import { IconGlyph } from "../display/icon.js";
|
|
7
|
+
import { TooltipFor } from "../overlay/floating.js";
|
|
8
|
+
import { LISTBOX, OPTION } from "../selection/listbox.js";
|
|
9
|
+
import { languageLabel } from "../i18n.js";
|
|
10
|
+
import { cn } from "../utils.js";
|
|
11
|
+
import { languageOptions, languageName } from "./language-names.js";
|
|
12
|
+
/**
|
|
13
|
+
* One language as the switcher shows it: the app's mark (a flag, a code chip), if any, and the name in the UI
|
|
14
|
+
* language. With the name hidden (a square trigger) the mark stands alone; the name stays for screen readers.
|
|
15
|
+
* The mark is decorative next to the name, so it is hidden from assistive technology, and the name always tells
|
|
16
|
+
* the options apart.
|
|
17
|
+
*/
|
|
18
|
+
export function LanguageLabel({ locale, uiLocale, hideName = false, mark, }) {
|
|
19
|
+
return (_jsxs("span", { "data-slot": "language-label", className: "inline-flex min-w-0 items-center gap-ds-075", children: [mark != null && (_jsx("span", { "data-slot": "language-mark", "aria-hidden": "true", className: "inline-flex shrink-0 items-center", children: mark })), _jsx("span", { className: hideName ? "sr-only" : "truncate", children: languageName(locale, uiLocale) })] }));
|
|
20
|
+
}
|
|
21
|
+
const subscribeToClient = () => () => { };
|
|
22
|
+
/**
|
|
23
|
+
* The language choice every surface offers, on the DS.
|
|
24
|
+
*
|
|
25
|
+
* Presentation only: the app resolves the product's locale list and handles
|
|
26
|
+
* `onSelect` (routing, persistence). Names come from `Intl.DisplayNames` in
|
|
27
|
+
* the active UI locale (`current`), ordered by that visible name.
|
|
28
|
+
* Choosing a value is a Select, not a Menu, so the list is a listbox whose
|
|
29
|
+
* current option is selected for assistive technology and carries a check.
|
|
30
|
+
*
|
|
31
|
+
* The trigger stays disabled until the component has mounted *and* the
|
|
32
|
+
* caller reports the list resolved, so a product restricted to one language
|
|
33
|
+
* never flashes the full list on a cold cache.
|
|
34
|
+
*/
|
|
35
|
+
export function LanguageSwitcher({ locales, current, onSelect, label: labelProp, isLoading: loading = false, variant = "button", isCollapsed: collapsed = false, size = "medium", renderMark, "aria-describedby": describedBy, }) {
|
|
36
|
+
const sidebar = variant === "sidebar";
|
|
37
|
+
const label = labelProp ?? languageLabel(current);
|
|
38
|
+
// A collapsed trigger hides the name only behind a mark that is really there.
|
|
39
|
+
const currentMark = renderMark?.(current) ?? null;
|
|
40
|
+
const mounted = React.useSyncExternalStore(subscribeToClient, () => true, () => false);
|
|
41
|
+
const buttonSize = size;
|
|
42
|
+
const square = collapsed && !sidebar;
|
|
43
|
+
const trigger = cn(BUTTON_BASE, buttonVariantClasses("subtle"), BUTTON_SIZE[buttonSize], "font-normal", square && ICON_ONLY_SIZE[buttonSize], sidebar && (collapsed ? "w-full justify-center px-0" : "w-full justify-start"));
|
|
44
|
+
if (!mounted || loading) {
|
|
45
|
+
return (_jsx(AriaButton, { "data-slot": "language-switcher-trigger", "aria-label": label, "aria-describedby": describedBy, isDisabled: true, className: trigger, children: _jsx(LanguageLabel, { locale: current, uiLocale: current, hideName: collapsed && currentMark != null, mark: currentMark }) }));
|
|
46
|
+
}
|
|
47
|
+
const options = languageOptions(locales, current);
|
|
48
|
+
return (_jsxs(AriaSelect, { "aria-label": label, "aria-describedby": describedBy, value: current, onChange: (key) => {
|
|
49
|
+
if (key != null)
|
|
50
|
+
onSelect(String(key));
|
|
51
|
+
}, "data-slot": "language-switcher", className: cn(sidebar && "w-full"), children: [_jsx(TooltipFor, { content: label, placement: "bottom", children: _jsx(AriaButton, { "data-slot": "language-switcher-trigger", className: trigger, children: _jsx(LanguageLabel, { locale: current, uiLocale: current, hideName: collapsed && currentMark != null, mark: currentMark }) }) }), _jsx(Popover, { "data-slot": "language-switcher-popover", placement: sidebar ? "top start" : "bottom end", offset: 4, className: "flex min-w-44 flex-col overflow-hidden rounded-ds-large bg-ds-surface-overlay p-ds-050 text-ds-text shadow-ds-overlay outline-hidden", children: _jsx(ListBox, { "data-slot": "language-switcher-list", className: LISTBOX, children: options.map((option) => (_jsx(ListBoxItem, { id: option.locale, textValue: option.label, "data-slot": "language-switcher-option", className: cn(OPTION, "whitespace-nowrap"), children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", "data-slot": "language-switcher-check", className: "flex size-4 shrink-0 items-center justify-center", children: isSelected && _jsx(IconGlyph, { name: "check" }) }), _jsx(LanguageLabel, { locale: option.locale, uiLocale: current, mark: renderMark?.(option.locale) })] })) }, option.locale))) }) })] }));
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=language-switcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-switcher.js","sourceRoot":"","sources":["../../src/navigation/language-switcher.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,MAAM,IAAI,UAAU,EACpB,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,IAAI,UAAU,GAErB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,E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C,aAAa,IAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,IAAI,WAAW,IAAI,IAAI,EAAE,IAAI,EAAE,WAAW,GAAI,GACzG,GACF,EACb,KAAC,OAAO,iBACI,2BAA2B,EACrC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,EAC/C,MAAM,EAAE,CAAC,EACT,SAAS,EAAC,sIAAsI,YAEhJ,KAAC,OAAO,iBAAW,wBAAwB,EAAC,SAAS,EAAE,OAAO,YAC3D,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,KAAC,WAAW,IAEV,EAAE,EAAE,MAAM,CAAC,MAAM,EACjB,SAAS,EAAE,MAAM,CAAC,KAAK,eACb,0BAA0B,EACpC,SAAS,EAAE,EAAE,CAAC,MAAM,EAAE,mBAAmB,CAAC,YAEzC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CACnB,8BAGE,8BAAkB,MAAM,eAAW,yBAAyB,EAAC,SAAS,EAAC,kDAAkD,YACtH,UAAU,IAAI,KAAC,SAAS,IAAC,IAAI,EAAC,OAAO,GAAG,GACpC,EACP,KAAC,aAAa,IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAI,IAC7F,CACJ,IAfI,MAAM,CAAC,MAAM,CAgBN,CACf,CAAC,GACM,GACF,IACC,CACd,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n Button as AriaButton,\n ListBox,\n ListBoxItem,\n Popover,\n Select as AriaSelect,\n type Key,\n} from \"react-aria-components\";\n\nimport { BUTTON_BASE, BUTTON_SIZE, buttonVariantClasses, ICON_ONLY_SIZE } from \"../action/styles\";\nimport { IconGlyph } from \"../display/icon\";\nimport { TooltipFor } from \"../overlay/floating\";\nimport { LISTBOX, OPTION } from \"../selection/listbox\";\nimport { languageLabel } from \"../i18n\";\nimport { cn } from \"../utils\";\nimport { languageOptions, languageName } from \"./language-names\";\n\n/**\n * One language as the switcher shows it: the app's mark (a flag, a code chip), if any, and the name in the UI\n * language. With the name hidden (a square trigger) the mark stands alone; the name stays for screen readers.\n * The mark is decorative next to the name, so it is hidden from assistive technology, and the name always tells\n * the options apart.\n */\nexport function LanguageLabel({\n locale, uiLocale, hideName = false, mark,\n}: { locale: string; uiLocale: string; hideName?: boolean; mark?: React.ReactNode }) {\n return (\n <span data-slot=\"language-label\" className=\"inline-flex min-w-0 items-center gap-ds-075\">\n {mark != null && (\n <span data-slot=\"language-mark\" aria-hidden=\"true\" className=\"inline-flex shrink-0 items-center\">\n {mark}\n </span>\n )}\n <span className={hideName ? \"sr-only\" : \"truncate\"}>{languageName(locale, uiLocale)}</span>\n </span>\n );\n}\n\nexport interface LanguageSwitcherProps<Locale extends string> {\n /** Locales to offer, already narrowed to what this product enables. */\n locales: readonly Locale[];\n current: Locale;\n onSelect: (locale: Locale) => void;\n /** The trigger's accessible name and tooltip; \"Language\" (the DS string) by default. */\n label?: string;\n /** Hold the disabled trigger while the product's locale list resolves. */\n isLoading?: boolean;\n /** `button` (default): a trigger in a bar. `sidebar`: a full-width row whose list opens upward, for a panel sidebar. */\n variant?: \"button\" | \"sidebar\";\n /** A collapsed rail: the mark alone (or the name, without one), kept for screen readers either way. */\n isCollapsed?: boolean;\n /**\n * A mark before each language's name: a flag, an `IsoChip`, an icon. None by default: a language is not a\n * country, and the name alone tells the options apart.\n */\n renderMark?: (locale: Locale) => React.ReactNode;\n /** Control height: `medium` (default) matches the DS controls, `small` is the compact step. */\n size?: \"small\" | \"medium\";\n /**\n * Ids of elements that describe the trigger (\"Changes the language of the whole panel\"). It lands on the\n * trigger button, the focusable control, also while it is disabled for `isLoading`; left out, nothing is\n * added. While the trigger's tooltip is open it takes the place of the tooltip's id, which only\n * repeats `label`.\n */\n \"aria-describedby\"?: string;\n}\n\nconst subscribeToClient = () => () => {};\n\n/**\n * The language choice every surface offers, on the DS.\n *\n * Presentation only: the app resolves the product's locale list and handles\n * `onSelect` (routing, persistence). Names come from `Intl.DisplayNames` in\n * the active UI locale (`current`), ordered by that visible name.\n * Choosing a value is a Select, not a Menu, so the list is a listbox whose\n * current option is selected for assistive technology and carries a check.\n *\n * The trigger stays disabled until the component has mounted *and* the\n * caller reports the list resolved, so a product restricted to one language\n * never flashes the full list on a cold cache.\n */\nexport function LanguageSwitcher<Locale extends string>({\n locales,\n current,\n onSelect,\n label: labelProp,\n isLoading: loading = false,\n variant = \"button\",\n isCollapsed: collapsed = false,\n size = \"medium\",\n renderMark,\n \"aria-describedby\": describedBy,\n}: LanguageSwitcherProps<Locale>) {\n const sidebar = variant === \"sidebar\";\n const label = labelProp ?? languageLabel(current);\n // A collapsed trigger hides the name only behind a mark that is really there.\n const currentMark = renderMark?.(current) ?? null;\n const mounted = React.useSyncExternalStore(subscribeToClient, () => true, () => false);\n const buttonSize = size;\n const square = collapsed && !sidebar;\n const trigger = cn(\n BUTTON_BASE,\n buttonVariantClasses(\"subtle\"),\n BUTTON_SIZE[buttonSize],\n \"font-normal\",\n square && ICON_ONLY_SIZE[buttonSize],\n sidebar && (collapsed ? \"w-full justify-center px-0\" : \"w-full justify-start\"),\n );\n\n if (!mounted || loading) {\n return (\n <AriaButton data-slot=\"language-switcher-trigger\" aria-label={label} aria-describedby={describedBy} isDisabled className={trigger}>\n <LanguageLabel locale={current} uiLocale={current} hideName={collapsed && currentMark != null} mark={currentMark} />\n </AriaButton>\n );\n }\n\n const options = languageOptions(locales, current);\n\n return (\n <AriaSelect\n aria-label={label}\n // React Aria's Select hands it to the trigger button (useSelect → useField → triggerProps), not the wrapper.\n aria-describedby={describedBy}\n value={current as Key}\n onChange={(key) => {\n if (key != null) onSelect(String(key) as Locale);\n }}\n data-slot=\"language-switcher\"\n className={cn(sidebar && \"w-full\")}\n >\n <TooltipFor content={label} placement=\"bottom\">\n <AriaButton data-slot=\"language-switcher-trigger\" className={trigger}>\n {/* No SelectValue: the trigger is named by the caller's label alone, as before, and shows the current\n language itself (it is always `current`). */}\n <LanguageLabel locale={current} uiLocale={current} hideName={collapsed && currentMark != null} mark={currentMark} />\n </AriaButton>\n </TooltipFor>\n <Popover\n data-slot=\"language-switcher-popover\"\n placement={sidebar ? \"top start\" : \"bottom end\"}\n offset={4}\n className=\"flex min-w-44 flex-col overflow-hidden rounded-ds-large bg-ds-surface-overlay p-ds-050 text-ds-text shadow-ds-overlay outline-hidden\"\n >\n <ListBox data-slot=\"language-switcher-list\" className={LISTBOX}>\n {options.map((option) => (\n <ListBoxItem\n key={option.locale}\n id={option.locale}\n textValue={option.label}\n data-slot=\"language-switcher-option\"\n className={cn(OPTION, \"whitespace-nowrap\")}\n >\n {({ isSelected }) => (\n <>\n {/* The slot holds its width whether or not it is filled, so switching never shifts the rows;\n the indicator stays at the inline start. */}\n <span aria-hidden=\"true\" data-slot=\"language-switcher-check\" className=\"flex size-4 shrink-0 items-center justify-center\">\n {isSelected && <IconGlyph name=\"check\" />}\n </span>\n <LanguageLabel locale={option.locale} uiLocale={current} mark={renderMark?.(option.locale)} />\n </>\n )}\n </ListBoxItem>\n ))}\n </ListBox>\n </Popover>\n </AriaSelect>\n );\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The phone menu of Navbar and Sidebar: a panel from the inline start or end edge, never a bottom sheet
|
|
4
|
+
* (a menu reads top to bottom). A React Aria Modal: focus moves in and is trapped, Esc and the scrim
|
|
5
|
+
* close it, and focus returns to the menu button.
|
|
6
|
+
*/
|
|
7
|
+
export declare function NavPanel({ isOpen, onOpenChange, label, side, slot, header, children, }: {
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
onOpenChange: (isOpen: boolean) => void;
|
|
10
|
+
/** Names the dialog ("Main menu"). */
|
|
11
|
+
label: string;
|
|
12
|
+
side: "start" | "end";
|
|
13
|
+
/** `data-slot` prefix: "navbar" gives navbar-panel, navbar-panel-overlay. */
|
|
14
|
+
slot: string;
|
|
15
|
+
/** Beside the close button: the brand. */
|
|
16
|
+
header?: React.ReactNode;
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Dialog, Modal, ModalOverlay } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { CloseButton } from "../action/close-button.js";
|
|
7
|
+
/**
|
|
8
|
+
* What a press inside the panel does to it: a link ("link") or a plain action button ("action") closes it;
|
|
9
|
+
* a button that opens or switches something in place (a menu trigger, a toggle, a radio, a tab) keeps it.
|
|
10
|
+
*/
|
|
11
|
+
function closesPanel(target) {
|
|
12
|
+
if (target?.closest?.("a[href]"))
|
|
13
|
+
return "link";
|
|
14
|
+
const button = target?.closest?.("button");
|
|
15
|
+
if (!button)
|
|
16
|
+
return null;
|
|
17
|
+
const opensInPlace = button.hasAttribute("aria-haspopup") ||
|
|
18
|
+
button.hasAttribute("aria-expanded") ||
|
|
19
|
+
button.hasAttribute("aria-pressed") ||
|
|
20
|
+
["radio", "checkbox", "switch", "tab", "menuitemradio"].includes(button.getAttribute("role") ?? "");
|
|
21
|
+
return opensInPlace ? null : "action";
|
|
22
|
+
}
|
|
23
|
+
const BLANKET = "fixed inset-0 z-50 bg-ds-blanket transition-opacity duration-(--ds-duration-slow) ease-ds-enter " +
|
|
24
|
+
"data-[entering]:opacity-0 data-[exiting]:opacity-0 data-[exiting]:ease-ds-exit motion-reduce:transition-none";
|
|
25
|
+
/**
|
|
26
|
+
* The phone menu of Navbar and Sidebar: a panel from the inline start or end edge, never a bottom sheet
|
|
27
|
+
* (a menu reads top to bottom). A React Aria Modal: focus moves in and is trapped, Esc and the scrim
|
|
28
|
+
* close it, and focus returns to the menu button.
|
|
29
|
+
*/
|
|
30
|
+
export function NavPanel({ isOpen, onOpenChange, label, side, slot, header, children, }) {
|
|
31
|
+
return (_jsx(ModalOverlay, { isOpen: isOpen, onOpenChange: onOpenChange, isDismissable: true, "data-slot": `${slot}-panel-overlay`, className: BLANKET, children: _jsx(Modal, { "data-slot": `${slot}-panel`, className: cn("fixed inset-y-0 flex w-[min(20rem,85vw)] flex-col bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden",
|
|
32
|
+
// Safe-area insets are physical edges, so they pair with physical padding (RTL keeps them right).
|
|
33
|
+
"pt-[env(safe-area-inset-top,0px)] pb-[env(safe-area-inset-bottom,0px)] [padding-left:env(safe-area-inset-left,0px)] [padding-right:env(safe-area-inset-right,0px)]", "transition-[translate] duration-(--ds-duration-slow) ease-ds-enter data-[exiting]:ease-ds-exit motion-reduce:transition-none", side === "start"
|
|
34
|
+
? "start-0 data-[entering]:-translate-x-full data-[exiting]:-translate-x-full rtl:data-[entering]:translate-x-full rtl:data-[exiting]:translate-x-full"
|
|
35
|
+
: "end-0 data-[entering]:translate-x-full data-[exiting]:translate-x-full rtl:data-[entering]:-translate-x-full rtl:data-[exiting]:-translate-x-full"), children: _jsx(Dialog, { "aria-label": label, "data-slot": `${slot}-panel-dialog`, className: "flex min-h-0 flex-1 flex-col outline-hidden", children: _jsxs("div", { className: "flex min-h-0 flex-1 flex-col", onClickCapture: (event) => {
|
|
36
|
+
// A modified or middle click opens the link elsewhere: the reader stays here, so does the panel.
|
|
37
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0)
|
|
38
|
+
return;
|
|
39
|
+
if (closesPanel(event.target))
|
|
40
|
+
onOpenChange(false);
|
|
41
|
+
},
|
|
42
|
+
// From the keyboard React Aria presses a button on Enter/Space without a native click; the key-up
|
|
43
|
+
// reaches this capture before the button acts, so the panel closes first here too.
|
|
44
|
+
onKeyUpCapture: (event) => {
|
|
45
|
+
if (event.key !== "Enter" && event.key !== " ")
|
|
46
|
+
return;
|
|
47
|
+
if (closesPanel(event.target) === "action")
|
|
48
|
+
onOpenChange(false);
|
|
49
|
+
}, children: [_jsxs("div", { className: "flex h-14 shrink-0 items-center gap-ds-100 border-b border-ds-border px-ds-200", children: [_jsx("div", { className: "flex min-w-0 flex-1 items-center", children: header }), _jsx(CloseButton, { onPress: () => onOpenChange(false) })] }), _jsx("div", { className: "flex min-h-0 flex-1 flex-col gap-ds-200 overflow-y-auto p-ds-200", children: children })] }) }) }) }));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=nav-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nav-panel.js","sourceRoot":"","sources":["../../src/navigation/nav-panel.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD;;;GAGG;AACH,SAAS,WAAW,CAAC,MAAsB;IACzC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC;QAAE,OAAO,MAAM,CAAC;IAChD,MAAM,MAAM,GAAG,MAAM,EAAE,OAAO,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC3C,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,MAAM,YAAY,GAChB,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC;QACpC,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC;QACpC,MAAM,CAAC,YAAY,CAAC,cAAc,CAAC;QACnC,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,e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AK,CAAC,GAAG,KAAK,OAAO,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG;4BAAE,OAAO;wBACvD,IAAI,WAAW,CAAC,KAAK,CAAC,MAAwB,CAAC,KAAK,QAAQ;4BAAE,YAAY,CAAC,KAAK,CAAC,CAAC;oBACpF,CAAC,aAEH,eAAK,SAAS,EAAC,gFAAgF,aAC7F,cAAK,SAAS,EAAC,kCAAkC,YAAE,MAAM,GAAO,EAChE,KAAC,WAAW,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,IAC/C,EACN,cAAK,SAAS,EAAC,kEAAkE,YAAE,QAAQ,GAAO,IAC5F,GACC,GACH,GACK,CAChB,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Dialog, Modal, ModalOverlay } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { CloseButton } from \"../action/close-button\";\n\n/**\n * What a press inside the panel does to it: a link (\"link\") or a plain action button (\"action\") closes it;\n * a button that opens or switches something in place (a menu trigger, a toggle, a radio, a tab) keeps it.\n */\nfunction closesPanel(target: Element | null): \"link\" | \"action\" | null {\n if (target?.closest?.(\"a[href]\")) return \"link\";\n const button = target?.closest?.(\"button\");\n if (!button) return null;\n const opensInPlace =\n button.hasAttribute(\"aria-haspopup\") ||\n button.hasAttribute(\"aria-expanded\") ||\n button.hasAttribute(\"aria-pressed\") ||\n [\"radio\", \"checkbox\", \"switch\", \"tab\", \"menuitemradio\"].includes(button.getAttribute(\"role\") ?? \"\");\n return opensInPlace ? null : \"action\";\n}\n\nconst BLANKET =\n \"fixed inset-0 z-50 bg-ds-blanket transition-opacity duration-(--ds-duration-slow) ease-ds-enter \" +\n \"data-[entering]:opacity-0 data-[exiting]:opacity-0 data-[exiting]:ease-ds-exit motion-reduce:transition-none\";\n\n/**\n * The phone menu of Navbar and Sidebar: a panel from the inline start or end edge, never a bottom sheet\n * (a menu reads top to bottom). A React Aria Modal: focus moves in and is trapped, Esc and the scrim\n * close it, and focus returns to the menu button.\n */\nexport function NavPanel({\n isOpen,\n onOpenChange,\n label,\n side,\n slot,\n header,\n children,\n}: {\n isOpen: boolean;\n onOpenChange: (isOpen: boolean) => void;\n /** Names the dialog (\"Main menu\"). */\n label: string;\n side: \"start\" | \"end\";\n /** `data-slot` prefix: \"navbar\" gives navbar-panel, navbar-panel-overlay. */\n slot: string;\n /** Beside the close button: the brand. */\n header?: React.ReactNode;\n children: React.ReactNode;\n}) {\n return (\n <ModalOverlay isOpen={isOpen} onOpenChange={onOpenChange} isDismissable data-slot={`${slot}-panel-overlay`} className={BLANKET}>\n <Modal\n data-slot={`${slot}-panel`}\n className={cn(\n \"fixed inset-y-0 flex w-[min(20rem,85vw)] flex-col bg-ds-surface-overlay text-ds-text shadow-ds-overlay outline-hidden\",\n // Safe-area insets are physical edges, so they pair with physical padding (RTL keeps them right).\n \"pt-[env(safe-area-inset-top,0px)] pb-[env(safe-area-inset-bottom,0px)] [padding-left:env(safe-area-inset-left,0px)] [padding-right:env(safe-area-inset-right,0px)]\",\n \"transition-[translate] duration-(--ds-duration-slow) ease-ds-enter data-[exiting]:ease-ds-exit motion-reduce:transition-none\",\n side === \"start\"\n ? \"start-0 data-[entering]:-translate-x-full data-[exiting]:-translate-x-full rtl:data-[entering]:translate-x-full rtl:data-[exiting]:translate-x-full\"\n : \"end-0 data-[entering]:translate-x-full data-[exiting]:translate-x-full rtl:data-[entering]:-translate-x-full rtl:data-[exiting]:-translate-x-full\",\n )}\n >\n <Dialog aria-label={label} data-slot={`${slot}-panel-dialog`} className=\"flex min-h-0 flex-1 flex-col outline-hidden\">\n {/* Any link chosen in the panel (its own, an action, a language in a menu portalled from it) closes\n it: the layout around a menu usually stays mounted across a client-side navigation. So does a\n plain action button (\"Get started\" opening a signup dialog would otherwise open under the panel);\n buttons that open or switch something in place (a menu trigger, a toggle, a radio) keep it open. */}\n <div\n className=\"flex min-h-0 flex-1 flex-col\"\n onClickCapture={(event) => {\n // A modified or middle click opens the link elsewhere: the reader stays here, so does the panel.\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey || event.button !== 0) return;\n if (closesPanel(event.target as Element | null)) onOpenChange(false);\n }}\n // From the keyboard React Aria presses a button on Enter/Space without a native click; the key-up\n // reaches this capture before the button acts, so the panel closes first here too.\n onKeyUpCapture={(event) => {\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n if (closesPanel(event.target as Element | null) === \"action\") onOpenChange(false);\n }}\n >\n <div className=\"flex h-14 shrink-0 items-center gap-ds-100 border-b border-ds-border px-ds-200\">\n <div className=\"flex min-w-0 flex-1 items-center\">{header}</div>\n <CloseButton onPress={() => onOpenChange(false)} />\n </div>\n <div className=\"flex min-h-0 flex-1 flex-col gap-ds-200 overflow-y-auto p-ds-200\">{children}</div>\n </div>\n </Dialog>\n </Modal>\n </ModalOverlay>\n );\n}\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Density } from "../density.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type NavbarLink = {
|
|
4
|
+
/** Unique; `currentKey` matches it. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** A noun for the place ("Pricing"), never a verb. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** A page or an in-page anchor ("/#pricing"); it goes through the host router. */
|
|
9
|
+
href: string;
|
|
10
|
+
};
|
|
11
|
+
export type NavbarProps = {
|
|
12
|
+
/** The logo and wordmark (the site's logo). It links to `brandHref`. Or a `NavbarBrand` child. */
|
|
13
|
+
brand?: React.ReactNode;
|
|
14
|
+
/** Where the brand goes: the home page. */
|
|
15
|
+
brandHref?: string;
|
|
16
|
+
/** The brand link's name when the brand alone does not say where it goes ("Acme home"). */
|
|
17
|
+
brandLabel?: string;
|
|
18
|
+
/** Up to five destinations. Leave it out to compose `NavbarItem`s as children instead. */
|
|
19
|
+
links?: readonly NavbarLink[];
|
|
20
|
+
/**
|
|
21
|
+
* With no `links`: `NavbarItem`s (the destinations), plus an optional `NavbarBrand` (instead of `brand`) and
|
|
22
|
+
* `NavbarActions` (instead of `actions`).
|
|
23
|
+
*/
|
|
24
|
+
children?: React.ReactNode;
|
|
25
|
+
/** The link of the page (or section) in view: marked `aria-current="page"`. */
|
|
26
|
+
currentKey?: string;
|
|
27
|
+
/**
|
|
28
|
+
* At the end: a language switcher, sign-in (subtle), then the one primary action, the same on every page. On
|
|
29
|
+
* phones they move into the menu panel, under the links. Or a `NavbarActions` child.
|
|
30
|
+
*/
|
|
31
|
+
actions?: React.ReactNode;
|
|
32
|
+
/** Pinned to the top while the page scrolls. */
|
|
33
|
+
isSticky?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The width of the bar's content ("1280px", 1280), centred, so the brand and the actions line up with the page's
|
|
36
|
+
* own container; the bar's background and border still run the full width. Left out, the content spans it.
|
|
37
|
+
*/
|
|
38
|
+
maxWidth?: number | string;
|
|
39
|
+
/** `compact`: 48px instead of 56px, the bar after the hero. */
|
|
40
|
+
density?: Density;
|
|
41
|
+
/** Names the navigation landmark; "Main menu" by default. */
|
|
42
|
+
"aria-label"?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The top bar of public sites. Brand at the start, up to
|
|
46
|
+
* five links (the current one on `ds-background-neutral`), then the language switch and the actions.
|
|
47
|
+
* Under 768px the links, language switch and actions move into a menu panel from the end edge.
|
|
48
|
+
*/
|
|
49
|
+
export declare function Navbar({ brand: brandProp, brandHref, brandLabel, links, children, currentKey, actions: actionsProp, isSticky, maxWidth, density, "aria-label": label, }: NavbarProps): React.JSX.Element;
|
|
50
|
+
export type NavbarItemProps = {
|
|
51
|
+
/** Matches the Navbar's `currentKey`. */
|
|
52
|
+
id: string;
|
|
53
|
+
/** A page or an in-page anchor ("/#pricing"); it goes through the host router. */
|
|
54
|
+
href: string;
|
|
55
|
+
/** A noun for the place ("Pricing"), never a verb. */
|
|
56
|
+
children: React.ReactNode;
|
|
57
|
+
/** Marks this link as the page in view, instead of the Navbar's `currentKey`. */
|
|
58
|
+
isCurrent?: boolean;
|
|
59
|
+
};
|
|
60
|
+
/** One destination. It shows in the bar from 768px up and in the menu panel below that. */
|
|
61
|
+
export declare function NavbarItem({ id, href, children, isCurrent }: NavbarItemProps): React.JSX.Element;
|
|
62
|
+
export type NavbarBrandProps = {
|
|
63
|
+
/** The logo and wordmark; it links to the Navbar's `brandHref`. */
|
|
64
|
+
children: React.ReactNode;
|
|
65
|
+
};
|
|
66
|
+
/** The brand at the start, as a child instead of the `brand` prop. */
|
|
67
|
+
export declare function NavbarBrand({ children }: NavbarBrandProps): React.JSX.Element;
|
|
68
|
+
export type NavbarActionsProps = {
|
|
69
|
+
/** A language switcher, sign-in (subtle), then the one primary action. */
|
|
70
|
+
children: React.ReactNode;
|
|
71
|
+
};
|
|
72
|
+
/** The actions at the end, as a child instead of the `actions` prop; on phones they move into the menu panel. */
|
|
73
|
+
export declare function NavbarActions({ children }: NavbarActionsProps): React.JSX.Element;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 { Link as AriaLink, useLocale } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { BrandLinkContext } from "./brand-link-context.js";
|
|
7
|
+
import { Button } from "../action/button.js";
|
|
8
|
+
import { mainNavigationLabel, openMenuLabel } from "../i18n.js";
|
|
9
|
+
import { LAYER } from "../layers.js";
|
|
10
|
+
import { NavPanel } from "./nav-panel.js";
|
|
11
|
+
const LINK = "inline-flex h-8 items-center gap-ds-075 rounded-ds-control-medium px-ds-100 text-body font-[500] text-ds-text-subtle outline-hidden transition-colors duration-(--ds-duration-fast) motion-reduce:transition-none " +
|
|
12
|
+
"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[hovered]:text-ds-text data-[pressed]:bg-ds-background-neutral-pressed " +
|
|
13
|
+
"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused " +
|
|
14
|
+
"aria-[current=page]:bg-ds-background-neutral aria-[current=page]:text-ds-text";
|
|
15
|
+
/**
|
|
16
|
+
* The top bar of public sites. Brand at the start, up to
|
|
17
|
+
* five links (the current one on `ds-background-neutral`), then the language switch and the actions.
|
|
18
|
+
* Under 768px the links, language switch and actions move into a menu panel from the end edge.
|
|
19
|
+
*/
|
|
20
|
+
export function Navbar({ brand: brandProp, brandHref = "/", brandLabel, links, children, currentKey, actions: actionsProp, isSticky, maxWidth, density = "comfortable", "aria-label": label, }) {
|
|
21
|
+
const { locale } = useLocale();
|
|
22
|
+
const [open, setOpen] = React.useState(false);
|
|
23
|
+
const name = label ?? mainNavigationLabel(locale);
|
|
24
|
+
const { brand, actions: endActions, items } = splitSlots(children, brandProp, actionsProp);
|
|
25
|
+
const renderLinks = () => links ? (links.map((link) => (_jsx(NavbarItem, { id: link.id, href: link.href, children: link.label }, link.id)))) : (items);
|
|
26
|
+
const brandLink = (_jsx(AriaLink, { href: brandHref, "aria-label": brandLabel, "data-slot": "navbar-brand", className: "flex min-w-0 items-center gap-ds-100 rounded-ds-medium text-body-strong text-ds-text outline-hidden data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused", children: _jsx(BrandLinkContext.Provider, { value: true, children: brand }) }));
|
|
27
|
+
return (_jsxs("header", { "data-slot": "navbar", "data-density": density, className: cn("border-b border-ds-border bg-ds-surface-raised text-ds-text", isSticky && cn("sticky top-0 pt-[env(safe-area-inset-top,0px)]", LAYER.stickyBar)), children: [_jsxs("div", { "data-slot": "navbar-content", style: maxWidth !== undefined ? { maxWidth } : undefined, className: cn("flex items-center gap-ds-300 transition-[height] duration-(--ds-duration-medium) motion-reduce:transition-none", maxWidth !== undefined && "mx-auto w-full",
|
|
28
|
+
// Safe-area insets are physical edges, so they pair with physical padding.
|
|
29
|
+
"[padding-left:max(var(--ds-space-200),env(safe-area-inset-left,0px))] [padding-right:max(var(--ds-space-200),env(safe-area-inset-right,0px))]", "md:[padding-left:max(var(--ds-space-300),env(safe-area-inset-left,0px))] md:[padding-right:max(var(--ds-space-300),env(safe-area-inset-right,0px))]", density === "compact" ? "h-12" : "h-14"), children: [brandLink, _jsx("nav", { "aria-label": name, "data-slot": "navbar-links", className: "hidden md:block", children: _jsx("ul", { className: "flex items-center gap-ds-100", children: _jsx(NavbarContext.Provider, { value: { currentKey, inPanel: false }, children: renderLinks() }) }) }), _jsxs("div", { "data-slot": "navbar-end", className: "ms-auto flex items-center gap-ds-100", children: [_jsx("div", { className: "hidden items-center gap-ds-100 md:flex", children: endActions }), _jsx("div", { className: "md:hidden", children: _jsx(Button, { variant: "subtle", iconOnly: true, iconBefore: "menu", "aria-label": openMenuLabel(locale), "aria-expanded": open, onPress: () => setOpen(true), "data-slot": "navbar-menu-button" }) })] })] }), _jsxs(NavPanel, { isOpen: open, onOpenChange: setOpen, label: name, side: "end", slot: "navbar", header: brand, children: [_jsx("nav", { children: _jsx("ul", { className: "flex flex-col gap-ds-025", children: _jsx(NavbarContext.Provider, { value: { currentKey, inPanel: true }, children: renderLinks() }) }) }), endActions && (_jsx("div", { "data-slot": "navbar-panel-actions", className: "flex flex-col items-stretch gap-ds-100 border-t border-ds-border pt-ds-200", children: endActions }))] })] }));
|
|
30
|
+
}
|
|
31
|
+
// ---- Composed from parts ---------------------------------------------------------------------------------------
|
|
32
|
+
/** Where a `NavbarItem` renders: the bar, or the phone menu panel (a full-width 44px row). */
|
|
33
|
+
const NavbarContext = React.createContext(null);
|
|
34
|
+
/** One destination. It shows in the bar from 768px up and in the menu panel below that. */
|
|
35
|
+
export function NavbarItem({ id, href, children, isCurrent }) {
|
|
36
|
+
const context = React.useContext(NavbarContext);
|
|
37
|
+
if (!context)
|
|
38
|
+
throw new Error("NavbarItem must be inside a Navbar.");
|
|
39
|
+
return (_jsx("li", { children: _jsx(AriaLink, { href: href, "data-slot": context.inPanel ? "navbar-panel-link" : "navbar-link", "aria-current": isCurrent || id === context.currentKey ? "page" : undefined, className: context.inPanel ? cn(LINK, "flex h-11 w-full") : LINK, children: children }) }));
|
|
40
|
+
}
|
|
41
|
+
/** The brand at the start, as a child instead of the `brand` prop. */
|
|
42
|
+
export function NavbarBrand({ children }) {
|
|
43
|
+
return _jsx(_Fragment, { children: children });
|
|
44
|
+
}
|
|
45
|
+
/** The actions at the end, as a child instead of the `actions` prop; on phones they move into the menu panel. */
|
|
46
|
+
export function NavbarActions({ children }) {
|
|
47
|
+
return _jsx(_Fragment, { children: children });
|
|
48
|
+
}
|
|
49
|
+
/** Pulls `NavbarBrand` and `NavbarActions` out of the children; the rest are the items. Props win over children. */
|
|
50
|
+
function splitSlots(children, brand, actions) {
|
|
51
|
+
let brandSlot;
|
|
52
|
+
let actionsSlot;
|
|
53
|
+
const items = [];
|
|
54
|
+
for (const child of React.Children.toArray(children)) {
|
|
55
|
+
if (React.isValidElement(child) && child.type === NavbarBrand)
|
|
56
|
+
brandSlot = child.props.children;
|
|
57
|
+
else if (React.isValidElement(child) && child.type === NavbarActions)
|
|
58
|
+
actionsSlot = child.props.children;
|
|
59
|
+
else
|
|
60
|
+
items.push(child);
|
|
61
|
+
}
|
|
62
|
+
return { brand: brand ?? brandSlot, actions: actions ?? actionsSlot, items };
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=navbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navbar.js","sourceRoot":"","sources":["../../src/navigation/navbar.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,MAA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OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC;AAOD,iHAAiH;AACjH,MAAM,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAsB;IAC5D,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC;AAED,oHAAoH;AACpH,SAAS,UAAU,CAAC,QAAyB,EAAE,KAAsB,EAAE,OAAwB;IAC7F,IAAI,SAA0B,CAAC;IAC/B,IAAI,WAA4B,CAAC;IACjC,MAAM,KAAK,GAAsB,EAAE,CAAC;IACpC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,IAAI,KAAK,CAAC,cAAc,CAAiC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;YAAE,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;aAC3H,IAAI,KAAK,CAAC,cAAc,CAAiC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,aAAa;YAAE,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;;YACpI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,KAAK,EAAE,CAAC;AAC/E,CAAC","sourcesContent":["\"use client\";\n\nimport type { Density } from \"../density\";\nimport * as React from \"react\";\nimport { Link as AriaLink, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { BrandLinkContext } from \"./brand-link-context\";\nimport { Button } from \"../action/button\";\nimport { mainNavigationLabel, openMenuLabel } from \"../i18n\";\nimport { LAYER } from \"../layers\";\nimport { NavPanel } from \"./nav-panel\";\n\nexport type NavbarLink = {\n /** Unique; `currentKey` matches it. */\n id: string;\n /** A noun for the place (\"Pricing\"), never a verb. */\n label: string;\n /** A page or an in-page anchor (\"/#pricing\"); it goes through the host router. */\n href: string;\n};\n\nexport type NavbarProps = {\n /** The logo and wordmark (the site's logo). It links to `brandHref`. Or a `NavbarBrand` child. */\n brand?: React.ReactNode;\n /** Where the brand goes: the home page. */\n brandHref?: string;\n /** The brand link's name when the brand alone does not say where it goes (\"Acme home\"). */\n brandLabel?: string;\n /** Up to five destinations. Leave it out to compose `NavbarItem`s as children instead. */\n links?: readonly NavbarLink[];\n /**\n * With no `links`: `NavbarItem`s (the destinations), plus an optional `NavbarBrand` (instead of `brand`) and\n * `NavbarActions` (instead of `actions`).\n */\n children?: React.ReactNode;\n /** The link of the page (or section) in view: marked `aria-current=\"page\"`. */\n currentKey?: string;\n /**\n * At the end: a language switcher, sign-in (subtle), then the one primary action, the same on every page. On\n * phones they move into the menu panel, under the links. Or a `NavbarActions` child.\n */\n actions?: React.ReactNode;\n /** Pinned to the top while the page scrolls. */\n isSticky?: boolean;\n /**\n * The width of the bar's content (\"1280px\", 1280), centred, so the brand and the actions line up with the page's\n * own container; the bar's background and border still run the full width. Left out, the content spans it.\n */\n maxWidth?: number | string;\n /** `compact`: 48px instead of 56px, the bar after the hero. */\n density?: Density;\n /** Names the navigation landmark; \"Main menu\" by default. */\n \"aria-label\"?: string;\n};\n\nconst LINK =\n \"inline-flex h-8 items-center gap-ds-075 rounded-ds-control-medium px-ds-100 text-body font-[500] text-ds-text-subtle outline-hidden transition-colors duration-(--ds-duration-fast) motion-reduce:transition-none \" +\n \"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[hovered]:text-ds-text data-[pressed]:bg-ds-background-neutral-pressed \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused \" +\n \"aria-[current=page]:bg-ds-background-neutral aria-[current=page]:text-ds-text\";\n\n/**\n * The top bar of public sites. Brand at the start, up to\n * five links (the current one on `ds-background-neutral`), then the language switch and the actions.\n * Under 768px the links, language switch and actions move into a menu panel from the end edge.\n */\nexport function Navbar({\n brand: brandProp,\n brandHref = \"/\",\n brandLabel,\n links,\n children,\n currentKey,\n actions: actionsProp,\n isSticky,\n maxWidth,\n density = \"comfortable\",\n \"aria-label\": label,\n}: NavbarProps) {\n const { locale } = useLocale();\n const [open, setOpen] = React.useState(false);\n const name = label ?? mainNavigationLabel(locale);\n const { brand, actions: endActions, items } = splitSlots(children, brandProp, actionsProp);\n const renderLinks = () =>\n links ? (\n links.map((link) => (\n <NavbarItem key={link.id} id={link.id} href={link.href}>\n {link.label}\n </NavbarItem>\n ))\n ) : (\n items\n );\n const brandLink = (\n <AriaLink\n href={brandHref}\n aria-label={brandLabel}\n data-slot=\"navbar-brand\"\n className=\"flex min-w-0 items-center gap-ds-100 rounded-ds-medium text-body-strong text-ds-text outline-hidden data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused\"\n >\n <BrandLinkContext.Provider value>{brand}</BrandLinkContext.Provider>\n </AriaLink>\n );\n return (\n <header\n data-slot=\"navbar\"\n data-density={density}\n className={cn(\n \"border-b border-ds-border bg-ds-surface-raised text-ds-text\",\n isSticky && cn(\"sticky top-0 pt-[env(safe-area-inset-top,0px)]\", LAYER.stickyBar),\n )}\n >\n <div\n data-slot=\"navbar-content\"\n style={maxWidth !== undefined ? { maxWidth } : undefined}\n className={cn(\n \"flex items-center gap-ds-300 transition-[height] duration-(--ds-duration-medium) motion-reduce:transition-none\",\n maxWidth !== undefined && \"mx-auto w-full\",\n // Safe-area insets are physical edges, so they pair with physical padding.\n \"[padding-left:max(var(--ds-space-200),env(safe-area-inset-left,0px))] [padding-right:max(var(--ds-space-200),env(safe-area-inset-right,0px))]\",\n \"md:[padding-left:max(var(--ds-space-300),env(safe-area-inset-left,0px))] md:[padding-right:max(var(--ds-space-300),env(safe-area-inset-right,0px))]\",\n density === \"compact\" ? \"h-12\" : \"h-14\",\n )}\n >\n {brandLink}\n <nav aria-label={name} data-slot=\"navbar-links\" className=\"hidden md:block\">\n <ul className=\"flex items-center gap-ds-100\">\n <NavbarContext.Provider value={{ currentKey, inPanel: false }}>{renderLinks()}</NavbarContext.Provider>\n </ul>\n </nav>\n <div data-slot=\"navbar-end\" className=\"ms-auto flex items-center gap-ds-100\">\n <div className=\"hidden items-center gap-ds-100 md:flex\">\n {endActions}\n </div>\n <div className=\"md:hidden\">\n <Button\n variant=\"subtle\"\n iconOnly\n iconBefore=\"menu\"\n aria-label={openMenuLabel(locale)}\n aria-expanded={open}\n onPress={() => setOpen(true)}\n data-slot=\"navbar-menu-button\"\n />\n </div>\n </div>\n </div>\n <NavPanel isOpen={open} onOpenChange={setOpen} label={name} side=\"end\" slot=\"navbar\" header={brand}>\n {/* The dialog already carries the name; a second landmark name would be read twice. */}\n <nav>\n <ul className=\"flex flex-col gap-ds-025\">\n <NavbarContext.Provider value={{ currentKey, inPanel: true }}>{renderLinks()}</NavbarContext.Provider>\n </ul>\n </nav>\n {endActions && (\n <div data-slot=\"navbar-panel-actions\" className=\"flex flex-col items-stretch gap-ds-100 border-t border-ds-border pt-ds-200\">\n {endActions}\n </div>\n )}\n </NavPanel>\n </header>\n );\n}\n\n// ---- Composed from parts ---------------------------------------------------------------------------------------\n\n/** Where a `NavbarItem` renders: the bar, or the phone menu panel (a full-width 44px row). */\nconst NavbarContext = React.createContext<{ currentKey?: string; inPanel: boolean } | null>(null);\n\nexport type NavbarItemProps = {\n /** Matches the Navbar's `currentKey`. */\n id: string;\n /** A page or an in-page anchor (\"/#pricing\"); it goes through the host router. */\n href: string;\n /** A noun for the place (\"Pricing\"), never a verb. */\n children: React.ReactNode;\n /** Marks this link as the page in view, instead of the Navbar's `currentKey`. */\n isCurrent?: boolean;\n};\n\n/** One destination. It shows in the bar from 768px up and in the menu panel below that. */\nexport function NavbarItem({ id, href, children, isCurrent }: NavbarItemProps) {\n const context = React.useContext(NavbarContext);\n if (!context) throw new Error(\"NavbarItem must be inside a Navbar.\");\n return (\n <li>\n <AriaLink\n href={href}\n data-slot={context.inPanel ? \"navbar-panel-link\" : \"navbar-link\"}\n aria-current={isCurrent || id === context.currentKey ? \"page\" : undefined}\n className={context.inPanel ? cn(LINK, \"flex h-11 w-full\") : LINK}\n >\n {children}\n </AriaLink>\n </li>\n );\n}\n\nexport type NavbarBrandProps = {\n /** The logo and wordmark; it links to the Navbar's `brandHref`. */\n children: React.ReactNode;\n};\n\n/** The brand at the start, as a child instead of the `brand` prop. */\nexport function NavbarBrand({ children }: NavbarBrandProps) {\n return <>{children}</>;\n}\n\nexport type NavbarActionsProps = {\n /** A language switcher, sign-in (subtle), then the one primary action. */\n children: React.ReactNode;\n};\n\n/** The actions at the end, as a child instead of the `actions` prop; on phones they move into the menu panel. */\nexport function NavbarActions({ children }: NavbarActionsProps) {\n return <>{children}</>;\n}\n\n/** Pulls `NavbarBrand` and `NavbarActions` out of the children; the rest are the items. Props win over children. */\nfunction splitSlots(children: React.ReactNode, brand: React.ReactNode, actions: React.ReactNode) {\n let brandSlot: React.ReactNode;\n let actionsSlot: React.ReactNode;\n const items: React.ReactNode[] = [];\n for (const child of React.Children.toArray(children)) {\n if (React.isValidElement<{ children?: React.ReactNode }>(child) && child.type === NavbarBrand) brandSlot = child.props.children;\n else if (React.isValidElement<{ children?: React.ReactNode }>(child) && child.type === NavbarActions) actionsSlot = child.props.children;\n else items.push(child);\n }\n return { brand: brand ?? brandSlot, actions: actions ?? actionsSlot, items };\n}\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type BreadcrumbItem } from "./breadcrumbs.js";
|
|
3
|
+
/**
|
|
4
|
+
* Owns the bar's two regions. It sits above both the bar and the page, because the shell renders them as
|
|
5
|
+
* siblings: the bar outside the scrolling box (so content never runs under it) and the page inside it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function PageHeaderProvider({ children }: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}): React.JSX.Element;
|
|
10
|
+
export type PageHeaderBarProps = {
|
|
11
|
+
/** The menu button's name ("Open menu"); it opens the Sidebar, which is a panel under 1024px. */
|
|
12
|
+
menuLabel: string;
|
|
13
|
+
onMenuPress: () => void;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The panel's top bar (admin apps): the menu button under 1024px, then the page's title and its
|
|
17
|
+
* actions, which the page passes through `PageHeader`. The shell renders it outside the box that scrolls.
|
|
18
|
+
* Below 640px the actions take their own row, so a search field and a primary button never squeeze the title.
|
|
19
|
+
*/
|
|
20
|
+
export declare function PageHeaderBar({ menuLabel, onMenuPress }: PageHeaderBarProps): React.JSX.Element;
|
|
21
|
+
export type PageHeaderProps = {
|
|
22
|
+
/** The page's name; the page's one h1. */
|
|
23
|
+
title: React.ReactNode;
|
|
24
|
+
/** One line under the title. */
|
|
25
|
+
description?: React.ReactNode;
|
|
26
|
+
/** Where the page sits, above the title (a detail page under its list). */
|
|
27
|
+
breadcrumbs?: readonly BreadcrumbItem[];
|
|
28
|
+
/** The page's actions: filters, a search field, one primary button. */
|
|
29
|
+
actions?: React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* A panel page's header: the page says what it is and what it can do, and the
|
|
33
|
+
* shell's `PageHeaderBar` shows it, outside the scrolling content. Outside a `PageHeaderProvider` (a page
|
|
34
|
+
* rendered on its own, a test), it renders in place, so such a page keeps its title. A provider must always
|
|
35
|
+
* render a bar.
|
|
36
|
+
*/
|
|
37
|
+
export declare function PageHeader({ title, description, breadcrumbs, actions }: PageHeaderProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { createPortal } from "react-dom";
|
|
5
|
+
import { Button } from "../action/button.js";
|
|
6
|
+
import { Heading, Text } from "../display/typography.js";
|
|
7
|
+
import { Breadcrumbs } from "./breadcrumbs.js";
|
|
8
|
+
const PageHeaderContext = React.createContext(null);
|
|
9
|
+
/**
|
|
10
|
+
* Owns the bar's two regions. It sits above both the bar and the page, because the shell renders them as
|
|
11
|
+
* siblings: the bar outside the scrolling box (so content never runs under it) and the page inside it.
|
|
12
|
+
*/
|
|
13
|
+
export function PageHeaderProvider({ children }) {
|
|
14
|
+
const [titleNode, setTitleNode] = React.useState(null);
|
|
15
|
+
const [actionsNode, setActionsNode] = React.useState(null);
|
|
16
|
+
const value = React.useMemo(() => ({ titleNode, actionsNode, setTitleNode, setActionsNode }), [titleNode, actionsNode]);
|
|
17
|
+
return _jsx(PageHeaderContext.Provider, { value: value, children: children });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The panel's top bar (admin apps): the menu button under 1024px, then the page's title and its
|
|
21
|
+
* actions, which the page passes through `PageHeader`. The shell renders it outside the box that scrolls.
|
|
22
|
+
* Below 640px the actions take their own row, so a search field and a primary button never squeeze the title.
|
|
23
|
+
*/
|
|
24
|
+
export function PageHeaderBar({ menuLabel, onMenuPress }) {
|
|
25
|
+
const slots = React.useContext(PageHeaderContext);
|
|
26
|
+
return (_jsxs("header", { "data-slot": "page-header-bar", className: "flex shrink-0 flex-col gap-ds-100 border-b border-ds-border bg-ds-surface px-ds-200 py-ds-100 sm:min-h-16 sm:flex-row sm:items-center sm:justify-between sm:gap-ds-150 sm:px-ds-400", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-ds-150", children: [_jsx("span", { "data-slot": "page-header-menu", className: "flex lg:hidden", children: _jsx(Button, { variant: "subtle", iconOnly: true, iconBefore: "menu", "aria-label": menuLabel, onPress: onMenuPress }) }), _jsx("div", { ref: slots?.setTitleNode, "data-slot": "page-header-title", className: "min-w-0 flex-1" })] }), _jsx("div", { ref: slots?.setActionsNode, "data-slot": "page-header-actions", className: "flex shrink-0 flex-wrap items-center gap-ds-100 empty:hidden sm:flex-nowrap sm:justify-end" })] }));
|
|
27
|
+
}
|
|
28
|
+
function TitleBlock({ title, description, breadcrumbs }) {
|
|
29
|
+
return (_jsxs("div", { "data-slot": "page-header-text", className: "flex min-w-0 flex-col gap-ds-025", children: [breadcrumbs && breadcrumbs.length > 0 && _jsx(Breadcrumbs, { items: breadcrumbs }), _jsx(Heading, { level: 1, size: "heading-medium", children: title }), description != null && (_jsx(Text, { size: "body-small", tone: "subtle", elementType: "p", children: description }))] }));
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A panel page's header: the page says what it is and what it can do, and the
|
|
33
|
+
* shell's `PageHeaderBar` shows it, outside the scrolling content. Outside a `PageHeaderProvider` (a page
|
|
34
|
+
* rendered on its own, a test), it renders in place, so such a page keeps its title. A provider must always
|
|
35
|
+
* render a bar.
|
|
36
|
+
*/
|
|
37
|
+
export function PageHeader({ title, description, breadcrumbs, actions }) {
|
|
38
|
+
const slots = React.useContext(PageHeaderContext);
|
|
39
|
+
const text = _jsx(TitleBlock, { title: title, description: description, breadcrumbs: breadcrumbs });
|
|
40
|
+
if (slots?.titleNode) {
|
|
41
|
+
return (_jsxs(_Fragment, { children: [createPortal(text, slots.titleNode), actions != null && slots.actionsNode && createPortal(actions, slots.actionsNode)] }));
|
|
42
|
+
}
|
|
43
|
+
// Under a provider the header belongs in the bar: on the first commit the bar's regions are not set yet and
|
|
44
|
+
// they arrive in the same layout pass, so nothing paints without it. A provider must always render a
|
|
45
|
+
// PageHeaderBar; without one the header shows nowhere, as with the old slots.
|
|
46
|
+
if (slots)
|
|
47
|
+
return null;
|
|
48
|
+
return (_jsxs("div", { "data-slot": "page-header-inline", className: "mb-ds-300 flex flex-col gap-ds-150 sm:flex-row sm:items-center sm:justify-between", children: [text, actions != null && _jsx("div", { "data-slot": "page-header-inline-actions", className: "flex shrink-0 flex-wrap items-center gap-ds-100", children: actions })] }));
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=page-header.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-header.js","sourceRoot":"","sources":["../../src/navigation/page-header.tsx"],"names":[],"mappings":"AAAA,YAAY,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,EAAE,KAAK,CAAC,WAAW,CAAC,IAChF,CACJ,CAAC;IACJ,CAAC;IACD,4GAA4G;IAC5G,qGAAqG;IACrG,8EAA8E;IAC9E,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IACvB,OAAO,CACL,4BAAe,oBAAoB,EAAC,SAAS,EAAC,mFAAmF,aAC9H,IAAI,EACJ,OAAO,IAAI,IAAI,IAAI,2BAAe,4BAA4B,EAAC,SAAS,EAAC,iDAAiD,YAAE,OAAO,GAAO,IACvI,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { Button } from \"../action/button\";\nimport { Heading, Text } from \"../display/typography\";\nimport { Breadcrumbs, type BreadcrumbItem } from \"./breadcrumbs\";\n\ntype Slots = {\n titleNode: HTMLElement | null;\n actionsNode: HTMLElement | null;\n setTitleNode: (node: HTMLElement | null) => void;\n setActionsNode: (node: HTMLElement | null) => void;\n};\n\nconst PageHeaderContext = React.createContext<Slots | null>(null);\n\n/**\n * Owns the bar's two regions. It sits above both the bar and the page, because the shell renders them as\n * siblings: the bar outside the scrolling box (so content never runs under it) and the page inside it.\n */\nexport function PageHeaderProvider({ children }: { children: React.ReactNode }) {\n const [titleNode, setTitleNode] = React.useState<HTMLElement | null>(null);\n const [actionsNode, setActionsNode] = React.useState<HTMLElement | null>(null);\n const value = React.useMemo(() => ({ titleNode, actionsNode, setTitleNode, setActionsNode }), [titleNode, actionsNode]);\n return <PageHeaderContext.Provider value={value}>{children}</PageHeaderContext.Provider>;\n}\n\nexport type PageHeaderBarProps = {\n /** The menu button's name (\"Open menu\"); it opens the Sidebar, which is a panel under 1024px. */\n menuLabel: string;\n onMenuPress: () => void;\n};\n\n/**\n * The panel's top bar (admin apps): the menu button under 1024px, then the page's title and its\n * actions, which the page passes through `PageHeader`. The shell renders it outside the box that scrolls.\n * Below 640px the actions take their own row, so a search field and a primary button never squeeze the title.\n */\nexport function PageHeaderBar({ menuLabel, onMenuPress }: PageHeaderBarProps) {\n const slots = React.useContext(PageHeaderContext);\n return (\n <header\n data-slot=\"page-header-bar\"\n className=\"flex shrink-0 flex-col gap-ds-100 border-b border-ds-border bg-ds-surface px-ds-200 py-ds-100 sm:min-h-16 sm:flex-row sm:items-center sm:justify-between sm:gap-ds-150 sm:px-ds-400\"\n >\n <div className=\"flex min-w-0 flex-1 items-center gap-ds-150\">\n <span data-slot=\"page-header-menu\" className=\"flex lg:hidden\">\n <Button variant=\"subtle\" iconOnly iconBefore=\"menu\" aria-label={menuLabel} onPress={onMenuPress} />\n </span>\n <div ref={slots?.setTitleNode} data-slot=\"page-header-title\" className=\"min-w-0 flex-1\" />\n </div>\n {/* Hidden while empty, so a page without actions pays no gap for them. */}\n <div\n ref={slots?.setActionsNode}\n data-slot=\"page-header-actions\"\n className=\"flex shrink-0 flex-wrap items-center gap-ds-100 empty:hidden sm:flex-nowrap sm:justify-end\"\n />\n </header>\n );\n}\n\nexport type PageHeaderProps = {\n /** The page's name; the page's one h1. */\n title: React.ReactNode;\n /** One line under the title. */\n description?: React.ReactNode;\n /** Where the page sits, above the title (a detail page under its list). */\n breadcrumbs?: readonly BreadcrumbItem[];\n /** The page's actions: filters, a search field, one primary button. */\n actions?: React.ReactNode;\n};\n\nfunction TitleBlock({ title, description, breadcrumbs }: Omit<PageHeaderProps, \"actions\">) {\n return (\n <div data-slot=\"page-header-text\" className=\"flex min-w-0 flex-col gap-ds-025\">\n {breadcrumbs && breadcrumbs.length > 0 && <Breadcrumbs items={breadcrumbs} />}\n <Heading level={1} size=\"heading-medium\">{title}</Heading>\n {description != null && (\n <Text size=\"body-small\" tone=\"subtle\" elementType=\"p\">{description}</Text>\n )}\n </div>\n );\n}\n\n/**\n * A panel page's header: the page says what it is and what it can do, and the\n * shell's `PageHeaderBar` shows it, outside the scrolling content. Outside a `PageHeaderProvider` (a page\n * rendered on its own, a test), it renders in place, so such a page keeps its title. A provider must always\n * render a bar.\n */\nexport function PageHeader({ title, description, breadcrumbs, actions }: PageHeaderProps) {\n const slots = React.useContext(PageHeaderContext);\n const text = <TitleBlock title={title} description={description} breadcrumbs={breadcrumbs} />;\n if (slots?.titleNode) {\n return (\n <>\n {createPortal(text, slots.titleNode)}\n {actions != null && slots.actionsNode && createPortal(actions, slots.actionsNode)}\n </>\n );\n }\n // Under a provider the header belongs in the bar: on the first commit the bar's regions are not set yet and\n // they arrive in the same layout pass, so nothing paints without it. A provider must always render a\n // PageHeaderBar; without one the header shows nowhere, as with the old slots.\n if (slots) return null;\n return (\n <div data-slot=\"page-header-inline\" className=\"mb-ds-300 flex flex-col gap-ds-150 sm:flex-row sm:items-center sm:justify-between\">\n {text}\n {actions != null && <div data-slot=\"page-header-inline-actions\" className=\"flex shrink-0 flex-wrap items-center gap-ds-100\">{actions}</div>}\n </div>\n );\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export type PaginationProps = {
|
|
3
|
+
/** 1-based. Keep it in the URL so back and refresh return to it. */
|
|
4
|
+
page: number;
|
|
5
|
+
pageSize: number;
|
|
6
|
+
/** All items across pages. */
|
|
7
|
+
total: number;
|
|
8
|
+
onPageChange: (page: number) => void;
|
|
9
|
+
onPageSizeChange?: (pageSize: number) => void;
|
|
10
|
+
/** 20, 50 and 100 by default; the current size joins the list when it is not in it. */
|
|
11
|
+
pageSizeOptions?: readonly number[];
|
|
12
|
+
/**
|
|
13
|
+
* The range sentence naming the items: (41, 60, 1204) → "41–60 of 1,204 orders". It gets the
|
|
14
|
+
* raw numbers; format them for the locale yourself (Intl.NumberFormat).
|
|
15
|
+
*/
|
|
16
|
+
formatRange?: (from: number, to: number, total: number) => string;
|
|
17
|
+
};
|
|
18
|
+
/** First, last, the current page and one neighbour each side; gaps of two or more become "…". */
|
|
19
|
+
export declare function pageWindow(page: number, pages: number): (number | "gap")[];
|
|
20
|
+
/**
|
|
21
|
+
* Moves through a long, server-paged list and says where the reader is: the range, the pages (first,
|
|
22
|
+
* last, the current one and its neighbours) and the page size. On phones only previous and next stay,
|
|
23
|
+
* with "Sayfa 3 / 61". For feeds and timelines, load more on scroll instead.
|
|
24
|
+
*/
|
|
25
|
+
export declare function Pagination({ page, pageSize, total, onPageChange, onPageSizeChange, pageSizeOptions, formatRange, }: PaginationProps): React.JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Button as AriaButton, useLocale } from "react-aria-components";
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
import { Button } from "../action/button.js";
|
|
7
|
+
import { IconGlyph } from "../display/icon.js";
|
|
8
|
+
import { intlLocale, nextPageLabel, pageLabel, pageOfLabel, pagesLabel, perPageLabel, previousPageLabel, rangeOfLabel } from "../i18n.js";
|
|
9
|
+
import { Menu } from "../overlay/floating.js";
|
|
10
|
+
/** First, last, the current page and one neighbour each side; gaps of two or more become "…". */
|
|
11
|
+
export function pageWindow(page, pages) {
|
|
12
|
+
const keep = new Set([1, pages, page - 1, page, page + 1].filter((n) => n >= 1 && n <= pages));
|
|
13
|
+
const sorted = [...keep].sort((a, b) => a - b);
|
|
14
|
+
const out = [];
|
|
15
|
+
sorted.forEach((n, i) => {
|
|
16
|
+
const previous = sorted[i - 1];
|
|
17
|
+
if (previous !== undefined && n - previous === 2)
|
|
18
|
+
out.push(previous + 1);
|
|
19
|
+
else if (previous !== undefined && n - previous > 2)
|
|
20
|
+
out.push("gap");
|
|
21
|
+
out.push(n);
|
|
22
|
+
});
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
const PAGE = "grid h-8 min-w-8 cursor-default place-items-center rounded-ds-control-medium px-ds-075 text-body tabular-nums text-ds-text outline-hidden " +
|
|
26
|
+
"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[pressed]:bg-ds-background-neutral-pressed " +
|
|
27
|
+
"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused " +
|
|
28
|
+
// The current page: a soft neutral fill, the full text color and weight (not colour alone); no rim.
|
|
29
|
+
"aria-[current=page]:bg-ds-background-neutral-hovered aria-[current=page]:font-medium aria-[current=page]:text-ds-text";
|
|
30
|
+
/**
|
|
31
|
+
* Moves through a long, server-paged list and says where the reader is: the range, the pages (first,
|
|
32
|
+
* last, the current one and its neighbours) and the page size. On phones only previous and next stay,
|
|
33
|
+
* with "Sayfa 3 / 61". For feeds and timelines, load more on scroll instead.
|
|
34
|
+
*/
|
|
35
|
+
export function Pagination({ page, pageSize, total, onPageChange, onPageSizeChange, pageSizeOptions = [20, 50, 100], formatRange, }) {
|
|
36
|
+
const { locale } = useLocale();
|
|
37
|
+
const number = new Intl.NumberFormat(intlLocale(locale));
|
|
38
|
+
const pages = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));
|
|
39
|
+
const current = Math.min(Math.max(1, page), pages);
|
|
40
|
+
const from = total === 0 ? 0 : (current - 1) * pageSize + 1;
|
|
41
|
+
const to = Math.min(total, current * pageSize);
|
|
42
|
+
// A size the options do not list (a saved 25) joins them, so the control never shows nothing.
|
|
43
|
+
const sizes = [...new Set([...pageSizeOptions, pageSize])].sort((a, b) => a - b);
|
|
44
|
+
// An empty list has no range to state ("0–0 of 0" says nothing); the list's own empty state speaks.
|
|
45
|
+
const range = total === 0 ? "" : formatRange ? formatRange(from, to, total) : rangeOfLabel(locale, from, to, total);
|
|
46
|
+
// Previous points to the inline start: left in LTR, right in RTL. The chevron is named for LTR and IconGlyph
|
|
47
|
+
// mirrors it on an RTL page, so it is never flipped twice.
|
|
48
|
+
const step = (label, toward, target) => (_jsx(Button, { variant: "subtle", size: "small", iconOnly: true, iconBefore: toward === "previous" ? "chevron-left" : "chevron-right", "aria-label": label, isDisabled: target < 1 || target > pages, onPress: () => onPageChange(target), "data-slot": `pagination-${toward}` }));
|
|
49
|
+
return (_jsxs("div", { "data-slot": "pagination", className: "flex flex-wrap items-center justify-between gap-ds-200", children: [_jsx("span", { "data-slot": "pagination-range", "aria-live": "polite", className: "text-body-small tabular-nums text-ds-text-subtle", children: range }), _jsxs("nav", { "aria-label": pagesLabel(locale), "data-slot": "pagination-pages", className: "flex items-center gap-ds-050", children: [step(previousPageLabel(locale), "previous", current - 1), _jsx("ul", { className: "hidden items-center gap-ds-050 sm:flex", children: pageWindow(current, pages).map((entry, index) => entry === "gap" ? (_jsx("li", { "aria-hidden": true, "data-slot": "pagination-gap", className: "grid h-8 min-w-8 place-items-center text-body text-ds-text-disabled", children: "\u2026" }, `gap-${index}`)) : (_jsx("li", { children: _jsx(AriaButton, { "data-slot": "pagination-page", "aria-label": pageLabel(locale, entry), "aria-current": entry === current ? "page" : undefined, onPress: () => entry !== current && onPageChange(entry), className: PAGE, children: number.format(entry) }) }, entry))) }), _jsx("span", { "data-slot": "pagination-compact", className: "px-ds-100 text-body-small tabular-nums text-ds-text-subtle sm:hidden", children: pageOfLabel(locale, current, pages) }), step(nextPageLabel(locale), "next", current + 1)] }), onPageSizeChange && (_jsxs("div", { "data-slot": "pagination-size", className: cn("flex items-center gap-ds-100"), children: [_jsx("span", { "aria-hidden": true, className: "text-body-small text-ds-text-subtle", children: perPageLabel(locale) }), _jsx(Menu, { "aria-label": perPageLabel(locale), selectionMode: "single", selectedKeys: [String(pageSize)], onAction: (key) => onPageSizeChange(Number(key)), items: sizes.map((size) => ({ id: String(size), label: number.format(size) })), trigger: _jsx(Button, { variant: "default", size: "small", iconAfter: "chevron-down", "aria-label": `${perPageLabel(locale)}: ${number.format(pageSize)}`, children: _jsx("span", { className: "tabular-nums", children: number.format(pageSize) }) }) })] }))] }));
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../../src/navigation/pagination.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb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CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAC9E,OAAO,EACL,KAAC,MAAM,IAAC,OAAO,EAAC,SAAS,EAAC,IAAI,EAAC,OAAO,EAAC,SAAS,EAAC,cAAc,gBAAa,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,YAC/H,eAAM,SAAS,EAAC,cAAc,YAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAQ,GACxD,GAEX,IACE,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport { Button as AriaButton, useLocale } from \"react-aria-components\";\n\nimport { cn } from \"../utils\";\nimport { Button } from \"../action/button\";\nimport { IconGlyph } from \"../display/icon\";\nimport { intlLocale, nextPageLabel, pageLabel, pageOfLabel, pagesLabel, perPageLabel, previousPageLabel, rangeOfLabel } from \"../i18n\";\nimport { Menu } from \"../overlay/floating\";\n\nexport type PaginationProps = {\n /** 1-based. Keep it in the URL so back and refresh return to it. */\n page: number;\n pageSize: number;\n /** All items across pages. */\n total: number;\n onPageChange: (page: number) => void;\n onPageSizeChange?: (pageSize: number) => void;\n /** 20, 50 and 100 by default; the current size joins the list when it is not in it. */\n pageSizeOptions?: readonly number[];\n /**\n * The range sentence naming the items: (41, 60, 1204) → \"41–60 of 1,204 orders\". It gets the\n * raw numbers; format them for the locale yourself (Intl.NumberFormat).\n */\n formatRange?: (from: number, to: number, total: number) => string;\n};\n\n/** First, last, the current page and one neighbour each side; gaps of two or more become \"…\". */\nexport function pageWindow(page: number, pages: number): (number | \"gap\")[] {\n const keep = new Set([1, pages, page - 1, page, page + 1].filter((n) => n >= 1 && n <= pages));\n const sorted = [...keep].sort((a, b) => a - b);\n const out: (number | \"gap\")[] = [];\n sorted.forEach((n, i) => {\n const previous = sorted[i - 1];\n if (previous !== undefined && n - previous === 2) out.push(previous + 1);\n else if (previous !== undefined && n - previous > 2) out.push(\"gap\");\n out.push(n);\n });\n return out;\n}\n\nconst PAGE =\n \"grid h-8 min-w-8 cursor-default place-items-center rounded-ds-control-medium px-ds-075 text-body tabular-nums text-ds-text outline-hidden \" +\n \"data-[hovered]:bg-ds-background-neutral-subtle-hovered data-[pressed]:bg-ds-background-neutral-pressed \" +\n \"data-[focus-visible]:inset-ring-2 data-[focus-visible]:inset-ring-ds-border-focused \" +\n // The current page: a soft neutral fill, the full text color and weight (not colour alone); no rim.\n \"aria-[current=page]:bg-ds-background-neutral-hovered aria-[current=page]:font-medium aria-[current=page]:text-ds-text\";\n\n/**\n * Moves through a long, server-paged list and says where the reader is: the range, the pages (first,\n * last, the current one and its neighbours) and the page size. On phones only previous and next stay,\n * with \"Sayfa 3 / 61\". For feeds and timelines, load more on scroll instead.\n */\nexport function Pagination({\n page,\n pageSize,\n total,\n onPageChange,\n onPageSizeChange,\n pageSizeOptions = [20, 50, 100],\n formatRange,\n}: PaginationProps) {\n const { locale } = useLocale();\n const number = new Intl.NumberFormat(intlLocale(locale));\n const pages = Math.max(1, Math.ceil(total / Math.max(1, pageSize)));\n const current = Math.min(Math.max(1, page), pages);\n const from = total === 0 ? 0 : (current - 1) * pageSize + 1;\n const to = Math.min(total, current * pageSize);\n // A size the options do not list (a saved 25) joins them, so the control never shows nothing.\n const sizes = [...new Set([...pageSizeOptions, pageSize])].sort((a, b) => a - b);\n // An empty list has no range to state (\"0–0 of 0\" says nothing); the list's own empty state speaks.\n const range = total === 0 ? \"\" : formatRange ? formatRange(from, to, total) : rangeOfLabel(locale, from, to, total);\n // Previous points to the inline start: left in LTR, right in RTL. The chevron is named for LTR and IconGlyph\n // mirrors it on an RTL page, so it is never flipped twice.\n const step = (label: string, toward: \"previous\" | \"next\", target: number) => (\n <Button\n variant=\"subtle\"\n size=\"small\"\n iconOnly\n iconBefore={toward === \"previous\" ? \"chevron-left\" : \"chevron-right\"}\n aria-label={label}\n isDisabled={target < 1 || target > pages}\n onPress={() => onPageChange(target)}\n data-slot={`pagination-${toward}`}\n />\n );\n return (\n <div data-slot=\"pagination\" className=\"flex flex-wrap items-center justify-between gap-ds-200\">\n <span data-slot=\"pagination-range\" aria-live=\"polite\" className=\"text-body-small tabular-nums text-ds-text-subtle\">\n {range}\n </span>\n <nav aria-label={pagesLabel(locale)} data-slot=\"pagination-pages\" className=\"flex items-center gap-ds-050\">\n {step(previousPageLabel(locale), \"previous\", current - 1)}\n <ul className=\"hidden items-center gap-ds-050 sm:flex\">\n {pageWindow(current, pages).map((entry, index) =>\n entry === \"gap\" ? (\n <li key={`gap-${index}`} aria-hidden data-slot=\"pagination-gap\" className=\"grid h-8 min-w-8 place-items-center text-body text-ds-text-disabled\">\n …\n </li>\n ) : (\n <li key={entry}>\n <AriaButton\n data-slot=\"pagination-page\"\n aria-label={pageLabel(locale, entry)}\n aria-current={entry === current ? \"page\" : undefined}\n onPress={() => entry !== current && onPageChange(entry)}\n className={PAGE}\n >\n {number.format(entry)}\n </AriaButton>\n </li>\n ),\n )}\n </ul>\n <span data-slot=\"pagination-compact\" className=\"px-ds-100 text-body-small tabular-nums text-ds-text-subtle sm:hidden\">\n {pageOfLabel(locale, current, pages)}\n </span>\n {step(nextPageLabel(locale), \"next\", current + 1)}\n </nav>\n {onPageSizeChange && (\n <div data-slot=\"pagination-size\" className={cn(\"flex items-center gap-ds-100\")}>\n <span aria-hidden className=\"text-body-small text-ds-text-subtle\">{perPageLabel(locale)}</span>\n <Menu\n aria-label={perPageLabel(locale)}\n selectionMode=\"single\"\n selectedKeys={[String(pageSize)]}\n onAction={(key) => onPageSizeChange(Number(key))}\n items={sizes.map((size) => ({ id: String(size), label: number.format(size) }))}\n trigger={\n <Button variant=\"default\" size=\"small\" iconAfter=\"chevron-down\" aria-label={`${perPageLabel(locale)}: ${number.format(pageSize)}`}>\n <span className=\"tabular-nums\">{number.format(pageSize)}</span>\n </Button>\n }\n />\n </div>\n )}\n </div>\n );\n}\n"]}
|