@skeletonlabs/skeleton-svelte 4.0.1 → 4.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/dist/components/segmented-control/anatomy/control.svelte +3 -1
- package/dist/components/segmented-control/modules/provider.svelte.js +3 -3
- package/dist/components/toggle-group/anatomy/item.svelte +39 -0
- package/dist/components/toggle-group/anatomy/item.svelte.d.ts +9 -0
- package/dist/components/toggle-group/anatomy/root-context.svelte +20 -0
- package/dist/components/toggle-group/anatomy/root-context.svelte.d.ts +10 -0
- package/dist/components/toggle-group/anatomy/root-provider.svelte +39 -0
- package/dist/components/toggle-group/anatomy/root-provider.svelte.d.ts +10 -0
- package/dist/components/toggle-group/anatomy/root.svelte +46 -0
- package/dist/components/toggle-group/anatomy/root.svelte.d.ts +9 -0
- package/dist/components/toggle-group/index.d.ts +7 -0
- package/dist/components/toggle-group/index.js +2 -0
- package/dist/components/toggle-group/modules/anatomy.d.ts +6 -0
- package/dist/components/toggle-group/modules/anatomy.js +9 -0
- package/dist/components/toggle-group/modules/provider.svelte.d.ts +4 -0
- package/dist/components/toggle-group/modules/provider.svelte.js +7 -0
- package/dist/components/toggle-group/modules/root-context.d.ts +6 -0
- package/dist/components/toggle-group/modules/root-context.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +6 -5
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { connect, machine } from '@zag-js/radio-group';
|
|
2
2
|
import { normalizeProps, useMachine } from '@zag-js/svelte';
|
|
3
3
|
export function useSegmentedControl(props) {
|
|
4
|
-
const service = useMachine(machine, {
|
|
4
|
+
const service = useMachine(machine, () => ({
|
|
5
5
|
orientation: 'horizontal',
|
|
6
6
|
...(typeof props === 'function' ? props() : props),
|
|
7
|
-
});
|
|
8
|
-
const segmentedControl = connect(service, normalizeProps);
|
|
7
|
+
}));
|
|
8
|
+
const segmentedControl = $derived(connect(service, normalizeProps));
|
|
9
9
|
return () => segmentedControl;
|
|
10
10
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { HTMLAttributes } from '../../../internal/html-attributes';
|
|
3
|
+
import type { PropsWithElement } from '../../../internal/props-with-element';
|
|
4
|
+
import type { ItemProps } from '@zag-js/toggle-group';
|
|
5
|
+
|
|
6
|
+
export interface ToggleGroupItemProps extends ItemProps, PropsWithElement<'button'>, HTMLAttributes<'button', 'value' | 'disabled'> {}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { RootContext } from '../modules/root-context';
|
|
11
|
+
import { classesToggleGroup } from '@skeletonlabs/skeleton-common';
|
|
12
|
+
import { mergeProps } from '@zag-js/svelte';
|
|
13
|
+
import { splitItemProps } from '@zag-js/toggle-group';
|
|
14
|
+
|
|
15
|
+
const props: ToggleGroupItemProps = $props();
|
|
16
|
+
|
|
17
|
+
const toggleGroup = RootContext.consume();
|
|
18
|
+
|
|
19
|
+
const [itemProps, componentProps] = $derived(splitItemProps(props));
|
|
20
|
+
const { element, children, ...rest } = $derived(componentProps);
|
|
21
|
+
|
|
22
|
+
const attributes = $derived(
|
|
23
|
+
mergeProps(
|
|
24
|
+
toggleGroup().getItemProps(itemProps),
|
|
25
|
+
{
|
|
26
|
+
class: classesToggleGroup.item,
|
|
27
|
+
},
|
|
28
|
+
rest,
|
|
29
|
+
),
|
|
30
|
+
);
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
{#if element}
|
|
34
|
+
{@render element(attributes)}
|
|
35
|
+
{:else}
|
|
36
|
+
<button {...attributes}>
|
|
37
|
+
{@render children?.()}
|
|
38
|
+
</button>
|
|
39
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HTMLAttributes } from '../../../internal/html-attributes';
|
|
2
|
+
import type { PropsWithElement } from '../../../internal/props-with-element';
|
|
3
|
+
import type { ItemProps } from '@zag-js/toggle-group';
|
|
4
|
+
export interface ToggleGroupItemProps extends ItemProps, PropsWithElement<'button'>, HTMLAttributes<'button', 'value' | 'disabled'> {
|
|
5
|
+
}
|
|
6
|
+
declare const Item: import("svelte").Component<ToggleGroupItemProps, {}, "">;
|
|
7
|
+
type Item = ReturnType<typeof Item>;
|
|
8
|
+
export default Item;
|
|
9
|
+
//# sourceMappingURL=item.svelte.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { useToggleGroup } from '../modules/provider.svelte';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
|
|
5
|
+
export interface ToggleGroupRootContextProps {
|
|
6
|
+
children: Snippet<[ReturnType<typeof useToggleGroup>]>;
|
|
7
|
+
}
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import { RootContext } from '../modules/root-context';
|
|
12
|
+
|
|
13
|
+
const props: ToggleGroupRootContextProps = $props();
|
|
14
|
+
|
|
15
|
+
const toggleGroup = RootContext.consume();
|
|
16
|
+
|
|
17
|
+
const { children } = $derived(props);
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
{@render children(toggleGroup)}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { useToggleGroup } from '../modules/provider.svelte';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
export interface ToggleGroupRootContextProps {
|
|
4
|
+
children: Snippet<[ReturnType<typeof useToggleGroup>]>;
|
|
5
|
+
}
|
|
6
|
+
import { RootContext } from '../modules/root-context';
|
|
7
|
+
declare const RootContext: import("svelte").Component<ToggleGroupRootContextProps, {}, "">;
|
|
8
|
+
type RootContext = ReturnType<typeof RootContext>;
|
|
9
|
+
export default RootContext;
|
|
10
|
+
//# sourceMappingURL=root-context.svelte.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { useToggleGroup } from '../modules/provider.svelte';
|
|
3
|
+
import type { HTMLAttributes } from '../../../internal/html-attributes';
|
|
4
|
+
import type { PropsWithElement } from '../../../internal/props-with-element';
|
|
5
|
+
|
|
6
|
+
export interface ToggleGroupRootProviderProps extends PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {
|
|
7
|
+
value: ReturnType<typeof useToggleGroup>;
|
|
8
|
+
}
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { RootContext } from '../modules/root-context';
|
|
13
|
+
import { classesToggleGroup } from '@skeletonlabs/skeleton-common';
|
|
14
|
+
import { mergeProps } from '@zag-js/svelte';
|
|
15
|
+
|
|
16
|
+
const props: ToggleGroupRootProviderProps = $props();
|
|
17
|
+
|
|
18
|
+
const { element, children, value: toggleGroup, ...rest } = $derived(props);
|
|
19
|
+
|
|
20
|
+
const attributes = $derived(
|
|
21
|
+
mergeProps(
|
|
22
|
+
toggleGroup().getRootProps(),
|
|
23
|
+
{
|
|
24
|
+
class: classesToggleGroup.root,
|
|
25
|
+
},
|
|
26
|
+
rest,
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
RootContext.provide(() => toggleGroup());
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
{#if element}
|
|
34
|
+
{@render element(attributes)}
|
|
35
|
+
{:else}
|
|
36
|
+
<div {...attributes}>
|
|
37
|
+
{@render children?.()}
|
|
38
|
+
</div>
|
|
39
|
+
{/if}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { useToggleGroup } from '../modules/provider.svelte';
|
|
2
|
+
import type { HTMLAttributes } from '../../../internal/html-attributes';
|
|
3
|
+
import type { PropsWithElement } from '../../../internal/props-with-element';
|
|
4
|
+
export interface ToggleGroupRootProviderProps extends PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {
|
|
5
|
+
value: ReturnType<typeof useToggleGroup>;
|
|
6
|
+
}
|
|
7
|
+
declare const RootProvider: import("svelte").Component<ToggleGroupRootProviderProps, {}, "">;
|
|
8
|
+
type RootProvider = ReturnType<typeof RootProvider>;
|
|
9
|
+
export default RootProvider;
|
|
10
|
+
//# sourceMappingURL=root-provider.svelte.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { HTMLAttributes } from '../../../internal/html-attributes';
|
|
3
|
+
import type { PropsWithElement } from '../../../internal/props-with-element';
|
|
4
|
+
import type { Props } from '@zag-js/toggle-group';
|
|
5
|
+
|
|
6
|
+
export interface ToggleGroupRootProps extends Omit<Props, 'id'>, PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {}
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
import { useToggleGroup } from '../modules/provider.svelte';
|
|
11
|
+
import { RootContext } from '../modules/root-context';
|
|
12
|
+
import { classesToggleGroup } from '@skeletonlabs/skeleton-common';
|
|
13
|
+
import { mergeProps } from '@zag-js/svelte';
|
|
14
|
+
import { splitProps } from '@zag-js/toggle-group';
|
|
15
|
+
|
|
16
|
+
const props: ToggleGroupRootProps = $props();
|
|
17
|
+
|
|
18
|
+
const [toggleGroupProps, componentProps] = $derived(splitProps(props));
|
|
19
|
+
const { element, children, ...rest } = $derived(componentProps);
|
|
20
|
+
|
|
21
|
+
const id = $props.id();
|
|
22
|
+
const toggleGroup = useToggleGroup(() => ({
|
|
23
|
+
...toggleGroupProps,
|
|
24
|
+
id: id,
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
const attributes = $derived(
|
|
28
|
+
mergeProps(
|
|
29
|
+
toggleGroup().getRootProps(),
|
|
30
|
+
{
|
|
31
|
+
class: classesToggleGroup.root,
|
|
32
|
+
},
|
|
33
|
+
rest,
|
|
34
|
+
),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
RootContext.provide(() => toggleGroup());
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
{#if element}
|
|
41
|
+
{@render element(attributes)}
|
|
42
|
+
{:else}
|
|
43
|
+
<div {...attributes}>
|
|
44
|
+
{@render children?.()}
|
|
45
|
+
</div>
|
|
46
|
+
{/if}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HTMLAttributes } from '../../../internal/html-attributes';
|
|
2
|
+
import type { PropsWithElement } from '../../../internal/props-with-element';
|
|
3
|
+
import type { Props } from '@zag-js/toggle-group';
|
|
4
|
+
export interface ToggleGroupRootProps extends Omit<Props, 'id'>, PropsWithElement<'div'>, HTMLAttributes<'div', 'id' | 'dir'> {
|
|
5
|
+
}
|
|
6
|
+
declare const Root: import("svelte").Component<ToggleGroupRootProps, {}, "">;
|
|
7
|
+
type Root = ReturnType<typeof Root>;
|
|
8
|
+
export default Root;
|
|
9
|
+
//# sourceMappingURL=root.svelte.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { ToggleGroupItemProps } from './anatomy/item.svelte';
|
|
2
|
+
export type { ToggleGroupRootProps } from './anatomy/root.svelte';
|
|
3
|
+
export type { ToggleGroupRootContextProps } from './anatomy/root-context.svelte';
|
|
4
|
+
export type { ToggleGroupRootProviderProps } from './anatomy/root-provider.svelte';
|
|
5
|
+
export { ToggleGroup } from './modules/anatomy';
|
|
6
|
+
export { useToggleGroup } from './modules/provider.svelte';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const ToggleGroup: import("svelte").Component<import("..").ToggleGroupRootProps, {}, ""> & {
|
|
2
|
+
Provider: import("svelte").Component<import("..").ToggleGroupRootProviderProps, {}, "">;
|
|
3
|
+
Context: import("svelte").Component<import("..").ToggleGroupRootContextProps, {}, "">;
|
|
4
|
+
Item: import("svelte").Component<import("..").ToggleGroupItemProps, {}, "">;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=anatomy.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Item from '../anatomy/item.svelte';
|
|
2
|
+
import RootContext from '../anatomy/root-context.svelte';
|
|
3
|
+
import RootProvider from '../anatomy/root-provider.svelte';
|
|
4
|
+
import Root from '../anatomy/root.svelte';
|
|
5
|
+
export const ToggleGroup = Object.assign(Root, {
|
|
6
|
+
Provider: RootProvider,
|
|
7
|
+
Context: RootContext,
|
|
8
|
+
Item: Item,
|
|
9
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { normalizeProps, useMachine } from '@zag-js/svelte';
|
|
2
|
+
import { connect, machine } from '@zag-js/toggle-group';
|
|
3
|
+
export function useToggleGroup(props) {
|
|
4
|
+
const service = useMachine(machine, props);
|
|
5
|
+
const toggleGroup = $derived(connect(service, normalizeProps));
|
|
6
|
+
return () => toggleGroup;
|
|
7
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const RootContext: {
|
|
2
|
+
key: symbol;
|
|
3
|
+
consume(): () => import("@zag-js/toggle-group").Api<import("@zag-js/svelte").PropTypes>;
|
|
4
|
+
provide(value: () => import("@zag-js/toggle-group").Api<import("@zag-js/svelte").PropTypes>): () => import("@zag-js/toggle-group").Api<import("@zag-js/svelte").PropTypes>;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=root-context.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from './components/switch/index';
|
|
|
19
19
|
export * from './components/tabs/index';
|
|
20
20
|
export * from './components/tags-input/index';
|
|
21
21
|
export * from './components/toast/index';
|
|
22
|
+
export * from './components/toggle-group/index';
|
|
22
23
|
export * from './components/tooltip/index';
|
|
23
24
|
export * from './components/tree-view/index';
|
|
24
25
|
export * from './hooks/use-list-collection';
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ export * from './components/switch/index';
|
|
|
19
19
|
export * from './components/tabs/index';
|
|
20
20
|
export * from './components/tags-input/index';
|
|
21
21
|
export * from './components/toast/index';
|
|
22
|
+
export * from './components/toggle-group/index';
|
|
22
23
|
export * from './components/tooltip/index';
|
|
23
24
|
export * from './components/tree-view/index';
|
|
24
25
|
export * from './hooks/use-list-collection';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skeletonlabs/skeleton-svelte",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "The Svelte package for Skeleton.",
|
|
5
5
|
"author": "endigo9740 <chris@skeletonlabs.dev>",
|
|
6
6
|
"repository": {
|
|
@@ -42,26 +42,27 @@
|
|
|
42
42
|
"@zag-js/tabs": "1.26.1",
|
|
43
43
|
"@zag-js/tags-input": "1.26.1",
|
|
44
44
|
"@zag-js/toast": "1.26.1",
|
|
45
|
+
"@zag-js/toggle-group": "1.26.1",
|
|
45
46
|
"@zag-js/tooltip": "1.26.1",
|
|
46
47
|
"@zag-js/tree-view": "1.26.1",
|
|
47
|
-
"@skeletonlabs/skeleton-common": "4.0
|
|
48
|
+
"@skeletonlabs/skeleton-common": "4.1.0"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"svelte": "^5.29.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
|
-
"@sveltejs/kit": "2.46.
|
|
54
|
+
"@sveltejs/kit": "2.46.5",
|
|
54
55
|
"@sveltejs/package": "2.5.4",
|
|
55
56
|
"@sveltejs/vite-plugin-svelte": "6.2.1",
|
|
56
57
|
"@testing-library/jest-dom": "6.9.1",
|
|
57
58
|
"@testing-library/svelte": "5.2.8",
|
|
58
59
|
"jsdom": "27.0.0",
|
|
59
|
-
"svelte": "5.39.
|
|
60
|
+
"svelte": "5.39.12",
|
|
60
61
|
"svelte-check": "4.3.3",
|
|
61
62
|
"typescript": "5.9.3",
|
|
62
63
|
"vite": "7.1.9",
|
|
63
64
|
"vitest": "3.2.4",
|
|
64
|
-
"@skeletonlabs/skeleton": "4.0
|
|
65
|
+
"@skeletonlabs/skeleton": "4.1.0"
|
|
65
66
|
},
|
|
66
67
|
"license": "MIT",
|
|
67
68
|
"type": "module",
|