bits-ui 0.11.5 → 0.11.6
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/bits/index.d.ts +2 -0
- package/dist/bits/index.js +2 -0
- package/dist/bits/pagination/_export.types.d.ts +1 -0
- package/dist/bits/pagination/_export.types.js +1 -0
- package/dist/bits/pagination/_types.d.ts +26 -0
- package/dist/bits/pagination/_types.js +6 -0
- package/dist/bits/pagination/components/pagination-next-button.svelte +27 -0
- package/dist/bits/pagination/components/pagination-next-button.svelte.d.ts +26 -0
- package/dist/bits/pagination/components/pagination-page.svelte +30 -0
- package/dist/bits/pagination/components/pagination-page.svelte.d.ts +27 -0
- package/dist/bits/pagination/components/pagination-prev-button.svelte +27 -0
- package/dist/bits/pagination/components/pagination-prev-button.svelte.d.ts +26 -0
- package/dist/bits/pagination/components/pagination.svelte +38 -0
- package/dist/bits/pagination/components/pagination.svelte.d.ts +30 -0
- package/dist/bits/pagination/ctx.d.ts +55 -0
- package/dist/bits/pagination/ctx.js +17 -0
- package/dist/bits/pagination/index.d.ts +5 -0
- package/dist/bits/pagination/index.js +5 -0
- package/dist/bits/pagination/types.d.ts +21 -0
- package/dist/bits/pagination/types.js +1 -0
- package/dist/bits/toolbar/_export.types.d.ts +1 -0
- package/dist/bits/toolbar/_export.types.js +1 -0
- package/dist/bits/toolbar/_types.d.ts +48 -0
- package/dist/bits/toolbar/_types.js +1 -0
- package/dist/bits/toolbar/components/toolbar-button.svelte +27 -0
- package/dist/bits/toolbar/components/toolbar-button.svelte.d.ts +25 -0
- package/dist/bits/toolbar/components/toolbar-group-item.svelte +30 -0
- package/dist/bits/toolbar/components/toolbar-group-item.svelte.d.ts +33 -0
- package/dist/bits/toolbar/components/toolbar-group.svelte +48 -0
- package/dist/bits/toolbar/components/toolbar-group.svelte.d.ts +26 -0
- package/dist/bits/toolbar/components/toolbar-link.svelte +27 -0
- package/dist/bits/toolbar/components/toolbar-link.svelte.d.ts +25 -0
- package/dist/bits/toolbar/components/toolbar.svelte +30 -0
- package/dist/bits/toolbar/components/toolbar.svelte.d.ts +26 -0
- package/dist/bits/toolbar/ctx.d.ts +120 -0
- package/dist/bits/toolbar/ctx.js +30 -0
- package/dist/bits/toolbar/index.d.ts +6 -0
- package/dist/bits/toolbar/index.js +6 -0
- package/dist/bits/toolbar/types.d.ts +23 -0
- package/dist/bits/toolbar/types.js +1 -0
- package/dist/shared/index.d.ts +2 -2
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/bits/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export * as DropdownMenu from "./dropdown-menu/index.js";
|
|
|
16
16
|
export * as LinkPreview from "./link-preview/index.js";
|
|
17
17
|
export * as Label from "./label/index.js";
|
|
18
18
|
export * as Menubar from "./menubar/index.js";
|
|
19
|
+
export * as Pagination from "./pagination/index.js";
|
|
19
20
|
export * as Popover from "./popover/index.js";
|
|
20
21
|
export * as Progress from "./progress/index.js";
|
|
21
22
|
export * as RadioGroup from "./radio-group/index.js";
|
|
@@ -27,4 +28,5 @@ export * as Switch from "./switch/index.js";
|
|
|
27
28
|
export * as Tabs from "./tabs/index.js";
|
|
28
29
|
export * as Toggle from "./toggle/index.js";
|
|
29
30
|
export * as ToggleGroup from "./toggle-group/index.js";
|
|
31
|
+
export * as Toolbar from "./toolbar/index.js";
|
|
30
32
|
export * as Tooltip from "./tooltip/index.js";
|
package/dist/bits/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export * as DropdownMenu from "./dropdown-menu/index.js";
|
|
|
16
16
|
export * as LinkPreview from "./link-preview/index.js";
|
|
17
17
|
export * as Label from "./label/index.js";
|
|
18
18
|
export * as Menubar from "./menubar/index.js";
|
|
19
|
+
export * as Pagination from "./pagination/index.js";
|
|
19
20
|
export * as Popover from "./popover/index.js";
|
|
20
21
|
export * as Progress from "./progress/index.js";
|
|
21
22
|
export * as RadioGroup from "./radio-group/index.js";
|
|
@@ -27,4 +28,5 @@ export * as Switch from "./switch/index.js";
|
|
|
27
28
|
export * as Tabs from "./tabs/index.js";
|
|
28
29
|
export * as Toggle from "./toggle/index.js";
|
|
29
30
|
export * as ToggleGroup from "./toggle-group/index.js";
|
|
31
|
+
export * as Toolbar from "./toolbar/index.js";
|
|
30
32
|
export * as Tooltip from "./tooltip/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { Props as PaginationProps, PrevButtonProps as PaginationPrevButtonProps, NextButtonProps as PaginationNextButtonProps, PageProps as PaginationPageProps, Events as PaginationEvents, PrevButtonEvents as PaginationPrevButtonEvents, NextButtonEvents as PaginationNextButtonEvents, PageEvents as PaginationPageEvents } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We define prop types without the HTMLAttributes here so that we can use them
|
|
3
|
+
* to type-check our API documentation, which requires we document each prop,
|
|
4
|
+
* but we don't want to document the HTML attributes.
|
|
5
|
+
*/
|
|
6
|
+
import type { AsChild, Expand, OnChangeFn } from "../../internal";
|
|
7
|
+
import type { CreatePaginationProps, Page } from "@melt-ui/svelte";
|
|
8
|
+
type OmitPaginationProps<T> = Omit<T, "page" | "defaultPage" | "onPageChange">;
|
|
9
|
+
type Props = Expand<OmitPaginationProps<CreatePaginationProps> & {
|
|
10
|
+
/**
|
|
11
|
+
* The selected page. This updates as the users selects new pages.
|
|
12
|
+
*
|
|
13
|
+
* You can bind this to a value to programmatically control the value state.
|
|
14
|
+
*/
|
|
15
|
+
page?: number;
|
|
16
|
+
/**
|
|
17
|
+
* A callback function called when the page changes.
|
|
18
|
+
*/
|
|
19
|
+
onPageChange?: OnChangeFn<number>;
|
|
20
|
+
} & AsChild>;
|
|
21
|
+
type PageProps = {
|
|
22
|
+
page: Page;
|
|
23
|
+
} & AsChild;
|
|
24
|
+
type PrevButtonProps = AsChild;
|
|
25
|
+
type NextButtonProps = AsChild;
|
|
26
|
+
export type { Props, PrevButtonProps, NextButtonProps, PageProps };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>import { createDispatcher } from "../../../internal/events.js";
|
|
2
|
+
import { getAttrs, getCtx } from "../ctx.js";
|
|
3
|
+
import { melt } from "@melt-ui/svelte";
|
|
4
|
+
export let asChild = void 0;
|
|
5
|
+
const {
|
|
6
|
+
elements: { nextButton }
|
|
7
|
+
} = getCtx();
|
|
8
|
+
const attrs = getAttrs("next-button");
|
|
9
|
+
$:
|
|
10
|
+
builder = $nextButton;
|
|
11
|
+
$:
|
|
12
|
+
Object.assign(builder, attrs);
|
|
13
|
+
const dispatch = createDispatcher();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
{#if asChild}
|
|
17
|
+
<slot {builder} />
|
|
18
|
+
{:else}
|
|
19
|
+
<button
|
|
20
|
+
{...builder} use:builder.action
|
|
21
|
+
type="button"
|
|
22
|
+
{...$$restProps}
|
|
23
|
+
on:m-click={dispatch}
|
|
24
|
+
>
|
|
25
|
+
<slot {builder} />
|
|
26
|
+
</button>
|
|
27
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { NextButtonProps } from "../types.js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: NextButtonProps;
|
|
5
|
+
slots: {
|
|
6
|
+
default: {
|
|
7
|
+
builder: {
|
|
8
|
+
readonly 'aria-label': "Next";
|
|
9
|
+
readonly disabled: boolean;
|
|
10
|
+
} & {
|
|
11
|
+
[x: `data-melt-${string}`]: "";
|
|
12
|
+
} & {
|
|
13
|
+
action: (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown" | "click">;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
events: {
|
|
18
|
+
click: import("../../../index.js").CustomEventHandler<MouseEvent, HTMLDivElement>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type PaginationNextButtonProps = typeof __propDef.props;
|
|
22
|
+
export type PaginationNextButtonEvents = typeof __propDef.events;
|
|
23
|
+
export type PaginationNextButtonSlots = typeof __propDef.slots;
|
|
24
|
+
export default class PaginationNextButton extends SvelteComponent<PaginationNextButtonProps, PaginationNextButtonEvents, PaginationNextButtonSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>import { createDispatcher } from "../../../internal/events.js";
|
|
2
|
+
import { getAttrs, getCtx } from "../ctx.js";
|
|
3
|
+
import { melt } from "@melt-ui/svelte";
|
|
4
|
+
export let asChild = void 0;
|
|
5
|
+
export let page;
|
|
6
|
+
const {
|
|
7
|
+
elements: { pageTrigger }
|
|
8
|
+
} = getCtx();
|
|
9
|
+
const attrs = getAttrs("page");
|
|
10
|
+
$:
|
|
11
|
+
builder = $pageTrigger(page);
|
|
12
|
+
$:
|
|
13
|
+
Object.assign(builder, attrs);
|
|
14
|
+
const dispatch = createDispatcher();
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
{#if asChild}
|
|
18
|
+
<slot {builder} />
|
|
19
|
+
{:else}
|
|
20
|
+
<button
|
|
21
|
+
type="button"
|
|
22
|
+
{...builder} use:builder.action
|
|
23
|
+
on:m-click={dispatch}
|
|
24
|
+
{...$$restProps}
|
|
25
|
+
>
|
|
26
|
+
<slot {builder}>
|
|
27
|
+
{page.value}
|
|
28
|
+
</slot>
|
|
29
|
+
</button>
|
|
30
|
+
{/if}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { PageProps } from "../types.js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: PageProps;
|
|
5
|
+
slots: {
|
|
6
|
+
default: {
|
|
7
|
+
builder: ((pageItem: import("@melt-ui/svelte/index.js").Page) => {
|
|
8
|
+
'aria-label': string;
|
|
9
|
+
'data-value': number;
|
|
10
|
+
'data-selected': string | undefined;
|
|
11
|
+
}) & {
|
|
12
|
+
[x: `data-melt-${string}`]: "";
|
|
13
|
+
} & {
|
|
14
|
+
action: (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown" | "click">;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
click: import("../../../index.js").CustomEventHandler<MouseEvent, HTMLDivElement>;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export type PaginationPageProps = typeof __propDef.props;
|
|
23
|
+
export type PaginationPageEvents = typeof __propDef.events;
|
|
24
|
+
export type PaginationPageSlots = typeof __propDef.slots;
|
|
25
|
+
export default class PaginationPage extends SvelteComponent<PaginationPageProps, PaginationPageEvents, PaginationPageSlots> {
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>import { createDispatcher } from "../../../internal/events.js";
|
|
2
|
+
import { getAttrs, getCtx } from "../ctx.js";
|
|
3
|
+
import { melt } from "@melt-ui/svelte";
|
|
4
|
+
export let asChild = void 0;
|
|
5
|
+
const {
|
|
6
|
+
elements: { prevButton }
|
|
7
|
+
} = getCtx();
|
|
8
|
+
const attrs = getAttrs("prev-button");
|
|
9
|
+
$:
|
|
10
|
+
builder = $prevButton;
|
|
11
|
+
$:
|
|
12
|
+
Object.assign(builder, attrs);
|
|
13
|
+
const dispatch = createDispatcher();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
{#if asChild}
|
|
17
|
+
<slot {builder} />
|
|
18
|
+
{:else}
|
|
19
|
+
<button
|
|
20
|
+
{...builder} use:builder.action
|
|
21
|
+
type="button"
|
|
22
|
+
{...$$restProps}
|
|
23
|
+
on:m-click={dispatch}
|
|
24
|
+
>
|
|
25
|
+
<slot {builder} />
|
|
26
|
+
</button>
|
|
27
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { PrevButtonProps } from "../types.js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: PrevButtonProps;
|
|
5
|
+
slots: {
|
|
6
|
+
default: {
|
|
7
|
+
builder: {
|
|
8
|
+
readonly 'aria-label': "Previous";
|
|
9
|
+
readonly disabled: boolean;
|
|
10
|
+
} & {
|
|
11
|
+
[x: `data-melt-${string}`]: "";
|
|
12
|
+
} & {
|
|
13
|
+
action: (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown" | "click">;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
events: {
|
|
18
|
+
click: import("../../../index.js").CustomEventHandler<MouseEvent, HTMLDivElement>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type PaginationPrevButtonProps = typeof __propDef.props;
|
|
22
|
+
export type PaginationPrevButtonEvents = typeof __propDef.events;
|
|
23
|
+
export type PaginationPrevButtonSlots = typeof __propDef.slots;
|
|
24
|
+
export default class PaginationPrevButton extends SvelteComponent<PaginationPrevButtonProps, PaginationPrevButtonEvents, PaginationPrevButtonSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script>import { melt } from "@melt-ui/svelte";
|
|
2
|
+
import { getAttrs, setCtx } from "../ctx.js";
|
|
3
|
+
export let count;
|
|
4
|
+
export let page = void 0;
|
|
5
|
+
export let onPageChange = void 0;
|
|
6
|
+
export let perPage = void 0;
|
|
7
|
+
export let siblingCount = void 0;
|
|
8
|
+
export let asChild = false;
|
|
9
|
+
const {
|
|
10
|
+
elements: { root },
|
|
11
|
+
states: { pages, range }
|
|
12
|
+
} = setCtx({
|
|
13
|
+
count,
|
|
14
|
+
perPage,
|
|
15
|
+
siblingCount,
|
|
16
|
+
defaultPage: page,
|
|
17
|
+
onPageChange: ({ next }) => {
|
|
18
|
+
if (page !== next) {
|
|
19
|
+
onPageChange?.(next);
|
|
20
|
+
page = next;
|
|
21
|
+
}
|
|
22
|
+
return next;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const attrs = getAttrs("root");
|
|
26
|
+
$:
|
|
27
|
+
builder = $root;
|
|
28
|
+
$:
|
|
29
|
+
Object.assign(builder, attrs);
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
{#if asChild}
|
|
33
|
+
<slot {builder} pages={$pages} range={$range} />
|
|
34
|
+
{:else}
|
|
35
|
+
<div {...builder} use:builder.action {...$$restProps}>
|
|
36
|
+
<slot {builder} pages={$pages} range={$range} />
|
|
37
|
+
</div>
|
|
38
|
+
{/if}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Props } from "../types.js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: Props;
|
|
5
|
+
events: {
|
|
6
|
+
[evt: string]: CustomEvent<any>;
|
|
7
|
+
};
|
|
8
|
+
slots: {
|
|
9
|
+
default: {
|
|
10
|
+
builder: {
|
|
11
|
+
'data-scope': string;
|
|
12
|
+
} & {
|
|
13
|
+
[x: `data-melt-${string}`]: "";
|
|
14
|
+
} & {
|
|
15
|
+
action: import("svelte/action").Action<any, any, Record<never, any>>;
|
|
16
|
+
};
|
|
17
|
+
pages: import("@melt-ui/svelte/index.js").PageItem[];
|
|
18
|
+
range: {
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type PaginationProps = typeof __propDef.props;
|
|
26
|
+
export type PaginationEvents = typeof __propDef.events;
|
|
27
|
+
export type PaginationSlots = typeof __propDef.slots;
|
|
28
|
+
export default class Pagination extends SvelteComponent<PaginationProps, PaginationEvents, PaginationSlots> {
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import { type CreatePaginationProps, type Pagination as PaginationReturn } from "@melt-ui/svelte";
|
|
3
|
+
export declare const getAttrs: (part: "page" | "root" | "prev-button" | "next-button") => Record<string, string>;
|
|
4
|
+
export declare function setCtx(props: CreatePaginationProps): {
|
|
5
|
+
updateOption: <K extends string, V extends unknown>(key: K, value: V | undefined) => void;
|
|
6
|
+
elements: {
|
|
7
|
+
root: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<import("svelte/store").Stores | undefined, import("svelte/action").Action<any, any, Record<never, any>>, () => {
|
|
8
|
+
'data-scope': string;
|
|
9
|
+
}, string>;
|
|
10
|
+
pageTrigger: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<{
|
|
11
|
+
update: (updater: import("svelte/store").Updater<number>, sideEffect?: ((newValue: number) => void) | undefined) => void;
|
|
12
|
+
set: (this: void, value: number) => void;
|
|
13
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: import("svelte/store").Invalidator<number> | undefined): import("svelte/store").Unsubscriber;
|
|
14
|
+
}, (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown" | "click">, ($page: number) => (pageItem: import("@melt-ui/svelte").Page) => {
|
|
15
|
+
'aria-label': string;
|
|
16
|
+
'data-value': number;
|
|
17
|
+
'data-selected': string | undefined;
|
|
18
|
+
}, string>;
|
|
19
|
+
prevButton: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<{
|
|
20
|
+
update: (updater: import("svelte/store").Updater<number>, sideEffect?: ((newValue: number) => void) | undefined) => void;
|
|
21
|
+
set: (this: void, value: number) => void;
|
|
22
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: import("svelte/store").Invalidator<number> | undefined): import("svelte/store").Unsubscriber;
|
|
23
|
+
}, (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown" | "click">, ($page: number) => {
|
|
24
|
+
readonly 'aria-label': "Previous";
|
|
25
|
+
readonly disabled: boolean;
|
|
26
|
+
}, string>;
|
|
27
|
+
nextButton: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<[{
|
|
28
|
+
update: (updater: import("svelte/store").Updater<number>, sideEffect?: ((newValue: number) => void) | undefined) => void;
|
|
29
|
+
set: (this: void, value: number) => void;
|
|
30
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: import("svelte/store").Invalidator<number> | undefined): import("svelte/store").Unsubscriber;
|
|
31
|
+
}, import("svelte/store").Readable<number>], (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown" | "click">, ([$page, $totalPages]: [number, number]) => {
|
|
32
|
+
readonly 'aria-label': "Next";
|
|
33
|
+
readonly disabled: boolean;
|
|
34
|
+
}, string>;
|
|
35
|
+
};
|
|
36
|
+
states: {
|
|
37
|
+
range: import("svelte/store").Readable<{
|
|
38
|
+
start: number;
|
|
39
|
+
end: number;
|
|
40
|
+
}>;
|
|
41
|
+
page: {
|
|
42
|
+
update: (updater: import("svelte/store").Updater<number>, sideEffect?: ((newValue: number) => void) | undefined) => void;
|
|
43
|
+
set: (this: void, value: number) => void;
|
|
44
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<number>, invalidate?: import("svelte/store").Invalidator<number> | undefined): import("svelte/store").Unsubscriber;
|
|
45
|
+
};
|
|
46
|
+
pages: import("svelte/store").Readable<import("@melt-ui/svelte").PageItem[]>;
|
|
47
|
+
totalPages: import("svelte/store").Readable<number>;
|
|
48
|
+
};
|
|
49
|
+
options: {
|
|
50
|
+
count: import("svelte/store").Writable<number>;
|
|
51
|
+
perPage: import("svelte/store").Writable<number>;
|
|
52
|
+
siblingCount: import("svelte/store").Writable<number>;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export declare function getCtx(): PaginationReturn;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createPagination } from "@melt-ui/svelte";
|
|
2
|
+
import { getContext, setContext } from "svelte";
|
|
3
|
+
import { createBitAttrs, getOptionUpdater, removeUndefined } from "../../internal";
|
|
4
|
+
const NAME = "pagination";
|
|
5
|
+
const PARTS = ["root", "prev-button", "next-button", "page"];
|
|
6
|
+
export const getAttrs = createBitAttrs(NAME, PARTS);
|
|
7
|
+
export function setCtx(props) {
|
|
8
|
+
const pagination = createPagination(removeUndefined(props));
|
|
9
|
+
setContext(NAME, pagination);
|
|
10
|
+
return {
|
|
11
|
+
...pagination,
|
|
12
|
+
updateOption: getOptionUpdater(pagination.options)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function getCtx() {
|
|
16
|
+
return getContext(NAME);
|
|
17
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Root } from "./components/pagination.svelte";
|
|
2
|
+
export { default as PrevButton } from "./components/pagination-prev-button.svelte";
|
|
3
|
+
export { default as NextButton } from "./components/pagination-next-button.svelte";
|
|
4
|
+
export { default as Page } from "./components/pagination-page.svelte";
|
|
5
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Root } from "./components/pagination.svelte";
|
|
2
|
+
export { default as PrevButton } from "./components/pagination-prev-button.svelte";
|
|
3
|
+
export { default as NextButton } from "./components/pagination-next-button.svelte";
|
|
4
|
+
export { default as Page } from "./components/pagination-page.svelte";
|
|
5
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
2
|
+
import type { CustomEventHandler } from "../..";
|
|
3
|
+
import type * as I from "./_types.js";
|
|
4
|
+
import type { HTMLDivAttributes } from "../../internal/types.js";
|
|
5
|
+
type Props = I.Props & HTMLDivAttributes;
|
|
6
|
+
type PrevButtonProps = I.PrevButtonProps & HTMLButtonAttributes;
|
|
7
|
+
type NextButtonProps = I.NextButtonProps & HTMLButtonAttributes;
|
|
8
|
+
type PageProps = I.PageProps & HTMLButtonAttributes;
|
|
9
|
+
/**
|
|
10
|
+
* Events
|
|
11
|
+
*/
|
|
12
|
+
type ButtonEvents = {
|
|
13
|
+
click: CustomEventHandler<MouseEvent, HTMLDivElement>;
|
|
14
|
+
};
|
|
15
|
+
type PrevButtonEvents = ButtonEvents;
|
|
16
|
+
type NextButtonEvents = ButtonEvents;
|
|
17
|
+
type PageEvents = ButtonEvents;
|
|
18
|
+
type Events = {
|
|
19
|
+
keydown: CustomEventHandler<KeyboardEvent, HTMLDivElement>;
|
|
20
|
+
};
|
|
21
|
+
export type { Props, PageProps, PrevButtonProps, NextButtonProps, Events, PageEvents, PrevButtonEvents, NextButtonEvents };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { Props as ToolbarProps, ButtonProps as ToolbarButtonProps, LinkProps as ToolbarLinkProps, GroupProps as ToolbarGroupProps, GroupItemProps as ToolbarItemProps, ButtonEvents as ToolbarButtonEvents, LinkEvents as ToolbarLinkEvents, GroupItemEvents as ToolbarItemEvents } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* We define prop types without the HTMLAttributes here so that we can use them
|
|
3
|
+
* to type-check our API documentation, which requires we document each prop,
|
|
4
|
+
* but we don't want to document the HTML attributes.
|
|
5
|
+
*/
|
|
6
|
+
import type { CreateToolbarProps, CreateToolbarGroupProps } from "@melt-ui/svelte";
|
|
7
|
+
import type { AsChild, Expand, OmitValue, OnChangeFn } from "../../internal/index.js";
|
|
8
|
+
type Props = Expand<CreateToolbarProps & AsChild>;
|
|
9
|
+
type ButtonProps = AsChild;
|
|
10
|
+
type LinkProps = AsChild;
|
|
11
|
+
type GroupProps<T extends "single" | "multiple"> = Expand<OmitValue<CreateToolbarGroupProps<T>> & {
|
|
12
|
+
/**
|
|
13
|
+
* The value of the toolbar toggle group, which is a string or an array of strings,
|
|
14
|
+
* depending on the type of the toolbar toggle group.
|
|
15
|
+
*
|
|
16
|
+
* You can bind to this to programmatically control the value.
|
|
17
|
+
*/
|
|
18
|
+
value?: CreateToolbarGroupProps<T>["defaultValue"];
|
|
19
|
+
/**
|
|
20
|
+
* A callback function called when the value changes.
|
|
21
|
+
*/
|
|
22
|
+
onValueChange?: OnChangeFn<CreateToolbarGroupProps<T>["defaultValue"]>;
|
|
23
|
+
/**
|
|
24
|
+
* The type of the toolbar toggle group.
|
|
25
|
+
*
|
|
26
|
+
* If the type is `"single"`, the toolbar toggle group allows only one item to be selected
|
|
27
|
+
* at a time. If the type is `"multiple"`, the toolbar toggle group allows multiple items
|
|
28
|
+
* to be selected at a time.
|
|
29
|
+
*/
|
|
30
|
+
type?: T;
|
|
31
|
+
} & AsChild>;
|
|
32
|
+
type GroupItemProps = Expand<{
|
|
33
|
+
/**
|
|
34
|
+
* The value of the toolbar toggle group item. When the toolbar toggle group item is selected,
|
|
35
|
+
* the toolbar toggle group's value will be set to this value if in `"single"` mode,
|
|
36
|
+
* or this value will be pushed to the toolbar toggle group's array value if in `"multiple"` mode.
|
|
37
|
+
*
|
|
38
|
+
* @required
|
|
39
|
+
*/
|
|
40
|
+
value: string;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the toolbar toggle group item is disabled.
|
|
43
|
+
*
|
|
44
|
+
* @defaultValue false
|
|
45
|
+
*/
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
} & AsChild>;
|
|
48
|
+
export type { Props, ButtonProps, LinkProps, GroupProps, GroupItemProps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>import { melt } from "@melt-ui/svelte";
|
|
2
|
+
import { getAttrs, getCtx } from "../ctx.js";
|
|
3
|
+
import { createDispatcher } from "../../../internal/events.js";
|
|
4
|
+
export let asChild = false;
|
|
5
|
+
const {
|
|
6
|
+
elements: { button }
|
|
7
|
+
} = getCtx();
|
|
8
|
+
const dispatch = createDispatcher();
|
|
9
|
+
const attrs = getAttrs("button");
|
|
10
|
+
$:
|
|
11
|
+
builder = $button;
|
|
12
|
+
$:
|
|
13
|
+
Object.assign(builder, attrs);
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
{#if asChild}
|
|
17
|
+
<slot {builder} />
|
|
18
|
+
{:else}
|
|
19
|
+
<button
|
|
20
|
+
{...builder} use:builder.action
|
|
21
|
+
type="button"
|
|
22
|
+
{...$$restProps}
|
|
23
|
+
on:m-keydown={dispatch}
|
|
24
|
+
>
|
|
25
|
+
<slot {builder} />
|
|
26
|
+
</button>
|
|
27
|
+
{/if}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { ButtonEvents, ButtonProps } from "../types.js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: ButtonProps;
|
|
5
|
+
slots: {
|
|
6
|
+
default: {
|
|
7
|
+
builder: {
|
|
8
|
+
readonly role: "button";
|
|
9
|
+
readonly type: "button";
|
|
10
|
+
readonly tabIndex: -1;
|
|
11
|
+
} & {
|
|
12
|
+
[x: `data-melt-${string}`]: "";
|
|
13
|
+
} & {
|
|
14
|
+
action: (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown">;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
events: ButtonEvents;
|
|
19
|
+
};
|
|
20
|
+
export type ToolbarButtonProps = typeof __propDef.props;
|
|
21
|
+
export type ToolbarButtonEvents = typeof __propDef.events;
|
|
22
|
+
export type ToolbarButtonSlots = typeof __propDef.slots;
|
|
23
|
+
export default class ToolbarButton extends SvelteComponent<ToolbarButtonProps, ToolbarButtonEvents, ToolbarButtonSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>import { melt } from "@melt-ui/svelte";
|
|
2
|
+
import { getGroupCtx, getAttrs } from "../ctx.js";
|
|
3
|
+
import { createDispatcher, disabledAttrs } from "../../../internal/index.js";
|
|
4
|
+
export let value;
|
|
5
|
+
export let disabled = false;
|
|
6
|
+
export let asChild = false;
|
|
7
|
+
const {
|
|
8
|
+
elements: { item }
|
|
9
|
+
} = getGroupCtx();
|
|
10
|
+
const dispatch = createDispatcher();
|
|
11
|
+
$:
|
|
12
|
+
attrs = { ...getAttrs("group-item"), ...disabledAttrs(disabled) };
|
|
13
|
+
$:
|
|
14
|
+
builder = $item({ value, disabled });
|
|
15
|
+
$:
|
|
16
|
+
Object.assign(builder, attrs);
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
{#if asChild}
|
|
20
|
+
<slot {builder} />
|
|
21
|
+
{:else}
|
|
22
|
+
<button
|
|
23
|
+
{...builder} use:builder.action
|
|
24
|
+
{...$$restProps}
|
|
25
|
+
on:m-click={dispatch}
|
|
26
|
+
on:m-keydown={dispatch}
|
|
27
|
+
>
|
|
28
|
+
<slot {builder} />
|
|
29
|
+
</button>
|
|
30
|
+
{/if}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { GroupItemProps, GroupItemEvents } from "../types.js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: GroupItemProps;
|
|
5
|
+
slots: {
|
|
6
|
+
default: {
|
|
7
|
+
builder: ((props: import("@melt-ui/svelte/index.js").ToolbarGroupItemProps) => {
|
|
8
|
+
readonly disabled: true | undefined;
|
|
9
|
+
readonly pressed: boolean;
|
|
10
|
+
readonly 'data-orientation': import("@melt-ui/svelte/internal/types").Orientation;
|
|
11
|
+
readonly 'data-disabled': true | undefined;
|
|
12
|
+
readonly 'data-value': string;
|
|
13
|
+
readonly 'data-state': "on" | "off";
|
|
14
|
+
readonly 'aria-checked': boolean | undefined;
|
|
15
|
+
readonly 'aria-pressed': boolean | undefined;
|
|
16
|
+
readonly type: "button";
|
|
17
|
+
readonly role: "radio" | undefined;
|
|
18
|
+
readonly 'data-melt-toolbar-item': "";
|
|
19
|
+
}) & {
|
|
20
|
+
[x: `data-melt-${string}`]: "";
|
|
21
|
+
} & {
|
|
22
|
+
action: (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown" | "click">;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
events: GroupItemEvents;
|
|
27
|
+
};
|
|
28
|
+
export type ToolbarGroupItemProps = typeof __propDef.props;
|
|
29
|
+
export type ToolbarGroupItemEvents = typeof __propDef.events;
|
|
30
|
+
export type ToolbarGroupItemSlots = typeof __propDef.slots;
|
|
31
|
+
export default class ToolbarGroupItem extends SvelteComponent<ToolbarGroupItemProps, ToolbarGroupItemEvents, ToolbarGroupItemSlots> {
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script>import { melt } from "@melt-ui/svelte";
|
|
2
|
+
import { setGroupCtx, getAttrs } from "../ctx.js";
|
|
3
|
+
export let type = "single";
|
|
4
|
+
export let disabled = void 0;
|
|
5
|
+
export let value = void 0;
|
|
6
|
+
export let onValueChange = void 0;
|
|
7
|
+
export let asChild = false;
|
|
8
|
+
const {
|
|
9
|
+
elements: { group },
|
|
10
|
+
states: { value: localValue },
|
|
11
|
+
updateOption
|
|
12
|
+
} = setGroupCtx({
|
|
13
|
+
disabled,
|
|
14
|
+
type,
|
|
15
|
+
defaultValue: value,
|
|
16
|
+
onValueChange: ({ next }) => {
|
|
17
|
+
if (Array.isArray(next)) {
|
|
18
|
+
onValueChange?.(next);
|
|
19
|
+
value = next;
|
|
20
|
+
return next;
|
|
21
|
+
}
|
|
22
|
+
if (value !== next) {
|
|
23
|
+
onValueChange?.(next);
|
|
24
|
+
value = next;
|
|
25
|
+
}
|
|
26
|
+
return next;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const attrs = getAttrs("group");
|
|
30
|
+
$:
|
|
31
|
+
value !== void 0 && localValue.set(value);
|
|
32
|
+
$:
|
|
33
|
+
updateOption("disabled", disabled);
|
|
34
|
+
$:
|
|
35
|
+
updateOption("type", type);
|
|
36
|
+
$:
|
|
37
|
+
builder = $group;
|
|
38
|
+
$:
|
|
39
|
+
Object.assign(builder, attrs);
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
{#if asChild}
|
|
43
|
+
<slot {builder} />
|
|
44
|
+
{:else}
|
|
45
|
+
<div {...builder} use:builder.action {...$$restProps}>
|
|
46
|
+
<slot {builder} />
|
|
47
|
+
</div>
|
|
48
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { GroupProps } from "../types.js";
|
|
3
|
+
declare class __sveltets_Render<T extends "single" | "multiple"> {
|
|
4
|
+
props(): GroupProps<T>;
|
|
5
|
+
events(): {} & {
|
|
6
|
+
[evt: string]: CustomEvent<any>;
|
|
7
|
+
};
|
|
8
|
+
slots(): {
|
|
9
|
+
default: {
|
|
10
|
+
builder: {
|
|
11
|
+
readonly role: "group";
|
|
12
|
+
readonly 'data-orientation': import("@melt-ui/svelte/internal/types").Orientation;
|
|
13
|
+
} & {
|
|
14
|
+
[x: `data-melt-${string}`]: "";
|
|
15
|
+
} & {
|
|
16
|
+
action: import("svelte/action").Action<any, any, Record<never, any>>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export type ToolbarGroupProps<T extends "single" | "multiple"> = ReturnType<__sveltets_Render<T>['props']>;
|
|
22
|
+
export type ToolbarGroupEvents<T extends "single" | "multiple"> = ReturnType<__sveltets_Render<T>['events']>;
|
|
23
|
+
export type ToolbarGroupSlots<T extends "single" | "multiple"> = ReturnType<__sveltets_Render<T>['slots']>;
|
|
24
|
+
export default class ToolbarGroup<T extends "single" | "multiple"> extends SvelteComponent<ToolbarGroupProps<T>, ToolbarGroupEvents<T>, ToolbarGroupSlots<T>> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>import { melt } from "@melt-ui/svelte";
|
|
2
|
+
import { getAttrs, getCtx } from "../ctx.js";
|
|
3
|
+
import { createDispatcher } from "../../../internal/events.js";
|
|
4
|
+
export let asChild = false;
|
|
5
|
+
const {
|
|
6
|
+
elements: { link }
|
|
7
|
+
} = getCtx();
|
|
8
|
+
const dispatch = createDispatcher();
|
|
9
|
+
const attrs = getAttrs("link");
|
|
10
|
+
$:
|
|
11
|
+
builder = $link;
|
|
12
|
+
$:
|
|
13
|
+
Object.assign(builder, attrs);
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
{#if asChild}
|
|
17
|
+
<slot {builder} />
|
|
18
|
+
{:else}
|
|
19
|
+
<svelte:element
|
|
20
|
+
this={"a"}
|
|
21
|
+
{...builder} use:builder.action
|
|
22
|
+
{...$$restProps}
|
|
23
|
+
on:m-keydown={dispatch}
|
|
24
|
+
>
|
|
25
|
+
<slot {builder} />
|
|
26
|
+
</svelte:element>
|
|
27
|
+
{/if}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { LinkEvents, LinkProps } from "../types.js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: LinkProps;
|
|
5
|
+
slots: {
|
|
6
|
+
default: {
|
|
7
|
+
builder: {
|
|
8
|
+
readonly role: "link";
|
|
9
|
+
readonly 'data-melt-toolbar-item': "";
|
|
10
|
+
readonly tabIndex: -1;
|
|
11
|
+
} & {
|
|
12
|
+
[x: `data-melt-${string}`]: "";
|
|
13
|
+
} & {
|
|
14
|
+
action: (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown">;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
events: LinkEvents;
|
|
19
|
+
};
|
|
20
|
+
export type ToolbarLinkProps = typeof __propDef.props;
|
|
21
|
+
export type ToolbarLinkEvents = typeof __propDef.events;
|
|
22
|
+
export type ToolbarLinkSlots = typeof __propDef.slots;
|
|
23
|
+
export default class ToolbarLink extends SvelteComponent<ToolbarLinkProps, ToolbarLinkEvents, ToolbarLinkSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<script>import { melt } from "@melt-ui/svelte";
|
|
2
|
+
import { setCtx, getAttrs } from "../ctx.js";
|
|
3
|
+
export let loop = true;
|
|
4
|
+
export let orientation = void 0;
|
|
5
|
+
export let asChild = false;
|
|
6
|
+
const {
|
|
7
|
+
elements: { root },
|
|
8
|
+
updateOption
|
|
9
|
+
} = setCtx({
|
|
10
|
+
loop,
|
|
11
|
+
orientation
|
|
12
|
+
});
|
|
13
|
+
const attrs = getAttrs("root");
|
|
14
|
+
$:
|
|
15
|
+
updateOption("loop", loop);
|
|
16
|
+
$:
|
|
17
|
+
updateOption("orientation", orientation);
|
|
18
|
+
$:
|
|
19
|
+
builder = $root;
|
|
20
|
+
$:
|
|
21
|
+
Object.assign(builder, attrs);
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
{#if asChild}
|
|
25
|
+
<slot {builder} />
|
|
26
|
+
{:else}
|
|
27
|
+
<div {...builder} use:builder.action {...$$restProps}>
|
|
28
|
+
<slot {builder} />
|
|
29
|
+
</div>
|
|
30
|
+
{/if}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Props } from "../types.js";
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: Props;
|
|
5
|
+
events: {
|
|
6
|
+
[evt: string]: CustomEvent<any>;
|
|
7
|
+
};
|
|
8
|
+
slots: {
|
|
9
|
+
default: {
|
|
10
|
+
builder: {
|
|
11
|
+
role: string;
|
|
12
|
+
'data-orientation': import("@melt-ui/svelte/internal/types").Orientation;
|
|
13
|
+
} & {
|
|
14
|
+
[x: `data-melt-${string}`]: "";
|
|
15
|
+
} & {
|
|
16
|
+
action: import("svelte/action").Action<any, any, Record<never, any>>;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type ToolbarProps = typeof __propDef.props;
|
|
22
|
+
export type ToolbarEvents = typeof __propDef.events;
|
|
23
|
+
export type ToolbarSlots = typeof __propDef.slots;
|
|
24
|
+
export default class Toolbar extends SvelteComponent<ToolbarProps, ToolbarEvents, ToolbarSlots> {
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import { type Toolbar as ToolbarReturn, type ToolbarGroup as ToolbarGroupReturn, type CreateToolbarProps as ToolbarProps, type CreateToolbarGroupProps as ToolbarGroupProps } from "@melt-ui/svelte";
|
|
3
|
+
export declare const getAttrs: (part: "link" | "group" | "button" | "root" | "group-item") => Record<string, string>;
|
|
4
|
+
export declare function setCtx(props: ToolbarProps): {
|
|
5
|
+
updateOption: <K extends string, V extends unknown>(key: K, value: V | undefined) => void;
|
|
6
|
+
elements: {
|
|
7
|
+
root: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<import("svelte/store").Writable<import("@melt-ui/svelte/internal/types").Orientation>, import("svelte/action").Action<any, any, Record<never, any>>, ($orientation: import("@melt-ui/svelte/internal/types").Orientation) => {
|
|
8
|
+
role: string;
|
|
9
|
+
'data-orientation': import("@melt-ui/svelte/internal/types").Orientation;
|
|
10
|
+
}, string>;
|
|
11
|
+
button: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<import("svelte/store").Stores | undefined, (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown">, () => {
|
|
12
|
+
readonly role: "button";
|
|
13
|
+
readonly type: "button";
|
|
14
|
+
readonly tabIndex: -1;
|
|
15
|
+
}, string>;
|
|
16
|
+
separator: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<import("svelte/store").Writable<import("@melt-ui/svelte/internal/types").Orientation>, import("svelte/action").Action<any, any, Record<never, any>>, ($orientation: import("@melt-ui/svelte/internal/types").Orientation) => {
|
|
17
|
+
readonly role: "separator";
|
|
18
|
+
readonly 'data-orientation': "horizontal" | "vertical";
|
|
19
|
+
readonly 'aria-orientation': "horizontal" | "vertical";
|
|
20
|
+
}, string>;
|
|
21
|
+
link: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<import("svelte/store").Stores | undefined, (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown">, () => {
|
|
22
|
+
readonly role: "link";
|
|
23
|
+
readonly 'data-melt-toolbar-item': "";
|
|
24
|
+
readonly tabIndex: -1;
|
|
25
|
+
}, string>;
|
|
26
|
+
};
|
|
27
|
+
builders: {
|
|
28
|
+
createToolbarGroup: <T extends import("@melt-ui/svelte").ToolbarGroupType = "single">(props?: ToolbarGroupProps<T> | undefined) => {
|
|
29
|
+
elements: {
|
|
30
|
+
group: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<import("svelte/store").Writable<import("@melt-ui/svelte/internal/types").Orientation>, import("svelte/action").Action<any, any, Record<never, any>>, ($orientation: import("@melt-ui/svelte/internal/types").Orientation) => {
|
|
31
|
+
readonly role: "group";
|
|
32
|
+
readonly 'data-orientation': import("@melt-ui/svelte/internal/types").Orientation;
|
|
33
|
+
}, string>;
|
|
34
|
+
item: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<[import("svelte/store").Writable<boolean>, import("svelte/store").Writable<"single" | T>, {
|
|
35
|
+
update: (updater: import("svelte/store").Updater<string | string[] | undefined>, sideEffect?: ((newValue: string | string[] | undefined) => void) | undefined) => void;
|
|
36
|
+
set: (this: void, value: string | string[] | undefined) => void;
|
|
37
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<string | string[] | undefined>, invalidate?: import("svelte/store").Invalidator<string | string[] | undefined> | undefined): import("svelte/store").Unsubscriber;
|
|
38
|
+
}, import("svelte/store").Writable<import("@melt-ui/svelte/internal/types").Orientation>], (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown" | "click">, ([$disabled, $type, $value, $orientation]: [boolean, "single" | T, string | string[] | undefined, import("@melt-ui/svelte/internal/types").Orientation]) => (props: import("@melt-ui/svelte").ToolbarGroupItemProps) => {
|
|
39
|
+
readonly disabled: true | undefined;
|
|
40
|
+
readonly pressed: boolean;
|
|
41
|
+
readonly 'data-orientation': import("@melt-ui/svelte/internal/types").Orientation;
|
|
42
|
+
readonly 'data-disabled': true | undefined;
|
|
43
|
+
readonly 'data-value': string;
|
|
44
|
+
readonly 'data-state': "on" | "off";
|
|
45
|
+
readonly 'aria-checked': boolean | undefined;
|
|
46
|
+
readonly 'aria-pressed': boolean | undefined;
|
|
47
|
+
readonly type: "button";
|
|
48
|
+
readonly role: "radio" | undefined;
|
|
49
|
+
readonly 'data-melt-toolbar-item': "";
|
|
50
|
+
}, string>;
|
|
51
|
+
};
|
|
52
|
+
states: {
|
|
53
|
+
value: {
|
|
54
|
+
update: (updater: import("svelte/store").Updater<string | string[] | undefined>, sideEffect?: ((newValue: string | string[] | undefined) => void) | undefined) => void;
|
|
55
|
+
set: (this: void, value: string | string[] | undefined) => void;
|
|
56
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<string | string[] | undefined>, invalidate?: import("svelte/store").Invalidator<string | string[] | undefined> | undefined): import("svelte/store").Unsubscriber;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
helpers: {
|
|
60
|
+
isPressed: import("svelte/store").Readable<(itemValue: string) => boolean>;
|
|
61
|
+
};
|
|
62
|
+
options: {
|
|
63
|
+
defaultValue?: import("svelte/store").Writable<(T extends "single" ? string : string[]) | undefined> | undefined;
|
|
64
|
+
value?: import("svelte/store").Writable<import("svelte/store").Writable<string | string[] | undefined> | undefined> | undefined;
|
|
65
|
+
onValueChange?: import("svelte/store").Writable<import("@melt-ui/svelte/internal/helpers").ChangeFn<string | string[] | undefined> | undefined> | undefined;
|
|
66
|
+
type: import("svelte/store").Writable<"single" | T>;
|
|
67
|
+
disabled: import("svelte/store").Writable<boolean>;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
options: {
|
|
72
|
+
loop: import("svelte/store").Writable<boolean>;
|
|
73
|
+
orientation: import("svelte/store").Writable<import("@melt-ui/svelte/internal/types").Orientation>;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export declare function setGroupCtx<T extends "single" | "multiple">(props: ToolbarGroupProps<T>): {
|
|
77
|
+
updateOption: <K extends string, V extends unknown>(key: K, value: V | undefined) => void;
|
|
78
|
+
elements: {
|
|
79
|
+
group: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<import("svelte/store").Writable<import("@melt-ui/svelte/internal/types").Orientation>, import("svelte/action").Action<any, any, Record<never, any>>, ($orientation: import("@melt-ui/svelte/internal/types").Orientation) => {
|
|
80
|
+
readonly role: "group";
|
|
81
|
+
readonly 'data-orientation': import("@melt-ui/svelte/internal/types").Orientation;
|
|
82
|
+
}, string>;
|
|
83
|
+
item: import("@melt-ui/svelte/internal/helpers").ExplicitBuilderReturn<[import("svelte/store").Writable<boolean>, import("svelte/store").Writable<"single" | T>, {
|
|
84
|
+
update: (updater: import("svelte/store").Updater<string | string[] | undefined>, sideEffect?: ((newValue: string | string[] | undefined) => void) | undefined) => void;
|
|
85
|
+
set: (this: void, value: string | string[] | undefined) => void;
|
|
86
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<string | string[] | undefined>, invalidate?: import("svelte/store").Invalidator<string | string[] | undefined> | undefined): import("svelte/store").Unsubscriber;
|
|
87
|
+
}, import("svelte/store").Writable<import("@melt-ui/svelte/internal/types").Orientation>], (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown" | "click">, ([$disabled, $type, $value, $orientation]: [boolean, "single" | T, string | string[] | undefined, import("@melt-ui/svelte/internal/types").Orientation]) => (props: import("@melt-ui/svelte").ToolbarGroupItemProps) => {
|
|
88
|
+
readonly disabled: true | undefined;
|
|
89
|
+
readonly pressed: boolean;
|
|
90
|
+
readonly 'data-orientation': import("@melt-ui/svelte/internal/types").Orientation;
|
|
91
|
+
readonly 'data-disabled': true | undefined;
|
|
92
|
+
readonly 'data-value': string;
|
|
93
|
+
readonly 'data-state': "on" | "off";
|
|
94
|
+
readonly 'aria-checked': boolean | undefined;
|
|
95
|
+
readonly 'aria-pressed': boolean | undefined;
|
|
96
|
+
readonly type: "button";
|
|
97
|
+
readonly role: "radio" | undefined;
|
|
98
|
+
readonly 'data-melt-toolbar-item': "";
|
|
99
|
+
}, string>;
|
|
100
|
+
};
|
|
101
|
+
states: {
|
|
102
|
+
value: {
|
|
103
|
+
update: (updater: import("svelte/store").Updater<string | string[] | undefined>, sideEffect?: ((newValue: string | string[] | undefined) => void) | undefined) => void;
|
|
104
|
+
set: (this: void, value: string | string[] | undefined) => void;
|
|
105
|
+
subscribe(this: void, run: import("svelte/store").Subscriber<string | string[] | undefined>, invalidate?: import("svelte/store").Invalidator<string | string[] | undefined> | undefined): import("svelte/store").Unsubscriber;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
helpers: {
|
|
109
|
+
isPressed: import("svelte/store").Readable<(itemValue: string) => boolean>;
|
|
110
|
+
};
|
|
111
|
+
options: {
|
|
112
|
+
defaultValue?: import("svelte/store").Writable<(T extends "single" ? string : string[]) | undefined> | undefined;
|
|
113
|
+
value?: import("svelte/store").Writable<import("svelte/store").Writable<string | string[] | undefined> | undefined> | undefined;
|
|
114
|
+
onValueChange?: import("svelte/store").Writable<import("@melt-ui/svelte/internal/helpers").ChangeFn<string | string[] | undefined> | undefined> | undefined;
|
|
115
|
+
type: import("svelte/store").Writable<"single" | T>;
|
|
116
|
+
disabled: import("svelte/store").Writable<boolean>;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
export declare function getCtx(): ToolbarReturn;
|
|
120
|
+
export declare function getGroupCtx(): ToolbarGroupReturn;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createBitAttrs, getOptionUpdater, removeUndefined } from "../../internal/index.js";
|
|
2
|
+
import { createToolbar } from "@melt-ui/svelte";
|
|
3
|
+
import { getContext, setContext } from "svelte";
|
|
4
|
+
const NAME = "toolbar";
|
|
5
|
+
const GROUP_NAME = "toolbar-group";
|
|
6
|
+
const PARTS = ["root", "button", "link", "group", "group-item"];
|
|
7
|
+
export const getAttrs = createBitAttrs(NAME, PARTS);
|
|
8
|
+
export function setCtx(props) {
|
|
9
|
+
const toolbar = createToolbar(removeUndefined(props));
|
|
10
|
+
setContext(NAME, toolbar);
|
|
11
|
+
return {
|
|
12
|
+
...toolbar,
|
|
13
|
+
updateOption: getOptionUpdater(toolbar.options)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export function setGroupCtx(props) {
|
|
17
|
+
const { builders: { createToolbarGroup } } = getCtx();
|
|
18
|
+
const group = createToolbarGroup(removeUndefined(props));
|
|
19
|
+
setContext(GROUP_NAME, group);
|
|
20
|
+
return {
|
|
21
|
+
...group,
|
|
22
|
+
updateOption: getOptionUpdater(group.options)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function getCtx() {
|
|
26
|
+
return getContext(NAME);
|
|
27
|
+
}
|
|
28
|
+
export function getGroupCtx() {
|
|
29
|
+
return getContext(GROUP_NAME);
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Root } from "./components/toolbar.svelte";
|
|
2
|
+
export { default as Button } from "./components/toolbar-button.svelte";
|
|
3
|
+
export { default as Link } from "./components/toolbar-link.svelte";
|
|
4
|
+
export { default as Group } from "./components/toolbar-group.svelte";
|
|
5
|
+
export { default as GroupItem } from "./components/toolbar-group-item.svelte";
|
|
6
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Root } from "./components/toolbar.svelte";
|
|
2
|
+
export { default as Button } from "./components/toolbar-button.svelte";
|
|
3
|
+
export { default as Link } from "./components/toolbar-link.svelte";
|
|
4
|
+
export { default as Group } from "./components/toolbar-group.svelte";
|
|
5
|
+
export { default as GroupItem } from "./components/toolbar-group-item.svelte";
|
|
6
|
+
export * from "./types.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HTMLDivAttributes } from "../../internal/index.js";
|
|
2
|
+
import type { HTMLAnchorAttributes, HTMLButtonAttributes } from "svelte/elements";
|
|
3
|
+
import type * as I from "./_types.js";
|
|
4
|
+
import type { CustomEventHandler } from "../../index.js";
|
|
5
|
+
type Props = I.Props & HTMLDivAttributes;
|
|
6
|
+
type ButtonProps = I.ButtonProps & HTMLButtonAttributes;
|
|
7
|
+
type LinkProps = I.LinkProps & HTMLAnchorAttributes;
|
|
8
|
+
type GroupProps<T extends "single" | "multiple"> = I.GroupProps<T> & HTMLDivAttributes;
|
|
9
|
+
type GroupItemProps = I.GroupItemProps & HTMLButtonAttributes;
|
|
10
|
+
/**
|
|
11
|
+
* Events
|
|
12
|
+
*/
|
|
13
|
+
type ButtonEvents = {
|
|
14
|
+
keydown: CustomEventHandler<KeyboardEvent, HTMLButtonElement>;
|
|
15
|
+
};
|
|
16
|
+
type LinkEvents = {
|
|
17
|
+
keydown: CustomEventHandler<KeyboardEvent, HTMLAnchorElement>;
|
|
18
|
+
};
|
|
19
|
+
type GroupItemEvents<T extends Element = HTMLButtonElement> = {
|
|
20
|
+
click: CustomEventHandler<MouseEvent, T>;
|
|
21
|
+
keydown: CustomEventHandler<KeyboardEvent, T>;
|
|
22
|
+
};
|
|
23
|
+
export type { Props, ButtonProps, LinkProps, GroupProps, GroupItemProps, ButtonEvents, LinkEvents, GroupItemEvents };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/shared/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DateValue } from "@internationalized/date";
|
|
2
|
-
import type { Month } from "@melt-ui/svelte";
|
|
2
|
+
import type { Month, Page, PageItem, Ellipsis } from "@melt-ui/svelte";
|
|
3
3
|
export type Selected<Value> = {
|
|
4
4
|
value: Value;
|
|
5
5
|
label?: string;
|
|
@@ -9,4 +9,4 @@ export type DateRange = {
|
|
|
9
9
|
end: DateValue | undefined;
|
|
10
10
|
};
|
|
11
11
|
export type SegmentPart = "month" | "day" | "year" | "hour" | "minute" | "second" | "dayPeriod" | "timeZoneName" | "literal";
|
|
12
|
-
export type { Month };
|
|
12
|
+
export type { Month, Page, PageItem, Ellipsis };
|
package/dist/types.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type * from "./bits/dropdown-menu/_export.types.js";
|
|
|
16
16
|
export type * from "./bits/label/_export.types.js";
|
|
17
17
|
export type * from "./bits/link-preview/_export.types.js";
|
|
18
18
|
export type * from "./bits/menubar/_export.types.js";
|
|
19
|
+
export type * from "./bits/pagination/_export.types.js";
|
|
19
20
|
export type * from "./bits/popover/_export.types.js";
|
|
20
21
|
export type * from "./bits/progress/_export.types.js";
|
|
21
22
|
export type * from "./bits/radio-group/_export.types.js";
|