@cloudvoyant/helical-svelte 0.19.0 → 0.20.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.
|
@@ -22,13 +22,15 @@
|
|
|
22
22
|
children?: Snippet;
|
|
23
23
|
} & HTMLAttributes<HTMLDivElement>;
|
|
24
24
|
|
|
25
|
-
let { defaultOpen =
|
|
25
|
+
let { defaultOpen = false, open: openProp, onOpenChange, class: className = '', style, children, ...rest }: Props = $props();
|
|
26
26
|
|
|
27
27
|
let isMobile = $state(false);
|
|
28
28
|
let openMobile = $state(false);
|
|
29
29
|
// svelte-ignore state_referenced_locally
|
|
30
30
|
let _open = $state(defaultOpen);
|
|
31
31
|
const open = $derived(openProp ?? _open);
|
|
32
|
+
const isControlled = openProp !== undefined;
|
|
33
|
+
const usesMobileSheetState = $derived(isMobile && !isControlled);
|
|
32
34
|
const contextState = $derived<SidebarContextProps['state']>(open ? 'expanded' : 'collapsed');
|
|
33
35
|
|
|
34
36
|
const setOpen = (value: boolean | ((value: boolean) => boolean)) => {
|
|
@@ -44,7 +46,7 @@
|
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
const toggleSidebar = () => {
|
|
47
|
-
if (
|
|
49
|
+
if (usesMobileSheetState) {
|
|
48
50
|
openMobile = !openMobile;
|
|
49
51
|
} else {
|
|
50
52
|
setOpen((o) => !o);
|
|
@@ -90,6 +92,9 @@
|
|
|
90
92
|
return isMobile;
|
|
91
93
|
},
|
|
92
94
|
toggleSidebar,
|
|
95
|
+
get isControlled() {
|
|
96
|
+
return isControlled;
|
|
97
|
+
},
|
|
93
98
|
});
|
|
94
99
|
</script>
|
|
95
100
|
|
package/dist/sidebar/Root.svelte
CHANGED
|
@@ -9,8 +9,16 @@
|
|
|
9
9
|
DrawerTitle,
|
|
10
10
|
DrawerDescription,
|
|
11
11
|
DrawerCloseTrigger,
|
|
12
|
+
DrawerGrabber,
|
|
13
|
+
DrawerGrabberIndicator,
|
|
12
14
|
} from '@ark-ui/svelte/drawer';
|
|
13
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
SIDEBAR_WIDTH_MOBILE,
|
|
17
|
+
SIDEBAR_WIDGET_SNAP_POINTS,
|
|
18
|
+
SIDEBAR_WIDGET_DEFAULT_SNAP_POINT,
|
|
19
|
+
sidebarStyles,
|
|
20
|
+
cn,
|
|
21
|
+
} from '@cloudvoyant/helical-ui';
|
|
14
22
|
import Col from '../Col.svelte';
|
|
15
23
|
import { getSidebarContext } from './context.svelte';
|
|
16
24
|
import type { Snippet } from 'svelte';
|
|
@@ -36,8 +44,18 @@
|
|
|
36
44
|
const sidebar = getSidebarContext();
|
|
37
45
|
const state = $derived(sidebar.state);
|
|
38
46
|
const isMobile = $derived(sidebar.isMobile);
|
|
47
|
+
const open = $derived(sidebar.open);
|
|
48
|
+
const setOpen = sidebar.setOpen;
|
|
39
49
|
const openMobile = $derived(sidebar.openMobile);
|
|
40
50
|
const setOpenMobile = sidebar.setOpenMobile;
|
|
51
|
+
const isControlled = $derived(sidebar.isControlled);
|
|
52
|
+
|
|
53
|
+
const isBottomWidgetSheet = $derived(side === 'right');
|
|
54
|
+
const mobileSheetOpen = $derived(isControlled ? open : openMobile);
|
|
55
|
+
const setMobileSheetOpen = (value: boolean) => (isControlled ? setOpen(value) : setOpenMobile(value));
|
|
56
|
+
const snapPoints = $derived(isBottomWidgetSheet ? SIDEBAR_WIDGET_SNAP_POINTS : undefined);
|
|
57
|
+
const defaultSnapPoint = $derived(isBottomWidgetSheet ? SIDEBAR_WIDGET_DEFAULT_SNAP_POINT : undefined);
|
|
58
|
+
const snapToSequentialPoints = $derived(isBottomWidgetSheet);
|
|
41
59
|
|
|
42
60
|
const containerClasses = $derived(
|
|
43
61
|
cn(
|
|
@@ -73,20 +91,39 @@
|
|
|
73
91
|
{@render children?.()}
|
|
74
92
|
</Col>
|
|
75
93
|
{:else if isMobile}
|
|
76
|
-
<DrawerRoot
|
|
77
|
-
|
|
78
|
-
|
|
94
|
+
<DrawerRoot
|
|
95
|
+
open={mobileSheetOpen}
|
|
96
|
+
onOpenChange={(details) => setMobileSheetOpen(details.open)}
|
|
97
|
+
swipeDirection={side === 'left' ? 'start' : 'down'}
|
|
98
|
+
modal={!isBottomWidgetSheet}
|
|
99
|
+
{snapPoints}
|
|
100
|
+
{defaultSnapPoint}
|
|
101
|
+
{snapToSequentialPoints}
|
|
102
|
+
preventDragOnScroll={false}
|
|
103
|
+
{...rest}
|
|
104
|
+
>
|
|
105
|
+
{#if !isBottomWidgetSheet}
|
|
106
|
+
<DrawerBackdrop class={sidebarStyles.mobileBackdropClass} />
|
|
107
|
+
{/if}
|
|
108
|
+
<DrawerPositioner class={sidebarStyles.mobilePositionerClass}>
|
|
79
109
|
<DrawerContent
|
|
80
110
|
data-sidebar="sidebar"
|
|
81
111
|
data-slot="sidebar"
|
|
82
112
|
data-mobile="true"
|
|
83
|
-
class=
|
|
113
|
+
class={cn(sidebarStyles.mobileContentClass, className)}
|
|
84
114
|
style={`--sidebar-width: ${SIDEBAR_WIDTH_MOBILE};`}
|
|
85
115
|
>
|
|
86
116
|
<DrawerTitle class="sr-only">Sidebar</DrawerTitle>
|
|
87
117
|
<DrawerDescription class="sr-only">Displays the mobile sidebar.</DrawerDescription>
|
|
88
118
|
<DrawerCloseTrigger class="hidden" />
|
|
89
|
-
|
|
119
|
+
{#if isBottomWidgetSheet}
|
|
120
|
+
<DrawerGrabber class={sidebarStyles.mobileGrabberClass}>
|
|
121
|
+
<DrawerGrabberIndicator class={sidebarStyles.mobileGrabberIndicatorClass} />
|
|
122
|
+
</DrawerGrabber>
|
|
123
|
+
{/if}
|
|
124
|
+
<div data-no-drag class="flex min-h-0 flex-1 flex-col">
|
|
125
|
+
<Col class="h-full w-full">{@render children?.()}</Col>
|
|
126
|
+
</div>
|
|
90
127
|
</DrawerContent>
|
|
91
128
|
</DrawerPositioner>
|
|
92
129
|
</DrawerRoot>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudvoyant/helical-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "helical-ui Svelte UI components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"lucide-svelte": "^0.577.0",
|
|
44
44
|
"lowlight": "^3.3.0",
|
|
45
45
|
"svelte-tiptap": "^3.0.1",
|
|
46
|
-
"@cloudvoyant/helical-ui": "0.
|
|
46
|
+
"@cloudvoyant/helical-ui": "0.20.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@sveltejs/package": "^2.5.8",
|