@ctrl-ui/react 0.8.6 → 0.8.8
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/dist/action-bar.d.ts +15 -7
- package/dist/action-bar.js +39 -19
- package/dist/activity.js +7 -15
- package/dist/audio-recorder.d.ts +14 -4
- package/dist/audio-recorder.js +82 -29
- package/dist/audio-visualizer.js +1 -1
- package/dist/blocks/coding-agent.js +54 -57
- package/dist/blocks/design-canvas-data.d.ts +32 -0
- package/dist/blocks/design-canvas-data.js +100 -0
- package/dist/blocks/design-canvas-inspector.d.ts +8 -0
- package/dist/blocks/design-canvas-inspector.js +238 -0
- package/dist/blocks/design-canvas.d.ts +21 -0
- package/dist/blocks/design-canvas.js +452 -0
- package/dist/blocks/discussion.d.ts +28 -0
- package/dist/blocks/discussion.js +67 -0
- package/dist/blocks/file-explorer-data.d.ts +1 -0
- package/dist/blocks/file-explorer-data.js +4 -1
- package/dist/blocks/file-explorer.d.ts +9 -1
- package/dist/blocks/file-explorer.js +461 -192
- package/dist/blocks/settings.d.ts +2 -1
- package/dist/blocks/settings.js +101 -79
- package/dist/blocks/team-chat.d.ts +12 -0
- package/dist/blocks/team-chat.js +26 -0
- package/dist/blocks/theme-toggle.js +23 -31
- package/dist/chat-composer-attachment.d.ts +12 -3
- package/dist/chat-composer-attachment.js +61 -19
- package/dist/chat-composer-editor/extensions/mention.d.ts +5 -1
- package/dist/chat-composer-editor/extensions/mention.js +58 -27
- package/dist/chat-composer-editor/ghost.js +2 -4
- package/dist/chat-composer-editor/types.d.ts +5 -0
- package/dist/chat-composer-editor.d.ts +1 -1
- package/dist/chat-composer-editor.js +71 -28
- package/dist/chat-composer.d.ts +13 -32
- package/dist/chat-composer.js +54 -13
- package/dist/chat-layout.d.ts +19 -0
- package/dist/chat-layout.js +96 -32
- package/dist/chat-message/social.d.ts +26 -0
- package/dist/chat-message/social.js +122 -0
- package/dist/chat-message.d.ts +28 -29
- package/dist/chat-message.js +106 -25
- package/dist/context.d.ts +2 -2
- package/dist/context.js +38 -23
- package/dist/dynamic-notification-canvas-loop.d.ts +24 -0
- package/dist/dynamic-notification-canvas-loop.js +113 -0
- package/dist/dynamic-notification-glass.js +23 -114
- package/dist/dynamic-notification-liquid.js +14 -118
- package/dist/dynamic-notification.d.ts +16 -8
- package/dist/dynamic-notification.js +85 -22
- package/dist/email/email-brand.d.ts +7 -4
- package/dist/email/email-brand.js +9 -6
- package/dist/email/email-code.d.ts +3 -2
- package/dist/email/email-code.js +11 -9
- package/dist/email/email-footer.d.ts +5 -3
- package/dist/email/email-footer.js +11 -5
- package/dist/email/email.d.ts +31 -9
- package/dist/email/email.js +50 -26
- package/dist/email/templates.d.ts +10 -9
- package/dist/email/templates.js +102 -38
- package/dist/email/theme.js +1 -1
- package/dist/environment-variables.d.ts +4 -2
- package/dist/environment-variables.js +52 -32
- package/dist/filter-bar/context.d.ts +32 -0
- package/dist/filter-bar/context.js +11 -0
- package/dist/filter-bar/editor.d.ts +14 -0
- package/dist/filter-bar/editor.js +216 -0
- package/dist/filter-bar/model.d.ts +10 -0
- package/dist/filter-bar/model.js +57 -0
- package/dist/filter-bar/motion.d.ts +10 -0
- package/dist/filter-bar/motion.js +84 -0
- package/dist/filter-bar/parts.d.ts +19 -0
- package/dist/filter-bar/parts.js +244 -0
- package/dist/filter-bar/types.d.ts +54 -0
- package/dist/filter-bar/types.js +0 -0
- package/dist/filter-bar.d.ts +27 -0
- package/dist/filter-bar.js +310 -0
- package/dist/hooks/use-audio-recorder.js +12 -6
- package/dist/hooks/use-chat-composer.d.ts +21 -7
- package/dist/hooks/use-chat-composer.js +32 -5
- package/dist/hooks/use-chat-message.d.ts +28 -2
- package/dist/hooks/use-chat-message.js +41 -10
- package/dist/hooks/use-chat-thread-scroll.js +43 -7
- package/dist/hooks/use-color-area.d.ts +3 -3
- package/dist/hooks/use-color-area.js +13 -12
- package/dist/hooks/use-copy-to-clipboard.d.ts +2 -1
- package/dist/hooks/use-copy-to-clipboard.js +20 -20
- package/dist/hooks/use-dropzone.d.ts +7 -4
- package/dist/hooks/use-dropzone.js +34 -3
- package/dist/hooks/use-dynamic-notification.d.ts +6 -2
- package/dist/hooks/use-dynamic-notification.js +26 -10
- package/dist/hooks/use-mobile.d.ts +3 -2
- package/dist/hooks/use-mobile.js +8 -4
- package/dist/hooks/use-textarea-trigger-menu.js +2 -1
- package/dist/hooks/use-trigger-menu.d.ts +54 -0
- package/dist/hooks/use-trigger-menu.js +102 -47
- package/dist/hooks/use-user-ask.d.ts +2 -0
- package/dist/hooks/use-user-ask.js +35 -41
- package/dist/inline-attachment.d.ts +6 -2
- package/dist/inline-attachment.js +44 -29
- package/dist/inline-citation.d.ts +12 -5
- package/dist/inline-citation.js +25 -16
- package/dist/knob-contracts/audio-recorder-knobs.d.ts +1 -1
- package/dist/knob-contracts/audio-recorder-knobs.js +2 -1
- package/dist/knob-contracts/audio-visualizer-knobs.d.ts +1 -1
- package/dist/knob-contracts/audio-visualizer-knobs.js +2 -1
- package/dist/knob-contracts/avatar-knobs.d.ts +1 -1
- package/dist/knob-contracts/avatar-knobs.js +6 -1
- package/dist/knob-contracts/badge-knobs.d.ts +1 -1
- package/dist/knob-contracts/badge-knobs.js +2 -1
- package/dist/knob-contracts/breadcrumb-knobs.d.ts +4 -0
- package/dist/knob-contracts/breadcrumb-knobs.js +8 -0
- package/dist/knob-contracts/button-knobs.d.ts +1 -1
- package/dist/knob-contracts/button-knobs.js +1 -0
- package/dist/knob-contracts/chat-layout-knobs.d.ts +1 -1
- package/dist/knob-contracts/chat-layout-knobs.js +2 -1
- package/dist/knob-contracts/chat-message-knobs.d.ts +1 -1
- package/dist/knob-contracts/chat-message-knobs.js +8 -1
- package/dist/knob-contracts/choice-knobs.d.ts +1 -1
- package/dist/knob-contracts/choice-knobs.js +1 -0
- package/dist/knob-contracts/code-diff-knobs.d.ts +1 -1
- package/dist/knob-contracts/code-diff-knobs.js +2 -0
- package/dist/knob-contracts/code-knobs.d.ts +1 -1
- package/dist/knob-contracts/code-knobs.js +2 -1
- package/dist/knob-contracts/collapsible-knobs.d.ts +1 -1
- package/dist/knob-contracts/collapsible-knobs.js +1 -1
- package/dist/knob-contracts/dynamic-notification-knobs.d.ts +1 -1
- package/dist/knob-contracts/dynamic-notification-knobs.js +2 -0
- package/dist/knob-contracts/emoji-picker-knobs.d.ts +4 -0
- package/dist/knob-contracts/emoji-picker-knobs.js +10 -0
- package/dist/knob-contracts/field-knobs.d.ts +1 -1
- package/dist/knob-contracts/field-knobs.js +5 -1
- package/dist/knob-contracts/filter-bar-knobs.d.ts +4 -0
- package/dist/knob-contracts/filter-bar-knobs.js +15 -0
- package/dist/knob-contracts/infinite-canvas-knobs.d.ts +1 -1
- package/dist/knob-contracts/infinite-canvas-knobs.js +3 -0
- package/dist/knob-contracts/markdown-knobs.d.ts +1 -1
- package/dist/knob-contracts/markdown-knobs.js +3 -1
- package/dist/knob-contracts/page-layout-knobs.d.ts +1 -1
- package/dist/knob-contracts/page-layout-knobs.js +4 -1
- package/dist/knob-contracts/popup-knobs.d.ts +1 -1
- package/dist/knob-contracts/popup-knobs.js +28 -0
- package/dist/knob-contracts/range-knobs.d.ts +1 -1
- package/dist/knob-contracts/range-knobs.js +1 -0
- package/dist/knob-contracts/rich-tooltip-knobs.d.ts +1 -1
- package/dist/knob-contracts/rich-tooltip-knobs.js +2 -1
- package/dist/knob-contracts/sidebar-knobs.d.ts +1 -1
- package/dist/knob-contracts/sidebar-knobs.js +27 -2
- package/dist/knob-contracts/spinner-knobs.d.ts +1 -1
- package/dist/knob-contracts/spinner-knobs.js +1 -1
- package/dist/knob-contracts/stepper-knobs.d.ts +1 -1
- package/dist/knob-contracts/stepper-knobs.js +4 -1
- package/dist/knob-contracts/switch-knobs.d.ts +1 -1
- package/dist/knob-contracts/switch-knobs.js +5 -0
- package/dist/knob-contracts/table-of-contents-knobs.d.ts +1 -1
- package/dist/knob-contracts/table-of-contents-knobs.js +4 -5
- package/dist/knob-contracts/tabs-knobs.d.ts +1 -1
- package/dist/knob-contracts/tabs-knobs.js +1 -0
- package/dist/knob-contracts/tree-knobs.d.ts +1 -1
- package/dist/knob-contracts/tree-knobs.js +2 -1
- package/dist/lib/cn.js +0 -4
- package/dist/lib/contrast.d.ts +1 -0
- package/dist/lib/contrast.js +17 -5
- package/dist/lib/dropzone-validation.js +41 -28
- package/dist/lib/env-file.d.ts +1 -1
- package/dist/lib/env-file.js +5 -5
- package/dist/lib/motion.d.ts +4 -0
- package/dist/lib/motion.js +15 -0
- package/dist/lib/trigger-detect.js +6 -8
- package/dist/markdown-block.js +13 -8
- package/dist/popup-parts.d.ts +8 -0
- package/dist/popup-parts.js +43 -0
- package/dist/scripts/contrast-eval.js +5 -4
- package/dist/source-badge.js +3 -1
- package/dist/styles/code.css +0 -2
- package/dist/styles/effects.css +6 -32
- package/dist/styles/index.css +14 -8
- package/dist/styles/recipes/accordion.css +9 -6
- package/dist/styles/recipes/action-bar.css +0 -15
- package/dist/styles/recipes/activity.css +5 -11
- package/dist/styles/recipes/alert.css +4 -4
- package/dist/styles/recipes/audio-recorder.css +15 -3
- package/dist/styles/recipes/audio-visualizer.css +13 -2
- package/dist/styles/recipes/avatar.css +78 -1
- package/dist/styles/recipes/badge.css +14 -4
- package/dist/styles/recipes/breadcrumb.css +77 -0
- package/dist/styles/recipes/button-group.css +6 -8
- package/dist/styles/recipes/button-states.css +66 -0
- package/dist/styles/recipes/button.css +26 -85
- package/dist/styles/recipes/calendar.css +17 -23
- package/dist/styles/recipes/card.css +2 -2
- package/dist/styles/recipes/chat-composer-attachment.css +9 -3
- package/dist/styles/recipes/chat-composer.css +21 -16
- package/dist/styles/recipes/chat-layout.css +64 -2
- package/dist/styles/recipes/chat-message-social.css +123 -0
- package/dist/styles/recipes/chat-message.css +157 -37
- package/dist/styles/recipes/choice.css +25 -21
- package/dist/styles/recipes/code-diff.css +51 -26
- package/dist/styles/recipes/code.css +44 -18
- package/dist/styles/recipes/collapsible.css +43 -1
- package/dist/styles/recipes/color-picker-details.css +3 -4
- package/dist/styles/recipes/color-picker-values.css +9 -8
- package/dist/styles/recipes/color-picker.css +23 -4
- package/dist/styles/recipes/context.css +3 -3
- package/dist/styles/recipes/dockable-panel.css +18 -7
- package/dist/styles/recipes/dropzone.css +7 -8
- package/dist/styles/recipes/dynamic-notification-input.css +8 -5
- package/dist/styles/recipes/dynamic-notification-motion.css +12 -21
- package/dist/styles/recipes/dynamic-notification.css +40 -26
- package/dist/styles/recipes/emoji-picker.css +132 -0
- package/dist/styles/recipes/empty.css +5 -4
- package/dist/styles/recipes/environment-variables.css +4 -15
- package/dist/styles/recipes/field-parts.css +89 -21
- package/dist/styles/recipes/field.css +83 -26
- package/dist/styles/recipes/filter-bar.css +161 -0
- package/dist/styles/recipes/gradient-editor.css +18 -7
- package/dist/styles/recipes/infinite-canvas.css +51 -4
- package/dist/styles/recipes/inline-attachment.css +9 -4
- package/dist/styles/recipes/inline-citation.css +10 -4
- package/dist/styles/recipes/item.css +23 -9
- package/dist/styles/recipes/markdown-block.css +5 -4
- package/dist/styles/recipes/markdown.css +68 -26
- package/dist/styles/recipes/morphing-panel.css +8 -8
- package/dist/styles/recipes/page-layout.css +36 -10
- package/dist/styles/recipes/pagination.css +5 -6
- package/dist/styles/recipes/phone-input.css +12 -8
- package/dist/styles/recipes/popup-controls.css +175 -26
- package/dist/styles/recipes/popup-drawer.css +35 -44
- package/dist/styles/recipes/popup-lists.css +139 -29
- package/dist/styles/recipes/popup-motion.css +4 -45
- package/dist/styles/recipes/popup-toast.css +55 -26
- package/dist/styles/recipes/popup.css +149 -153
- package/dist/styles/recipes/range.css +55 -19
- package/dist/styles/recipes/resizable.css +36 -7
- package/dist/styles/recipes/rich-tooltip.css +24 -34
- package/dist/styles/recipes/scroll-area.css +8 -1
- package/dist/styles/recipes/sidebar-menu.css +149 -34
- package/dist/styles/recipes/sidebar-parts.css +154 -0
- package/dist/styles/recipes/sidebar.css +187 -128
- package/dist/styles/recipes/source-badge.css +1 -1
- package/dist/styles/recipes/spinner.css +12 -1
- package/dist/styles/recipes/stepper.css +31 -13
- package/dist/styles/recipes/switch.css +68 -23
- package/dist/styles/recipes/table-of-contents.css +49 -41
- package/dist/styles/recipes/table.css +14 -10
- package/dist/styles/recipes/tabs.css +38 -12
- package/dist/styles/recipes/task-list.css +7 -14
- package/dist/styles/recipes/thread-rail.css +42 -19
- package/dist/styles/recipes/timeline.css +2 -0
- package/dist/styles/recipes/toolbar.css +27 -25
- package/dist/styles/recipes/track-highlight.css +12 -8
- package/dist/styles/recipes/transcript-divider.css +2 -2
- package/dist/styles/recipes/tree.css +31 -4
- package/dist/styles/recipes/user-ask-details.css +0 -1
- package/dist/styles/recipes/user-ask.css +4 -4
- package/dist/styles/theme.css +287 -107
- package/dist/task-list.d.ts +4 -1
- package/dist/task-list.js +24 -8
- package/dist/thread-rail.d.ts +1 -1
- package/dist/thread-rail.js +61 -19
- package/dist/transcript-divider.js +2 -1
- package/dist/ui/alert.d.ts +3 -1
- package/dist/ui/alert.js +14 -8
- package/dist/ui/autocomplete.js +7 -1
- package/dist/ui/avatar.d.ts +8 -0
- package/dist/ui/avatar.js +23 -3
- package/dist/ui/badge.js +1 -1
- package/dist/ui/breadcrumb.d.ts +27 -0
- package/dist/ui/breadcrumb.js +88 -0
- package/dist/ui/button.d.ts +2 -1
- package/dist/ui/button.js +1 -1
- package/dist/ui/calendar.js +2 -2
- package/dist/ui/card.d.ts +3 -1
- package/dist/ui/card.js +12 -7
- package/dist/ui/checkbox-group.js +1 -1
- package/dist/ui/checkbox.d.ts +2 -0
- package/dist/ui/code-diff.d.ts +1 -1
- package/dist/ui/code-diff.js +71 -27
- package/dist/ui/code.d.ts +5 -3
- package/dist/ui/code.js +27 -28
- package/dist/ui/color-picker.d.ts +5 -2
- package/dist/ui/color-picker.js +84 -36
- package/dist/ui/combobox-disabled-selection.d.ts +1 -2
- package/dist/ui/combobox-disabled-selection.js +7 -8
- package/dist/ui/combobox.d.ts +5 -23
- package/dist/ui/combobox.js +36 -16
- package/dist/ui/command.d.ts +8 -2
- package/dist/ui/command.js +39 -15
- package/dist/ui/context-menu.js +3 -0
- package/dist/ui/dialog.d.ts +2 -1
- package/dist/ui/dialog.js +3 -22
- package/dist/ui/dockable-panel-geometry.d.ts +1 -0
- package/dist/ui/dockable-panel-geometry.js +7 -1
- package/dist/ui/dockable-panel.d.ts +9 -6
- package/dist/ui/dockable-panel.js +81 -33
- package/dist/ui/drawer.d.ts +7 -4
- package/dist/ui/drawer.js +35 -22
- package/dist/ui/dropdown-menu.js +4 -3
- package/dist/ui/dropzone.d.ts +5 -3
- package/dist/ui/dropzone.js +78 -17
- package/dist/ui/emoji-picker.d.ts +18 -0
- package/dist/ui/emoji-picker.js +136 -0
- package/dist/ui/empty.d.ts +3 -1
- package/dist/ui/empty.js +12 -7
- package/dist/ui/field.js +1 -1
- package/dist/ui/gradient-editor.d.ts +1 -1
- package/dist/ui/gradient-editor.js +37 -21
- package/dist/ui/infinite-canvas.d.ts +13 -1
- package/dist/ui/infinite-canvas.js +139 -20
- package/dist/ui/input-group.d.ts +2 -4
- package/dist/ui/input-group.js +13 -14
- package/dist/ui/input-otp.d.ts +1 -1
- package/dist/ui/input-otp.js +32 -15
- package/dist/ui/input.js +11 -2
- package/dist/ui/item.d.ts +2 -1
- package/dist/ui/item.js +11 -7
- package/dist/ui/live-status.d.ts +7 -0
- package/dist/ui/live-status.js +17 -0
- package/dist/ui/markdown-elements.d.ts +6 -0
- package/dist/ui/markdown-elements.js +42 -9
- package/dist/ui/menubar.js +2 -2
- package/dist/ui/morphing-panel.js +2 -1
- package/dist/ui/native-select.d.ts +1 -1
- package/dist/ui/native-select.js +24 -11
- package/dist/ui/number-field.d.ts +1 -1
- package/dist/ui/number-field.js +13 -2
- package/dist/ui/page-layout.d.ts +2 -2
- package/dist/ui/page-layout.js +2 -4
- package/dist/ui/pagination.d.ts +7 -5
- package/dist/ui/pagination.js +19 -13
- package/dist/ui/phone-input.d.ts +1 -0
- package/dist/ui/phone-input.js +56 -58
- package/dist/ui/radio-group.d.ts +3 -0
- package/dist/ui/radio-group.js +11 -1
- package/dist/ui/resizable.d.ts +20 -2
- package/dist/ui/resizable.js +130 -8
- package/dist/ui/responsive-dialog.d.ts +1 -1
- package/dist/ui/responsive-dialog.js +9 -23
- package/dist/ui/rich-tooltip.d.ts +10 -4
- package/dist/ui/rich-tooltip.js +81 -33
- package/dist/ui/scroll-area.d.ts +4 -1
- package/dist/ui/scroll-area.js +44 -28
- package/dist/ui/select.d.ts +2 -1
- package/dist/ui/select.js +57 -32
- package/dist/ui/sidebar-menu.d.ts +5 -1
- package/dist/ui/sidebar-menu.js +31 -33
- package/dist/ui/sidebar-provider.d.ts +10 -1
- package/dist/ui/sidebar-provider.js +38 -13
- package/dist/ui/sidebar-resize-rail.js +7 -3
- package/dist/ui/sidebar.d.ts +11 -6
- package/dist/ui/sidebar.js +46 -23
- package/dist/ui/slider.js +31 -22
- package/dist/ui/spinner.d.ts +3 -2
- package/dist/ui/spinner.js +3 -2
- package/dist/ui/stepper.d.ts +8 -1
- package/dist/ui/stepper.js +74 -25
- package/dist/ui/switch.d.ts +1 -0
- package/dist/ui/table-of-contents.d.ts +5 -4
- package/dist/ui/table-of-contents.js +143 -52
- package/dist/ui/table.js +15 -9
- package/dist/ui/textarea.d.ts +1 -1
- package/dist/ui/textarea.js +20 -9
- package/dist/ui/timeline.d.ts +3 -1
- package/dist/ui/timeline.js +17 -9
- package/dist/ui/toast.d.ts +11 -5
- package/dist/ui/toast.js +100 -54
- package/dist/ui/toggle.d.ts +1 -1
- package/dist/ui/toggle.js +2 -1
- package/dist/ui/toolbar.d.ts +3 -2
- package/dist/ui/toolbar.js +4 -2
- package/dist/ui/tooltip.js +3 -20
- package/dist/ui/tree.js +120 -80
- package/dist/ui/trigger-menu.js +7 -2
- package/dist/user-ask.d.ts +10 -5
- package/dist/user-ask.js +31 -11
- package/package.json +5 -1
- package/dist/hooks/use-keyboard-navigation.d.ts +0 -3
- package/dist/hooks/use-keyboard-navigation.js +0 -22
package/dist/ui/scroll-area.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
import { useSkin } from "../skin-provider.js";
|
|
4
4
|
import { ProgressiveBlur } from "./progressive-blur.js";
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import { ScrollArea as ScrollArea$1 } from "@base-ui/react/scroll-area";
|
|
7
7
|
//#region src/ui/scroll-area.tsx
|
|
8
8
|
const scrollAreaScrollbarVisibilities = [
|
|
@@ -27,25 +27,54 @@ function Scrollbar({ orientation, visibility, thumbStyle }) {
|
|
|
27
27
|
})
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
function viewportStyle(maxHeight, lockX, lockY) {
|
|
31
|
-
if (!maxHeight && !lockX && !lockY) return
|
|
30
|
+
function viewportStyle(baseStyle, maxHeight, lockX, lockY) {
|
|
31
|
+
if (!maxHeight && !lockX && !lockY) return baseStyle;
|
|
32
32
|
return {
|
|
33
|
+
...baseStyle,
|
|
33
34
|
...maxHeight ? { maxHeight } : {},
|
|
34
35
|
...lockX ? { overflowX: "hidden" } : {},
|
|
35
36
|
...lockY ? { overflowY: "hidden" } : {}
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
|
-
function
|
|
39
|
+
function regionProps(ariaLabel, ariaLabelledby) {
|
|
40
|
+
if (!ariaLabel && !ariaLabelledby) return {};
|
|
41
|
+
return {
|
|
42
|
+
role: "region",
|
|
43
|
+
"aria-label": ariaLabel,
|
|
44
|
+
"aria-labelledby": ariaLabelledby
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function EdgeBlurs({ blurProps, lockX, lockY }) {
|
|
48
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
49
|
+
!lockY && /* @__PURE__ */ jsx(ProgressiveBlur, {
|
|
50
|
+
...blurProps,
|
|
51
|
+
side: "top",
|
|
52
|
+
visible: false
|
|
53
|
+
}),
|
|
54
|
+
!lockY && /* @__PURE__ */ jsx(ProgressiveBlur, {
|
|
55
|
+
...blurProps,
|
|
56
|
+
side: "bottom",
|
|
57
|
+
visible: false
|
|
58
|
+
}),
|
|
59
|
+
!lockX && /* @__PURE__ */ jsx(ProgressiveBlur, {
|
|
60
|
+
...blurProps,
|
|
61
|
+
side: "inline-start",
|
|
62
|
+
visible: false
|
|
63
|
+
}),
|
|
64
|
+
!lockX && /* @__PURE__ */ jsx(ProgressiveBlur, {
|
|
65
|
+
...blurProps,
|
|
66
|
+
side: "inline-end",
|
|
67
|
+
visible: false
|
|
68
|
+
})
|
|
69
|
+
] });
|
|
70
|
+
}
|
|
71
|
+
function ScrollArea({ className, viewportClassName, contentClassName, viewportProps, viewportRef, maxHeight, mask = true, blur, blurProps, lockAxis, scrollbarVisibility = "hover", children, style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...props }) {
|
|
39
72
|
const skin = useSkin();
|
|
40
73
|
const resolvedBlur = blur ?? skin.scrollAreaBlur ?? false;
|
|
41
74
|
const lockX = lockAxis === "x" || lockAxis === "both";
|
|
42
75
|
const lockY = lockAxis === "y" || lockAxis === "both";
|
|
43
|
-
const resolvedViewportStyle = viewportStyle(maxHeight, lockX, lockY);
|
|
44
76
|
const { style: viewportPropsStyle, ...resolvedViewportProps } = viewportProps ?? {};
|
|
45
|
-
const mergedViewportStyle = viewportPropsStyle
|
|
46
|
-
...viewportPropsStyle,
|
|
47
|
-
...resolvedViewportStyle
|
|
48
|
-
} : void 0;
|
|
77
|
+
const mergedViewportStyle = viewportStyle(viewportPropsStyle, maxHeight, lockX, lockY);
|
|
49
78
|
const thumbStyle = style;
|
|
50
79
|
const cornerStyle = style;
|
|
51
80
|
return /* @__PURE__ */ jsxs(ScrollArea$1.Root, {
|
|
@@ -64,6 +93,7 @@ function ScrollArea({ className, viewportClassName, viewportProps, viewportRef,
|
|
|
64
93
|
"data-control-family": "scroll-area",
|
|
65
94
|
"data-slot": "viewport",
|
|
66
95
|
...resolvedViewportProps,
|
|
96
|
+
...regionProps(ariaLabel, ariaLabelledby),
|
|
67
97
|
"data-scroll-area-viewport": "",
|
|
68
98
|
ref: viewportRef,
|
|
69
99
|
className: cn("h-full w-full", viewportClassName),
|
|
@@ -72,29 +102,15 @@ function ScrollArea({ className, viewportClassName, viewportProps, viewportRef,
|
|
|
72
102
|
"data-control-ui": "scroll-area",
|
|
73
103
|
"data-control-family": "scroll-area",
|
|
74
104
|
"data-slot": "content",
|
|
105
|
+
className: contentClassName,
|
|
75
106
|
style: { minWidth: 0 },
|
|
76
107
|
children
|
|
77
108
|
})
|
|
78
109
|
}),
|
|
79
|
-
resolvedBlur &&
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}),
|
|
84
|
-
resolvedBlur && !lockY && /* @__PURE__ */ jsx(ProgressiveBlur, {
|
|
85
|
-
...blurProps,
|
|
86
|
-
side: "bottom",
|
|
87
|
-
visible: false
|
|
88
|
-
}),
|
|
89
|
-
resolvedBlur && !lockX && /* @__PURE__ */ jsx(ProgressiveBlur, {
|
|
90
|
-
...blurProps,
|
|
91
|
-
side: "inline-start",
|
|
92
|
-
visible: false
|
|
93
|
-
}),
|
|
94
|
-
resolvedBlur && !lockX && /* @__PURE__ */ jsx(ProgressiveBlur, {
|
|
95
|
-
...blurProps,
|
|
96
|
-
side: "inline-end",
|
|
97
|
-
visible: false
|
|
110
|
+
resolvedBlur && /* @__PURE__ */ jsx(EdgeBlurs, {
|
|
111
|
+
blurProps,
|
|
112
|
+
lockX,
|
|
113
|
+
lockY
|
|
98
114
|
}),
|
|
99
115
|
!lockY && /* @__PURE__ */ jsx(Scrollbar, {
|
|
100
116
|
orientation: "vertical",
|
package/dist/ui/select.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ControlledChoice } from "../control-props.js";
|
|
|
2
2
|
import { ControlSize } from "../control-variants.js";
|
|
3
3
|
import { ButtonKnobStyle } from "../knob-contracts/button-knobs.js";
|
|
4
4
|
import { PopupKnobStyle } from "../knob-contracts/popup-knobs.js";
|
|
5
|
+
import { FieldKnobStyle } from "../knob-contracts/field-knobs.js";
|
|
5
6
|
import { CSSProperties, ComponentProps, ReactNode } from "react";
|
|
6
7
|
import { Select as Select$1 } from "@base-ui/react/select";
|
|
7
8
|
//#region src/ui/select.d.ts
|
|
@@ -21,7 +22,7 @@ export type SelectProps<TValue extends string = string> = Omit<ControlledChoice<
|
|
|
21
22
|
export declare const selectTriggerVariants: readonly ["surface", "ghost"];
|
|
22
23
|
export type SelectTriggerVariant = (typeof selectTriggerVariants)[number];
|
|
23
24
|
export type SelectTriggerProps = Omit<ComponentProps<"button">, "style"> & {
|
|
24
|
-
style?: CSSProperties & ButtonKnobStyle;
|
|
25
|
+
style?: CSSProperties & FieldKnobStyle & ButtonKnobStyle;
|
|
25
26
|
} & {
|
|
26
27
|
size?: ControlSize;
|
|
27
28
|
variant?: SelectTriggerVariant;
|
package/dist/ui/select.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
import { controlEffectsAttribute } from "../skin.js";
|
|
4
4
|
import { useSkin } from "../skin-provider.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { ScrollArea } from "./scroll-area.js";
|
|
5
7
|
import { popupItemStructureClasses } from "../surface-variants.js";
|
|
6
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
9
|
import { Select as Select$1 } from "@base-ui/react/select";
|
|
@@ -16,46 +18,58 @@ function Select({ children, onValueChange, ...props }) {
|
|
|
16
18
|
children
|
|
17
19
|
});
|
|
18
20
|
}
|
|
21
|
+
const selectTriggerLayoutClasses = "group relative isolate inline-flex shrink-0 items-center justify-between overflow-visible";
|
|
22
|
+
function SelectIcon() {
|
|
23
|
+
return /* @__PURE__ */ jsx(Select$1.Icon, {
|
|
24
|
+
"data-control-ui": "select",
|
|
25
|
+
"data-control-family": "popup",
|
|
26
|
+
"data-popup-kind": "select",
|
|
27
|
+
"data-slot": "icon",
|
|
28
|
+
className: "relative z-[1]",
|
|
29
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
30
|
+
viewBox: "0 0 12 12",
|
|
31
|
+
className: "size-3",
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
fill: "none",
|
|
34
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
35
|
+
d: "M3 4.5 6 7.5 9 4.5",
|
|
36
|
+
stroke: "currentColor",
|
|
37
|
+
strokeWidth: "1.3",
|
|
38
|
+
strokeLinecap: "round",
|
|
39
|
+
strokeLinejoin: "round"
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
});
|
|
43
|
+
}
|
|
19
44
|
function SelectTrigger({ size = "sm", variant = "surface", className, children, disabled, ...props }) {
|
|
45
|
+
if (variant === "ghost") return /* @__PURE__ */ jsxs(Select$1.Trigger, {
|
|
46
|
+
render: /* @__PURE__ */ jsx(Button, {
|
|
47
|
+
variant: "ghost",
|
|
48
|
+
size
|
|
49
|
+
}),
|
|
50
|
+
className: cn(selectTriggerLayoutClasses, className),
|
|
51
|
+
disabled,
|
|
52
|
+
...props,
|
|
53
|
+
children: [children, /* @__PURE__ */ jsx(SelectIcon, {})]
|
|
54
|
+
});
|
|
20
55
|
return /* @__PURE__ */ jsxs(Select$1.Trigger, {
|
|
21
56
|
"data-control-ui": "select",
|
|
22
|
-
"data-control-family": "
|
|
23
|
-
"data-
|
|
57
|
+
"data-control-family": "field",
|
|
58
|
+
"data-field-kind": "select",
|
|
24
59
|
"data-slot": "trigger",
|
|
25
60
|
"data-control": "true",
|
|
26
61
|
"data-size": size,
|
|
27
|
-
|
|
28
|
-
"data-tone": "neutral",
|
|
29
|
-
"data-shape": "default",
|
|
30
|
-
className: cn("group relative isolate inline-flex shrink-0 items-center justify-between overflow-visible", className),
|
|
62
|
+
className: cn(selectTriggerLayoutClasses, className),
|
|
31
63
|
disabled,
|
|
32
64
|
...props,
|
|
33
65
|
children: [/* @__PURE__ */ jsx("span", {
|
|
34
|
-
"data-control-ui": "button",
|
|
35
|
-
"data-control-family": "button",
|
|
36
|
-
"data-slot": "content",
|
|
37
|
-
className: "relative z-[1] inline-flex min-w-0 items-center justify-center gap-[inherit]",
|
|
38
|
-
children
|
|
39
|
-
}), /* @__PURE__ */ jsx(Select$1.Icon, {
|
|
40
66
|
"data-control-ui": "select",
|
|
41
|
-
"data-control-family": "
|
|
42
|
-
"data-
|
|
43
|
-
"data-slot": "
|
|
44
|
-
className: "
|
|
45
|
-
children
|
|
46
|
-
|
|
47
|
-
className: "size-3",
|
|
48
|
-
"aria-hidden": "true",
|
|
49
|
-
fill: "none",
|
|
50
|
-
children: /* @__PURE__ */ jsx("path", {
|
|
51
|
-
d: "M3 4.5 6 7.5 9 4.5",
|
|
52
|
-
stroke: "currentColor",
|
|
53
|
-
strokeWidth: "1.3",
|
|
54
|
-
strokeLinecap: "round",
|
|
55
|
-
strokeLinejoin: "round"
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
})]
|
|
67
|
+
"data-control-family": "field",
|
|
68
|
+
"data-field-kind": "select",
|
|
69
|
+
"data-slot": "value",
|
|
70
|
+
className: "inline-flex min-w-0 items-center gap-[inherit]",
|
|
71
|
+
children
|
|
72
|
+
}), /* @__PURE__ */ jsx(SelectIcon, {})]
|
|
59
73
|
});
|
|
60
74
|
}
|
|
61
75
|
function SelectValue({ children, ...props }) {
|
|
@@ -82,12 +96,19 @@ function SelectContent({ className, children, alignItemWithTrigger = false, ...p
|
|
|
82
96
|
"data-surface": "floating",
|
|
83
97
|
"data-control-family": "popup",
|
|
84
98
|
"data-popup-part": "list-surface",
|
|
85
|
-
className: cn("max-h-[min(20rem,var(--available-height))] min-w-[var(--anchor-width)]
|
|
99
|
+
className: cn("grid max-h-[min(20rem,var(--available-height))] min-w-[var(--anchor-width)] grid-rows-[minmax(0,1fr)]", className),
|
|
86
100
|
...props,
|
|
87
|
-
children
|
|
101
|
+
children: /* @__PURE__ */ jsx(ScrollArea, {
|
|
102
|
+
lockAxis: "x",
|
|
103
|
+
viewportProps: { render: renderListAsScrollViewport },
|
|
104
|
+
children
|
|
105
|
+
})
|
|
88
106
|
})
|
|
89
107
|
}) });
|
|
90
108
|
}
|
|
109
|
+
function renderListAsScrollViewport({ role: _role, tabIndex: _tabIndex, ...viewportProps }) {
|
|
110
|
+
return /* @__PURE__ */ jsx(Select$1.List, { ...viewportProps });
|
|
111
|
+
}
|
|
91
112
|
function SelectItem({ className, children, disabled, ...props }) {
|
|
92
113
|
return /* @__PURE__ */ jsxs(Select$1.Item, {
|
|
93
114
|
"data-control-ui": "select",
|
|
@@ -99,6 +120,10 @@ function SelectItem({ className, children, disabled, ...props }) {
|
|
|
99
120
|
className: cn(popupItemStructureClasses, className),
|
|
100
121
|
...props,
|
|
101
122
|
children: [/* @__PURE__ */ jsx(Select$1.ItemText, {
|
|
123
|
+
"data-control-ui": "select",
|
|
124
|
+
"data-control-family": "popup",
|
|
125
|
+
"data-popup-kind": "select",
|
|
126
|
+
"data-slot": "item-text",
|
|
102
127
|
className: "flex min-w-0 flex-1 items-center",
|
|
103
128
|
children
|
|
104
129
|
}), /* @__PURE__ */ jsx("span", {
|
|
@@ -43,6 +43,10 @@ export declare function SidebarMenu({ className, indicator, style, children, ...
|
|
|
43
43
|
export declare function SidebarMenuItem({ className, ...props }: ComponentProps<"li"> & {
|
|
44
44
|
style?: CSSProperties & SidebarKnobStyle;
|
|
45
45
|
}): import("react").JSX.Element;
|
|
46
|
-
export
|
|
46
|
+
export type SidebarMenuBadgeProps = Omit<ComponentProps<"div">, "style"> & {
|
|
47
|
+
style?: CSSProperties & SidebarKnobStyle;
|
|
48
|
+
};
|
|
49
|
+
export declare function SidebarMenuBadge({ className, ...props }: SidebarMenuBadgeProps): import("react").JSX.Element;
|
|
50
|
+
export declare function SidebarMenuButton({ render, isActive, variant, size, tooltip, className, children, ref, ...props }: SidebarMenuButtonProps): import("react").JSX.Element;
|
|
47
51
|
export declare function SidebarMenuSub({ className, ...props }: ComponentProps<typeof SidebarMenu>): import("react").JSX.Element;
|
|
48
52
|
//#endregion
|
package/dist/ui/sidebar-menu.js
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
import { useSkin } from "../skin-provider.js";
|
|
4
4
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
5
|
-
import { useSidebar } from "./sidebar-provider.js";
|
|
5
|
+
import { SidebarSurfaceContext, useSidebar } from "./sidebar-provider.js";
|
|
6
6
|
import { TrackHighlight } from "../extensions/track-highlight.js";
|
|
7
|
-
import { createContext, useContext } from "react";
|
|
7
|
+
import { createContext, useContext, useRef, useState } from "react";
|
|
8
8
|
import { useRender } from "@base-ui/react/use-render";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
-
import { cva } from "class-variance-authority";
|
|
11
10
|
//#region src/ui/sidebar-menu.tsx
|
|
12
11
|
const sidebarMenuButtonVariants = ["default", "outline"];
|
|
13
12
|
const sidebarMenuButtonSizes = [
|
|
@@ -102,31 +101,28 @@ function SidebarMenuItem({ className, ...props }) {
|
|
|
102
101
|
...props
|
|
103
102
|
});
|
|
104
103
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
defaultVariants: {
|
|
118
|
-
variant: "default",
|
|
119
|
-
size: "default"
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
function SidebarMenuButton({ render, isActive = false, variant = "default", size = "default", tooltip, className, children, ...props }) {
|
|
104
|
+
function SidebarMenuBadge({ className, ...props }) {
|
|
105
|
+
return /* @__PURE__ */ jsx("div", {
|
|
106
|
+
"data-control-ui": "sidebar",
|
|
107
|
+
"data-control-family": "sidebar",
|
|
108
|
+
"data-slot": "menu-badge",
|
|
109
|
+
className: cn("pointer-events-none absolute flex -translate-y-1/2 select-none items-center justify-center tabular-nums group-data-[collapsible=icon]:hidden", className),
|
|
110
|
+
...props
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function SidebarMenuButton({ render, isActive = false, variant = "default", size = "default", tooltip, className, children, ref, ...props }) {
|
|
123
114
|
const { isMobile, state } = useSidebar();
|
|
115
|
+
const surface = useContext(SidebarSurfaceContext);
|
|
124
116
|
const indicator = useContext(SidebarMenuContext);
|
|
117
|
+
const buttonRef = useRef(null);
|
|
118
|
+
const [textLabel, setTextLabel] = useState("");
|
|
125
119
|
const button = useRender({
|
|
126
120
|
defaultTagName: "button",
|
|
127
121
|
render,
|
|
122
|
+
ref: [ref ?? null, buttonRef],
|
|
128
123
|
props: {
|
|
129
124
|
type: "button",
|
|
125
|
+
"aria-current": isActive ? "page" : void 0,
|
|
130
126
|
...props,
|
|
131
127
|
"data-control-ui": "sidebar",
|
|
132
128
|
"data-control-family": "sidebar",
|
|
@@ -135,20 +131,22 @@ function SidebarMenuButton({ render, isActive = false, variant = "default", size
|
|
|
135
131
|
"data-variant": variant,
|
|
136
132
|
"data-active": isActive || void 0,
|
|
137
133
|
"data-track-item": indicator !== "none" ? "" : void 0,
|
|
138
|
-
className: cn(
|
|
139
|
-
variant,
|
|
140
|
-
size
|
|
141
|
-
}), className),
|
|
134
|
+
className: cn("peer/menu-button flex w-full items-center overflow-hidden text-start group-data-[collapsible=icon]:w-(--cui-sidebar-menu-button-height) disabled:pointer-events-none aria-disabled:pointer-events-none [&>span]:truncate [&>svg]:size-4 [&>svg]:shrink-0", className),
|
|
142
135
|
children
|
|
143
136
|
}
|
|
144
137
|
});
|
|
145
|
-
if (!tooltip) return button;
|
|
146
|
-
return /* @__PURE__ */ jsxs(Tooltip, {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
children:
|
|
151
|
-
|
|
138
|
+
if (!tooltip && surface?.collapsible !== "icon") return button;
|
|
139
|
+
return /* @__PURE__ */ jsxs(Tooltip, {
|
|
140
|
+
onOpenChange: (open) => {
|
|
141
|
+
if (open && !tooltip) setTextLabel(buttonRef.current?.textContent?.trim() ?? "");
|
|
142
|
+
},
|
|
143
|
+
children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: button }), /* @__PURE__ */ jsx(TooltipContent, {
|
|
144
|
+
side: surface?.side === "right" ? "inline-start" : "inline-end",
|
|
145
|
+
align: "center",
|
|
146
|
+
hidden: state !== "collapsed" || isMobile,
|
|
147
|
+
children: tooltip ?? textLabel
|
|
148
|
+
})]
|
|
149
|
+
});
|
|
152
150
|
}
|
|
153
151
|
function SidebarMenuSub({ className, ...props }) {
|
|
154
152
|
return /* @__PURE__ */ jsx(SidebarMenu, {
|
|
@@ -158,4 +156,4 @@ function SidebarMenuSub({ className, ...props }) {
|
|
|
158
156
|
});
|
|
159
157
|
}
|
|
160
158
|
//#endregion
|
|
161
|
-
export { SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, sidebarMenuButtonSizes, sidebarMenuButtonVariants };
|
|
159
|
+
export { SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, sidebarMenuButtonSizes, sidebarMenuButtonVariants };
|
|
@@ -5,6 +5,7 @@ export type SidebarStyle = CSSProperties & SidebarKnobStyle & {
|
|
|
5
5
|
"--sidebar-width"?: string;
|
|
6
6
|
"--sidebar-width-icon"?: string;
|
|
7
7
|
};
|
|
8
|
+
export type SidebarLayoutMode = "viewport" | "contained";
|
|
8
9
|
type SidebarContextProps = {
|
|
9
10
|
state: "expanded" | "collapsed";
|
|
10
11
|
open: boolean;
|
|
@@ -17,12 +18,17 @@ type SidebarContextProps = {
|
|
|
17
18
|
minWidth: number;
|
|
18
19
|
maxWidth: number;
|
|
19
20
|
setWidth: (width: number) => void;
|
|
21
|
+
layout: SidebarLayoutMode;
|
|
22
|
+
keyboardShortcut: string | null;
|
|
23
|
+
sidebarId: string;
|
|
24
|
+
contentId: string;
|
|
20
25
|
};
|
|
21
26
|
type SidebarElements = {
|
|
22
27
|
wrapperRef: RefObject<HTMLDivElement | null>;
|
|
23
28
|
offcanvasRef: RefObject<HTMLDivElement | null>;
|
|
24
29
|
railRef: RefObject<HTMLElement | null>;
|
|
25
30
|
triggerRef: RefObject<HTMLButtonElement | null>;
|
|
31
|
+
insetRef: RefObject<HTMLElement | null>;
|
|
26
32
|
};
|
|
27
33
|
export declare const SidebarSurfaceContext: import("react").Context<{
|
|
28
34
|
side: "left" | "right";
|
|
@@ -47,7 +53,10 @@ export type SidebarProviderProps = Omit<ComponentProps<"div">, "style"> & {
|
|
|
47
53
|
onWidthChange?: (width: number) => void;
|
|
48
54
|
persistOpen?: boolean;
|
|
49
55
|
keyboardShortcut?: string | null;
|
|
56
|
+
layout?: SidebarLayoutMode;
|
|
57
|
+
skipLinkLabel?: string;
|
|
58
|
+
contentId?: string;
|
|
50
59
|
style?: SidebarStyle;
|
|
51
60
|
};
|
|
52
|
-
export declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange, defaultWidth, minWidth, maxWidth, width: widthProp, onWidthChange, persistOpen, keyboardShortcut, ref, className, style, children, ...props }: SidebarProviderProps): import("react").JSX.Element;
|
|
61
|
+
export declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange, defaultWidth, minWidth, maxWidth, width: widthProp, onWidthChange, persistOpen, keyboardShortcut, layout, skipLinkLabel, contentId: contentIdProp, ref, className, style, children, ...props }: SidebarProviderProps): import("react").JSX.Element;
|
|
53
62
|
//#endregion
|
|
@@ -4,15 +4,15 @@ import { useSkin } from "../skin-provider.js";
|
|
|
4
4
|
import { SIDEBAR_COOKIE_NAME } from "../control-props.js";
|
|
5
5
|
import { TooltipProvider } from "./tooltip.js";
|
|
6
6
|
import { useIsMobile } from "../hooks/use-mobile.js";
|
|
7
|
-
import { createContext, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
7
|
+
import { createContext, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
8
8
|
import { useRender } from "@base-ui/react/use-render";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
//#region src/ui/sidebar-provider.tsx
|
|
11
11
|
const SIDEBAR_COOKIE_MAX_AGE = 604800;
|
|
12
12
|
const SIDEBAR_WIDTH = "16rem";
|
|
13
13
|
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
14
14
|
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
15
|
-
const SIDEBAR_MOBILE_BREAKPOINT =
|
|
15
|
+
const SIDEBAR_MOBILE_BREAKPOINT = "--breakpoint-lg";
|
|
16
16
|
const SidebarElementsContext = createContext(null);
|
|
17
17
|
const SidebarSurfaceContext = createContext(null);
|
|
18
18
|
function useSidebarElements() {
|
|
@@ -38,7 +38,7 @@ function useSidebar() {
|
|
|
38
38
|
if (!context) throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
39
39
|
return context;
|
|
40
40
|
}
|
|
41
|
-
function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, defaultWidth, minWidth = 224, maxWidth = 420, width: widthProp, onWidthChange, persistOpen = true, keyboardShortcut = SIDEBAR_KEYBOARD_SHORTCUT, ref, className, style, children, ...props }) {
|
|
41
|
+
function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, defaultWidth, minWidth = 224, maxWidth = 420, width: widthProp, onWidthChange, persistOpen = true, keyboardShortcut = SIDEBAR_KEYBOARD_SHORTCUT, layout = "viewport", skipLinkLabel = "Skip to content", contentId: contentIdProp, ref, className, style, children, ...props }) {
|
|
42
42
|
const skin = useSkin();
|
|
43
43
|
const isMobile = useIsMobile(SIDEBAR_MOBILE_BREAKPOINT);
|
|
44
44
|
const [openMobile, setOpenMobile] = useState(false);
|
|
@@ -46,12 +46,17 @@ function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, def
|
|
|
46
46
|
const offcanvasRef = useRef(null);
|
|
47
47
|
const railRef = useRef(null);
|
|
48
48
|
const triggerRef = useRef(null);
|
|
49
|
+
const insetRef = useRef(null);
|
|
49
50
|
const elements = {
|
|
50
51
|
wrapperRef,
|
|
51
52
|
offcanvasRef,
|
|
52
53
|
railRef,
|
|
53
|
-
triggerRef
|
|
54
|
+
triggerRef,
|
|
55
|
+
insetRef
|
|
54
56
|
};
|
|
57
|
+
const sidebarId = useId();
|
|
58
|
+
const generatedContentId = useId();
|
|
59
|
+
const contentId = contentIdProp ?? generatedContentId;
|
|
55
60
|
const [internalWidth, setInternalWidth] = useState(defaultWidth);
|
|
56
61
|
function clampWidth(nextWidth) {
|
|
57
62
|
return Math.min(maxWidth, Math.max(minWidth, nextWidth));
|
|
@@ -67,7 +72,6 @@ function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, def
|
|
|
67
72
|
const open = openProp ?? internalOpen;
|
|
68
73
|
useLayoutEffect(() => {
|
|
69
74
|
if (!open && !isMobile) focusOutsideCollapsedContent({
|
|
70
|
-
wrapperRef,
|
|
71
75
|
offcanvasRef,
|
|
72
76
|
railRef,
|
|
73
77
|
triggerRef
|
|
@@ -87,11 +91,14 @@ function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, def
|
|
|
87
91
|
});
|
|
88
92
|
useEffect(() => {
|
|
89
93
|
if (keyboardShortcut === null) return;
|
|
94
|
+
const shortcut = keyboardShortcut.toLowerCase();
|
|
90
95
|
const handleKeyDown = (event) => {
|
|
91
|
-
if (event.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
if (event.defaultPrevented || event.repeat || event.altKey || event.shiftKey) return;
|
|
97
|
+
if (!(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== shortcut) return;
|
|
98
|
+
const target = event.target;
|
|
99
|
+
if (target instanceof HTMLElement && (target.isContentEditable || target.closest("input, textarea, select") !== null)) return;
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
toggleRef.current();
|
|
95
102
|
};
|
|
96
103
|
window.addEventListener("keydown", handleKeyDown);
|
|
97
104
|
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
@@ -107,7 +114,11 @@ function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, def
|
|
|
107
114
|
width,
|
|
108
115
|
setWidth,
|
|
109
116
|
minWidth,
|
|
110
|
-
maxWidth
|
|
117
|
+
maxWidth,
|
|
118
|
+
layout,
|
|
119
|
+
keyboardShortcut,
|
|
120
|
+
sidebarId,
|
|
121
|
+
contentId
|
|
111
122
|
};
|
|
112
123
|
const wrapperStyle = {
|
|
113
124
|
"--sidebar-width": skin.sidebarWidth ?? SIDEBAR_WIDTH,
|
|
@@ -115,6 +126,12 @@ function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, def
|
|
|
115
126
|
...style,
|
|
116
127
|
...width === void 0 ? {} : { "--sidebar-width": `${width}px` }
|
|
117
128
|
};
|
|
129
|
+
function skipToContent(event) {
|
|
130
|
+
const inset = insetRef.current;
|
|
131
|
+
if (!inset) return;
|
|
132
|
+
event.preventDefault();
|
|
133
|
+
inset.focus();
|
|
134
|
+
}
|
|
118
135
|
const wrapper = useRender({
|
|
119
136
|
defaultTagName: "div",
|
|
120
137
|
ref: [ref ?? null, wrapperRef],
|
|
@@ -123,9 +140,17 @@ function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, def
|
|
|
123
140
|
"data-control-ui": "sidebar",
|
|
124
141
|
"data-control-family": "sidebar",
|
|
125
142
|
"data-slot": "wrapper",
|
|
143
|
+
"data-layout": layout,
|
|
126
144
|
style: wrapperStyle,
|
|
127
|
-
className: cn("group/sidebar-wrapper flex min-h-
|
|
128
|
-
children
|
|
145
|
+
className: cn("group/sidebar-wrapper relative flex w-full", layout === "contained" ? "h-full min-h-0 overflow-hidden" : "min-h-svh", className),
|
|
146
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("a", {
|
|
147
|
+
href: `#${contentId}`,
|
|
148
|
+
"data-control-ui": "sidebar",
|
|
149
|
+
"data-control-family": "sidebar",
|
|
150
|
+
"data-slot": "skip-link",
|
|
151
|
+
onClick: skipToContent,
|
|
152
|
+
children: skipLinkLabel
|
|
153
|
+
}), children] })
|
|
129
154
|
}
|
|
130
155
|
});
|
|
131
156
|
return /* @__PURE__ */ jsx(SidebarContext.Provider, {
|
|
@@ -28,6 +28,9 @@ function SidebarResizeRail({ className, ref, onPointerDown, onClick, onKeyDown,
|
|
|
28
28
|
function clampWidth(nextWidth) {
|
|
29
29
|
return Math.min(maxWidth, Math.max(minWidth, nextWidth));
|
|
30
30
|
}
|
|
31
|
+
function anchoredToLeftEdge(element) {
|
|
32
|
+
return side === "left" === (getComputedStyle(element).direction !== "rtl");
|
|
33
|
+
}
|
|
31
34
|
function handlePointerDown(event) {
|
|
32
35
|
onPointerDown?.(event);
|
|
33
36
|
if (event.defaultPrevented || event.button !== 0) return;
|
|
@@ -43,6 +46,7 @@ function SidebarResizeRail({ className, ref, onPointerDown, onClick, onKeyDown,
|
|
|
43
46
|
handle.setPointerCapture(event.pointerId);
|
|
44
47
|
const pointerId = event.pointerId;
|
|
45
48
|
const startX = event.clientX;
|
|
49
|
+
const anchoredLeft = anchoredToLeftEdge(handle);
|
|
46
50
|
const wrapperBounds = wrapper.getBoundingClientRect();
|
|
47
51
|
const initialWidth = measure.getBoundingClientRect().width;
|
|
48
52
|
const previousWidth = wrapper.style.getPropertyValue("--sidebar-width");
|
|
@@ -88,7 +92,7 @@ function SidebarResizeRail({ className, ref, onPointerDown, onClick, onKeyDown,
|
|
|
88
92
|
document.body.style.userSelect = "none";
|
|
89
93
|
wrapper.setAttribute("data-resizing", "true");
|
|
90
94
|
handle.setAttribute("data-resizing", "true");
|
|
91
|
-
const cursorWidth =
|
|
95
|
+
const cursorWidth = anchoredLeft ? pointer.clientX - wrapperBounds.left : wrapperBounds.right - pointer.clientX;
|
|
92
96
|
if (updateCollapse(cursorWidth)) return;
|
|
93
97
|
draftWidth = clampWidth(cursorWidth);
|
|
94
98
|
wrapper.style.setProperty("--sidebar-width", `${draftWidth}px`);
|
|
@@ -152,7 +156,7 @@ function SidebarResizeRail({ className, ref, onPointerDown, onClick, onKeyDown,
|
|
|
152
156
|
case "ArrowLeft":
|
|
153
157
|
case "ArrowRight":
|
|
154
158
|
event.preventDefault();
|
|
155
|
-
resizeWithArrow(event.key === (
|
|
159
|
+
resizeWithArrow(event.key === (anchoredToLeftEdge(event.currentTarget) ? "ArrowRight" : "ArrowLeft"));
|
|
156
160
|
return;
|
|
157
161
|
}
|
|
158
162
|
}
|
|
@@ -179,7 +183,7 @@ function SidebarResizeRail({ className, ref, onPointerDown, onClick, onKeyDown,
|
|
|
179
183
|
onPointerDown: handlePointerDown,
|
|
180
184
|
onClick: handleClick,
|
|
181
185
|
onKeyDown: handleKeyDown,
|
|
182
|
-
className: cn("absolute inset-y-0 z-20 hidden cursor-col-resize touch-pan-y
|
|
186
|
+
className: cn("absolute inset-y-0 z-20 hidden cursor-col-resize touch-pan-y group-data-[side=left]:-end-1 group-data-[side=right]:-start-1 group-data-[side=left]:group-data-[collapsible=offcanvas]:-end-2 group-data-[side=right]:group-data-[collapsible=offcanvas]:-start-2 lg:block", className),
|
|
183
187
|
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
184
188
|
ref: widthMeasureRef,
|
|
185
189
|
"aria-hidden": true,
|
package/dist/ui/sidebar.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { RenderProp } from "../control-props.js";
|
|
1
2
|
import { Button } from "./button.js";
|
|
2
3
|
import { SidebarKnobStyle } from "../knob-contracts/sidebar-knobs.js";
|
|
3
4
|
import { SidebarLayout } from "../skin.js";
|
|
4
|
-
import { SidebarGroup, SidebarGroupContent, SidebarGroupContentProps, SidebarGroupLabel, SidebarGroupLabelProps, SidebarMenu, SidebarMenuAction, SidebarMenuActionProps, SidebarMenuButton, SidebarMenuButtonProps, SidebarMenuButtonSize, SidebarMenuButtonVariant, SidebarMenuItem, SidebarMenuSub, SidebarSelectionIndicator, sidebarMenuButtonSizes, sidebarMenuButtonVariants } from "./sidebar-menu.js";
|
|
5
|
-
import { SidebarProvider, SidebarProviderProps, SidebarStyle, useSidebar } from "./sidebar-provider.js";
|
|
6
5
|
import { SidebarResizeRailProps } from "./sidebar-resize-rail.js";
|
|
6
|
+
import { SidebarGroup, SidebarGroupContent, SidebarGroupContentProps, SidebarGroupLabel, SidebarGroupLabelProps, SidebarMenu, SidebarMenuAction, SidebarMenuActionProps, SidebarMenuBadge, SidebarMenuBadgeProps, SidebarMenuButton, SidebarMenuButtonProps, SidebarMenuButtonSize, SidebarMenuButtonVariant, SidebarMenuItem, SidebarMenuSub, SidebarSelectionIndicator, sidebarMenuButtonSizes, sidebarMenuButtonVariants } from "./sidebar-menu.js";
|
|
7
|
+
import { SidebarLayoutMode, SidebarProvider, SidebarProviderProps, SidebarStyle, useSidebar } from "./sidebar-provider.js";
|
|
7
8
|
import { CSSProperties, ComponentProps } from "react";
|
|
8
9
|
//#region src/ui/sidebar.d.ts
|
|
9
10
|
export type SidebarRailProps = (Omit<ComponentProps<"button">, "style"> & {
|
|
@@ -12,7 +13,8 @@ export type SidebarRailProps = (Omit<ComponentProps<"button">, "style"> & {
|
|
|
12
13
|
}) | (SidebarResizeRailProps & {
|
|
13
14
|
resizable: true;
|
|
14
15
|
});
|
|
15
|
-
export type SidebarInsetProps = Omit<ComponentProps<"main">, "style"> & {
|
|
16
|
+
export type SidebarInsetProps = Omit<ComponentProps<"main">, "style" | "id"> & {
|
|
17
|
+
render?: RenderProp<ComponentProps<"main">>;
|
|
16
18
|
style?: CSSProperties & SidebarKnobStyle;
|
|
17
19
|
};
|
|
18
20
|
type SidebarSurfaceStyle = CSSProperties & SidebarKnobStyle;
|
|
@@ -20,12 +22,15 @@ export type SidebarProps = Omit<ComponentProps<"div">, "style"> & {
|
|
|
20
22
|
side?: "left" | "right";
|
|
21
23
|
variant?: SidebarLayout;
|
|
22
24
|
collapsible?: "offcanvas" | "icon" | "none";
|
|
25
|
+
label?: string;
|
|
23
26
|
style?: SidebarSurfaceStyle;
|
|
24
27
|
};
|
|
25
28
|
export declare function Sidebar({ side, collapsible, ...props }: SidebarProps): import("react").JSX.Element;
|
|
26
|
-
export declare function SidebarTrigger({ className, onClick, size, ref, ...props }: ComponentProps<typeof Button>
|
|
29
|
+
export declare function SidebarTrigger({ className, onClick, size, label, ref, ...props }: ComponentProps<typeof Button> & {
|
|
30
|
+
label?: string;
|
|
31
|
+
}): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
27
32
|
export declare function SidebarRail(props: SidebarRailProps): any;
|
|
28
|
-
export declare function SidebarInset({ className, ...props }: SidebarInsetProps): import("react").
|
|
33
|
+
export declare function SidebarInset({ className, render, ref, ...props }: SidebarInsetProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
29
34
|
export declare function SidebarHeader({ className, ...props }: ComponentProps<"div"> & {
|
|
30
35
|
style?: CSSProperties & SidebarKnobStyle;
|
|
31
36
|
}): import("react").JSX.Element;
|
|
@@ -34,4 +39,4 @@ export declare function SidebarFooter({ className, ...props }: ComponentProps<"d
|
|
|
34
39
|
}): import("react").JSX.Element;
|
|
35
40
|
export declare function SidebarContent({ className, children, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
36
41
|
//#endregion
|
|
37
|
-
export { SidebarGroup, SidebarGroupContent, type SidebarGroupContentProps, SidebarGroupLabel, type SidebarGroupLabelProps, SidebarMenu, SidebarMenuAction, type SidebarMenuActionProps, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonSize, type SidebarMenuButtonVariant, SidebarMenuItem, SidebarMenuSub, SidebarProvider, type SidebarProviderProps, type SidebarSelectionIndicator, type SidebarStyle, sidebarMenuButtonSizes, sidebarMenuButtonVariants, useSidebar };
|
|
42
|
+
export { SidebarGroup, SidebarGroupContent, type SidebarGroupContentProps, SidebarGroupLabel, type SidebarGroupLabelProps, type SidebarLayoutMode, SidebarMenu, SidebarMenuAction, type SidebarMenuActionProps, SidebarMenuBadge, type SidebarMenuBadgeProps, SidebarMenuButton, type SidebarMenuButtonProps, type SidebarMenuButtonSize, type SidebarMenuButtonVariant, SidebarMenuItem, SidebarMenuSub, SidebarProvider, type SidebarProviderProps, type SidebarSelectionIndicator, type SidebarStyle, sidebarMenuButtonSizes, sidebarMenuButtonVariants, useSidebar };
|