@skeletonlabs/skeleton-svelte 1.0.0-next.20 → 1.0.0-next.22
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/dist/components/Accordion/Accordion.svelte +12 -24
- package/dist/components/Accordion/Accordion.svelte.d.ts +1 -1
- package/dist/components/Accordion/AccordionItem.svelte +3 -3
- package/dist/components/Accordion/context.js +2 -1
- package/dist/components/Accordion/index.d.ts +1 -1
- package/dist/components/Accordion/index.js +1 -1
- package/dist/components/Accordion/types.d.ts +7 -9
- package/dist/components/AppBar/AppBar.svelte +1 -1
- package/dist/components/Avatar/Avatar.svelte +20 -20
- package/dist/components/Avatar/types.d.ts +3 -5
- package/dist/components/Combobox/Combobox.svelte +44 -57
- package/dist/components/Combobox/Combobox.svelte.d.ts +17 -3
- package/dist/components/Combobox/types.d.ts +10 -11
- package/dist/components/FileUpload/FileUpload.svelte +15 -18
- package/dist/components/FileUpload/FileUpload.svelte.d.ts +1 -1
- package/dist/components/FileUpload/types.d.ts +2 -2
- package/dist/components/Modal/Modal.svelte +9 -31
- package/dist/components/Modal/Modal.svelte.d.ts +1 -1
- package/dist/components/Modal/types.d.ts +3 -7
- package/dist/components/Navigation/NavBar.svelte +6 -9
- package/dist/components/Navigation/NavBar.svelte.d.ts +1 -1
- package/dist/components/Navigation/NavRail.svelte +6 -9
- package/dist/components/Navigation/NavRail.svelte.d.ts +1 -1
- package/dist/components/Navigation/NavTile.svelte +6 -5
- package/dist/components/Navigation/context.js +4 -4
- package/dist/components/Navigation/index.d.ts +3 -3
- package/dist/components/Navigation/index.js +1 -1
- package/dist/components/Navigation/types.d.ts +3 -3
- package/dist/components/Pagination/Pagination.svelte +10 -42
- package/dist/components/Pagination/Pagination.svelte.d.ts +1 -1
- package/dist/components/Pagination/types.d.ts +1 -7
- package/dist/components/Popover/Popover.svelte +9 -31
- package/dist/components/Popover/Popover.svelte.d.ts +1 -1
- package/dist/components/Popover/types.d.ts +3 -7
- package/dist/components/Progress/Progress.svelte +8 -10
- package/dist/components/Progress/types.d.ts +1 -1
- package/dist/components/ProgressRing/ProgressRing.svelte +10 -5
- package/dist/components/ProgressRing/types.d.ts +1 -1
- package/dist/components/Rating/Rating.svelte +67 -28
- package/dist/components/Rating/Rating.svelte.d.ts +1 -1
- package/dist/components/Rating/types.d.ts +1 -3
- package/dist/components/Segment/Segment.svelte +12 -29
- package/dist/components/Segment/Segment.svelte.d.ts +1 -1
- package/dist/components/Segment/context.js +3 -2
- package/dist/components/Segment/index.d.ts +1 -1
- package/dist/components/Segment/index.js +1 -1
- package/dist/components/Segment/types.d.ts +1 -5
- package/dist/components/Slider/Slider.svelte +15 -28
- package/dist/components/Slider/Slider.svelte.d.ts +1 -1
- package/dist/components/Slider/types.d.ts +3 -5
- package/dist/components/Switch/Switch.svelte +19 -49
- package/dist/components/Switch/Switch.svelte.d.ts +1 -1
- package/dist/components/Switch/types.d.ts +1 -7
- package/dist/components/Tabs/Tabs.svelte +7 -21
- package/dist/components/Tabs/Tabs.svelte.d.ts +1 -1
- package/dist/components/Tabs/TabsControl.svelte +1 -1
- package/dist/components/Tabs/TabsPanel.svelte +1 -1
- package/dist/components/Tabs/context.js +3 -2
- package/dist/components/Tabs/index.d.ts +1 -1
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/Tabs/types.d.ts +1 -3
- package/dist/components/TagsInput/TagsInput.svelte +12 -27
- package/dist/components/TagsInput/TagsInput.svelte.d.ts +1 -1
- package/dist/components/TagsInput/types.d.ts +3 -7
- package/dist/components/Toast/ToastProvider.svelte +17 -16
- package/dist/components/Toast/types.d.ts +9 -9
- package/dist/components/Tooltip/Tooltip.svelte +9 -31
- package/dist/components/Tooltip/Tooltip.svelte.d.ts +1 -1
- package/dist/components/Tooltip/types.d.ts +3 -7
- package/dist/internal/create-context.js +3 -3
- package/dist/internal/test-utils.js +2 -2
- package/package.json +38 -44
- package/dist/components/Accordion/Accordion.test.d.ts +0 -1
- package/dist/components/Accordion/Accordion.test.js +0 -53
- package/dist/components/Accordion/Accordion.test.svelte +0 -22
- package/dist/components/Accordion/Accordion.test.svelte.d.ts +0 -7
- package/dist/components/AppBar/AppBar.test.d.ts +0 -1
- package/dist/components/AppBar/AppBar.test.js +0 -51
- package/dist/components/Avatar/Avatar.test.d.ts +0 -1
- package/dist/components/Avatar/Avatar.test.js +0 -63
- package/dist/components/Combobox/Combobox.test.d.ts +0 -1
- package/dist/components/Combobox/Combobox.test.js +0 -14
- package/dist/components/FileUpload/FIleUpload.test.d.ts +0 -1
- package/dist/components/FileUpload/FIleUpload.test.js +0 -43
- package/dist/components/Modal/Modal.test.d.ts +0 -1
- package/dist/components/Modal/Modal.test.js +0 -14
- package/dist/components/Navigation/NavBar.test.svelte +0 -14
- package/dist/components/Navigation/NavBar.test.svelte.d.ts +0 -6
- package/dist/components/Navigation/NavRail.test.svelte +0 -24
- package/dist/components/Navigation/NavRail.test.svelte.d.ts +0 -7
- package/dist/components/Navigation/Navigation.test.d.ts +0 -1
- package/dist/components/Navigation/Navigation.test.js +0 -180
- package/dist/components/Pagination/Pagination.test.d.ts +0 -1
- package/dist/components/Pagination/Pagination.test.js +0 -58
- package/dist/components/Popover/Popover.test.d.ts +0 -1
- package/dist/components/Popover/Popover.test.js +0 -14
- package/dist/components/Progress/Progress.test.d.ts +0 -1
- package/dist/components/Progress/Progress.test.js +0 -59
- package/dist/components/ProgressRing/ProgressRing.test.d.ts +0 -1
- package/dist/components/ProgressRing/ProgressRing.test.js +0 -58
- package/dist/components/Rating/Rating.test.d.ts +0 -1
- package/dist/components/Rating/Rating.test.js +0 -42
- package/dist/components/Segment/Segment.test.d.ts +0 -1
- package/dist/components/Segment/Segment.test.js +0 -71
- package/dist/components/Segment/Segment.test.svelte +0 -14
- package/dist/components/Segment/Segment.test.svelte.d.ts +0 -7
- package/dist/components/Slider/Slider.test.d.ts +0 -1
- package/dist/components/Slider/Slider.test.js +0 -49
- package/dist/components/Switch/Switch.test.d.ts +0 -1
- package/dist/components/Switch/Switch.test.js +0 -63
- package/dist/components/Tabs/Tabs.test.d.ts +0 -1
- package/dist/components/Tabs/Tabs.test.js +0 -68
- package/dist/components/Tabs/Tabs.test.svelte +0 -21
- package/dist/components/Tabs/Tabs.test.svelte.d.ts +0 -8
- package/dist/components/TagsInput/TagsInput.test.d.ts +0 -1
- package/dist/components/TagsInput/TagsInput.test.js +0 -38
- package/dist/components/Tooltip/Tooltip.test.d.ts +0 -1
- package/dist/components/Tooltip/Tooltip.test.js +0 -14
- 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 -50
- package/dist/internal/use-id.d.ts +0 -2
- package/dist/internal/use-id.js +0 -5
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import * as accordion from '@zag-js/accordion';
|
|
3
3
|
import { useMachine, normalizeProps } from '@zag-js/svelte';
|
|
4
|
-
import { useId } from '../../internal/use-id.js';
|
|
5
4
|
import { setAccordionContext } from './context.js';
|
|
6
5
|
import type { AccordionProps } from './types.js';
|
|
7
6
|
|
|
8
7
|
// Props
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
const {
|
|
9
|
+
animationConfig = {
|
|
10
|
+
duration: 200
|
|
11
|
+
},
|
|
12
12
|
// Root
|
|
13
13
|
base = '',
|
|
14
14
|
padding = '',
|
|
@@ -24,32 +24,20 @@
|
|
|
24
24
|
}: AccordionProps = $props();
|
|
25
25
|
|
|
26
26
|
// Zag
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
}),
|
|
35
|
-
{
|
|
36
|
-
context: {
|
|
37
|
-
...zagProps,
|
|
38
|
-
get value() {
|
|
39
|
-
return $state.snapshot(value);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
);
|
|
44
|
-
const api = $derived(accordion.connect(snapshot, send, normalizeProps));
|
|
27
|
+
const id = $props.id();
|
|
28
|
+
const service = useMachine(accordion.machine, () => ({
|
|
29
|
+
id: id,
|
|
30
|
+
...zagProps
|
|
31
|
+
}));
|
|
32
|
+
const api = $derived(accordion.connect(service, normalizeProps));
|
|
45
33
|
|
|
46
34
|
// Context
|
|
47
35
|
setAccordionContext({
|
|
48
36
|
get api() {
|
|
49
37
|
return api;
|
|
50
38
|
},
|
|
51
|
-
get
|
|
52
|
-
return
|
|
39
|
+
get animationConfig() {
|
|
40
|
+
return animationConfig;
|
|
53
41
|
},
|
|
54
42
|
get iconClosed() {
|
|
55
43
|
return iconClosed;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AccordionProps } from './types.js';
|
|
2
2
|
/** Divide content into collapsible sections. */
|
|
3
|
-
declare const Accordion: import("svelte").Component<AccordionProps, {}, "
|
|
3
|
+
declare const Accordion: import("svelte").Component<AccordionProps, {}, "">;
|
|
4
4
|
type Accordion = ReturnType<typeof Accordion>;
|
|
5
5
|
export default Accordion;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
// Props
|
|
7
7
|
const {
|
|
8
|
-
|
|
8
|
+
headingLevel = 3,
|
|
9
9
|
// Root
|
|
10
10
|
base,
|
|
11
11
|
spaceY,
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
|
|
46
46
|
<div class="{base} {spaceY} {classes}" {...ctx.api.getItemProps(zagProps)} data-testid="accordion-item">
|
|
47
47
|
<!-- Control -->
|
|
48
|
-
<svelte:element this={
|
|
48
|
+
<svelte:element this={`h${headingLevel}`}>
|
|
49
49
|
<button
|
|
50
50
|
class="{controlBase} {controlHover} {controlPadding} {controlRounded} {controlClasses}"
|
|
51
51
|
{...ctx.api.getItemTriggerProps(zagProps)}
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
<div
|
|
82
82
|
class="{panelBase} {panelPadding} {panelRounded} {panelClasses}"
|
|
83
83
|
{...ctx.api.getItemContentProps(zagProps)}
|
|
84
|
-
transition:slide={
|
|
84
|
+
transition:slide={ctx.animationConfig}
|
|
85
85
|
data-testid="accordion-panel"
|
|
86
86
|
>
|
|
87
87
|
{@render panel?.()}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var _a;
|
|
1
2
|
import { createContext } from '../../internal/create-context.js';
|
|
2
3
|
// @ts-expect-error - Defaults for context don't make sense, `createContext` should just throw TBH
|
|
3
|
-
export
|
|
4
|
+
export var setAccordionContext = (_a = createContext(), _a[0]), getAccordionContext = _a[1], key = _a[2];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const _default: import("svelte").Component<import("./types").AccordionProps, {}, "
|
|
1
|
+
declare const _default: import("svelte").Component<import("./types").AccordionProps, {}, ""> & {
|
|
2
2
|
Item: import("svelte").Component<import("./types").AccordionItemProps, {}, "">;
|
|
3
3
|
};
|
|
4
4
|
export default _default;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import * as accordion from '@zag-js/accordion';
|
|
3
|
-
|
|
3
|
+
import type { SlideParams } from 'svelte/transition';
|
|
4
|
+
export interface AccordionContext extends Pick<AccordionProps, 'animationConfig' | 'iconOpen' | 'iconClosed'> {
|
|
4
5
|
api: ReturnType<typeof accordion.connect>;
|
|
5
|
-
animDuration: number;
|
|
6
|
-
iconOpen?: Snippet;
|
|
7
|
-
iconClosed?: Snippet;
|
|
8
6
|
}
|
|
9
|
-
export interface AccordionProps extends Omit<accordion.
|
|
10
|
-
/** The
|
|
11
|
-
|
|
7
|
+
export interface AccordionProps extends Omit<accordion.Props, 'id' | 'orientation'> {
|
|
8
|
+
/** The animation configuration */
|
|
9
|
+
animationConfig?: SlideParams;
|
|
12
10
|
/** Sets base styles. */
|
|
13
11
|
base?: string;
|
|
14
12
|
/** Set padding styles. */
|
|
@@ -29,8 +27,8 @@ export interface AccordionProps extends Omit<accordion.Context, 'id' | 'orientat
|
|
|
29
27
|
iconClosed?: Snippet;
|
|
30
28
|
}
|
|
31
29
|
export interface AccordionItemProps extends accordion.ItemProps {
|
|
32
|
-
/** The
|
|
33
|
-
|
|
30
|
+
/** The heading level. */
|
|
31
|
+
headingLevel?: number;
|
|
34
32
|
/** Sets base styles. */
|
|
35
33
|
base?: string;
|
|
36
34
|
/** Set vertical spacing styles. */
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
import * as avatar from '@zag-js/avatar';
|
|
3
3
|
import { useMachine, normalizeProps } from '@zag-js/svelte';
|
|
4
4
|
import type { AvatarProps } from './types.js';
|
|
5
|
-
import { useId } from '../../internal/use-id.js';
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
const {
|
|
8
7
|
src,
|
|
9
8
|
srcset,
|
|
10
9
|
name,
|
|
11
|
-
filter,
|
|
12
10
|
// Root
|
|
13
11
|
base = 'overflow-hidden isolate',
|
|
14
12
|
background = 'bg-surface-400-600',
|
|
@@ -26,12 +24,18 @@
|
|
|
26
24
|
fallbackBase = 'w-full h-full flex justify-center items-center',
|
|
27
25
|
fallbackClasses = '',
|
|
28
26
|
// Snippets
|
|
29
|
-
children
|
|
27
|
+
children,
|
|
28
|
+
// Zag
|
|
29
|
+
...zagProps
|
|
30
30
|
}: AvatarProps = $props();
|
|
31
31
|
|
|
32
32
|
// Zag
|
|
33
|
-
const
|
|
34
|
-
const
|
|
33
|
+
const id = $props.id();
|
|
34
|
+
const service = useMachine(avatar.machine, () => ({
|
|
35
|
+
id: id,
|
|
36
|
+
...zagProps
|
|
37
|
+
}));
|
|
38
|
+
const api = $derived(avatar.connect(service, normalizeProps));
|
|
35
39
|
|
|
36
40
|
// Generate Initials
|
|
37
41
|
function getInitials(name: string) {
|
|
@@ -44,20 +48,12 @@
|
|
|
44
48
|
|
|
45
49
|
<!-- @component An image with a fallback for representing a single user. -->
|
|
46
50
|
|
|
47
|
-
<figure
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{srcset}
|
|
54
|
-
alt={name}
|
|
55
|
-
class="{imageBase} {imageClasses}"
|
|
56
|
-
style:filter={filter && `url(${filter})`}
|
|
57
|
-
data-testid="avatar-image"
|
|
58
|
-
{style}
|
|
59
|
-
/>
|
|
60
|
-
{/if}
|
|
51
|
+
<figure
|
|
52
|
+
{...api.getRootProps()}
|
|
53
|
+
class="{base} {background} {size} {font} {border} {rounded} {shadow} {classes}"
|
|
54
|
+
{style}
|
|
55
|
+
data-testid="avatar"
|
|
56
|
+
>
|
|
61
57
|
<!-- Fallback -->
|
|
62
58
|
<span {...api.getFallbackProps()} class="{fallbackBase} {fallbackClasses}" data-testid="avatar-fallback">
|
|
63
59
|
{#if children}
|
|
@@ -66,4 +62,8 @@
|
|
|
66
62
|
{getInitials(name)}
|
|
67
63
|
{/if}
|
|
68
64
|
</span>
|
|
65
|
+
<!-- Image -->
|
|
66
|
+
{#if src || srcset}
|
|
67
|
+
<img {...api.getImageProps()} {src} {srcset} alt={name} class="{imageBase} {imageClasses}" data-testid="avatar-image" />
|
|
68
|
+
{/if}
|
|
69
69
|
</figure>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
1
2
|
import type { Snippet } from 'svelte';
|
|
2
|
-
|
|
3
|
+
import type * as avatar from '@zag-js/avatar';
|
|
4
|
+
export interface AvatarProps extends Omit<avatar.Props, 'id'>, Pick<HTMLAttributes<HTMLElement>, 'style'> {
|
|
3
5
|
/** Set avatar image source URL. */
|
|
4
6
|
src?: string;
|
|
5
7
|
/** The source set of the avatar image. */
|
|
6
8
|
srcset?: string;
|
|
7
9
|
/** Provide a name or username for the avatar. */
|
|
8
10
|
name: string;
|
|
9
|
-
/** Set avatar image filter name, such as: "#Apollo". */
|
|
10
|
-
filter?: string;
|
|
11
11
|
/** Set base styles. */
|
|
12
12
|
base?: string;
|
|
13
13
|
/** Set background styles. */
|
|
@@ -28,8 +28,6 @@ export interface AvatarProps {
|
|
|
28
28
|
imageBase?: string;
|
|
29
29
|
/** Provide avatar image arbitrary CSS classes. */
|
|
30
30
|
imageClasses?: string;
|
|
31
|
-
/** Set avatar image styles. */
|
|
32
|
-
style?: string;
|
|
33
31
|
/** Set base classes for the fallback element. */
|
|
34
32
|
fallbackBase?: string;
|
|
35
33
|
/** Provide arbitrary CSS classes to fallback element. */
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
<script lang="ts">
|
|
1
|
+
<script lang="ts" generics="T extends ComboboxItem">
|
|
2
2
|
import { fade } from 'svelte/transition';
|
|
3
|
-
|
|
4
3
|
import * as combobox from '@zag-js/combobox';
|
|
5
4
|
import { useMachine, normalizeProps, mergeProps } from '@zag-js/svelte';
|
|
6
|
-
import type { ComboboxProps } from './types.js';
|
|
7
|
-
import { useId } from '../../internal/use-id.js';
|
|
5
|
+
import type { ComboboxProps, ComboboxItem } from './types.js';
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
data =
|
|
11
|
-
value = $bindable([]),
|
|
7
|
+
const {
|
|
8
|
+
data = [],
|
|
12
9
|
label = '',
|
|
13
|
-
|
|
10
|
+
zIndex = 'auto',
|
|
14
11
|
// Base
|
|
15
12
|
base = '',
|
|
16
13
|
width = '',
|
|
@@ -27,7 +24,6 @@
|
|
|
27
24
|
inputGroupClasses = '',
|
|
28
25
|
// Positioner
|
|
29
26
|
positionerBase = '',
|
|
30
|
-
zIndex = 'auto',
|
|
31
27
|
positionerClasses = '',
|
|
32
28
|
// Content
|
|
33
29
|
contentBase = 'card p-2',
|
|
@@ -41,55 +37,41 @@
|
|
|
41
37
|
optionClasses = '',
|
|
42
38
|
// Snippets
|
|
43
39
|
arrow,
|
|
40
|
+
item,
|
|
44
41
|
// Events
|
|
45
42
|
onclick,
|
|
46
43
|
// Zag ---
|
|
47
44
|
...zagProps
|
|
48
|
-
}: ComboboxProps = $props();
|
|
45
|
+
}: ComboboxProps<T> = $props();
|
|
49
46
|
|
|
50
47
|
// Zag
|
|
51
48
|
let options = $state.raw(data);
|
|
52
|
-
const collection =
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
combobox.machine({
|
|
60
|
-
id: useId(),
|
|
61
|
-
collection,
|
|
62
|
-
value: $state.snapshot(value),
|
|
63
|
-
loopFocus: true,
|
|
64
|
-
onOpenChange(details) {
|
|
65
|
-
zagProps.onOpenChange?.(details);
|
|
66
|
-
options = data;
|
|
67
|
-
},
|
|
68
|
-
onInputValueChange(details) {
|
|
69
|
-
zagProps.onInputValueChange?.(details);
|
|
70
|
-
const filtered = data.filter((item) => item.label.toLowerCase().includes(details.inputValue.toLowerCase()));
|
|
71
|
-
const newOptions = filtered.length > 0 ? filtered : data;
|
|
72
|
-
collection.setItems(newOptions);
|
|
73
|
-
options = newOptions;
|
|
74
|
-
},
|
|
75
|
-
onValueChange(event) {
|
|
76
|
-
zagProps.onValueChange?.(event);
|
|
77
|
-
value = event.value;
|
|
78
|
-
}
|
|
79
|
-
}),
|
|
80
|
-
{
|
|
81
|
-
context: {
|
|
82
|
-
...zagProps,
|
|
83
|
-
get data() {
|
|
84
|
-
return $state.snapshot(data);
|
|
85
|
-
},
|
|
86
|
-
get value() {
|
|
87
|
-
return $state.snapshot(value);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
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
|
+
})
|
|
91
56
|
);
|
|
92
|
-
|
|
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));
|
|
93
75
|
const triggerProps = $derived(mergeProps(api.getTriggerProps(), { onclick }));
|
|
94
76
|
</script>
|
|
95
77
|
|
|
@@ -100,9 +82,9 @@
|
|
|
100
82
|
<!-- Input Group -->
|
|
101
83
|
<div {...api.getControlProps()} class="{inputGroupBase} {inputGroupClasses}">
|
|
102
84
|
<!-- Input -->
|
|
103
|
-
<input {...api.getInputProps()} class={inputGroupInput}
|
|
85
|
+
<input {...api.getInputProps()} class={inputGroupInput} />
|
|
104
86
|
<!-- Arrow -->
|
|
105
|
-
<button {...triggerProps} class={inputGroupButton}
|
|
87
|
+
<button {...triggerProps} class={inputGroupButton}>
|
|
106
88
|
{#if arrow}
|
|
107
89
|
{@render arrow()}
|
|
108
90
|
{:else}
|
|
@@ -135,13 +117,18 @@
|
|
|
135
117
|
class="{contentBase} {contentBackground} {contentSpaceY} {contentClasses}"
|
|
136
118
|
style="z-index: {zIndex}"
|
|
137
119
|
>
|
|
138
|
-
{#each options as
|
|
139
|
-
{@const isChecked = api.getItemProps({ item })['data-state'] === 'checked'}
|
|
120
|
+
{#each options as option (option.label)}
|
|
121
|
+
{@const isChecked = api.getItemProps({ item: option })['data-state'] === 'checked'}
|
|
140
122
|
{@const displayClass = isChecked ? optionActive : optionHover}
|
|
141
123
|
<!-- Option -->
|
|
142
|
-
<!-- ZagJs should have set button type to "button" here.
|
|
143
|
-
|
|
144
|
-
|
|
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}
|
|
145
132
|
</button>
|
|
146
133
|
{/each}
|
|
147
134
|
</nav>
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import type { ComboboxProps } from './types.js';
|
|
2
|
-
declare
|
|
3
|
-
|
|
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>>;
|
|
4
18
|
export default Combobox;
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
2
|
import * as combobox from '@zag-js/combobox';
|
|
3
|
-
export interface ComboboxProps extends Omit<combobox.
|
|
3
|
+
export interface ComboboxProps<T extends ComboboxItem> extends Omit<combobox.Props, 'id' | 'collection'> {
|
|
4
4
|
/** Provide the list of label and value data */
|
|
5
|
-
data?:
|
|
6
|
-
label: string;
|
|
7
|
-
value: string;
|
|
8
|
-
}[];
|
|
9
|
-
/** Bind the selected value. */
|
|
10
|
-
value?: string[] | undefined;
|
|
5
|
+
data?: T[];
|
|
11
6
|
/** Set the label to display. */
|
|
12
7
|
label?: string;
|
|
13
|
-
/**
|
|
14
|
-
|
|
8
|
+
/** Set z-index for the positioner. */
|
|
9
|
+
zIndex?: string;
|
|
15
10
|
/** Set base classes for the root element. */
|
|
16
11
|
base?: string;
|
|
17
12
|
/** Set width classes for the root element. */
|
|
@@ -36,8 +31,6 @@ export interface ComboboxProps extends Omit<combobox.Context, 'id' | 'collection
|
|
|
36
31
|
inputGroupClasses?: string;
|
|
37
32
|
/** Set base classes for the positioner. */
|
|
38
33
|
positionerBase?: string;
|
|
39
|
-
/** Set z-index for the positioner. */
|
|
40
|
-
zIndex?: string;
|
|
41
34
|
/** Provide arbitrary classes for the positioner. */
|
|
42
35
|
positionerClasses?: string;
|
|
43
36
|
/** Set base classes for the content. */
|
|
@@ -60,6 +53,12 @@ export interface ComboboxProps extends Omit<combobox.Context, 'id' | 'collection
|
|
|
60
53
|
optionClasses?: string;
|
|
61
54
|
/** Provide a custom arrow icon. */
|
|
62
55
|
arrow?: Snippet;
|
|
56
|
+
/** Provide a custom template for the option. */
|
|
57
|
+
item?: Snippet<[T]>;
|
|
63
58
|
/** Handle the combobox dropdown button click event. */
|
|
64
59
|
onclick?: (event: Event) => void;
|
|
65
60
|
}
|
|
61
|
+
export interface ComboboxItem {
|
|
62
|
+
label: string;
|
|
63
|
+
value: string;
|
|
64
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import * as fileUpload from '@zag-js/file-upload';
|
|
3
3
|
import { useMachine, normalizeProps } from '@zag-js/svelte';
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
import type { FileUploadProps } from './types.js';
|
|
6
6
|
|
|
7
7
|
// Props
|
|
8
|
-
|
|
8
|
+
const {
|
|
9
9
|
label = `Select file or drag here`,
|
|
10
10
|
subtext = '',
|
|
11
11
|
// Root
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
// Interface (content)
|
|
23
23
|
interfaceIcon = '',
|
|
24
24
|
interfaceText = '',
|
|
25
|
-
interfaceSubtext = '
|
|
25
|
+
interfaceSubtext = 'text-xs opacity-60',
|
|
26
26
|
// Files List
|
|
27
27
|
filesListBase = 'mt-2 space-y-2',
|
|
28
28
|
filesListClasses = '',
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
fileClasses = '',
|
|
36
36
|
// File (content)
|
|
37
37
|
fileIcon = '',
|
|
38
|
-
fileName = '
|
|
39
|
-
fileSize = '
|
|
38
|
+
fileName = 'text-sm flex items-center gap-4',
|
|
39
|
+
fileSize = 'text-xs opacity-60',
|
|
40
40
|
fileButton = '',
|
|
41
41
|
// State
|
|
42
42
|
stateInvalid = 'border-error-500',
|
|
@@ -48,26 +48,23 @@
|
|
|
48
48
|
iconFile,
|
|
49
49
|
iconFileRemove,
|
|
50
50
|
// Zag
|
|
51
|
-
internalApi = $bindable(),
|
|
52
51
|
...zagProps
|
|
53
52
|
}: FileUploadProps = $props();
|
|
54
53
|
|
|
55
54
|
// Zag
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
);
|
|
62
|
-
const api = $derived(fileUpload.connect(snapshot, send, normalizeProps));
|
|
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));
|
|
63
61
|
|
|
64
|
-
$effect(() => {
|
|
65
|
-
|
|
66
|
-
internalApi = api;
|
|
62
|
+
$effect.pre(() => {
|
|
63
|
+
zagProps.onApiReady?.(api);
|
|
67
64
|
});
|
|
68
65
|
|
|
69
66
|
// Reactive
|
|
70
|
-
const rxDisabled = $derived(
|
|
67
|
+
const rxDisabled = $derived(service.prop('disabled') ? stateDisabled : '');
|
|
71
68
|
const rxInvalid = $derived(api.rejectedFiles.length > 0 ? stateInvalid : interfaceBorderColor);
|
|
72
69
|
const rxDragging = $derived(api.dragging && !children ? stateDragging : '');
|
|
73
70
|
</script>
|
|
@@ -104,7 +101,7 @@
|
|
|
104
101
|
{#if !children}
|
|
105
102
|
<ul {...api.getItemGroupProps()} class="{filesListBase} {filesListClasses}" data-testid="uploader-files-list">
|
|
106
103
|
<!-- Loop Files -->
|
|
107
|
-
{#each api.acceptedFiles as file}
|
|
104
|
+
{#each api.acceptedFiles as file (file.name)}
|
|
108
105
|
<!-- File -->
|
|
109
106
|
<li
|
|
110
107
|
{...api.getItemProps({ file })}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FileUploadProps } from './types.js';
|
|
2
2
|
/** A form component for handling file uploads. */
|
|
3
|
-
declare const FileUpload: import("svelte").Component<FileUploadProps, {}, "
|
|
3
|
+
declare const FileUpload: import("svelte").Component<FileUploadProps, {}, "">;
|
|
4
4
|
type FileUpload = ReturnType<typeof FileUpload>;
|
|
5
5
|
export default FileUpload;
|
|
@@ -2,7 +2,7 @@ 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
4
|
export type FileUploadApi = fileUpload.Api<PropTypes>;
|
|
5
|
-
export interface FileUploadProps extends Omit<fileUpload.
|
|
5
|
+
export interface FileUploadProps extends Omit<fileUpload.Props, 'id'> {
|
|
6
6
|
/** Set the interface text value. */
|
|
7
7
|
label?: string;
|
|
8
8
|
/** Set the interface subtext value. */
|
|
@@ -70,5 +70,5 @@ export interface FileUploadProps extends Omit<fileUpload.Context, 'id' | 'value'
|
|
|
70
70
|
/** Provide an icon for the remove file action. */
|
|
71
71
|
iconFileRemove?: Snippet;
|
|
72
72
|
/** Binds the Zag API for external use. */
|
|
73
|
-
|
|
73
|
+
onApiReady?: (api: FileUploadApi) => void;
|
|
74
74
|
}
|
|
@@ -3,14 +3,12 @@
|
|
|
3
3
|
import * as dialog from '@zag-js/dialog';
|
|
4
4
|
import { portal, normalizeProps, useMachine, mergeProps } from '@zag-js/svelte';
|
|
5
5
|
import type { ModalProps } from './types.js';
|
|
6
|
-
import { useId } from '../../internal/use-id.js';
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
open = $bindable(false),
|
|
10
|
-
disabled = false,
|
|
7
|
+
const {
|
|
11
8
|
// Base
|
|
12
9
|
base = '',
|
|
13
10
|
classes = '',
|
|
11
|
+
zIndex = 'auto',
|
|
14
12
|
// Trigger
|
|
15
13
|
triggerBase = '',
|
|
16
14
|
triggerBackground = '',
|
|
@@ -26,7 +24,6 @@
|
|
|
26
24
|
positionerJustify = 'justify-center',
|
|
27
25
|
positionerAlign = 'items-center',
|
|
28
26
|
positionerPadding = 'p-4',
|
|
29
|
-
zIndex = 'auto',
|
|
30
27
|
positionerClasses = '',
|
|
31
28
|
// Content
|
|
32
29
|
contentBase = '',
|
|
@@ -47,38 +44,19 @@
|
|
|
47
44
|
}: ModalProps = $props();
|
|
48
45
|
|
|
49
46
|
// Zag
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
context: {
|
|
57
|
-
...zagProps,
|
|
58
|
-
onOpenChange(details) {
|
|
59
|
-
zagProps.onOpenChange?.(details);
|
|
60
|
-
open = details.open;
|
|
61
|
-
},
|
|
62
|
-
get open() {
|
|
63
|
-
return $state.snapshot(open);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
);
|
|
68
|
-
const api = $derived(dialog.connect(snapshot, send, normalizeProps));
|
|
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));
|
|
69
53
|
const triggerProps = $derived(mergeProps(api.getTriggerProps(), { onclick }));
|
|
70
54
|
</script>
|
|
71
55
|
|
|
72
56
|
<span class="{base} {classes}" data-testid="modal">
|
|
73
57
|
<!-- Trigger -->
|
|
74
58
|
{#if trigger}
|
|
75
|
-
<button
|
|
76
|
-
{...triggerProps}
|
|
77
|
-
class="{triggerBase} {triggerBackground} {triggerClasses}"
|
|
78
|
-
{disabled}
|
|
79
|
-
type="button"
|
|
80
|
-
aria-label={triggerAriaLabel}
|
|
81
|
-
>
|
|
59
|
+
<button {...triggerProps} class="{triggerBase} {triggerBackground} {triggerClasses}" type="button" aria-label={triggerAriaLabel}>
|
|
82
60
|
{@render trigger()}
|
|
83
61
|
</button>
|
|
84
62
|
{/if}
|