-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rearrange shadcn-svelte to own components.
- Loading branch information
Showing
19 changed files
with
310 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
apps/svelte-gravity-forms/src/lib/components/description/description.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<script lang="ts"> | ||
import { Form as FormPrimitive } from 'formsnap'; | ||
import { cn } from '$lib/utils.js'; | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
type $$Props = HTMLAttributes<HTMLSpanElement>; | ||
let className: string | undefined | null = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<FormPrimitive.Description class={cn('text-muted-foreground text-sm', className)} {...$$restProps}> | ||
<slot /> | ||
</FormPrimitive.Description> |
7 changes: 7 additions & 0 deletions
7
apps/svelte-gravity-forms/src/lib/components/description/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Root from './description.svelte'; | ||
|
||
export { | ||
Root, | ||
// | ||
Root as Description | ||
}; |
89 changes: 0 additions & 89 deletions
89
apps/svelte-gravity-forms/src/lib/components/form/form.svelte
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,66 @@ | ||
export { default as Form } from './form.svelte'; | ||
import { Form as FormPrimitive, getFormField } from 'formsnap'; | ||
import * as RadioGroupComp from '$lib/components/ui/radio-group/index.js'; | ||
import * as SelectComp from '$lib/components/ui/select/index.js'; | ||
import type { Writable } from 'svelte/store'; | ||
import { Item } from '$components/item/index.js'; | ||
import { Input } from '$components/input/index.js'; | ||
import { Description } from '$components/description/index.js'; | ||
import { Label } from '$components/label/index.js'; | ||
import { Validation } from '$components/validation/index.js'; | ||
|
||
import { Button } from '$components/button/index.js'; | ||
|
||
const Root = FormPrimitive.Root; | ||
const Field = FormPrimitive.Field; | ||
const Control = FormPrimitive.Control; | ||
const RadioItem = RadioGroupComp.Item; | ||
const NativeRadio = FormPrimitive.Radio; | ||
const SelectContent = SelectComp.Content; | ||
const SelectLabel = SelectComp.Label; | ||
const SelectGroup = SelectComp.Group; | ||
const SelectItem = SelectComp.Item; | ||
const SelectSeparator = SelectComp.Separator; | ||
|
||
export type TextareaGetFormField = Omit<ReturnType<typeof getFormField>, 'value'> & { | ||
value: Writable<string>; | ||
}; | ||
|
||
export type Props = { | ||
formId?: number; | ||
}; | ||
|
||
export { | ||
Root, | ||
Field, | ||
Control, | ||
Item, | ||
Input, | ||
Label, | ||
Button, | ||
Validation, | ||
RadioItem, | ||
Description, | ||
SelectContent, | ||
SelectLabel, | ||
SelectGroup, | ||
SelectItem, | ||
SelectSeparator, | ||
NativeRadio, | ||
// | ||
Root as Form, | ||
Field as FormField, | ||
Control as FormControl, | ||
Item as FormItem, | ||
Input as FormInput, | ||
Description as FormDescription, | ||
Label as FormLabel, | ||
Validation as FormValidation, | ||
NativeRadio as FormNativeRadio, | ||
RadioItem as FormRadioItem, | ||
SelectContent as FormSelectContent, | ||
SelectLabel as FormSelectLabel, | ||
SelectGroup as FormSelectGroup, | ||
SelectItem as FormSelectItem, | ||
SelectSeparator as FormSelectSeparator, | ||
Button as FormButton | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { default as GFForm } from './form/form.svelte'; | ||
import { default as GFButton } from './button/button.svelte'; | ||
|
||
export { GFForm, GFButton }; |
25 changes: 25 additions & 0 deletions
25
apps/svelte-gravity-forms/src/lib/components/input/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Root from './input.svelte'; | ||
|
||
type FormInputEvent<T extends Event = Event> = T & { | ||
currentTarget: EventTarget & HTMLInputElement; | ||
}; | ||
export type InputEvents = { | ||
blur: FormInputEvent<FocusEvent>; | ||
change: FormInputEvent<Event>; | ||
click: FormInputEvent<MouseEvent>; | ||
focus: FormInputEvent<FocusEvent>; | ||
keydown: FormInputEvent<KeyboardEvent>; | ||
keypress: FormInputEvent<KeyboardEvent>; | ||
keyup: FormInputEvent<KeyboardEvent>; | ||
mouseover: FormInputEvent<MouseEvent>; | ||
mouseenter: FormInputEvent<MouseEvent>; | ||
mouseleave: FormInputEvent<MouseEvent>; | ||
paste: FormInputEvent<ClipboardEvent>; | ||
input: FormInputEvent<InputEvent>; | ||
}; | ||
|
||
export { | ||
Root, | ||
// | ||
Root as Input | ||
}; |
36 changes: 36 additions & 0 deletions
36
apps/svelte-gravity-forms/src/lib/components/input/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
import { getFormField } from 'formsnap'; | ||
import type { HTMLInputAttributes } from 'svelte/elements'; | ||
import { cn } from '$lib/utils.js'; | ||
import type { InputEvents } from './index.js'; | ||
type $$Props = HTMLInputAttributes; | ||
type $$Events = InputEvents; | ||
/* const { attrStore, value } = getFormField(); */ | ||
const { attrStore, value } = getFormField(); | ||
let className: $$Props['class'] = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<input | ||
class={cn( | ||
'border-input ring-offset-background file:text-foreground placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border bg-transparent px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', | ||
className | ||
)} | ||
{...$attrStore} | ||
bind:value={$value} | ||
{...$$restProps} | ||
on:blur | ||
on:change | ||
on:click | ||
on:focus | ||
on:keydown | ||
on:keypress | ||
on:keyup | ||
on:mouseover | ||
on:mouseenter | ||
on:mouseleave | ||
on:paste | ||
on:input | ||
/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Root from './item.svelte'; | ||
|
||
export { | ||
Root, | ||
// | ||
Root as Item | ||
}; |
12 changes: 12 additions & 0 deletions
12
apps/svelte-gravity-forms/src/lib/components/item/item.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script lang="ts"> | ||
import { cn } from '$lib/utils.js'; | ||
import type { HTMLAttributes } from 'svelte/elements'; | ||
type $$Props = HTMLAttributes<HTMLDivElement>; | ||
let className: string | undefined | null = undefined; | ||
export { className as class }; | ||
</script> | ||
|
||
<div class={cn('space-y-2', className)} {...$$restProps}> | ||
<slot /> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Root from './label.svelte'; | ||
|
||
export { | ||
Root, | ||
// | ||
Root as Label | ||
}; |
26 changes: 26 additions & 0 deletions
26
apps/svelte-gravity-forms/src/lib/components/label/label.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<script lang="ts"> | ||
import { Label as LabelPrimitive } from 'bits-ui'; | ||
import { getFormField } from 'formsnap'; | ||
import { cn } from '$lib/utils.js'; | ||
type $$Props = LabelPrimitive.Props; | ||
type $$Events = LabelPrimitive.Events; | ||
let className: $$Props['class'] = undefined; | ||
export { className as class }; | ||
const { errors } = getFormField(); | ||
$: className = $errors ? cn($errors && 'text-destructive', className) : className; | ||
</script> | ||
|
||
<LabelPrimitive.Root | ||
class={cn( | ||
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70', | ||
className | ||
)} | ||
{...$$restProps} | ||
on:mousedown | ||
> | ||
<slot /> | ||
</LabelPrimitive.Root> |
Oops, something went wrong.