@surreal-ui/svelte 0.5.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/CHANGELOG.md +66 -0
- package/package.json +33 -0
- package/src/components/GlassmorphismAlert.svelte +37 -0
- package/src/components/GlassmorphismButton.svelte +16 -0
- package/src/components/GlassmorphismCard.svelte +37 -0
- package/src/components/GlassmorphismEmptyState.svelte +19 -0
- package/src/components/GlassmorphismInputGroup.svelte +124 -0
- package/src/components/GlassmorphismMenubar.svelte +98 -0
- package/src/components/GlassmorphismScrollArea.svelte +61 -0
- package/src/components/GlassmorphismTable.svelte +54 -0
- package/src/components/GlassmorphismTypography.svelte +31 -0
- package/src/components/MinimalistAccordion.svelte +189 -0
- package/src/components/MinimalistAlert.svelte +35 -0
- package/src/components/MinimalistAlertDialog.svelte +247 -0
- package/src/components/MinimalistAspectRatio.svelte +31 -0
- package/src/components/MinimalistAvatar.svelte +127 -0
- package/src/components/MinimalistBadge.svelte +60 -0
- package/src/components/MinimalistBreadcrumb.svelte +141 -0
- package/src/components/MinimalistButton.svelte +94 -0
- package/src/components/MinimalistButtonGroup.svelte +93 -0
- package/src/components/MinimalistCalendar.svelte +307 -0
- package/src/components/MinimalistCard.svelte +87 -0
- package/src/components/MinimalistCarousel.svelte +258 -0
- package/src/components/MinimalistChart.svelte +225 -0
- package/src/components/MinimalistCheckbox.svelte +95 -0
- package/src/components/MinimalistCodeBlock.svelte +189 -0
- package/src/components/MinimalistCollapsible.svelte +88 -0
- package/src/components/MinimalistCommand.svelte +299 -0
- package/src/components/MinimalistContextMenu.svelte +236 -0
- package/src/components/MinimalistDialog.svelte +218 -0
- package/src/components/MinimalistDrawer.svelte +209 -0
- package/src/components/MinimalistDropdownMenu.svelte +349 -0
- package/src/components/MinimalistEmpty.svelte +136 -0
- package/src/components/MinimalistEmptyState.svelte +27 -0
- package/src/components/MinimalistField.svelte +239 -0
- package/src/components/MinimalistForm.svelte +157 -0
- package/src/components/MinimalistHoverCard.svelte +71 -0
- package/src/components/MinimalistInput.svelte +53 -0
- package/src/components/MinimalistInputGroup.svelte +165 -0
- package/src/components/MinimalistInputOtp.svelte +171 -0
- package/src/components/MinimalistItem.svelte +225 -0
- package/src/components/MinimalistKbd.svelte +39 -0
- package/src/components/MinimalistLabel.svelte +26 -0
- package/src/components/MinimalistMenubar.svelte +373 -0
- package/src/components/MinimalistNativeSelect.svelte +81 -0
- package/src/components/MinimalistNavigationMenu.svelte +188 -0
- package/src/components/MinimalistPagination.svelte +189 -0
- package/src/components/MinimalistPopover.svelte +160 -0
- package/src/components/MinimalistProgress.svelte +42 -0
- package/src/components/MinimalistRadioGroup.svelte +90 -0
- package/src/components/MinimalistRangeCalendar.svelte +273 -0
- package/src/components/MinimalistResizable.svelte +45 -0
- package/src/components/MinimalistScrollArea.svelte +24 -0
- package/src/components/MinimalistSelect.svelte +237 -0
- package/src/components/MinimalistSeparator.svelte +35 -0
- package/src/components/MinimalistSheet.svelte +189 -0
- package/src/components/MinimalistSidebar.svelte +601 -0
- package/src/components/MinimalistSkeleton.svelte +19 -0
- package/src/components/MinimalistSlider.svelte +192 -0
- package/src/components/MinimalistSonner.svelte +30 -0
- package/src/components/MinimalistSpinner.svelte +35 -0
- package/src/components/MinimalistSwitch.svelte +67 -0
- package/src/components/MinimalistTable.svelte +53 -0
- package/src/components/MinimalistTabs.svelte +169 -0
- package/src/components/MinimalistTextarea.svelte +31 -0
- package/src/components/MinimalistToggle.svelte +74 -0
- package/src/components/MinimalistToggleGroup.svelte +184 -0
- package/src/components/MinimalistTooltip.svelte +121 -0
- package/src/components/MinimalistTypography.svelte +25 -0
- package/src/components/NeubrutalismCard.svelte +85 -0
- package/src/components/NeubrutalismItem.svelte +53 -0
- package/src/components/ShadcnAccordion.svelte +189 -0
- package/src/components/ShadcnAlertDialog.svelte +247 -0
- package/src/components/ShadcnAspectRatio.svelte +31 -0
- package/src/components/ShadcnAvatar.svelte +127 -0
- package/src/components/ShadcnBadge.svelte +60 -0
- package/src/components/ShadcnBreadcrumb.svelte +141 -0
- package/src/components/ShadcnButton.svelte +94 -0
- package/src/components/ShadcnButtonGroup.svelte +93 -0
- package/src/components/ShadcnCalendar.svelte +307 -0
- package/src/components/ShadcnCarousel.svelte +258 -0
- package/src/components/ShadcnChart.svelte +225 -0
- package/src/components/ShadcnCheckbox.svelte +95 -0
- package/src/components/ShadcnCodeBlock.svelte +189 -0
- package/src/components/ShadcnCollapsible.svelte +88 -0
- package/src/components/ShadcnCommand.svelte +299 -0
- package/src/components/ShadcnContextMenu.svelte +236 -0
- package/src/components/ShadcnDialog.svelte +218 -0
- package/src/components/ShadcnDrawer.svelte +209 -0
- package/src/components/ShadcnDropdownMenu.svelte +349 -0
- package/src/components/ShadcnEmpty.svelte +136 -0
- package/src/components/ShadcnField.svelte +239 -0
- package/src/components/ShadcnForm.svelte +157 -0
- package/src/components/ShadcnHoverCard.svelte +71 -0
- package/src/components/ShadcnInput.svelte +53 -0
- package/src/components/ShadcnInputGroup.svelte +165 -0
- package/src/components/ShadcnInputOtp.svelte +171 -0
- package/src/components/ShadcnItem.svelte +225 -0
- package/src/components/ShadcnKbd.svelte +39 -0
- package/src/components/ShadcnLabel.svelte +26 -0
- package/src/components/ShadcnMenubar.svelte +373 -0
- package/src/components/ShadcnNativeSelect.svelte +81 -0
- package/src/components/ShadcnNavigationMenu.svelte +188 -0
- package/src/components/ShadcnPagination.svelte +189 -0
- package/src/components/ShadcnPopover.svelte +160 -0
- package/src/components/ShadcnProgress.svelte +42 -0
- package/src/components/ShadcnRadioGroup.svelte +90 -0
- package/src/components/ShadcnRangeCalendar.svelte +273 -0
- package/src/components/ShadcnSelect.svelte +237 -0
- package/src/components/ShadcnSeparator.svelte +35 -0
- package/src/components/ShadcnSheet.svelte +189 -0
- package/src/components/ShadcnSidebar.svelte +601 -0
- package/src/components/ShadcnSkeleton.svelte +19 -0
- package/src/components/ShadcnSlider.svelte +192 -0
- package/src/components/ShadcnSonner.svelte +30 -0
- package/src/components/ShadcnSpinner.svelte +35 -0
- package/src/components/ShadcnSwitch.svelte +67 -0
- package/src/components/ShadcnTabs.svelte +169 -0
- package/src/components/ShadcnTextarea.svelte +31 -0
- package/src/components/ShadcnToggle.svelte +74 -0
- package/src/components/ShadcnToggleGroup.svelte +184 -0
- package/src/components/ShadcnTooltip.svelte +121 -0
- package/src/index.d.ts +123 -0
- package/src/index.js +123 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '@surreal-ui/core';
|
|
3
|
+
|
|
4
|
+
import { ContextMenu as ContextMenuPrimitive } from 'bits-ui';
|
|
5
|
+
import Check from '@lucide/svelte/icons/check';
|
|
6
|
+
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
|
7
|
+
import type { Snippet } from 'svelte';
|
|
8
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
9
|
+
|
|
10
|
+
interface ShadcnContextMenuProps extends ContextMenuPrimitive.RootProps {}
|
|
11
|
+
|
|
12
|
+
let { open = $bindable(false), children, ...restProps }: ShadcnContextMenuProps = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
{#snippet Trigger({ class: className = '', children: triggerChildren, ...triggerProps })}
|
|
16
|
+
<ContextMenuPrimitive.Trigger
|
|
17
|
+
data-slot="context-menu-trigger"
|
|
18
|
+
class={cn('cn-context-menu-trigger select-none', className)}
|
|
19
|
+
{...triggerProps}
|
|
20
|
+
>
|
|
21
|
+
{@render triggerChildren?.()}
|
|
22
|
+
</ContextMenuPrimitive.Trigger>
|
|
23
|
+
{/snippet}
|
|
24
|
+
|
|
25
|
+
{#snippet Content({
|
|
26
|
+
class: className = '',
|
|
27
|
+
children: contentChildren,
|
|
28
|
+
portalProps,
|
|
29
|
+
...contentProps
|
|
30
|
+
})}
|
|
31
|
+
<ContextMenuPrimitive.Portal {...portalProps}>
|
|
32
|
+
<ContextMenuPrimitive.Content
|
|
33
|
+
data-slot="context-menu-content"
|
|
34
|
+
class={cn(
|
|
35
|
+
'min-w-36 rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 overflow-x-hidden overflow-y-auto outline-none',
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
{...contentProps}
|
|
39
|
+
>
|
|
40
|
+
{@render contentChildren?.()}
|
|
41
|
+
</ContextMenuPrimitive.Content>
|
|
42
|
+
</ContextMenuPrimitive.Portal>
|
|
43
|
+
{/snippet}
|
|
44
|
+
|
|
45
|
+
{#snippet Item({
|
|
46
|
+
class: className = '',
|
|
47
|
+
inset = false,
|
|
48
|
+
variant = 'default',
|
|
49
|
+
children: itemChildren,
|
|
50
|
+
...itemProps
|
|
51
|
+
})}
|
|
52
|
+
<ContextMenuPrimitive.Item
|
|
53
|
+
data-slot="context-menu-item"
|
|
54
|
+
data-inset={inset}
|
|
55
|
+
data-variant={variant}
|
|
56
|
+
class={cn(
|
|
57
|
+
"gap-1.5 rounded-md px-1.5 py-1 text-sm focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive group/context-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
58
|
+
className,
|
|
59
|
+
)}
|
|
60
|
+
{...itemProps}
|
|
61
|
+
>
|
|
62
|
+
{@render itemChildren?.()}
|
|
63
|
+
</ContextMenuPrimitive.Item>
|
|
64
|
+
{/snippet}
|
|
65
|
+
|
|
66
|
+
{#snippet CheckboxItem({
|
|
67
|
+
class: className = '',
|
|
68
|
+
inset = false,
|
|
69
|
+
checked = false,
|
|
70
|
+
children: checkboxChildren,
|
|
71
|
+
...checkboxProps
|
|
72
|
+
})}
|
|
73
|
+
<ContextMenuPrimitive.CheckboxItem
|
|
74
|
+
data-slot="context-menu-checkbox-item"
|
|
75
|
+
data-inset={inset}
|
|
76
|
+
{checked}
|
|
77
|
+
class={cn(
|
|
78
|
+
"gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm focus:bg-accent focus:text-accent-foreground data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
79
|
+
className,
|
|
80
|
+
)}
|
|
81
|
+
{...checkboxProps}
|
|
82
|
+
>
|
|
83
|
+
{#snippet children({ checked: isChecked })}
|
|
84
|
+
<span class="absolute right-2 pointer-events-none flex size-3.5 items-center justify-center">
|
|
85
|
+
{#if isChecked}
|
|
86
|
+
<Check class="size-4" />
|
|
87
|
+
{/if}
|
|
88
|
+
</span>
|
|
89
|
+
{@render checkboxChildren?.()}
|
|
90
|
+
{/snippet}
|
|
91
|
+
</ContextMenuPrimitive.CheckboxItem>
|
|
92
|
+
{/snippet}
|
|
93
|
+
|
|
94
|
+
{#snippet RadioGroup({
|
|
95
|
+
class: className = '',
|
|
96
|
+
value = '',
|
|
97
|
+
children: radioGroupChildren,
|
|
98
|
+
...radioGroupProps
|
|
99
|
+
})}
|
|
100
|
+
<ContextMenuPrimitive.RadioGroup
|
|
101
|
+
data-slot="context-menu-radio-group"
|
|
102
|
+
{value}
|
|
103
|
+
class={cn(className)}
|
|
104
|
+
{...radioGroupProps}
|
|
105
|
+
>
|
|
106
|
+
{@render radioGroupChildren?.()}
|
|
107
|
+
</ContextMenuPrimitive.RadioGroup>
|
|
108
|
+
{/snippet}
|
|
109
|
+
|
|
110
|
+
{#snippet RadioItem({
|
|
111
|
+
class: className = '',
|
|
112
|
+
inset = false,
|
|
113
|
+
value = '',
|
|
114
|
+
children: radioItemChildren,
|
|
115
|
+
...radioItemProps
|
|
116
|
+
})}
|
|
117
|
+
<ContextMenuPrimitive.RadioItem
|
|
118
|
+
data-slot="context-menu-radio-item"
|
|
119
|
+
data-inset={inset}
|
|
120
|
+
{value}
|
|
121
|
+
class={cn(
|
|
122
|
+
"gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm focus:bg-accent focus:text-accent-foreground data-inset:pl-7 [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
123
|
+
className,
|
|
124
|
+
)}
|
|
125
|
+
{...radioItemProps}
|
|
126
|
+
>
|
|
127
|
+
{#snippet children({ checked: isChecked })}
|
|
128
|
+
<span class="absolute right-2 pointer-events-none flex size-3.5 items-center justify-center">
|
|
129
|
+
{#if isChecked}
|
|
130
|
+
<Check class="size-4" />
|
|
131
|
+
{/if}
|
|
132
|
+
</span>
|
|
133
|
+
{@render radioItemChildren?.()}
|
|
134
|
+
{/snippet}
|
|
135
|
+
</ContextMenuPrimitive.RadioItem>
|
|
136
|
+
{/snippet}
|
|
137
|
+
|
|
138
|
+
{#snippet Label({ class: className = '', inset = false, children: labelChildren, ...labelProps })}
|
|
139
|
+
<div
|
|
140
|
+
data-slot="context-menu-label"
|
|
141
|
+
data-inset={inset}
|
|
142
|
+
class={cn(
|
|
143
|
+
'px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7 data-inset:pl-8',
|
|
144
|
+
className,
|
|
145
|
+
)}
|
|
146
|
+
{...labelProps}
|
|
147
|
+
>
|
|
148
|
+
{@render labelChildren?.()}
|
|
149
|
+
</div>
|
|
150
|
+
{/snippet}
|
|
151
|
+
|
|
152
|
+
{#snippet Separator({ class: className = '', ...separatorProps })}
|
|
153
|
+
<ContextMenuPrimitive.Separator
|
|
154
|
+
data-slot="context-menu-separator"
|
|
155
|
+
class={cn('-mx-1 my-1 h-px bg-border', className)}
|
|
156
|
+
{...separatorProps}
|
|
157
|
+
/>
|
|
158
|
+
{/snippet}
|
|
159
|
+
|
|
160
|
+
{#snippet Shortcut({ class: className = '', children: shortcutChildren, ...shortcutProps })}
|
|
161
|
+
<span
|
|
162
|
+
data-slot="context-menu-shortcut"
|
|
163
|
+
class={cn(
|
|
164
|
+
'ml-auto text-xs tracking-widest text-muted-foreground group-focus/context-menu-item:text-accent-foreground',
|
|
165
|
+
className,
|
|
166
|
+
)}
|
|
167
|
+
{...shortcutProps}
|
|
168
|
+
>
|
|
169
|
+
{@render shortcutChildren?.()}
|
|
170
|
+
</span>
|
|
171
|
+
{/snippet}
|
|
172
|
+
|
|
173
|
+
{#snippet Group({ class: className = '', children: groupChildren, ...groupProps })}
|
|
174
|
+
<ContextMenuPrimitive.Group data-slot="context-menu-group" class={cn(className)} {...groupProps}>
|
|
175
|
+
{@render groupChildren?.()}
|
|
176
|
+
</ContextMenuPrimitive.Group>
|
|
177
|
+
{/snippet}
|
|
178
|
+
|
|
179
|
+
{#snippet GroupHeading({
|
|
180
|
+
class: className = '',
|
|
181
|
+
inset = false,
|
|
182
|
+
children: headingChildren,
|
|
183
|
+
...headingProps
|
|
184
|
+
})}
|
|
185
|
+
<ContextMenuPrimitive.GroupHeading
|
|
186
|
+
data-slot="context-menu-group-heading"
|
|
187
|
+
data-inset={inset}
|
|
188
|
+
class={cn('px-2 py-1.5 text-sm font-medium text-foreground data-inset:ps-8', className)}
|
|
189
|
+
{...headingProps}
|
|
190
|
+
>
|
|
191
|
+
{@render headingChildren?.()}
|
|
192
|
+
</ContextMenuPrimitive.GroupHeading>
|
|
193
|
+
{/snippet}
|
|
194
|
+
|
|
195
|
+
{#snippet Sub({ children: subChildren, ...subProps })}
|
|
196
|
+
<ContextMenuPrimitive.Sub {...subProps}>
|
|
197
|
+
{@render subChildren?.()}
|
|
198
|
+
</ContextMenuPrimitive.Sub>
|
|
199
|
+
{/snippet}
|
|
200
|
+
|
|
201
|
+
{#snippet SubTrigger({
|
|
202
|
+
class: className = '',
|
|
203
|
+
inset = false,
|
|
204
|
+
children: subTriggerChildren,
|
|
205
|
+
...subTriggerProps
|
|
206
|
+
})}
|
|
207
|
+
<ContextMenuPrimitive.SubTrigger
|
|
208
|
+
data-slot="context-menu-sub-trigger"
|
|
209
|
+
data-inset={inset}
|
|
210
|
+
class={cn(
|
|
211
|
+
"gap-1.5 rounded-md px-1.5 py-1 text-sm focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg:not([class*='size-'])]:size-4 flex cursor-default items-center outline-hidden select-none data-inset:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
212
|
+
className,
|
|
213
|
+
)}
|
|
214
|
+
{...subTriggerProps}
|
|
215
|
+
>
|
|
216
|
+
{@render subTriggerChildren?.()}
|
|
217
|
+
<ChevronRight class="ml-auto size-4" />
|
|
218
|
+
</ContextMenuPrimitive.SubTrigger>
|
|
219
|
+
{/snippet}
|
|
220
|
+
|
|
221
|
+
{#snippet SubContent({ class: className = '', children: subContentChildren, ...subContentProps })}
|
|
222
|
+
<ContextMenuPrimitive.SubContent
|
|
223
|
+
data-slot="context-menu-sub-content"
|
|
224
|
+
class={cn(
|
|
225
|
+
'min-w-32 rounded-lg border bg-popover p-1 text-popover-foreground shadow-lg duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',
|
|
226
|
+
className,
|
|
227
|
+
)}
|
|
228
|
+
{...subContentProps}
|
|
229
|
+
>
|
|
230
|
+
{@render subContentChildren?.()}
|
|
231
|
+
</ContextMenuPrimitive.SubContent>
|
|
232
|
+
{/snippet}
|
|
233
|
+
|
|
234
|
+
<ContextMenuPrimitive.Root bind:open {...restProps}>
|
|
235
|
+
{@render children?.()}
|
|
236
|
+
</ContextMenuPrimitive.Root>
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { cn } from '@surreal-ui/core';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type { HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
5
|
+
|
|
6
|
+
export interface ShadcnDialogRootProps {
|
|
7
|
+
open?: boolean;
|
|
8
|
+
onOpenChange?: (open: boolean) => void;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ShadcnDialogTriggerProps extends HTMLButtonAttributes {
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ShadcnDialogPortalProps {
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ShadcnDialogOverlayProps extends HTMLAttributes<HTMLDivElement> {
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ShadcnDialogContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
25
|
+
children?: Snippet;
|
|
26
|
+
showCloseButton?: boolean;
|
|
27
|
+
portalProps?: DialogPortalProps;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ShadcnDialogHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
31
|
+
children?: Snippet;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ShadcnDialogTitleProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
35
|
+
children?: Snippet;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ShadcnDialogDescriptionProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
39
|
+
children?: Snippet;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ShadcnDialogFooterProps extends HTMLAttributes<HTMLDivElement> {
|
|
43
|
+
children?: Snippet;
|
|
44
|
+
showCloseButton?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ShadcnDialogCloseProps extends HTMLButtonAttributes {
|
|
48
|
+
children?: Snippet;
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<script lang="ts">
|
|
53
|
+
import { X } from '@lucide/svelte';
|
|
54
|
+
|
|
55
|
+
let { open = $bindable(false), onOpenChange, children }: ShadcnDialogRootProps = $props();
|
|
56
|
+
|
|
57
|
+
function handleOpenChange(value: boolean) {
|
|
58
|
+
open = value;
|
|
59
|
+
onOpenChange?.(value);
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
{#snippet DialogTrigger({
|
|
64
|
+
class: className = '',
|
|
65
|
+
children,
|
|
66
|
+
onclick,
|
|
67
|
+
...props
|
|
68
|
+
}: ShadcnDialogTriggerProps = {})}
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
data-slot="dialog-trigger"
|
|
72
|
+
class={cn('inline-flex items-center justify-center', className)}
|
|
73
|
+
onclick={(e) => {
|
|
74
|
+
handleOpenChange(true);
|
|
75
|
+
onclick?.(e);
|
|
76
|
+
}}
|
|
77
|
+
{...props}
|
|
78
|
+
>
|
|
79
|
+
{@render children?.()}
|
|
80
|
+
</button>
|
|
81
|
+
{/snippet}
|
|
82
|
+
|
|
83
|
+
{#snippet DialogPortal({ children }: ShadcnDialogPortalProps = {})}
|
|
84
|
+
{@render children?.()}
|
|
85
|
+
{/snippet}
|
|
86
|
+
|
|
87
|
+
{#snippet DialogOverlay({ class: className = '', onclick, ...props }: ShadcnDialogOverlayProps = {})}
|
|
88
|
+
<div
|
|
89
|
+
role="presentation"
|
|
90
|
+
data-slot="dialog-overlay"
|
|
91
|
+
class={cn(
|
|
92
|
+
'bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0 fixed inset-0 isolate z-50',
|
|
93
|
+
className,
|
|
94
|
+
)}
|
|
95
|
+
onclick={(e) => {
|
|
96
|
+
handleOpenChange(false);
|
|
97
|
+
onclick?.(e);
|
|
98
|
+
}}
|
|
99
|
+
{...props}
|
|
100
|
+
></div>
|
|
101
|
+
{/snippet}
|
|
102
|
+
|
|
103
|
+
{#snippet DialogContent({
|
|
104
|
+
class: className = '',
|
|
105
|
+
children,
|
|
106
|
+
showCloseButton = true,
|
|
107
|
+
...props
|
|
108
|
+
}: ShadcnDialogContentProps = {})}
|
|
109
|
+
{#if open}
|
|
110
|
+
{@render DialogOverlay({})}
|
|
111
|
+
<div
|
|
112
|
+
role="dialog"
|
|
113
|
+
aria-modal="true"
|
|
114
|
+
data-slot="dialog-content"
|
|
115
|
+
class={cn(
|
|
116
|
+
'grid max-w-[calc(100%-2rem)] gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 fixed top-1/2 left-1/2 z-50 w-full -translate-x-1/2 -translate-y-1/2 outline-none shadow-lg',
|
|
117
|
+
className,
|
|
118
|
+
)}
|
|
119
|
+
{...props}
|
|
120
|
+
>
|
|
121
|
+
{@render children?.()}
|
|
122
|
+
{#if showCloseButton}
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
data-slot="dialog-close"
|
|
126
|
+
aria-label="Close"
|
|
127
|
+
class="absolute top-2 right-2 inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring outline-none transition-colors"
|
|
128
|
+
onclick={() => handleOpenChange(false)}
|
|
129
|
+
>
|
|
130
|
+
<X class="h-4 w-4" />
|
|
131
|
+
<span class="sr-only">Close</span>
|
|
132
|
+
</button>
|
|
133
|
+
{/if}
|
|
134
|
+
</div>
|
|
135
|
+
{/if}
|
|
136
|
+
{/snippet}
|
|
137
|
+
|
|
138
|
+
{#snippet DialogHeader({ class: className = '', children, ...props }: ShadcnDialogHeaderProps = {})}
|
|
139
|
+
<div data-slot="dialog-header" class={cn('gap-2 flex flex-col', className)} {...props}>
|
|
140
|
+
{@render children?.()}
|
|
141
|
+
</div>
|
|
142
|
+
{/snippet}
|
|
143
|
+
|
|
144
|
+
{#snippet DialogTitle({ class: className = '', children, ...props }: ShadcnDialogTitleProps = {})}
|
|
145
|
+
<h2
|
|
146
|
+
data-slot="dialog-title"
|
|
147
|
+
class={cn('text-base leading-none font-medium', className)}
|
|
148
|
+
{...props}
|
|
149
|
+
>
|
|
150
|
+
{@render children?.()}
|
|
151
|
+
</h2>
|
|
152
|
+
{/snippet}
|
|
153
|
+
|
|
154
|
+
{#snippet DialogDescription({
|
|
155
|
+
class: className = '',
|
|
156
|
+
children,
|
|
157
|
+
...props
|
|
158
|
+
}: ShadcnDialogDescriptionProps = {})}
|
|
159
|
+
<p
|
|
160
|
+
data-slot="dialog-description"
|
|
161
|
+
class={cn(
|
|
162
|
+
'text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground',
|
|
163
|
+
className,
|
|
164
|
+
)}
|
|
165
|
+
{...props}
|
|
166
|
+
>
|
|
167
|
+
{@render children?.()}
|
|
168
|
+
</p>
|
|
169
|
+
{/snippet}
|
|
170
|
+
|
|
171
|
+
{#snippet DialogFooter({
|
|
172
|
+
class: className = '',
|
|
173
|
+
children,
|
|
174
|
+
showCloseButton = false,
|
|
175
|
+
...props
|
|
176
|
+
}: ShadcnDialogFooterProps = {})}
|
|
177
|
+
<div
|
|
178
|
+
data-slot="dialog-footer"
|
|
179
|
+
class={cn(
|
|
180
|
+
'-mx-4 -mb-4 rounded-b-xl border-t bg-muted/50 p-4 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',
|
|
181
|
+
className,
|
|
182
|
+
)}
|
|
183
|
+
{...props}
|
|
184
|
+
>
|
|
185
|
+
{@render children?.()}
|
|
186
|
+
{#if showCloseButton}
|
|
187
|
+
<button
|
|
188
|
+
type="button"
|
|
189
|
+
class="inline-flex items-center justify-center rounded-md border border-input bg-background px-3 py-1.5 text-sm font-medium shadow-xs hover:bg-accent hover:text-accent-foreground"
|
|
190
|
+
onclick={() => handleOpenChange(false)}
|
|
191
|
+
>
|
|
192
|
+
Close
|
|
193
|
+
</button>
|
|
194
|
+
{/if}
|
|
195
|
+
</div>
|
|
196
|
+
{/snippet}
|
|
197
|
+
|
|
198
|
+
{#snippet DialogClose({
|
|
199
|
+
class: className = '',
|
|
200
|
+
children,
|
|
201
|
+
onclick,
|
|
202
|
+
...props
|
|
203
|
+
}: ShadcnDialogCloseProps = {})}
|
|
204
|
+
<button
|
|
205
|
+
type="button"
|
|
206
|
+
data-slot="dialog-close"
|
|
207
|
+
class={cn('inline-flex items-center justify-center', className)}
|
|
208
|
+
onclick={(e) => {
|
|
209
|
+
handleOpenChange(false);
|
|
210
|
+
onclick?.(e);
|
|
211
|
+
}}
|
|
212
|
+
{...props}
|
|
213
|
+
>
|
|
214
|
+
{@render children?.()}
|
|
215
|
+
</button>
|
|
216
|
+
{/snippet}
|
|
217
|
+
|
|
218
|
+
{@render children?.()}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '@surreal-ui/core';
|
|
3
|
+
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import type { HTMLAttributes, HTMLButtonAttributes } from 'svelte/elements';
|
|
6
|
+
|
|
7
|
+
interface ShadcnDrawerRootProps {
|
|
8
|
+
open?: boolean;
|
|
9
|
+
onOpenChange?: (open: boolean) => void;
|
|
10
|
+
direction?: 'bottom' | 'top' | 'left' | 'right';
|
|
11
|
+
shouldScaleBackground?: boolean;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ShadcnDrawerTriggerProps extends HTMLButtonAttributes {
|
|
16
|
+
class?: string;
|
|
17
|
+
children?: Snippet;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface ShadcnDrawerPortalProps {
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ShadcnDrawerOverlayProps extends HTMLAttributes<HTMLDivElement> {
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ShadcnDrawerContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
29
|
+
class?: string;
|
|
30
|
+
children?: Snippet;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface ShadcnDrawerHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
34
|
+
class?: string;
|
|
35
|
+
children?: Snippet;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface ShadcnDrawerTitleProps extends HTMLAttributes<HTMLHeadingElement> {
|
|
39
|
+
class?: string;
|
|
40
|
+
children?: Snippet;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface ShadcnDrawerDescriptionProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
44
|
+
class?: string;
|
|
45
|
+
children?: Snippet;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface ShadcnDrawerFooterProps extends HTMLAttributes<HTMLDivElement> {
|
|
49
|
+
class?: string;
|
|
50
|
+
children?: Snippet;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface ShadcnDrawerCloseProps extends HTMLButtonAttributes {
|
|
54
|
+
class?: string;
|
|
55
|
+
children?: Snippet;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let {
|
|
59
|
+
open = $bindable(false),
|
|
60
|
+
onOpenChange,
|
|
61
|
+
direction = 'bottom',
|
|
62
|
+
shouldScaleBackground = true,
|
|
63
|
+
children,
|
|
64
|
+
}: ShadcnDrawerRootProps = $props();
|
|
65
|
+
|
|
66
|
+
function setOpen(value: boolean) {
|
|
67
|
+
open = value;
|
|
68
|
+
onOpenChange?.(value);
|
|
69
|
+
}
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
{#snippet DrawerTrigger({
|
|
73
|
+
class: className = '',
|
|
74
|
+
children,
|
|
75
|
+
onclick,
|
|
76
|
+
...props
|
|
77
|
+
}: ShadcnDrawerTriggerProps = {})}
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
data-slot="drawer-trigger"
|
|
81
|
+
class={cn('inline-flex items-center justify-center', className)}
|
|
82
|
+
onclick={(e) => {
|
|
83
|
+
onclick?.(e);
|
|
84
|
+
setOpen(true);
|
|
85
|
+
}}
|
|
86
|
+
{...props}
|
|
87
|
+
>
|
|
88
|
+
{@render children?.()}
|
|
89
|
+
</button>
|
|
90
|
+
{/snippet}
|
|
91
|
+
|
|
92
|
+
{#snippet DrawerPortal({ children }: ShadcnDrawerPortalProps = {})}
|
|
93
|
+
{@render children?.()}
|
|
94
|
+
{/snippet}
|
|
95
|
+
|
|
96
|
+
{#snippet DrawerOverlay({ class: className = '', onclick, ...props }: ShadcnDrawerOverlayProps = {})}
|
|
97
|
+
{#if open}
|
|
98
|
+
<div
|
|
99
|
+
data-slot="drawer-overlay"
|
|
100
|
+
data-state={open ? 'open' : 'closed'}
|
|
101
|
+
class={cn(
|
|
102
|
+
'fixed inset-0 z-50 bg-black/80 supports-backdrop-filter:backdrop-blur-xs transition-opacity duration-300 animate-in fade-in-0',
|
|
103
|
+
className,
|
|
104
|
+
)}
|
|
105
|
+
onclick={(e) => {
|
|
106
|
+
onclick?.(e);
|
|
107
|
+
setOpen(false);
|
|
108
|
+
}}
|
|
109
|
+
{...props}
|
|
110
|
+
></div>
|
|
111
|
+
{/if}
|
|
112
|
+
{/snippet}
|
|
113
|
+
|
|
114
|
+
{#snippet DrawerContent({ class: className = '', children, ...props }: ShadcnDrawerContentProps = {})}
|
|
115
|
+
{#if open}
|
|
116
|
+
{@render DrawerOverlay()}
|
|
117
|
+
<div
|
|
118
|
+
data-slot="drawer-content"
|
|
119
|
+
data-vaul-drawer-direction={direction}
|
|
120
|
+
data-state={open ? 'open' : 'closed'}
|
|
121
|
+
class={cn(
|
|
122
|
+
'group/drawer-content fixed z-50 flex h-auto flex-col bg-popover text-sm text-popover-foreground shadow-lg transition-transform duration-300 ease-out',
|
|
123
|
+
direction === 'bottom' &&
|
|
124
|
+
'inset-x-0 bottom-0 mt-24 max-h-[80vh] rounded-t-xl border-t animate-in slide-in-from-bottom',
|
|
125
|
+
direction === 'top' &&
|
|
126
|
+
'inset-x-0 top-0 mb-24 max-h-[80vh] rounded-b-xl border-b animate-in slide-in-from-top',
|
|
127
|
+
direction === 'left' &&
|
|
128
|
+
'inset-y-0 left-0 w-3/4 max-w-sm rounded-r-xl border-r animate-in slide-in-from-left',
|
|
129
|
+
direction === 'right' &&
|
|
130
|
+
'inset-y-0 right-0 w-3/4 max-w-sm rounded-l-xl border-l animate-in slide-in-from-right',
|
|
131
|
+
className,
|
|
132
|
+
)}
|
|
133
|
+
{...props}
|
|
134
|
+
>
|
|
135
|
+
{#if direction === 'bottom'}
|
|
136
|
+
<div class="mx-auto mt-4 h-1.5 w-12 shrink-0 rounded-full bg-muted"></div>
|
|
137
|
+
{/if}
|
|
138
|
+
{@render children?.()}
|
|
139
|
+
</div>
|
|
140
|
+
{/if}
|
|
141
|
+
{/snippet}
|
|
142
|
+
|
|
143
|
+
{#snippet DrawerHeader({ class: className = '', children, ...props }: ShadcnDrawerHeaderProps = {})}
|
|
144
|
+
<div
|
|
145
|
+
data-slot="drawer-header"
|
|
146
|
+
class={cn('flex flex-col gap-1.5 p-4 text-center md:text-left', className)}
|
|
147
|
+
{...props}
|
|
148
|
+
>
|
|
149
|
+
{@render children?.()}
|
|
150
|
+
</div>
|
|
151
|
+
{/snippet}
|
|
152
|
+
|
|
153
|
+
{#snippet DrawerTitle({ class: className = '', children, ...props }: ShadcnDrawerTitleProps = {})}
|
|
154
|
+
<h2
|
|
155
|
+
data-slot="drawer-title"
|
|
156
|
+
class={cn('text-base font-semibold leading-none tracking-tight text-foreground', className)}
|
|
157
|
+
{...props}
|
|
158
|
+
>
|
|
159
|
+
{@render children?.()}
|
|
160
|
+
</h2>
|
|
161
|
+
{/snippet}
|
|
162
|
+
|
|
163
|
+
{#snippet DrawerDescription({
|
|
164
|
+
class: className = '',
|
|
165
|
+
children,
|
|
166
|
+
...props
|
|
167
|
+
}: ShadcnDrawerDescriptionProps = {})}
|
|
168
|
+
<p
|
|
169
|
+
data-slot="drawer-description"
|
|
170
|
+
class={cn('text-sm text-muted-foreground', className)}
|
|
171
|
+
{...props}
|
|
172
|
+
>
|
|
173
|
+
{@render children?.()}
|
|
174
|
+
</p>
|
|
175
|
+
{/snippet}
|
|
176
|
+
|
|
177
|
+
{#snippet DrawerFooter({ class: className = '', children, ...props }: ShadcnDrawerFooterProps = {})}
|
|
178
|
+
<div
|
|
179
|
+
data-slot="drawer-footer"
|
|
180
|
+
class={cn('mt-auto flex flex-col gap-2 p-4', className)}
|
|
181
|
+
{...props}
|
|
182
|
+
>
|
|
183
|
+
{@render children?.()}
|
|
184
|
+
</div>
|
|
185
|
+
{/snippet}
|
|
186
|
+
|
|
187
|
+
{#snippet DrawerClose({
|
|
188
|
+
class: className = '',
|
|
189
|
+
children,
|
|
190
|
+
onclick,
|
|
191
|
+
...props
|
|
192
|
+
}: ShadcnDrawerCloseProps = {})}
|
|
193
|
+
<button
|
|
194
|
+
type="button"
|
|
195
|
+
data-slot="drawer-close"
|
|
196
|
+
class={cn('inline-flex items-center justify-center', className)}
|
|
197
|
+
onclick={(e) => {
|
|
198
|
+
onclick?.(e);
|
|
199
|
+
setOpen(false);
|
|
200
|
+
}}
|
|
201
|
+
{...props}
|
|
202
|
+
>
|
|
203
|
+
{@render children?.()}
|
|
204
|
+
</button>
|
|
205
|
+
{/snippet}
|
|
206
|
+
|
|
207
|
+
<div data-slot="drawer-root" data-state={open ? 'open' : 'closed'}>
|
|
208
|
+
{@render children?.()}
|
|
209
|
+
</div>
|