bits-ui 0.11.4 → 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/calendar/components/calendar.svelte +6 -3
- package/dist/bits/calendar/components/calendar.svelte.d.ts +3 -1
- package/dist/bits/date-picker/components/date-picker-calendar.svelte +6 -3
- package/dist/bits/date-picker/components/date-picker-calendar.svelte.d.ts +3 -1
- package/dist/bits/date-picker/components/date-picker.svelte +4 -0
- package/dist/bits/date-range-picker/components/date-range-picker-calendar.svelte +6 -3
- package/dist/bits/date-range-picker/components/date-range-picker-calendar.svelte.d.ts +3 -1
- package/dist/bits/date-range-picker/components/date-range-picker.svelte +4 -0
- 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/range-calendar/components/range-calendar.svelte +10 -3
- package/dist/bits/range-calendar/components/range-calendar.svelte.d.ts +5 -3
- 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
|
@@ -36,7 +36,7 @@ const {
|
|
|
36
36
|
states: {
|
|
37
37
|
value: localValue,
|
|
38
38
|
placeholder: localPlaceholder,
|
|
39
|
-
months,
|
|
39
|
+
months: localMonths,
|
|
40
40
|
weekdays
|
|
41
41
|
},
|
|
42
42
|
updateOption,
|
|
@@ -126,10 +126,13 @@ $:
|
|
|
126
126
|
$:
|
|
127
127
|
Object.assign(builder, attrs);
|
|
128
128
|
const dispatch = createDispatcher();
|
|
129
|
+
let months = $localMonths;
|
|
130
|
+
$:
|
|
131
|
+
months = $localMonths;
|
|
129
132
|
</script>
|
|
130
133
|
|
|
131
134
|
{#if asChild}
|
|
132
|
-
<slot
|
|
135
|
+
<slot {months} weekdays={$weekdays} {builder} />
|
|
133
136
|
{:else}
|
|
134
137
|
<div
|
|
135
138
|
{...builder} use:builder.action
|
|
@@ -137,6 +140,6 @@ const dispatch = createDispatcher();
|
|
|
137
140
|
on:m-keydown={dispatch}
|
|
138
141
|
bind:this={el}
|
|
139
142
|
>
|
|
140
|
-
<slot
|
|
143
|
+
<slot {months} weekdays={$weekdays} {builder} />
|
|
141
144
|
</div>
|
|
142
145
|
{/if}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { DateValue } from "@internationalized/date";
|
|
3
|
+
import { type Month } from "@melt-ui/svelte";
|
|
2
4
|
import type { Props } from "../types.js";
|
|
3
5
|
declare class __sveltets_Render<Multiple extends boolean> {
|
|
4
6
|
props(): Props<Multiple>;
|
|
@@ -7,7 +9,7 @@ declare class __sveltets_Render<Multiple extends boolean> {
|
|
|
7
9
|
};
|
|
8
10
|
slots(): {
|
|
9
11
|
default: {
|
|
10
|
-
months:
|
|
12
|
+
months: Month<DateValue>[];
|
|
11
13
|
weekdays: string[];
|
|
12
14
|
builder: {
|
|
13
15
|
id: string;
|
|
@@ -5,7 +5,7 @@ export let asChild = false;
|
|
|
5
5
|
export let id = void 0;
|
|
6
6
|
const {
|
|
7
7
|
elements: { calendar },
|
|
8
|
-
states: { months, weekdays },
|
|
8
|
+
states: { months: localMonths, weekdays },
|
|
9
9
|
ids
|
|
10
10
|
} = getCtx();
|
|
11
11
|
$:
|
|
@@ -18,12 +18,15 @@ $:
|
|
|
18
18
|
builder = $calendar;
|
|
19
19
|
$:
|
|
20
20
|
Object.assign(builder, attrs);
|
|
21
|
+
let months = $localMonths;
|
|
22
|
+
$:
|
|
23
|
+
months = $localMonths;
|
|
21
24
|
</script>
|
|
22
25
|
|
|
23
26
|
{#if asChild}
|
|
24
|
-
<slot {builder}
|
|
27
|
+
<slot {builder} {months} weekdays={$weekdays} />
|
|
25
28
|
{:else}
|
|
26
29
|
<div {...builder} use:builder.action {...$$restProps} on:m-keydown={dispatch}>
|
|
27
|
-
<slot {builder}
|
|
30
|
+
<slot {builder} {months} weekdays={$weekdays} />
|
|
28
31
|
</div>
|
|
29
32
|
{/if}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { type Month } from "@melt-ui/svelte";
|
|
2
3
|
import type { CalendarEvents, CalendarProps } from "../types.js";
|
|
4
|
+
import type { DateValue } from "@internationalized/date";
|
|
3
5
|
declare const __propDef: {
|
|
4
6
|
props: CalendarProps;
|
|
5
7
|
slots: {
|
|
@@ -16,7 +18,7 @@ declare const __propDef: {
|
|
|
16
18
|
} & {
|
|
17
19
|
action: (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown">;
|
|
18
20
|
};
|
|
19
|
-
months:
|
|
21
|
+
months: Month<DateValue>[];
|
|
20
22
|
weekdays: string[];
|
|
21
23
|
};
|
|
22
24
|
};
|
|
@@ -22,6 +22,7 @@ export let isDateDisabled = void 0;
|
|
|
22
22
|
export let fixedWeeks = void 0;
|
|
23
23
|
export let calendarLabel = void 0;
|
|
24
24
|
export let weekdayFormat = void 0;
|
|
25
|
+
export let numberOfMonths = void 0;
|
|
25
26
|
const {
|
|
26
27
|
states: {
|
|
27
28
|
value: localValue,
|
|
@@ -48,6 +49,7 @@ const {
|
|
|
48
49
|
minValue,
|
|
49
50
|
readonly,
|
|
50
51
|
weekdayFormat,
|
|
52
|
+
numberOfMonths,
|
|
51
53
|
isDateUnavailable,
|
|
52
54
|
onValueChange: ({ next }) => {
|
|
53
55
|
if (value !== next) {
|
|
@@ -158,6 +160,8 @@ $:
|
|
|
158
160
|
updateOption("calendarLabel", calendarLabel);
|
|
159
161
|
$:
|
|
160
162
|
updateOption("weekdayFormat", weekdayFormat);
|
|
163
|
+
$:
|
|
164
|
+
updateOption("numberOfMonths", numberOfMonths);
|
|
161
165
|
</script>
|
|
162
166
|
|
|
163
167
|
<slot ids={$idValues} isInvalid={$localIsInvalid} />
|
|
@@ -4,7 +4,7 @@ export let asChild = false;
|
|
|
4
4
|
export let id = void 0;
|
|
5
5
|
const {
|
|
6
6
|
elements: { calendar },
|
|
7
|
-
states: { months, weekdays },
|
|
7
|
+
states: { months: localMonths, weekdays },
|
|
8
8
|
ids
|
|
9
9
|
} = getCtx();
|
|
10
10
|
$:
|
|
@@ -16,12 +16,15 @@ $:
|
|
|
16
16
|
builder = $calendar;
|
|
17
17
|
$:
|
|
18
18
|
Object.assign(builder, attrs);
|
|
19
|
+
let months = $localMonths;
|
|
20
|
+
$:
|
|
21
|
+
months = $localMonths;
|
|
19
22
|
</script>
|
|
20
23
|
|
|
21
24
|
{#if asChild}
|
|
22
|
-
<slot {builder}
|
|
25
|
+
<slot {builder} {months} weekdays={$weekdays} />
|
|
23
26
|
{:else}
|
|
24
27
|
<div {...builder} use:builder.action {...$$restProps}>
|
|
25
|
-
<slot {builder}
|
|
28
|
+
<slot {builder} {months} weekdays={$weekdays} />
|
|
26
29
|
</div>
|
|
27
30
|
{/if}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { type Month } from "@melt-ui/svelte";
|
|
2
3
|
import type { CalendarProps } from "../types.js";
|
|
4
|
+
import type { DateValue } from "@internationalized/date";
|
|
3
5
|
declare const __propDef: {
|
|
4
6
|
props: CalendarProps;
|
|
5
7
|
events: {
|
|
@@ -19,7 +21,7 @@ declare const __propDef: {
|
|
|
19
21
|
} & {
|
|
20
22
|
action: (node: HTMLElement) => import("@melt-ui/svelte/internal/types").MeltActionReturn<"keydown">;
|
|
21
23
|
};
|
|
22
|
-
months:
|
|
24
|
+
months: Month<DateValue>[];
|
|
23
25
|
weekdays: string[];
|
|
24
26
|
};
|
|
25
27
|
};
|
|
@@ -23,6 +23,7 @@ export let fixedWeeks = void 0;
|
|
|
23
23
|
export let calendarLabel = void 0;
|
|
24
24
|
export let weekdayFormat = void 0;
|
|
25
25
|
export let startValue = void 0;
|
|
26
|
+
export let numberOfMonths = void 0;
|
|
26
27
|
const {
|
|
27
28
|
states: {
|
|
28
29
|
value: localValue,
|
|
@@ -51,6 +52,7 @@ const {
|
|
|
51
52
|
minValue,
|
|
52
53
|
readonly,
|
|
53
54
|
weekdayFormat,
|
|
55
|
+
numberOfMonths,
|
|
54
56
|
isDateUnavailable,
|
|
55
57
|
onValueChange: ({ next }) => {
|
|
56
58
|
if (value !== next) {
|
|
@@ -211,6 +213,8 @@ $:
|
|
|
211
213
|
updateOption("calendarLabel", calendarLabel);
|
|
212
214
|
$:
|
|
213
215
|
updateOption("weekdayFormat", weekdayFormat);
|
|
216
|
+
$:
|
|
217
|
+
updateOption("numberOfMonths", numberOfMonths);
|
|
214
218
|
</script>
|
|
215
219
|
|
|
216
220
|
<slot
|
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 {};
|