@ctrl-ui/react 0.8.7 → 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 +40 -20
- package/dist/activity.js +8 -16
- 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 +39 -39
- package/dist/blocks/design-canvas-inspector.js +2 -2
- package/dist/blocks/design-canvas.d.ts +5 -1
- package/dist/blocks/design-canvas.js +200 -94
- 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 +102 -80
- 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 +4 -1
- package/dist/chat-composer-attachment.js +35 -10
- 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 +57 -30
- package/dist/chat-composer.d.ts +13 -32
- package/dist/chat-composer.js +53 -13
- package/dist/chat-layout.d.ts +19 -0
- package/dist/chat-layout.js +91 -40
- 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 +39 -24
- 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 +86 -23
- 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/editor.js +20 -8
- package/dist/filter-bar/model.d.ts +1 -0
- package/dist/filter-bar/model.js +10 -1
- package/dist/filter-bar/motion.js +4 -4
- package/dist/filter-bar/parts.js +20 -9
- package/dist/filter-bar/types.d.ts +1 -0
- package/dist/filter-bar.js +20 -14
- package/dist/hooks/use-audio-recorder.js +12 -6
- package/dist/hooks/use-chat-composer.d.ts +19 -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-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 +36 -15
- package/dist/inline-citation.d.ts +12 -5
- package/dist/inline-citation.js +26 -17
- 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-message-knobs.d.ts +1 -1
- package/dist/knob-contracts/chat-message-knobs.js +8 -1
- 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/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 +1 -1
- package/dist/knob-contracts/filter-bar-knobs.js +1 -2
- 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 +2 -1
- package/dist/knob-contracts/popup-knobs.d.ts +1 -1
- package/dist/knob-contracts/popup-knobs.js +27 -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 +2 -1
- 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/phone-input-format.js +1 -1
- package/dist/lib/trigger-detect.js +6 -8
- package/dist/markdown-block.js +2 -1
- package/dist/popup-parts.d.ts +8 -0
- package/dist/popup-parts.js +43 -0
- 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 +10 -5
- 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 +5 -7
- package/dist/styles/recipes/button-states.css +66 -0
- package/dist/styles/recipes/button.css +24 -83
- 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 +7 -10
- package/dist/styles/recipes/chat-layout.css +35 -0
- 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 +18 -21
- package/dist/styles/recipes/code-diff.css +46 -33
- package/dist/styles/recipes/code.css +36 -16
- package/dist/styles/recipes/collapsible.css +7 -2
- 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 +11 -2
- package/dist/styles/recipes/context.css +3 -3
- package/dist/styles/recipes/dockable-panel.css +7 -4
- 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 +30 -24
- package/dist/styles/recipes/field.css +61 -26
- package/dist/styles/recipes/filter-bar.css +18 -31
- package/dist/styles/recipes/gradient-editor.css +18 -7
- package/dist/styles/recipes/infinite-canvas.css +0 -1
- package/dist/styles/recipes/inline-attachment.css +3 -3
- 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 +20 -12
- package/dist/styles/recipes/pagination.css +4 -5
- package/dist/styles/recipes/phone-input.css +12 -8
- package/dist/styles/recipes/popup-controls.css +166 -33
- package/dist/styles/recipes/popup-drawer.css +3 -14
- package/dist/styles/recipes/popup-lists.css +128 -27
- package/dist/styles/recipes/popup-motion.css +4 -45
- package/dist/styles/recipes/popup-toast.css +55 -26
- package/dist/styles/recipes/popup.css +139 -141
- package/dist/styles/recipes/range.css +54 -18
- package/dist/styles/recipes/resizable.css +2 -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 +8 -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 +9 -1
- package/dist/styles/recipes/table.css +14 -10
- package/dist/styles/recipes/tabs.css +17 -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 +10 -7
- 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 +37 -16
- 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-dialog.js +1 -1
- package/dist/ui/alert.d.ts +3 -1
- package/dist/ui/alert.js +14 -8
- package/dist/ui/autocomplete.js +4 -2
- 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 +3 -3
- 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.d.ts +2 -0
- package/dist/ui/code-diff.d.ts +1 -1
- package/dist/ui/code-diff.js +72 -28
- package/dist/ui/code.d.ts +5 -3
- package/dist/ui/code.js +28 -29
- package/dist/ui/collapsible.js +1 -1
- package/dist/ui/color-picker.d.ts +5 -2
- package/dist/ui/color-picker.js +85 -37
- package/dist/ui/combobox-disabled-selection.d.ts +1 -2
- package/dist/ui/combobox-disabled-selection.js +7 -9
- package/dist/ui/combobox.js +14 -6
- package/dist/ui/command.d.ts +8 -2
- package/dist/ui/command.js +30 -14
- package/dist/ui/context-menu.js +4 -1
- package/dist/ui/dialog.d.ts +2 -1
- package/dist/ui/dialog.js +4 -23
- 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 +63 -23
- package/dist/ui/drawer.js +1 -1
- package/dist/ui/dropdown-menu.js +5 -4
- package/dist/ui/dropzone.d.ts +2 -2
- package/dist/ui/dropzone.js +75 -16
- 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/gradient-editor.d.ts +1 -1
- package/dist/ui/gradient-editor.js +37 -21
- package/dist/ui/hover-card.js +1 -1
- package/dist/ui/infinite-canvas.d.ts +3 -2
- package/dist/ui/infinite-canvas.js +63 -19
- package/dist/ui/input-group.d.ts +0 -3
- package/dist/ui/input-group.js +4 -14
- package/dist/ui/input-otp.d.ts +1 -1
- package/dist/ui/input-otp.js +32 -15
- package/dist/ui/input.js +4 -4
- package/dist/ui/item.d.ts +2 -1
- package/dist/ui/item.js +12 -8
- 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 +31 -1
- package/dist/ui/menubar.js +3 -3
- package/dist/ui/morphing-panel.js +3 -2
- package/dist/ui/native-select.d.ts +1 -1
- package/dist/ui/native-select.js +24 -11
- package/dist/ui/navigation-menu.js +1 -1
- 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 +58 -60
- package/dist/ui/popover.js +1 -1
- package/dist/ui/radio-group.d.ts +2 -0
- package/dist/ui/resizable.d.ts +3 -2
- package/dist/ui/resizable.js +5 -3
- package/dist/ui/responsive-dialog.d.ts +1 -1
- package/dist/ui/responsive-dialog.js +4 -21
- package/dist/ui/rich-tooltip.d.ts +10 -4
- package/dist/ui/rich-tooltip.js +82 -34
- package/dist/ui/scroll-area.d.ts +1 -1
- package/dist/ui/scroll-area.js +43 -28
- package/dist/ui/select.js +1 -1
- package/dist/ui/sheet.js +1 -1
- package/dist/ui/sidebar-menu.d.ts +5 -1
- package/dist/ui/sidebar-menu.js +32 -34
- package/dist/ui/sidebar-provider.d.ts +10 -1
- package/dist/ui/sidebar-provider.js +39 -14
- package/dist/ui/sidebar-resize-rail.js +8 -4
- package/dist/ui/sidebar.d.ts +11 -6
- package/dist/ui/sidebar.js +47 -24
- 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 +2 -2
- package/dist/ui/table-of-contents.js +20 -8
- package/dist/ui/table.js +4 -2
- 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 +101 -55
- package/dist/ui/toolbar.d.ts +3 -2
- package/dist/ui/toolbar.js +4 -2
- package/dist/ui/tooltip.js +4 -21
- package/dist/ui/tree.js +121 -81
- package/dist/ui/trigger-menu.js +2 -1
- package/dist/user-ask.d.ts +10 -5
- package/dist/user-ask.js +32 -12
- package/package.json +5 -1
- package/dist/hooks/use-keyboard-navigation.d.ts +0 -3
- package/dist/hooks/use-keyboard-navigation.js +0 -22
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
import { useSkin } from "../skin-provider.js";
|
|
4
|
-
import { TooltipProvider } from "./tooltip.js";
|
|
5
4
|
import { SIDEBAR_COOKIE_NAME } from "../control-props.js";
|
|
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";
|
|
8
|
-
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { createContext, useContext, useEffect, useId, useLayoutEffect, useRef, useState } from "react";
|
|
9
8
|
import { useRender } from "@base-ui/react/use-render";
|
|
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, {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
3
|
import { useSidebar, useSidebarElements, useSidebarSurface } from "./sidebar-provider.js";
|
|
4
4
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
5
|
-
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
//#region src/ui/sidebar-resize-rail.tsx
|
|
8
8
|
const DRAG_THRESHOLD_PX = 5;
|
|
9
9
|
const KEYBOARD_STEP_PX = 10;
|
|
@@ -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 };
|
package/dist/ui/sidebar.js
CHANGED
|
@@ -3,14 +3,14 @@ import { cn } from "../lib/cn.js";
|
|
|
3
3
|
import { useSkin } from "../skin-provider.js";
|
|
4
4
|
import { Button } from "./button.js";
|
|
5
5
|
import { ScrollArea } from "./scroll-area.js";
|
|
6
|
-
import { Sheet, SheetContent,
|
|
6
|
+
import { Sheet, SheetContent, SheetHeader, SheetTitle } from "./sheet.js";
|
|
7
7
|
import { SidebarProvider, SidebarSurfaceContext, useSidebar, useSidebarElements, useSidebarSurface } from "./sidebar-provider.js";
|
|
8
8
|
import { SidebarResizeRail } from "./sidebar-resize-rail.js";
|
|
9
|
-
import { SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, sidebarMenuButtonSizes, sidebarMenuButtonVariants } from "./sidebar-menu.js";
|
|
9
|
+
import { SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, sidebarMenuButtonSizes, sidebarMenuButtonVariants } from "./sidebar-menu.js";
|
|
10
10
|
import { useState } from "react";
|
|
11
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
11
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
13
|
import { PanelLeftIcon } from "lucide-react";
|
|
13
|
-
import { useRender } from "@base-ui/react/use-render";
|
|
14
14
|
import { createPortal } from "react-dom";
|
|
15
15
|
//#region src/ui/sidebar.tsx
|
|
16
16
|
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
@@ -34,22 +34,23 @@ function Sidebar({ side = "left", collapsible = "offcanvas", ...props }) {
|
|
|
34
34
|
})
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
function SidebarSurface({ variant, ref, className, children, style, railContainerRef, ...props }) {
|
|
37
|
+
function SidebarSurface({ variant, label = "Navigation", ref, className, children, style, railContainerRef, ...props }) {
|
|
38
38
|
const { side, collapsible } = useSidebarSurface();
|
|
39
39
|
const { offcanvasRef } = useSidebarElements();
|
|
40
40
|
const skin = useSkin();
|
|
41
|
-
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
41
|
+
const { isMobile, state, openMobile, setOpenMobile, layout, sidebarId } = useSidebar();
|
|
42
42
|
const resolvedVariant = variant ?? skin.sidebarLayout ?? "sidebar";
|
|
43
43
|
const container = useRender({
|
|
44
44
|
defaultTagName: "div",
|
|
45
45
|
ref: collapsible === "offcanvas" ? [ref ?? null, offcanvasRef] : ref,
|
|
46
46
|
props: {
|
|
47
|
+
id: sidebarId,
|
|
47
48
|
...props,
|
|
48
49
|
"data-control-ui": "sidebar",
|
|
49
50
|
"data-control-family": "sidebar",
|
|
50
51
|
"data-slot": "container",
|
|
51
52
|
tabIndex: -1,
|
|
52
|
-
className: cn("fixed inset-y-0 z-10 hidden
|
|
53
|
+
className: cn(layout === "contained" ? "absolute h-full" : "fixed h-svh", "inset-y-0 z-10 hidden w-(--sidebar-width) lg:flex", side === "left" ? "start-0 group-data-[collapsible=offcanvas]:start-[calc(var(--sidebar-width)*-1)]" : "end-0 group-data-[collapsible=offcanvas]:end-[calc(var(--sidebar-width)*-1)]", resolvedVariant === "floating" || resolvedVariant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)", className),
|
|
53
54
|
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
54
55
|
"data-control-ui": "sidebar",
|
|
55
56
|
"data-control-family": "sidebar",
|
|
@@ -91,11 +92,12 @@ function SidebarSurface({ variant, ref, className, children, style, railContaine
|
|
|
91
92
|
side,
|
|
92
93
|
className: "w-(--sidebar-width) gap-0 p-0",
|
|
93
94
|
style: mobileSheetStyle,
|
|
94
|
-
children: [/* @__PURE__ */
|
|
95
|
+
children: [/* @__PURE__ */ jsx(SheetHeader, {
|
|
95
96
|
className: "sr-only",
|
|
96
|
-
children:
|
|
97
|
+
children: /* @__PURE__ */ jsx(SheetTitle, { children: label })
|
|
97
98
|
}), /* @__PURE__ */ jsx("div", {
|
|
98
99
|
ref,
|
|
100
|
+
id: sidebarId,
|
|
99
101
|
"data-control-ui": "sidebar",
|
|
100
102
|
"data-control-family": "sidebar",
|
|
101
103
|
"data-slot": "root",
|
|
@@ -136,9 +138,10 @@ function SidebarSurface({ variant, ref, className, children, style, railContaine
|
|
|
136
138
|
}), container]
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
|
-
function SidebarTrigger({ className, onClick, size = "sm", ref, ...props }) {
|
|
140
|
-
const { toggleSidebar, isMobile, openMobile, open } = useSidebar();
|
|
141
|
+
function SidebarTrigger({ className, onClick, size = "sm", label = "Toggle sidebar", ref, ...props }) {
|
|
142
|
+
const { toggleSidebar, isMobile, openMobile, open, keyboardShortcut, sidebarId } = useSidebar();
|
|
141
143
|
const { triggerRef, railRef } = useSidebarElements();
|
|
144
|
+
const shortcutKey = keyboardShortcut?.toUpperCase();
|
|
142
145
|
return useRender({
|
|
143
146
|
defaultTagName: "button",
|
|
144
147
|
render: /* @__PURE__ */ jsx(Button, {
|
|
@@ -152,16 +155,26 @@ function SidebarTrigger({ className, onClick, size = "sm", ref, ...props }) {
|
|
|
152
155
|
"data-slot": "trigger",
|
|
153
156
|
"data-sidebar-trigger": "",
|
|
154
157
|
"aria-expanded": isMobile ? openMobile : open,
|
|
158
|
+
"aria-controls": isMobile && !openMobile ? void 0 : sidebarId,
|
|
159
|
+
"aria-keyshortcuts": shortcutKey ? `Meta+${shortcutKey} Control+${shortcutKey}` : void 0,
|
|
155
160
|
className: cn(sidebarTriggerWidth[size], "px-0", className),
|
|
156
161
|
onClick: (event) => {
|
|
157
162
|
onClick?.(event);
|
|
158
163
|
if (event.defaultPrevented) return;
|
|
159
164
|
toggleSidebar();
|
|
160
|
-
if (
|
|
165
|
+
if (isMobile || open) return;
|
|
166
|
+
const trigger = event.currentTarget;
|
|
167
|
+
requestAnimationFrame(() => {
|
|
168
|
+
if (!trigger.checkVisibility()) railRef.current?.focus({ preventScroll: true });
|
|
169
|
+
});
|
|
161
170
|
},
|
|
162
|
-
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(PanelLeftIcon, {
|
|
171
|
+
children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(PanelLeftIcon, {
|
|
172
|
+
className: "size-4",
|
|
173
|
+
"data-icon-dir": "inline",
|
|
174
|
+
"aria-hidden": "true"
|
|
175
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
163
176
|
className: "sr-only",
|
|
164
|
-
children:
|
|
177
|
+
children: label
|
|
165
178
|
})] })
|
|
166
179
|
}
|
|
167
180
|
});
|
|
@@ -189,25 +202,34 @@ function SidebarToggleRail({ className, ref, onClick, ...props }) {
|
|
|
189
202
|
"data-control-ui": "sidebar",
|
|
190
203
|
"data-control-family": "sidebar",
|
|
191
204
|
"data-slot": "rail",
|
|
192
|
-
"aria-label": props["aria-label"] ?? "Toggle
|
|
205
|
+
"aria-label": props["aria-label"] ?? "Toggle sidebar",
|
|
193
206
|
"aria-expanded": open,
|
|
194
207
|
tabIndex: -1,
|
|
195
208
|
onClick: (event) => {
|
|
196
209
|
onClick?.(event);
|
|
197
210
|
if (!event.defaultPrevented) toggleSidebar();
|
|
198
211
|
},
|
|
199
|
-
title: "Toggle
|
|
200
|
-
className: cn("absolute inset-y-0 z-20 hidden -translate-x-1/2 group-data-[side=left]:-
|
|
212
|
+
title: props.title ?? "Toggle sidebar",
|
|
213
|
+
className: cn("absolute inset-y-0 z-20 hidden -translate-x-1/2 rtl:translate-x-1/2 group-data-[side=left]:-end-4 group-data-[side=right]:start-0 lg:flex", "in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize", "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize", "group-data-[collapsible=offcanvas]:translate-x-0", className)
|
|
201
214
|
}
|
|
202
215
|
});
|
|
203
216
|
}
|
|
204
|
-
function SidebarInset({ className, ...props }) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
"
|
|
209
|
-
|
|
210
|
-
|
|
217
|
+
function SidebarInset({ className, render, ref, ...props }) {
|
|
218
|
+
const { layout, contentId } = useSidebar();
|
|
219
|
+
const { insetRef } = useSidebarElements();
|
|
220
|
+
return useRender({
|
|
221
|
+
defaultTagName: layout === "contained" ? "div" : "main",
|
|
222
|
+
render,
|
|
223
|
+
ref: [ref ?? null, insetRef],
|
|
224
|
+
props: {
|
|
225
|
+
tabIndex: -1,
|
|
226
|
+
...props,
|
|
227
|
+
id: contentId,
|
|
228
|
+
"data-control-ui": "sidebar",
|
|
229
|
+
"data-control-family": "sidebar",
|
|
230
|
+
"data-slot": "inset",
|
|
231
|
+
className: cn("relative flex min-w-0 w-full flex-1 flex-col", className)
|
|
232
|
+
}
|
|
211
233
|
});
|
|
212
234
|
}
|
|
213
235
|
function SidebarHeader({ className, ...props }) {
|
|
@@ -234,6 +256,7 @@ function SidebarContent({ className, children, ...props }) {
|
|
|
234
256
|
"data-slot": "content",
|
|
235
257
|
className: cn("min-h-0 flex-1 group-data-[collapsible=icon]:overflow-hidden", className),
|
|
236
258
|
lockAxis: "x",
|
|
259
|
+
viewportClassName: "overscroll-contain",
|
|
237
260
|
...props,
|
|
238
261
|
children: /* @__PURE__ */ jsx("div", {
|
|
239
262
|
"data-control-ui": "sidebar",
|
|
@@ -245,4 +268,4 @@ function SidebarContent({ className, children, ...props }) {
|
|
|
245
268
|
});
|
|
246
269
|
}
|
|
247
270
|
//#endregion
|
|
248
|
-
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarProvider, SidebarRail, SidebarTrigger, sidebarMenuButtonSizes, sidebarMenuButtonVariants, useSidebar };
|
|
271
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarProvider, SidebarRail, SidebarTrigger, sidebarMenuButtonSizes, sidebarMenuButtonVariants, useSidebar };
|
package/dist/ui/slider.js
CHANGED
|
@@ -12,10 +12,10 @@ function tickPositions(min, max, step) {
|
|
|
12
12
|
if (stepCount <= 1 || stepCount > MAX_VISIBLE_STEP_TICKS) return [];
|
|
13
13
|
return Array.from({ length: stepCount - 1 }, (_, i) => (i + 1) / stepCount * 100);
|
|
14
14
|
}
|
|
15
|
-
function displaySliderValue(values, formatValue) {
|
|
15
|
+
function displaySliderValue(formattedValues, values, formatValue) {
|
|
16
16
|
const value = values[0];
|
|
17
17
|
if (value === void 0) return "";
|
|
18
|
-
return formatValue ? formatValue(value) :
|
|
18
|
+
return formatValue ? formatValue(value) : formattedValues[0] ?? "";
|
|
19
19
|
}
|
|
20
20
|
function Slider({ className, variant = "default", label, showValue, formatValue, value, defaultValue, onValueChange, onValueCommitted, orientation = "horizontal", min = 0, max = 100, step, disabled, style, "aria-label": ariaLabel, ...props }) {
|
|
21
21
|
const showValueResolved = showValue ?? Boolean(label);
|
|
@@ -78,38 +78,47 @@ function Slider({ className, variant = "default", label, showValue, formatValue,
|
|
|
78
78
|
}
|
|
79
79
|
}, pct)),
|
|
80
80
|
/* @__PURE__ */ jsx(Slider$1.Thumb, {
|
|
81
|
-
"aria-label": ariaLabel,
|
|
81
|
+
"aria-label": ariaLabel ?? (labeled ? void 0 : label),
|
|
82
|
+
getAriaValueText: formatValue ? (_, thumbValue) => formatValue(thumbValue) : void 0,
|
|
82
83
|
"data-control-ui": "slider",
|
|
83
84
|
"data-control-family": "range",
|
|
84
85
|
"data-range-kind": "slider",
|
|
85
86
|
"data-slot": "thumb",
|
|
86
87
|
"data-variant": variant,
|
|
87
|
-
|
|
88
|
+
"data-focus-ring": "within",
|
|
89
|
+
className: "block",
|
|
88
90
|
style
|
|
89
91
|
})
|
|
90
92
|
]
|
|
91
93
|
})
|
|
92
|
-
}), labeled && /* @__PURE__ */
|
|
94
|
+
}), labeled && /* @__PURE__ */ jsx(SliderLabelOverlay, {
|
|
95
|
+
label,
|
|
96
|
+
showValue: showValueResolved,
|
|
97
|
+
formatValue
|
|
98
|
+
})]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function SliderLabelOverlay({ label, showValue, formatValue }) {
|
|
102
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
103
|
+
"data-control-ui": "slider",
|
|
104
|
+
"data-control-family": "range",
|
|
105
|
+
"data-range-kind": "slider",
|
|
106
|
+
"data-slot": "label-overlay",
|
|
107
|
+
className: "pointer-events-none absolute inset-0 z-10 flex items-center justify-between",
|
|
108
|
+
children: [label ? /* @__PURE__ */ jsx(Slider$1.Label, {
|
|
93
109
|
"data-control-ui": "slider",
|
|
94
110
|
"data-control-family": "range",
|
|
95
111
|
"data-range-kind": "slider",
|
|
96
|
-
"data-slot": "label
|
|
97
|
-
className: "
|
|
98
|
-
children:
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
"data-control-ui": "slider",
|
|
107
|
-
"data-control-family": "range",
|
|
108
|
-
"data-range-kind": "slider",
|
|
109
|
-
"data-slot": "value",
|
|
110
|
-
className: "select-none",
|
|
111
|
-
children: (_, values) => displaySliderValue(values, formatValue)
|
|
112
|
-
})]
|
|
112
|
+
"data-slot": "label",
|
|
113
|
+
className: "select-none",
|
|
114
|
+
children: label
|
|
115
|
+
}) : /* @__PURE__ */ jsx("span", {}), showValue && /* @__PURE__ */ jsx(Slider$1.Value, {
|
|
116
|
+
"data-control-ui": "slider",
|
|
117
|
+
"data-control-family": "range",
|
|
118
|
+
"data-range-kind": "slider",
|
|
119
|
+
"data-slot": "value",
|
|
120
|
+
className: "select-none",
|
|
121
|
+
children: (formattedValues, values) => displaySliderValue(formattedValues, values, formatValue)
|
|
113
122
|
})]
|
|
114
123
|
});
|
|
115
124
|
}
|
package/dist/ui/spinner.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import { CSSProperties, ComponentProps } from "react";
|
|
|
4
4
|
//#region src/ui/spinner.d.ts
|
|
5
5
|
export type SpinnerProps = Omit<ComponentProps<"span"> & {
|
|
6
6
|
size?: ControlSize;
|
|
7
|
-
|
|
7
|
+
label?: string;
|
|
8
|
+
}, "style" | "children"> & {
|
|
8
9
|
style?: CSSProperties & SpinnerKnobStyle;
|
|
9
10
|
};
|
|
10
|
-
export declare function Spinner({ size, className, ...props }: SpinnerProps): import("react").JSX.Element;
|
|
11
|
+
export declare function Spinner({ size, label, className, ...props }: SpinnerProps): import("react").JSX.Element;
|
|
11
12
|
//#endregion
|
package/dist/ui/spinner.js
CHANGED
|
@@ -2,12 +2,13 @@ import { cn } from "../lib/cn.js";
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Loader2 } from "lucide-react";
|
|
4
4
|
//#region src/ui/spinner.tsx
|
|
5
|
-
function Spinner({ size = "sm", className, ...props }) {
|
|
5
|
+
function Spinner({ size = "sm", label = "Loading", className, ...props }) {
|
|
6
6
|
return /* @__PURE__ */ jsxs("span", {
|
|
7
7
|
role: "status",
|
|
8
8
|
"data-control-ui": "spinner",
|
|
9
9
|
"data-control-family": "spinner",
|
|
10
10
|
"data-slot": "root",
|
|
11
|
+
"data-motion-essential": "",
|
|
11
12
|
className: cn("inline-flex", className),
|
|
12
13
|
...props,
|
|
13
14
|
children: [/* @__PURE__ */ jsx(Loader2, {
|
|
@@ -18,7 +19,7 @@ function Spinner({ size = "sm", className, ...props }) {
|
|
|
18
19
|
"data-size": size
|
|
19
20
|
}), /* @__PURE__ */ jsx("span", {
|
|
20
21
|
className: "sr-only",
|
|
21
|
-
children:
|
|
22
|
+
children: label
|
|
22
23
|
})]
|
|
23
24
|
});
|
|
24
25
|
}
|
package/dist/ui/stepper.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ import { CSSProperties, ComponentProps } from "react";
|
|
|
4
4
|
export type StepperOrientation = "horizontal" | "vertical";
|
|
5
5
|
export type StepperContentMode = "current" | "all";
|
|
6
6
|
export type StepperState = "neutral" | "complete" | "current" | "upcoming";
|
|
7
|
+
export type StepperStatusDetails = {
|
|
8
|
+
step: number;
|
|
9
|
+
state: StepperState;
|
|
10
|
+
invalid: boolean;
|
|
11
|
+
disabled: boolean;
|
|
12
|
+
};
|
|
7
13
|
export type StepperProps = Omit<ComponentProps<"div">, "defaultValue" | "onChange"> & {
|
|
8
14
|
value?: number | null;
|
|
9
15
|
defaultValue?: number | null;
|
|
@@ -11,6 +17,7 @@ export type StepperProps = Omit<ComponentProps<"div">, "defaultValue" | "onChang
|
|
|
11
17
|
orientation?: StepperOrientation;
|
|
12
18
|
contentMode?: StepperContentMode;
|
|
13
19
|
responsive?: boolean;
|
|
20
|
+
getStatusLabel?: (details: StepperStatusDetails) => string;
|
|
14
21
|
} & {
|
|
15
22
|
style?: CSSProperties & StepperKnobStyle;
|
|
16
23
|
};
|
|
@@ -45,7 +52,7 @@ export type StepperContentProps = ComponentProps<"section"> & {
|
|
|
45
52
|
} & {
|
|
46
53
|
style?: CSSProperties & StepperKnobStyle;
|
|
47
54
|
};
|
|
48
|
-
export declare function Stepper({ value, defaultValue, onValueChange, orientation, contentMode, responsive, id, className, children, ...props }: StepperProps): import("react").JSX.Element;
|
|
55
|
+
export declare function Stepper({ value, defaultValue, onValueChange, orientation, contentMode, responsive, getStatusLabel, id, className, children, ...props }: StepperProps): import("react").JSX.Element;
|
|
49
56
|
export declare function StepperList({ className, ...props }: StepperListProps): import("react").JSX.Element;
|
|
50
57
|
export declare function StepperItem({ step, disabled, invalid, className, children, ...props }: StepperItemProps): import("react").JSX.Element;
|
|
51
58
|
export declare function StepperTrigger({ disabled: disabledProp, className, onClick, type, ...props }: StepperTriggerProps): import("react").JSX.Element;
|