@aleph-alpha/ui-library 2.3.0 → 2.4.1
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/UiAlert/UiAlert.vue.d.ts +1 -0
- package/dist/system/components/UiAlert/constants.d.ts +16 -2
- package/dist/system/components/UiResizable/UiResizableHandle.vue.d.ts +22 -0
- package/dist/system/components/UiResizable/UiResizablePanel.vue.d.ts +31 -0
- package/dist/system/components/UiResizable/UiResizablePanelGroup.vue.d.ts +23 -0
- package/dist/system/components/UiResizable/index.d.ts +4 -0
- package/dist/system/components/UiResizable/types.d.ts +37 -0
- package/dist/system/components/core/resizable/ResizableHandle.vue.d.ts +27 -0
- package/dist/system/components/core/resizable/ResizablePanel.vue.d.ts +32 -0
- package/dist/system/components/core/resizable/ResizablePanelGroup.vue.d.ts +28 -0
- package/dist/system/components/core/resizable/index.d.ts +3 -0
- package/dist/system/components/core/sidebar/Sidebar.vue.d.ts +7 -0
- package/dist/system/components/core/sidebar/SidebarResizeHandle.vue.d.ts +16 -0
- package/dist/system/components/core/sidebar/index.d.ts +16 -0
- package/dist/system/components/core/sidebar/utils.d.ts +4 -0
- package/dist/system/components/index.d.ts +1 -0
- package/dist/system/favicon.ico +0 -0
- package/dist/system/lib.js +21879 -20151
- package/dist/system/patterns/UiSidebar/UiSidebar.vue.d.ts +1 -0
- package/dist/system/patterns/UiSidebar/__tests__/sidebar-test-helpers.d.ts +6 -0
- package/dist/system/storybook-config.json +9 -0
- package/package.json +3 -2
- package/src/components/UiAlert/UiAlert.stories.ts +3 -15
- package/src/components/UiAlert/UiAlert.vue +16 -10
- package/src/components/UiAlert/constants.ts +21 -2
- package/src/components/UiResizable/UiResizable.stories.ts +424 -0
- package/src/components/UiResizable/UiResizableHandle.vue +17 -0
- package/src/components/UiResizable/UiResizablePanel.vue +30 -0
- package/src/components/UiResizable/UiResizablePanelGroup.vue +27 -0
- package/src/components/UiResizable/__tests__/UiResizableHandle.test.ts +64 -0
- package/src/components/UiResizable/__tests__/UiResizablePanel.test.ts +82 -0
- package/src/components/UiResizable/__tests__/UiResizablePanelGroup.test.ts +79 -0
- package/src/components/UiResizable/index.ts +4 -0
- package/src/components/UiResizable/types.ts +50 -0
- package/src/components/core/resizable/ResizableHandle.vue +45 -0
- package/src/components/core/resizable/ResizablePanel.vue +21 -0
- package/src/components/core/resizable/ResizablePanelGroup.vue +31 -0
- package/src/components/core/resizable/index.ts +3 -0
- package/src/components/core/sidebar/Sidebar.vue +208 -2
- package/src/components/core/sidebar/SidebarMenuButton.vue +5 -1
- package/src/components/core/sidebar/SidebarRail.vue +1 -2
- package/src/components/core/sidebar/SidebarResizeHandle.vue +46 -0
- package/src/components/core/sidebar/index.ts +17 -0
- package/src/components/core/sidebar/utils.ts +4 -0
- package/src/components/index.ts +1 -0
- package/src/patterns/UiSidebar/UiSidebar.stories.ts +42 -1
- package/src/patterns/UiSidebar/UiSidebar.vue +20 -0
- package/src/patterns/UiSidebar/__tests__/UiSidebar.test.ts +204 -2
- package/src/patterns/UiSidebar/__tests__/UiSidebarMenuButton.test.ts +31 -0
- package/src/patterns/UiSidebar/__tests__/UiSidebarRail.test.ts +14 -0
|
@@ -11,6 +11,7 @@ declare const __VLS_component: import('vue').DefineComponent<import('../../compo
|
|
|
11
11
|
collapsible: "offcanvas" | "icon" | "none";
|
|
12
12
|
variant: "sidebar" | "floating" | "inset";
|
|
13
13
|
side: "left" | "right";
|
|
14
|
+
resizable: boolean;
|
|
14
15
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
15
16
|
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
16
17
|
export default _default;
|
|
@@ -32,6 +32,7 @@ export declare function createSidebarShell(innerTemplate: string, extraComponent
|
|
|
32
32
|
collapsible: "offcanvas" | "icon" | "none";
|
|
33
33
|
variant: "sidebar" | "floating" | "inset";
|
|
34
34
|
side: "left" | "right";
|
|
35
|
+
resizable: boolean;
|
|
35
36
|
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
36
37
|
P: {};
|
|
37
38
|
B: {};
|
|
@@ -43,6 +44,7 @@ export declare function createSidebarShell(innerTemplate: string, extraComponent
|
|
|
43
44
|
collapsible: "offcanvas" | "icon" | "none";
|
|
44
45
|
variant: "sidebar" | "floating" | "inset";
|
|
45
46
|
side: "left" | "right";
|
|
47
|
+
resizable: boolean;
|
|
46
48
|
}>;
|
|
47
49
|
__isFragment?: never;
|
|
48
50
|
__isTeleport?: never;
|
|
@@ -51,6 +53,7 @@ export declare function createSidebarShell(innerTemplate: string, extraComponent
|
|
|
51
53
|
collapsible: "offcanvas" | "icon" | "none";
|
|
52
54
|
variant: "sidebar" | "floating" | "inset";
|
|
53
55
|
side: "left" | "right";
|
|
56
|
+
resizable: boolean;
|
|
54
57
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
55
58
|
$slots: {
|
|
56
59
|
default?(_: {}): any;
|
|
@@ -105,6 +108,7 @@ export declare function createOffcanvasSidebar(innerTemplate: string, extraCompo
|
|
|
105
108
|
collapsible: "offcanvas" | "icon" | "none";
|
|
106
109
|
variant: "sidebar" | "floating" | "inset";
|
|
107
110
|
side: "left" | "right";
|
|
111
|
+
resizable: boolean;
|
|
108
112
|
}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
|
|
109
113
|
P: {};
|
|
110
114
|
B: {};
|
|
@@ -116,6 +120,7 @@ export declare function createOffcanvasSidebar(innerTemplate: string, extraCompo
|
|
|
116
120
|
collapsible: "offcanvas" | "icon" | "none";
|
|
117
121
|
variant: "sidebar" | "floating" | "inset";
|
|
118
122
|
side: "left" | "right";
|
|
123
|
+
resizable: boolean;
|
|
119
124
|
}>;
|
|
120
125
|
__isFragment?: never;
|
|
121
126
|
__isTeleport?: never;
|
|
@@ -124,6 +129,7 @@ export declare function createOffcanvasSidebar(innerTemplate: string, extraCompo
|
|
|
124
129
|
collapsible: "offcanvas" | "icon" | "none";
|
|
125
130
|
variant: "sidebar" | "floating" | "inset";
|
|
126
131
|
side: "left" | "right";
|
|
132
|
+
resizable: boolean;
|
|
127
133
|
}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
|
|
128
134
|
$slots: {
|
|
129
135
|
default?(_: {}): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aleph-alpha/ui-library",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/system/lib.js",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"http-server": "14.1.1",
|
|
63
63
|
"playwright": "^1.57.0",
|
|
64
64
|
"postcss": "8.5.10",
|
|
65
|
+
"sb-addon-versions": "^1.0.12",
|
|
65
66
|
"storybook": "10.2.17",
|
|
66
67
|
"storybook-addon-tag-badges": "^3.1.0",
|
|
67
68
|
"typescript": "^5.2.2",
|
|
@@ -106,7 +107,7 @@
|
|
|
106
107
|
"date-fns": "4.1.0",
|
|
107
108
|
"lucide-vue-next": "1.0.0",
|
|
108
109
|
"radix-vue": "^1.9.17",
|
|
109
|
-
"reka-ui": "^2.
|
|
110
|
+
"reka-ui": "^2.9.2",
|
|
110
111
|
"shiki": "^3.0.0",
|
|
111
112
|
"tailwind-merge": "^3.4.0",
|
|
112
113
|
"vue-sonner": "^2.0.9",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
2
|
import { UiAlert, UiAlertDescription, UiAlertTitle } from './index';
|
|
3
3
|
import { AlertVariants } from './constants';
|
|
4
|
-
import { UiIcon } from '../UiIcon';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* UiAlert is a static, contextual message that calls attention to status information (info, success, warning, destructive).
|
|
@@ -29,12 +28,11 @@ export default meta;
|
|
|
29
28
|
type Story = StoryObj<typeof UiAlert>;
|
|
30
29
|
|
|
31
30
|
const defaultTemplateSource = `<script setup lang="ts">
|
|
32
|
-
import { UiAlert, UiAlertDescription, UiAlertTitle
|
|
31
|
+
import { UiAlert, UiAlertDescription, UiAlertTitle } from '@aleph-alpha/ui-library'
|
|
33
32
|
</script>
|
|
34
33
|
|
|
35
34
|
<template>
|
|
36
35
|
<UiAlert>
|
|
37
|
-
<UiIcon name="circle-check" :size="16" />
|
|
38
36
|
<UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
|
|
39
37
|
<UiAlertDescription>
|
|
40
38
|
This is an alert with icon, title and description.
|
|
@@ -51,14 +49,12 @@ export const Default: Story = {
|
|
|
51
49
|
UiAlert,
|
|
52
50
|
UiAlertDescription,
|
|
53
51
|
UiAlertTitle,
|
|
54
|
-
UiIcon,
|
|
55
52
|
},
|
|
56
53
|
setup() {
|
|
57
54
|
return { args };
|
|
58
55
|
},
|
|
59
56
|
template: `
|
|
60
57
|
<UiAlert :variant="args.variant">
|
|
61
|
-
<UiIcon name="circle-check" :size="16" />
|
|
62
58
|
<UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
|
|
63
59
|
<UiAlertDescription>
|
|
64
60
|
This is an alert with icon, title and description.
|
|
@@ -76,12 +72,11 @@ export const Default: Story = {
|
|
|
76
72
|
};
|
|
77
73
|
|
|
78
74
|
const destructiveTemplateSource = `<script setup lang="ts">
|
|
79
|
-
import { UiAlert, UiAlertDescription, UiAlertTitle
|
|
75
|
+
import { UiAlert, UiAlertDescription, UiAlertTitle } from '@aleph-alpha/ui-library'
|
|
80
76
|
</script>
|
|
81
77
|
|
|
82
78
|
<template>
|
|
83
79
|
<UiAlert variant="destructive">
|
|
84
|
-
<UiIcon name="circle-x" :size="16" />
|
|
85
80
|
<UiAlertTitle>Unable to process your payment.</UiAlertTitle>
|
|
86
81
|
<UiAlertDescription>
|
|
87
82
|
<p>Please verify your billing information and try again.</p>
|
|
@@ -103,11 +98,9 @@ export const Destructive: Story = {
|
|
|
103
98
|
UiAlert,
|
|
104
99
|
UiAlertDescription,
|
|
105
100
|
UiAlertTitle,
|
|
106
|
-
UiIcon,
|
|
107
101
|
},
|
|
108
102
|
template: `
|
|
109
103
|
<UiAlert variant="destructive">
|
|
110
|
-
<UiIcon name="circle-x" :size="16" />
|
|
111
104
|
<UiAlertTitle>Unable to process your payment.</UiAlertTitle>
|
|
112
105
|
<UiAlertDescription>
|
|
113
106
|
<p>Please verify your billing information and try again.</p>
|
|
@@ -130,13 +123,12 @@ export const Destructive: Story = {
|
|
|
130
123
|
};
|
|
131
124
|
|
|
132
125
|
const allVariantsTemplateSource = `<script setup lang="ts">
|
|
133
|
-
import { UiAlert, UiAlertDescription, UiAlertTitle
|
|
126
|
+
import { UiAlert, UiAlertDescription, UiAlertTitle } from '@aleph-alpha/ui-library'
|
|
134
127
|
</script>
|
|
135
128
|
|
|
136
129
|
<template>
|
|
137
130
|
<div class="flex flex-col gap-4">
|
|
138
131
|
<UiAlert>
|
|
139
|
-
<UiIcon name="circle-check" :size="16" />
|
|
140
132
|
<UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
|
|
141
133
|
<UiAlertDescription>
|
|
142
134
|
This is an alert with icon, title and description.
|
|
@@ -144,7 +136,6 @@ import { UiAlert, UiAlertDescription, UiAlertTitle, UiIcon } from '@aleph-alpha/
|
|
|
144
136
|
</UiAlert>
|
|
145
137
|
|
|
146
138
|
<UiAlert variant="destructive">
|
|
147
|
-
<UiIcon name="circle-x" :size="16" />
|
|
148
139
|
<UiAlertTitle>Unable to process your payment.</UiAlertTitle>
|
|
149
140
|
<UiAlertDescription>
|
|
150
141
|
<p>Please verify your billing information and try again.</p>
|
|
@@ -167,12 +158,10 @@ export const AllVariants: Story = {
|
|
|
167
158
|
UiAlert,
|
|
168
159
|
UiAlertDescription,
|
|
169
160
|
UiAlertTitle,
|
|
170
|
-
UiIcon,
|
|
171
161
|
},
|
|
172
162
|
template: `
|
|
173
163
|
<div class="flex flex-col gap-4">
|
|
174
164
|
<UiAlert>
|
|
175
|
-
<UiIcon name="circle-check" :size="16" />
|
|
176
165
|
<UiAlertTitle>Success! Your changes have been saved</UiAlertTitle>
|
|
177
166
|
<UiAlertDescription>
|
|
178
167
|
This is an alert with icon, title and description.
|
|
@@ -180,7 +169,6 @@ export const AllVariants: Story = {
|
|
|
180
169
|
</UiAlert>
|
|
181
170
|
|
|
182
171
|
<UiAlert variant="destructive">
|
|
183
|
-
<UiIcon name="circle-x" :size="16" />
|
|
184
172
|
<UiAlertTitle>Unable to process your payment.</UiAlertTitle>
|
|
185
173
|
<UiAlertDescription>
|
|
186
174
|
<p>Please verify your billing information and try again.</p>
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { Alert as ShadcnAlert } from '@/components/core/alert';
|
|
3
3
|
|
|
4
|
-
import { UiAlertProps } from './types';
|
|
4
|
+
import type { UiAlertProps } from './types';
|
|
5
|
+
import UiIcon from '../UiIcon/UiIcon.vue';
|
|
6
|
+
import { AlertVariantIconNames, AlertVariants } from './constants';
|
|
7
|
+
import { computed } from 'vue';
|
|
5
8
|
|
|
6
9
|
defineOptions({
|
|
7
10
|
name: 'UiAlert',
|
|
8
11
|
});
|
|
9
12
|
|
|
10
|
-
withDefaults(defineProps<UiAlertProps>(), {
|
|
13
|
+
const props = withDefaults(defineProps<UiAlertProps>(), {
|
|
11
14
|
variant: 'default',
|
|
12
15
|
});
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const alertVariantIcons = new Map(
|
|
18
|
+
AlertVariants.map((variant) => [variant, AlertVariantIconNames[variant]]),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const alertIcon = computed(
|
|
22
|
+
() => alertVariantIcons.get(props.variant) ?? AlertVariantIconNames.default,
|
|
23
|
+
);
|
|
21
24
|
</script>
|
|
22
25
|
|
|
23
26
|
<template>
|
|
24
|
-
<ShadcnAlert :variant
|
|
27
|
+
<ShadcnAlert :variant>
|
|
28
|
+
<slot name="icon">
|
|
29
|
+
<UiIcon :name="alertIcon" :size="16" />
|
|
30
|
+
</slot>
|
|
25
31
|
<slot />
|
|
26
32
|
</ShadcnAlert>
|
|
27
33
|
</template>
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
-
import { UiAlertVariants } from './types';
|
|
1
|
+
import type { UiAlertVariants } from './types';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Supported visual variants for `UiAlert`.
|
|
5
|
+
*
|
|
6
|
+
* Keep this list aligned with `UiAlertVariants` so Storybook controls and
|
|
7
|
+
* variant iteration stay type-safe when variants are added or removed.
|
|
8
|
+
*/
|
|
9
|
+
export const AlertVariants = [
|
|
10
|
+
'default',
|
|
11
|
+
'destructive',
|
|
12
|
+
] as const satisfies readonly UiAlertVariants[];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Default icon names for each alert variant.
|
|
16
|
+
*
|
|
17
|
+
* Consumers can override the rendered icon through the `icon` slot.
|
|
18
|
+
*/
|
|
19
|
+
export const AlertVariantIconNames = {
|
|
20
|
+
default: 'circle-check',
|
|
21
|
+
destructive: 'circle-alert',
|
|
22
|
+
} as const satisfies Record<UiAlertVariants, string>;
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import {
|
|
4
|
+
UiResizableHandle,
|
|
5
|
+
UiResizablePanel,
|
|
6
|
+
UiResizablePanelGroup,
|
|
7
|
+
} from './index';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* UiResizable creates split-panel layouts whose panels can be resized by dragging
|
|
11
|
+
* the handle between them.
|
|
12
|
+
*/
|
|
13
|
+
const meta: Meta<typeof UiResizablePanelGroup> = {
|
|
14
|
+
title: 'Components/UiResizable',
|
|
15
|
+
component: UiResizablePanelGroup,
|
|
16
|
+
tags: ['autodocs'],
|
|
17
|
+
argTypes: {
|
|
18
|
+
direction: {
|
|
19
|
+
control: 'select',
|
|
20
|
+
options: ['horizontal', 'vertical'],
|
|
21
|
+
description: 'The orientation of the resizable panel group.',
|
|
22
|
+
},
|
|
23
|
+
autoSaveId: {
|
|
24
|
+
control: 'text',
|
|
25
|
+
description:
|
|
26
|
+
'Optional id used to persist the panel layout in localStorage.',
|
|
27
|
+
},
|
|
28
|
+
keyboardResizeBy: {
|
|
29
|
+
control: 'number',
|
|
30
|
+
description: 'Step size used when resizing with the keyboard.',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
args: {
|
|
34
|
+
direction: 'horizontal',
|
|
35
|
+
keyboardResizeBy: 10,
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default meta;
|
|
40
|
+
|
|
41
|
+
type Story = StoryObj<typeof UiResizablePanelGroup>;
|
|
42
|
+
|
|
43
|
+
const panelClasses =
|
|
44
|
+
'flex items-center justify-center rounded-md bg-background-surface-muted p-6 text-sm';
|
|
45
|
+
const sizeValueClasses = 'font-mono text-xs text-muted-foreground';
|
|
46
|
+
|
|
47
|
+
const defaultTemplateSource = `<script setup lang="ts">
|
|
48
|
+
import { ref } from 'vue'
|
|
49
|
+
import {
|
|
50
|
+
UiResizableHandle,
|
|
51
|
+
UiResizablePanel,
|
|
52
|
+
UiResizablePanelGroup,
|
|
53
|
+
} from '@aleph-alpha/ui-library'
|
|
54
|
+
|
|
55
|
+
const sidebarWidth = ref(30)
|
|
56
|
+
const contentWidth = ref(70)
|
|
57
|
+
|
|
58
|
+
function updateSidebarWidth(size: number) {
|
|
59
|
+
sidebarWidth.value = Math.round(size)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function updateContentWidth(size: number) {
|
|
63
|
+
contentWidth.value = Math.round(size)
|
|
64
|
+
}
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<template>
|
|
68
|
+
<UiResizablePanelGroup direction="horizontal" class="min-h-64 rounded-lg">
|
|
69
|
+
<UiResizablePanel
|
|
70
|
+
:default-size="30"
|
|
71
|
+
:min-size="20"
|
|
72
|
+
@resize="updateSidebarWidth"
|
|
73
|
+
>
|
|
74
|
+
<div
|
|
75
|
+
class="flex h-full flex-col items-center justify-center gap-1 rounded-md bg-background-surface-muted p-6 text-sm"
|
|
76
|
+
>
|
|
77
|
+
<span>Sidebar</span>
|
|
78
|
+
<span class="font-mono text-xs text-muted-foreground">{{ sidebarWidth }}% wide</span>
|
|
79
|
+
</div>
|
|
80
|
+
</UiResizablePanel>
|
|
81
|
+
<UiResizableHandle with-handle />
|
|
82
|
+
<UiResizablePanel
|
|
83
|
+
:default-size="70"
|
|
84
|
+
:min-size="30"
|
|
85
|
+
@resize="updateContentWidth"
|
|
86
|
+
>
|
|
87
|
+
<div
|
|
88
|
+
class="flex h-full flex-col items-center justify-center gap-1 rounded-md bg-background-surface-muted p-6 text-sm"
|
|
89
|
+
>
|
|
90
|
+
<span>Content</span>
|
|
91
|
+
<span class="font-mono text-xs text-muted-foreground">{{ contentWidth }}% wide</span>
|
|
92
|
+
</div>
|
|
93
|
+
</UiResizablePanel>
|
|
94
|
+
</UiResizablePanelGroup>
|
|
95
|
+
</template>`;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Two horizontal panels with a visible drag handle.
|
|
99
|
+
*/
|
|
100
|
+
export const Default: Story = {
|
|
101
|
+
render: (args) => ({
|
|
102
|
+
components: {
|
|
103
|
+
UiResizableHandle,
|
|
104
|
+
UiResizablePanel,
|
|
105
|
+
UiResizablePanelGroup,
|
|
106
|
+
},
|
|
107
|
+
setup() {
|
|
108
|
+
const sidebarWidth = ref(30);
|
|
109
|
+
const contentWidth = ref(70);
|
|
110
|
+
|
|
111
|
+
function updateSidebarWidth(size: number) {
|
|
112
|
+
sidebarWidth.value = Math.round(size);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function updateContentWidth(size: number) {
|
|
116
|
+
contentWidth.value = Math.round(size);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
args,
|
|
121
|
+
contentWidth,
|
|
122
|
+
panelClasses,
|
|
123
|
+
sidebarWidth,
|
|
124
|
+
sizeValueClasses,
|
|
125
|
+
updateContentWidth,
|
|
126
|
+
updateSidebarWidth,
|
|
127
|
+
};
|
|
128
|
+
},
|
|
129
|
+
template: `
|
|
130
|
+
<UiResizablePanelGroup
|
|
131
|
+
v-bind="args"
|
|
132
|
+
class="min-h-64 border border-border-surface-focus-ring"
|
|
133
|
+
>
|
|
134
|
+
<UiResizablePanel
|
|
135
|
+
:default-size="30"
|
|
136
|
+
:min-size="20"
|
|
137
|
+
@resize="updateSidebarWidth"
|
|
138
|
+
>
|
|
139
|
+
<div
|
|
140
|
+
:class="[panelClasses, 'h-full flex-col gap-1']"
|
|
141
|
+
>
|
|
142
|
+
<span>Sidebar</span>
|
|
143
|
+
<span :class="sizeValueClasses">{{ sidebarWidth }}% wide</span>
|
|
144
|
+
</div>
|
|
145
|
+
</UiResizablePanel>
|
|
146
|
+
<UiResizableHandle with-handle />
|
|
147
|
+
<UiResizablePanel
|
|
148
|
+
:default-size="70"
|
|
149
|
+
:min-size="30"
|
|
150
|
+
@resize="updateContentWidth"
|
|
151
|
+
>
|
|
152
|
+
<div
|
|
153
|
+
:class="[panelClasses, 'h-full flex-col gap-1']"
|
|
154
|
+
>
|
|
155
|
+
<span>Content</span>
|
|
156
|
+
<span :class="sizeValueClasses">{{ contentWidth }}% wide</span>
|
|
157
|
+
</div>
|
|
158
|
+
</UiResizablePanel>
|
|
159
|
+
</UiResizablePanelGroup>
|
|
160
|
+
`,
|
|
161
|
+
}),
|
|
162
|
+
parameters: {
|
|
163
|
+
docs: {
|
|
164
|
+
source: {
|
|
165
|
+
code: defaultTemplateSource,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const verticalTemplateSource = `<script setup lang="ts">
|
|
172
|
+
import { ref } from 'vue'
|
|
173
|
+
import {
|
|
174
|
+
UiResizableHandle,
|
|
175
|
+
UiResizablePanel,
|
|
176
|
+
UiResizablePanelGroup,
|
|
177
|
+
} from '@aleph-alpha/ui-library'
|
|
178
|
+
|
|
179
|
+
const previewHeight = ref(60)
|
|
180
|
+
const consoleHeight = ref(40)
|
|
181
|
+
|
|
182
|
+
function updatePreviewHeight(size: number) {
|
|
183
|
+
previewHeight.value = Math.round(size)
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function updateConsoleHeight(size: number) {
|
|
187
|
+
consoleHeight.value = Math.round(size)
|
|
188
|
+
}
|
|
189
|
+
</script>
|
|
190
|
+
|
|
191
|
+
<template>
|
|
192
|
+
<UiResizablePanelGroup direction="vertical" class="min-h-96 rounded-lg bg-background-surface-secondary p-2 shadow-lg">
|
|
193
|
+
<UiResizablePanel
|
|
194
|
+
:default-size="60"
|
|
195
|
+
:min-size="30"
|
|
196
|
+
@resize="updatePreviewHeight"
|
|
197
|
+
>
|
|
198
|
+
<div
|
|
199
|
+
class="flex h-full flex-col items-center justify-center gap-1 rounded-md bg-background-surface-muted p-6 text-sm"
|
|
200
|
+
>
|
|
201
|
+
<span>Preview</span>
|
|
202
|
+
<span class="font-mono text-xs text-muted-foreground">{{ previewHeight }}% tall</span>
|
|
203
|
+
</div>
|
|
204
|
+
</UiResizablePanel>
|
|
205
|
+
<UiResizableHandle with-handle />
|
|
206
|
+
<UiResizablePanel
|
|
207
|
+
:default-size="40"
|
|
208
|
+
:min-size="20"
|
|
209
|
+
@resize="updateConsoleHeight"
|
|
210
|
+
>
|
|
211
|
+
<div
|
|
212
|
+
class="flex h-full flex-col items-center justify-center gap-1 rounded-md bg-background-surface-muted p-6 text-sm"
|
|
213
|
+
>
|
|
214
|
+
<span>Console</span>
|
|
215
|
+
<span class="font-mono text-xs text-muted-foreground">{{ consoleHeight }}% tall</span>
|
|
216
|
+
</div>
|
|
217
|
+
</UiResizablePanel>
|
|
218
|
+
</UiResizablePanelGroup>
|
|
219
|
+
</template>`;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Vertical resizing stacks panels from top to bottom.
|
|
223
|
+
*/
|
|
224
|
+
export const Vertical: Story = {
|
|
225
|
+
render: () => ({
|
|
226
|
+
components: {
|
|
227
|
+
UiResizableHandle,
|
|
228
|
+
UiResizablePanel,
|
|
229
|
+
UiResizablePanelGroup,
|
|
230
|
+
},
|
|
231
|
+
setup() {
|
|
232
|
+
const previewHeight = ref(60);
|
|
233
|
+
const consoleHeight = ref(40);
|
|
234
|
+
|
|
235
|
+
function updatePreviewHeight(size: number) {
|
|
236
|
+
previewHeight.value = Math.round(size);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function updateConsoleHeight(size: number) {
|
|
240
|
+
consoleHeight.value = Math.round(size);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return {
|
|
244
|
+
consoleHeight,
|
|
245
|
+
panelClasses,
|
|
246
|
+
previewHeight,
|
|
247
|
+
sizeValueClasses,
|
|
248
|
+
updateConsoleHeight,
|
|
249
|
+
updatePreviewHeight,
|
|
250
|
+
};
|
|
251
|
+
},
|
|
252
|
+
template: `
|
|
253
|
+
<UiResizablePanelGroup
|
|
254
|
+
direction="vertical"
|
|
255
|
+
class="min-h-96 rounded-lg bg-background-surface-secondary p-2 shadow-lg"
|
|
256
|
+
>
|
|
257
|
+
<UiResizablePanel
|
|
258
|
+
:default-size="60"
|
|
259
|
+
:min-size="30"
|
|
260
|
+
@resize="updatePreviewHeight"
|
|
261
|
+
>
|
|
262
|
+
<div
|
|
263
|
+
:class="[panelClasses, 'h-full flex-col gap-1']"
|
|
264
|
+
>
|
|
265
|
+
<span>Preview</span>
|
|
266
|
+
<span :class="sizeValueClasses">{{ previewHeight }}% tall</span>
|
|
267
|
+
</div>
|
|
268
|
+
</UiResizablePanel>
|
|
269
|
+
<UiResizableHandle with-handle />
|
|
270
|
+
<UiResizablePanel
|
|
271
|
+
:default-size="40"
|
|
272
|
+
:min-size="20"
|
|
273
|
+
@resize="updateConsoleHeight"
|
|
274
|
+
>
|
|
275
|
+
<div
|
|
276
|
+
:class="[panelClasses, 'h-full flex-col gap-1']"
|
|
277
|
+
>
|
|
278
|
+
<span>Console</span>
|
|
279
|
+
<span :class="sizeValueClasses">{{ consoleHeight }}% tall</span>
|
|
280
|
+
</div>
|
|
281
|
+
</UiResizablePanel>
|
|
282
|
+
</UiResizablePanelGroup>
|
|
283
|
+
`,
|
|
284
|
+
}),
|
|
285
|
+
parameters: {
|
|
286
|
+
docs: {
|
|
287
|
+
source: {
|
|
288
|
+
code: verticalTemplateSource,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const collapsibleTemplateSource = `<script setup lang="ts">
|
|
295
|
+
import {
|
|
296
|
+
UiResizableHandle,
|
|
297
|
+
UiResizablePanel,
|
|
298
|
+
UiResizablePanelGroup,
|
|
299
|
+
} from '@aleph-alpha/ui-library'
|
|
300
|
+
</script>
|
|
301
|
+
|
|
302
|
+
<template>
|
|
303
|
+
<UiResizablePanelGroup direction="horizontal" class="min-h-64 rounded-lg bg-background-surface-secondary p-2 shadow-lg">
|
|
304
|
+
<UiResizablePanel collapsible :collapsed-size="8" :default-size="25" :min-size="20">
|
|
305
|
+
<div class="flex h-full items-center justify-center rounded-md bg-background-surface-muted p-6 text-sm">
|
|
306
|
+
Collapsible
|
|
307
|
+
</div>
|
|
308
|
+
</UiResizablePanel>
|
|
309
|
+
<UiResizableHandle with-handle />
|
|
310
|
+
<UiResizablePanel :default-size="75" :min-size="30">
|
|
311
|
+
<div class="flex h-full items-center justify-center rounded-md bg-background-surface-muted p-6 text-sm">
|
|
312
|
+
Main panel
|
|
313
|
+
</div>
|
|
314
|
+
</UiResizablePanel>
|
|
315
|
+
</UiResizablePanelGroup>
|
|
316
|
+
</template>`;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* A panel can collapse when resized below its minimum size.
|
|
320
|
+
*/
|
|
321
|
+
export const Collapsible: Story = {
|
|
322
|
+
render: () => ({
|
|
323
|
+
components: {
|
|
324
|
+
UiResizableHandle,
|
|
325
|
+
UiResizablePanel,
|
|
326
|
+
UiResizablePanelGroup,
|
|
327
|
+
},
|
|
328
|
+
setup() {
|
|
329
|
+
return { panelClasses };
|
|
330
|
+
},
|
|
331
|
+
template: `
|
|
332
|
+
<UiResizablePanelGroup
|
|
333
|
+
direction="horizontal"
|
|
334
|
+
class="min-h-64 rounded-lg bg-background-surface-secondary p-2 shadow-lg"
|
|
335
|
+
>
|
|
336
|
+
<UiResizablePanel
|
|
337
|
+
collapsible
|
|
338
|
+
:collapsed-size="8"
|
|
339
|
+
:default-size="25"
|
|
340
|
+
:min-size="20"
|
|
341
|
+
>
|
|
342
|
+
<div :class="[panelClasses, 'h-full']">Collapsible</div>
|
|
343
|
+
</UiResizablePanel>
|
|
344
|
+
<UiResizableHandle with-handle />
|
|
345
|
+
<UiResizablePanel :default-size="75" :min-size="30">
|
|
346
|
+
<div :class="[panelClasses, 'h-full']">Main panel</div>
|
|
347
|
+
</UiResizablePanel>
|
|
348
|
+
</UiResizablePanelGroup>
|
|
349
|
+
`,
|
|
350
|
+
}),
|
|
351
|
+
parameters: {
|
|
352
|
+
docs: {
|
|
353
|
+
source: {
|
|
354
|
+
code: collapsibleTemplateSource,
|
|
355
|
+
},
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
const pixelSizingTemplateSource = `<script setup lang="ts">
|
|
361
|
+
import {
|
|
362
|
+
UiResizableHandle,
|
|
363
|
+
UiResizablePanel,
|
|
364
|
+
UiResizablePanelGroup,
|
|
365
|
+
} from '@aleph-alpha/ui-library'
|
|
366
|
+
</script>
|
|
367
|
+
|
|
368
|
+
<template>
|
|
369
|
+
<UiResizablePanelGroup direction="horizontal" class="min-h-64 rounded-lg bg-background-surface-secondary p-2 shadow-lg">
|
|
370
|
+
<UiResizablePanel size-unit="px" :default-size="240" :min-size="160" :max-size="320">
|
|
371
|
+
<div class="flex h-full items-center justify-center rounded-md bg-background-surface-muted p-6 text-sm">
|
|
372
|
+
Fixed sidebar
|
|
373
|
+
</div>
|
|
374
|
+
</UiResizablePanel>
|
|
375
|
+
<UiResizableHandle with-handle />
|
|
376
|
+
<UiResizablePanel>
|
|
377
|
+
<div class="flex h-full items-center justify-center rounded-md bg-background-surface-muted p-6 text-sm">
|
|
378
|
+
Flexible content
|
|
379
|
+
</div>
|
|
380
|
+
</UiResizablePanel>
|
|
381
|
+
</UiResizablePanelGroup>
|
|
382
|
+
</template>`;
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Pixel sizing keeps a panel at a fixed pixel width while the rest of the group stays flexible.
|
|
386
|
+
*/
|
|
387
|
+
export const PixelSizing: Story = {
|
|
388
|
+
render: () => ({
|
|
389
|
+
components: {
|
|
390
|
+
UiResizableHandle,
|
|
391
|
+
UiResizablePanel,
|
|
392
|
+
UiResizablePanelGroup,
|
|
393
|
+
},
|
|
394
|
+
setup() {
|
|
395
|
+
return { panelClasses };
|
|
396
|
+
},
|
|
397
|
+
template: `
|
|
398
|
+
<UiResizablePanelGroup
|
|
399
|
+
direction="horizontal"
|
|
400
|
+
class="min-h-64 rounded-lg bg-background-surface-secondary p-2 shadow-lg"
|
|
401
|
+
>
|
|
402
|
+
<UiResizablePanel
|
|
403
|
+
size-unit="px"
|
|
404
|
+
:default-size="240"
|
|
405
|
+
:min-size="160"
|
|
406
|
+
:max-size="320"
|
|
407
|
+
>
|
|
408
|
+
<div :class="[panelClasses, 'h-full']">Fixed sidebar</div>
|
|
409
|
+
</UiResizablePanel>
|
|
410
|
+
<UiResizableHandle with-handle />
|
|
411
|
+
<UiResizablePanel>
|
|
412
|
+
<div :class="[panelClasses, 'h-full']">Flexible content</div>
|
|
413
|
+
</UiResizablePanel>
|
|
414
|
+
</UiResizablePanelGroup>
|
|
415
|
+
`,
|
|
416
|
+
}),
|
|
417
|
+
parameters: {
|
|
418
|
+
docs: {
|
|
419
|
+
source: {
|
|
420
|
+
code: pixelSizingTemplateSource,
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
},
|
|
424
|
+
};
|