@colletdev/svelte 0.1.3
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 +58 -0
- package/package.json +33 -0
- package/src/accordion.svelte +52 -0
- package/src/accordion.svelte.d.ts +19 -0
- package/src/activity-group.svelte +34 -0
- package/src/activity-group.svelte.d.ts +16 -0
- package/src/alert.svelte +61 -0
- package/src/alert.svelte.d.ts +24 -0
- package/src/autocomplete.svelte +126 -0
- package/src/autocomplete.svelte.d.ts +47 -0
- package/src/avatar.svelte +32 -0
- package/src/avatar.svelte.d.ts +15 -0
- package/src/backdrop.svelte +24 -0
- package/src/backdrop.svelte.d.ts +11 -0
- package/src/badge.svelte +45 -0
- package/src/badge.svelte.d.ts +19 -0
- package/src/breadcrumb.svelte +42 -0
- package/src/breadcrumb.svelte.d.ts +16 -0
- package/src/button.svelte +52 -0
- package/src/button.svelte.d.ts +23 -0
- package/src/card.svelte +67 -0
- package/src/card.svelte.d.ts +22 -0
- package/src/carousel.svelte +59 -0
- package/src/carousel.svelte.d.ts +29 -0
- package/src/chat-input.svelte +76 -0
- package/src/chat-input.svelte.d.ts +28 -0
- package/src/checkbox.svelte +83 -0
- package/src/checkbox.svelte.d.ts +29 -0
- package/src/code-block.svelte +40 -0
- package/src/code-block.svelte.d.ts +19 -0
- package/src/collapsible.svelte +56 -0
- package/src/collapsible.svelte.d.ts +27 -0
- package/src/date-picker.svelte +110 -0
- package/src/date-picker.svelte.d.ts +40 -0
- package/src/dialog.svelte +56 -0
- package/src/dialog.svelte.d.ts +24 -0
- package/src/drawer.svelte +56 -0
- package/src/drawer.svelte.d.ts +24 -0
- package/src/elements.d.ts +715 -0
- package/src/fab.svelte +48 -0
- package/src/fab.svelte.d.ts +21 -0
- package/src/file-upload.svelte +55 -0
- package/src/file-upload.svelte.d.ts +24 -0
- package/src/index.ts +85 -0
- package/src/label.svelte +29 -0
- package/src/label.svelte.d.ts +20 -0
- package/src/listbox.svelte +75 -0
- package/src/listbox.svelte.d.ts +21 -0
- package/src/menu.svelte +76 -0
- package/src/menu.svelte.d.ts +27 -0
- package/src/message-bubble.svelte +49 -0
- package/src/message-bubble.svelte.d.ts +20 -0
- package/src/message-group.svelte +41 -0
- package/src/message-group.svelte.d.ts +16 -0
- package/src/message-part.svelte +20 -0
- package/src/message-part.svelte.d.ts +9 -0
- package/src/pagination.svelte +40 -0
- package/src/pagination.svelte.d.ts +19 -0
- package/src/popover.svelte +66 -0
- package/src/popover.svelte.d.ts +28 -0
- package/src/profile-menu.svelte +55 -0
- package/src/profile-menu.svelte.d.ts +24 -0
- package/src/progress.svelte +33 -0
- package/src/progress.svelte.d.ts +16 -0
- package/src/radio-group.svelte +91 -0
- package/src/radio-group.svelte.d.ts +26 -0
- package/src/scrollbar.svelte +41 -0
- package/src/scrollbar.svelte.d.ts +16 -0
- package/src/search-bar.svelte +94 -0
- package/src/search-bar.svelte.d.ts +34 -0
- package/src/select.svelte +112 -0
- package/src/select.svelte.d.ts +37 -0
- package/src/separator.svelte +25 -0
- package/src/separator.svelte.d.ts +18 -0
- package/src/sidebar.svelte +65 -0
- package/src/sidebar.svelte.d.ts +26 -0
- package/src/skeleton.svelte +30 -0
- package/src/skeleton.svelte.d.ts +14 -0
- package/src/slider.svelte +100 -0
- package/src/slider.svelte.d.ts +35 -0
- package/src/speed-dial.svelte +66 -0
- package/src/speed-dial.svelte.d.ts +30 -0
- package/src/spinner.svelte +26 -0
- package/src/spinner.svelte.d.ts +12 -0
- package/src/split-button.svelte +64 -0
- package/src/split-button.svelte.d.ts +28 -0
- package/src/stepper.svelte +48 -0
- package/src/stepper.svelte.d.ts +19 -0
- package/src/switch.svelte +85 -0
- package/src/switch.svelte.d.ts +30 -0
- package/src/table.svelte +133 -0
- package/src/table.svelte.d.ts +33 -0
- package/src/tabs.svelte +51 -0
- package/src/tabs.svelte.d.ts +21 -0
- package/src/text-input.svelte +126 -0
- package/src/text-input.svelte.d.ts +49 -0
- package/src/text.svelte +63 -0
- package/src/text.svelte.d.ts +23 -0
- package/src/thinking.svelte +30 -0
- package/src/thinking.svelte.d.ts +14 -0
- package/src/toast.svelte +58 -0
- package/src/toast.svelte.d.ts +25 -0
- package/src/toggle-group.svelte +64 -0
- package/src/toggle-group.svelte.d.ts +23 -0
- package/src/tooltip.svelte +38 -0
- package/src/tooltip.svelte.d.ts +17 -0
- package/src/types.ts +334 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @collet/svelte
|
|
2
|
+
|
|
3
|
+
Svelte 5 runes-first wrappers for the Collet component library. Typed `$props()`, callback props, and `bind:this` refs over 48 Rust/WASM Custom Elements.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @collet/svelte @collet/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```svelte
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
import { init, Button, TextInput } from '@collet/svelte';
|
|
16
|
+
|
|
17
|
+
await init(); // once, at app startup
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<Button variant="filled" label="Save" intent="primary" oncxclick={save} />
|
|
21
|
+
<TextInput label="Email" kind="email" oncxinput={onInput} />
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Features
|
|
25
|
+
|
|
26
|
+
- **Runes-first** -- components use `$props()` with full type inference
|
|
27
|
+
- **Callback props** -- `oncxclick`, `oncxchange`, `oncxinput` (not `on:event` syntax)
|
|
28
|
+
- **Typed refs** -- `bind:this` exposes imperative methods (`.open()`, `.close()`, `.focus()`)
|
|
29
|
+
- **Structured data** -- `SelectOption[]`, `TableColumn[]`, `AccordionItem[]` fully typed
|
|
30
|
+
- **Ships source** -- `.svelte` files are included as-is; your bundler compiles them
|
|
31
|
+
|
|
32
|
+
## Event Pattern
|
|
33
|
+
|
|
34
|
+
Svelte 5 uses callback props instead of the `on:` directive. All custom events use the `oncx` prefix:
|
|
35
|
+
|
|
36
|
+
```svelte
|
|
37
|
+
<Select
|
|
38
|
+
label="Country"
|
|
39
|
+
options={countries}
|
|
40
|
+
oncxchange={(e) => setCountry(e.detail.value)}
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Custom Element Types
|
|
45
|
+
|
|
46
|
+
For direct `<cx-*>` tag usage in Svelte templates, import the element type definitions:
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
/// <reference types="@collet/svelte/elements" />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## API Reference
|
|
53
|
+
|
|
54
|
+
See [@collet/docs](https://www.npmjs.com/package/@collet/docs) for the full props/events reference and framework guides.
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
MIT -- [github.com/Danrozen87/collet](https://github.com/Danrozen87/collet)
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@colletdev/svelte",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Svelte 5 wrappers for Collet Rust/WASM UI components",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"svelte": "./src/index.ts",
|
|
7
|
+
"types": "./src/index.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.ts",
|
|
11
|
+
"svelte": "./src/index.ts"
|
|
12
|
+
},
|
|
13
|
+
"./elements": {
|
|
14
|
+
"types": "./src/elements.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"src/"
|
|
19
|
+
],
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"@colletdev/core": ">=0.1.0",
|
|
22
|
+
"svelte": ">=5.0.0"
|
|
23
|
+
},
|
|
24
|
+
"keywords": ["svelte", "svelte5", "runes", "web-components", "rust", "wasm", "ui", "collet"],
|
|
25
|
+
"author": "Dan",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/Danrozen87/collet",
|
|
31
|
+
"directory": "packages/svelte"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<!-- Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT -->
|
|
2
|
+
<!-- Svelte 5 wrapper for <cx-accordion> -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { AccordionDetail, AccordionItem } from './types.js';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
id?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
items?: AccordionItem[] | string;
|
|
10
|
+
mode?: 'single' | 'multiple';
|
|
11
|
+
collapsible?: boolean;
|
|
12
|
+
headingLevel?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
13
|
+
defaultExpanded?: string[] | string;
|
|
14
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
onChange?: (event: CustomEvent<AccordionDetail>) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let { id, label, items, mode, collapsible, headingLevel, defaultExpanded, size, disabled, onChange }: Props = $props();
|
|
20
|
+
|
|
21
|
+
let el: HTMLElement;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
$effect(() => {
|
|
25
|
+
if (!el) return;
|
|
26
|
+
if (items != null) el.setAttribute('items', typeof items === 'object' ? JSON.stringify(items) : String(items));
|
|
27
|
+
else el.removeAttribute('items');
|
|
28
|
+
});
|
|
29
|
+
$effect(() => {
|
|
30
|
+
if (!el) return;
|
|
31
|
+
if (defaultExpanded != null) el.setAttribute('default-expanded', typeof defaultExpanded === 'object' ? JSON.stringify(defaultExpanded) : String(defaultExpanded));
|
|
32
|
+
else el.removeAttribute('default-expanded');
|
|
33
|
+
});
|
|
34
|
+
$effect(() => {
|
|
35
|
+
if (!el) return;
|
|
36
|
+
const handler = (e: Event) => onChange?.(e as CustomEvent);
|
|
37
|
+
el.addEventListener('cx-change', handler);
|
|
38
|
+
return () => el.removeEventListener('cx-change', handler);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<cx-accordion
|
|
44
|
+
bind:this={el}
|
|
45
|
+
id={typeof id === 'object' && id != null ? JSON.stringify(id) : id}
|
|
46
|
+
label={typeof label === 'object' && label != null ? JSON.stringify(label) : label}
|
|
47
|
+
mode={typeof mode === 'object' && mode != null ? JSON.stringify(mode) : mode}
|
|
48
|
+
collapsible={collapsible || undefined}
|
|
49
|
+
heading-level={typeof headingLevel === 'object' && headingLevel != null ? JSON.stringify(headingLevel) : headingLevel}
|
|
50
|
+
size={typeof size === 'object' && size != null ? JSON.stringify(size) : size}
|
|
51
|
+
disabled={disabled || undefined}
|
|
52
|
+
/>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { AccordionDetail, AccordionItem } from './types.js';
|
|
4
|
+
|
|
5
|
+
interface AccordionProps {
|
|
6
|
+
id?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
items?: AccordionItem[] | string;
|
|
9
|
+
mode?: 'single' | 'multiple';
|
|
10
|
+
collapsible?: boolean;
|
|
11
|
+
headingLevel?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
12
|
+
defaultExpanded?: string[] | string;
|
|
13
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
onChange?: (event: CustomEvent<AccordionDetail>) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare const Accordion: Component<AccordionProps, {}>;
|
|
19
|
+
export default Accordion;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!-- Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT -->
|
|
2
|
+
<!-- Svelte 5 wrapper for <cx-activity-group> -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
id?: string;
|
|
7
|
+
status?: string;
|
|
8
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
|
+
border?: string;
|
|
10
|
+
summary?: string;
|
|
11
|
+
action?: string;
|
|
12
|
+
expanded?: boolean;
|
|
13
|
+
parts?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let { id, status, size, border, summary, action, expanded, parts }: Props = $props();
|
|
17
|
+
|
|
18
|
+
let el: HTMLElement;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<cx-activity-group
|
|
25
|
+
bind:this={el}
|
|
26
|
+
id={typeof id === 'object' && id != null ? JSON.stringify(id) : id}
|
|
27
|
+
status={typeof status === 'object' && status != null ? JSON.stringify(status) : status}
|
|
28
|
+
size={typeof size === 'object' && size != null ? JSON.stringify(size) : size}
|
|
29
|
+
border={typeof border === 'object' && border != null ? JSON.stringify(border) : border}
|
|
30
|
+
summary={typeof summary === 'object' && summary != null ? JSON.stringify(summary) : summary}
|
|
31
|
+
action={typeof action === 'object' && action != null ? JSON.stringify(action) : action}
|
|
32
|
+
expanded={expanded || undefined}
|
|
33
|
+
parts={typeof parts === 'object' && parts != null ? JSON.stringify(parts) : parts}
|
|
34
|
+
/>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface ActivityGroupProps {
|
|
5
|
+
id?: string;
|
|
6
|
+
status?: string;
|
|
7
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
8
|
+
border?: string;
|
|
9
|
+
summary?: string;
|
|
10
|
+
action?: string;
|
|
11
|
+
expanded?: boolean;
|
|
12
|
+
parts?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
declare const ActivityGroup: Component<ActivityGroupProps, {}>;
|
|
16
|
+
export default ActivityGroup;
|
package/src/alert.svelte
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<!-- Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT -->
|
|
2
|
+
<!-- Svelte 5 wrapper for <cx-alert> -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { DismissDetail } from './types.js';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
id?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
variant?: 'subtle' | 'filled' | 'outline';
|
|
11
|
+
intent?: 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
12
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
13
|
+
showIcon?: boolean;
|
|
14
|
+
icon?: string;
|
|
15
|
+
dismissible?: boolean;
|
|
16
|
+
dismissLabel?: string;
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
dynamic?: boolean;
|
|
19
|
+
actionsHtml?: string;
|
|
20
|
+
onDismiss?: (event: CustomEvent<DismissDetail>) => void;
|
|
21
|
+
actions?: import('svelte').Snippet;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let { id, title, description, variant, intent, size, showIcon, icon, dismissible, dismissLabel, compact, dynamic, actionsHtml, onDismiss, actions }: Props = $props();
|
|
25
|
+
|
|
26
|
+
let el: HTMLElement;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
$effect(() => {
|
|
30
|
+
if (!el) return;
|
|
31
|
+
if (title != null) el.setAttribute('title', String(title));
|
|
32
|
+
else el.removeAttribute('title');
|
|
33
|
+
});
|
|
34
|
+
$effect(() => {
|
|
35
|
+
if (!el) return;
|
|
36
|
+
const handler = (e: Event) => onDismiss?.(e as CustomEvent);
|
|
37
|
+
el.addEventListener('cx-dismiss', handler);
|
|
38
|
+
return () => el.removeEventListener('cx-dismiss', handler);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<cx-alert
|
|
44
|
+
bind:this={el}
|
|
45
|
+
id={typeof id === 'object' && id != null ? JSON.stringify(id) : id}
|
|
46
|
+
description={typeof description === 'object' && description != null ? JSON.stringify(description) : description}
|
|
47
|
+
variant={typeof variant === 'object' && variant != null ? JSON.stringify(variant) : variant}
|
|
48
|
+
intent={typeof intent === 'object' && intent != null ? JSON.stringify(intent) : intent}
|
|
49
|
+
size={typeof size === 'object' && size != null ? JSON.stringify(size) : size}
|
|
50
|
+
show-icon={showIcon || undefined}
|
|
51
|
+
icon={typeof icon === 'object' && icon != null ? JSON.stringify(icon) : icon}
|
|
52
|
+
dismissible={dismissible || undefined}
|
|
53
|
+
dismiss-label={typeof dismissLabel === 'object' && dismissLabel != null ? JSON.stringify(dismissLabel) : dismissLabel}
|
|
54
|
+
compact={compact || undefined}
|
|
55
|
+
dynamic={dynamic || undefined}
|
|
56
|
+
actions-html={typeof actionsHtml === 'object' && actionsHtml != null ? JSON.stringify(actionsHtml) : actionsHtml}
|
|
57
|
+
>
|
|
58
|
+
{#if actions}
|
|
59
|
+
<div slot="actions" style="display:contents">{@render actions()}</div>
|
|
60
|
+
{/if}
|
|
61
|
+
</cx-alert>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { DismissDetail } from './types.js';
|
|
4
|
+
|
|
5
|
+
interface AlertProps {
|
|
6
|
+
id?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
variant?: 'subtle' | 'filled' | 'outline';
|
|
10
|
+
intent?: 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
11
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
+
showIcon?: boolean;
|
|
13
|
+
icon?: string;
|
|
14
|
+
dismissible?: boolean;
|
|
15
|
+
dismissLabel?: string;
|
|
16
|
+
compact?: boolean;
|
|
17
|
+
dynamic?: boolean;
|
|
18
|
+
actionsHtml?: string;
|
|
19
|
+
onDismiss?: (event: CustomEvent<DismissDetail>) => void;
|
|
20
|
+
actions?: import('svelte').Snippet;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare const Alert: Component<AlertProps, {}>;
|
|
24
|
+
export default Alert;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<!-- Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT -->
|
|
2
|
+
<!-- Svelte 5 wrapper for <cx-autocomplete> -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { FocusDetail, InputDetail, KeyboardDetail, OptionGroup, SelectDetail, SelectOption } from './types.js';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
id?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
variant?: 'outline' | 'filled' | 'ghost';
|
|
10
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
11
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
+
/** 'single' for single select, 'multiple' for multi-select with chips. */
|
|
13
|
+
mode?: 'single' | 'multiple';
|
|
14
|
+
selected?: string[] | string;
|
|
15
|
+
/** Current search query text. Controlled by onInput events. */
|
|
16
|
+
query?: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
helperText?: string;
|
|
19
|
+
error?: string;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
readonly?: boolean;
|
|
23
|
+
name?: string;
|
|
24
|
+
/** When true, user can submit values not in the items list. */
|
|
25
|
+
allowCustom?: boolean;
|
|
26
|
+
clearable?: boolean;
|
|
27
|
+
/** Options to filter from. Filtering is client-side (fuzzy substring match). For server-side search, update this array in your onInput handler. */
|
|
28
|
+
items?: SelectOption[] | string;
|
|
29
|
+
groups?: OptionGroup[] | string;
|
|
30
|
+
onInput?: (event: CustomEvent<InputDetail>) => void;
|
|
31
|
+
onChange?: (event: CustomEvent<SelectDetail>) => void;
|
|
32
|
+
onFocus?: (event: CustomEvent<FocusDetail>) => void;
|
|
33
|
+
onBlur?: (event: CustomEvent<FocusDetail>) => void;
|
|
34
|
+
onKeydown?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
35
|
+
onKeyup?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let { id, label, variant, shape, size, mode, selected, query, placeholder, helperText, error, disabled, required, readonly, name, allowCustom, clearable, items, groups, onInput, onChange, onFocus, onBlur, onKeydown, onKeyup }: Props = $props();
|
|
39
|
+
|
|
40
|
+
let el: HTMLElement;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
$effect(() => {
|
|
44
|
+
if (!el) return;
|
|
45
|
+
if (name != null) el.setAttribute('name', String(name));
|
|
46
|
+
else el.removeAttribute('name');
|
|
47
|
+
});
|
|
48
|
+
$effect(() => {
|
|
49
|
+
if (!el) return;
|
|
50
|
+
if (selected != null) el.setAttribute('selected', typeof selected === 'object' ? JSON.stringify(selected) : String(selected));
|
|
51
|
+
else el.removeAttribute('selected');
|
|
52
|
+
});
|
|
53
|
+
$effect(() => {
|
|
54
|
+
if (!el) return;
|
|
55
|
+
if (items != null) el.setAttribute('items', typeof items === 'object' ? JSON.stringify(items) : String(items));
|
|
56
|
+
else el.removeAttribute('items');
|
|
57
|
+
});
|
|
58
|
+
$effect(() => {
|
|
59
|
+
if (!el) return;
|
|
60
|
+
if (groups != null) el.setAttribute('groups', typeof groups === 'object' ? JSON.stringify(groups) : String(groups));
|
|
61
|
+
else el.removeAttribute('groups');
|
|
62
|
+
});
|
|
63
|
+
$effect(() => {
|
|
64
|
+
if (!el) return;
|
|
65
|
+
const handler = (e: Event) => onInput?.(e as CustomEvent);
|
|
66
|
+
el.addEventListener('cx-input', handler);
|
|
67
|
+
return () => el.removeEventListener('cx-input', handler);
|
|
68
|
+
});
|
|
69
|
+
$effect(() => {
|
|
70
|
+
if (!el) return;
|
|
71
|
+
const handler = (e: Event) => onChange?.(e as CustomEvent);
|
|
72
|
+
el.addEventListener('cx-change', handler);
|
|
73
|
+
return () => el.removeEventListener('cx-change', handler);
|
|
74
|
+
});
|
|
75
|
+
$effect(() => {
|
|
76
|
+
if (!el) return;
|
|
77
|
+
const handler = (e: Event) => onFocus?.(e as CustomEvent);
|
|
78
|
+
el.addEventListener('cx-focus', handler);
|
|
79
|
+
return () => el.removeEventListener('cx-focus', handler);
|
|
80
|
+
});
|
|
81
|
+
$effect(() => {
|
|
82
|
+
if (!el) return;
|
|
83
|
+
const handler = (e: Event) => onBlur?.(e as CustomEvent);
|
|
84
|
+
el.addEventListener('cx-blur', handler);
|
|
85
|
+
return () => el.removeEventListener('cx-blur', handler);
|
|
86
|
+
});
|
|
87
|
+
$effect(() => {
|
|
88
|
+
if (!el) return;
|
|
89
|
+
const handler = (e: Event) => onKeydown?.(e as CustomEvent);
|
|
90
|
+
el.addEventListener('cx-keydown', handler);
|
|
91
|
+
return () => el.removeEventListener('cx-keydown', handler);
|
|
92
|
+
});
|
|
93
|
+
$effect(() => {
|
|
94
|
+
if (!el) return;
|
|
95
|
+
const handler = (e: Event) => onKeyup?.(e as CustomEvent);
|
|
96
|
+
el.addEventListener('cx-keyup', handler);
|
|
97
|
+
return () => el.removeEventListener('cx-keyup', handler);
|
|
98
|
+
});
|
|
99
|
+
/** Opens the suggestion dropdown. */
|
|
100
|
+
export function open() { (el as any)?.open(); }
|
|
101
|
+
/** Closes the suggestion dropdown. */
|
|
102
|
+
export function close() { (el as any)?.close(); }
|
|
103
|
+
/** Clears all selections (multi-mode) or the input (single-mode). */
|
|
104
|
+
export function clear() { (el as any)?.clear(); }
|
|
105
|
+
/** Focuses the search input. */
|
|
106
|
+
export function focus() { (el as any)?.focus(); }
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<cx-autocomplete
|
|
110
|
+
bind:this={el}
|
|
111
|
+
id={typeof id === 'object' && id != null ? JSON.stringify(id) : id}
|
|
112
|
+
label={typeof label === 'object' && label != null ? JSON.stringify(label) : label}
|
|
113
|
+
variant={typeof variant === 'object' && variant != null ? JSON.stringify(variant) : variant}
|
|
114
|
+
shape={typeof shape === 'object' && shape != null ? JSON.stringify(shape) : shape}
|
|
115
|
+
size={typeof size === 'object' && size != null ? JSON.stringify(size) : size}
|
|
116
|
+
mode={typeof mode === 'object' && mode != null ? JSON.stringify(mode) : mode}
|
|
117
|
+
query={typeof query === 'object' && query != null ? JSON.stringify(query) : query}
|
|
118
|
+
placeholder={typeof placeholder === 'object' && placeholder != null ? JSON.stringify(placeholder) : placeholder}
|
|
119
|
+
helper-text={typeof helperText === 'object' && helperText != null ? JSON.stringify(helperText) : helperText}
|
|
120
|
+
error={typeof error === 'object' && error != null ? JSON.stringify(error) : error}
|
|
121
|
+
disabled={disabled || undefined}
|
|
122
|
+
required={required || undefined}
|
|
123
|
+
readonly={readonly || undefined}
|
|
124
|
+
allow-custom={allowCustom || undefined}
|
|
125
|
+
clearable={clearable || undefined}
|
|
126
|
+
/>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
import type { FocusDetail, InputDetail, KeyboardDetail, OptionGroup, SelectDetail, SelectOption } from './types.js';
|
|
4
|
+
|
|
5
|
+
interface AutocompleteProps {
|
|
6
|
+
id?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
variant?: 'outline' | 'filled' | 'ghost';
|
|
9
|
+
shape?: 'sharp' | 'rounded' | 'pill';
|
|
10
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
11
|
+
/** 'single' for single select, 'multiple' for multi-select with chips. */
|
|
12
|
+
mode?: 'single' | 'multiple';
|
|
13
|
+
selected?: string[] | string;
|
|
14
|
+
/** Current search query text. Controlled by onInput events. */
|
|
15
|
+
query?: string;
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
helperText?: string;
|
|
18
|
+
error?: string;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
readonly?: boolean;
|
|
22
|
+
name?: string;
|
|
23
|
+
/** When true, user can submit values not in the items list. */
|
|
24
|
+
allowCustom?: boolean;
|
|
25
|
+
clearable?: boolean;
|
|
26
|
+
/** Options to filter from. Filtering is client-side (fuzzy substring match). For server-side search, update this array in your onInput handler. */
|
|
27
|
+
items?: SelectOption[] | string;
|
|
28
|
+
groups?: OptionGroup[] | string;
|
|
29
|
+
onInput?: (event: CustomEvent<InputDetail>) => void;
|
|
30
|
+
onChange?: (event: CustomEvent<SelectDetail>) => void;
|
|
31
|
+
onFocus?: (event: CustomEvent<FocusDetail>) => void;
|
|
32
|
+
onBlur?: (event: CustomEvent<FocusDetail>) => void;
|
|
33
|
+
onKeydown?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
34
|
+
onKeyup?: (event: CustomEvent<KeyboardDetail>) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare const Autocomplete: Component<AutocompleteProps, {
|
|
38
|
+
/** Opens the suggestion dropdown. */
|
|
39
|
+
open(): void;
|
|
40
|
+
/** Closes the suggestion dropdown. */
|
|
41
|
+
close(): void;
|
|
42
|
+
/** Clears all selections (multi-mode) or the input (single-mode). */
|
|
43
|
+
clear(): void;
|
|
44
|
+
/** Focuses the search input. */
|
|
45
|
+
focus(): void;
|
|
46
|
+
}>;
|
|
47
|
+
export default Autocomplete;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!-- Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT -->
|
|
2
|
+
<!-- Svelte 5 wrapper for <cx-avatar> -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
id?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
shape?: 'circle' | 'rounded';
|
|
9
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
10
|
+
image?: string;
|
|
11
|
+
initials?: string;
|
|
12
|
+
clickable?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let { id, label, shape, size, image, initials, clickable }: Props = $props();
|
|
16
|
+
|
|
17
|
+
let el: HTMLElement;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<cx-avatar
|
|
24
|
+
bind:this={el}
|
|
25
|
+
id={typeof id === 'object' && id != null ? JSON.stringify(id) : id}
|
|
26
|
+
label={typeof label === 'object' && label != null ? JSON.stringify(label) : label}
|
|
27
|
+
shape={typeof shape === 'object' && shape != null ? JSON.stringify(shape) : shape}
|
|
28
|
+
size={typeof size === 'object' && size != null ? JSON.stringify(size) : size}
|
|
29
|
+
image={typeof image === 'object' && image != null ? JSON.stringify(image) : image}
|
|
30
|
+
initials={typeof initials === 'object' && initials != null ? JSON.stringify(initials) : initials}
|
|
31
|
+
clickable={clickable || undefined}
|
|
32
|
+
/>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface AvatarProps {
|
|
5
|
+
id?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
shape?: 'circle' | 'rounded';
|
|
8
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
9
|
+
image?: string;
|
|
10
|
+
initials?: string;
|
|
11
|
+
clickable?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare const Avatar: Component<AvatarProps, {}>;
|
|
15
|
+
export default Avatar;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<!-- Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT -->
|
|
2
|
+
<!-- Svelte 5 wrapper for <cx-backdrop> -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
tint?: string;
|
|
7
|
+
blur?: string;
|
|
8
|
+
dismissible?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { tint, blur, dismissible }: Props = $props();
|
|
12
|
+
|
|
13
|
+
let el: HTMLElement;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<cx-backdrop
|
|
20
|
+
bind:this={el}
|
|
21
|
+
tint={typeof tint === 'object' && tint != null ? JSON.stringify(tint) : tint}
|
|
22
|
+
blur={typeof blur === 'object' && blur != null ? JSON.stringify(blur) : blur}
|
|
23
|
+
dismissible={dismissible || undefined}
|
|
24
|
+
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface BackdropProps {
|
|
5
|
+
tint?: string;
|
|
6
|
+
blur?: string;
|
|
7
|
+
dismissible?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare const Backdrop: Component<BackdropProps, {}>;
|
|
11
|
+
export default Backdrop;
|
package/src/badge.svelte
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<!-- Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT -->
|
|
2
|
+
<!-- Svelte 5 wrapper for <cx-badge> -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
id?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
variant?: 'filled' | 'outline' | 'ghost';
|
|
9
|
+
intent?: 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
10
|
+
shape?: 'rounded' | 'pill';
|
|
11
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
12
|
+
dot?: boolean;
|
|
13
|
+
dismissible?: boolean;
|
|
14
|
+
dismissLabel?: string;
|
|
15
|
+
dynamic?: boolean;
|
|
16
|
+
onDismiss?: (event: CustomEvent) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let { id, label, variant, intent, shape, size, dot, dismissible, dismissLabel, dynamic, onDismiss }: Props = $props();
|
|
20
|
+
|
|
21
|
+
let el: HTMLElement;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
$effect(() => {
|
|
25
|
+
if (!el) return;
|
|
26
|
+
const handler = (e: Event) => onDismiss?.(e as CustomEvent);
|
|
27
|
+
el.addEventListener('cx-dismiss', handler);
|
|
28
|
+
return () => el.removeEventListener('cx-dismiss', handler);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<cx-badge
|
|
34
|
+
bind:this={el}
|
|
35
|
+
id={typeof id === 'object' && id != null ? JSON.stringify(id) : id}
|
|
36
|
+
label={typeof label === 'object' && label != null ? JSON.stringify(label) : label}
|
|
37
|
+
variant={typeof variant === 'object' && variant != null ? JSON.stringify(variant) : variant}
|
|
38
|
+
intent={typeof intent === 'object' && intent != null ? JSON.stringify(intent) : intent}
|
|
39
|
+
shape={typeof shape === 'object' && shape != null ? JSON.stringify(shape) : shape}
|
|
40
|
+
size={typeof size === 'object' && size != null ? JSON.stringify(size) : size}
|
|
41
|
+
dot={dot || undefined}
|
|
42
|
+
dismissible={dismissible || undefined}
|
|
43
|
+
dismiss-label={typeof dismissLabel === 'object' && dismissLabel != null ? JSON.stringify(dismissLabel) : dismissLabel}
|
|
44
|
+
dynamic={dynamic || undefined}
|
|
45
|
+
/>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT
|
|
2
|
+
import type { Component } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface BadgeProps {
|
|
5
|
+
id?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
variant?: 'filled' | 'outline' | 'ghost';
|
|
8
|
+
intent?: 'neutral' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
|
|
9
|
+
shape?: 'rounded' | 'pill';
|
|
10
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
11
|
+
dot?: boolean;
|
|
12
|
+
dismissible?: boolean;
|
|
13
|
+
dismissLabel?: string;
|
|
14
|
+
dynamic?: boolean;
|
|
15
|
+
onDismiss?: (event: CustomEvent) => void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare const Badge: Component<BadgeProps, {}>;
|
|
19
|
+
export default Badge;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<!-- Auto-generated by scripts/generate-svelte.mjs — DO NOT EDIT -->
|
|
2
|
+
<!-- Svelte 5 wrapper for <cx-breadcrumb> -->
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { BreadcrumbItem, NavigateDetail } from './types.js';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
id?: string;
|
|
8
|
+
items?: BreadcrumbItem[] | string;
|
|
9
|
+
separator?: string;
|
|
10
|
+
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
11
|
+
navLabel?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
onNavigate?: (event: CustomEvent<NavigateDetail>) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let { id, items, separator, size, navLabel, disabled, onNavigate }: Props = $props();
|
|
17
|
+
|
|
18
|
+
let el: HTMLElement;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
$effect(() => {
|
|
22
|
+
if (!el) return;
|
|
23
|
+
if (items != null) el.setAttribute('items', typeof items === 'object' ? JSON.stringify(items) : String(items));
|
|
24
|
+
else el.removeAttribute('items');
|
|
25
|
+
});
|
|
26
|
+
$effect(() => {
|
|
27
|
+
if (!el) return;
|
|
28
|
+
const handler = (e: Event) => onNavigate?.(e as CustomEvent);
|
|
29
|
+
el.addEventListener('cx-navigate', handler);
|
|
30
|
+
return () => el.removeEventListener('cx-navigate', handler);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<cx-breadcrumb
|
|
36
|
+
bind:this={el}
|
|
37
|
+
id={typeof id === 'object' && id != null ? JSON.stringify(id) : id}
|
|
38
|
+
separator={typeof separator === 'object' && separator != null ? JSON.stringify(separator) : separator}
|
|
39
|
+
size={typeof size === 'object' && size != null ? JSON.stringify(size) : size}
|
|
40
|
+
nav-label={typeof navLabel === 'object' && navLabel != null ? JSON.stringify(navLabel) : navLabel}
|
|
41
|
+
disabled={disabled || undefined}
|
|
42
|
+
/>
|