@aleph-alpha/ui-library 5.1.0 → 5.3.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/README.md +2 -0
- package/dist/system/components/core/sidebar/SidebarInset.vue.d.ts +14 -1
- package/dist/system/index.d.ts +1 -0
- package/dist/system/lib/useAnchorFloat.d.ts +143 -0
- package/dist/system/lib.js +19421 -18919
- package/dist/system/patterns/UiFloatActions/UiFloatActionItems.vue.d.ts +35 -0
- package/dist/system/patterns/UiFloatActions/UiFloatActions.vue.d.ts +43 -0
- package/dist/system/patterns/UiFloatActions/floatActionItemContext.d.ts +16 -0
- package/dist/system/patterns/UiFloatActions/index.d.ts +3 -0
- package/dist/system/patterns/UiFloatActions/types.d.ts +127 -0
- package/dist/system/patterns/index.d.ts +1 -0
- package/package.json +12 -3
- package/src/components/UiButton/UiButton.stories.ts +526 -38
- package/src/components/core/sidebar/SidebarInset.vue +19 -2
- package/src/index.ts +1 -0
- package/src/lib/useAnchorFloat.test.ts +166 -0
- package/src/lib/useAnchorFloat.ts +437 -0
- package/src/patterns/UiFloatActions/UiFloatActionItems.vue +321 -0
- package/src/patterns/UiFloatActions/UiFloatActions.stories.ts +767 -0
- package/src/patterns/UiFloatActions/UiFloatActions.vue +220 -0
- package/src/patterns/UiFloatActions/__tests__/UiFloatActionItems.test.ts +104 -0
- package/src/patterns/UiFloatActions/__tests__/UiFloatActions.a11y.test.ts +152 -0
- package/src/patterns/UiFloatActions/__tests__/UiFloatActions.test.ts +86 -0
- package/src/patterns/UiFloatActions/floatActionItemContext.ts +20 -0
- package/src/patterns/UiFloatActions/index.ts +3 -0
- package/src/patterns/UiFloatActions/types.ts +155 -0
- package/src/patterns/UiSidebar/UiSidebarInset.stories.ts +259 -0
- package/src/patterns/UiSidebar/__tests__/UiSidebarInset.test.ts +20 -0
- package/src/patterns/index.ts +1 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { Placement } from '@floating-ui/vue';
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
import type {
|
|
4
|
+
AnchorFloatOffset,
|
|
5
|
+
AnchorFloatTrigger,
|
|
6
|
+
} from '@/lib/useAnchorFloat';
|
|
7
|
+
|
|
8
|
+
export type UiFloatActionsTrigger = AnchorFloatTrigger;
|
|
9
|
+
export type UiFloatActionsPlacement = Placement;
|
|
10
|
+
export type UiFloatActionsOffset = number | AnchorFloatOffset;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Anchors floating action content to a trigger element on hover, focus, or click.
|
|
14
|
+
* Use for contextual toolbars, quick actions, and inline controls.
|
|
15
|
+
* For rich panels or forms, prefer `UiPopover`.
|
|
16
|
+
*
|
|
17
|
+
* This component is currently experimental. Its API and behavior may still change
|
|
18
|
+
* before it is considered stable.
|
|
19
|
+
* @category Overlays
|
|
20
|
+
* @useCases contextual toolbar, inline actions, hover controls, keyboard toolbar
|
|
21
|
+
* @keywords float, anchor, floating, toolbar, hover, focus, contextual, experimental
|
|
22
|
+
* @related UiFloatActionItems, UiPopover, UiTooltip, useAnchorFloat
|
|
23
|
+
*/
|
|
24
|
+
export interface UiFloatActionsProps {
|
|
25
|
+
/**
|
|
26
|
+
* How the floating panel opens.
|
|
27
|
+
* - `hover` — pointer hover and keyboard focus on a focusable `button` anchor
|
|
28
|
+
* - `focus` — keyboard focus on the `button` anchor
|
|
29
|
+
* - `click` — click or Enter/Space on the `button` anchor
|
|
30
|
+
* - `manual` — controlled via `v-model:open`
|
|
31
|
+
* @default 'hover'
|
|
32
|
+
*/
|
|
33
|
+
trigger?: UiFloatActionsTrigger;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Preferred placement relative to the anchor element.
|
|
37
|
+
* Auto-flips when there is not enough room.
|
|
38
|
+
* @default 'top'
|
|
39
|
+
*/
|
|
40
|
+
placement?: UiFloatActionsPlacement;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Distance from the anchor element, in pixels.
|
|
44
|
+
* Pass an object to set main-axis and cross-axis offsets independently.
|
|
45
|
+
* @default 8
|
|
46
|
+
*/
|
|
47
|
+
offset?: UiFloatActionsOffset;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The controlled open state of the floating panel.
|
|
51
|
+
* - Omit for uncontrolled mode (component manages state internally)
|
|
52
|
+
* - Use `v-model:open` for controlled mode
|
|
53
|
+
* @example
|
|
54
|
+
* ```vue
|
|
55
|
+
* <UiFloatActions v-model:open="isOpen">…</UiFloatActions>
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
open?: boolean;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Delay in ms before opening on pointer hover.
|
|
62
|
+
* Keyboard focus opens immediately regardless of this value.
|
|
63
|
+
* @default 150
|
|
64
|
+
*/
|
|
65
|
+
openDelay?: number;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Delay in ms before closing on pointer leave.
|
|
69
|
+
* @default 150
|
|
70
|
+
*/
|
|
71
|
+
closeDelay?: number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Close when clicking outside the anchor and floating panel.
|
|
75
|
+
* @default true
|
|
76
|
+
*/
|
|
77
|
+
dismissOnOutsideClick?: boolean;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Close when Escape is pressed and restore focus to the anchor.
|
|
81
|
+
* @default true
|
|
82
|
+
*/
|
|
83
|
+
dismissOnEscape?: boolean;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Accessible label for the anchor when it has no visible text.
|
|
87
|
+
* **Required** for triggers without readable anchor content when keyboard
|
|
88
|
+
* users need a concise name (e.g. icon-only or non-descriptive anchors).
|
|
89
|
+
*/
|
|
90
|
+
ariaLabel?: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Item role within a {@link UiFloatActionItems} toolbar. */
|
|
94
|
+
export type UiFloatActionItemsType =
|
|
95
|
+
| 'toolbar'
|
|
96
|
+
| 'button'
|
|
97
|
+
| 'input'
|
|
98
|
+
| 'text'
|
|
99
|
+
| 'group'
|
|
100
|
+
| 'separator';
|
|
101
|
+
|
|
102
|
+
/** Arrow-key navigation direction for toolbar roving focus. */
|
|
103
|
+
export type UiFloatActionItemsOrientation = 'horizontal' | 'vertical';
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Pill-shaped floating toolbar and its action items.
|
|
107
|
+
*
|
|
108
|
+
* Use the root item (`type="toolbar"`) as the container and nest child items
|
|
109
|
+
* for buttons, inputs, text labels, groups, and separators. Implements the
|
|
110
|
+
* WAI-ARIA APG toolbar pattern with roving tabindex.
|
|
111
|
+
*
|
|
112
|
+
* @category Overlays
|
|
113
|
+
* @useCases contextual toolbar, inline actions, pagination controls, filter bar
|
|
114
|
+
* @keywords float, toolbar, pill, actions, keyboard, roving focus
|
|
115
|
+
* @related UiFloatActions, useAnchorFloat
|
|
116
|
+
*/
|
|
117
|
+
export interface UiFloatActionItemsProps {
|
|
118
|
+
/**
|
|
119
|
+
* Item role within the floating toolbar.
|
|
120
|
+
* Omit or use `toolbar` for the root pill container.
|
|
121
|
+
* @default 'toolbar'
|
|
122
|
+
*/
|
|
123
|
+
type?: UiFloatActionItemsType;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Disables interaction for `button` and `input` items.
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
disabled?: boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Accessible label for `toolbar`, `button`, and `input` items.
|
|
133
|
+
* **Required** for those types — icon-only buttons have no visible text.
|
|
134
|
+
*/
|
|
135
|
+
ariaLabel?: string;
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Keyboard navigation direction for toolbar items (ArrowLeft/Right or Up/Down).
|
|
139
|
+
* @default 'horizontal'
|
|
140
|
+
*/
|
|
141
|
+
orientation?: UiFloatActionItemsOrientation;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Placeholder text for `input` items.
|
|
145
|
+
*/
|
|
146
|
+
placeholder?: string;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Events emitted by {@link UiFloatActionItems} button items. */
|
|
150
|
+
export interface UiFloatActionItemsEmits {
|
|
151
|
+
/** Emitted when a `button` item is activated. */
|
|
152
|
+
click: [event: MouseEvent];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export type UiFloatActionItemsClass = HTMLAttributes['class'];
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { UiButton } from '@/components/UiButton';
|
|
3
|
+
import { UiIcon } from '@/components/UiIcon';
|
|
4
|
+
import { useSidebar } from '@/components/core/sidebar';
|
|
5
|
+
import UiSidebar from './UiSidebar.vue';
|
|
6
|
+
import UiSidebarContent from './UiSidebarContent.vue';
|
|
7
|
+
import UiSidebarHeader from './UiSidebarHeader.vue';
|
|
8
|
+
import UiSidebarInset from './UiSidebarInset.vue';
|
|
9
|
+
import UiSidebarMenu from './UiSidebarMenu.vue';
|
|
10
|
+
import UiSidebarMenuButton from './UiSidebarMenuButton.vue';
|
|
11
|
+
import UiSidebarMenuItem from './UiSidebarMenuItem.vue';
|
|
12
|
+
import UiSidebarProvider from './UiSidebarProvider.vue';
|
|
13
|
+
|
|
14
|
+
const meta: Meta<typeof UiSidebarInset> = {
|
|
15
|
+
title: 'Patterns/UiSidebar/UiSidebarInset',
|
|
16
|
+
component: UiSidebarInset,
|
|
17
|
+
tags: ['autodocs'],
|
|
18
|
+
parameters: {
|
|
19
|
+
layout: 'fullscreen',
|
|
20
|
+
docs: {
|
|
21
|
+
description: {
|
|
22
|
+
component:
|
|
23
|
+
'The main content column that peers with `UiSidebar` inside a `UiSidebarProvider`. Renders as a `<main>` landmark by default. Use the `as` prop to render a different tag (e.g. `div`, `section`) or a Vue component — this is required when a page contains more than one inset so there is only a single `<main>` landmark for accessibility.',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
argTypes: {
|
|
28
|
+
as: {
|
|
29
|
+
control: 'text',
|
|
30
|
+
description:
|
|
31
|
+
'The tag or component to render as the root element. Defaults to `main`. Use a different tag when rendering multiple insets on a single page to avoid duplicate `main` landmarks.',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default meta;
|
|
37
|
+
|
|
38
|
+
type Story = StoryObj<typeof UiSidebarInset>;
|
|
39
|
+
|
|
40
|
+
const NAV_ITEMS = [
|
|
41
|
+
{ title: 'Home', icon: 'home' },
|
|
42
|
+
{ title: 'Collections', icon: 'folder' },
|
|
43
|
+
{ title: 'Chat', icon: 'message-square' },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A toggle button that opens/closes the nearest sidebar via `useSidebar()`.
|
|
48
|
+
* `toggleSidebar` collapses/expands on desktop and opens/closes the sheet on
|
|
49
|
+
* mobile; the label reflects the current desktop state.
|
|
50
|
+
*/
|
|
51
|
+
const SidebarToggle = {
|
|
52
|
+
name: 'SidebarToggle',
|
|
53
|
+
components: { UiButton, UiIcon },
|
|
54
|
+
props: {
|
|
55
|
+
name: { type: String, default: 'sidebar' },
|
|
56
|
+
},
|
|
57
|
+
setup() {
|
|
58
|
+
const { toggleSidebar, state } = useSidebar();
|
|
59
|
+
return { toggleSidebar, state };
|
|
60
|
+
},
|
|
61
|
+
template: `
|
|
62
|
+
<UiButton
|
|
63
|
+
variant="outline"
|
|
64
|
+
size="sm"
|
|
65
|
+
:aria-label="(state === 'expanded' ? 'Collapse ' : 'Expand ') + name"
|
|
66
|
+
@click="toggleSidebar"
|
|
67
|
+
>
|
|
68
|
+
<UiIcon name="panel-left" size="s" />
|
|
69
|
+
{{ state === 'expanded' ? 'Collapse' : 'Expand' }} {{ name }}
|
|
70
|
+
</UiButton>
|
|
71
|
+
`,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const sharedComponents = {
|
|
75
|
+
SidebarToggle,
|
|
76
|
+
UiButton,
|
|
77
|
+
UiIcon,
|
|
78
|
+
UiSidebar,
|
|
79
|
+
UiSidebarContent,
|
|
80
|
+
UiSidebarHeader,
|
|
81
|
+
UiSidebarInset,
|
|
82
|
+
UiSidebarMenu,
|
|
83
|
+
UiSidebarMenuButton,
|
|
84
|
+
UiSidebarMenuItem,
|
|
85
|
+
UiSidebarProvider,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const insetBody = (title: string) => `
|
|
89
|
+
<header class="flex h-14 items-center gap-3 border-b border-border-surface-default px-4">
|
|
90
|
+
<SidebarToggle name="sidebar" />
|
|
91
|
+
<span class="body-14-regular text-content-on-surface-primary">${title}</span>
|
|
92
|
+
</header>
|
|
93
|
+
<div class="flex min-h-[320px] flex-1 p-4">
|
|
94
|
+
<div class="w-full rounded-md border border-border-surface-default bg-background-surface-primary p-6">
|
|
95
|
+
<div class="heading-s mb-2 text-content-on-surface-primary">${title}</div>
|
|
96
|
+
<div class="body-14-regular text-content-on-surface-muted">
|
|
97
|
+
Content rendered inside the sidebar inset.
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
const navMarkup = (header: string) => `
|
|
104
|
+
<UiSidebarHeader tooltip="${header}" aria-label="${header}">${header}</UiSidebarHeader>
|
|
105
|
+
<UiSidebarContent>
|
|
106
|
+
<UiSidebarMenu class="px-2 pt-1">
|
|
107
|
+
<UiSidebarMenuItem v-for="item in navItems" :key="item.title">
|
|
108
|
+
<UiSidebarMenuButton :tooltip="item.title" :aria-label="item.title">
|
|
109
|
+
<template #start-icon>
|
|
110
|
+
<UiIcon :name="item.icon" size="s" />
|
|
111
|
+
</template>
|
|
112
|
+
{{ item.title }}
|
|
113
|
+
</UiSidebarMenuButton>
|
|
114
|
+
</UiSidebarMenuItem>
|
|
115
|
+
</UiSidebarMenu>
|
|
116
|
+
</UiSidebarContent>
|
|
117
|
+
`;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A single `UiSidebarProvider` with a `UiSidebar` and a `UiSidebarInset`
|
|
121
|
+
* rendered with its default `as` value, so the content column is a `<main>`
|
|
122
|
+
* landmark.
|
|
123
|
+
*/
|
|
124
|
+
export const Default: Story = {
|
|
125
|
+
render: () => ({
|
|
126
|
+
components: sharedComponents,
|
|
127
|
+
setup() {
|
|
128
|
+
return { navItems: NAV_ITEMS };
|
|
129
|
+
},
|
|
130
|
+
template: `
|
|
131
|
+
<UiSidebarProvider :default-open="true">
|
|
132
|
+
<UiSidebar collapsible="icon">
|
|
133
|
+
${navMarkup('Assistant')}
|
|
134
|
+
</UiSidebar>
|
|
135
|
+
|
|
136
|
+
<UiSidebarInset>
|
|
137
|
+
${insetBody('Main content (<main>)')}
|
|
138
|
+
</UiSidebarInset>
|
|
139
|
+
</UiSidebarProvider>
|
|
140
|
+
`,
|
|
141
|
+
}),
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Passing `as="div"` renders the inset root as a `<div>` instead of `<main>`.
|
|
146
|
+
* Useful when the `<main>` landmark is owned by an ancestor.
|
|
147
|
+
*/
|
|
148
|
+
export const CustomTag: Story = {
|
|
149
|
+
render: () => ({
|
|
150
|
+
components: sharedComponents,
|
|
151
|
+
setup() {
|
|
152
|
+
return { navItems: NAV_ITEMS };
|
|
153
|
+
},
|
|
154
|
+
template: `
|
|
155
|
+
<UiSidebarProvider :default-open="true">
|
|
156
|
+
<UiSidebar collapsible="icon">
|
|
157
|
+
${navMarkup('Assistant')}
|
|
158
|
+
</UiSidebar>
|
|
159
|
+
|
|
160
|
+
<UiSidebarInset as="div">
|
|
161
|
+
${insetBody('Custom tag (<div>)')}
|
|
162
|
+
</UiSidebarInset>
|
|
163
|
+
</UiSidebarProvider>
|
|
164
|
+
`,
|
|
165
|
+
}),
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const PanelSection = {
|
|
169
|
+
name: 'PanelSection',
|
|
170
|
+
template: `
|
|
171
|
+
<section aria-label="Panel section">
|
|
172
|
+
<slot />
|
|
173
|
+
</section>
|
|
174
|
+
`,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* The `as` prop also accepts a Vue component. Here the inset renders as a custom
|
|
179
|
+
* `PanelSection` component, which receives the inset's `data-slot`, classes, and
|
|
180
|
+
* slot content on its root element.
|
|
181
|
+
*/
|
|
182
|
+
export const CustomComponent: Story = {
|
|
183
|
+
render: () => ({
|
|
184
|
+
components: { ...sharedComponents, PanelSection },
|
|
185
|
+
setup() {
|
|
186
|
+
return { navItems: NAV_ITEMS, PanelSection };
|
|
187
|
+
},
|
|
188
|
+
template: `
|
|
189
|
+
<UiSidebarProvider :default-open="true">
|
|
190
|
+
<UiSidebar collapsible="icon">
|
|
191
|
+
${navMarkup('Assistant')}
|
|
192
|
+
</UiSidebar>
|
|
193
|
+
|
|
194
|
+
<UiSidebarInset :as="PanelSection">
|
|
195
|
+
${insetBody('Custom component (<PanelSection>)')}
|
|
196
|
+
</UiSidebarInset>
|
|
197
|
+
</UiSidebarProvider>
|
|
198
|
+
`,
|
|
199
|
+
}),
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Two sidebars on one page: an inner right sidebar nested inside the left
|
|
204
|
+
* sidebar's inset. The outer inset keeps the single `<main>` landmark, while the
|
|
205
|
+
* inner inset renders as a `<div>` (`as="div"`) so the page does not end up with
|
|
206
|
+
* duplicate `<main>` landmarks — keeping the layout accessible.
|
|
207
|
+
*/
|
|
208
|
+
export const NestedSidebars: Story = {
|
|
209
|
+
parameters: {
|
|
210
|
+
docs: {
|
|
211
|
+
description: {
|
|
212
|
+
story:
|
|
213
|
+
'A right sidebar nested inside the left sidebar’s inset. The outer inset is the sole `<main>` landmark; the inner inset uses `as="div"` to avoid a second `<main>`, so accessibility (landmark uniqueness) is preserved.',
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
render: () => ({
|
|
218
|
+
components: sharedComponents,
|
|
219
|
+
setup() {
|
|
220
|
+
return { navItems: NAV_ITEMS };
|
|
221
|
+
},
|
|
222
|
+
template: `
|
|
223
|
+
<UiSidebarProvider :default-open="true">
|
|
224
|
+
<UiSidebar side="left" collapsible="icon">
|
|
225
|
+
${navMarkup('Primary')}
|
|
226
|
+
</UiSidebar>
|
|
227
|
+
|
|
228
|
+
<UiSidebarInset>
|
|
229
|
+
<header class="flex h-14 items-center gap-3 border-b border-border-surface-default px-4">
|
|
230
|
+
<SidebarToggle name="left sidebar" />
|
|
231
|
+
<span class="body-14-regular text-content-on-surface-primary">Outer inset (<main>)</span>
|
|
232
|
+
</header>
|
|
233
|
+
|
|
234
|
+
<UiSidebarProvider :default-open="true">
|
|
235
|
+
<UiSidebar side="right" collapsible="icon">
|
|
236
|
+
${navMarkup('Secondary')}
|
|
237
|
+
</UiSidebar>
|
|
238
|
+
|
|
239
|
+
<UiSidebarInset as="div">
|
|
240
|
+
<header class="flex h-14 items-center gap-3 border-b border-border-surface-default px-4">
|
|
241
|
+
<SidebarToggle name="right sidebar" />
|
|
242
|
+
<span class="body-14-regular text-content-on-surface-primary">Inner inset (<div>)</span>
|
|
243
|
+
</header>
|
|
244
|
+
<div class="flex min-h-[320px] flex-1 p-4">
|
|
245
|
+
<div class="w-full rounded-md border border-border-surface-default bg-background-surface-primary p-6">
|
|
246
|
+
<div class="heading-s mb-2 text-content-on-surface-primary">Nested content</div>
|
|
247
|
+
<div class="body-14-regular text-content-on-surface-muted">
|
|
248
|
+
The inner inset is rendered as a <div> so the page keeps a single <main> landmark.
|
|
249
|
+
Use the toggles above to open and close each sidebar.
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
</UiSidebarInset>
|
|
254
|
+
</UiSidebarProvider>
|
|
255
|
+
</UiSidebarInset>
|
|
256
|
+
</UiSidebarProvider>
|
|
257
|
+
`,
|
|
258
|
+
}),
|
|
259
|
+
};
|
|
@@ -33,4 +33,24 @@ describe('UiSidebarInset', () => {
|
|
|
33
33
|
expect(container.querySelector('[data-slot="sidebar-inset"]')).toBeTruthy();
|
|
34
34
|
expect(container).toHaveTextContent('Main');
|
|
35
35
|
});
|
|
36
|
+
|
|
37
|
+
test('renders a main tag by default', () => {
|
|
38
|
+
const { container } = render(UiSidebarInset, {
|
|
39
|
+
slots: { default: 'Main' },
|
|
40
|
+
});
|
|
41
|
+
expect(
|
|
42
|
+
container.querySelector('main[data-slot="sidebar-inset"]'),
|
|
43
|
+
).toBeTruthy();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('renders a custom tag when the "as" prop is provided', () => {
|
|
47
|
+
const { container } = render(UiSidebarInset, {
|
|
48
|
+
props: { as: 'div' },
|
|
49
|
+
slots: { default: 'Main' },
|
|
50
|
+
});
|
|
51
|
+
expect(container.querySelector('main')).toBeFalsy();
|
|
52
|
+
expect(
|
|
53
|
+
container.querySelector('div[data-slot="sidebar-inset"]'),
|
|
54
|
+
).toBeTruthy();
|
|
55
|
+
});
|
|
36
56
|
});
|