@aleph-alpha/ui-library 2.12.0 → 3.1.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/system/components/core/sidebar/SidebarProvider.vue.d.ts +2 -0
- package/dist/system/components/core/sidebar/utils.d.ts +1 -1
- package/dist/system/index.d.ts +1 -0
- package/dist/system/lib/useDevice.d.ts +59 -0
- package/dist/system/lib.js +13579 -13483
- package/dist/system/patterns/UiSidebar/UiSidebarProvider.vue.d.ts +10 -1
- package/dist/system/patterns/UiSidebar/__tests__/sidebar-test-helpers.d.ts +55 -6
- package/dist/system/patterns/UiSidebar/index.d.ts +1 -1
- package/dist/system/patterns/UiSidebar/types.d.ts +26 -2
- package/package.json +2 -2
- package/src/components/UiButton/UiButton.stories.ts +2 -2
- package/src/components/UiCheckbox/UiCheckbox.stories.ts +2 -2
- package/src/components/UiField/UiField.stories.ts +3 -2
- package/src/components/UiItem/UiItem.stories.ts +2 -2
- package/src/components/core/sidebar/Sidebar.vue +25 -27
- package/src/components/core/sidebar/SidebarInset.vue +13 -1
- package/src/components/core/sidebar/SidebarProvider.vue +22 -2
- package/src/components/core/sidebar/SidebarTrigger.vue +2 -2
- package/src/components/core/sidebar/utils.ts +1 -1
- package/src/directives/vHover.stories.ts +3 -0
- package/src/index.ts +1 -0
- package/src/lib/useDevice.stories.ts +407 -0
- package/src/lib/useDevice.test.ts +129 -0
- package/src/lib/useDevice.ts +199 -0
- package/src/lib/useDrag.stories.ts +3 -0
- package/src/patterns/UiSidebar/UiSidebar.stories.ts +14 -1
- package/src/patterns/UiSidebar/UiSidebarProvider.vue +21 -1
- package/src/patterns/UiSidebar/UiSidebarTrigger.vue +39 -5
- package/src/patterns/UiSidebar/__tests__/UiSidebar.test.ts +66 -1
- package/src/patterns/UiSidebar/__tests__/UiSidebarHeader.test.ts +1 -1
- package/src/patterns/UiSidebar/__tests__/UiSidebarTrigger.test.ts +1 -1
- package/src/patterns/UiSidebar/__tests__/sidebar-test-helpers.ts +21 -0
- package/src/patterns/UiSidebar/index.ts +1 -0
- package/src/patterns/UiSidebar/types.ts +29 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UiSidebarProviderProps } from './types';
|
|
1
2
|
declare function __VLS_template(): {
|
|
2
3
|
attrs: Partial<{}>;
|
|
3
4
|
slots: {
|
|
@@ -7,7 +8,15 @@ declare function __VLS_template(): {
|
|
|
7
8
|
rootEl: any;
|
|
8
9
|
};
|
|
9
10
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
10
|
-
declare const __VLS_component: import('vue').DefineComponent<
|
|
11
|
+
declare const __VLS_component: import('vue').DefineComponent<UiSidebarProviderProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
12
|
+
"update:open": (open: boolean) => any;
|
|
13
|
+
}, string, import('vue').PublicProps, Readonly<UiSidebarProviderProps> & Readonly<{
|
|
14
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
15
|
+
}>, {
|
|
16
|
+
open: boolean;
|
|
17
|
+
defaultOpen: boolean;
|
|
18
|
+
mobileTransitionDuration: string;
|
|
19
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
11
20
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
12
21
|
export default _default;
|
|
13
22
|
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
* Call from `beforeEach`; pair with `vi.restoreAllMocks()` in `afterEach`.
|
|
4
4
|
*/
|
|
5
5
|
export declare function mockMatchMediaDesktop(): void;
|
|
6
|
+
/**
|
|
7
|
+
* Mobile viewport for `useMediaQuery('(max-width: 768px)')` in `SidebarProvider` / `Sidebar`.
|
|
8
|
+
* Call from a test before rendering; pair with `vi.restoreAllMocks()` in `afterEach`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function mockMatchMediaMobile(): void;
|
|
6
11
|
/**
|
|
7
12
|
* Provider + non-collapsing sidebar + content region (typical pattern shell).
|
|
8
13
|
* @param innerTemplate
|
|
@@ -11,18 +16,40 @@ export declare function mockMatchMediaDesktop(): void;
|
|
|
11
16
|
export declare function createSidebarShell(innerTemplate: string, extraComponents?: Record<string, unknown>): {
|
|
12
17
|
components: {
|
|
13
18
|
UiSidebarProvider: {
|
|
14
|
-
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<
|
|
19
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('..').UiSidebarProviderProps> & Readonly<{
|
|
20
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
21
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
22
|
+
"update:open": (open: boolean) => any;
|
|
23
|
+
}, import('vue').PublicProps, {
|
|
24
|
+
open: boolean;
|
|
25
|
+
defaultOpen: boolean;
|
|
26
|
+
mobileTransitionDuration: string;
|
|
27
|
+
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
15
28
|
P: {};
|
|
16
29
|
B: {};
|
|
17
30
|
D: {};
|
|
18
31
|
C: {};
|
|
19
32
|
M: {};
|
|
20
33
|
Defaults: {};
|
|
21
|
-
}, Readonly<
|
|
34
|
+
}, Readonly<import('..').UiSidebarProviderProps> & Readonly<{
|
|
35
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
36
|
+
}>, {}, {}, {}, {}, {
|
|
37
|
+
open: boolean;
|
|
38
|
+
defaultOpen: boolean;
|
|
39
|
+
mobileTransitionDuration: string;
|
|
40
|
+
}>;
|
|
22
41
|
__isFragment?: never;
|
|
23
42
|
__isTeleport?: never;
|
|
24
43
|
__isSuspense?: never;
|
|
25
|
-
} & import('vue').ComponentOptionsBase<Readonly<
|
|
44
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('..').UiSidebarProviderProps> & Readonly<{
|
|
45
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
46
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
47
|
+
"update:open": (open: boolean) => any;
|
|
48
|
+
}, string, {
|
|
49
|
+
open: boolean;
|
|
50
|
+
defaultOpen: boolean;
|
|
51
|
+
mobileTransitionDuration: string;
|
|
52
|
+
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
26
53
|
$slots: {
|
|
27
54
|
default?(_: {}): any;
|
|
28
55
|
};
|
|
@@ -87,18 +114,40 @@ export declare function createSidebarShell(innerTemplate: string, extraComponent
|
|
|
87
114
|
export declare function createOffcanvasSidebar(innerTemplate: string, extraComponents?: Record<string, unknown>): {
|
|
88
115
|
components: {
|
|
89
116
|
UiSidebarProvider: {
|
|
90
|
-
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<
|
|
117
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('..').UiSidebarProviderProps> & Readonly<{
|
|
118
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
119
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
120
|
+
"update:open": (open: boolean) => any;
|
|
121
|
+
}, import('vue').PublicProps, {
|
|
122
|
+
open: boolean;
|
|
123
|
+
defaultOpen: boolean;
|
|
124
|
+
mobileTransitionDuration: string;
|
|
125
|
+
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
91
126
|
P: {};
|
|
92
127
|
B: {};
|
|
93
128
|
D: {};
|
|
94
129
|
C: {};
|
|
95
130
|
M: {};
|
|
96
131
|
Defaults: {};
|
|
97
|
-
}, Readonly<
|
|
132
|
+
}, Readonly<import('..').UiSidebarProviderProps> & Readonly<{
|
|
133
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
134
|
+
}>, {}, {}, {}, {}, {
|
|
135
|
+
open: boolean;
|
|
136
|
+
defaultOpen: boolean;
|
|
137
|
+
mobileTransitionDuration: string;
|
|
138
|
+
}>;
|
|
98
139
|
__isFragment?: never;
|
|
99
140
|
__isTeleport?: never;
|
|
100
141
|
__isSuspense?: never;
|
|
101
|
-
} & import('vue').ComponentOptionsBase<Readonly<
|
|
142
|
+
} & import('vue').ComponentOptionsBase<Readonly<import('..').UiSidebarProviderProps> & Readonly<{
|
|
143
|
+
"onUpdate:open"?: ((open: boolean) => any) | undefined;
|
|
144
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
145
|
+
"update:open": (open: boolean) => any;
|
|
146
|
+
}, string, {
|
|
147
|
+
open: boolean;
|
|
148
|
+
defaultOpen: boolean;
|
|
149
|
+
mobileTransitionDuration: string;
|
|
150
|
+
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
102
151
|
$slots: {
|
|
103
152
|
default?(_: {}): any;
|
|
104
153
|
};
|
|
@@ -19,4 +19,4 @@ export { default as UiSidebarSub } from './UiSidebarSub.vue';
|
|
|
19
19
|
export { default as UiSidebarProvider } from './UiSidebarProvider.vue';
|
|
20
20
|
export { default as UiSidebarRail } from './UiSidebarRail.vue';
|
|
21
21
|
export { default as UiSidebarTrigger } from './UiSidebarTrigger.vue';
|
|
22
|
-
export type { UiSidebarContentProps, UiSidebarFooterProps, UiSidebarGroupContentProps, UiSidebarGroupLabelEmits, UiSidebarGroupLabelProps, UiSidebarGroupProps, UiSidebarHeaderProps, UiSidebarInsetProps, UiSidebarMenuButtonEmits, UiSidebarMenuButtonProps, UiSidebarMenuItemProps, UiSidebarMenuProps, UiSidebarMenuSubItemProps, UiSidebarMenuSubProps, UiSidebarSubProps, UiSidebarPopoverMenuItemEmits, UiSidebarPopoverMenuItemProps, UiSidebarPopoverMenuProps, UiSidebarPopoverProps, UiSidebarPopoverTriggerProps, UiSidebarProviderProps, UiSidebarProps, UiSidebarRailProps, UiSidebarTriggerProps, } from './types';
|
|
22
|
+
export type { UiSidebarContentProps, UiSidebarFooterProps, UiSidebarGroupContentProps, UiSidebarGroupLabelEmits, UiSidebarGroupLabelProps, UiSidebarGroupProps, UiSidebarHeaderProps, UiSidebarInsetProps, UiSidebarMenuButtonEmits, UiSidebarMenuButtonProps, UiSidebarMenuItemProps, UiSidebarMenuProps, UiSidebarMenuSubItemProps, UiSidebarMenuSubProps, UiSidebarSubProps, UiSidebarPopoverMenuItemEmits, UiSidebarPopoverMenuItemProps, UiSidebarPopoverMenuProps, UiSidebarPopoverProps, UiSidebarPopoverTriggerProps, UiSidebarProviderEmits, UiSidebarProviderProps, UiSidebarProps, UiSidebarRailProps, UiSidebarTriggerProps, } from './types';
|
|
@@ -302,9 +302,33 @@ export type UiSidebarMenuProps = Record<string, never>;
|
|
|
302
302
|
*/
|
|
303
303
|
export type UiSidebarMenuItemProps = Record<string, never>;
|
|
304
304
|
/**
|
|
305
|
-
*
|
|
305
|
+
* Provider props for the sidebar open state.
|
|
306
|
+
*/
|
|
307
|
+
export interface UiSidebarProviderProps {
|
|
308
|
+
/**
|
|
309
|
+
* Initial expanded state for uncontrolled desktop sidebars.
|
|
310
|
+
* Mobile sidebars remain collapsed by default unless `open` is controlled.
|
|
311
|
+
*/
|
|
312
|
+
defaultOpen?: boolean;
|
|
313
|
+
/**
|
|
314
|
+
* CSS duration used for the mobile sidebar and content slide animation.
|
|
315
|
+
* @default '20ms'
|
|
316
|
+
*/
|
|
317
|
+
mobileTransitionDuration?: string;
|
|
318
|
+
/**
|
|
319
|
+
* Controlled open state. On mobile this controls the sheet visibility.
|
|
320
|
+
*/
|
|
321
|
+
open?: boolean;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Emitted events for `UiSidebarProvider`.
|
|
306
325
|
*/
|
|
307
|
-
export
|
|
326
|
+
export interface UiSidebarProviderEmits {
|
|
327
|
+
/**
|
|
328
|
+
* Fired when desktop collapse state or mobile sheet visibility changes.
|
|
329
|
+
*/
|
|
330
|
+
'update:open': [open: boolean];
|
|
331
|
+
}
|
|
308
332
|
/**
|
|
309
333
|
* @see UiSidebarContentProps
|
|
310
334
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aleph-alpha/ui-library",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/system/lib.js",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"vue-router": "4.6.4",
|
|
82
82
|
"vue-tsc": "^2.2.12",
|
|
83
83
|
"wait-on": "9.0.3",
|
|
84
|
-
"@aleph-alpha/prettier-config-frontend": "2.1.0",
|
|
85
84
|
"@aleph-alpha/eslint-config-frontend": "0.6.0",
|
|
85
|
+
"@aleph-alpha/prettier-config-frontend": "2.1.0",
|
|
86
86
|
"@aleph-alpha/tsconfig-frontend": "0.7.0"
|
|
87
87
|
},
|
|
88
88
|
"peerDependencies": {
|
|
@@ -17,9 +17,9 @@ const MailIcon = {
|
|
|
17
17
|
template: '<UiIcon name="mail" :size="16" />',
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
const designStoryLink = '
|
|
20
|
+
const designStoryLink = './?path=/docs/components-uibutton--design-notes';
|
|
21
21
|
const accessibilityStoryLink =
|
|
22
|
-
'
|
|
22
|
+
'./?path=/docs/components-uibutton--accessibility';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Buttons are used to initiate actions within an application. Their labels clearly describe the action they trigger.
|
|
@@ -2,9 +2,9 @@ import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
|
2
2
|
import UiCheckbox from './UiCheckbox.vue';
|
|
3
3
|
import { ref } from 'vue';
|
|
4
4
|
|
|
5
|
-
const designStoryLink = '
|
|
5
|
+
const designStoryLink = './?path=/docs/components-uicheckbox--design-notes';
|
|
6
6
|
const accessibilityStoryLink =
|
|
7
|
-
'
|
|
7
|
+
'./?path=/docs/components-uicheckbox--accessibility';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* A control that allows the user to toggle between checked and not checked.
|
|
@@ -29,8 +29,9 @@ import { UiTextarea } from '../UiTextarea';
|
|
|
29
29
|
import { UiButton } from '../UiButton';
|
|
30
30
|
import { ref } from 'vue';
|
|
31
31
|
|
|
32
|
-
const designStoryLink = '
|
|
33
|
-
const accessibilityStoryLink =
|
|
32
|
+
const designStoryLink = './?path=/docs/components-uifield--design-notes';
|
|
33
|
+
const accessibilityStoryLink =
|
|
34
|
+
'./?path=/docs/components-uifield--accessibility';
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
37
|
* Field composes label, description, and error messaging into a consistent form-field layout. Use it to keep spacing, typography, and validation feedback consistent across inputs.
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
UiAvatarImage,
|
|
21
21
|
} from '../UiAvatar';
|
|
22
22
|
|
|
23
|
-
const designStoryLink = '
|
|
24
|
-
const accessibilityStoryLink = '
|
|
23
|
+
const designStoryLink = './?path=/docs/components-uiitem--design-notes';
|
|
24
|
+
const accessibilityStoryLink = './?path=/docs/components-uiitem--accessibility';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* A versatile component that you can use to display any content.
|
|
@@ -3,10 +3,6 @@ import type { SidebarProps } from '.';
|
|
|
3
3
|
import { defaultWindow } from '@vueuse/core';
|
|
4
4
|
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
|
5
5
|
import { cn } from '@/lib/utils';
|
|
6
|
-
import { Sheet, SheetContent } from '@/components/core/sheet';
|
|
7
|
-
import SheetDescription from '@/components/core/sheet/SheetDescription.vue';
|
|
8
|
-
import SheetHeader from '@/components/core/sheet/SheetHeader.vue';
|
|
9
|
-
import SheetTitle from '@/components/core/sheet/SheetTitle.vue';
|
|
10
6
|
import SidebarResizeHandle from './SidebarResizeHandle.vue';
|
|
11
7
|
import {
|
|
12
8
|
SIDEBAR_WIDTH_DEFAULT,
|
|
@@ -34,7 +30,7 @@ const props = withDefaults(defineProps<SidebarProps>(), {
|
|
|
34
30
|
keyboardResizeBy: 10,
|
|
35
31
|
});
|
|
36
32
|
|
|
37
|
-
const { isMobile, state, openMobile
|
|
33
|
+
const { isMobile, state, openMobile } = useSidebar();
|
|
38
34
|
|
|
39
35
|
const resolvedResizable = computed(
|
|
40
36
|
() => props.resizeOptions !== undefined || props.resizable,
|
|
@@ -227,31 +223,33 @@ onBeforeUnmount(stopResize);
|
|
|
227
223
|
/>
|
|
228
224
|
</div>
|
|
229
225
|
|
|
230
|
-
<
|
|
226
|
+
<div
|
|
231
227
|
v-else-if="isMobile"
|
|
232
|
-
:open="openMobile"
|
|
233
228
|
v-bind="$attrs"
|
|
234
|
-
|
|
229
|
+
:aria-hidden="openMobile ? undefined : 'true'"
|
|
230
|
+
data-sidebar="sidebar"
|
|
231
|
+
data-slot="sidebar"
|
|
232
|
+
data-mobile="true"
|
|
233
|
+
:data-state="openMobile ? 'expanded' : 'collapsed'"
|
|
234
|
+
data-side="left"
|
|
235
|
+
:style="{
|
|
236
|
+
'--sidebar-width': SIDEBAR_WIDTH_MOBILE,
|
|
237
|
+
}"
|
|
238
|
+
:class="
|
|
239
|
+
cn(
|
|
240
|
+
'bg-sidebar text-sidebar-foreground fixed inset-y-0 left-0 z-30 flex h-svh w-(--sidebar-width) flex-col transition-[opacity,transform] duration-(--sidebar-mobile-transition-duration) ease-out will-change-[opacity,transform]',
|
|
241
|
+
openMobile
|
|
242
|
+
? 'translate-x-0 opacity-100'
|
|
243
|
+
: 'pointer-events-none opacity-0',
|
|
244
|
+
'data-[state=collapsed]:-translate-x-full',
|
|
245
|
+
$attrs.class ?? '',
|
|
246
|
+
)
|
|
247
|
+
"
|
|
235
248
|
>
|
|
236
|
-
<
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
:side="side"
|
|
241
|
-
class="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
|
|
242
|
-
:style="{
|
|
243
|
-
'--sidebar-width': SIDEBAR_WIDTH_MOBILE,
|
|
244
|
-
}"
|
|
245
|
-
>
|
|
246
|
-
<SheetHeader class="sr-only">
|
|
247
|
-
<SheetTitle>Sidebar</SheetTitle>
|
|
248
|
-
<SheetDescription>Displays the mobile sidebar.</SheetDescription>
|
|
249
|
-
</SheetHeader>
|
|
250
|
-
<div class="flex h-full w-full flex-col">
|
|
251
|
-
<slot />
|
|
252
|
-
</div>
|
|
253
|
-
</SheetContent>
|
|
254
|
-
</Sheet>
|
|
249
|
+
<div class="flex h-full w-full flex-col">
|
|
250
|
+
<slot />
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
255
253
|
|
|
256
254
|
<div
|
|
257
255
|
v-else
|
|
@@ -10,7 +10,7 @@ defineOptions({ inheritAttrs: false });
|
|
|
10
10
|
data-slot="sidebar-inset"
|
|
11
11
|
:class="
|
|
12
12
|
cn(
|
|
13
|
-
'bg-background relative flex w-full flex-1 flex-col',
|
|
13
|
+
'bg-background relative flex w-full flex-1 flex-col transition-[border-radius,box-shadow,opacity,transform] duration-(--sidebar-mobile-transition-duration) ease-out will-change-[opacity,transform]',
|
|
14
14
|
'md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2',
|
|
15
15
|
$attrs.class ?? '',
|
|
16
16
|
)
|
|
@@ -19,3 +19,15 @@ defineOptions({ inheritAttrs: false });
|
|
|
19
19
|
<slot />
|
|
20
20
|
</main>
|
|
21
21
|
</template>
|
|
22
|
+
|
|
23
|
+
<style scoped>
|
|
24
|
+
:global(
|
|
25
|
+
[data-slot='sidebar'][data-mobile='true'][data-state='expanded'][data-side='left']
|
|
26
|
+
~ [data-slot='sidebar-inset']
|
|
27
|
+
) {
|
|
28
|
+
border-radius: 12px 0 0 12px;
|
|
29
|
+
box-shadow: 0 4px 16px rgb(0 0 0 / 8%);
|
|
30
|
+
opacity: 0.32;
|
|
31
|
+
transform: translateX(calc(var(--sidebar-width-mobile) + 12px));
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
useVModel,
|
|
8
8
|
} from '@vueuse/core';
|
|
9
9
|
import { TooltipProvider } from 'reka-ui';
|
|
10
|
-
import { computed, ref } from 'vue';
|
|
10
|
+
import { computed, ref, watch } from 'vue';
|
|
11
11
|
import { cn } from '@/lib/utils';
|
|
12
12
|
import {
|
|
13
13
|
provideSidebarContext,
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
SIDEBAR_KEYBOARD_SHORTCUT,
|
|
17
17
|
SIDEBAR_WIDTH,
|
|
18
18
|
SIDEBAR_WIDTH_ICON,
|
|
19
|
+
SIDEBAR_WIDTH_MOBILE,
|
|
19
20
|
} from './utils';
|
|
20
21
|
|
|
21
22
|
defineOptions({ inheritAttrs: false });
|
|
@@ -23,12 +24,14 @@ defineOptions({ inheritAttrs: false });
|
|
|
23
24
|
const props = withDefaults(
|
|
24
25
|
defineProps<{
|
|
25
26
|
defaultOpen?: boolean;
|
|
27
|
+
mobileTransitionDuration?: string;
|
|
26
28
|
open?: boolean;
|
|
27
29
|
}>(),
|
|
28
30
|
{
|
|
29
31
|
defaultOpen: !defaultDocument?.cookie.includes(
|
|
30
32
|
`${SIDEBAR_COOKIE_NAME}=false`,
|
|
31
33
|
),
|
|
34
|
+
mobileTransitionDuration: '20ms',
|
|
32
35
|
open: undefined,
|
|
33
36
|
},
|
|
34
37
|
);
|
|
@@ -58,6 +61,9 @@ function setOpen(value: boolean) {
|
|
|
58
61
|
|
|
59
62
|
function setOpenMobile(value: boolean) {
|
|
60
63
|
openMobile.value = value;
|
|
64
|
+
if (props.open !== undefined) {
|
|
65
|
+
emits('update:open', value);
|
|
66
|
+
}
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
// Helper to toggle the sidebar.
|
|
@@ -67,6 +73,16 @@ function toggleSidebar() {
|
|
|
67
73
|
: setOpen(!open.value);
|
|
68
74
|
}
|
|
69
75
|
|
|
76
|
+
watch(
|
|
77
|
+
[isMobile, () => props.open],
|
|
78
|
+
([mobile, controlledOpen]) => {
|
|
79
|
+
if (mobile && controlledOpen !== undefined) {
|
|
80
|
+
openMobile.value = controlledOpen;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{ immediate: true },
|
|
84
|
+
);
|
|
85
|
+
|
|
70
86
|
useEventListener('keydown', (event: KeyboardEvent) => {
|
|
71
87
|
if (
|
|
72
88
|
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
@@ -97,13 +113,17 @@ provideSidebarContext({
|
|
|
97
113
|
<div
|
|
98
114
|
v-bind="$attrs"
|
|
99
115
|
data-slot="sidebar-wrapper"
|
|
116
|
+
:data-mobile="isMobile ? 'true' : undefined"
|
|
117
|
+
:data-mobile-open="isMobile ? String(openMobile) : undefined"
|
|
100
118
|
:style="{
|
|
101
119
|
'--sidebar-width': SIDEBAR_WIDTH,
|
|
102
120
|
'--sidebar-width-icon': SIDEBAR_WIDTH_ICON,
|
|
121
|
+
'--sidebar-width-mobile': SIDEBAR_WIDTH_MOBILE,
|
|
122
|
+
'--sidebar-mobile-transition-duration': props.mobileTransitionDuration,
|
|
103
123
|
}"
|
|
104
124
|
:class="
|
|
105
125
|
cn(
|
|
106
|
-
'group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full',
|
|
126
|
+
'group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full overflow-hidden bg-background',
|
|
107
127
|
$attrs.class ?? '',
|
|
108
128
|
)
|
|
109
129
|
"
|
|
@@ -11,13 +11,13 @@ const { toggleSidebar } = useSidebar();
|
|
|
11
11
|
|
|
12
12
|
<template>
|
|
13
13
|
<Button
|
|
14
|
-
v-bind="$attrs"
|
|
15
14
|
data-sidebar="trigger"
|
|
16
15
|
data-slot="sidebar-trigger"
|
|
17
16
|
variant="ghost"
|
|
18
17
|
size="icon-sm"
|
|
19
18
|
aria-label="Toggle Sidebar"
|
|
20
|
-
|
|
19
|
+
v-bind="$attrs"
|
|
20
|
+
:class="cn('hidden h-8 w-8 md:inline-flex', $attrs.class ?? '')"
|
|
21
21
|
@click="toggleSidebar"
|
|
22
22
|
>
|
|
23
23
|
<UiIcon name="panel-left" />
|
|
@@ -7,7 +7,7 @@ export const SIDEBAR_WIDTH = '16rem';
|
|
|
7
7
|
export const SIDEBAR_WIDTH_DEFAULT = 256;
|
|
8
8
|
export const SIDEBAR_WIDTH_MIN = 240;
|
|
9
9
|
export const SIDEBAR_WIDTH_MAX = 480;
|
|
10
|
-
export const SIDEBAR_WIDTH_MOBILE = '
|
|
10
|
+
export const SIDEBAR_WIDTH_MOBILE = '16rem';
|
|
11
11
|
export const SIDEBAR_WIDTH_ICON = '3rem';
|
|
12
12
|
export const SIDEBAR_KEYBOARD_SHORTCUT = 'b';
|
|
13
13
|
export const SIDEBAR_WIDTH_STORAGE_KEY = 'sidebar_width';
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { PrimitiveProps as RekaPrimitiveProps } from 'reka-ui';
|
|
|
7
7
|
export * from './components';
|
|
8
8
|
export * from './patterns';
|
|
9
9
|
export * from './templates';
|
|
10
|
+
export * from './lib/useDevice';
|
|
10
11
|
export * from './directives';
|
|
11
12
|
export { Primitive } from 'reka-ui';
|
|
12
13
|
export type PrimitiveProps = RekaPrimitiveProps;
|