@adea-ai/ui 0.107.0 → 0.109.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NOTICE +13 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts +55 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.d.ts.map +1 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js +199 -0
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -0
- package/dist/components/layout/contextual-sidebar/index.d.ts +3 -0
- package/dist/components/layout/contextual-sidebar/index.d.ts.map +1 -0
- package/dist/components/layout/contextual-sidebar/index.js +3 -0
- package/dist/components/layout/pixel-resize-handle/index.d.ts +2 -0
- package/dist/components/layout/pixel-resize-handle/index.d.ts.map +1 -0
- package/dist/components/layout/pixel-resize-handle/index.js +2 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts +29 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts.map +1 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js +183 -0
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js.map +1 -0
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts +3 -19
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.d.ts.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.js +8 -76
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.js.map +1 -1
- package/dist/components/ui/annotation-surface/annotation-surface.css +27 -0
- package/dist/components/ui/annotation-surface/annotation-surface.d.ts +66 -0
- package/dist/components/ui/annotation-surface/annotation-surface.d.ts.map +1 -0
- package/dist/components/ui/annotation-surface/annotation-surface.js +244 -0
- package/dist/components/ui/annotation-surface/annotation-surface.js.map +1 -0
- package/dist/components/ui/annotation-surface/geometry.d.ts +10 -0
- package/dist/components/ui/annotation-surface/geometry.d.ts.map +1 -0
- package/dist/components/ui/annotation-surface/geometry.js +19 -0
- package/dist/components/ui/annotation-surface/geometry.js.map +1 -0
- package/dist/components/ui/annotation-surface/index.d.ts +4 -0
- package/dist/components/ui/annotation-surface/index.d.ts.map +1 -0
- package/dist/components/ui/annotation-surface/index.js +2 -0
- package/dist/components/ui/resizable/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable/resizable.js +2 -2
- package/dist/components/ui/resizable/resizable.js.map +1 -1
- package/dist/components/ui/sheet/sheet.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/lint/index.d.ts.map +1 -1
- package/dist/lint.js +154 -20
- package/dist/lint.js.map +1 -1
- package/dist/r/annotation-surface.json +32 -0
- package/dist/r/contextual-sidebar.json +25 -0
- package/dist/r/pixel-resize-handle.json +23 -0
- package/dist/r/registry.json +81 -1
- package/dist/r/sidebar-nav.json +1 -1
- package/dist/r/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +180 -0
- package/dist/r/src/components/layout/contextual-sidebar/index.ts +6 -0
- package/dist/r/src/components/layout/pixel-resize-handle/index.ts +1 -0
- package/dist/r/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +177 -0
- package/dist/r/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +7 -55
- package/dist/r/src/components/ui/annotation-surface/annotation-surface.css +27 -0
- package/dist/r/src/components/ui/annotation-surface/annotation-surface.tsx +316 -0
- package/dist/r/src/components/ui/annotation-surface/geometry.ts +31 -0
- package/dist/r/src/components/ui/annotation-surface/index.ts +13 -0
- package/dist/r/src/components/ui/resizable/resizable.tsx +4 -2
- package/package.json +5 -2
- package/registry.json +81 -1
- package/src/components/layout/contextual-sidebar/contextual-sidebar.tsx +180 -0
- package/src/components/layout/contextual-sidebar/index.ts +6 -0
- package/src/components/layout/pixel-resize-handle/index.ts +1 -0
- package/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +177 -0
- package/src/components/layout/sidebar-nav/sidebar-nav-resize-handle.tsx +7 -55
- package/src/components/ui/annotation-surface/annotation-surface.css +27 -0
- package/src/components/ui/annotation-surface/annotation-surface.tsx +316 -0
- package/src/components/ui/annotation-surface/geometry.ts +31 -0
- package/src/components/ui/annotation-surface/index.ts +13 -0
- package/src/components/ui/resizable/resizable.tsx +4 -2
- package/src/index.ts +2 -0
- package/src/lint/index.ts +234 -22
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "annotation-surface",
|
|
3
|
+
"type": "registry:ui",
|
|
4
|
+
"title": "Annotation Surface",
|
|
5
|
+
"description": "Keyboard-operable normalized drawing surface; hosts retain domain geometry and actions.",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"lib"
|
|
9
|
+
],
|
|
10
|
+
"files": [
|
|
11
|
+
{
|
|
12
|
+
"path": "src/components/ui/annotation-surface/annotation-surface.css",
|
|
13
|
+
"type": "registry:ui",
|
|
14
|
+
"target": "components/ui/annotation-surface/annotation-surface.css"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"path": "src/components/ui/annotation-surface/annotation-surface.tsx",
|
|
18
|
+
"type": "registry:ui",
|
|
19
|
+
"target": "components/ui/annotation-surface/annotation-surface.tsx"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"path": "src/components/ui/annotation-surface/geometry.ts",
|
|
23
|
+
"type": "registry:ui",
|
|
24
|
+
"target": "components/ui/annotation-surface/geometry.ts"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "src/components/ui/annotation-surface/index.ts",
|
|
28
|
+
"type": "registry:ui",
|
|
29
|
+
"target": "components/ui/annotation-surface/index.ts"
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "contextual-sidebar",
|
|
3
|
+
"type": "registry:ui",
|
|
4
|
+
"title": "Contextual Sidebar",
|
|
5
|
+
"description": "",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"@adea-ai/ui/pixel-resize-handle",
|
|
9
|
+
"@adea-ai/ui/sheet",
|
|
10
|
+
"@adea-ai/ui/sidebar-nav",
|
|
11
|
+
"lib"
|
|
12
|
+
],
|
|
13
|
+
"files": [
|
|
14
|
+
{
|
|
15
|
+
"path": "src/components/layout/contextual-sidebar/contextual-sidebar.tsx",
|
|
16
|
+
"type": "registry:ui",
|
|
17
|
+
"target": "components/layout/contextual-sidebar/contextual-sidebar.tsx"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"path": "src/components/layout/contextual-sidebar/index.ts",
|
|
21
|
+
"type": "registry:ui",
|
|
22
|
+
"target": "components/layout/contextual-sidebar/index.ts"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pixel-resize-handle",
|
|
3
|
+
"type": "registry:ui",
|
|
4
|
+
"title": "Pixel Resize Handle",
|
|
5
|
+
"description": "",
|
|
6
|
+
"dependencies": [],
|
|
7
|
+
"registryDependencies": [
|
|
8
|
+
"@adea-ai/ui/resizable",
|
|
9
|
+
"lib"
|
|
10
|
+
],
|
|
11
|
+
"files": [
|
|
12
|
+
{
|
|
13
|
+
"path": "src/components/layout/pixel-resize-handle/index.ts",
|
|
14
|
+
"type": "registry:ui",
|
|
15
|
+
"target": "components/layout/pixel-resize-handle/index.ts"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"path": "src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx",
|
|
19
|
+
"type": "registry:ui",
|
|
20
|
+
"target": "components/layout/pixel-resize-handle/pixel-resize-handle.tsx"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
package/dist/r/registry.json
CHANGED
|
@@ -77,6 +77,38 @@
|
|
|
77
77
|
}
|
|
78
78
|
]
|
|
79
79
|
},
|
|
80
|
+
{
|
|
81
|
+
"name": "annotation-surface",
|
|
82
|
+
"type": "registry:ui",
|
|
83
|
+
"title": "Annotation Surface",
|
|
84
|
+
"description": "Keyboard-operable normalized drawing surface; hosts retain domain geometry and actions.",
|
|
85
|
+
"dependencies": [],
|
|
86
|
+
"registryDependencies": [
|
|
87
|
+
"lib"
|
|
88
|
+
],
|
|
89
|
+
"files": [
|
|
90
|
+
{
|
|
91
|
+
"path": "src/components/ui/annotation-surface/annotation-surface.css",
|
|
92
|
+
"type": "registry:ui",
|
|
93
|
+
"target": "components/ui/annotation-surface/annotation-surface.css"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"path": "src/components/ui/annotation-surface/annotation-surface.tsx",
|
|
97
|
+
"type": "registry:ui",
|
|
98
|
+
"target": "components/ui/annotation-surface/annotation-surface.tsx"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"path": "src/components/ui/annotation-surface/geometry.ts",
|
|
102
|
+
"type": "registry:ui",
|
|
103
|
+
"target": "components/ui/annotation-surface/geometry.ts"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"path": "src/components/ui/annotation-surface/index.ts",
|
|
107
|
+
"type": "registry:ui",
|
|
108
|
+
"target": "components/ui/annotation-surface/index.ts"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
80
112
|
{
|
|
81
113
|
"name": "aspect-ratio",
|
|
82
114
|
"type": "registry:ui",
|
|
@@ -1555,6 +1587,31 @@
|
|
|
1555
1587
|
}
|
|
1556
1588
|
]
|
|
1557
1589
|
},
|
|
1590
|
+
{
|
|
1591
|
+
"name": "contextual-sidebar",
|
|
1592
|
+
"type": "registry:ui",
|
|
1593
|
+
"title": "Contextual Sidebar",
|
|
1594
|
+
"description": "",
|
|
1595
|
+
"dependencies": [],
|
|
1596
|
+
"registryDependencies": [
|
|
1597
|
+
"@adea-ai/ui/pixel-resize-handle",
|
|
1598
|
+
"@adea-ai/ui/sheet",
|
|
1599
|
+
"@adea-ai/ui/sidebar-nav",
|
|
1600
|
+
"lib"
|
|
1601
|
+
],
|
|
1602
|
+
"files": [
|
|
1603
|
+
{
|
|
1604
|
+
"path": "src/components/layout/contextual-sidebar/contextual-sidebar.tsx",
|
|
1605
|
+
"type": "registry:ui",
|
|
1606
|
+
"target": "components/layout/contextual-sidebar/contextual-sidebar.tsx"
|
|
1607
|
+
},
|
|
1608
|
+
{
|
|
1609
|
+
"path": "src/components/layout/contextual-sidebar/index.ts",
|
|
1610
|
+
"type": "registry:ui",
|
|
1611
|
+
"target": "components/layout/contextual-sidebar/index.ts"
|
|
1612
|
+
}
|
|
1613
|
+
]
|
|
1614
|
+
},
|
|
1558
1615
|
{
|
|
1559
1616
|
"name": "floating-preview",
|
|
1560
1617
|
"type": "registry:ui",
|
|
@@ -1652,6 +1709,29 @@
|
|
|
1652
1709
|
}
|
|
1653
1710
|
]
|
|
1654
1711
|
},
|
|
1712
|
+
{
|
|
1713
|
+
"name": "pixel-resize-handle",
|
|
1714
|
+
"type": "registry:ui",
|
|
1715
|
+
"title": "Pixel Resize Handle",
|
|
1716
|
+
"description": "",
|
|
1717
|
+
"dependencies": [],
|
|
1718
|
+
"registryDependencies": [
|
|
1719
|
+
"@adea-ai/ui/resizable",
|
|
1720
|
+
"lib"
|
|
1721
|
+
],
|
|
1722
|
+
"files": [
|
|
1723
|
+
{
|
|
1724
|
+
"path": "src/components/layout/pixel-resize-handle/index.ts",
|
|
1725
|
+
"type": "registry:ui",
|
|
1726
|
+
"target": "components/layout/pixel-resize-handle/index.ts"
|
|
1727
|
+
},
|
|
1728
|
+
{
|
|
1729
|
+
"path": "src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx",
|
|
1730
|
+
"type": "registry:ui",
|
|
1731
|
+
"target": "components/layout/pixel-resize-handle/pixel-resize-handle.tsx"
|
|
1732
|
+
}
|
|
1733
|
+
]
|
|
1734
|
+
},
|
|
1655
1735
|
{
|
|
1656
1736
|
"name": "side-rail",
|
|
1657
1737
|
"type": "registry:ui",
|
|
@@ -1687,11 +1767,11 @@
|
|
|
1687
1767
|
"title": "Sidebar Nav",
|
|
1688
1768
|
"description": "",
|
|
1689
1769
|
"dependencies": [
|
|
1690
|
-
"@corvu/resizable@^0.2.5",
|
|
1691
1770
|
"@kobalte/core@^0.13.14",
|
|
1692
1771
|
"lucide-solid@^1.51.0"
|
|
1693
1772
|
],
|
|
1694
1773
|
"registryDependencies": [
|
|
1774
|
+
"@adea-ai/ui/pixel-resize-handle",
|
|
1695
1775
|
"lib"
|
|
1696
1776
|
],
|
|
1697
1777
|
"files": [
|
package/dist/r/sidebar-nav.json
CHANGED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { Accessor, JSX } from 'solid-js'
|
|
2
|
+
import { Show, createSignal, createUniqueId, onCleanup, onMount } from 'solid-js'
|
|
3
|
+
import { cn } from '../../../lib/utils'
|
|
4
|
+
import { Sheet, SheetContent, SheetTitle } from '../../ui/sheet'
|
|
5
|
+
import {
|
|
6
|
+
SidebarNav,
|
|
7
|
+
SidebarNavContent,
|
|
8
|
+
SidebarNavFooter,
|
|
9
|
+
SidebarNavHeader,
|
|
10
|
+
SidebarNavTitle,
|
|
11
|
+
} from '../sidebar-nav/sidebar-nav'
|
|
12
|
+
import { PixelResizeHandle } from '../pixel-resize-handle/pixel-resize-handle'
|
|
13
|
+
|
|
14
|
+
export type ContextualSidebarRenderContext = {
|
|
15
|
+
/** Whether the slot is being rendered inside the modal mobile sheet. */
|
|
16
|
+
mobile: boolean
|
|
17
|
+
/** Mount nested popovers and menus inside the mobile dialog's accessibility tree. */
|
|
18
|
+
portalMount(): HTMLElement | undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type ContextualSidebarProps = {
|
|
22
|
+
/** Stable host id prefix; generated when omitted. */
|
|
23
|
+
id?: string
|
|
24
|
+
/** Landmark name shared by the desktop and mobile navigation. */
|
|
25
|
+
label: string
|
|
26
|
+
/** Visible navigation title and mobile dialog title. */
|
|
27
|
+
title: string
|
|
28
|
+
/** Host-controlled expanded state for the desktop panel and mobile dialog. */
|
|
29
|
+
open: boolean
|
|
30
|
+
onOpenChange(open: boolean): void
|
|
31
|
+
/** Current host-owned pixel width, reflected by the resize handle. */
|
|
32
|
+
width: number
|
|
33
|
+
minimum: number
|
|
34
|
+
maximum: number
|
|
35
|
+
step?: number
|
|
36
|
+
/** Pass the host's initial viewport seed to distinguish stale desktop state. */
|
|
37
|
+
wideViewportAtLoad?: boolean
|
|
38
|
+
resizeLabel?: string
|
|
39
|
+
/** Stable external opener used when the modal mobile sheet closes. */
|
|
40
|
+
restoreFocusRef?: Accessor<HTMLElement | undefined>
|
|
41
|
+
/** Called with the nav node so a host can project width onto its layout root. */
|
|
42
|
+
onSidebarElement?: (element: HTMLElement | undefined, mobile: boolean) => void
|
|
43
|
+
/** Host-owned layout classes applied to both nav instances. */
|
|
44
|
+
sidebarClass?: string
|
|
45
|
+
/** Host-owned responsive constraints for the modal sheet. */
|
|
46
|
+
sheetClass?: string
|
|
47
|
+
headerClass?: string
|
|
48
|
+
contentClass?: string
|
|
49
|
+
footerClass?: string
|
|
50
|
+
headingAs?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
|
|
51
|
+
/** Optional action/content slot alongside the shared heading. */
|
|
52
|
+
header?(context: ContextualSidebarRenderContext): JSX.Element
|
|
53
|
+
/** View-specific navigation rows, projects, rooms, files, or sessions. */
|
|
54
|
+
content(context: ContextualSidebarRenderContext): JSX.Element
|
|
55
|
+
/** Optional view-specific footer, such as an archive affordance. */
|
|
56
|
+
footer?(context: ContextualSidebarRenderContext): JSX.Element
|
|
57
|
+
onWidthChange(width: number): void
|
|
58
|
+
onWidthCommit?(width: number): void
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* ContextualSidebar.
|
|
63
|
+
*
|
|
64
|
+
* Shared navigation geometry and interaction policy for an application's
|
|
65
|
+
* contextual sidebar. The host keeps ownership of the actual grid width,
|
|
66
|
+
* persisted preference, open state, and view-specific navigation content.
|
|
67
|
+
*/
|
|
68
|
+
export function ContextualSidebar(props: ContextualSidebarProps) {
|
|
69
|
+
const [isNarrowViewport, setIsNarrowViewport] = createSignal(false)
|
|
70
|
+
const [mobileMount, setMobileMount] = createSignal<
|
|
71
|
+
{ element: HTMLElement; connected: boolean } | undefined
|
|
72
|
+
>()
|
|
73
|
+
const id = props.id ?? `contextual-sidebar-${createUniqueId()}`
|
|
74
|
+
const resizeLabel = () => props.resizeLabel ?? `Resize ${props.label}`
|
|
75
|
+
const portalMount = () => {
|
|
76
|
+
const mount = mobileMount()
|
|
77
|
+
return mount?.connected && mount.element.isConnected ? mount.element : undefined
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
onMount(() => {
|
|
81
|
+
const media = window.matchMedia('(max-width: 48rem)')
|
|
82
|
+
const updateViewport = () => {
|
|
83
|
+
const wasNarrow = isNarrowViewport()
|
|
84
|
+
// Close before mounting a modal. A desktop-expanded host state is not
|
|
85
|
+
// mobile intent, and opening the Sheet for one frame can steal focus.
|
|
86
|
+
if (media.matches && !wasNarrow) props.onOpenChange(false)
|
|
87
|
+
setIsNarrowViewport(media.matches)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// A route can mount after a wide-loaded host crosses into mobile. Clear
|
|
91
|
+
// that stale seed, but preserve a sidebar intentionally opened at a
|
|
92
|
+
// narrow boot viewport.
|
|
93
|
+
if (media.matches && props.wideViewportAtLoad && props.open) props.onOpenChange(false)
|
|
94
|
+
setIsNarrowViewport(media.matches)
|
|
95
|
+
media.addEventListener('change', updateViewport)
|
|
96
|
+
onCleanup(() => media.removeEventListener('change', updateViewport))
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const renderSidebar = (mobile: boolean) => {
|
|
100
|
+
let element: HTMLElement | undefined
|
|
101
|
+
const context: ContextualSidebarRenderContext = {
|
|
102
|
+
mobile,
|
|
103
|
+
portalMount: () => (mobile ? portalMount() : undefined),
|
|
104
|
+
}
|
|
105
|
+
const navigationId = `${id}-${mobile ? 'mobile' : 'desktop'}`
|
|
106
|
+
|
|
107
|
+
onCleanup(() => {
|
|
108
|
+
if (mobile && mobileMount()?.element === element) setMobileMount(undefined)
|
|
109
|
+
element = undefined
|
|
110
|
+
props.onSidebarElement?.(undefined, mobile)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<SidebarNav
|
|
115
|
+
as="aside"
|
|
116
|
+
id={navigationId}
|
|
117
|
+
aria-label={props.label}
|
|
118
|
+
aria-hidden={!mobile && !props.open ? 'true' : undefined}
|
|
119
|
+
inert={!mobile && !props.open}
|
|
120
|
+
data-contextual-sidebar={mobile ? 'mobile' : 'desktop'}
|
|
121
|
+
data-open={mobile ? undefined : String(props.open)}
|
|
122
|
+
ref={(node) => {
|
|
123
|
+
element = node
|
|
124
|
+
if (mobile) {
|
|
125
|
+
setMobileMount({ element: node, connected: node.isConnected })
|
|
126
|
+
queueMicrotask(() => {
|
|
127
|
+
if (node.isConnected && mobileMount()?.element === node)
|
|
128
|
+
setMobileMount({ element: node, connected: true })
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
props.onSidebarElement?.(node, mobile)
|
|
132
|
+
}}
|
|
133
|
+
class={cn('relative h-full w-full max-w-full', props.sidebarClass)}
|
|
134
|
+
>
|
|
135
|
+
<Show when={!mobile && props.open}>
|
|
136
|
+
<PixelResizeHandle
|
|
137
|
+
side="left"
|
|
138
|
+
value={props.width}
|
|
139
|
+
minimum={props.minimum}
|
|
140
|
+
maximum={props.maximum}
|
|
141
|
+
step={props.step}
|
|
142
|
+
label={resizeLabel()}
|
|
143
|
+
controls={navigationId}
|
|
144
|
+
onChange={props.onWidthChange}
|
|
145
|
+
onCommit={props.onWidthCommit}
|
|
146
|
+
/>
|
|
147
|
+
</Show>
|
|
148
|
+
<Show when={!mobile || mobileMount()?.connected}>
|
|
149
|
+
<SidebarNavHeader class={cn(mobile && 'pe-12', props.headerClass)}>
|
|
150
|
+
<SidebarNavTitle as={props.headingAs ?? 'h2'}>{props.title}</SidebarNavTitle>
|
|
151
|
+
{props.header?.(context)}
|
|
152
|
+
</SidebarNavHeader>
|
|
153
|
+
<SidebarNavContent class={props.contentClass}>{props.content(context)}</SidebarNavContent>
|
|
154
|
+
{props.footer ? (
|
|
155
|
+
<SidebarNavFooter class={props.footerClass}>{props.footer(context)}</SidebarNavFooter>
|
|
156
|
+
) : null}
|
|
157
|
+
</Show>
|
|
158
|
+
</SidebarNav>
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<Sheet
|
|
164
|
+
open={isNarrowViewport() && props.open}
|
|
165
|
+
onOpenChange={(open) => props.onOpenChange(open)}
|
|
166
|
+
>
|
|
167
|
+
<Show when={!isNarrowViewport()}>{(_wide) => renderSidebar(false)}</Show>
|
|
168
|
+
<Show when={isNarrowViewport()}>
|
|
169
|
+
<SheetContent
|
|
170
|
+
side="start"
|
|
171
|
+
class={cn('gap-0 p-0', props.sheetClass)}
|
|
172
|
+
restoreFocusRef={props.restoreFocusRef}
|
|
173
|
+
>
|
|
174
|
+
<SheetTitle class="sr-only">{props.title} navigation</SheetTitle>
|
|
175
|
+
{renderSidebar(true)}
|
|
176
|
+
</SheetContent>
|
|
177
|
+
</Show>
|
|
178
|
+
</Sheet>
|
|
179
|
+
)
|
|
180
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PixelResizeHandle, type PixelResizeHandleProps } from './pixel-resize-handle'
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '../../ui/resizable'
|
|
2
|
+
import { createSignal, onCleanup } from 'solid-js'
|
|
3
|
+
import { cn } from '../../../lib/utils'
|
|
4
|
+
|
|
5
|
+
export type PixelResizeHandleProps = {
|
|
6
|
+
/** Which physical edge of the ruler the resizable surface is attached to. */
|
|
7
|
+
side: 'left' | 'right'
|
|
8
|
+
/** Current width in CSS pixels. */
|
|
9
|
+
value: number
|
|
10
|
+
minimum: number
|
|
11
|
+
maximum: number
|
|
12
|
+
step?: number
|
|
13
|
+
label?: string
|
|
14
|
+
controls?: string
|
|
15
|
+
class?: string
|
|
16
|
+
onChange(value: number): void
|
|
17
|
+
onCommit?(value: number): void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* PixelResizeHandle.
|
|
22
|
+
*
|
|
23
|
+
* A keyboard- and pointer-operable edge ruler for a host-owned pane. Keep the
|
|
24
|
+
* pane's actual width and any persistence in its layout owner; this component
|
|
25
|
+
* reports a bounded pixel value and places the shared resizable grip at the
|
|
26
|
+
* matching left or right edge.
|
|
27
|
+
*
|
|
28
|
+
* Corvu 0.2.5 supplies geometry, keyboard resizing, ARIA and the shared grip,
|
|
29
|
+
* but its global drag handler does not end on pointer cancellation. Prevent
|
|
30
|
+
* that handler through its public start hook and use local pointer capture
|
|
31
|
+
* for bounded pixel gestures, including cancellation and lost capture.
|
|
32
|
+
*/
|
|
33
|
+
export function PixelResizeHandle(props: PixelResizeHandleProps) {
|
|
34
|
+
const maximum = () => Math.max(1, props.maximum)
|
|
35
|
+
const minimum = () => Math.min(maximum(), Math.max(0, props.minimum))
|
|
36
|
+
const value = () => Math.min(maximum(), Math.max(minimum(), Math.round(props.value)))
|
|
37
|
+
const ratio = () => value() / maximum()
|
|
38
|
+
const isRight = () => props.side === 'right'
|
|
39
|
+
const rulerSizes = () => (isRight() ? [1 - ratio(), ratio()] : [ratio(), 1 - ratio()])
|
|
40
|
+
const commit = () => props.onCommit?.(value())
|
|
41
|
+
let interacting = false
|
|
42
|
+
const [drag, setDrag] = createSignal<{
|
|
43
|
+
pointerId: number
|
|
44
|
+
startX: number
|
|
45
|
+
startValue: number
|
|
46
|
+
handle: HTMLElement
|
|
47
|
+
}>()
|
|
48
|
+
const endPointer = (shouldCommit: boolean) => {
|
|
49
|
+
const current = drag()
|
|
50
|
+
if (!current) return
|
|
51
|
+
setDrag(undefined)
|
|
52
|
+
if (current.handle.hasPointerCapture(current.pointerId))
|
|
53
|
+
current.handle.releasePointerCapture(current.pointerId)
|
|
54
|
+
if (shouldCommit) commit()
|
|
55
|
+
}
|
|
56
|
+
const endKeyboard = () => {
|
|
57
|
+
const wasInteracting = interacting
|
|
58
|
+
interacting = false
|
|
59
|
+
if (wasInteracting) commit()
|
|
60
|
+
}
|
|
61
|
+
onCleanup(() => {
|
|
62
|
+
endKeyboard()
|
|
63
|
+
endPointer(false)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<ResizablePanelGroup
|
|
68
|
+
orientation="horizontal"
|
|
69
|
+
dir="ltr"
|
|
70
|
+
sizes={rulerSizes()}
|
|
71
|
+
keyboardDelta={`${props.step ?? 16}px`}
|
|
72
|
+
style={{ width: `${maximum()}px` }}
|
|
73
|
+
class={cn(
|
|
74
|
+
'pointer-events-none absolute inset-y-0 flex',
|
|
75
|
+
{
|
|
76
|
+
'left-0': props.side === 'left',
|
|
77
|
+
'right-0': props.side === 'right',
|
|
78
|
+
},
|
|
79
|
+
props.class
|
|
80
|
+
)}
|
|
81
|
+
onSizesChange={(sizes) => {
|
|
82
|
+
// Panel registration and teardown also emit sizes. Only user resizing
|
|
83
|
+
// may update the host preference; collapsing must preserve its width.
|
|
84
|
+
if (!interacting || sizes.length !== 2) return
|
|
85
|
+
const next = Math.round((sizes[isRight() ? 1 : 0] ?? ratio()) * maximum())
|
|
86
|
+
const bounded = Math.min(maximum(), Math.max(minimum(), next))
|
|
87
|
+
if (bounded !== value()) props.onChange(bounded)
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<ResizablePanel
|
|
91
|
+
minSize={isRight() ? 0 : minimum() / maximum()}
|
|
92
|
+
maxSize={1}
|
|
93
|
+
aria-hidden="true"
|
|
94
|
+
/>
|
|
95
|
+
<ResizableHandle
|
|
96
|
+
withHandle
|
|
97
|
+
label={props.label ?? `Resize ${props.side} pane`}
|
|
98
|
+
aria-controls={props.controls}
|
|
99
|
+
aria-valuemin={minimum()}
|
|
100
|
+
aria-valuemax={maximum()}
|
|
101
|
+
aria-valuenow={value()}
|
|
102
|
+
aria-valuetext={`${value()} pixels`}
|
|
103
|
+
data-dragging={drag() ? '' : undefined}
|
|
104
|
+
onHandleDragStart={(event) => {
|
|
105
|
+
// Corvu checks defaultPrevented before starting its global handler.
|
|
106
|
+
event.preventDefault()
|
|
107
|
+
if (event.button !== 0 || !event.isPrimary) return
|
|
108
|
+
const handle = event.currentTarget
|
|
109
|
+
if (!(handle instanceof HTMLElement)) return
|
|
110
|
+
endPointer(false)
|
|
111
|
+
interacting = false
|
|
112
|
+
handle.focus()
|
|
113
|
+
handle.setPointerCapture(event.pointerId)
|
|
114
|
+
setDrag({
|
|
115
|
+
pointerId: event.pointerId,
|
|
116
|
+
startX: event.clientX,
|
|
117
|
+
startValue: value(),
|
|
118
|
+
handle,
|
|
119
|
+
})
|
|
120
|
+
}}
|
|
121
|
+
onPointerMove={(event: PointerEvent) => {
|
|
122
|
+
const current = drag()
|
|
123
|
+
if (!current || event.pointerId !== current.pointerId) return
|
|
124
|
+
if (!current.handle.hasPointerCapture(current.pointerId)) {
|
|
125
|
+
endPointer(false)
|
|
126
|
+
return
|
|
127
|
+
}
|
|
128
|
+
const delta = (event.clientX - current.startX) * (isRight() ? -1 : 1)
|
|
129
|
+
const next = Math.min(
|
|
130
|
+
maximum(),
|
|
131
|
+
Math.max(minimum(), Math.round(current.startValue + delta))
|
|
132
|
+
)
|
|
133
|
+
if (next !== value()) props.onChange(next)
|
|
134
|
+
}}
|
|
135
|
+
onPointerUp={(event: PointerEvent) => {
|
|
136
|
+
if (event.pointerId === drag()?.pointerId) endPointer(true)
|
|
137
|
+
}}
|
|
138
|
+
onPointerCancel={(event: PointerEvent) => {
|
|
139
|
+
if (event.pointerId === drag()?.pointerId) endPointer(false)
|
|
140
|
+
}}
|
|
141
|
+
onLostPointerCapture={(event: PointerEvent) => {
|
|
142
|
+
if (event.pointerId === drag()?.pointerId) endPointer(false)
|
|
143
|
+
}}
|
|
144
|
+
onBlur={() => {
|
|
145
|
+
endKeyboard()
|
|
146
|
+
endPointer(false)
|
|
147
|
+
}}
|
|
148
|
+
onKeyDown={(event) => {
|
|
149
|
+
const current = drag()
|
|
150
|
+
if (current && !current.handle.hasPointerCapture(current.pointerId)) endPointer(false)
|
|
151
|
+
if (drag()) {
|
|
152
|
+
event.preventDefault()
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) interacting = true
|
|
156
|
+
// Corvu operates on physical panel order. Home/End here describe
|
|
157
|
+
// the controlled pane width, including a pane after the separator.
|
|
158
|
+
if (event.key === 'Home' || event.key === 'End') {
|
|
159
|
+
event.preventDefault()
|
|
160
|
+
props.onChange(event.key === 'Home' ? minimum() : maximum())
|
|
161
|
+
}
|
|
162
|
+
}}
|
|
163
|
+
onKeyUp={(event) => {
|
|
164
|
+
if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) {
|
|
165
|
+
endKeyboard()
|
|
166
|
+
}
|
|
167
|
+
}}
|
|
168
|
+
class="pointer-events-auto"
|
|
169
|
+
/>
|
|
170
|
+
<ResizablePanel
|
|
171
|
+
minSize={isRight() ? minimum() / maximum() : 0}
|
|
172
|
+
maxSize={1}
|
|
173
|
+
aria-hidden="true"
|
|
174
|
+
/>
|
|
175
|
+
</ResizablePanelGroup>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
@@ -1,59 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
PixelResizeHandle,
|
|
3
|
+
type PixelResizeHandleProps,
|
|
4
|
+
} from '../pixel-resize-handle/pixel-resize-handle'
|
|
3
5
|
|
|
4
|
-
export type SidebarNavResizeHandleProps =
|
|
5
|
-
value: number
|
|
6
|
-
minimum: number
|
|
7
|
-
maximum: number
|
|
8
|
-
step?: number
|
|
9
|
-
label?: string
|
|
10
|
-
controls?: string
|
|
11
|
-
class?: string
|
|
12
|
-
onChange(value: number): void
|
|
13
|
-
onCommit?(value: number): void
|
|
14
|
-
}
|
|
6
|
+
export type SidebarNavResizeHandleProps = Omit<PixelResizeHandleProps, 'side'>
|
|
15
7
|
|
|
16
|
-
/**
|
|
17
|
-
* Resize a contextual sidebar without making its host recreate a separator
|
|
18
|
-
* widget. Corvu owns pointer capture, cancellation, constraints, keyboard
|
|
19
|
-
* movement and cleanup. Its two invisible panels provide a bounded pixel
|
|
20
|
-
* ruler; the host retains the real pane layout and preference persistence.
|
|
21
|
-
* Place this inside the positioned sidebar. The ruler can extend over the
|
|
22
|
-
* adjacent content, but only its handle participates in pointer hit testing.
|
|
23
|
-
*/
|
|
8
|
+
/** Keep the established left-sidebar API as a thin adapter over the shared edge ruler. */
|
|
24
9
|
export function SidebarNavResizeHandle(props: SidebarNavResizeHandleProps) {
|
|
25
|
-
|
|
26
|
-
const minimum = () => Math.min(maximum(), Math.max(0, props.minimum))
|
|
27
|
-
const value = () => Math.min(maximum(), Math.max(minimum(), props.value))
|
|
28
|
-
const commit = () => props.onCommit?.(value())
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Resizable
|
|
32
|
-
orientation="horizontal"
|
|
33
|
-
sizes={[value() / maximum(), 1 - value() / maximum()]}
|
|
34
|
-
keyboardDelta={`${props.step ?? 16}px`}
|
|
35
|
-
style={{ width: `${maximum()}px` }}
|
|
36
|
-
class={cn('pointer-events-none absolute inset-y-0 start-0 flex', props.class)}
|
|
37
|
-
onSizesChange={(sizes) => {
|
|
38
|
-
const next = Math.round((sizes[0] ?? 0) * maximum())
|
|
39
|
-
if (next !== value()) props.onChange(Math.min(maximum(), Math.max(minimum(), next)))
|
|
40
|
-
}}
|
|
41
|
-
>
|
|
42
|
-
<Resizable.Panel minSize={minimum() / maximum()} maxSize={1} aria-hidden="true" />
|
|
43
|
-
<Resizable.Handle
|
|
44
|
-
aria-label={props.label ?? 'Resize navigation'}
|
|
45
|
-
aria-controls={props.controls}
|
|
46
|
-
aria-orientation="vertical"
|
|
47
|
-
aria-valuemin={minimum()}
|
|
48
|
-
aria-valuemax={maximum()}
|
|
49
|
-
aria-valuenow={value()}
|
|
50
|
-
onHandleDragEnd={commit}
|
|
51
|
-
onKeyUp={(event) => {
|
|
52
|
-
if (['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) commit()
|
|
53
|
-
}}
|
|
54
|
-
class="pointer-events-auto relative z-(--z-docked) w-px -translate-x-full shrink-0 bg-transparent after:absolute after:inset-y-0 after:-inset-x-1 after:w-3 hover:bg-primary focus-visible:bg-primary focus-visible:ring-3 focus-visible:ring-primary-subtle focus-visible:outline-none"
|
|
55
|
-
/>
|
|
56
|
-
<Resizable.Panel minSize={0} aria-hidden="true" />
|
|
57
|
-
</Resizable>
|
|
58
|
-
)
|
|
10
|
+
return <PixelResizeHandle {...props} side="left" label={props.label ?? 'Resize navigation'} />
|
|
59
11
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.dev-annotation-surface {
|
|
2
|
+
touch-action: none;
|
|
3
|
+
cursor: crosshair;
|
|
4
|
+
background-image: repeating-linear-gradient(
|
|
5
|
+
45deg,
|
|
6
|
+
color-mix(in oklch, var(--muted) 55%, transparent) 0 calc(var(--spacing) * 2),
|
|
7
|
+
transparent calc(var(--spacing) * 2) calc(var(--spacing) * 4)
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.dev-annotation-surface[data-tool='point'] {
|
|
12
|
+
cursor: cell;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.dev-annotation-surface[data-dragging='true'] {
|
|
16
|
+
cursor: grabbing;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.dev-annotation-surface[aria-disabled='true'] {
|
|
20
|
+
touch-action: auto;
|
|
21
|
+
cursor: default;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.dev-annotation-surface__region,
|
|
25
|
+
.dev-annotation-surface__hint {
|
|
26
|
+
pointer-events: none;
|
|
27
|
+
}
|