@skeletonlabs/skeleton-svelte 1.0.0-next.9 → 1.1.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 +1 -1
- package/dist/components/Accordion/Accordion.svelte +49 -52
- package/dist/components/Accordion/Accordion.svelte.d.ts +2 -14
- package/dist/components/Accordion/AccordionItem.svelte +43 -37
- package/dist/components/Accordion/AccordionItem.svelte.d.ts +2 -14
- package/dist/components/Accordion/context.js +2 -1
- package/dist/components/Accordion/index.d.ts +4 -0
- package/dist/components/Accordion/index.js +1 -1
- package/dist/components/Accordion/types.d.ts +7 -9
- package/dist/components/AppBar/AppBar.svelte +43 -40
- package/dist/components/AppBar/AppBar.svelte.d.ts +2 -14
- package/dist/components/Avatar/Avatar.svelte +56 -44
- package/dist/components/Avatar/Avatar.svelte.d.ts +2 -14
- package/dist/components/Avatar/types.d.ts +3 -3
- package/dist/components/Combobox/Combobox.svelte +144 -0
- package/dist/components/Combobox/Combobox.svelte.d.ts +18 -0
- package/dist/components/Combobox/types.d.ts +64 -0
- package/dist/components/Combobox/types.js +1 -0
- package/dist/components/FileUpload/FileUpload.svelte +70 -63
- package/dist/components/FileUpload/FileUpload.svelte.d.ts +2 -14
- package/dist/components/FileUpload/types.d.ts +3 -4
- package/dist/components/Modal/Modal.svelte +87 -0
- package/dist/components/Modal/Modal.svelte.d.ts +4 -0
- package/dist/components/Modal/types.d.ts +57 -0
- package/dist/components/Modal/types.js +1 -0
- package/dist/components/Navigation/NavBar.svelte +48 -0
- package/dist/components/Navigation/NavBar.svelte.d.ts +5 -0
- package/dist/components/Navigation/NavRail.svelte +90 -0
- package/dist/components/Navigation/NavRail.svelte.d.ts +5 -0
- package/dist/components/Navigation/NavTile.svelte +87 -0
- package/dist/components/Navigation/NavTile.svelte.d.ts +5 -0
- package/dist/components/Navigation/context.js +7 -0
- package/dist/components/Navigation/index.d.ts +6 -0
- package/dist/components/{Nav → Navigation}/index.js +1 -1
- package/dist/components/{Nav → Navigation}/types.d.ts +5 -3
- package/dist/components/Pagination/Pagination.svelte +58 -67
- package/dist/components/Pagination/Pagination.svelte.d.ts +2 -14
- package/dist/components/Pagination/types.d.ts +15 -15
- package/dist/components/Popover/Popover.svelte +78 -0
- package/dist/components/Popover/Popover.svelte.d.ts +4 -0
- package/dist/components/Popover/types.d.ts +42 -0
- package/dist/components/Popover/types.js +1 -0
- package/dist/components/Progress/Progress.svelte +44 -38
- package/dist/components/Progress/Progress.svelte.d.ts +2 -14
- package/dist/components/Progress/types.d.ts +1 -1
- package/dist/components/ProgressRing/ProgressRing.svelte +58 -46
- package/dist/components/ProgressRing/ProgressRing.svelte.d.ts +2 -14
- package/dist/components/ProgressRing/types.d.ts +3 -1
- package/dist/components/Rating/Rating.svelte +101 -57
- package/dist/components/Rating/Rating.svelte.d.ts +2 -14
- package/dist/components/Rating/types.d.ts +1 -5
- package/dist/components/Segment/Segment.svelte +59 -61
- package/dist/components/Segment/Segment.svelte.d.ts +3 -15
- package/dist/components/Segment/SegmentItem.svelte +28 -21
- package/dist/components/Segment/SegmentItem.svelte.d.ts +2 -14
- package/dist/components/Segment/context.js +3 -2
- package/dist/components/Segment/index.d.ts +4 -0
- package/dist/components/Segment/index.js +1 -1
- package/dist/components/Segment/types.d.ts +8 -10
- package/dist/components/Slider/Slider.svelte +67 -72
- package/dist/components/Slider/Slider.svelte.d.ts +2 -14
- package/dist/components/Slider/types.d.ts +5 -9
- package/dist/components/Switch/Switch.svelte +75 -90
- package/dist/components/Switch/Switch.svelte.d.ts +2 -14
- package/dist/components/Switch/types.d.ts +2 -8
- package/dist/components/Tabs/Tabs.svelte +59 -0
- package/dist/components/Tabs/Tabs.svelte.d.ts +5 -0
- package/dist/components/Tabs/TabsControl.svelte +51 -0
- package/dist/components/Tabs/TabsControl.svelte.d.ts +5 -0
- package/dist/components/Tabs/TabsPanel.svelte +23 -0
- package/dist/components/Tabs/TabsPanel.svelte.d.ts +5 -0
- package/dist/components/{Tab → Tabs}/context.js +3 -2
- package/dist/components/Tabs/index.d.ts +5 -0
- package/dist/components/{Tab → Tabs}/index.js +1 -1
- package/dist/components/{Tab → Tabs}/types.d.ts +1 -3
- package/dist/components/TagsInput/TagsInput.svelte +48 -54
- package/dist/components/TagsInput/TagsInput.svelte.d.ts +2 -14
- package/dist/components/TagsInput/types.d.ts +3 -7
- package/dist/components/Toast/Toast.svelte +68 -0
- package/dist/components/Toast/Toast.svelte.d.ts +4 -0
- package/dist/components/Toast/Toaster.svelte +68 -0
- package/dist/components/Toast/Toaster.svelte.d.ts +4 -0
- package/dist/components/Toast/create-toaster.d.ts +2 -0
- package/dist/components/Toast/create-toaster.js +5 -0
- package/dist/components/Toast/types.d.ts +43 -0
- package/dist/components/Toast/types.js +1 -0
- package/dist/components/Tooltip/Tooltip.svelte +79 -0
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +4 -0
- package/dist/components/Tooltip/types.d.ts +44 -0
- package/dist/components/Tooltip/types.js +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.js +12 -3
- package/dist/internal/create-context.d.ts +6 -0
- package/dist/internal/create-context.js +3 -3
- package/dist/internal/test-utils.d.ts +3 -0
- package/dist/internal/test-utils.js +9 -0
- package/package.json +43 -54
- package/dist/components/Accordion/Accordion.svelte.spec.d.ts +0 -1
- package/dist/components/Accordion/Accordion.svelte.spec.js +0 -4
- package/dist/components/Nav/NavBar.svelte +0 -45
- package/dist/components/Nav/NavBar.svelte.d.ts +0 -17
- package/dist/components/Nav/NavRail.svelte +0 -79
- package/dist/components/Nav/NavRail.svelte.d.ts +0 -17
- package/dist/components/Nav/NavTile.svelte +0 -76
- package/dist/components/Nav/NavTile.svelte.d.ts +0 -17
- package/dist/components/Nav/context.js +0 -7
- package/dist/components/Tab/Tabs.svelte +0 -65
- package/dist/components/Tab/Tabs.svelte.d.ts +0 -17
- package/dist/components/Tab/TabsControl.svelte +0 -42
- package/dist/components/Tab/TabsControl.svelte.d.ts +0 -17
- package/dist/components/Tab/TabsPanel.svelte +0 -18
- package/dist/components/Tab/TabsPanel.svelte.d.ts +0 -17
- package/dist/internal/noop.d.ts +0 -1
- package/dist/internal/noop.js +0 -2
- package/dist/internal/snippets.d.ts +0 -3
- package/dist/internal/snippets.js +0 -45
- package/dist/internal/use-id.d.ts +0 -2
- package/dist/internal/use-id.js +0 -5
- /package/dist/components/{Nav → Navigation}/context.d.ts +0 -0
- /package/dist/components/{Nav → Navigation}/types.js +0 -0
- /package/dist/components/{Tab → Tabs}/context.d.ts +0 -0
- /package/dist/components/{Tab → Tabs}/types.js +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<script lang="ts" generics="T extends ComboboxItem">
|
|
2
|
+
import { fade } from 'svelte/transition';
|
|
3
|
+
import * as combobox from '@zag-js/combobox';
|
|
4
|
+
import { useMachine, normalizeProps, mergeProps } from '@zag-js/svelte';
|
|
5
|
+
import type { ComboboxProps, ComboboxItem } from './types.js';
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
data = [],
|
|
9
|
+
label = '',
|
|
10
|
+
zIndex = 'auto',
|
|
11
|
+
// Base
|
|
12
|
+
base = '',
|
|
13
|
+
width = '',
|
|
14
|
+
classes = '',
|
|
15
|
+
// Label
|
|
16
|
+
labelBase = 'label',
|
|
17
|
+
labelText = 'label-text',
|
|
18
|
+
labelClasses = '',
|
|
19
|
+
// Input
|
|
20
|
+
inputGroupBase = 'input-group grid-cols-[1fr_auto]',
|
|
21
|
+
inputGroupInput = 'ig-input',
|
|
22
|
+
inputGroupButton = 'ig-btn hover:preset-tonal',
|
|
23
|
+
inputGroupArrow = '',
|
|
24
|
+
inputGroupClasses = '',
|
|
25
|
+
// Positioner
|
|
26
|
+
positionerBase = '',
|
|
27
|
+
positionerClasses = '',
|
|
28
|
+
// Content
|
|
29
|
+
contentBase = 'card p-2',
|
|
30
|
+
contentBackground = 'preset-outlined-surface-200-800 bg-surface-50-950',
|
|
31
|
+
contentSpaceY = 'space-y-1',
|
|
32
|
+
contentClasses = '',
|
|
33
|
+
// Option
|
|
34
|
+
optionBase = 'btn justify-start w-full',
|
|
35
|
+
optionHover = 'hover:preset-tonal',
|
|
36
|
+
optionActive = 'preset-filled-primary-500',
|
|
37
|
+
optionClasses = '',
|
|
38
|
+
// Snippets
|
|
39
|
+
arrow,
|
|
40
|
+
item,
|
|
41
|
+
// Events
|
|
42
|
+
onclick,
|
|
43
|
+
// Zag ---
|
|
44
|
+
...zagProps
|
|
45
|
+
}: ComboboxProps<T> = $props();
|
|
46
|
+
|
|
47
|
+
// Zag
|
|
48
|
+
let options = $state.raw(data);
|
|
49
|
+
const collection = $derived(
|
|
50
|
+
combobox.collection({
|
|
51
|
+
items: data,
|
|
52
|
+
// Map data structure
|
|
53
|
+
itemToValue: (item) => item.value,
|
|
54
|
+
itemToString: (item) => item.label
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const id = $props.id();
|
|
59
|
+
const service = useMachine(combobox.machine, () => ({
|
|
60
|
+
id: id,
|
|
61
|
+
collection: collection,
|
|
62
|
+
...zagProps,
|
|
63
|
+
onOpenChange(event) {
|
|
64
|
+
options = data;
|
|
65
|
+
zagProps.onOpenChange?.(event);
|
|
66
|
+
},
|
|
67
|
+
onInputValueChange(event) {
|
|
68
|
+
const filtered = data.filter((item) => item.label.toLowerCase().includes(event.inputValue.toLowerCase()));
|
|
69
|
+
collection.setItems(filtered);
|
|
70
|
+
options = filtered;
|
|
71
|
+
zagProps.onInputValueChange?.(event);
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
const api = $derived(combobox.connect(service, normalizeProps));
|
|
75
|
+
const triggerProps = $derived(mergeProps(api.getTriggerProps(), { onclick }));
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<span {...api.getRootProps()} class="{base} {width} {classes}" data-testid="combobox">
|
|
79
|
+
<!-- Label -->
|
|
80
|
+
<label {...api.getLabelProps()} class="{labelBase} {labelClasses}">
|
|
81
|
+
{#if label}<span class={labelText}>{label}</span>{/if}
|
|
82
|
+
<!-- Input Group -->
|
|
83
|
+
<div {...api.getControlProps()} class="{inputGroupBase} {inputGroupClasses}">
|
|
84
|
+
<!-- Input -->
|
|
85
|
+
<input {...api.getInputProps()} class={inputGroupInput} />
|
|
86
|
+
<!-- Arrow -->
|
|
87
|
+
<button {...triggerProps} class={inputGroupButton}>
|
|
88
|
+
{#if arrow}
|
|
89
|
+
{@render arrow()}
|
|
90
|
+
{:else}
|
|
91
|
+
<svg
|
|
92
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
93
|
+
width="16"
|
|
94
|
+
height="16"
|
|
95
|
+
viewBox="0 0 24 24"
|
|
96
|
+
fill="none"
|
|
97
|
+
stroke="currentColor"
|
|
98
|
+
stroke-width="2"
|
|
99
|
+
stroke-linecap="round"
|
|
100
|
+
stroke-linejoin="round"
|
|
101
|
+
style="opacity: 0.5"
|
|
102
|
+
class={inputGroupArrow}
|
|
103
|
+
>
|
|
104
|
+
<path d="m6 9 6 6 6-6" />
|
|
105
|
+
</svg>
|
|
106
|
+
{/if}
|
|
107
|
+
</button>
|
|
108
|
+
</div>
|
|
109
|
+
</label>
|
|
110
|
+
<!-- Menu -->
|
|
111
|
+
{#if api.open}
|
|
112
|
+
<div {...api.getPositionerProps()} transition:fade={{ duration: 100 }} class="{positionerBase} {positionerClasses}">
|
|
113
|
+
{#if options.length > 0}
|
|
114
|
+
<!-- Content (list) -->
|
|
115
|
+
<nav
|
|
116
|
+
{...api.getContentProps()}
|
|
117
|
+
class="{contentBase} {contentBackground} {contentSpaceY} {contentClasses}"
|
|
118
|
+
style="z-index: {zIndex}"
|
|
119
|
+
>
|
|
120
|
+
{#each options as option (option.label)}
|
|
121
|
+
{@const isChecked = api.getItemProps({ item: option })['data-state'] === 'checked'}
|
|
122
|
+
{@const displayClass = isChecked ? optionActive : optionHover}
|
|
123
|
+
<!-- Option -->
|
|
124
|
+
<!-- ZagJs should have set button type to "button" here. -->
|
|
125
|
+
<!-- See https://github.com/skeletonlabs/skeleton/pull/2998#discussion_r1855511385 -->
|
|
126
|
+
<button {...api.getItemProps({ item: option })} class="{optionBase} {displayClass} {optionClasses}" type="button">
|
|
127
|
+
{#if item}
|
|
128
|
+
{@render item(option)}
|
|
129
|
+
{:else}
|
|
130
|
+
{option.label}
|
|
131
|
+
{/if}
|
|
132
|
+
</button>
|
|
133
|
+
{/each}
|
|
134
|
+
</nav>
|
|
135
|
+
{/if}
|
|
136
|
+
</div>
|
|
137
|
+
{/if}
|
|
138
|
+
</span>
|
|
139
|
+
|
|
140
|
+
<style>
|
|
141
|
+
[data-part='item'][data-highlighted]:not([data-state='checked']) {
|
|
142
|
+
background-color: var(--color-surface-200-800);
|
|
143
|
+
}
|
|
144
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ComboboxProps, ComboboxItem } from './types.js';
|
|
2
|
+
declare class __sveltets_Render<T extends ComboboxItem> {
|
|
3
|
+
props(): ComboboxProps<T>;
|
|
4
|
+
events(): {};
|
|
5
|
+
slots(): {};
|
|
6
|
+
bindings(): "";
|
|
7
|
+
exports(): {};
|
|
8
|
+
}
|
|
9
|
+
interface $$IsomorphicComponent {
|
|
10
|
+
new <T extends ComboboxItem>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
11
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
12
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
13
|
+
<T extends ComboboxItem>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
14
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
15
|
+
}
|
|
16
|
+
declare const Combobox: $$IsomorphicComponent;
|
|
17
|
+
type Combobox<T extends ComboboxItem> = InstanceType<typeof Combobox<T>>;
|
|
18
|
+
export default Combobox;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import * as combobox from '@zag-js/combobox';
|
|
3
|
+
export interface ComboboxProps<T extends ComboboxItem> extends Omit<combobox.Props, 'id' | 'collection'> {
|
|
4
|
+
/** Provide the list of label and value data */
|
|
5
|
+
data?: T[];
|
|
6
|
+
/** Set the label to display. */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** Set z-index for the positioner. */
|
|
9
|
+
zIndex?: string;
|
|
10
|
+
/** Set base classes for the root element. */
|
|
11
|
+
base?: string;
|
|
12
|
+
/** Set width classes for the root element. */
|
|
13
|
+
width?: string;
|
|
14
|
+
/** Provide arbitrary classes for the root element. */
|
|
15
|
+
classes?: string;
|
|
16
|
+
/** Set base classes for the label. */
|
|
17
|
+
labelBase?: string;
|
|
18
|
+
/** Set text and font classes for the label. */
|
|
19
|
+
labelText?: string;
|
|
20
|
+
/** Provide arbitrary classes for the label. */
|
|
21
|
+
labelClasses?: string;
|
|
22
|
+
/** Set base classes for the input group. */
|
|
23
|
+
inputGroupBase?: string;
|
|
24
|
+
/** Set input classes for the input group. */
|
|
25
|
+
inputGroupInput?: string;
|
|
26
|
+
/** Set button classes for the input group. */
|
|
27
|
+
inputGroupButton?: string;
|
|
28
|
+
/** Set arrow classes for the input group. */
|
|
29
|
+
inputGroupArrow?: string;
|
|
30
|
+
/** Provide arbitrary classes for the input group. */
|
|
31
|
+
inputGroupClasses?: string;
|
|
32
|
+
/** Set base classes for the positioner. */
|
|
33
|
+
positionerBase?: string;
|
|
34
|
+
/** Provide arbitrary classes for the positioner. */
|
|
35
|
+
positionerClasses?: string;
|
|
36
|
+
/** Set base classes for the content. */
|
|
37
|
+
contentBase?: string;
|
|
38
|
+
/** Set background classes for the content. */
|
|
39
|
+
contentBackground?: string;
|
|
40
|
+
/** Set space-y classes for the content. */
|
|
41
|
+
contentSpaceY?: string;
|
|
42
|
+
/** Provide arbitrary classes for the content. */
|
|
43
|
+
contentClasses?: string;
|
|
44
|
+
/** Set base classes for the option. */
|
|
45
|
+
optionBase?: string;
|
|
46
|
+
/** Set focus classes for the option. */
|
|
47
|
+
optionFocus?: string;
|
|
48
|
+
/** Set hover classes for the option. */
|
|
49
|
+
optionHover?: string;
|
|
50
|
+
/** Set active classes for the option. */
|
|
51
|
+
optionActive?: string;
|
|
52
|
+
/** Provide arbitrary classes for the option. */
|
|
53
|
+
optionClasses?: string;
|
|
54
|
+
/** Provide a custom arrow icon. */
|
|
55
|
+
arrow?: Snippet;
|
|
56
|
+
/** Provide a custom template for the option. */
|
|
57
|
+
item?: Snippet<[T]>;
|
|
58
|
+
/** Handle the combobox dropdown button click event. */
|
|
59
|
+
onclick?: (event: Event) => void;
|
|
60
|
+
}
|
|
61
|
+
export interface ComboboxItem {
|
|
62
|
+
label: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as combobox from '@zag-js/combobox';
|
|
@@ -1,65 +1,72 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
);
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import * as fileUpload from '@zag-js/file-upload';
|
|
3
|
+
import { useMachine, normalizeProps } from '@zag-js/svelte';
|
|
4
|
+
|
|
5
|
+
import type { FileUploadProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
// Props
|
|
8
|
+
const {
|
|
9
|
+
label = `Select file or drag here`,
|
|
10
|
+
subtext = '',
|
|
11
|
+
// Root
|
|
12
|
+
base = '',
|
|
13
|
+
classes = '',
|
|
14
|
+
// Interface
|
|
15
|
+
interfaceBase = 'flex flex-col items-center gap-2 hover:cursor-pointer',
|
|
16
|
+
interfaceBg = 'hover:preset-tonal',
|
|
17
|
+
interfaceBorder = 'border-[1px] border-dashed',
|
|
18
|
+
interfaceBorderColor = 'border-surface-200-800',
|
|
19
|
+
interfacePadding = 'p-4 py-10',
|
|
20
|
+
interfaceRounded = 'rounded-container',
|
|
21
|
+
interfaceClasses = '',
|
|
22
|
+
// Interface (content)
|
|
23
|
+
interfaceIcon = '',
|
|
24
|
+
interfaceText = '',
|
|
25
|
+
interfaceSubtext = 'text-xs opacity-60',
|
|
26
|
+
// Files List
|
|
27
|
+
filesListBase = 'mt-2 space-y-2',
|
|
28
|
+
filesListClasses = '',
|
|
29
|
+
// File
|
|
30
|
+
fileBase = 'grid grid-cols-[auto_1fr_auto] rtl:grid-cols-[1fr_auto_auto] items-center',
|
|
31
|
+
fileBg = 'preset-tonal',
|
|
32
|
+
fileGap = 'gap-4 px-4',
|
|
33
|
+
filePadding = 'py-2',
|
|
34
|
+
fileRounded = 'rounded-base',
|
|
35
|
+
fileClasses = '',
|
|
36
|
+
// File (content)
|
|
37
|
+
fileIcon = '',
|
|
38
|
+
fileName = 'text-sm flex items-center gap-4',
|
|
39
|
+
fileSize = 'text-xs opacity-60',
|
|
40
|
+
fileButton = '',
|
|
41
|
+
// State
|
|
42
|
+
stateInvalid = 'border-error-500',
|
|
43
|
+
stateDisabled = 'disabled',
|
|
44
|
+
stateDragging = 'preset-filled-primary-500',
|
|
45
|
+
// Children
|
|
46
|
+
children,
|
|
47
|
+
iconInterface,
|
|
48
|
+
iconFile,
|
|
49
|
+
iconFileRemove,
|
|
50
|
+
// Zag
|
|
51
|
+
...zagProps
|
|
52
|
+
}: FileUploadProps = $props();
|
|
53
|
+
|
|
54
|
+
// Zag
|
|
55
|
+
const id = $props.id();
|
|
56
|
+
const service = useMachine(fileUpload.machine, () => ({
|
|
57
|
+
id: id,
|
|
58
|
+
...zagProps
|
|
59
|
+
}));
|
|
60
|
+
const api = $derived(fileUpload.connect(service, normalizeProps));
|
|
61
|
+
|
|
62
|
+
$effect.pre(() => {
|
|
63
|
+
zagProps.onApiReady?.(api);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Reactive
|
|
67
|
+
const rxDisabled = $derived(service.prop('disabled') ? stateDisabled : '');
|
|
68
|
+
const rxInvalid = $derived(api.rejectedFiles.length > 0 ? stateInvalid : interfaceBorderColor);
|
|
69
|
+
const rxDragging = $derived(api.dragging && !children ? stateDragging : '');
|
|
63
70
|
</script>
|
|
64
71
|
|
|
65
72
|
<!-- @component A form component for handling file uploads. -->
|
|
@@ -94,7 +101,7 @@ const rxDragging = $derived(api.dragging && !children ? stateDragging : "");
|
|
|
94
101
|
{#if !children}
|
|
95
102
|
<ul {...api.getItemGroupProps()} class="{filesListBase} {filesListClasses}" data-testid="uploader-files-list">
|
|
96
103
|
<!-- Loop Files -->
|
|
97
|
-
{#each api.acceptedFiles as file}
|
|
104
|
+
{#each api.acceptedFiles as file (file)}
|
|
98
105
|
<!-- File -->
|
|
99
106
|
<li
|
|
100
107
|
{...api.getItemProps({ file })}
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import type { FileUploadProps } from './types.js';
|
|
2
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
-
$$bindings?: Bindings;
|
|
5
|
-
} & Exports;
|
|
6
|
-
(internal: unknown, props: Props & {
|
|
7
|
-
$$events?: Events;
|
|
8
|
-
$$slots?: Slots;
|
|
9
|
-
}): Exports;
|
|
10
|
-
z_$$bindings?: Bindings;
|
|
11
|
-
}
|
|
12
2
|
/** A form component for handling file uploads. */
|
|
13
|
-
declare const FileUpload:
|
|
14
|
-
|
|
15
|
-
}, {}, {}, "internalApi">;
|
|
16
|
-
type FileUpload = InstanceType<typeof FileUpload>;
|
|
3
|
+
declare const FileUpload: import("svelte").Component<FileUploadProps, {}, "">;
|
|
4
|
+
type FileUpload = ReturnType<typeof FileUpload>;
|
|
17
5
|
export default FileUpload;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import * as fileUpload from '@zag-js/file-upload';
|
|
3
3
|
import type { PropTypes } from '@zag-js/svelte';
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
export interface FileUploadProps extends Omit<fileUpload.Context, 'id' | 'value'> {
|
|
4
|
+
export type FileUploadApi = fileUpload.Api<PropTypes>;
|
|
5
|
+
export interface FileUploadProps extends Omit<fileUpload.Props, 'id'> {
|
|
7
6
|
/** Set the interface text value. */
|
|
8
7
|
label?: string;
|
|
9
8
|
/** Set the interface subtext value. */
|
|
@@ -71,5 +70,5 @@ export interface FileUploadProps extends Omit<fileUpload.Context, 'id' | 'value'
|
|
|
71
70
|
/** Provide an icon for the remove file action. */
|
|
72
71
|
iconFileRemove?: Snippet;
|
|
73
72
|
/** Binds the Zag API for external use. */
|
|
74
|
-
|
|
73
|
+
onApiReady?: (api: FileUploadApi) => void;
|
|
75
74
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { fly, fade } from 'svelte/transition';
|
|
3
|
+
import * as dialog from '@zag-js/dialog';
|
|
4
|
+
import { portal, normalizeProps, useMachine, mergeProps } from '@zag-js/svelte';
|
|
5
|
+
import type { ModalProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
// Base
|
|
9
|
+
base = '',
|
|
10
|
+
classes = '',
|
|
11
|
+
zIndex = 'auto',
|
|
12
|
+
// Trigger
|
|
13
|
+
triggerBase = '',
|
|
14
|
+
triggerBackground = '',
|
|
15
|
+
triggerClasses = '',
|
|
16
|
+
triggerAriaLabel = '',
|
|
17
|
+
// Backdrop
|
|
18
|
+
backdropBase = 'fixed top-0 left-0 right-0 bottom-0 z-[998]',
|
|
19
|
+
backdropBackground = 'bg-surface-50/75 dark:bg-surface-950/75',
|
|
20
|
+
backdropClasses = '',
|
|
21
|
+
// Positioner
|
|
22
|
+
positionerBase = 'fixed top-0 left-0 right-0 bottom-0 z-[999]',
|
|
23
|
+
positionerDisplay = 'flex',
|
|
24
|
+
positionerJustify = 'justify-center',
|
|
25
|
+
positionerAlign = 'items-center',
|
|
26
|
+
positionerPadding = 'p-4',
|
|
27
|
+
positionerClasses = '',
|
|
28
|
+
// Content
|
|
29
|
+
contentBase = '',
|
|
30
|
+
contentBackground = '',
|
|
31
|
+
contentClasses = '',
|
|
32
|
+
// Transitions
|
|
33
|
+
transitionsBackdropIn = { duration: 100 },
|
|
34
|
+
transitionsBackdropOut = { duration: 100 },
|
|
35
|
+
transitionsPositionerIn = { y: 50, duration: 200 },
|
|
36
|
+
transitionsPositionerOut = { y: 50, duration: 200 },
|
|
37
|
+
// Snippets
|
|
38
|
+
trigger,
|
|
39
|
+
content,
|
|
40
|
+
// Events
|
|
41
|
+
onclick,
|
|
42
|
+
// Zag ---
|
|
43
|
+
...zagProps
|
|
44
|
+
}: ModalProps = $props();
|
|
45
|
+
|
|
46
|
+
// Zag
|
|
47
|
+
const id = $props.id();
|
|
48
|
+
const service = useMachine(dialog.machine, () => ({
|
|
49
|
+
id: id,
|
|
50
|
+
...zagProps
|
|
51
|
+
}));
|
|
52
|
+
const api = $derived(dialog.connect(service, normalizeProps));
|
|
53
|
+
const triggerProps = $derived(mergeProps(api.getTriggerProps(), { onclick }));
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<span class="{base} {classes}" data-testid="modal">
|
|
57
|
+
<!-- Trigger -->
|
|
58
|
+
{#if trigger}
|
|
59
|
+
<button {...triggerProps} class="{triggerBase} {triggerBackground} {triggerClasses}" type="button" aria-label={triggerAriaLabel}>
|
|
60
|
+
{@render trigger()}
|
|
61
|
+
</button>
|
|
62
|
+
{/if}
|
|
63
|
+
|
|
64
|
+
{#if api.open}
|
|
65
|
+
<!-- Backdrop -->
|
|
66
|
+
<div
|
|
67
|
+
use:portal
|
|
68
|
+
{...api.getBackdropProps()}
|
|
69
|
+
class="{backdropBase} {backdropBackground} {backdropClasses}"
|
|
70
|
+
in:fade={transitionsBackdropIn}
|
|
71
|
+
out:fade={transitionsBackdropOut}
|
|
72
|
+
></div>
|
|
73
|
+
<!-- Positioner -->
|
|
74
|
+
<div
|
|
75
|
+
use:portal
|
|
76
|
+
{...api.getPositionerProps()}
|
|
77
|
+
class="{positionerBase} {positionerDisplay} {positionerJustify} {positionerAlign} {positionerPadding} {positionerClasses}"
|
|
78
|
+
in:fly={transitionsPositionerIn}
|
|
79
|
+
out:fly={transitionsPositionerOut}
|
|
80
|
+
>
|
|
81
|
+
<!-- Content -->
|
|
82
|
+
<div {...api.getContentProps()} class="{contentBase} {contentBackground} {contentClasses}" style="z-index: {zIndex};">
|
|
83
|
+
{@render content?.()}
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
{/if}
|
|
87
|
+
</span>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import * as dialog from '@zag-js/dialog';
|
|
3
|
+
import type { FlyParams, FadeParams } from 'svelte/transition';
|
|
4
|
+
export interface ModalProps extends Omit<dialog.Props, 'id'> {
|
|
5
|
+
/** Set base classes for the root element. */
|
|
6
|
+
base?: string;
|
|
7
|
+
/** Provide arbitrary classes for the root element. */
|
|
8
|
+
classes?: string;
|
|
9
|
+
/** Set z-index for the positioner. */
|
|
10
|
+
zIndex?: string;
|
|
11
|
+
/** Set base classes for the trigger. */
|
|
12
|
+
triggerBase?: string;
|
|
13
|
+
/** Set background classes for the trigger. */
|
|
14
|
+
triggerBackground?: string;
|
|
15
|
+
/** Provide arbitrary classes for the trigger. */
|
|
16
|
+
triggerClasses?: string;
|
|
17
|
+
/** Set the aria-label for the trigger. */
|
|
18
|
+
triggerAriaLabel?: string;
|
|
19
|
+
/** Set base classes for the backdrop. */
|
|
20
|
+
backdropBase?: string;
|
|
21
|
+
/** Set background classes for the backdrop. */
|
|
22
|
+
backdropBackground?: string;
|
|
23
|
+
/** Provide arbitrary classes for the backdrop. */
|
|
24
|
+
backdropClasses?: string;
|
|
25
|
+
/** Set base classes for the positioner. */
|
|
26
|
+
positionerBase?: string;
|
|
27
|
+
/** Set display classes for the positioner. */
|
|
28
|
+
positionerDisplay?: string;
|
|
29
|
+
/** Set justify classes for the positioner. */
|
|
30
|
+
positionerJustify?: string;
|
|
31
|
+
/** Set align classes for the positioner. */
|
|
32
|
+
positionerAlign?: string;
|
|
33
|
+
/** Set padding classes for the positioner. */
|
|
34
|
+
positionerPadding?: string;
|
|
35
|
+
/** Provide arbitrary classes for the positioner. */
|
|
36
|
+
positionerClasses?: string;
|
|
37
|
+
/** Set base classes for the content. */
|
|
38
|
+
contentBase?: string;
|
|
39
|
+
/** Set background classes for the content. */
|
|
40
|
+
contentBackground?: string;
|
|
41
|
+
/** Provide arbitrary classes for the content. */
|
|
42
|
+
contentClasses?: string;
|
|
43
|
+
/** Provide transition for backdrop in */
|
|
44
|
+
transitionsBackdropIn?: FadeParams;
|
|
45
|
+
/** Provide transition for backdrop out */
|
|
46
|
+
transitionsBackdropOut?: FadeParams;
|
|
47
|
+
/** Provide transition for dialog in */
|
|
48
|
+
transitionsPositionerIn?: FlyParams;
|
|
49
|
+
/** Provide transition for dialog out */
|
|
50
|
+
transitionsPositionerOut?: FlyParams;
|
|
51
|
+
/** Provide the template contents inside the trigger button. */
|
|
52
|
+
trigger?: Snippet;
|
|
53
|
+
/** Provide the template contents of the dialog itself. */
|
|
54
|
+
content?: Snippet;
|
|
55
|
+
/** Handle the dialog button click event. */
|
|
56
|
+
onclick?: () => void;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import * as dialog from '@zag-js/dialog';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { NavBarProps } from './types.js';
|
|
3
|
+
import { setNavigationContext } from './context.js';
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
value,
|
|
7
|
+
// Root
|
|
8
|
+
base = 'flex flex-col',
|
|
9
|
+
background = 'preset-filled-surface-100-900',
|
|
10
|
+
width = 'min-w-[320px] w-full',
|
|
11
|
+
height = 'h-20',
|
|
12
|
+
padding = 'p-1',
|
|
13
|
+
classes = '',
|
|
14
|
+
// Tiles
|
|
15
|
+
tilesBase = 'flex-1 flex',
|
|
16
|
+
tilesFlexDirection = '',
|
|
17
|
+
tilesJustify = 'justify-center',
|
|
18
|
+
tilesItems = 'items-center',
|
|
19
|
+
tilesGap = 'gap-1',
|
|
20
|
+
tilesClasses = '',
|
|
21
|
+
// Events
|
|
22
|
+
onValueChange,
|
|
23
|
+
// Snippets
|
|
24
|
+
children
|
|
25
|
+
}: NavBarProps = $props();
|
|
26
|
+
|
|
27
|
+
// Context
|
|
28
|
+
setNavigationContext({
|
|
29
|
+
parent: 'bar',
|
|
30
|
+
get value() {
|
|
31
|
+
return value;
|
|
32
|
+
},
|
|
33
|
+
expanded: false,
|
|
34
|
+
get onValueChange() {
|
|
35
|
+
return onValueChange;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<!-- @component Provides a horizontal navigation interface. -->
|
|
41
|
+
|
|
42
|
+
<aside class="{base} {background} {width} {height} {padding} {classes}" data-testid="nav-bar">
|
|
43
|
+
{#if children}
|
|
44
|
+
<nav class="{tilesBase} {tilesFlexDirection} {tilesJustify} {tilesItems} {tilesGap} {tilesClasses}" data-testid="nav-bar-tileset">
|
|
45
|
+
{@render children()}
|
|
46
|
+
</nav>
|
|
47
|
+
{/if}
|
|
48
|
+
</aside>
|