sve-ui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -0
- package/dist/components/Accordion/AccordionContent.svelte +25 -0
- package/dist/components/Accordion/AccordionContent.svelte.d.ts +10 -0
- package/dist/components/Accordion/AccordionContent.svelte.d.ts.map +1 -0
- package/dist/components/Accordion/AccordionHeader.svelte +22 -0
- package/dist/components/Accordion/AccordionHeader.svelte.d.ts +10 -0
- package/dist/components/Accordion/AccordionHeader.svelte.d.ts.map +1 -0
- package/dist/components/Accordion/AccordionItem.svelte +22 -0
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +10 -0
- package/dist/components/Accordion/AccordionItem.svelte.d.ts.map +1 -0
- package/dist/components/Accordion/AccordionRoot.svelte +37 -0
- package/dist/components/Accordion/AccordionRoot.svelte.d.ts +21 -0
- package/dist/components/Accordion/AccordionRoot.svelte.d.ts.map +1 -0
- package/dist/components/Accordion/AccordionTrigger.svelte +71 -0
- package/dist/components/Accordion/AccordionTrigger.svelte.d.ts +11 -0
- package/dist/components/Accordion/AccordionTrigger.svelte.d.ts.map +1 -0
- package/dist/components/Accordion/index.d.ts +14 -0
- package/dist/components/Accordion/index.d.ts.map +1 -0
- package/dist/components/Accordion/index.js +13 -0
- package/dist/components/Checkbox/CheckboxRoot.svelte +95 -0
- package/dist/components/Checkbox/CheckboxRoot.svelte.d.ts +12 -0
- package/dist/components/Checkbox/CheckboxRoot.svelte.d.ts.map +1 -0
- package/dist/components/Checkbox/index.d.ts +9 -0
- package/dist/components/Checkbox/index.d.ts.map +1 -0
- package/dist/components/Checkbox/index.js +8 -0
- package/dist/components/Code/Code.svelte +130 -0
- package/dist/components/Code/Code.svelte.d.ts +14 -0
- package/dist/components/Code/Code.svelte.d.ts.map +1 -0
- package/dist/components/Combobox/ComboboxContent.svelte +33 -0
- package/dist/components/Combobox/ComboboxContent.svelte.d.ts +10 -0
- package/dist/components/Combobox/ComboboxContent.svelte.d.ts.map +1 -0
- package/dist/components/Combobox/ComboboxInput.svelte +42 -0
- package/dist/components/Combobox/ComboboxInput.svelte.d.ts +10 -0
- package/dist/components/Combobox/ComboboxInput.svelte.d.ts.map +1 -0
- package/dist/components/Combobox/ComboboxItem.svelte +50 -0
- package/dist/components/Combobox/ComboboxItem.svelte.d.ts +10 -0
- package/dist/components/Combobox/ComboboxItem.svelte.d.ts.map +1 -0
- package/dist/components/Combobox/index.d.ts +17 -0
- package/dist/components/Combobox/index.d.ts.map +1 -0
- package/dist/components/Combobox/index.js +16 -0
- package/dist/components/RadioGroup/RadioGroupItem.svelte +58 -0
- package/dist/components/RadioGroup/RadioGroupItem.svelte.d.ts +10 -0
- package/dist/components/RadioGroup/RadioGroupItem.svelte.d.ts.map +1 -0
- package/dist/components/RadioGroup/RadioGroupRoot.svelte +30 -0
- package/dist/components/RadioGroup/RadioGroupRoot.svelte.d.ts +10 -0
- package/dist/components/RadioGroup/RadioGroupRoot.svelte.d.ts.map +1 -0
- package/dist/components/RadioGroup/index.d.ts +10 -0
- package/dist/components/RadioGroup/index.d.ts.map +1 -0
- package/dist/components/RadioGroup/index.js +9 -0
- package/dist/components/Select/SelectContent.svelte +33 -0
- package/dist/components/Select/SelectContent.svelte.d.ts +10 -0
- package/dist/components/Select/SelectContent.svelte.d.ts.map +1 -0
- package/dist/components/Select/SelectItem.svelte +51 -0
- package/dist/components/Select/SelectItem.svelte.d.ts +10 -0
- package/dist/components/Select/SelectItem.svelte.d.ts.map +1 -0
- package/dist/components/Select/SelectTrigger.svelte +66 -0
- package/dist/components/Select/SelectTrigger.svelte.d.ts +11 -0
- package/dist/components/Select/SelectTrigger.svelte.d.ts.map +1 -0
- package/dist/components/Select/index.d.ts +18 -0
- package/dist/components/Select/index.d.ts.map +1 -0
- package/dist/components/Select/index.js +17 -0
- package/dist/components/Slider/Slider.svelte +91 -0
- package/dist/components/Slider/Slider.svelte.d.ts +26 -0
- package/dist/components/Slider/Slider.svelte.d.ts.map +1 -0
- package/dist/components/Switch/SwitchRoot.svelte +87 -0
- package/dist/components/Switch/SwitchRoot.svelte.d.ts +12 -0
- package/dist/components/Switch/SwitchRoot.svelte.d.ts.map +1 -0
- package/dist/components/Switch/index.d.ts +8 -0
- package/dist/components/Switch/index.d.ts.map +1 -0
- package/dist/components/Switch/index.js +7 -0
- package/dist/components/Tabs/TabsContent.svelte +29 -0
- package/dist/components/Tabs/TabsContent.svelte.d.ts +10 -0
- package/dist/components/Tabs/TabsContent.svelte.d.ts.map +1 -0
- package/dist/components/Tabs/TabsList.svelte +24 -0
- package/dist/components/Tabs/TabsList.svelte.d.ts +10 -0
- package/dist/components/Tabs/TabsList.svelte.d.ts.map +1 -0
- package/dist/components/Tabs/TabsRoot.svelte +29 -0
- package/dist/components/Tabs/TabsRoot.svelte.d.ts +10 -0
- package/dist/components/Tabs/TabsRoot.svelte.d.ts.map +1 -0
- package/dist/components/Tabs/TabsTrigger.svelte +54 -0
- package/dist/components/Tabs/TabsTrigger.svelte.d.ts +10 -0
- package/dist/components/Tabs/TabsTrigger.svelte.d.ts.map +1 -0
- package/dist/components/Tabs/index.d.ts +12 -0
- package/dist/components/Tabs/index.d.ts.map +1 -0
- package/dist/components/Tabs/index.js +11 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# Sve·UI
|
|
4
|
+
|
|
5
|
+
**Styled, accessible Svelte 5 components — zero config.**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/sve-ui)
|
|
8
|
+
[](https://github.com/rodriabregu/sve-ui/blob/main/LICENSE)
|
|
9
|
+
[](https://svelte.dev)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
A library of ready-made, fully **styled** and fully **accessible** Svelte 5
|
|
14
|
+
components, built on [Bits UI](https://bits-ui.com). The wedge: it needs **no
|
|
15
|
+
Tailwind and no config** in your project. Install, import the stylesheet once,
|
|
16
|
+
and use — then theme everything with CSS custom properties.
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
pnpm add sve-ui
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Why Sve·UI
|
|
23
|
+
|
|
24
|
+
- **No Tailwind, no config** — styles ship with the package. No `tailwind.config`,
|
|
25
|
+
no PostCSS, no utility classes in your app.
|
|
26
|
+
- **Accessible by default** — overlays are built on Bits UI: WAI-ARIA, focus traps,
|
|
27
|
+
keyboard navigation.
|
|
28
|
+
- **Themeable** — every color, radius and spacing value is a `--sve-*` CSS variable.
|
|
29
|
+
Light and dark out of the box.
|
|
30
|
+
- **Svelte 5 + runes** — modern, typed, tree-shakeable, ships with provenance.
|
|
31
|
+
|
|
32
|
+
## Quick start
|
|
33
|
+
|
|
34
|
+
Import the stylesheet once (e.g. in your root layout), then use the components:
|
|
35
|
+
|
|
36
|
+
```svelte
|
|
37
|
+
<script>
|
|
38
|
+
import 'sve-ui/theme.css';
|
|
39
|
+
import { Button } from 'sve-ui';
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<Button color="primary">Ship it</Button>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Wrap your app in `ThemeProvider` to control light/dark (optional — components work
|
|
46
|
+
without it):
|
|
47
|
+
|
|
48
|
+
```svelte
|
|
49
|
+
<script>
|
|
50
|
+
import { ThemeProvider, Button, Dialog } from 'sve-ui';
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<ThemeProvider colorScheme="dark">
|
|
54
|
+
<Dialog.Root>
|
|
55
|
+
<Dialog.Trigger>
|
|
56
|
+
{#snippet child({ props })}
|
|
57
|
+
<Button {...props}>Open dialog</Button>
|
|
58
|
+
{/snippet}
|
|
59
|
+
</Dialog.Trigger>
|
|
60
|
+
<Dialog.Overlay />
|
|
61
|
+
<Dialog.Content>
|
|
62
|
+
<Dialog.Title>Delete project?</Dialog.Title>
|
|
63
|
+
<Dialog.Description>This action can't be undone.</Dialog.Description>
|
|
64
|
+
</Dialog.Content>
|
|
65
|
+
</Dialog.Root>
|
|
66
|
+
</ThemeProvider>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Components
|
|
70
|
+
|
|
71
|
+
**Display & form** — `Button`, `Input`, `Card`, `Badge`, `Avatar`, `Spinner`,
|
|
72
|
+
`Text`, `Heading`, `Alert`.
|
|
73
|
+
|
|
74
|
+
**Form controls** (on Bits UI) — `Switch`, `Checkbox`, `RadioGroup`.
|
|
75
|
+
|
|
76
|
+
**Overlays** (on Bits UI) — `Dialog`, `DropdownMenu`, `Tooltip`, `Popover`.
|
|
77
|
+
|
|
78
|
+
Most components take `variant`, `color` and `size` props, e.g.:
|
|
79
|
+
|
|
80
|
+
```svelte
|
|
81
|
+
<Button variant="solid" color="primary">Primary</Button>
|
|
82
|
+
<Button variant="outline" color="danger">Danger</Button>
|
|
83
|
+
<Badge variant="subtle" color="success">Active</Badge>
|
|
84
|
+
<Input variant="outline" size="md" placeholder="you@example.com" bind:value />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`Avatar`, `Card`, `Alert`, the overlays, and the form controls are **namespaced**
|
|
88
|
+
compositions — import the namespace and compose its parts (`Dialog.Root`,
|
|
89
|
+
`Dialog.Trigger`, `Dialog.Content`; `RadioGroup.Root`, `RadioGroup.Item`; …).
|
|
90
|
+
|
|
91
|
+
## Theming
|
|
92
|
+
|
|
93
|
+
All design tokens are CSS custom properties under `:root`, established by
|
|
94
|
+
`sve-ui/theme.css`. Override any of them to retheme — no rebuild, no config:
|
|
95
|
+
|
|
96
|
+
```css
|
|
97
|
+
:root {
|
|
98
|
+
--sve-color-primary: #8b5cf6;
|
|
99
|
+
--sve-radius-md: 0.5rem;
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Semantic color roles (`primary`, `secondary`, `success`, `warning`, `danger`,
|
|
104
|
+
`default`) each expose `…-foreground`, `…-surface`, `…-border`, `…-hover` and
|
|
105
|
+
`…-active` variants. Light and dark are both included; `ThemeProvider` toggles
|
|
106
|
+
the scheme via a `colorScheme` prop (`"light" | "dark" | "system"`) and can apply
|
|
107
|
+
per-subtree token overrides via its `theme` prop.
|
|
108
|
+
|
|
109
|
+
## Package exports
|
|
110
|
+
|
|
111
|
+
| Import | What |
|
|
112
|
+
| ------------------ | ------------------------------------------------------------------ |
|
|
113
|
+
| `sve-ui` | All components, `ThemeProvider`, variant helpers and types |
|
|
114
|
+
| `sve-ui/theme` | Token maps and theming utilities (`lightTokens`, `themeToVars`, …) |
|
|
115
|
+
| `sve-ui/theme.css` | The stylesheet that registers all `--sve-*` variables |
|
|
116
|
+
|
|
117
|
+
## Requirements
|
|
118
|
+
|
|
119
|
+
- Svelte `^5` (peer dependency)
|
|
120
|
+
|
|
121
|
+
## Links
|
|
122
|
+
|
|
123
|
+
- Docs: [sveui.org](https://sveui.org)
|
|
124
|
+
- Source: [github.com/rodriabregu/sve-ui](https://github.com/rodriabregu/sve-ui)
|
|
125
|
+
|
|
126
|
+
## License
|
|
127
|
+
|
|
128
|
+
[MIT](https://github.com/rodriabregu/sve-ui/blob/main/LICENSE) © Rodrigo Abregu
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Accordion } from 'bits-ui';
|
|
3
|
+
import type { ComponentProps } from 'svelte';
|
|
4
|
+
|
|
5
|
+
type BitsContentProps = ComponentProps<typeof Accordion.Content>;
|
|
6
|
+
|
|
7
|
+
interface Props extends Omit<BitsContentProps, 'class'> {
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { class: cls, ...rest }: Props = $props();
|
|
12
|
+
|
|
13
|
+
const className = $derived(['sve-accordion__content', cls].filter(Boolean).join(' '));
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Accordion.Content class={className} data-slot="accordion-content" {...rest} />
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
:global(.sve-accordion__content) {
|
|
20
|
+
padding-bottom: var(--sve-space-4);
|
|
21
|
+
color: var(--sve-color-default-foreground);
|
|
22
|
+
font-size: var(--sve-font-size-sm);
|
|
23
|
+
line-height: var(--sve-line-height-normal);
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Accordion } from 'bits-ui';
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
type BitsContentProps = ComponentProps<typeof Accordion.Content>;
|
|
4
|
+
interface Props extends Omit<BitsContentProps, 'class'> {
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const AccordionContent: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type AccordionContent = ReturnType<typeof AccordionContent>;
|
|
9
|
+
export default AccordionContent;
|
|
10
|
+
//# sourceMappingURL=AccordionContent.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionContent.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Accordion/AccordionContent.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAG3C,KAAK,gBAAgB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAEjE,UAAU,KAAM,SAAQ,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkBH,QAAA,MAAM,gBAAgB,2CAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Accordion } from 'bits-ui';
|
|
3
|
+
import type { ComponentProps } from 'svelte';
|
|
4
|
+
|
|
5
|
+
type BitsHeaderProps = ComponentProps<typeof Accordion.Header>;
|
|
6
|
+
|
|
7
|
+
interface Props extends Omit<BitsHeaderProps, 'class'> {
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { class: cls, ...rest }: Props = $props();
|
|
12
|
+
|
|
13
|
+
const className = $derived(['sve-accordion__header', cls].filter(Boolean).join(' '));
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Accordion.Header class={className} data-slot="accordion-header" {...rest} />
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
:global(.sve-accordion__header) {
|
|
20
|
+
margin: 0;
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Accordion } from 'bits-ui';
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
type BitsHeaderProps = ComponentProps<typeof Accordion.Header>;
|
|
4
|
+
interface Props extends Omit<BitsHeaderProps, 'class'> {
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const AccordionHeader: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type AccordionHeader = ReturnType<typeof AccordionHeader>;
|
|
9
|
+
export default AccordionHeader;
|
|
10
|
+
//# sourceMappingURL=AccordionHeader.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionHeader.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Accordion/AccordionHeader.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAG3C,KAAK,eAAe,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC;AAE/D,UAAU,KAAM,SAAQ,IAAI,CAAC,eAAe,EAAE,OAAO,CAAC;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkBH,QAAA,MAAM,eAAe,2CAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Accordion } from 'bits-ui';
|
|
3
|
+
import type { ComponentProps } from 'svelte';
|
|
4
|
+
|
|
5
|
+
type BitsItemProps = ComponentProps<typeof Accordion.Item>;
|
|
6
|
+
|
|
7
|
+
interface Props extends Omit<BitsItemProps, 'class'> {
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { class: cls, ...rest }: Props = $props();
|
|
12
|
+
|
|
13
|
+
const className = $derived(['sve-accordion__item', cls].filter(Boolean).join(' '));
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Accordion.Item class={className} data-slot="accordion-item" {...rest} />
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
:global(.sve-accordion__item) {
|
|
20
|
+
border-bottom: 1px solid var(--sve-color-default-border);
|
|
21
|
+
}
|
|
22
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Accordion } from 'bits-ui';
|
|
2
|
+
import type { ComponentProps } from 'svelte';
|
|
3
|
+
type BitsItemProps = ComponentProps<typeof Accordion.Item>;
|
|
4
|
+
interface Props extends Omit<BitsItemProps, 'class'> {
|
|
5
|
+
class?: string;
|
|
6
|
+
}
|
|
7
|
+
declare const AccordionItem: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type AccordionItem = ReturnType<typeof AccordionItem>;
|
|
9
|
+
export default AccordionItem;
|
|
10
|
+
//# sourceMappingURL=AccordionItem.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionItem.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Accordion/AccordionItem.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAG3C,KAAK,aAAa,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;AAE3D,UAAU,KAAM,SAAQ,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAkBH,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Accordion } from 'bits-ui';
|
|
3
|
+
import type { Component, Snippet } from 'svelte';
|
|
4
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Bits' Accordion.Root props are a discriminated union (single vs multiple)
|
|
8
|
+
* over 400+ HTML attributes, which overflows TypeScript's union representation
|
|
9
|
+
* when spread. We expose a flat, non-union surface here and forward it to a
|
|
10
|
+
* loosely-typed view of the Bits root — behavior is unchanged.
|
|
11
|
+
*/
|
|
12
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'class'> {
|
|
13
|
+
type?: 'single' | 'multiple';
|
|
14
|
+
value?: string | string[];
|
|
15
|
+
onValueChange?: (value: string & string[]) => void;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
loop?: boolean;
|
|
18
|
+
class?: string;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
let { type = 'single', class: cls, ...rest }: Props = $props();
|
|
23
|
+
|
|
24
|
+
const className = $derived(['sve-accordion', cls].filter(Boolean).join(' '));
|
|
25
|
+
|
|
26
|
+
const Root = Accordion.Root as unknown as Component<Record<string, unknown>>;
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<Root {type} class={className} data-slot="accordion" {...rest} />
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
:global(.sve-accordion) {
|
|
33
|
+
display: block;
|
|
34
|
+
font-family: var(--sve-font-family-sans);
|
|
35
|
+
border-top: 1px solid var(--sve-color-default-border);
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Component, Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
/**
|
|
4
|
+
* Bits' Accordion.Root props are a discriminated union (single vs multiple)
|
|
5
|
+
* over 400+ HTML attributes, which overflows TypeScript's union representation
|
|
6
|
+
* when spread. We expose a flat, non-union surface here and forward it to a
|
|
7
|
+
* loosely-typed view of the Bits root — behavior is unchanged.
|
|
8
|
+
*/
|
|
9
|
+
interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'class'> {
|
|
10
|
+
type?: 'single' | 'multiple';
|
|
11
|
+
value?: string | string[];
|
|
12
|
+
onValueChange?: (value: string & string[]) => void;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
loop?: boolean;
|
|
15
|
+
class?: string;
|
|
16
|
+
children?: Snippet;
|
|
17
|
+
}
|
|
18
|
+
declare const AccordionRoot: Component<Props, {}, "">;
|
|
19
|
+
type AccordionRoot = ReturnType<typeof AccordionRoot>;
|
|
20
|
+
export default AccordionRoot;
|
|
21
|
+
//# sourceMappingURL=AccordionRoot.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionRoot.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Accordion/AccordionRoot.svelte.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGpD;;;;;GAKG;AACH,UAAU,KAAM,SAAQ,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IACnE,IAAI,CAAC,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC1B,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAoBH,QAAA,MAAM,aAAa,0BAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Accordion } from 'bits-ui';
|
|
3
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
type BitsTriggerProps = ComponentProps<typeof Accordion.Trigger>;
|
|
6
|
+
|
|
7
|
+
interface Props extends Omit<BitsTriggerProps, 'class' | 'children'> {
|
|
8
|
+
class?: string;
|
|
9
|
+
children?: Snippet;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let { class: cls, children, ...rest }: Props = $props();
|
|
13
|
+
|
|
14
|
+
const className = $derived(['sve-accordion__trigger', cls].filter(Boolean).join(' '));
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<Accordion.Trigger class={className} data-slot="accordion-trigger" {...rest}>
|
|
18
|
+
<span class="sve-accordion__label">{@render children?.()}</span>
|
|
19
|
+
<svg class="sve-accordion__chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
20
|
+
<path d="m6 9 6 6 6-6" />
|
|
21
|
+
</svg>
|
|
22
|
+
</Accordion.Trigger>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
:global(.sve-accordion__trigger) {
|
|
26
|
+
display: flex;
|
|
27
|
+
width: 100%;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: space-between;
|
|
30
|
+
gap: var(--sve-space-2);
|
|
31
|
+
padding: var(--sve-space-4) 0;
|
|
32
|
+
border: none;
|
|
33
|
+
background-color: transparent;
|
|
34
|
+
color: var(--sve-color-default-foreground);
|
|
35
|
+
font-family: var(--sve-font-family-sans);
|
|
36
|
+
font-size: var(--sve-font-size-md);
|
|
37
|
+
font-weight: var(--sve-font-weight-medium);
|
|
38
|
+
text-align: left;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:global(.sve-accordion__trigger:focus-visible) {
|
|
43
|
+
outline: 2px solid var(--sve-color-primary);
|
|
44
|
+
outline-offset: 2px;
|
|
45
|
+
border-radius: var(--sve-radius-sm);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:global(.sve-accordion__trigger:disabled) {
|
|
49
|
+
opacity: 0.5;
|
|
50
|
+
cursor: not-allowed;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
:global(.sve-accordion__chevron) {
|
|
54
|
+
width: 1.25rem;
|
|
55
|
+
height: 1.25rem;
|
|
56
|
+
flex-shrink: 0;
|
|
57
|
+
color: var(--sve-color-default-foreground);
|
|
58
|
+
opacity: 0.6;
|
|
59
|
+
transition: transform 0.2s ease;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
:global(.sve-accordion__trigger[data-state='open'] .sve-accordion__chevron) {
|
|
63
|
+
transform: rotate(180deg);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media (prefers-reduced-motion: reduce) {
|
|
67
|
+
:global(.sve-accordion__chevron) {
|
|
68
|
+
transition: none;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
</style>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Accordion } from 'bits-ui';
|
|
2
|
+
import type { ComponentProps, Snippet } from 'svelte';
|
|
3
|
+
type BitsTriggerProps = ComponentProps<typeof Accordion.Trigger>;
|
|
4
|
+
interface Props extends Omit<BitsTriggerProps, 'class' | 'children'> {
|
|
5
|
+
class?: string;
|
|
6
|
+
children?: Snippet;
|
|
7
|
+
}
|
|
8
|
+
declare const AccordionTrigger: import("svelte").Component<Props, {}, "">;
|
|
9
|
+
type AccordionTrigger = ReturnType<typeof AccordionTrigger>;
|
|
10
|
+
export default AccordionTrigger;
|
|
11
|
+
//# sourceMappingURL=AccordionTrigger.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccordionTrigger.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Accordion/AccordionTrigger.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGpD,KAAK,gBAAgB,GAAG,cAAc,CAAC,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC;AAEjE,UAAU,KAAM,SAAQ,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,UAAU,CAAC;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAuBH,QAAA,MAAM,gBAAgB,2CAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accordion namespace — sve-ui styled wrappers over bits-ui Accordion.
|
|
3
|
+
*
|
|
4
|
+
* Root: container; requires `type` ("single" | "multiple"); `bind:value` tracks
|
|
5
|
+
* the open item(s) (Bits owns ARIA, keyboard, and open/close state).
|
|
6
|
+
* Item / Header / Trigger / Content: styled parts. Trigger includes a chevron
|
|
7
|
+
* that rotates on open; compose Trigger inside Header.
|
|
8
|
+
*/
|
|
9
|
+
export { default as Root } from './AccordionRoot.svelte';
|
|
10
|
+
export { default as Item } from './AccordionItem.svelte';
|
|
11
|
+
export { default as Header } from './AccordionHeader.svelte';
|
|
12
|
+
export { default as Trigger } from './AccordionTrigger.svelte';
|
|
13
|
+
export { default as Content } from './AccordionContent.svelte';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Accordion/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Accordion namespace — sve-ui styled wrappers over bits-ui Accordion.
|
|
3
|
+
*
|
|
4
|
+
* Root: container; requires `type` ("single" | "multiple"); `bind:value` tracks
|
|
5
|
+
* the open item(s) (Bits owns ARIA, keyboard, and open/close state).
|
|
6
|
+
* Item / Header / Trigger / Content: styled parts. Trigger includes a chevron
|
|
7
|
+
* that rotates on open; compose Trigger inside Header.
|
|
8
|
+
*/
|
|
9
|
+
export { default as Root } from './AccordionRoot.svelte';
|
|
10
|
+
export { default as Item } from './AccordionItem.svelte';
|
|
11
|
+
export { default as Header } from './AccordionHeader.svelte';
|
|
12
|
+
export { default as Trigger } from './AccordionTrigger.svelte';
|
|
13
|
+
export { default as Content } from './AccordionContent.svelte';
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type Size = 'sm' | 'md' | 'lg';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { Checkbox } from 'bits-ui';
|
|
7
|
+
import type { ComponentProps } from 'svelte';
|
|
8
|
+
|
|
9
|
+
type BitsRootProps = ComponentProps<typeof Checkbox.Root>;
|
|
10
|
+
|
|
11
|
+
interface Props extends Omit<BitsRootProps, 'class' | 'children'> {
|
|
12
|
+
size?: Size;
|
|
13
|
+
class?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
size = 'md',
|
|
18
|
+
checked = $bindable(false),
|
|
19
|
+
indeterminate = $bindable(false),
|
|
20
|
+
class: cls,
|
|
21
|
+
...rest
|
|
22
|
+
}: Props = $props();
|
|
23
|
+
|
|
24
|
+
const className = $derived(
|
|
25
|
+
['sve-checkbox', `sve-checkbox--${size}`, cls].filter(Boolean).join(' ')
|
|
26
|
+
);
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<Checkbox.Root
|
|
30
|
+
bind:checked
|
|
31
|
+
bind:indeterminate
|
|
32
|
+
class={className}
|
|
33
|
+
data-slot="checkbox"
|
|
34
|
+
{...rest}
|
|
35
|
+
>
|
|
36
|
+
{#snippet children({ checked, indeterminate })}
|
|
37
|
+
{#if indeterminate}
|
|
38
|
+
<svg class="sve-checkbox__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linecap="round" aria-hidden="true">
|
|
39
|
+
<path d="M5 12h14" />
|
|
40
|
+
</svg>
|
|
41
|
+
{:else if checked}
|
|
42
|
+
<svg class="sve-checkbox__icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
43
|
+
<path d="M20 6 9 17l-5-5" />
|
|
44
|
+
</svg>
|
|
45
|
+
{/if}
|
|
46
|
+
{/snippet}
|
|
47
|
+
</Checkbox.Root>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
:global(.sve-checkbox) {
|
|
51
|
+
display: inline-flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
flex-shrink: 0;
|
|
55
|
+
padding: 0;
|
|
56
|
+
border: 1px solid var(--sve-color-default-border);
|
|
57
|
+
border-radius: var(--sve-radius-sm);
|
|
58
|
+
background-color: transparent;
|
|
59
|
+
color: var(--sve-color-primary-foreground);
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
transition: background-color 0.15s ease, border-color 0.15s ease;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
:global(.sve-checkbox[data-state='checked']),
|
|
65
|
+
:global(.sve-checkbox[data-state='indeterminate']) {
|
|
66
|
+
background-color: var(--sve-color-primary);
|
|
67
|
+
border-color: var(--sve-color-primary);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
:global(.sve-checkbox:focus-visible) {
|
|
71
|
+
outline: 2px solid var(--sve-color-primary);
|
|
72
|
+
outline-offset: 2px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:global(.sve-checkbox:disabled) {
|
|
76
|
+
opacity: 0.5;
|
|
77
|
+
cursor: not-allowed;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:global(.sve-checkbox__icon) {
|
|
81
|
+
width: 80%;
|
|
82
|
+
height: 80%;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* --- Sizes --- */
|
|
86
|
+
:global(.sve-checkbox--sm) { width: 1rem; height: 1rem; }
|
|
87
|
+
:global(.sve-checkbox--md) { width: 1.25rem; height: 1.25rem; }
|
|
88
|
+
:global(.sve-checkbox--lg) { width: 1.5rem; height: 1.5rem; }
|
|
89
|
+
|
|
90
|
+
@media (prefers-reduced-motion: reduce) {
|
|
91
|
+
:global(.sve-checkbox) {
|
|
92
|
+
transition: none;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type Size = 'sm' | 'md' | 'lg';
|
|
2
|
+
import { Checkbox } from 'bits-ui';
|
|
3
|
+
import type { ComponentProps } from 'svelte';
|
|
4
|
+
type BitsRootProps = ComponentProps<typeof Checkbox.Root>;
|
|
5
|
+
interface Props extends Omit<BitsRootProps, 'class' | 'children'> {
|
|
6
|
+
size?: Size;
|
|
7
|
+
class?: string;
|
|
8
|
+
}
|
|
9
|
+
declare const CheckboxRoot: import("svelte").Component<Props, {}, "checked" | "indeterminate">;
|
|
10
|
+
type CheckboxRoot = ReturnType<typeof CheckboxRoot>;
|
|
11
|
+
export default CheckboxRoot;
|
|
12
|
+
//# sourceMappingURL=CheckboxRoot.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckboxRoot.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Checkbox/CheckboxRoot.svelte.ts"],"names":[],"mappings":"AAGE,MAAM,MAAM,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAGxC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAG3C,KAAK,aAAa,GAAG,cAAc,CAAC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;AAE1D,UAAU,KAAM,SAAQ,IAAI,CAAC,aAAa,EAAE,OAAO,GAAG,UAAU,CAAC;IAC/D,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAwCH,QAAA,MAAM,YAAY,oEAAwC,CAAC;AAC3D,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AACpD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox namespace — sve-ui styled wrapper over the bits-ui Checkbox primitive.
|
|
3
|
+
*
|
|
4
|
+
* Root: styled box + check/indeterminate indicator (Bits owns ARIA
|
|
5
|
+
* role="checkbox", keyboard, and state). `bind:checked` and `bind:indeterminate`
|
|
6
|
+
* are forwarded to the Bits root.
|
|
7
|
+
*/
|
|
8
|
+
export { default as Root, type Size as CheckboxSize } from './CheckboxRoot.svelte';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/Checkbox/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checkbox namespace — sve-ui styled wrapper over the bits-ui Checkbox primitive.
|
|
3
|
+
*
|
|
4
|
+
* Root: styled box + check/indeterminate indicator (Bits owns ARIA
|
|
5
|
+
* role="checkbox", keyboard, and state). `bind:checked` and `bind:indeterminate`
|
|
6
|
+
* are forwarded to the Bits root.
|
|
7
|
+
*/
|
|
8
|
+
export { default as Root } from './CheckboxRoot.svelte';
|