@sdxc/ui 0.0.0-pre.1
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.md +21 -0
- package/README.md +812 -0
- package/dist/animations/index.d.ts +12 -0
- package/dist/animations/index.js +12 -0
- package/dist/animations/keyframes.d.ts +162 -0
- package/dist/animations/keyframes.js +297 -0
- package/dist/animations/scroll.d.ts +154 -0
- package/dist/animations/scroll.js +228 -0
- package/dist/animations/tokens.d.ts +47 -0
- package/dist/animations/tokens.js +47 -0
- package/dist/animations/transitions.d.ts +143 -0
- package/dist/animations/transitions.js +147 -0
- package/dist/behaviors/announcer.d.ts +90 -0
- package/dist/behaviors/announcer.js +93 -0
- package/dist/behaviors/calendar-model.d.ts +218 -0
- package/dist/behaviors/calendar-model.js +376 -0
- package/dist/behaviors/drag-session.d.ts +119 -0
- package/dist/behaviors/drag-session.js +110 -0
- package/dist/behaviors/filter-model.d.ts +117 -0
- package/dist/behaviors/filter-model.js +185 -0
- package/dist/behaviors/index.d.ts +16 -0
- package/dist/behaviors/index.js +16 -0
- package/dist/behaviors/resize-session.d.ts +115 -0
- package/dist/behaviors/resize-session.js +157 -0
- package/dist/behaviors/scroll-follow-model.d.ts +180 -0
- package/dist/behaviors/scroll-follow-model.js +197 -0
- package/dist/behaviors/selection-model.d.ts +129 -0
- package/dist/behaviors/selection-model.js +259 -0
- package/dist/behaviors/toaster.d.ts +144 -0
- package/dist/behaviors/toaster.js +228 -0
- package/dist/components/accordion.d.ts +93 -0
- package/dist/components/accordion.js +165 -0
- package/dist/components/alert-dialog.d.ts +110 -0
- package/dist/components/alert-dialog.js +169 -0
- package/dist/components/alert.d.ts +109 -0
- package/dist/components/alert.js +160 -0
- package/dist/components/aspect-ratio.d.ts +44 -0
- package/dist/components/aspect-ratio.js +35 -0
- package/dist/components/attachment.d.ts +146 -0
- package/dist/components/attachment.js +320 -0
- package/dist/components/avatar.d.ts +118 -0
- package/dist/components/avatar.js +89 -0
- package/dist/components/badge.d.ts +66 -0
- package/dist/components/badge.js +129 -0
- package/dist/components/breadcrumbs.d.ts +67 -0
- package/dist/components/breadcrumbs.js +121 -0
- package/dist/components/bubble.d.ts +91 -0
- package/dist/components/bubble.js +216 -0
- package/dist/components/button.d.ts +78 -0
- package/dist/components/button.js +207 -0
- package/dist/components/calendar.d.ts +166 -0
- package/dist/components/calendar.js +320 -0
- package/dist/components/card.d.ts +82 -0
- package/dist/components/card.js +126 -0
- package/dist/components/carousel.d.ts +96 -0
- package/dist/components/carousel.js +214 -0
- package/dist/components/chart.d.ts +485 -0
- package/dist/components/chart.js +563 -0
- package/dist/components/checkbox-group.d.ts +58 -0
- package/dist/components/checkbox-group.js +53 -0
- package/dist/components/checkbox.d.ts +61 -0
- package/dist/components/checkbox.js +81 -0
- package/dist/components/color-area.d.ts +83 -0
- package/dist/components/color-area.js +251 -0
- package/dist/components/color-field.d.ts +128 -0
- package/dist/components/color-field.js +73 -0
- package/dist/components/color-picker.d.ts +132 -0
- package/dist/components/color-picker.js +183 -0
- package/dist/components/color-slider.d.ts +103 -0
- package/dist/components/color-slider.js +198 -0
- package/dist/components/color-swatch-picker.d.ts +106 -0
- package/dist/components/color-swatch-picker.js +75 -0
- package/dist/components/color-swatch.d.ts +57 -0
- package/dist/components/color-swatch.js +82 -0
- package/dist/components/color-wheel.d.ts +58 -0
- package/dist/components/color-wheel.js +160 -0
- package/dist/components/combobox.d.ts +73 -0
- package/dist/components/combobox.js +108 -0
- package/dist/components/command.d.ts +80 -0
- package/dist/components/command.js +151 -0
- package/dist/components/confirm.d.ts +124 -0
- package/dist/components/confirm.js +56 -0
- package/dist/components/context-menu.d.ts +108 -0
- package/dist/components/context-menu.js +200 -0
- package/dist/components/date-field.d.ts +110 -0
- package/dist/components/date-field.js +49 -0
- package/dist/components/date-picker.d.ts +136 -0
- package/dist/components/date-picker.js +155 -0
- package/dist/components/date-range-picker.d.ts +152 -0
- package/dist/components/date-range-picker.js +106 -0
- package/dist/components/description.d.ts +36 -0
- package/dist/components/description.js +21 -0
- package/dist/components/dialog.d.ts +97 -0
- package/dist/components/dialog.js +203 -0
- package/dist/components/disclosure.d.ts +85 -0
- package/dist/components/disclosure.js +180 -0
- package/dist/components/drawer.d.ts +82 -0
- package/dist/components/drawer.js +162 -0
- package/dist/components/drop-indicator.d.ts +43 -0
- package/dist/components/drop-indicator.js +47 -0
- package/dist/components/drop-zone.d.ts +73 -0
- package/dist/components/drop-zone.js +54 -0
- package/dist/components/empty.d.ts +89 -0
- package/dist/components/empty.js +129 -0
- package/dist/components/field-error.d.ts +41 -0
- package/dist/components/field-error.js +36 -0
- package/dist/components/file-trigger.d.ts +84 -0
- package/dist/components/file-trigger.js +169 -0
- package/dist/components/form.d.ts +118 -0
- package/dist/components/form.js +113 -0
- package/dist/components/grid-list.d.ts +112 -0
- package/dist/components/grid-list.js +220 -0
- package/dist/components/group.d.ts +45 -0
- package/dist/components/group.js +44 -0
- package/dist/components/header.d.ts +33 -0
- package/dist/components/header.js +29 -0
- package/dist/components/heading-scope.d.ts +83 -0
- package/dist/components/heading-scope.js +82 -0
- package/dist/components/heading.d.ts +50 -0
- package/dist/components/heading.js +31 -0
- package/dist/components/hover-card.d.ts +77 -0
- package/dist/components/hover-card.js +151 -0
- package/dist/components/image-placeholder.d.ts +105 -0
- package/dist/components/image-placeholder.js +212 -0
- package/dist/components/index.d.ts +109 -0
- package/dist/components/index.js +109 -0
- package/dist/components/input.d.ts +53 -0
- package/dist/components/input.js +76 -0
- package/dist/components/item.d.ts +97 -0
- package/dist/components/item.js +185 -0
- package/dist/components/keyboard.d.ts +33 -0
- package/dist/components/keyboard.js +20 -0
- package/dist/components/label.d.ts +38 -0
- package/dist/components/label.js +24 -0
- package/dist/components/link-button.d.ts +59 -0
- package/dist/components/link-button.js +174 -0
- package/dist/components/link.d.ts +43 -0
- package/dist/components/link.js +85 -0
- package/dist/components/listbox.d.ts +119 -0
- package/dist/components/listbox.js +114 -0
- package/dist/components/logo.d.ts +117 -0
- package/dist/components/logo.js +89 -0
- package/dist/components/marker.d.ts +82 -0
- package/dist/components/marker.js +163 -0
- package/dist/components/menu.d.ts +90 -0
- package/dist/components/menu.js +146 -0
- package/dist/components/menubar.d.ts +54 -0
- package/dist/components/menubar.js +118 -0
- package/dist/components/message-scroller.d.ts +109 -0
- package/dist/components/message-scroller.js +180 -0
- package/dist/components/message.d.ts +104 -0
- package/dist/components/message.js +200 -0
- package/dist/components/meter.d.ts +60 -0
- package/dist/components/meter.js +110 -0
- package/dist/components/modal.d.ts +71 -0
- package/dist/components/modal.js +120 -0
- package/dist/components/nav-link.d.ts +53 -0
- package/dist/components/nav-link.js +83 -0
- package/dist/components/navigation-menu.d.ts +150 -0
- package/dist/components/navigation-menu.js +381 -0
- package/dist/components/number-field.d.ts +76 -0
- package/dist/components/number-field.js +190 -0
- package/dist/components/otp-field.d.ts +68 -0
- package/dist/components/otp-field.js +46 -0
- package/dist/components/overlay-arrow.d.ts +51 -0
- package/dist/components/overlay-arrow.js +77 -0
- package/dist/components/pagination.d.ts +67 -0
- package/dist/components/pagination.js +164 -0
- package/dist/components/popover.d.ts +69 -0
- package/dist/components/popover.js +68 -0
- package/dist/components/progress-bar.d.ts +53 -0
- package/dist/components/progress-bar.js +90 -0
- package/dist/components/radio-group.d.ts +102 -0
- package/dist/components/radio-group.js +114 -0
- package/dist/components/range-calendar.d.ts +169 -0
- package/dist/components/range-calendar.js +216 -0
- package/dist/components/resizable.d.ts +98 -0
- package/dist/components/resizable.js +151 -0
- package/dist/components/scroll-area.d.ts +54 -0
- package/dist/components/scroll-area.js +89 -0
- package/dist/components/search-field.d.ts +55 -0
- package/dist/components/search-field.js +49 -0
- package/dist/components/section.d.ts +37 -0
- package/dist/components/section.js +22 -0
- package/dist/components/select.d.ts +96 -0
- package/dist/components/select.js +285 -0
- package/dist/components/selection-indicator.d.ts +47 -0
- package/dist/components/selection-indicator.js +50 -0
- package/dist/components/sentinel-row.d.ts +22 -0
- package/dist/components/sentinel-row.js +29 -0
- package/dist/components/separator.d.ts +35 -0
- package/dist/components/separator.js +48 -0
- package/dist/components/shared-element.d.ts +45 -0
- package/dist/components/shared-element.js +48 -0
- package/dist/components/sheet.d.ts +78 -0
- package/dist/components/sheet.js +167 -0
- package/dist/components/sidebar.d.ts +288 -0
- package/dist/components/sidebar.js +1068 -0
- package/dist/components/skeleton.d.ts +36 -0
- package/dist/components/skeleton.js +38 -0
- package/dist/components/slider.d.ts +102 -0
- package/dist/components/slider.js +179 -0
- package/dist/components/spinner.d.ts +55 -0
- package/dist/components/spinner.js +51 -0
- package/dist/components/switch.d.ts +47 -0
- package/dist/components/switch.js +82 -0
- package/dist/components/table.d.ts +139 -0
- package/dist/components/table.js +216 -0
- package/dist/components/tabs.d.ts +124 -0
- package/dist/components/tabs.js +246 -0
- package/dist/components/tag-group.d.ts +83 -0
- package/dist/components/tag-group.js +157 -0
- package/dist/components/text-field.d.ts +119 -0
- package/dist/components/text-field.js +51 -0
- package/dist/components/text.d.ts +34 -0
- package/dist/components/text.js +19 -0
- package/dist/components/textarea.d.ts +52 -0
- package/dist/components/textarea.js +82 -0
- package/dist/components/time-field.d.ts +110 -0
- package/dist/components/time-field.js +48 -0
- package/dist/components/toast.d.ts +149 -0
- package/dist/components/toast.js +365 -0
- package/dist/components/toggle-button.d.ts +115 -0
- package/dist/components/toggle-button.js +237 -0
- package/dist/components/toolbar.d.ts +47 -0
- package/dist/components/toolbar.js +54 -0
- package/dist/components/tooltip.d.ts +52 -0
- package/dist/components/tooltip.js +92 -0
- package/dist/components/tree.d.ts +123 -0
- package/dist/components/tree.js +239 -0
- package/dist/components/typeset.d.ts +53 -0
- package/dist/components/typeset.js +271 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/mixins/aria-checked.d.ts +42 -0
- package/dist/mixins/aria-checked.js +127 -0
- package/dist/mixins/attachment-trigger.d.ts +64 -0
- package/dist/mixins/attachment-trigger.js +190 -0
- package/dist/mixins/calendar-keys.d.ts +27 -0
- package/dist/mixins/calendar-keys.js +113 -0
- package/dist/mixins/carousel-controls.d.ts +30 -0
- package/dist/mixins/carousel-controls.js +222 -0
- package/dist/mixins/chart-tooltip.d.ts +118 -0
- package/dist/mixins/chart-tooltip.js +323 -0
- package/dist/mixins/clear-field.d.ts +60 -0
- package/dist/mixins/clear-field.js +100 -0
- package/dist/mixins/color-area-drag.d.ts +58 -0
- package/dist/mixins/color-area-drag.js +162 -0
- package/dist/mixins/color-channel-sync.d.ts +73 -0
- package/dist/mixins/color-channel-sync.js +169 -0
- package/dist/mixins/color-preview.d.ts +28 -0
- package/dist/mixins/color-preview.js +77 -0
- package/dist/mixins/color-wheel-drag.d.ts +58 -0
- package/dist/mixins/color-wheel-drag.js +139 -0
- package/dist/mixins/combobox-filter.d.ts +59 -0
- package/dist/mixins/combobox-filter.js +81 -0
- package/dist/mixins/command-filter.d.ts +55 -0
- package/dist/mixins/command-filter.js +121 -0
- package/dist/mixins/command-keys.d.ts +31 -0
- package/dist/mixins/command-keys.js +116 -0
- package/dist/mixins/context-menu.d.ts +24 -0
- package/dist/mixins/context-menu.js +64 -0
- package/dist/mixins/copy-to-clipboard.d.ts +64 -0
- package/dist/mixins/copy-to-clipboard.js +109 -0
- package/dist/mixins/dismiss.d.ts +77 -0
- package/dist/mixins/dismiss.js +151 -0
- package/dist/mixins/drag-reorder.d.ts +88 -0
- package/dist/mixins/drag-reorder.js +214 -0
- package/dist/mixins/drop-zone.d.ts +52 -0
- package/dist/mixins/drop-zone.js +132 -0
- package/dist/mixins/dual-range.d.ts +60 -0
- package/dist/mixins/dual-range.js +100 -0
- package/dist/mixins/grid-list-keys.d.ts +34 -0
- package/dist/mixins/grid-list-keys.js +260 -0
- package/dist/mixins/heading-level-fallback.d.ts +81 -0
- package/dist/mixins/heading-level-fallback.js +112 -0
- package/dist/mixins/hotkey.d.ts +26 -0
- package/dist/mixins/hotkey.js +132 -0
- package/dist/mixins/image-fallback.d.ts +57 -0
- package/dist/mixins/image-fallback.js +86 -0
- package/dist/mixins/index.d.ts +48 -0
- package/dist/mixins/index.js +48 -0
- package/dist/mixins/listbox-keys.d.ts +52 -0
- package/dist/mixins/listbox-keys.js +63 -0
- package/dist/mixins/long-press.d.ts +76 -0
- package/dist/mixins/long-press.js +130 -0
- package/dist/mixins/menu-keys.d.ts +40 -0
- package/dist/mixins/menu-keys.js +117 -0
- package/dist/mixins/menubar-keys.d.ts +59 -0
- package/dist/mixins/menubar-keys.js +230 -0
- package/dist/mixins/message-follow.d.ts +56 -0
- package/dist/mixins/message-follow.js +368 -0
- package/dist/mixins/otp-slots.d.ts +53 -0
- package/dist/mixins/otp-slots.js +175 -0
- package/dist/mixins/persist.d.ts +36 -0
- package/dist/mixins/persist.js +78 -0
- package/dist/mixins/press-toggle.d.ts +43 -0
- package/dist/mixins/press-toggle.js +61 -0
- package/dist/mixins/range-preview.d.ts +26 -0
- package/dist/mixins/range-preview.js +120 -0
- package/dist/mixins/resize-handle.d.ts +101 -0
- package/dist/mixins/resize-handle.js +288 -0
- package/dist/mixins/stepper.d.ts +81 -0
- package/dist/mixins/stepper.js +194 -0
- package/dist/mixins/tab-keys.d.ts +30 -0
- package/dist/mixins/tab-keys.js +63 -0
- package/dist/mixins/theme-toggle.d.ts +82 -0
- package/dist/mixins/theme-toggle.js +158 -0
- package/dist/mixins/track-host-node.d.ts +34 -0
- package/dist/mixins/track-host-node.js +42 -0
- package/dist/mixins/treeKeys.d.ts +57 -0
- package/dist/mixins/treeKeys.js +266 -0
- package/dist/mixins/validate.d.ts +65 -0
- package/dist/mixins/validate.js +139 -0
- package/dist/mixins/view-transition.d.ts +56 -0
- package/dist/mixins/view-transition.js +111 -0
- package/dist/styles/chart-palette.d.ts +34 -0
- package/dist/styles/chart-palette.js +27 -0
- package/dist/styles/field-stack-layout.d.ts +27 -0
- package/dist/styles/field-stack-layout.js +16 -0
- package/dist/styles/floating-surface.d.ts +32 -0
- package/dist/styles/floating-surface.js +30 -0
- package/dist/styles/graphic-host.d.ts +25 -0
- package/dist/styles/graphic-host.js +18 -0
- package/dist/styles/index.d.ts +20 -0
- package/dist/styles/index.js +20 -0
- package/dist/styles/interactive-transition.d.ts +32 -0
- package/dist/styles/interactive-transition.js +32 -0
- package/dist/styles/legend-toggle.d.ts +29 -0
- package/dist/styles/legend-toggle.js +24 -0
- package/dist/styles/output-caption-text.d.ts +22 -0
- package/dist/styles/output-caption-text.js +15 -0
- package/dist/styles/panel-chrome.d.ts +34 -0
- package/dist/styles/panel-chrome.js +26 -0
- package/dist/styles/range-thumb-appearance.d.ts +36 -0
- package/dist/styles/range-thumb-appearance.js +76 -0
- package/dist/styles/rtl-aware-gradient-direction.d.ts +28 -0
- package/dist/styles/rtl-aware-gradient-direction.js +28 -0
- package/dist/styles/semantic-color-panel.d.ts +35 -0
- package/dist/styles/semantic-color-panel.js +41 -0
- package/dist/utils/chart-marker-indices.d.ts +22 -0
- package/dist/utils/chart-marker-indices.js +45 -0
- package/dist/utils/chart-path.d.ts +86 -0
- package/dist/utils/chart-path.js +122 -0
- package/dist/utils/chart-scale.d.ts +182 -0
- package/dist/utils/chart-scale.js +221 -0
- package/dist/utils/color-math.d.ts +252 -0
- package/dist/utils/color-math.js +480 -0
- package/dist/utils/command-event.d.ts +24 -0
- package/dist/utils/command-event.js +26 -0
- package/dist/utils/css-styles.d.ts +21 -0
- package/dist/utils/css-styles.js +11 -0
- package/dist/utils/decorative-icon.d.ts +15 -0
- package/dist/utils/decorative-icon.js +15 -0
- package/dist/utils/disabled-selector.d.ts +22 -0
- package/dist/utils/disabled-selector.js +22 -0
- package/dist/utils/dispatch-change.d.ts +17 -0
- package/dist/utils/dispatch-change.js +19 -0
- package/dist/utils/field-parts.d.ts +26 -0
- package/dist/utils/field-parts.js +12 -0
- package/dist/utils/full-turn-radians.d.ts +16 -0
- package/dist/utils/full-turn-radians.js +16 -0
- package/dist/utils/geometry.d.ts +14 -0
- package/dist/utils/geometry.js +9 -0
- package/dist/utils/has-accessible-text.d.ts +19 -0
- package/dist/utils/has-accessible-text.js +30 -0
- package/dist/utils/hue-spectrum.d.ts +19 -0
- package/dist/utils/hue-spectrum.js +19 -0
- package/dist/utils/index.d.ts +35 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/is-new-primary-press.d.ts +29 -0
- package/dist/utils/is-new-primary-press.js +31 -0
- package/dist/utils/keyboard-nav.d.ts +64 -0
- package/dist/utils/keyboard-nav.js +79 -0
- package/dist/utils/merge-style.d.ts +33 -0
- package/dist/utils/merge-style.js +30 -0
- package/dist/utils/paired-range-inputs.d.ts +26 -0
- package/dist/utils/paired-range-inputs.js +29 -0
- package/dist/utils/placement.d.ts +18 -0
- package/dist/utils/placement.js +12 -0
- package/dist/utils/prefers-reduced-motion.d.ts +17 -0
- package/dist/utils/prefers-reduced-motion.js +19 -0
- package/dist/utils/resolve-field-wiring.d.ts +83 -0
- package/dist/utils/resolve-field-wiring.js +53 -0
- package/dist/utils/resolve-fill-percent.d.ts +28 -0
- package/dist/utils/resolve-fill-percent.js +34 -0
- package/dist/utils/round-precision.d.ts +22 -0
- package/dist/utils/round-precision.js +25 -0
- package/dist/utils/semantic-color-panel.d.ts +35 -0
- package/dist/utils/semantic-color-panel.js +28 -0
- package/dist/utils/semantic-color.d.ts +17 -0
- package/dist/utils/semantic-color.js +11 -0
- package/dist/utils/warn-if-no-accessible-name.d.ts +52 -0
- package/dist/utils/warn-if-no-accessible-name.js +55 -0
- package/dist/utils/write-cookie.d.ts +35 -0
- package/dist/utils/write-cookie.js +37 -0
- package/package.json +32 -0
- package/src/reset.css +223 -0
- package/src/theme.css +146 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An inline text link for site navigation, colored through a semantic color
|
|
3
|
+
* role and underlined to read as a link among surrounding prose. Its
|
|
4
|
+
* current-page state comes straight from `aria-current` set on the host
|
|
5
|
+
* server-side, rendering the emphasized, non-underlined treatment directly
|
|
6
|
+
* from that attribute.
|
|
7
|
+
*
|
|
8
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
9
|
+
* @copyright Sergio Xalambrí 2026
|
|
10
|
+
*/
|
|
11
|
+
import type { Handle, Props as TagProps } from "remix/ui";
|
|
12
|
+
import type { SemanticColor } from "../utils/semantic-color.js";
|
|
13
|
+
/**
|
|
14
|
+
* Prop types for {@link NavLink}.
|
|
15
|
+
*/
|
|
16
|
+
export declare namespace NavLink {
|
|
17
|
+
/**
|
|
18
|
+
* Semantic color role, each mapped to its matching `--ui-*` variables.
|
|
19
|
+
*/
|
|
20
|
+
type Color = SemanticColor;
|
|
21
|
+
/**
|
|
22
|
+
* Props accepted by {@link NavLink}, built as an intersection: the
|
|
23
|
+
* underlying anchor prop type is a union keyed on `href`, since the
|
|
24
|
+
* accessible-anchor contract restricts `role` once `href` is present.
|
|
25
|
+
*/
|
|
26
|
+
type Props = TagProps<"a"> & {
|
|
27
|
+
/** Destination the link navigates to. */
|
|
28
|
+
href: string;
|
|
29
|
+
/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */
|
|
30
|
+
color?: Color;
|
|
31
|
+
/**
|
|
32
|
+
* Marks the link as sitting over its own colored background: drops the
|
|
33
|
+
* underline entirely, since the background fill already sets it apart
|
|
34
|
+
* from surrounding text.
|
|
35
|
+
*/
|
|
36
|
+
hasBackground?: boolean;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Renders a native `<a>`, colored via `data-color` and underlined with a
|
|
41
|
+
* translucent decoration that solidifies on hover. Setting `aria-current`
|
|
42
|
+
* server-side renders the current-page treatment; the focus-visible ring always reads in the primary color.
|
|
43
|
+
*
|
|
44
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
45
|
+
* @returns The render function producing the link's markup.
|
|
46
|
+
* @example
|
|
47
|
+
* <NavLink href="/dashboard" color="brand">{t("nav.dashboard")}</NavLink>
|
|
48
|
+
* @example
|
|
49
|
+
* <NavLink href="/settings" aria-current={pathname === "/settings" ? "page" : undefined}>{t("nav.settings")}</NavLink>
|
|
50
|
+
* @example
|
|
51
|
+
* <NavLink href="/settings" hasBackground mix={css({ paddingInline: "0.75rem", paddingBlock: "0.5rem" })}>{t("nav.settings")}</NavLink>
|
|
52
|
+
*/
|
|
53
|
+
export declare function NavLink(handle: Handle<NavLink.Props>): () => import("remix/ui").RemixElement;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { colorMix, fg, outline } from "@sdxc/u/color";
|
|
3
|
+
import { rounded } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, raw } from "@sdxc/u/general";
|
|
5
|
+
import { data, hover, when } from "@sdxc/u/state";
|
|
6
|
+
import { textDecoration, weight } from "@sdxc/u/typography";
|
|
7
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
8
|
+
/** Semantic color role {@link NavLink} falls back to when `color` is omitted. */
|
|
9
|
+
const DEFAULT_COLOR = "neutral";
|
|
10
|
+
/**
|
|
11
|
+
* Renders a native `<a>`, colored via `data-color` and underlined with a
|
|
12
|
+
* translucent decoration that solidifies on hover. Setting `aria-current`
|
|
13
|
+
* server-side renders the current-page treatment; the focus-visible ring always reads in the primary color.
|
|
14
|
+
*
|
|
15
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
16
|
+
* @returns The render function producing the link's markup.
|
|
17
|
+
* @example
|
|
18
|
+
* <NavLink href="/dashboard" color="brand">{t("nav.dashboard")}</NavLink>
|
|
19
|
+
* @example
|
|
20
|
+
* <NavLink href="/settings" aria-current={pathname === "/settings" ? "page" : undefined}>{t("nav.settings")}</NavLink>
|
|
21
|
+
* @example
|
|
22
|
+
* <NavLink href="/settings" hasBackground mix={css({ paddingInline: "0.75rem", paddingBlock: "0.5rem" })}>{t("nav.settings")}</NavLink>
|
|
23
|
+
*/
|
|
24
|
+
export function NavLink(handle) {
|
|
25
|
+
return () => {
|
|
26
|
+
let { color, hasBackground, mix, ...rest } = handle.props;
|
|
27
|
+
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
28
|
+
return (_jsx("a", { ...rest, "data-color": resolvedColor, "data-has-background": hasBackground || undefined, mix: [
|
|
29
|
+
interactiveTransition(),
|
|
30
|
+
rounded("sm"),
|
|
31
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
32
|
+
cursor("pointer"),
|
|
33
|
+
textDecoration("underline"),
|
|
34
|
+
raw({
|
|
35
|
+
textDecorationColor: colorMix("oklab", { color: "currentcolor", weight: 60 }, "transparent"),
|
|
36
|
+
textUnderlineOffset: "4px",
|
|
37
|
+
}),
|
|
38
|
+
hover(raw({ textDecorationColor: "currentcolor" })),
|
|
39
|
+
data("color", "brand", [
|
|
40
|
+
fg("brand"),
|
|
41
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
42
|
+
weight(500),
|
|
43
|
+
fg("brand.emphasis"),
|
|
44
|
+
]),
|
|
45
|
+
]),
|
|
46
|
+
data("color", "neutral", [
|
|
47
|
+
fg("neutral"),
|
|
48
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
49
|
+
weight(500),
|
|
50
|
+
fg("neutral.emphasis"),
|
|
51
|
+
]),
|
|
52
|
+
]),
|
|
53
|
+
data("color", "success", [
|
|
54
|
+
fg("success"),
|
|
55
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
56
|
+
weight(500),
|
|
57
|
+
fg("success.emphasis"),
|
|
58
|
+
]),
|
|
59
|
+
]),
|
|
60
|
+
data("color", "warning", [
|
|
61
|
+
fg("warning"),
|
|
62
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
63
|
+
weight(500),
|
|
64
|
+
fg("warning.emphasis"),
|
|
65
|
+
]),
|
|
66
|
+
]),
|
|
67
|
+
data("color", "danger", [
|
|
68
|
+
fg("danger"),
|
|
69
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
70
|
+
weight(500),
|
|
71
|
+
fg("danger.emphasis"),
|
|
72
|
+
]),
|
|
73
|
+
]),
|
|
74
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
75
|
+
weight(500),
|
|
76
|
+
raw({ textDecorationThickness: "2px", textDecorationColor: "currentcolor" }),
|
|
77
|
+
]),
|
|
78
|
+
data("has-background", textDecoration("none")),
|
|
79
|
+
when('&[data-has-background]:hover, &[data-has-background][aria-current]:not([aria-current="false"])', textDecoration("none")),
|
|
80
|
+
mix,
|
|
81
|
+
] }));
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A row of top-level navigation triggers, each either a plain link or a
|
|
3
|
+
* button that opens a floating panel of related links. `NavigationMenu.Item`
|
|
4
|
+
* hands its own stable id to whichever `NavigationMenu.Trigger` and
|
|
5
|
+
* `NavigationMenu.Content` nest inside it through component context, so the
|
|
6
|
+
* two pair up automatically — a consumer never wires a `commandfor`/`id`
|
|
7
|
+
* pair by hand for the common case.
|
|
8
|
+
*
|
|
9
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
10
|
+
* @copyright Sergio Xalambrí 2026
|
|
11
|
+
*/
|
|
12
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/ui";
|
|
13
|
+
import { Popover } from "./popover.js";
|
|
14
|
+
/**
|
|
15
|
+
* Prop types for {@link NavigationMenu} and its compound parts.
|
|
16
|
+
*/
|
|
17
|
+
export declare namespace NavigationMenu {
|
|
18
|
+
/**
|
|
19
|
+
* Axis {@link NavigationMenu.List} lays its triggers out along: a single
|
|
20
|
+
* row, or a single column.
|
|
21
|
+
*/
|
|
22
|
+
type Orientation = "horizontal" | "vertical";
|
|
23
|
+
/**
|
|
24
|
+
* Panel width {@link NavigationMenu.Content} renders at: sized to its own
|
|
25
|
+
* content (`"default"`), or a fixed, generously wide measure that still
|
|
26
|
+
* clamps to the viewport on narrow screens (`"wide"`).
|
|
27
|
+
*/
|
|
28
|
+
type ContentSize = "default" | "wide";
|
|
29
|
+
/**
|
|
30
|
+
* Value {@link NavigationMenu.Item} stores in component context so the
|
|
31
|
+
* {@link NavigationMenu.Trigger} and {@link NavigationMenu.Content} nested
|
|
32
|
+
* inside it pair up automatically.
|
|
33
|
+
*/
|
|
34
|
+
interface Context {
|
|
35
|
+
/** Stable id the enclosing {@link NavigationMenu.Item} generated for its {@link NavigationMenu.Content}. */
|
|
36
|
+
contentId: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Every native `<nav>` attribute, plus the `mix` passthrough.
|
|
40
|
+
*/
|
|
41
|
+
interface Props extends TagProps<"nav"> {
|
|
42
|
+
/** The menu's own {@link NavigationMenu.List}, and anything else rendered alongside it (a {@link NavigationMenu.Viewport}, for instance). */
|
|
43
|
+
children?: RemixNode;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Every native `<ul>` attribute, plus the `mix` passthrough.
|
|
47
|
+
*/
|
|
48
|
+
interface ListProps extends TagProps<"ul"> {
|
|
49
|
+
/** Layout axis. Defaults to {@link DEFAULT_ORIENTATION}. */
|
|
50
|
+
orientation?: Orientation;
|
|
51
|
+
/** One or more {@link NavigationMenu.Item}s. */
|
|
52
|
+
children?: RemixNode;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Every native `<li>` attribute, plus the `mix` passthrough.
|
|
56
|
+
*/
|
|
57
|
+
interface ItemProps extends TagProps<"li"> {
|
|
58
|
+
/**
|
|
59
|
+
* Either a standalone {@link NavigationMenu.Link}, or a
|
|
60
|
+
* {@link NavigationMenu.Trigger} followed by the
|
|
61
|
+
* {@link NavigationMenu.Content} it opens.
|
|
62
|
+
*/
|
|
63
|
+
children?: RemixNode;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Every native `<button>` attribute, plus the `mix` passthrough.
|
|
67
|
+
* `commandfor` and `command` both default from the enclosing
|
|
68
|
+
* {@link NavigationMenu.Item}'s context.
|
|
69
|
+
*/
|
|
70
|
+
interface TriggerProps extends TagProps<"button"> {
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Every prop {@link Popover.Props} accepts except `id`, which becomes
|
|
74
|
+
* optional here since it defaults from the enclosing
|
|
75
|
+
* {@link NavigationMenu.Item}'s context, plus `size`.
|
|
76
|
+
*/
|
|
77
|
+
interface ContentProps extends Omit<Popover.Props, "id" | "placement"> {
|
|
78
|
+
/** Stable id matched against a {@link NavigationMenu.Trigger}'s `commandfor`. Defaults to the enclosing {@link NavigationMenu.Item}'s generated id. */
|
|
79
|
+
id?: string;
|
|
80
|
+
/** Side of the trigger to render against. Defaults to {@link DEFAULT_CONTENT_PLACEMENT}. */
|
|
81
|
+
placement?: Popover.Placement;
|
|
82
|
+
/** Panel width. Defaults to {@link DEFAULT_CONTENT_SIZE}. */
|
|
83
|
+
size?: ContentSize;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Every native `<a>` attribute, plus the `mix` passthrough. Uses an
|
|
87
|
+
* intersection because the underlying anchor prop type is a union keyed on
|
|
88
|
+
* `href`, narrowed here to required since a link needs a destination.
|
|
89
|
+
*/
|
|
90
|
+
type LinkProps = TagProps<"a"> & {
|
|
91
|
+
/** Destination the link navigates to. */
|
|
92
|
+
href: string;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Every native `<div>` attribute, plus the `mix` passthrough.
|
|
96
|
+
*/
|
|
97
|
+
interface ViewportProps extends TagProps<"div"> {
|
|
98
|
+
/** The currently active item's content, mirrored in from wherever it actually renders. */
|
|
99
|
+
children?: RemixNode;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Every native `<div>` attribute, plus the `mix` passthrough.
|
|
103
|
+
*/
|
|
104
|
+
interface ContentListProps extends TagProps<"div"> {
|
|
105
|
+
/** One or more {@link NavigationMenu.Link}s. */
|
|
106
|
+
children?: RemixNode;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Every native `<div>` attribute, plus the `mix` passthrough.
|
|
110
|
+
*/
|
|
111
|
+
interface ContentGridProps extends TagProps<"div"> {
|
|
112
|
+
/** Two or more {@link NavigationMenu.ContentColumn}s. */
|
|
113
|
+
children?: RemixNode;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Every native `<div>` attribute, plus the `mix` passthrough.
|
|
117
|
+
*/
|
|
118
|
+
interface ContentColumnProps extends TagProps<"div"> {
|
|
119
|
+
/** One or more {@link NavigationMenu.Link}s. */
|
|
120
|
+
children?: RemixNode;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Renders the menu's root host: a native `<nav>` landmark establishing a
|
|
125
|
+
* positioning context for whatever floating panels its
|
|
126
|
+
* {@link NavigationMenu.Content} instances anchor against.
|
|
127
|
+
*
|
|
128
|
+
* @param handle Runtime handle carrying the host `<nav>`'s props.
|
|
129
|
+
* @returns The render function producing the menu's markup.
|
|
130
|
+
* @example
|
|
131
|
+
* <NavigationMenu aria-label={t("nav.primary")}>
|
|
132
|
+
* <NavigationMenu.List>
|
|
133
|
+
* <NavigationMenu.Item>
|
|
134
|
+
* <NavigationMenu.Link href="/">{t("nav.home")}</NavigationMenu.Link>
|
|
135
|
+
* </NavigationMenu.Item>
|
|
136
|
+
* </NavigationMenu.List>
|
|
137
|
+
* </NavigationMenu>
|
|
138
|
+
*/
|
|
139
|
+
export declare function NavigationMenu(handle: Handle<NavigationMenu.Props>): () => import("remix/ui").RemixElement;
|
|
140
|
+
export declare namespace NavigationMenu {
|
|
141
|
+
var List: (handle: Handle<NavigationMenu.ListProps>) => () => import("remix/ui").RemixElement;
|
|
142
|
+
var Item: (handle: Handle<NavigationMenu.ItemProps, NavigationMenu.Context>) => () => import("remix/ui").RemixElement;
|
|
143
|
+
var Trigger: (handle: Handle<NavigationMenu.TriggerProps>) => () => import("remix/ui").RemixElement;
|
|
144
|
+
var Content: (handle: Handle<NavigationMenu.ContentProps>) => () => import("remix/ui").RemixElement;
|
|
145
|
+
var Link: (handle: Handle<NavigationMenu.LinkProps>) => () => import("remix/ui").RemixElement;
|
|
146
|
+
var Viewport: (handle: Handle<NavigationMenu.ViewportProps>) => () => import("remix/ui").RemixElement;
|
|
147
|
+
var ContentList: (handle: Handle<NavigationMenu.ContentListProps>) => () => import("remix/ui").RemixElement;
|
|
148
|
+
var ContentGrid: (handle: Handle<NavigationMenu.ContentGridProps>) => () => import("remix/ui").RemixElement;
|
|
149
|
+
var ContentColumn: (handle: Handle<NavigationMenu.ContentColumnProps>) => () => import("remix/ui").RemixElement;
|
|
150
|
+
}
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { jsx as _jsx } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { bg, fg, outline, outlineStyle } from "@sdxc/u/color";
|
|
3
|
+
import { opacity, rounded, transition, transitionBehavior, transitionProperty, } from "@sdxc/u/effects";
|
|
4
|
+
import { cursor, userSelect } from "@sdxc/u/general";
|
|
5
|
+
import { container, flex, flexCol, gap, grid, gridTemplate, inlineFlex, items, justify, relative, } from "@sdxc/u/layout";
|
|
6
|
+
import { overflow } from "@sdxc/u/overflow";
|
|
7
|
+
import { at, media, startingStyle } from "@sdxc/u/responsive";
|
|
8
|
+
import { bs, is, maxIs, mbs, minIs, p, pb, pi } from "@sdxc/u/size";
|
|
9
|
+
import { z } from "@sdxc/u/stacking";
|
|
10
|
+
import { data, disabled, hover, when } from "@sdxc/u/state";
|
|
11
|
+
import { scaleProperty } from "@sdxc/u/transform";
|
|
12
|
+
import { fontSize, leading, text, textDecoration, weight } from "@sdxc/u/typography";
|
|
13
|
+
import { attrs } from "remix/ui";
|
|
14
|
+
import { durations, easings } from "../animations/tokens.js";
|
|
15
|
+
import { floatingSurface } from "../styles/floating-surface.js";
|
|
16
|
+
import { interactiveTransition } from "../styles/interactive-transition.js";
|
|
17
|
+
import { Popover } from "./popover.js";
|
|
18
|
+
/**
|
|
19
|
+
* Named container {@link NavigationMenu.Content} declares on its own host, so
|
|
20
|
+
* {@link NavigationMenu.ContentGrid} can adapt to the panel's own width
|
|
21
|
+
* instead of the page's.
|
|
22
|
+
*/
|
|
23
|
+
const CONTAINER_NAME = "ui-navigation-menu-content";
|
|
24
|
+
/**
|
|
25
|
+
* `role="list"` applied to {@link NavigationMenu.List} through {@link attrs}
|
|
26
|
+
* unless a consumer supplies its own `role`, restoring list semantics that a
|
|
27
|
+
* stylesheet clearing `list-style` otherwise drops for assistive technology.
|
|
28
|
+
*/
|
|
29
|
+
const DEFAULT_LIST_ROLE = "list";
|
|
30
|
+
/**
|
|
31
|
+
* Default {@link NavigationMenu.ListProps} orientation, applied when
|
|
32
|
+
* `orientation` is omitted, laying triggers out in a single row.
|
|
33
|
+
*/
|
|
34
|
+
const DEFAULT_ORIENTATION = "horizontal";
|
|
35
|
+
/**
|
|
36
|
+
* `type` {@link NavigationMenu.TriggerProps.type} falls back to when a
|
|
37
|
+
* consumer doesn't supply one, keeping a click on the trigger from
|
|
38
|
+
* submitting a surrounding `<form>`.
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_TRIGGER_TYPE = "button";
|
|
41
|
+
/**
|
|
42
|
+
* Invoker Commands verb {@link NavigationMenu.TriggerProps.command} falls
|
|
43
|
+
* back to when omitted, showing the paired {@link NavigationMenu.Content} if
|
|
44
|
+
* it's hidden and hiding it again if it's already showing.
|
|
45
|
+
*/
|
|
46
|
+
const DEFAULT_TRIGGER_COMMAND = "toggle-popover";
|
|
47
|
+
/**
|
|
48
|
+
* Side of the trigger {@link NavigationMenu.Content} renders against when
|
|
49
|
+
* `placement` is left unset, matching a dropdown reading down and start-ward
|
|
50
|
+
* from its trigger.
|
|
51
|
+
*/
|
|
52
|
+
const DEFAULT_CONTENT_PLACEMENT = "bottom-start";
|
|
53
|
+
/**
|
|
54
|
+
* {@link NavigationMenu.ContentProps.size} falls back to when omitted,
|
|
55
|
+
* sizing the panel to its own content instead of a fixed wide measure.
|
|
56
|
+
*/
|
|
57
|
+
const DEFAULT_CONTENT_SIZE = "default";
|
|
58
|
+
/**
|
|
59
|
+
* Renders the menu's root host: a native `<nav>` landmark establishing a
|
|
60
|
+
* positioning context for whatever floating panels its
|
|
61
|
+
* {@link NavigationMenu.Content} instances anchor against.
|
|
62
|
+
*
|
|
63
|
+
* @param handle Runtime handle carrying the host `<nav>`'s props.
|
|
64
|
+
* @returns The render function producing the menu's markup.
|
|
65
|
+
* @example
|
|
66
|
+
* <NavigationMenu aria-label={t("nav.primary")}>
|
|
67
|
+
* <NavigationMenu.List>
|
|
68
|
+
* <NavigationMenu.Item>
|
|
69
|
+
* <NavigationMenu.Link href="/">{t("nav.home")}</NavigationMenu.Link>
|
|
70
|
+
* </NavigationMenu.Item>
|
|
71
|
+
* </NavigationMenu.List>
|
|
72
|
+
* </NavigationMenu>
|
|
73
|
+
*/
|
|
74
|
+
export function NavigationMenu(handle) {
|
|
75
|
+
return () => {
|
|
76
|
+
let { mix, ...rest } = handle.props;
|
|
77
|
+
return _jsx("nav", { ...rest, mix: [relative(), mix] });
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Renders the row of top-level triggers: a native `<ul>` laying its
|
|
82
|
+
* {@link NavigationMenu.Item}s out horizontally by default, switching to a
|
|
83
|
+
* single start-aligned column when `orientation` is `"vertical"`.
|
|
84
|
+
*
|
|
85
|
+
* @param handle Runtime handle carrying the host `<ul>`'s props.
|
|
86
|
+
* @returns The render function producing the row's markup.
|
|
87
|
+
* @example
|
|
88
|
+
* <NavigationMenu.List>
|
|
89
|
+
* <NavigationMenu.Item>
|
|
90
|
+
* <NavigationMenu.Link href="/pricing">{t("nav.pricing")}</NavigationMenu.Link>
|
|
91
|
+
* </NavigationMenu.Item>
|
|
92
|
+
* </NavigationMenu.List>
|
|
93
|
+
* @example
|
|
94
|
+
* <NavigationMenu.List orientation="vertical">
|
|
95
|
+
* <NavigationMenu.Item>
|
|
96
|
+
* <NavigationMenu.Link href="/settings/profile">{t("nav.profile")}</NavigationMenu.Link>
|
|
97
|
+
* </NavigationMenu.Item>
|
|
98
|
+
* </NavigationMenu.List>
|
|
99
|
+
*/
|
|
100
|
+
NavigationMenu.List = function NavigationMenuList(handle) {
|
|
101
|
+
return () => {
|
|
102
|
+
let { orientation, mix, ...rest } = handle.props;
|
|
103
|
+
let resolvedOrientation = orientation ?? DEFAULT_ORIENTATION;
|
|
104
|
+
return (_jsx("ul", { "data-orientation": resolvedOrientation, ...rest, mix: [
|
|
105
|
+
attrs({ role: DEFAULT_LIST_ROLE }),
|
|
106
|
+
flex(),
|
|
107
|
+
items("center"),
|
|
108
|
+
gap(1),
|
|
109
|
+
when('&[data-orientation="vertical"]', [flexCol(), items("start")]),
|
|
110
|
+
mix,
|
|
111
|
+
] }));
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Renders a single top-level entry: a native `<li>` holding either a
|
|
116
|
+
* standalone {@link NavigationMenu.Link} or a {@link NavigationMenu.Trigger}
|
|
117
|
+
* paired with the {@link NavigationMenu.Content} it opens.
|
|
118
|
+
*
|
|
119
|
+
* @param handle Runtime handle carrying the host `<li>`'s props and providing {@link NavigationMenu.Context}.
|
|
120
|
+
* @returns The render function producing the item's markup.
|
|
121
|
+
* @example
|
|
122
|
+
* <NavigationMenu.Item>
|
|
123
|
+
* <NavigationMenu.Trigger>{t("nav.products")}</NavigationMenu.Trigger>
|
|
124
|
+
* <NavigationMenu.Content>
|
|
125
|
+
* <NavigationMenu.ContentList>
|
|
126
|
+
* <NavigationMenu.Link href="/products/one">{t("products.one")}</NavigationMenu.Link>
|
|
127
|
+
* <NavigationMenu.Link href="/products/two">{t("products.two")}</NavigationMenu.Link>
|
|
128
|
+
* </NavigationMenu.ContentList>
|
|
129
|
+
* </NavigationMenu.Content>
|
|
130
|
+
* </NavigationMenu.Item>
|
|
131
|
+
*/
|
|
132
|
+
NavigationMenu.Item = function NavigationMenuItem(handle) {
|
|
133
|
+
return () => {
|
|
134
|
+
let { mix, ...rest } = handle.props;
|
|
135
|
+
handle.context.set({ contentId: handle.id });
|
|
136
|
+
return _jsx("li", { ...rest, mix: [relative(), flex(), items("center"), mix] });
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Renders a native `<button>` that opens the enclosing
|
|
141
|
+
* {@link NavigationMenu.Item}'s {@link NavigationMenu.Content} through the
|
|
142
|
+
* Invoker Commands API, so `aria-expanded` reflects the panel automatically.
|
|
143
|
+
*
|
|
144
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
145
|
+
* @returns The render function producing the trigger's markup.
|
|
146
|
+
* @example
|
|
147
|
+
* <NavigationMenu.Trigger>{t("nav.products")}</NavigationMenu.Trigger>
|
|
148
|
+
* @example
|
|
149
|
+
* <NavigationMenu.Trigger aria-disabled="true">{t("nav.archived")}</NavigationMenu.Trigger>
|
|
150
|
+
*/
|
|
151
|
+
NavigationMenu.Trigger = function NavigationMenuTrigger(handle) {
|
|
152
|
+
return () => {
|
|
153
|
+
let { type, commandfor, command, mix, ...rest } = handle.props;
|
|
154
|
+
let context = handle.context.get(NavigationMenu.Item);
|
|
155
|
+
let resolvedType = type ?? DEFAULT_TRIGGER_TYPE;
|
|
156
|
+
let resolvedCommandfor = commandfor ?? context.contentId;
|
|
157
|
+
let resolvedCommand = command ?? DEFAULT_TRIGGER_COMMAND;
|
|
158
|
+
return (_jsx("button", { type: resolvedType, commandfor: resolvedCommandfor, command: resolvedCommand, ...rest, mix: [
|
|
159
|
+
interactiveTransition(),
|
|
160
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
161
|
+
inlineFlex(),
|
|
162
|
+
items("center"),
|
|
163
|
+
gap(2),
|
|
164
|
+
rounded("md"),
|
|
165
|
+
pi(3),
|
|
166
|
+
pb(2),
|
|
167
|
+
weight("medium"),
|
|
168
|
+
fg("neutral"),
|
|
169
|
+
disabled(opacity(50)),
|
|
170
|
+
hover([bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
171
|
+
when('&[aria-expanded="true"]', [bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
172
|
+
disabled(cursor("not-allowed")),
|
|
173
|
+
text("sm"),
|
|
174
|
+
mix,
|
|
175
|
+
] }));
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Renders {@link NavigationMenu.Content}, the floating panel a
|
|
180
|
+
* {@link NavigationMenu.Trigger} opens: a {@link Popover} that fades and
|
|
181
|
+
* scales itself using the platform's own `:popover-open` state.
|
|
182
|
+
*
|
|
183
|
+
* @param handle Runtime handle carrying the host's {@link Popover} props.
|
|
184
|
+
* @returns The render function producing the panel's markup.
|
|
185
|
+
* @example
|
|
186
|
+
* <NavigationMenu.Content>
|
|
187
|
+
* <NavigationMenu.ContentList>
|
|
188
|
+
* <NavigationMenu.Link href="/products/one">{t("products.one")}</NavigationMenu.Link>
|
|
189
|
+
* </NavigationMenu.ContentList>
|
|
190
|
+
* </NavigationMenu.Content>
|
|
191
|
+
* @example
|
|
192
|
+
* <NavigationMenu.Content size="wide">
|
|
193
|
+
* <NavigationMenu.ContentGrid>
|
|
194
|
+
* <NavigationMenu.ContentColumn>
|
|
195
|
+
* <NavigationMenu.Link href="/products/one">{t("products.one")}</NavigationMenu.Link>
|
|
196
|
+
* </NavigationMenu.ContentColumn>
|
|
197
|
+
* <NavigationMenu.ContentColumn>
|
|
198
|
+
* <NavigationMenu.Link href="/products/two">{t("products.two")}</NavigationMenu.Link>
|
|
199
|
+
* </NavigationMenu.ContentColumn>
|
|
200
|
+
* </NavigationMenu.ContentGrid>
|
|
201
|
+
* </NavigationMenu.Content>
|
|
202
|
+
*/
|
|
203
|
+
NavigationMenu.Content = function NavigationMenuContent(handle) {
|
|
204
|
+
return () => {
|
|
205
|
+
let { id, placement, size, mix, ...rest } = handle.props;
|
|
206
|
+
let context = handle.context.get(NavigationMenu.Item);
|
|
207
|
+
let resolvedId = id ?? context.contentId;
|
|
208
|
+
let resolvedPlacement = placement ?? DEFAULT_CONTENT_PLACEMENT;
|
|
209
|
+
let resolvedSize = size ?? DEFAULT_CONTENT_SIZE;
|
|
210
|
+
return (_jsx(Popover, { id: resolvedId, placement: resolvedPlacement, "data-size": resolvedSize, ...rest, mix: [
|
|
211
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
212
|
+
is("max-content"),
|
|
213
|
+
minIs("11rem"),
|
|
214
|
+
p(2),
|
|
215
|
+
z(50),
|
|
216
|
+
opacity(0),
|
|
217
|
+
when('& [data-slot="link"]', [is("full"), justify("start")]),
|
|
218
|
+
when('&[data-size="wide"]', [is("28rem"), maxIs("calc(100vw - 2rem)")]),
|
|
219
|
+
container(CONTAINER_NAME),
|
|
220
|
+
transition("opacity, scale, display, overlay", {
|
|
221
|
+
duration: durations.fast,
|
|
222
|
+
easing: easings.standard,
|
|
223
|
+
}),
|
|
224
|
+
outlineStyle("none"),
|
|
225
|
+
scaleProperty("0.95"),
|
|
226
|
+
transitionBehavior("allow-discrete"),
|
|
227
|
+
when("&:popover-open", [opacity(100), scaleProperty("none")]),
|
|
228
|
+
startingStyle(when("&:popover-open", [opacity(0), scaleProperty("0.95")])),
|
|
229
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
230
|
+
scaleProperty("none"),
|
|
231
|
+
transitionProperty("opacity, display, overlay"),
|
|
232
|
+
]),
|
|
233
|
+
mix,
|
|
234
|
+
] }));
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Renders {@link NavigationMenu.LinkProps.children} as a native `<a>`.
|
|
239
|
+
* `aria-current` marks the active page; `aria-disabled="true"` only mutes it
|
|
240
|
+
* visually, since a plain `<a>` has no native disabled state to block clicks.
|
|
241
|
+
*
|
|
242
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
243
|
+
* @returns The render function producing the link's markup.
|
|
244
|
+
* @example
|
|
245
|
+
* <NavigationMenu.Link href="/pricing">{t("nav.pricing")}</NavigationMenu.Link>
|
|
246
|
+
* @example
|
|
247
|
+
* <NavigationMenu.Link href="/dashboard" aria-current={pathname === "/dashboard" ? "page" : undefined}>
|
|
248
|
+
* {t("nav.dashboard")}
|
|
249
|
+
* </NavigationMenu.Link>
|
|
250
|
+
*/
|
|
251
|
+
NavigationMenu.Link = function NavigationMenuLink(handle) {
|
|
252
|
+
return () => {
|
|
253
|
+
let { mix, ...rest } = handle.props;
|
|
254
|
+
return (_jsx("a", { "data-slot": "link", ...rest, mix: [
|
|
255
|
+
interactiveTransition(),
|
|
256
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
257
|
+
inlineFlex(),
|
|
258
|
+
items("center"),
|
|
259
|
+
gap(2),
|
|
260
|
+
rounded("md"),
|
|
261
|
+
pi(3),
|
|
262
|
+
pb(2),
|
|
263
|
+
leading(1),
|
|
264
|
+
weight("medium"),
|
|
265
|
+
fg("neutral"),
|
|
266
|
+
hover([bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
267
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
268
|
+
bg("neutral.bg-tint-hover"),
|
|
269
|
+
fg("neutral.emphasis"),
|
|
270
|
+
]),
|
|
271
|
+
when('&[aria-disabled="true"]', [opacity(50), cursor("not-allowed")]),
|
|
272
|
+
userSelect(),
|
|
273
|
+
textDecoration("none"),
|
|
274
|
+
fontSize("sm"),
|
|
275
|
+
mix,
|
|
276
|
+
] }));
|
|
277
|
+
};
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Renders a shared, animated surface that swaps in the active
|
|
281
|
+
* {@link NavigationMenu.Item}'s content, sized by the custom properties a
|
|
282
|
+
* pairing mixin writes as it measures the active panel and toggles visibility.
|
|
283
|
+
*
|
|
284
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
285
|
+
* @returns The render function producing the shared frame's markup.
|
|
286
|
+
* @example
|
|
287
|
+
* <NavigationMenu.Viewport data-visible={isMenuOpen || undefined} />
|
|
288
|
+
*/
|
|
289
|
+
NavigationMenu.Viewport = function NavigationMenuViewport(handle) {
|
|
290
|
+
return () => {
|
|
291
|
+
let { mix, ...rest } = handle.props;
|
|
292
|
+
return (_jsx("div", { ...rest, mix: [
|
|
293
|
+
floatingSurface(),
|
|
294
|
+
relative(),
|
|
295
|
+
mbs(2),
|
|
296
|
+
overflow(),
|
|
297
|
+
is("var(--ui-navigation-menu-viewport-inline-size, auto)"),
|
|
298
|
+
bs("var(--ui-navigation-menu-viewport-block-size, auto)"),
|
|
299
|
+
opacity(0),
|
|
300
|
+
transition("inline-size, block-size, opacity, scale", {
|
|
301
|
+
duration: durations.normal,
|
|
302
|
+
easing: easings.decelerate,
|
|
303
|
+
}),
|
|
304
|
+
scaleProperty("0.95"),
|
|
305
|
+
data("visible", [opacity(100), scaleProperty("none")]),
|
|
306
|
+
startingStyle(data("visible", [opacity(0), scaleProperty("0.95")])),
|
|
307
|
+
media("(prefers-reduced-motion: reduce)", [
|
|
308
|
+
scaleProperty("none"),
|
|
309
|
+
transitionProperty("inline-size, block-size, opacity"),
|
|
310
|
+
]),
|
|
311
|
+
mix,
|
|
312
|
+
] }));
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* Renders {@link NavigationMenu.ContentListProps.children} as a plain
|
|
317
|
+
* vertical run of {@link NavigationMenu.Link}s inside
|
|
318
|
+
* {@link NavigationMenu.Content}, for a dropdown that's just a short list.
|
|
319
|
+
*
|
|
320
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
321
|
+
* @returns The render function producing the list's markup.
|
|
322
|
+
* @example
|
|
323
|
+
* <NavigationMenu.ContentList>
|
|
324
|
+
* <NavigationMenu.Link href="/products/one">{t("products.one")}</NavigationMenu.Link>
|
|
325
|
+
* <NavigationMenu.Link href="/products/two">{t("products.two")}</NavigationMenu.Link>
|
|
326
|
+
* </NavigationMenu.ContentList>
|
|
327
|
+
*/
|
|
328
|
+
NavigationMenu.ContentList = function NavigationMenuContentList(handle) {
|
|
329
|
+
return () => {
|
|
330
|
+
let { mix, ...rest } = handle.props;
|
|
331
|
+
return _jsx("div", { ...rest, mix: [grid(), gap(1), mix] });
|
|
332
|
+
};
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Renders {@link NavigationMenu.ContentGridProps.children} as a
|
|
336
|
+
* multi-column layout inside {@link NavigationMenu.Content}: a single column
|
|
337
|
+
* while the panel's own container is narrower than `40rem`, else two columns.
|
|
338
|
+
*
|
|
339
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
340
|
+
* @returns The render function producing the grid's markup.
|
|
341
|
+
* @example
|
|
342
|
+
* <NavigationMenu.Content size="wide">
|
|
343
|
+
* <NavigationMenu.ContentGrid>
|
|
344
|
+
* <NavigationMenu.ContentColumn>
|
|
345
|
+
* <NavigationMenu.Link href="/products/one">{t("products.one")}</NavigationMenu.Link>
|
|
346
|
+
* </NavigationMenu.ContentColumn>
|
|
347
|
+
* <NavigationMenu.ContentColumn>
|
|
348
|
+
* <NavigationMenu.Link href="/products/two">{t("products.two")}</NavigationMenu.Link>
|
|
349
|
+
* </NavigationMenu.ContentColumn>
|
|
350
|
+
* </NavigationMenu.ContentGrid>
|
|
351
|
+
* </NavigationMenu.Content>
|
|
352
|
+
*/
|
|
353
|
+
NavigationMenu.ContentGrid = function NavigationMenuContentGrid(handle) {
|
|
354
|
+
return () => {
|
|
355
|
+
let { mix, ...rest } = handle.props;
|
|
356
|
+
return (_jsx("div", { ...rest, mix: [
|
|
357
|
+
grid(),
|
|
358
|
+
gap(4),
|
|
359
|
+
at("40rem", CONTAINER_NAME, gridTemplate({ columns: "repeat(2, minmax(0, 1fr))" })),
|
|
360
|
+
mix,
|
|
361
|
+
] }));
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Renders {@link NavigationMenu.ContentColumnProps.children} as one column of
|
|
366
|
+
* stacked {@link NavigationMenu.Link}s inside a
|
|
367
|
+
* {@link NavigationMenu.ContentGrid}.
|
|
368
|
+
*
|
|
369
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
370
|
+
* @returns The render function producing the column's markup.
|
|
371
|
+
* @example
|
|
372
|
+
* <NavigationMenu.ContentColumn>
|
|
373
|
+
* <NavigationMenu.Link href="/products/one">{t("products.one")}</NavigationMenu.Link>
|
|
374
|
+
* </NavigationMenu.ContentColumn>
|
|
375
|
+
*/
|
|
376
|
+
NavigationMenu.ContentColumn = function NavigationMenuContentColumn(handle) {
|
|
377
|
+
return () => {
|
|
378
|
+
let { mix, ...rest } = handle.props;
|
|
379
|
+
return _jsx("div", { ...rest, mix: [grid(), gap(1), mix] });
|
|
380
|
+
};
|
|
381
|
+
};
|