-
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.
Add select component and fix typings for some components
- Loading branch information
Showing
26 changed files
with
798 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@jeanne-mas/svelte-ui': minor | ||
--- | ||
|
||
Added select component |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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
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
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
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
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
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,103 @@ | ||
<script context="module" lang="ts"> | ||
import { Select as SelectPrimitive } from 'bits-ui'; | ||
import type { SvelteHTMLElements } from 'svelte/elements'; | ||
import { scale } from 'svelte/transition'; | ||
import { flyAndScale } from '$lib/transition/flyAndScale.js'; | ||
import { cn } from '$lib/utils/cn.js'; | ||
import type { ComponentSlots, Transition } from '$lib/utils/types.js'; | ||
export type Attributes = SvelteHTMLElements['div']; | ||
export type Events = Record<never, never>; | ||
export type Props< | ||
TTransition extends Transition = Transition, | ||
TTransitionIn extends Transition = Transition, | ||
TTransitionOut extends Transition = Transition, | ||
> = Omit< | ||
SelectPrimitive.ContentProps<TTransition, TTransitionIn, TTransitionOut>, | ||
keyof Attributes | ||
>; | ||
export type Slots< | ||
TTransition extends Transition = Transition, | ||
TTransitionIn extends Transition = Transition, | ||
TTransitionOut extends Transition = Transition, | ||
> = ComponentSlots<SelectPrimitive.Content<TTransition, TTransitionIn, TTransitionOut>>; | ||
</script> | ||
|
||
<script | ||
generics=" | ||
TTransition extends Transition = Transition, | ||
TTransitionIn extends Transition = Transition, | ||
TTransitionOut extends Transition = Transition, | ||
" | ||
lang="ts" | ||
> | ||
type $$Events = SelectPrimitive.ContentEvents; | ||
type $$Props = Attributes & Events & TypedProps; | ||
type $$Slots = TypedSlots; | ||
type TypedProps = Props<TTransition, TTransitionIn, TTransitionOut>; | ||
type TypedSlots = Slots<TTransition, TTransitionIn, TTransitionOut>; | ||
export let align: TypedProps['align'] = undefined; | ||
export let alignOffset: TypedProps['alignOffset'] = undefined; | ||
export let asChild: TypedProps['asChild'] = undefined; | ||
export let avoidCollisions: TypedProps['avoidCollisions'] = undefined; | ||
export let collisionBoundary: TypedProps['collisionBoundary'] = undefined; | ||
export let collisionPadding: TypedProps['collisionPadding'] = undefined; | ||
export let el: TypedProps['el'] = undefined; | ||
export let fitViewport: TypedProps['fitViewport'] = undefined; | ||
export let inTransition: TypedProps['inTransition'] = flyAndScale as TypedProps['inTransition']; | ||
export let inTransitionConfig: TypedProps['inTransitionConfig'] = undefined; | ||
export let outTransition: TypedProps['outTransition'] = scale as TypedProps['outTransition']; | ||
export let outTransitionConfig: TypedProps['outTransitionConfig'] = { | ||
start: 0.95, | ||
opacity: 0, | ||
duration: 50, | ||
}; | ||
export let overlap: TypedProps['overlap'] = undefined; | ||
export let sameWidth: TypedProps['sameWidth'] = undefined; | ||
export let side: TypedProps['side'] = undefined; | ||
export let sideOffset: TypedProps['sideOffset'] = 4; | ||
export let strategy: TypedProps['strategy'] = undefined; | ||
export let transition: TypedProps['transition'] = undefined; | ||
export let transitionConfig: TypedProps['transitionConfig'] = undefined; | ||
$: attributes = $$restProps as Attributes; | ||
</script> | ||
|
||
<!-- <style lang="postcss"> | ||
</style> --> | ||
|
||
<SelectPrimitive.Content | ||
{...attributes} | ||
align="{align}" | ||
alignOffset="{alignOffset}" | ||
asChild="{asChild}" | ||
avoidCollisions="{avoidCollisions}" | ||
class="{cn( | ||
'relative z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md outline-none', | ||
attributes.class, | ||
)}" | ||
collisionBoundary="{collisionBoundary}" | ||
collisionPadding="{collisionPadding}" | ||
el="{el}" | ||
fitViewport="{fitViewport}" | ||
inTransition="{inTransition}" | ||
inTransitionConfig="{inTransitionConfig}" | ||
outTransition="{outTransition}" | ||
outTransitionConfig="{outTransitionConfig}" | ||
overlap="{overlap}" | ||
sameWidth="{sameWidth}" | ||
side="{side}" | ||
sideOffset="{sideOffset}" | ||
strategy="{strategy}" | ||
transition="{transition}" | ||
transitionConfig="{transitionConfig}" | ||
let:builder | ||
on:keydown | ||
on:pointerleave | ||
> | ||
<div class="w-full p-1"> | ||
<slot builder="{builder}" /> | ||
</div> | ||
</SelectPrimitive.Content> |
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,29 @@ | ||
<script context="module" lang="ts"> | ||
import { Select as SelectPrimitive } from 'bits-ui'; | ||
import type { SvelteHTMLElements } from 'svelte/elements'; | ||
import type { ComponentSlots } from '$lib/utils/types.js'; | ||
export type Attributes = SvelteHTMLElements['div']; | ||
export type Events = Record<never, never>; | ||
export type Props = Omit<SelectPrimitive.GroupProps, keyof Attributes>; | ||
export type Slots = ComponentSlots<SelectPrimitive.Group>; | ||
</script> | ||
|
||
<script lang="ts"> | ||
type $$Events = Record<never, never>; | ||
type $$Props = Attributes & Events & Props; | ||
type $$Slots = Slots; | ||
export let asChild: Props['asChild'] = undefined; | ||
export let el: Props['el'] = undefined; | ||
$: attributes = $$restProps as Attributes; | ||
</script> | ||
|
||
<!-- <style lang="postcss"> | ||
</style> --> | ||
|
||
<SelectPrimitive.Group {...attributes} asChild="{asChild}" el="{el}" let:builder> | ||
<slot builder="{builder}" /> | ||
</SelectPrimitive.Group> |
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,30 @@ | ||
<script context="module" lang="ts"> | ||
import { Select as SelectPrimitive } from 'bits-ui'; | ||
import type { SvelteHTMLElements } from 'svelte/elements'; | ||
import { castAsAny } from '$lib/utils/internal.js'; | ||
import type { ComponentSlots } from '$lib/utils/types.js'; | ||
export type Attributes = SvelteHTMLElements['input']; | ||
export type Events = Record<never, never>; | ||
export type Props = Omit<SelectPrimitive.InputProps, keyof Attributes>; | ||
export type Slots = ComponentSlots<SelectPrimitive.Input>; | ||
</script> | ||
|
||
<script lang="ts"> | ||
type $$Events = Record<never, never>; | ||
type $$Props = Attributes & Events & Props; | ||
type $$Slots = Slots; | ||
export let asChild: Props['asChild'] = undefined; | ||
export let el: Props['el'] = undefined; | ||
$: attributes = $$restProps as Attributes; | ||
</script> | ||
|
||
<!-- <style lang="postcss"> | ||
</style> --> | ||
|
||
<SelectPrimitive.Input {...attributes} asChild="{asChild}" el="{el}" let:builder> | ||
<slot builder="{castAsAny(builder)}" /> | ||
</SelectPrimitive.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,63 @@ | ||
<script context="module" lang="ts"> | ||
import { Select as SelectPrimitive } from 'bits-ui'; | ||
import CheckIcon from 'lucide-svelte/icons/check'; | ||
import type { SvelteHTMLElements } from 'svelte/elements'; | ||
import { cn } from '$lib/utils/cn.js'; | ||
import type { ComponentSlots } from '$lib/utils/types.js'; | ||
export type Attributes = SvelteHTMLElements['div']; | ||
export type Events = Record<never, never>; | ||
export type Props = Omit<SelectPrimitive.ItemProps, keyof Attributes>; | ||
export type Slots = ComponentSlots<SelectPrimitive.Item>; | ||
</script> | ||
|
||
<script lang="ts"> | ||
type $$Events = SelectPrimitive.ItemEvents; | ||
type $$Props = Attributes & Events & Props; | ||
type $$Slots = Slots; | ||
export let asChild: Props['asChild'] = undefined; | ||
export let disabled: Props['disabled'] = undefined; | ||
export let el: Props['el'] = undefined; | ||
export let label: Props['label'] = undefined; | ||
export let value: Props['value']; | ||
$: attributes = $$restProps as Attributes; | ||
</script> | ||
|
||
<!-- <style lang="postcss"> | ||
</style> --> | ||
|
||
<SelectPrimitive.Item | ||
{...attributes} | ||
asChild="{asChild}" | ||
class="{cn( | ||
'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none', | ||
'data-[disabled]:pointer-events-none data-[disabled]:opacity-50', | ||
'data-[highlighted]:bg-accent data-[highlighted]:text-accent-foreground', | ||
attributes.class, | ||
)}" | ||
disabled="{disabled}" | ||
el="{el}" | ||
label="{label}" | ||
value="{value}" | ||
let:builder | ||
let:isSelected | ||
on:click | ||
on:focusin | ||
on:focusout | ||
on:keydown | ||
on:pointerleave | ||
on:pointermove | ||
> | ||
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> | ||
<SelectPrimitive.ItemIndicator> | ||
<CheckIcon class="h-4 w-4" /> | ||
</SelectPrimitive.ItemIndicator> | ||
</span> | ||
|
||
<slot builder="{builder}" isSelected="{isSelected}"> | ||
{label || value} | ||
</slot> | ||
</SelectPrimitive.Item> |
Oops, something went wrong.