@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,239 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { cn, cva, type VariantProps } from '@surreal-ui/core';
|
|
3
|
+
|
|
4
|
+
import type { Snippet } from 'svelte';
|
|
5
|
+
import type {
|
|
6
|
+
HTMLAttributes,
|
|
7
|
+
HTMLLabelAttributes,
|
|
8
|
+
HTMLFieldsetAttributes,
|
|
9
|
+
} from 'svelte/elements';
|
|
10
|
+
|
|
11
|
+
export const shadcnFieldVariants = cva(
|
|
12
|
+
'gap-2 data-[invalid=true]:text-destructive group/field flex w-full',
|
|
13
|
+
{
|
|
14
|
+
variants: {
|
|
15
|
+
orientation: {
|
|
16
|
+
vertical: 'cn-field-orientation-vertical flex-col [&>*]:w-full [&>.sr-only]:w-auto',
|
|
17
|
+
horizontal:
|
|
18
|
+
'cn-field-orientation-horizontal flex-row items-center has-[>[data-slot=field-content]]:items-start [&>[data-slot=field-label]]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
|
19
|
+
responsive:
|
|
20
|
+
'cn-field-orientation-responsive flex-col @md/field-group:flex-row @md/field-group:items-center @md/field-group:has-[>[data-slot=field-content]]:items-start [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto @md/field-group:[&>[data-slot=field-label]]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
orientation: 'vertical',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export type ShadcnFieldOrientation = VariantProps<typeof shadcnFieldVariants>['orientation'];
|
|
30
|
+
|
|
31
|
+
export interface ShadcnFieldProps extends HTMLAttributes<HTMLDivElement> {
|
|
32
|
+
orientation?: FieldOrientation;
|
|
33
|
+
invalid?: boolean;
|
|
34
|
+
ref?: HTMLDivElement | null;
|
|
35
|
+
children?: Snippet;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ShadcnFieldContentProps extends HTMLAttributes<HTMLDivElement> {
|
|
39
|
+
children?: Snippet;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ShadcnFieldDescriptionProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
43
|
+
children?: Snippet;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface FieldErrorProps extends HTMLAttributes<HTMLDivElement> {
|
|
47
|
+
errors?: { message?: string }[];
|
|
48
|
+
children?: Snippet;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ShadcnFieldGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
52
|
+
children?: Snippet;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ShadcnFieldLabelProps extends HTMLLabelAttributes {
|
|
56
|
+
children?: Snippet;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface FieldLegendProps extends HTMLAttributes<HTMLLegendElement> {
|
|
60
|
+
variant?: 'legend' | 'label';
|
|
61
|
+
children?: Snippet;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ShadcnFieldSeparatorProps extends HTMLAttributes<HTMLDivElement> {
|
|
65
|
+
children?: Snippet;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface FieldSetProps extends HTMLFieldsetAttributes {
|
|
69
|
+
children?: Snippet;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ShadcnFieldTitleProps extends HTMLAttributes<HTMLDivElement> {
|
|
73
|
+
children?: Snippet;
|
|
74
|
+
}
|
|
75
|
+
</script>
|
|
76
|
+
|
|
77
|
+
<script lang="ts">
|
|
78
|
+
let {
|
|
79
|
+
ref = $bindable(null),
|
|
80
|
+
class: className = '',
|
|
81
|
+
orientation = 'vertical',
|
|
82
|
+
invalid = false,
|
|
83
|
+
children,
|
|
84
|
+
...restProps
|
|
85
|
+
}: ShadcnFieldProps = $props();
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
{#snippet Content({ class: contentClass = '', children: contentChildren, ...contentProps })}
|
|
89
|
+
<div
|
|
90
|
+
data-slot="field-content"
|
|
91
|
+
class={cn('gap-0.5 group/field-content flex flex-1 flex-col leading-snug', contentClass)}
|
|
92
|
+
{...contentProps}
|
|
93
|
+
>
|
|
94
|
+
{@render contentChildren?.()}
|
|
95
|
+
</div>
|
|
96
|
+
{/snippet}
|
|
97
|
+
|
|
98
|
+
{#snippet Description({ class: descClass = '', children: descChildren, ...descProps })}
|
|
99
|
+
<p
|
|
100
|
+
data-slot="field-description"
|
|
101
|
+
class={cn(
|
|
102
|
+
'text-left text-sm text-muted-foreground [[data-variant=legend]+&]:-mt-1.5 leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance last:mt-0 nth-last-2:-mt-1 [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',
|
|
103
|
+
descClass,
|
|
104
|
+
)}
|
|
105
|
+
{...descProps}
|
|
106
|
+
>
|
|
107
|
+
{@render descChildren?.()}
|
|
108
|
+
</p>
|
|
109
|
+
{/snippet}
|
|
110
|
+
|
|
111
|
+
{#snippet Error({ class: errorClass = '', errors, children: errorChildren, ...errorProps })}
|
|
112
|
+
{#if errorChildren || (errors && errors.length > 0 && (errors.length > 1 || errors[0]?.message))}
|
|
113
|
+
<div
|
|
114
|
+
role="alert"
|
|
115
|
+
data-slot="field-error"
|
|
116
|
+
class={cn('text-sm text-destructive font-normal', errorClass)}
|
|
117
|
+
{...errorProps}
|
|
118
|
+
>
|
|
119
|
+
{#if errorChildren}
|
|
120
|
+
{@render errorChildren()}
|
|
121
|
+
{:else if errors && errors.length === 1 && errors[0]?.message}
|
|
122
|
+
{errors[0].message}
|
|
123
|
+
{:else if errors && errors.length > 1}
|
|
124
|
+
<ul class="ml-4 flex list-disc flex-col gap-1">
|
|
125
|
+
{#each errors as error, index (index)}
|
|
126
|
+
{#if error?.message}
|
|
127
|
+
<li>{error.message}</li>
|
|
128
|
+
{/if}
|
|
129
|
+
{/each}
|
|
130
|
+
</ul>
|
|
131
|
+
{/if}
|
|
132
|
+
</div>
|
|
133
|
+
{/if}
|
|
134
|
+
{/snippet}
|
|
135
|
+
|
|
136
|
+
{#snippet Group({ class: groupClass = '', children: groupChildren, ...groupProps })}
|
|
137
|
+
<div
|
|
138
|
+
data-slot="field-group"
|
|
139
|
+
class={cn(
|
|
140
|
+
'gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4 group/field-group @container/field-group flex w-full flex-col',
|
|
141
|
+
groupClass,
|
|
142
|
+
)}
|
|
143
|
+
{...groupProps}
|
|
144
|
+
>
|
|
145
|
+
{@render groupChildren?.()}
|
|
146
|
+
</div>
|
|
147
|
+
{/snippet}
|
|
148
|
+
|
|
149
|
+
{#snippet Label({ class: labelClass = '', children: labelChildren, ...labelProps })}
|
|
150
|
+
<label
|
|
151
|
+
data-slot="field-label"
|
|
152
|
+
class={cn(
|
|
153
|
+
'gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10 group/field-label peer/field-label flex w-fit cursor-pointer text-sm font-medium text-foreground has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col',
|
|
154
|
+
labelClass,
|
|
155
|
+
)}
|
|
156
|
+
{...labelProps}
|
|
157
|
+
>
|
|
158
|
+
{@render labelChildren?.()}
|
|
159
|
+
</label>
|
|
160
|
+
{/snippet}
|
|
161
|
+
|
|
162
|
+
{#snippet Legend({
|
|
163
|
+
class: legendClass = '',
|
|
164
|
+
variant = 'legend',
|
|
165
|
+
children: legendChildren,
|
|
166
|
+
...legendProps
|
|
167
|
+
})}
|
|
168
|
+
<legend
|
|
169
|
+
data-slot="field-legend"
|
|
170
|
+
data-variant={variant}
|
|
171
|
+
class={cn(
|
|
172
|
+
'mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base text-foreground',
|
|
173
|
+
legendClass,
|
|
174
|
+
)}
|
|
175
|
+
{...legendProps}
|
|
176
|
+
>
|
|
177
|
+
{@render legendChildren?.()}
|
|
178
|
+
</legend>
|
|
179
|
+
{/snippet}
|
|
180
|
+
|
|
181
|
+
{#snippet Separator({ class: separatorClass = '', children: separatorChildren, ...separatorProps })}
|
|
182
|
+
<div
|
|
183
|
+
data-slot="field-separator"
|
|
184
|
+
data-content={!!separatorChildren}
|
|
185
|
+
class={cn(
|
|
186
|
+
'-my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2 relative flex items-center justify-center',
|
|
187
|
+
separatorClass,
|
|
188
|
+
)}
|
|
189
|
+
{...separatorProps}
|
|
190
|
+
>
|
|
191
|
+
<div class="absolute inset-0 top-1/2 -translate-y-1/2 border-t border-border w-full" />
|
|
192
|
+
{#if separatorChildren}
|
|
193
|
+
<span
|
|
194
|
+
class="px-2 text-muted-foreground relative bg-background text-xs uppercase tracking-wider"
|
|
195
|
+
data-slot="field-separator-content"
|
|
196
|
+
>
|
|
197
|
+
{@render separatorChildren()}
|
|
198
|
+
</span>
|
|
199
|
+
{/if}
|
|
200
|
+
</div>
|
|
201
|
+
{/snippet}
|
|
202
|
+
|
|
203
|
+
{#snippet Set({ class: setClass = '', children: setChildren, ...setProps })}
|
|
204
|
+
<fieldset
|
|
205
|
+
data-slot="field-set"
|
|
206
|
+
class={cn(
|
|
207
|
+
'gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3 flex flex-col border-0 p-0 m-0',
|
|
208
|
+
setClass,
|
|
209
|
+
)}
|
|
210
|
+
{...setProps}
|
|
211
|
+
>
|
|
212
|
+
{@render setChildren?.()}
|
|
213
|
+
</fieldset>
|
|
214
|
+
{/snippet}
|
|
215
|
+
|
|
216
|
+
{#snippet Title({ class: titleClass = '', children: titleChildren, ...titleProps })}
|
|
217
|
+
<div
|
|
218
|
+
data-slot="field-label"
|
|
219
|
+
class={cn(
|
|
220
|
+
'gap-2 text-sm leading-snug font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center text-foreground',
|
|
221
|
+
titleClass,
|
|
222
|
+
)}
|
|
223
|
+
{...titleProps}
|
|
224
|
+
>
|
|
225
|
+
{@render titleChildren?.()}
|
|
226
|
+
</div>
|
|
227
|
+
{/snippet}
|
|
228
|
+
|
|
229
|
+
<div
|
|
230
|
+
bind:this={ref}
|
|
231
|
+
role="group"
|
|
232
|
+
data-slot="field"
|
|
233
|
+
data-orientation={orientation}
|
|
234
|
+
data-invalid={invalid ? 'true' : undefined}
|
|
235
|
+
class={cn(shadcnFieldVariants({ orientation }), className)}
|
|
236
|
+
{...restProps}
|
|
237
|
+
>
|
|
238
|
+
{@render children?.()}
|
|
239
|
+
</div>
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { cn } from '@surreal-ui/core';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import type {
|
|
5
|
+
HTMLAttributes,
|
|
6
|
+
HTMLButtonAttributes,
|
|
7
|
+
HTMLLabelAttributes,
|
|
8
|
+
HTMLFieldSetAttributes,
|
|
9
|
+
} from 'svelte/elements';
|
|
10
|
+
|
|
11
|
+
export interface ShadcnFormItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
12
|
+
class?: string;
|
|
13
|
+
children?: Snippet;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ShadcnFormLabelProps extends HTMLLabelAttributes {
|
|
17
|
+
class?: string;
|
|
18
|
+
error?: boolean;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ShadcnFormDescriptionProps extends HTMLAttributes<HTMLParagraphElement> {
|
|
23
|
+
class?: string;
|
|
24
|
+
children?: Snippet;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface FormFieldErrorsProps extends HTMLAttributes<HTMLDivElement> {
|
|
28
|
+
class?: string;
|
|
29
|
+
errors?: string[];
|
|
30
|
+
errorClasses?: string;
|
|
31
|
+
children?: Snippet<[{ errors: string[] }]>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface FormFieldsetProps extends HTMLFieldSetAttributes {
|
|
35
|
+
class?: string;
|
|
36
|
+
children?: Snippet;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface FormLegendProps extends HTMLAttributes<HTMLLegendElement> {
|
|
40
|
+
class?: string;
|
|
41
|
+
error?: boolean;
|
|
42
|
+
children?: Snippet;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ShadcnFormButtonProps extends HTMLButtonAttributes {
|
|
46
|
+
class?: string;
|
|
47
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
48
|
+
children?: Snippet;
|
|
49
|
+
}
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<script lang="ts">
|
|
53
|
+
let { class: className = '', children, ...props }: HTMLAttributes<HTMLFormElement> = $props();
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
{#snippet Item({ class: className = '', children, ...props }: ShadcnFormItemProps = {})}
|
|
57
|
+
<div data-slot="form-item" class={cn('space-y-2', className)} {...props}>
|
|
58
|
+
{@render children?.()}
|
|
59
|
+
</div>
|
|
60
|
+
{/snippet}
|
|
61
|
+
|
|
62
|
+
{#snippet Label({ class: className = '', error = false, children, ...props }: ShadcnFormLabelProps = {})}
|
|
63
|
+
<label
|
|
64
|
+
data-slot="form-label"
|
|
65
|
+
data-error={error ? '' : undefined}
|
|
66
|
+
class={cn(
|
|
67
|
+
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 data-[error]:text-destructive',
|
|
68
|
+
className,
|
|
69
|
+
)}
|
|
70
|
+
{...props}
|
|
71
|
+
>
|
|
72
|
+
{@render children?.()}
|
|
73
|
+
</label>
|
|
74
|
+
{/snippet}
|
|
75
|
+
|
|
76
|
+
{#snippet Description({ class: className = '', children, ...props }: ShadcnFormDescriptionProps = {})}
|
|
77
|
+
<p data-slot="form-description" class={cn('text-sm text-muted-foreground', className)} {...props}>
|
|
78
|
+
{@render children?.()}
|
|
79
|
+
</p>
|
|
80
|
+
{/snippet}
|
|
81
|
+
|
|
82
|
+
{#snippet FieldErrors({
|
|
83
|
+
class: className = '',
|
|
84
|
+
errors = [],
|
|
85
|
+
errorClasses = '',
|
|
86
|
+
children,
|
|
87
|
+
...props
|
|
88
|
+
}: FormFieldErrorsProps = {})}
|
|
89
|
+
{#if errors.length > 0 || children}
|
|
90
|
+
<div
|
|
91
|
+
data-slot="form-message"
|
|
92
|
+
class={cn('text-sm font-medium text-destructive', className)}
|
|
93
|
+
{...props}
|
|
94
|
+
>
|
|
95
|
+
{#if children}
|
|
96
|
+
{@render children({ errors })}
|
|
97
|
+
{:else}
|
|
98
|
+
{#each errors as error}
|
|
99
|
+
<div class={cn(errorClasses)}>{error}</div>
|
|
100
|
+
{/each}
|
|
101
|
+
{/if}
|
|
102
|
+
</div>
|
|
103
|
+
{/if}
|
|
104
|
+
{/snippet}
|
|
105
|
+
|
|
106
|
+
{#snippet Fieldset({ class: className = '', children, ...props }: FormFieldsetProps = {})}
|
|
107
|
+
<fieldset class={cn('space-y-2', className)} {...props}>
|
|
108
|
+
{@render children?.()}
|
|
109
|
+
</fieldset>
|
|
110
|
+
{/snippet}
|
|
111
|
+
|
|
112
|
+
{#snippet Legend({
|
|
113
|
+
class: className = '',
|
|
114
|
+
error = false,
|
|
115
|
+
children,
|
|
116
|
+
...props
|
|
117
|
+
}: FormLegendProps = {})}
|
|
118
|
+
<legend
|
|
119
|
+
data-slot="form-legend"
|
|
120
|
+
data-error={error ? '' : undefined}
|
|
121
|
+
class={cn('text-sm leading-none font-medium data-[error]:text-destructive', className)}
|
|
122
|
+
{...props}
|
|
123
|
+
>
|
|
124
|
+
{@render children?.()}
|
|
125
|
+
</legend>
|
|
126
|
+
{/snippet}
|
|
127
|
+
|
|
128
|
+
{#snippet Button({
|
|
129
|
+
class: className = '',
|
|
130
|
+
type = 'submit',
|
|
131
|
+
variant = 'default',
|
|
132
|
+
children,
|
|
133
|
+
...props
|
|
134
|
+
}: ShadcnFormButtonProps = {})}
|
|
135
|
+
<button
|
|
136
|
+
{type}
|
|
137
|
+
class={cn(
|
|
138
|
+
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 h-9 px-4 py-2 shadow',
|
|
139
|
+
variant === 'default' && 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
140
|
+
variant === 'destructive' &&
|
|
141
|
+
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
|
|
142
|
+
variant === 'outline' &&
|
|
143
|
+
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
144
|
+
variant === 'secondary' && 'bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
145
|
+
variant === 'ghost' && 'hover:bg-accent hover:text-accent-foreground',
|
|
146
|
+
variant === 'link' && 'text-primary underline-offset-4 hover:underline',
|
|
147
|
+
className,
|
|
148
|
+
)}
|
|
149
|
+
{...props}
|
|
150
|
+
>
|
|
151
|
+
{@render children?.()}
|
|
152
|
+
</button>
|
|
153
|
+
{/snippet}
|
|
154
|
+
|
|
155
|
+
<form class={cn('space-y-6', className)} {...props}>
|
|
156
|
+
{@render children?.()}
|
|
157
|
+
</form>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { cn } from '@surreal-ui/core';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
import { LinkPreview as HoverCardPrimitive } from 'bits-ui';
|
|
6
|
+
|
|
7
|
+
export interface ShadcnHoverCardRootProps extends HoverCardPrimitive.RootProps {
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ShadcnHoverCardTriggerProps extends HoverCardPrimitive.TriggerProps {
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ShadcnHoverCardPortalProps extends HoverCardPrimitive.PortalProps {
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ShadcnHoverCardContentProps extends HoverCardPrimitive.ContentProps {
|
|
20
|
+
portalProps?: HoverCardPrimitive.PortalProps;
|
|
21
|
+
children?: Snippet;
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<script lang="ts">
|
|
26
|
+
let { open = $bindable(false), children, ...restProps }: ShadcnHoverCardRootProps = $props();
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
{#snippet Trigger({
|
|
30
|
+
class: className,
|
|
31
|
+
children: triggerChildren,
|
|
32
|
+
...props
|
|
33
|
+
}: ShadcnHoverCardTriggerProps = {})}
|
|
34
|
+
<HoverCardPrimitive.Trigger data-slot="hover-card-trigger" class={className} {...props}>
|
|
35
|
+
{@render triggerChildren?.()}
|
|
36
|
+
</HoverCardPrimitive.Trigger>
|
|
37
|
+
{/snippet}
|
|
38
|
+
|
|
39
|
+
{#snippet Portal({ children: portalChildren, ...props }: ShadcnHoverCardPortalProps = {})}
|
|
40
|
+
<HoverCardPrimitive.Portal {...props}>
|
|
41
|
+
{@render portalChildren?.()}
|
|
42
|
+
</HoverCardPrimitive.Portal>
|
|
43
|
+
{/snippet}
|
|
44
|
+
|
|
45
|
+
{#snippet Content({
|
|
46
|
+
class: className,
|
|
47
|
+
align = 'center',
|
|
48
|
+
sideOffset = 4,
|
|
49
|
+
portalProps,
|
|
50
|
+
children: contentChildren,
|
|
51
|
+
...props
|
|
52
|
+
}: ShadcnHoverCardContentProps = {})}
|
|
53
|
+
<HoverCardPrimitive.Portal {...portalProps}>
|
|
54
|
+
<HoverCardPrimitive.Content
|
|
55
|
+
data-slot="hover-card-content"
|
|
56
|
+
{align}
|
|
57
|
+
{sideOffset}
|
|
58
|
+
class={cn(
|
|
59
|
+
'z-50 w-64 rounded-lg bg-popover p-2.5 text-sm 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 origin-(--transform-origin) outline-hidden',
|
|
60
|
+
className,
|
|
61
|
+
)}
|
|
62
|
+
{...props}
|
|
63
|
+
>
|
|
64
|
+
{@render contentChildren?.()}
|
|
65
|
+
</HoverCardPrimitive.Content>
|
|
66
|
+
</HoverCardPrimitive.Portal>
|
|
67
|
+
{/snippet}
|
|
68
|
+
|
|
69
|
+
<HoverCardPrimitive.Root bind:open {...restProps}>
|
|
70
|
+
{@render children?.()}
|
|
71
|
+
</HoverCardPrimitive.Root>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '@surreal-ui/core';
|
|
3
|
+
|
|
4
|
+
import type { HTMLInputAttributes, HTMLInputTypeAttribute } from 'svelte/elements';
|
|
5
|
+
|
|
6
|
+
type InputType = Exclude<HTMLInputTypeAttribute, 'file'>;
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
ref?: HTMLInputElement | null;
|
|
10
|
+
value?: string | number | readonly string[] | undefined;
|
|
11
|
+
files?: FileList;
|
|
12
|
+
type?: HTMLInputTypeAttribute;
|
|
13
|
+
class?: string;
|
|
14
|
+
'data-slot'?: string;
|
|
15
|
+
} & Omit<HTMLInputAttributes, 'type' | 'value' | 'files'>;
|
|
16
|
+
|
|
17
|
+
let {
|
|
18
|
+
ref = $bindable(null),
|
|
19
|
+
value = $bindable(),
|
|
20
|
+
type,
|
|
21
|
+
files = $bindable(),
|
|
22
|
+
class: className,
|
|
23
|
+
'data-slot': dataSlot = 'input',
|
|
24
|
+
...restProps
|
|
25
|
+
}: Props = $props();
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
{#if type === 'file'}
|
|
29
|
+
<input
|
|
30
|
+
bind:this={ref}
|
|
31
|
+
data-slot={dataSlot}
|
|
32
|
+
class={cn(
|
|
33
|
+
'h-8 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
|
|
34
|
+
className,
|
|
35
|
+
)}
|
|
36
|
+
type="file"
|
|
37
|
+
bind:files
|
|
38
|
+
bind:value
|
|
39
|
+
{...restProps}
|
|
40
|
+
/>
|
|
41
|
+
{:else}
|
|
42
|
+
<input
|
|
43
|
+
bind:this={ref}
|
|
44
|
+
data-slot={dataSlot}
|
|
45
|
+
class={cn(
|
|
46
|
+
'h-8 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors file:h-6 file:text-sm file:font-medium focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:bg-input/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 w-full min-w-0 outline-none file:inline-flex file:border-0 file:bg-transparent file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
|
|
47
|
+
className,
|
|
48
|
+
)}
|
|
49
|
+
{type}
|
|
50
|
+
bind:value
|
|
51
|
+
{...restProps}
|
|
52
|
+
/>
|
|
53
|
+
{/if}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import { cn, cva, type VariantProps } from '@surreal-ui/core';
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
HTMLAttributes,
|
|
6
|
+
HTMLInputAttributes,
|
|
7
|
+
HTMLTextareaAttributes,
|
|
8
|
+
HTMLButtonAttributes,
|
|
9
|
+
} from 'svelte/elements';
|
|
10
|
+
import type { Snippet } from 'svelte';
|
|
11
|
+
|
|
12
|
+
export const inputGroupAddonVariants = cva(
|
|
13
|
+
"h-auto gap-2 py-1.5 text-sm font-medium text-muted-foreground group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4 flex cursor-text items-center justify-center select-none",
|
|
14
|
+
{
|
|
15
|
+
variants: {
|
|
16
|
+
align: {
|
|
17
|
+
'inline-start': 'pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem] order-first',
|
|
18
|
+
'inline-end': 'pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem] order-last',
|
|
19
|
+
'block-start':
|
|
20
|
+
'px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2 order-first w-full justify-start',
|
|
21
|
+
'block-end':
|
|
22
|
+
'px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2 order-last w-full justify-start',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
align: 'inline-start',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const inputGroupButtonVariants = cva(
|
|
32
|
+
'gap-2 text-sm flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 shadow-none hover:bg-accent hover:text-accent-foreground',
|
|
33
|
+
{
|
|
34
|
+
variants: {
|
|
35
|
+
size: {
|
|
36
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",
|
|
37
|
+
sm: 'h-7 gap-1.5 rounded-md px-2 text-xs',
|
|
38
|
+
'icon-xs': 'size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0',
|
|
39
|
+
'icon-sm': 'size-8 p-0 has-[>svg]:p-0',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
defaultVariants: {
|
|
43
|
+
size: 'xs',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export type InputGroupAddonAlign = VariantProps<typeof inputGroupAddonVariants>['align'];
|
|
49
|
+
export type InputGroupButtonSize = VariantProps<typeof inputGroupButtonVariants>['size'];
|
|
50
|
+
|
|
51
|
+
export interface ShadcnInputGroupProps extends HTMLAttributes<HTMLDivElement> {
|
|
52
|
+
ref?: HTMLDivElement | null;
|
|
53
|
+
children?: Snippet;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface InputGroupAddonProps extends HTMLAttributes<HTMLDivElement> {
|
|
57
|
+
ref?: HTMLDivElement | null;
|
|
58
|
+
align?: InputGroupAddonAlign;
|
|
59
|
+
children?: Snippet;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ShadcnInputGroupButtonProps extends HTMLButtonAttributes {
|
|
63
|
+
ref?: HTMLButtonElement | null;
|
|
64
|
+
size?: InputGroupButtonSize;
|
|
65
|
+
children?: Snippet;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface ShadcnInputGroupInputProps extends HTMLInputAttributes {
|
|
69
|
+
ref?: HTMLInputElement | null;
|
|
70
|
+
value?: string | number | null;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ShadcnInputGroupTextProps extends HTMLAttributes<HTMLSpanElement> {
|
|
74
|
+
ref?: HTMLSpanElement | null;
|
|
75
|
+
children?: Snippet;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface InputGroupTextareaProps extends HTMLTextareaAttributes {
|
|
79
|
+
ref?: HTMLTextAreaElement | null;
|
|
80
|
+
value?: string | null;
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<script lang="ts">
|
|
85
|
+
let { ref = $bindable(null), class: className, children, ...props }: ShadcnInputGroupProps = $props();
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
{#snippet Addon({ class: className = '', align = 'inline-start', children, ...addonProps })}
|
|
89
|
+
<div
|
|
90
|
+
role="group"
|
|
91
|
+
data-slot="input-group-addon"
|
|
92
|
+
data-align={align}
|
|
93
|
+
class={cn(inputGroupAddonVariants({ align }), className)}
|
|
94
|
+
onclick={(e) => {
|
|
95
|
+
if (e.target.closest('button')) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
e.currentTarget.parentElement?.querySelector('input, textarea')?.focus();
|
|
99
|
+
}}
|
|
100
|
+
{...addonProps}
|
|
101
|
+
>
|
|
102
|
+
{@render children?.()}
|
|
103
|
+
</div>
|
|
104
|
+
{/snippet}
|
|
105
|
+
|
|
106
|
+
{#snippet Button({ class: className = '', size = 'xs', type = 'button', children, ...buttonProps })}
|
|
107
|
+
<button
|
|
108
|
+
{type}
|
|
109
|
+
data-size={size}
|
|
110
|
+
class={cn(inputGroupButtonVariants({ size }), className)}
|
|
111
|
+
{...buttonProps}
|
|
112
|
+
>
|
|
113
|
+
{@render children?.()}
|
|
114
|
+
</button>
|
|
115
|
+
{/snippet}
|
|
116
|
+
|
|
117
|
+
{#snippet Input({ class: className = '', type = 'text', value, ...inputProps })}
|
|
118
|
+
<input
|
|
119
|
+
{type}
|
|
120
|
+
data-slot="input-group-control"
|
|
121
|
+
{value}
|
|
122
|
+
class={cn(
|
|
123
|
+
'flex-1 rounded-none border-0 bg-transparent px-2.5 py-1 text-sm shadow-none ring-0 outline-none placeholder:text-muted-foreground focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent',
|
|
124
|
+
className,
|
|
125
|
+
)}
|
|
126
|
+
{...inputProps}
|
|
127
|
+
/>
|
|
128
|
+
{/snippet}
|
|
129
|
+
|
|
130
|
+
{#snippet Text({ class: className = '', children, ...textProps })}
|
|
131
|
+
<span
|
|
132
|
+
class={cn(
|
|
133
|
+
"gap-2 text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 flex items-center [&_svg]:pointer-events-none",
|
|
134
|
+
className,
|
|
135
|
+
)}
|
|
136
|
+
{...textProps}
|
|
137
|
+
>
|
|
138
|
+
{@render children?.()}
|
|
139
|
+
</span>
|
|
140
|
+
{/snippet}
|
|
141
|
+
|
|
142
|
+
{#snippet Textarea({ class: className = '', value, ...textareaProps })}
|
|
143
|
+
<textarea
|
|
144
|
+
data-slot="input-group-control"
|
|
145
|
+
{value}
|
|
146
|
+
class={cn(
|
|
147
|
+
'flex-1 resize-none rounded-none border-0 bg-transparent px-2.5 py-2 text-sm shadow-none ring-0 outline-none placeholder:text-muted-foreground focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent',
|
|
148
|
+
className,
|
|
149
|
+
)}
|
|
150
|
+
{...textareaProps}
|
|
151
|
+
></textarea>
|
|
152
|
+
{/snippet}
|
|
153
|
+
|
|
154
|
+
<div
|
|
155
|
+
bind:this={ref}
|
|
156
|
+
data-slot="input-group"
|
|
157
|
+
role="group"
|
|
158
|
+
class={cn(
|
|
159
|
+
'group/input-group h-8 rounded-lg border border-input transition-colors in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5 relative flex w-full min-w-0 items-center outline-none has-[>textarea]:h-auto',
|
|
160
|
+
className,
|
|
161
|
+
)}
|
|
162
|
+
{...props}
|
|
163
|
+
>
|
|
164
|
+
{@render children?.()}
|
|
165
|
+
</div>
|