@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,1068 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/ui/jsx-runtime";
|
|
2
|
+
import { PanelLeftIcon } from "@sdxc/icons";
|
|
3
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
4
|
+
import { bg, border, borderEdge, colorMix, fg, outline, outlineStyle } from "@sdxc/u/color";
|
|
5
|
+
import { backdropBlur, backdropSaturate, opacity, rounded, shadow, transition, transitionBehavior, transitionDuration, transitionProperty, } from "@sdxc/u/effects";
|
|
6
|
+
import { cursor, pseudoContent, userSelect, willChange } from "@sdxc/u/general";
|
|
7
|
+
import { var as varUtility } from "@sdxc/u/general/var";
|
|
8
|
+
import { absolute, container, fixed, flex, flexCol, gap, grow, hidden, inlineFlex, insBe, insBs, insIe, insIs, insLeft, insRight, items, justify, relative, shrink, vstack, } from "@sdxc/u/layout";
|
|
9
|
+
import { overflow } from "@sdxc/u/overflow";
|
|
10
|
+
import { media, supports } from "@sdxc/u/responsive";
|
|
11
|
+
import { bs, is, m, maxBs, maxIs, mbe, mbs, minBs, minIs, mis, p, pb, pbe, pbs, pi, pis, safeAreaPadding, } from "@sdxc/u/size";
|
|
12
|
+
import { z } from "@sdxc/u/stacking";
|
|
13
|
+
import { after, data, focusVisible, hover, when } from "@sdxc/u/state";
|
|
14
|
+
import { scaleProperty, translateProperty, translateX } from "@sdxc/u/transform";
|
|
15
|
+
import { fontSize, tabularNums, textAlign, textDecoration, textTransform, tracking, truncate, weight, } from "@sdxc/u/typography";
|
|
16
|
+
import { attrs } from "remix/ui";
|
|
17
|
+
import { durations, easings } from "../animations/tokens.js";
|
|
18
|
+
import { warnIfNoAccessibleName } from "../utils/warn-if-no-accessible-name.js";
|
|
19
|
+
import { Dialog } from "./dialog.js";
|
|
20
|
+
import { ScrollArea } from "./scroll-area.js";
|
|
21
|
+
import { Separator } from "./separator.js";
|
|
22
|
+
/** Visual treatment {@link Sidebar} falls back to when `variant` is omitted. */
|
|
23
|
+
const DEFAULT_VARIANT = "sidebar";
|
|
24
|
+
/** Collapse behavior {@link Sidebar} falls back to when `collapsible` is omitted. */
|
|
25
|
+
const DEFAULT_COLLAPSIBLE = "offcanvas";
|
|
26
|
+
/**
|
|
27
|
+
* Physical edge {@link Sidebar} docks against, and the edge
|
|
28
|
+
* {@link Sidebar.MobileNav} slides in from, when `side` is omitted.
|
|
29
|
+
*/
|
|
30
|
+
const DEFAULT_SIDE = "left";
|
|
31
|
+
/** Semantic color role {@link Sidebar.Item} falls back to when `color` is omitted. */
|
|
32
|
+
const DEFAULT_ITEM_COLOR = "neutral";
|
|
33
|
+
/** Size variant {@link Sidebar.MenuButton} and {@link Sidebar.MenuLink} fall back to when `size` is omitted. */
|
|
34
|
+
const DEFAULT_MENU_BUTTON_SIZE = "md";
|
|
35
|
+
/** Whether {@link Sidebar.MenuAction} stays hidden until its row is hovered or focused, when `showOnHover` is omitted. */
|
|
36
|
+
const DEFAULT_SHOW_ON_HOVER = true;
|
|
37
|
+
/** Whether {@link Sidebar.MenuSkeleton} renders a leading icon placeholder, when `showIcon` is omitted. */
|
|
38
|
+
const DEFAULT_SHOW_ICON = false;
|
|
39
|
+
/**
|
|
40
|
+
* Named container {@link Sidebar.Provider} declares on its own host, so
|
|
41
|
+
* {@link Sidebar} and {@link Sidebar.Rail} can query the shell's overall
|
|
42
|
+
* width for room to show a persistent rail, regardless of nesting depth.
|
|
43
|
+
*/
|
|
44
|
+
const PROVIDER_CONTAINER_NAME = "ui-sidebar-provider";
|
|
45
|
+
/**
|
|
46
|
+
* Named container {@link Sidebar.Inset} declares on its own host, so content
|
|
47
|
+
* rendered inside it — a Card, a Table, anything sized by its surroundings —
|
|
48
|
+
* responds to the inset's own available width as the rail expands or collapses.
|
|
49
|
+
*/
|
|
50
|
+
const INSET_CONTAINER_NAME = "ui-sidebar-inset";
|
|
51
|
+
/**
|
|
52
|
+
* Container query matching a shell wide enough to host the persistent rail
|
|
53
|
+
* alongside its inset; below this width, {@link Sidebar}'s `"icon"` and
|
|
54
|
+
* `"offcanvas"` collapse modes step aside for {@link Sidebar.MobileNav}.
|
|
55
|
+
*/
|
|
56
|
+
const WIDE_SHELL_QUERY = `@container ${PROVIDER_CONTAINER_NAME} (min-width: 48rem)`;
|
|
57
|
+
/**
|
|
58
|
+
* Selector matching {@link Sidebar.Trigger}'s own checkbox input once it
|
|
59
|
+
* carries the platform's native `:checked` state — the single source of
|
|
60
|
+
* truth every collapse-driven rule in {@link Sidebar.Provider} reads from.
|
|
61
|
+
*/
|
|
62
|
+
const TOGGLE_CHECKED_SELECTOR = '[data-slot="toggle"]:checked';
|
|
63
|
+
/**
|
|
64
|
+
* Resolves the `aria-current` value an anchor-based nav part renders with:
|
|
65
|
+
* an explicit `aria-current` always wins, and a `current`/`active`
|
|
66
|
+
* shorthand of `true` falls back to `"page"` when nothing else was given.
|
|
67
|
+
*/
|
|
68
|
+
function resolveAriaCurrent(current, ariaCurrent) {
|
|
69
|
+
return ariaCurrent ?? (current ? "page" : undefined);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Renders the rail itself: a native `<aside>` sized and styled through its
|
|
73
|
+
* `data-variant`, `data-collapsible`, and `data-side` attributes, with
|
|
74
|
+
* every collapse rule keyed off {@link Sidebar.Provider}'s `:has()` state.
|
|
75
|
+
*
|
|
76
|
+
* @param handle Runtime handle carrying the host `<aside>`'s props.
|
|
77
|
+
* @returns The render function producing the rail's markup.
|
|
78
|
+
* @example
|
|
79
|
+
* <Sidebar.Provider>
|
|
80
|
+
* <Sidebar variant="floating" collapsible="icon" side="right">
|
|
81
|
+
* <Sidebar.Header>{logo}</Sidebar.Header>
|
|
82
|
+
* <Sidebar.Content>{nav}</Sidebar.Content>
|
|
83
|
+
* </Sidebar>
|
|
84
|
+
* <Sidebar.Inset>{children}</Sidebar.Inset>
|
|
85
|
+
* </Sidebar.Provider>
|
|
86
|
+
*/
|
|
87
|
+
export function Sidebar(handle) {
|
|
88
|
+
return () => {
|
|
89
|
+
let { variant, collapsible, side, mix, ...rest } = handle.props;
|
|
90
|
+
let resolvedVariant = variant ?? DEFAULT_VARIANT;
|
|
91
|
+
let resolvedCollapsible = collapsible ?? DEFAULT_COLLAPSIBLE;
|
|
92
|
+
let resolvedSide = side ?? DEFAULT_SIDE;
|
|
93
|
+
return (_jsx("aside", { ...rest, "data-slot": "sidebar", "data-variant": resolvedVariant, "data-collapsible": resolvedCollapsible, "data-side": resolvedSide, mix: [
|
|
94
|
+
relative(),
|
|
95
|
+
flex(),
|
|
96
|
+
flexCol(),
|
|
97
|
+
shrink(),
|
|
98
|
+
bs("full"),
|
|
99
|
+
is(varUtility("sidebar-width", "16rem")),
|
|
100
|
+
willChange("transform"),
|
|
101
|
+
data("side", "left", [
|
|
102
|
+
borderEdge("right", { width: 1, style: "solid", color: "neutral" }),
|
|
103
|
+
safeAreaPadding("left"),
|
|
104
|
+
]),
|
|
105
|
+
data("side", "right", [
|
|
106
|
+
borderEdge("left", { width: 1, style: "solid", color: "neutral" }),
|
|
107
|
+
safeAreaPadding("right"),
|
|
108
|
+
]),
|
|
109
|
+
data("variant", "floating", [
|
|
110
|
+
m("0.5rem"),
|
|
111
|
+
shadow("lg"),
|
|
112
|
+
supports("(backdrop-filter: blur(0))", media("(prefers-reduced-transparency: no-preference)", [
|
|
113
|
+
border(colorMix("oklab", { color: "var(--ui-neutral-border)", weight: 80 }, "transparent")),
|
|
114
|
+
bg(colorMix("oklab", { color: "var(--ui-neutral-bg-tint)", weight: 95 }, "transparent")),
|
|
115
|
+
backdropBlur("md"),
|
|
116
|
+
backdropSaturate(1.4),
|
|
117
|
+
])),
|
|
118
|
+
]),
|
|
119
|
+
data("variant", "inset", shadow("base")),
|
|
120
|
+
when(`@container ${PROVIDER_CONTAINER_NAME} (max-width: 47.9375rem)`, when('&[data-collapsible="icon"], &[data-collapsible="offcanvas"]', hidden())),
|
|
121
|
+
media("(prefers-reduced-motion: reduce)", transitionProperty("none")),
|
|
122
|
+
bg("neutral.tint"),
|
|
123
|
+
fg("neutral.emphasis"),
|
|
124
|
+
transition("inline-size, transform", {
|
|
125
|
+
duration: durations.normal,
|
|
126
|
+
easing: easings.standard,
|
|
127
|
+
}),
|
|
128
|
+
data("variant", "floating", [rounded("xl"), border({ color: "neutral", width: 1 })]),
|
|
129
|
+
data("variant", "inset", [rounded("xl"), border({ color: "neutral", width: 1 })]),
|
|
130
|
+
mix,
|
|
131
|
+
] }));
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Renders the shell's layout root: a flex row placing {@link Sidebar} beside
|
|
136
|
+
* {@link Sidebar.Inset}, hosting every collapse rule keyed purely off
|
|
137
|
+
* {@link Sidebar.Trigger}'s checkbox reaching `:checked` in this subtree.
|
|
138
|
+
*
|
|
139
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
140
|
+
* @returns The render function producing the shell's markup.
|
|
141
|
+
* @example
|
|
142
|
+
* <Sidebar.Provider>
|
|
143
|
+
* <Sidebar collapsible="icon">
|
|
144
|
+
* <Sidebar.Header>
|
|
145
|
+
* <Sidebar.Trigger id="app-sidebar-toggle" aria-label={t("nav.toggleSidebar")} />
|
|
146
|
+
* </Sidebar.Header>
|
|
147
|
+
* <Sidebar.Content>
|
|
148
|
+
* <Sidebar.Menu>
|
|
149
|
+
* <Sidebar.MenuItem>
|
|
150
|
+
* <Sidebar.MenuLink href="/dashboard" active>
|
|
151
|
+
* <HomeIcon aria-hidden />
|
|
152
|
+
* <span data-sidebar-collapsed-hide>{t("nav.dashboard")}</span>
|
|
153
|
+
* </Sidebar.MenuLink>
|
|
154
|
+
* </Sidebar.MenuItem>
|
|
155
|
+
* </Sidebar.Menu>
|
|
156
|
+
* </Sidebar.Content>
|
|
157
|
+
* <Sidebar.Rail htmlFor="app-sidebar-toggle" />
|
|
158
|
+
* </Sidebar>
|
|
159
|
+
* <Sidebar.Inset>{children}</Sidebar.Inset>
|
|
160
|
+
* </Sidebar.Provider>
|
|
161
|
+
*/
|
|
162
|
+
Sidebar.Provider = function SidebarProvider(handle) {
|
|
163
|
+
return () => {
|
|
164
|
+
let { mix, ...rest } = handle.props;
|
|
165
|
+
return (_jsx("div", { ...rest, "data-slot": "provider", mix: [
|
|
166
|
+
flex(),
|
|
167
|
+
items("stretch"),
|
|
168
|
+
minBs("100dvh"),
|
|
169
|
+
is("full"),
|
|
170
|
+
when(`&:has(${TOGGLE_CHECKED_SELECTOR})`, [
|
|
171
|
+
when('[data-slot="sidebar"][data-collapsible="icon"]', [
|
|
172
|
+
is(varUtility("sidebar-width-icon", "3rem")),
|
|
173
|
+
when("[data-sidebar-collapsed-hide]", visuallyHidden()),
|
|
174
|
+
when('[data-slot="group-label"]', visuallyHidden()),
|
|
175
|
+
when('[data-slot="menu-badge"]', hidden()),
|
|
176
|
+
when('[data-slot="menu-sub"]', hidden()),
|
|
177
|
+
when('[data-slot="menu-button"], [data-slot="menu-link"]', [
|
|
178
|
+
justify("center"),
|
|
179
|
+
pi("0"),
|
|
180
|
+
]),
|
|
181
|
+
]),
|
|
182
|
+
when('[data-slot="sidebar"][data-collapsible="offcanvas"][data-side="left"]', [
|
|
183
|
+
translateX("-100%"),
|
|
184
|
+
is("0"),
|
|
185
|
+
overflow("hidden"),
|
|
186
|
+
border({ width: "0", noStyleDefault: true }),
|
|
187
|
+
]),
|
|
188
|
+
when('[data-slot="sidebar"][data-collapsible="offcanvas"][data-side="right"]', [
|
|
189
|
+
translateX("100%"),
|
|
190
|
+
is("0"),
|
|
191
|
+
overflow("hidden"),
|
|
192
|
+
border({ width: "0", noStyleDefault: true }),
|
|
193
|
+
]),
|
|
194
|
+
]),
|
|
195
|
+
container(PROVIDER_CONTAINER_NAME),
|
|
196
|
+
mix,
|
|
197
|
+
] }));
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* Renders the docked, edge-to-edge mobile substitute for {@link Sidebar}:
|
|
202
|
+
* {@link Sidebar}'s nav content re-composed inside {@link Dialog}, docked
|
|
203
|
+
* to `side` and opened via Invoker Commands, not a viewport check.
|
|
204
|
+
*
|
|
205
|
+
* @param handle Runtime handle carrying the host `<dialog>`'s props, plus `side`.
|
|
206
|
+
* @returns The render function producing the drawer's markup.
|
|
207
|
+
* @example
|
|
208
|
+
* <button commandfor="mobile-nav" command="show-modal" aria-label={t("nav.openMenu")}>
|
|
209
|
+
* <MenuIcon aria-hidden />
|
|
210
|
+
* </button>
|
|
211
|
+
* <Sidebar.MobileNav id="mobile-nav" aria-label={t("nav.mainNavigation")}>
|
|
212
|
+
* <Sidebar.Header>{logo}</Sidebar.Header>
|
|
213
|
+
* <Sidebar.Content>{nav}</Sidebar.Content>
|
|
214
|
+
* </Sidebar.MobileNav>
|
|
215
|
+
*/
|
|
216
|
+
Sidebar.MobileNav = function SidebarMobileNav(handle) {
|
|
217
|
+
return () => {
|
|
218
|
+
let { side, mix, ...rest } = handle.props;
|
|
219
|
+
let resolvedSide = side ?? DEFAULT_SIDE;
|
|
220
|
+
return (_jsx(Dialog, { ...rest, "data-slot": "mobile-nav", "data-side": resolvedSide, mix: [
|
|
221
|
+
fixed(),
|
|
222
|
+
insBs("0"),
|
|
223
|
+
insBe("0"),
|
|
224
|
+
m("0"),
|
|
225
|
+
rounded("none"),
|
|
226
|
+
p("0"),
|
|
227
|
+
maxBs("none"),
|
|
228
|
+
bs("full"),
|
|
229
|
+
is(varUtility("sidebar-width-mobile", "18rem")),
|
|
230
|
+
maxIs("90vw"),
|
|
231
|
+
flex(),
|
|
232
|
+
flexCol(),
|
|
233
|
+
overflow("hidden"),
|
|
234
|
+
willChange("transform"),
|
|
235
|
+
transitionBehavior("allow-discrete"),
|
|
236
|
+
data("side", "left", [insLeft("0"), safeAreaPadding("left"), translateX("-100%")]),
|
|
237
|
+
when('&[data-side="left"][open]', translateX("0")),
|
|
238
|
+
data("side", "right", [insRight("0"), safeAreaPadding("right"), translateX("100%")]),
|
|
239
|
+
when('&[data-side="right"][open]', translateX("0")),
|
|
240
|
+
when("@starting-style", [
|
|
241
|
+
when('&[data-side="left"][open]', translateX("-100%")),
|
|
242
|
+
when('&[data-side="right"][open]', translateX("100%")),
|
|
243
|
+
]),
|
|
244
|
+
media("(prefers-reduced-motion: reduce)", transitionProperty("none")),
|
|
245
|
+
pbs("env(safe-area-inset-top, 0px)"),
|
|
246
|
+
pbe("env(safe-area-inset-bottom, 0px)"),
|
|
247
|
+
transition("transform, display, overlay", {
|
|
248
|
+
duration: durations.slow,
|
|
249
|
+
easing: easings.decelerate,
|
|
250
|
+
}),
|
|
251
|
+
mix,
|
|
252
|
+
] }));
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Renders the rail's header slot: a `<header>` laying out its children in
|
|
257
|
+
* a centered row, block-sized to a fixed height with a divider border
|
|
258
|
+
* below it and safe-area padding on its block-start edge.
|
|
259
|
+
*
|
|
260
|
+
* @param handle Runtime handle carrying the host `<header>`'s props.
|
|
261
|
+
* @returns The render function producing the header slot's markup.
|
|
262
|
+
* @example
|
|
263
|
+
* <Sidebar.Header>
|
|
264
|
+
* <Sidebar.Trigger id="app-sidebar-toggle" aria-label={t("nav.toggleSidebar")} />
|
|
265
|
+
* </Sidebar.Header>
|
|
266
|
+
*/
|
|
267
|
+
Sidebar.Header = function SidebarHeader(handle) {
|
|
268
|
+
return () => {
|
|
269
|
+
let { mix, ...rest } = handle.props;
|
|
270
|
+
return (_jsx("header", { ...rest, "data-slot": "header", mix: [
|
|
271
|
+
flex(),
|
|
272
|
+
bs("4rem"),
|
|
273
|
+
shrink(),
|
|
274
|
+
items("center"),
|
|
275
|
+
borderEdge("block-end", {
|
|
276
|
+
width: 1,
|
|
277
|
+
style: "solid",
|
|
278
|
+
color: colorMix("oklab", { color: "var(--ui-neutral-border)", weight: 80 }, "transparent"),
|
|
279
|
+
}),
|
|
280
|
+
gap("0.5rem"),
|
|
281
|
+
pi("1rem"),
|
|
282
|
+
pbs("calc(0.5rem + env(safe-area-inset-top, 0px))"),
|
|
283
|
+
pbe("0.5rem"),
|
|
284
|
+
mix,
|
|
285
|
+
] }));
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Renders the rail's own scrollable nav region: {@link ScrollArea.Viewport}
|
|
290
|
+
* laid out as a padded, gap-separated column that scrolls independently of
|
|
291
|
+
* {@link Sidebar.Header} and {@link Sidebar.Footer} once it overflows.
|
|
292
|
+
*
|
|
293
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
294
|
+
* @returns The render function producing the content region's markup.
|
|
295
|
+
* @example
|
|
296
|
+
* <Sidebar.Content>
|
|
297
|
+
* <Sidebar.Group>
|
|
298
|
+
* <Sidebar.GroupLabel>{t("nav.workspace")}</Sidebar.GroupLabel>
|
|
299
|
+
* <Sidebar.Menu>...</Sidebar.Menu>
|
|
300
|
+
* </Sidebar.Group>
|
|
301
|
+
* </Sidebar.Content>
|
|
302
|
+
*/
|
|
303
|
+
Sidebar.Content = function SidebarContent(handle) {
|
|
304
|
+
return () => {
|
|
305
|
+
let { mix, ...rest } = handle.props;
|
|
306
|
+
return (_jsx(ScrollArea.Viewport, { ...rest, "data-slot": "content", mix: [
|
|
307
|
+
flex(),
|
|
308
|
+
flexCol(),
|
|
309
|
+
grow(),
|
|
310
|
+
minBs("0"),
|
|
311
|
+
bs("auto"),
|
|
312
|
+
gap("1rem"),
|
|
313
|
+
pi("0.75rem"),
|
|
314
|
+
pb("1rem"),
|
|
315
|
+
mix,
|
|
316
|
+
] }));
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Renders the rail's footer slot: a `<footer>` laying out its children in
|
|
321
|
+
* a centered row with a divider border above it and safe-area padding on
|
|
322
|
+
* its block-end edge.
|
|
323
|
+
*
|
|
324
|
+
* @param handle Runtime handle carrying the host `<footer>`'s props.
|
|
325
|
+
* @returns The render function producing the footer slot's markup.
|
|
326
|
+
* @example
|
|
327
|
+
* <Sidebar.Footer>
|
|
328
|
+
* <Sidebar.MenuButton>{t("nav.account")}</Sidebar.MenuButton>
|
|
329
|
+
* </Sidebar.Footer>
|
|
330
|
+
*/
|
|
331
|
+
Sidebar.Footer = function SidebarFooter(handle) {
|
|
332
|
+
return () => {
|
|
333
|
+
let { mix, ...rest } = handle.props;
|
|
334
|
+
return (_jsx("footer", { ...rest, "data-slot": "footer", mix: [
|
|
335
|
+
flex(),
|
|
336
|
+
shrink(),
|
|
337
|
+
items("center"),
|
|
338
|
+
borderEdge("block-start", {
|
|
339
|
+
width: 1,
|
|
340
|
+
style: "solid",
|
|
341
|
+
color: colorMix("oklab", { color: "var(--ui-neutral-border)", weight: 80 }, "transparent"),
|
|
342
|
+
}),
|
|
343
|
+
gap("0.5rem"),
|
|
344
|
+
pi("1rem"),
|
|
345
|
+
pbs("1rem"),
|
|
346
|
+
pbe("calc(1rem + env(safe-area-inset-bottom, 0px))"),
|
|
347
|
+
mix,
|
|
348
|
+
] }));
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
/**
|
|
352
|
+
* Renders a flat navigation list: a `<nav>` stacking its {@link Sidebar.Item}
|
|
353
|
+
* children in a column with a small gap, suited to a rail with a simple,
|
|
354
|
+
* ungrouped set of links.
|
|
355
|
+
*
|
|
356
|
+
* @param handle Runtime handle carrying the host `<nav>`'s props.
|
|
357
|
+
* @returns The render function producing the list's markup.
|
|
358
|
+
* @example
|
|
359
|
+
* <Sidebar.Nav aria-label={t("nav.mainNavigation")}>
|
|
360
|
+
* <Sidebar.Item href="/dashboard" current>{t("nav.dashboard")}</Sidebar.Item>
|
|
361
|
+
* <Sidebar.Item href="/settings">{t("nav.settings")}</Sidebar.Item>
|
|
362
|
+
* </Sidebar.Nav>
|
|
363
|
+
*/
|
|
364
|
+
Sidebar.Nav = function SidebarNav(handle) {
|
|
365
|
+
return () => {
|
|
366
|
+
let { mix, ...rest } = handle.props;
|
|
367
|
+
return _jsx("nav", { ...rest, "data-slot": "nav", mix: [vstack({ gap: "0.25rem" }), mix] });
|
|
368
|
+
};
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Renders a single row inside {@link Sidebar.Nav}: a native `<a>` colored
|
|
372
|
+
* through `data-color`, tinted once `aria-current` is set, matching
|
|
373
|
+
* {@link Sidebar.MenuLink}; its focus ring always reads in that same color.
|
|
374
|
+
*
|
|
375
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
376
|
+
* @returns The render function producing the row's markup.
|
|
377
|
+
* @example
|
|
378
|
+
* <Sidebar.Item href="/dashboard" current>
|
|
379
|
+
* <HomeIcon aria-hidden />
|
|
380
|
+
* {t("nav.dashboard")}
|
|
381
|
+
* </Sidebar.Item>
|
|
382
|
+
* @example
|
|
383
|
+
* <Sidebar.Item href="/billing/cancel" color="danger" aria-current={pathname === "/billing/cancel" ? "page" : undefined}>
|
|
384
|
+
* <XCircleIcon aria-hidden />
|
|
385
|
+
* {t("nav.cancelPlan")}
|
|
386
|
+
* </Sidebar.Item>
|
|
387
|
+
*/
|
|
388
|
+
Sidebar.Item = function SidebarItem(handle) {
|
|
389
|
+
return () => {
|
|
390
|
+
let { color, current, "aria-current": ariaCurrent, mix, ...rest } = handle.props;
|
|
391
|
+
let resolvedColor = color ?? DEFAULT_ITEM_COLOR;
|
|
392
|
+
let resolvedAriaCurrent = resolveAriaCurrent(current, ariaCurrent);
|
|
393
|
+
return (_jsx("a", { ...rest, "aria-current": resolvedAriaCurrent, "data-slot": "item", "data-color": resolvedColor, mix: [
|
|
394
|
+
when("&:focus-visible", [
|
|
395
|
+
outline({ color: "brand.ring", offset: 2 }),
|
|
396
|
+
data("color", "neutral", outline("neutral.ring")),
|
|
397
|
+
data("color", "success", outline("success.ring")),
|
|
398
|
+
data("color", "warning", outline("warning.ring")),
|
|
399
|
+
data("color", "danger", outline("danger.ring")),
|
|
400
|
+
]),
|
|
401
|
+
flex(),
|
|
402
|
+
minBs("2.25rem"),
|
|
403
|
+
items("center"),
|
|
404
|
+
fontSize("sm"),
|
|
405
|
+
weight(500),
|
|
406
|
+
textDecoration("none"),
|
|
407
|
+
when("& > svg, & > [data-slot='icon']", [is("1rem"), bs("1rem"), shrink()]),
|
|
408
|
+
when("&:active", scaleProperty(0.98)),
|
|
409
|
+
when('&[aria-disabled="true"]', [cursor("not-allowed"), opacity(50)]),
|
|
410
|
+
gap("0.75rem"),
|
|
411
|
+
rounded("lg"),
|
|
412
|
+
pi("0.75rem"),
|
|
413
|
+
pb("0.5rem"),
|
|
414
|
+
fg("neutral"),
|
|
415
|
+
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
416
|
+
when("&:hover", [bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
417
|
+
when("& > svg, & > [data-slot='icon']", fg("neutral.muted")),
|
|
418
|
+
when('&[aria-current]:not([aria-current="false"])', [
|
|
419
|
+
bg("neutral.bg-tint-hover"),
|
|
420
|
+
fg("neutral.emphasis"),
|
|
421
|
+
when("& > svg, & > [data-slot='icon']", fg("neutral.emphasis")),
|
|
422
|
+
]),
|
|
423
|
+
data("color", "brand", when('&[aria-current]:not([aria-current="false"])', [
|
|
424
|
+
bg("brand.tint"),
|
|
425
|
+
fg("brand"),
|
|
426
|
+
when("& > svg, & > [data-slot='icon']", fg("brand")),
|
|
427
|
+
])),
|
|
428
|
+
data("color", "success", when('&[aria-current]:not([aria-current="false"])', [
|
|
429
|
+
bg("success.tint"),
|
|
430
|
+
fg("success"),
|
|
431
|
+
when("& > svg, & > [data-slot='icon']", fg("success")),
|
|
432
|
+
])),
|
|
433
|
+
data("color", "warning", when('&[aria-current]:not([aria-current="false"])', [
|
|
434
|
+
bg("warning.tint"),
|
|
435
|
+
fg("warning"),
|
|
436
|
+
when("& > svg, & > [data-slot='icon']", fg("warning")),
|
|
437
|
+
])),
|
|
438
|
+
data("color", "danger", when('&[aria-current]:not([aria-current="false"])', [
|
|
439
|
+
bg("danger.tint"),
|
|
440
|
+
fg("danger"),
|
|
441
|
+
when("& > svg, & > [data-slot='icon']", fg("danger")),
|
|
442
|
+
])),
|
|
443
|
+
when("&:active", bg("neutral.bg-tint-pressed")),
|
|
444
|
+
mix,
|
|
445
|
+
] }));
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
/**
|
|
449
|
+
* Renders a related cluster of {@link Sidebar.Menu} items: a `<section>`
|
|
450
|
+
* stacking its children in a column, gaining a divider border and extra
|
|
451
|
+
* space above itself whenever it follows another {@link Sidebar.Group}.
|
|
452
|
+
*
|
|
453
|
+
* @param handle Runtime handle carrying the host `<section>`'s props.
|
|
454
|
+
* @returns The render function producing the group's markup.
|
|
455
|
+
* @example
|
|
456
|
+
* <Sidebar.Group>
|
|
457
|
+
* <Sidebar.GroupLabel>{t("nav.workspace")}</Sidebar.GroupLabel>
|
|
458
|
+
* <Sidebar.GroupContent>
|
|
459
|
+
* <Sidebar.Menu>...</Sidebar.Menu>
|
|
460
|
+
* </Sidebar.GroupContent>
|
|
461
|
+
* </Sidebar.Group>
|
|
462
|
+
*/
|
|
463
|
+
Sidebar.Group = function SidebarGroup(handle) {
|
|
464
|
+
return () => {
|
|
465
|
+
let { mix, ...rest } = handle.props;
|
|
466
|
+
return (_jsx("section", { ...rest, "data-slot": "group", mix: [
|
|
467
|
+
flex(),
|
|
468
|
+
flexCol(),
|
|
469
|
+
when("& + &", [
|
|
470
|
+
mbs("0.5rem"),
|
|
471
|
+
borderEdge("block-start", {
|
|
472
|
+
width: 1,
|
|
473
|
+
style: "solid",
|
|
474
|
+
color: colorMix("oklab", { color: "var(--ui-neutral-border)", weight: 60 }, "transparent"),
|
|
475
|
+
}),
|
|
476
|
+
]),
|
|
477
|
+
gap("0.25rem"),
|
|
478
|
+
when("& + &", pbs("1rem")),
|
|
479
|
+
mix,
|
|
480
|
+
] }));
|
|
481
|
+
};
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* Renders {@link Sidebar.Group}'s label: a small, muted, uppercase heading
|
|
485
|
+
* row, visually clipped once the ancestor {@link Sidebar} collapses to
|
|
486
|
+
* icon-only, while staying announced to assistive technology.
|
|
487
|
+
*
|
|
488
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
489
|
+
* @returns The render function producing the label's markup.
|
|
490
|
+
* @example
|
|
491
|
+
* <Sidebar.GroupLabel>{t("nav.workspace")}</Sidebar.GroupLabel>
|
|
492
|
+
*/
|
|
493
|
+
Sidebar.GroupLabel = function SidebarGroupLabel(handle) {
|
|
494
|
+
return () => {
|
|
495
|
+
let { mix, ...rest } = handle.props;
|
|
496
|
+
return (_jsx("div", { ...rest, "data-slot": "group-label", mix: [
|
|
497
|
+
flex(),
|
|
498
|
+
items("center"),
|
|
499
|
+
justify("between"),
|
|
500
|
+
mbe("0.25rem"),
|
|
501
|
+
weight(600),
|
|
502
|
+
fontSize("xs"),
|
|
503
|
+
textTransform("uppercase"),
|
|
504
|
+
tracking("wider"),
|
|
505
|
+
userSelect(),
|
|
506
|
+
pi("0.5rem"),
|
|
507
|
+
pb("0.375rem"),
|
|
508
|
+
fg("neutral.muted"),
|
|
509
|
+
mix,
|
|
510
|
+
] }));
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* Renders a small icon-only action button anchored to
|
|
515
|
+
* {@link Sidebar.GroupLabel}'s trailing edge. In dev mode, an action with no
|
|
516
|
+
* plain text and no `aria-label`/`aria-labelledby` logs a `console.warn`.
|
|
517
|
+
*
|
|
518
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
519
|
+
* @returns The render function producing the action's markup.
|
|
520
|
+
* @example
|
|
521
|
+
* <Sidebar.GroupLabel>
|
|
522
|
+
* {t("nav.workspace")}
|
|
523
|
+
* <Sidebar.GroupAction aria-label={t("nav.addWorkspace")}>
|
|
524
|
+
* <PlusIcon aria-hidden />
|
|
525
|
+
* </Sidebar.GroupAction>
|
|
526
|
+
* </Sidebar.GroupLabel>
|
|
527
|
+
*/
|
|
528
|
+
Sidebar.GroupAction = function SidebarGroupAction(handle) {
|
|
529
|
+
return () => {
|
|
530
|
+
let { children, mix, ...rest } = handle.props;
|
|
531
|
+
warnIfNoAccessibleName(handle.props, children, "Sidebar.GroupAction: an icon-only action needs an `aria-label` describing what it does — assistive technology has no accessible text to announce otherwise.");
|
|
532
|
+
return (_jsx("button", { type: "button", ...rest, "data-slot": "group-action", mix: [
|
|
533
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
534
|
+
inlineFlex(),
|
|
535
|
+
is("1.25rem"),
|
|
536
|
+
bs("1.25rem"),
|
|
537
|
+
items("center"),
|
|
538
|
+
justify("center"),
|
|
539
|
+
when("&:disabled", [cursor("not-allowed"), opacity(50)]),
|
|
540
|
+
rounded("sm"),
|
|
541
|
+
fg("neutral.muted"),
|
|
542
|
+
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
543
|
+
hover([bg("neutral.bg-tint-hover"), fg("neutral")]),
|
|
544
|
+
mix,
|
|
545
|
+
], children: children }));
|
|
546
|
+
};
|
|
547
|
+
};
|
|
548
|
+
/**
|
|
549
|
+
* Renders {@link Sidebar.Group}'s body slot: a `<div>` stacking its children
|
|
550
|
+
* — typically a {@link Sidebar.Menu} — in a column with a small gap.
|
|
551
|
+
*
|
|
552
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
553
|
+
* @returns The render function producing the body slot's markup.
|
|
554
|
+
* @example
|
|
555
|
+
* <Sidebar.GroupContent>
|
|
556
|
+
* <Sidebar.Menu>...</Sidebar.Menu>
|
|
557
|
+
* </Sidebar.GroupContent>
|
|
558
|
+
*/
|
|
559
|
+
Sidebar.GroupContent = function SidebarGroupContent(handle) {
|
|
560
|
+
return () => {
|
|
561
|
+
let { mix, ...rest } = handle.props;
|
|
562
|
+
return _jsx("div", { ...rest, "data-slot": "group-content", mix: [vstack({ gap: "0.125rem" }), mix] });
|
|
563
|
+
};
|
|
564
|
+
};
|
|
565
|
+
/**
|
|
566
|
+
* Renders a list of nav rows: a native `<ul>` stacking {@link Sidebar.MenuItem}
|
|
567
|
+
* children in a column with a small gap.
|
|
568
|
+
*
|
|
569
|
+
* @param handle Runtime handle carrying the host `<ul>`'s props.
|
|
570
|
+
* @returns The render function producing the list's markup.
|
|
571
|
+
* @example
|
|
572
|
+
* <Sidebar.Menu>
|
|
573
|
+
* <Sidebar.MenuItem>
|
|
574
|
+
* <Sidebar.MenuLink href="/dashboard">{t("nav.dashboard")}</Sidebar.MenuLink>
|
|
575
|
+
* </Sidebar.MenuItem>
|
|
576
|
+
* </Sidebar.Menu>
|
|
577
|
+
*/
|
|
578
|
+
Sidebar.Menu = function SidebarMenu(handle) {
|
|
579
|
+
return () => {
|
|
580
|
+
let { mix, ...rest } = handle.props;
|
|
581
|
+
return (_jsx("ul", { ...rest, "data-slot": "menu", mix: [is("full"), minIs("0"), vstack({ gap: "0.125rem" }), mix] }));
|
|
582
|
+
};
|
|
583
|
+
};
|
|
584
|
+
/**
|
|
585
|
+
* Renders a single row inside {@link Sidebar.Menu}: a relatively positioned
|
|
586
|
+
* `<li>` whose own `:hover`/`:focus-within` state reveals a nested
|
|
587
|
+
* {@link Sidebar.MenuAction} that stays invisible at rest.
|
|
588
|
+
*
|
|
589
|
+
* @param handle Runtime handle carrying the host `<li>`'s props.
|
|
590
|
+
* @returns The render function producing the row's markup.
|
|
591
|
+
* @example
|
|
592
|
+
* <Sidebar.MenuItem>
|
|
593
|
+
* <Sidebar.MenuLink href="/inbox">{t("nav.inbox")}</Sidebar.MenuLink>
|
|
594
|
+
* <Sidebar.MenuAction aria-label={t("nav.inboxSettings")}>
|
|
595
|
+
* <SettingsIcon aria-hidden />
|
|
596
|
+
* </Sidebar.MenuAction>
|
|
597
|
+
* </Sidebar.MenuItem>
|
|
598
|
+
*/
|
|
599
|
+
Sidebar.MenuItem = function SidebarMenuItem(handle) {
|
|
600
|
+
return () => {
|
|
601
|
+
let { mix, ...rest } = handle.props;
|
|
602
|
+
return (_jsx("li", { ...rest, "data-slot": "menu-item", mix: [
|
|
603
|
+
relative(),
|
|
604
|
+
flex(),
|
|
605
|
+
items("center"),
|
|
606
|
+
when("&:hover [data-slot='menu-action'], &:focus-within [data-slot='menu-action']", opacity(100)),
|
|
607
|
+
mix,
|
|
608
|
+
] }));
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
/**
|
|
612
|
+
* Renders a native `<button>` row for an in-page action inside
|
|
613
|
+
* {@link Sidebar.Menu}, sized through `data-size` and marked current via
|
|
614
|
+
* `active`; its leading icon is muted, and a trailing label truncates.
|
|
615
|
+
*
|
|
616
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
617
|
+
* @returns The render function producing the row's markup.
|
|
618
|
+
* @example
|
|
619
|
+
* <Sidebar.MenuButton onClick={openCommandPalette}>
|
|
620
|
+
* <SearchIcon aria-hidden />
|
|
621
|
+
* <span data-sidebar-collapsed-hide>{t("nav.search")}</span>
|
|
622
|
+
* </Sidebar.MenuButton>
|
|
623
|
+
*/
|
|
624
|
+
Sidebar.MenuButton = function SidebarMenuButton(handle) {
|
|
625
|
+
return () => {
|
|
626
|
+
let { size, active, mix, ...rest } = handle.props;
|
|
627
|
+
let resolvedSize = size ?? DEFAULT_MENU_BUTTON_SIZE;
|
|
628
|
+
return (_jsx("button", { type: "button", ...rest, "data-slot": "menu-button", "data-size": resolvedSize, "data-active": active || undefined, mix: [
|
|
629
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
630
|
+
...menuRowMixins(),
|
|
631
|
+
mix,
|
|
632
|
+
] }));
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
/**
|
|
636
|
+
* Renders a native `<a>` row for navigation inside {@link Sidebar.Menu},
|
|
637
|
+
* visually identical to {@link Sidebar.MenuButton}. `active` sets
|
|
638
|
+
* `aria-current="page"` when unset, with styling reading that attribute directly.
|
|
639
|
+
*
|
|
640
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
641
|
+
* @returns The render function producing the row's markup.
|
|
642
|
+
* @example
|
|
643
|
+
* <Sidebar.MenuLink href="/dashboard" active>
|
|
644
|
+
* <HomeIcon aria-hidden />
|
|
645
|
+
* <span data-sidebar-collapsed-hide>{t("nav.dashboard")}</span>
|
|
646
|
+
* </Sidebar.MenuLink>
|
|
647
|
+
*/
|
|
648
|
+
Sidebar.MenuLink = function SidebarMenuLink(handle) {
|
|
649
|
+
return () => {
|
|
650
|
+
let { size, active, "aria-current": ariaCurrent, mix, ...rest } = handle.props;
|
|
651
|
+
let resolvedSize = size ?? DEFAULT_MENU_BUTTON_SIZE;
|
|
652
|
+
let resolvedAriaCurrent = resolveAriaCurrent(active, ariaCurrent);
|
|
653
|
+
return (_jsx("a", { ...rest, "aria-current": resolvedAriaCurrent, "data-slot": "menu-link", "data-size": resolvedSize, "data-active": active || undefined, mix: [
|
|
654
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
655
|
+
...menuRowMixins(),
|
|
656
|
+
mix,
|
|
657
|
+
] }));
|
|
658
|
+
};
|
|
659
|
+
};
|
|
660
|
+
/**
|
|
661
|
+
* Shared `@sdxc/u` mixins for {@link Sidebar.MenuButton} and
|
|
662
|
+
* {@link Sidebar.MenuLink}, factored out since the two differ only in host
|
|
663
|
+
* element and how their current/active state is expressed.
|
|
664
|
+
*/
|
|
665
|
+
function menuRowMixins() {
|
|
666
|
+
return [
|
|
667
|
+
flex(),
|
|
668
|
+
is("full"),
|
|
669
|
+
minIs("0"),
|
|
670
|
+
items("center"),
|
|
671
|
+
overflow("hidden"),
|
|
672
|
+
textAlign("start"),
|
|
673
|
+
weight(500),
|
|
674
|
+
textDecoration("none"),
|
|
675
|
+
fontSize("sm"),
|
|
676
|
+
outlineStyle("none"),
|
|
677
|
+
when("& > svg:first-child, & > [data-slot='icon']:first-child", [
|
|
678
|
+
is("1rem"),
|
|
679
|
+
bs("1rem"),
|
|
680
|
+
shrink(),
|
|
681
|
+
]),
|
|
682
|
+
when("& > span", truncate()),
|
|
683
|
+
data("size", "sm", [
|
|
684
|
+
minBs("1.75rem"),
|
|
685
|
+
pi("0.625rem"),
|
|
686
|
+
pb("0.375rem"),
|
|
687
|
+
fontSize("xs"),
|
|
688
|
+
when("& > svg:first-child, & > [data-slot='icon']:first-child", [
|
|
689
|
+
is("0.875rem"),
|
|
690
|
+
bs("0.875rem"),
|
|
691
|
+
]),
|
|
692
|
+
]),
|
|
693
|
+
data("size", "md", minBs("2.25rem")),
|
|
694
|
+
data("size", "lg", [
|
|
695
|
+
minBs("2.75rem"),
|
|
696
|
+
pi("1rem"),
|
|
697
|
+
pb("0.625rem"),
|
|
698
|
+
fontSize("base"),
|
|
699
|
+
when("& > svg:first-child, & > [data-slot='icon']:first-child", [
|
|
700
|
+
is("1.25rem"),
|
|
701
|
+
bs("1.25rem"),
|
|
702
|
+
]),
|
|
703
|
+
]),
|
|
704
|
+
when("&:active", scaleProperty(0.98)),
|
|
705
|
+
when("&:disabled", [cursor("not-allowed"), opacity(50)]),
|
|
706
|
+
when('&[aria-disabled="true"]', [cursor("not-allowed"), opacity(50)]),
|
|
707
|
+
gap("0.75rem"),
|
|
708
|
+
rounded("lg"),
|
|
709
|
+
pi("0.75rem"),
|
|
710
|
+
pb("0.5rem"),
|
|
711
|
+
fg("neutral"),
|
|
712
|
+
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
713
|
+
hover([bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
714
|
+
when("& > svg:first-child, & > [data-slot='icon']:first-child", fg("neutral.muted")),
|
|
715
|
+
when('&[data-active], &[aria-current]:not([aria-current="false"])', [
|
|
716
|
+
bg("neutral.bg-tint-hover"),
|
|
717
|
+
fg("neutral.emphasis"),
|
|
718
|
+
when("& > svg:first-child, & > [data-slot='icon']:first-child", fg("neutral.emphasis")),
|
|
719
|
+
]),
|
|
720
|
+
when("&:active", bg("neutral.bg-tint-pressed")),
|
|
721
|
+
];
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* Renders a small icon-only action anchored to {@link Sidebar.MenuItem}'s
|
|
725
|
+
* trailing edge, revealed by `showOnHover` on hover or focus within the row.
|
|
726
|
+
* In dev mode, an action with no accessible name logs a `console.warn`.
|
|
727
|
+
*
|
|
728
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
729
|
+
* @returns The render function producing the action's markup.
|
|
730
|
+
* @example
|
|
731
|
+
* <Sidebar.MenuAction aria-label={t("nav.inboxSettings")}>
|
|
732
|
+
* <SettingsIcon aria-hidden />
|
|
733
|
+
* </Sidebar.MenuAction>
|
|
734
|
+
* @example
|
|
735
|
+
* <Sidebar.MenuAction showOnHover={false} aria-label={t("nav.starred")}>
|
|
736
|
+
* <StarIcon aria-hidden />
|
|
737
|
+
* </Sidebar.MenuAction>
|
|
738
|
+
*/
|
|
739
|
+
Sidebar.MenuAction = function SidebarMenuAction(handle) {
|
|
740
|
+
return () => {
|
|
741
|
+
let { showOnHover, children, mix, ...rest } = handle.props;
|
|
742
|
+
let resolvedShowOnHover = showOnHover ?? DEFAULT_SHOW_ON_HOVER;
|
|
743
|
+
warnIfNoAccessibleName(handle.props, children, "Sidebar.MenuAction: an icon-only action needs an `aria-label` describing what it does — assistive technology has no accessible text to announce otherwise.");
|
|
744
|
+
return (_jsx("button", { type: "button", ...rest, "data-slot": "menu-action", "data-show-on-hover": resolvedShowOnHover ? undefined : "false", mix: [
|
|
745
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
746
|
+
absolute(),
|
|
747
|
+
insIe("0.375rem"),
|
|
748
|
+
insBs("50%"),
|
|
749
|
+
translateProperty("0 -50%"),
|
|
750
|
+
inlineFlex(),
|
|
751
|
+
is("1.5rem"),
|
|
752
|
+
bs("1.5rem"),
|
|
753
|
+
items("center"),
|
|
754
|
+
justify("center"),
|
|
755
|
+
opacity(0),
|
|
756
|
+
focusVisible(opacity(100)),
|
|
757
|
+
when("&:disabled", [cursor("not-allowed"), opacity(50)]),
|
|
758
|
+
data("show-on-hover", "false", opacity(100)),
|
|
759
|
+
rounded("md"),
|
|
760
|
+
fg("neutral.muted"),
|
|
761
|
+
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
762
|
+
hover([bg("neutral.bg-tint-pressed"), fg("neutral")]),
|
|
763
|
+
mix,
|
|
764
|
+
], children: children }));
|
|
765
|
+
};
|
|
766
|
+
};
|
|
767
|
+
/**
|
|
768
|
+
* Renders a small count or status pill pinned to the trailing edge of a
|
|
769
|
+
* {@link Sidebar.MenuButton} or {@link Sidebar.MenuLink} row, hidden once
|
|
770
|
+
* the ancestor {@link Sidebar} collapses to its icon-only rail.
|
|
771
|
+
*
|
|
772
|
+
* @param handle Runtime handle carrying the host `<span>`'s props.
|
|
773
|
+
* @returns The render function producing the pill's markup.
|
|
774
|
+
* @example
|
|
775
|
+
* <Sidebar.MenuLink href="/inbox">
|
|
776
|
+
* {t("nav.inbox")}
|
|
777
|
+
* <Sidebar.MenuBadge>24</Sidebar.MenuBadge>
|
|
778
|
+
* </Sidebar.MenuLink>
|
|
779
|
+
*/
|
|
780
|
+
Sidebar.MenuBadge = function SidebarMenuBadge(handle) {
|
|
781
|
+
return () => {
|
|
782
|
+
let { mix, ...rest } = handle.props;
|
|
783
|
+
return (_jsx("span", { ...rest, "data-slot": "menu-badge", mix: [
|
|
784
|
+
mis("auto"),
|
|
785
|
+
shrink(),
|
|
786
|
+
fontSize("xs"),
|
|
787
|
+
weight(600),
|
|
788
|
+
tabularNums(),
|
|
789
|
+
rounded("md"),
|
|
790
|
+
pi("0.375rem"),
|
|
791
|
+
pb("0.125rem"),
|
|
792
|
+
bg("neutral.bg-tint-hover"),
|
|
793
|
+
fg("neutral"),
|
|
794
|
+
mix,
|
|
795
|
+
] }));
|
|
796
|
+
};
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* Renders a static loading placeholder shaped like {@link Sidebar.MenuButton}:
|
|
800
|
+
* an optional icon-shaped {@link Skeleton} block followed by a text-shaped
|
|
801
|
+
* one; compose `pulse()` or `shimmer()` through `mix` for a loading cue.
|
|
802
|
+
*
|
|
803
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
804
|
+
* @returns The render function producing the placeholder's markup.
|
|
805
|
+
* @example
|
|
806
|
+
* <Sidebar.MenuSkeleton showIcon />
|
|
807
|
+
* @example
|
|
808
|
+
* <Sidebar.MenuSkeleton style={{ inlineSize: "70%" }} />
|
|
809
|
+
*/
|
|
810
|
+
Sidebar.MenuSkeleton = function SidebarMenuSkeleton(handle) {
|
|
811
|
+
return () => {
|
|
812
|
+
let { showIcon, mix, ...rest } = handle.props;
|
|
813
|
+
let resolvedShowIcon = showIcon ?? DEFAULT_SHOW_ICON;
|
|
814
|
+
return (_jsxs("div", { ...rest, "data-slot": "menu-skeleton", mix: [
|
|
815
|
+
flex(),
|
|
816
|
+
items("center"),
|
|
817
|
+
bs("2.25rem"),
|
|
818
|
+
gap("0.75rem"),
|
|
819
|
+
pi("0.75rem"),
|
|
820
|
+
rounded("lg"),
|
|
821
|
+
mix,
|
|
822
|
+
], children: [resolvedShowIcon && (_jsx("span", { "aria-hidden": "true", "data-slot": "menu-skeleton-icon", mix: [is("1rem"), bs("1rem"), shrink(), rounded("sm"), bg("neutral.border")] })), _jsx("span", { "aria-hidden": "true", "data-slot": "menu-skeleton-text", mix: [bs("1rem"), grow(), is("60%"), rounded("md"), bg("neutral.border")] })] }));
|
|
823
|
+
};
|
|
824
|
+
};
|
|
825
|
+
/**
|
|
826
|
+
* Renders a nested list of sub-rows beneath a {@link Sidebar.MenuItem}: a
|
|
827
|
+
* `<ul>` indented from and bordered against the rail's inline-start edge,
|
|
828
|
+
* hidden once the ancestor {@link Sidebar} collapses to its icon-only rail.
|
|
829
|
+
*
|
|
830
|
+
* @param handle Runtime handle carrying the host `<ul>`'s props.
|
|
831
|
+
* @returns The render function producing the nested list's markup.
|
|
832
|
+
* @example
|
|
833
|
+
* <Sidebar.MenuSub>
|
|
834
|
+
* <Sidebar.MenuSubItem>
|
|
835
|
+
* <Sidebar.MenuSubLink href="/settings/profile">{t("nav.profile")}</Sidebar.MenuSubLink>
|
|
836
|
+
* </Sidebar.MenuSubItem>
|
|
837
|
+
* </Sidebar.MenuSub>
|
|
838
|
+
*/
|
|
839
|
+
Sidebar.MenuSub = function SidebarMenuSub(handle) {
|
|
840
|
+
return () => {
|
|
841
|
+
let { mix, ...rest } = handle.props;
|
|
842
|
+
return (_jsx("ul", { ...rest, "data-slot": "menu-sub", mix: [
|
|
843
|
+
relative(),
|
|
844
|
+
mis("0.875rem"),
|
|
845
|
+
flex(),
|
|
846
|
+
flexCol(),
|
|
847
|
+
borderEdge("inline-start", { width: 1, style: "solid" }),
|
|
848
|
+
pis("0.875rem"),
|
|
849
|
+
gap("0.125rem"),
|
|
850
|
+
border("neutral"),
|
|
851
|
+
mix,
|
|
852
|
+
] }));
|
|
853
|
+
};
|
|
854
|
+
};
|
|
855
|
+
/**
|
|
856
|
+
* Renders a single row inside {@link Sidebar.MenuSub}: a plain `<li>`.
|
|
857
|
+
*
|
|
858
|
+
* @param handle Runtime handle carrying the host `<li>`'s props.
|
|
859
|
+
* @returns The render function producing the row's markup.
|
|
860
|
+
* @example
|
|
861
|
+
* <Sidebar.MenuSubItem>
|
|
862
|
+
* <Sidebar.MenuSubLink href="/settings/profile">{t("nav.profile")}</Sidebar.MenuSubLink>
|
|
863
|
+
* </Sidebar.MenuSubItem>
|
|
864
|
+
*/
|
|
865
|
+
Sidebar.MenuSubItem = function SidebarMenuSubItem(handle) {
|
|
866
|
+
return () => {
|
|
867
|
+
let { mix, ...rest } = handle.props;
|
|
868
|
+
return _jsx("li", { ...rest, "data-slot": "menu-sub-item", mix: [flex(), items("center"), mix] });
|
|
869
|
+
};
|
|
870
|
+
};
|
|
871
|
+
/**
|
|
872
|
+
* Renders a native `<button>` row for an in-page action inside
|
|
873
|
+
* {@link Sidebar.MenuSub}, smaller and more muted than
|
|
874
|
+
* {@link Sidebar.MenuButton}, marked current through `active`.
|
|
875
|
+
*
|
|
876
|
+
* @param handle Runtime handle carrying the host `<button>`'s props.
|
|
877
|
+
* @returns The render function producing the row's markup.
|
|
878
|
+
* @example
|
|
879
|
+
* <Sidebar.MenuSubButton onClick={runQuickAction}>{t("nav.markAllRead")}</Sidebar.MenuSubButton>
|
|
880
|
+
*/
|
|
881
|
+
Sidebar.MenuSubButton = function SidebarMenuSubButton(handle) {
|
|
882
|
+
return () => {
|
|
883
|
+
let { active, mix, ...rest } = handle.props;
|
|
884
|
+
return (_jsx("button", { type: "button", ...rest, "data-slot": "menu-sub-button", "data-active": active || undefined, mix: [
|
|
885
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
886
|
+
...menuSubRowMixins(),
|
|
887
|
+
mix,
|
|
888
|
+
] }));
|
|
889
|
+
};
|
|
890
|
+
};
|
|
891
|
+
/**
|
|
892
|
+
* Renders a native `<a>` row for navigation inside {@link Sidebar.MenuSub},
|
|
893
|
+
* visually identical to {@link Sidebar.MenuSubButton}. `active` sets
|
|
894
|
+
* `aria-current="page"` when `aria-current` is otherwise unset.
|
|
895
|
+
*
|
|
896
|
+
* @param handle Runtime handle carrying the host `<a>`'s props.
|
|
897
|
+
* @returns The render function producing the row's markup.
|
|
898
|
+
* @example
|
|
899
|
+
* <Sidebar.MenuSubLink href="/settings/profile" active>{t("nav.profile")}</Sidebar.MenuSubLink>
|
|
900
|
+
*/
|
|
901
|
+
Sidebar.MenuSubLink = function SidebarMenuSubLink(handle) {
|
|
902
|
+
return () => {
|
|
903
|
+
let { active, "aria-current": ariaCurrent, mix, ...rest } = handle.props;
|
|
904
|
+
let resolvedAriaCurrent = resolveAriaCurrent(active, ariaCurrent);
|
|
905
|
+
return (_jsx("a", { ...rest, "aria-current": resolvedAriaCurrent, "data-slot": "menu-sub-link", "data-active": active || undefined, mix: [
|
|
906
|
+
when("&:focus-visible", outline({ color: "brand.ring", offset: 2 })),
|
|
907
|
+
...menuSubRowMixins(),
|
|
908
|
+
mix,
|
|
909
|
+
] }));
|
|
910
|
+
};
|
|
911
|
+
};
|
|
912
|
+
/**
|
|
913
|
+
* Shared `@sdxc/u` mixins for {@link Sidebar.MenuSubButton} and
|
|
914
|
+
* {@link Sidebar.MenuSubLink}.
|
|
915
|
+
*/
|
|
916
|
+
function menuSubRowMixins() {
|
|
917
|
+
return [
|
|
918
|
+
flex(),
|
|
919
|
+
minBs("2rem"),
|
|
920
|
+
is("full"),
|
|
921
|
+
items("center"),
|
|
922
|
+
textAlign("start"),
|
|
923
|
+
textDecoration("none"),
|
|
924
|
+
fontSize("sm"),
|
|
925
|
+
when('&[data-active], &[aria-current]:not([aria-current="false"])', weight(500)),
|
|
926
|
+
when("&:active", scaleProperty(0.98)),
|
|
927
|
+
when("&:disabled", [cursor("not-allowed"), opacity(50)]),
|
|
928
|
+
when('&[aria-disabled="true"]', [cursor("not-allowed"), opacity(50)]),
|
|
929
|
+
gap("0.5rem"),
|
|
930
|
+
rounded("lg"),
|
|
931
|
+
pi("0.625rem"),
|
|
932
|
+
pb("0.375rem"),
|
|
933
|
+
fg("neutral.muted"),
|
|
934
|
+
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
935
|
+
hover([bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
936
|
+
when('&[data-active], &[aria-current]:not([aria-current="false"])', [
|
|
937
|
+
bg("neutral.bg-tint-hover"),
|
|
938
|
+
fg("neutral.emphasis"),
|
|
939
|
+
]),
|
|
940
|
+
when("&:active", bg("neutral.bg-tint-pressed")),
|
|
941
|
+
];
|
|
942
|
+
}
|
|
943
|
+
/**
|
|
944
|
+
* Renders a thin drag-styled affordance along {@link Sidebar}'s own edge,
|
|
945
|
+
* toggling {@link Sidebar.Trigger}'s checkbox through a native `<label>`
|
|
946
|
+
* association; marked `aria-hidden` since that checkbox is the accessible control.
|
|
947
|
+
*
|
|
948
|
+
* @param handle Runtime handle carrying the host `<label>`'s props.
|
|
949
|
+
* @returns The render function producing the rail's markup.
|
|
950
|
+
* @example
|
|
951
|
+
* <Sidebar>
|
|
952
|
+
* <Sidebar.Header>...</Sidebar.Header>
|
|
953
|
+
* <Sidebar.Rail htmlFor="app-sidebar-toggle" />
|
|
954
|
+
* </Sidebar>
|
|
955
|
+
*/
|
|
956
|
+
Sidebar.Rail = function SidebarRail(handle) {
|
|
957
|
+
return () => {
|
|
958
|
+
let { mix, ...rest } = handle.props;
|
|
959
|
+
return (_jsx("label", { ...rest, "data-slot": "rail", mix: [
|
|
960
|
+
attrs({ "aria-hidden": "true" }),
|
|
961
|
+
absolute(),
|
|
962
|
+
insBs("0"),
|
|
963
|
+
insBe("0"),
|
|
964
|
+
is("1rem"),
|
|
965
|
+
z(20),
|
|
966
|
+
hidden(),
|
|
967
|
+
cursor("col-resize"),
|
|
968
|
+
when('[data-side="left"] &', insRight("-1rem")),
|
|
969
|
+
when('[data-side="right"] &', insLeft("-1rem")),
|
|
970
|
+
after([
|
|
971
|
+
absolute(),
|
|
972
|
+
is("2px"),
|
|
973
|
+
bg("transparent"),
|
|
974
|
+
insBs("0"),
|
|
975
|
+
insBe("0"),
|
|
976
|
+
insIs("50%"),
|
|
977
|
+
translateProperty("-50% 0"),
|
|
978
|
+
pseudoContent('""'),
|
|
979
|
+
transitionProperty("background-color"),
|
|
980
|
+
transitionDuration("150ms"),
|
|
981
|
+
]),
|
|
982
|
+
when(WIDE_SHELL_QUERY, [flex(), items("center"), justify("center")]),
|
|
983
|
+
hover(after(bg("neutral.border"))),
|
|
984
|
+
when("&:active", after(bg("brand.ring"))),
|
|
985
|
+
mix,
|
|
986
|
+
] }));
|
|
987
|
+
};
|
|
988
|
+
};
|
|
989
|
+
/**
|
|
990
|
+
* Renders the collapse toggle: a native, keyboard-reachable
|
|
991
|
+
* `<input type="checkbox">` wrapped in a button-styled `<label>`; its
|
|
992
|
+
* `:checked` state drives every collapse rule in {@link Sidebar.Provider}.
|
|
993
|
+
*
|
|
994
|
+
* @param handle Runtime handle carrying the host checkbox's props.
|
|
995
|
+
* @returns The render function producing the toggle's markup.
|
|
996
|
+
* @example
|
|
997
|
+
* <Sidebar.Trigger id="app-sidebar-toggle" aria-label={t("nav.toggleSidebar")} />
|
|
998
|
+
* @example
|
|
999
|
+
* <Sidebar.Trigger id="app-sidebar-toggle" defaultChecked aria-label={t("nav.toggleSidebar")} />
|
|
1000
|
+
*/
|
|
1001
|
+
Sidebar.Trigger = function SidebarTrigger(handle) {
|
|
1002
|
+
return () => {
|
|
1003
|
+
let { mix, ...rest } = handle.props;
|
|
1004
|
+
return (_jsxs("label", { "data-slot": "trigger", mix: [
|
|
1005
|
+
when("&:has(input:focus-visible)", outline({ color: "brand.ring", offset: 2 })),
|
|
1006
|
+
relative(),
|
|
1007
|
+
inlineFlex(),
|
|
1008
|
+
is("2rem"),
|
|
1009
|
+
bs("2rem"),
|
|
1010
|
+
items("center"),
|
|
1011
|
+
justify("center"),
|
|
1012
|
+
cursor("pointer"),
|
|
1013
|
+
when("& > svg", [is("1rem"), bs("1rem")]),
|
|
1014
|
+
when("&:has(input:disabled)", [cursor("not-allowed"), opacity(50)]),
|
|
1015
|
+
rounded("md"),
|
|
1016
|
+
fg("neutral.muted"),
|
|
1017
|
+
transition("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
1018
|
+
hover([bg("neutral.bg-tint-hover"), fg("neutral.emphasis")]),
|
|
1019
|
+
], children: [_jsx(PanelLeftIcon, {}), _jsx("input", { type: "checkbox", ...rest, "data-slot": "toggle", mix: [visuallyHidden(), mix] })] }));
|
|
1020
|
+
};
|
|
1021
|
+
};
|
|
1022
|
+
/**
|
|
1023
|
+
* Renders the shell's main content region: {@link ScrollArea.Viewport}
|
|
1024
|
+
* laid out as a growing flex column that resizes as {@link Sidebar}
|
|
1025
|
+
* collapses or expands, declaring {@link INSET_CONTAINER_NAME} for nested sizing.
|
|
1026
|
+
*
|
|
1027
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
1028
|
+
* @returns The render function producing the inset's markup.
|
|
1029
|
+
* @example
|
|
1030
|
+
* <Sidebar.Inset>
|
|
1031
|
+
* <Sidebar.Trigger id="app-sidebar-toggle" aria-label={t("nav.toggleSidebar")} />
|
|
1032
|
+
* <main>{children}</main>
|
|
1033
|
+
* </Sidebar.Inset>
|
|
1034
|
+
*/
|
|
1035
|
+
Sidebar.Inset = function SidebarInset(handle) {
|
|
1036
|
+
return () => {
|
|
1037
|
+
let { mix, ...rest } = handle.props;
|
|
1038
|
+
return (_jsx(ScrollArea.Viewport, { ...rest, "data-slot": "inset", mix: [
|
|
1039
|
+
flex(),
|
|
1040
|
+
flexCol(),
|
|
1041
|
+
grow(),
|
|
1042
|
+
minIs("0"),
|
|
1043
|
+
minBs("0"),
|
|
1044
|
+
bs("auto"),
|
|
1045
|
+
container(INSET_CONTAINER_NAME),
|
|
1046
|
+
bg("neutral.tint"),
|
|
1047
|
+
mix,
|
|
1048
|
+
] }));
|
|
1049
|
+
};
|
|
1050
|
+
};
|
|
1051
|
+
/**
|
|
1052
|
+
* Renders a hairline divider between two stretches of rail content:
|
|
1053
|
+
* identical to {@link Separator}, with the small block-axis and inline-axis
|
|
1054
|
+
* margins {@link Sidebar}'s own content regions expect around one.
|
|
1055
|
+
*
|
|
1056
|
+
* @param handle Runtime handle carrying the host `<div>`'s props.
|
|
1057
|
+
* @returns The render function producing the divider's markup.
|
|
1058
|
+
* @example
|
|
1059
|
+
* <Sidebar.Group>...</Sidebar.Group>
|
|
1060
|
+
* <Sidebar.Separator />
|
|
1061
|
+
* <Sidebar.Group>...</Sidebar.Group>
|
|
1062
|
+
*/
|
|
1063
|
+
Sidebar.Separator = function SidebarSeparator(handle) {
|
|
1064
|
+
return () => {
|
|
1065
|
+
let { mix, ...rest } = handle.props;
|
|
1066
|
+
return _jsx(Separator, { ...rest, "data-slot": "separator", mix: [m("0.5rem"), mix] });
|
|
1067
|
+
};
|
|
1068
|
+
};
|