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
|
@@ -24,6 +24,7 @@ export let id = void 0;
|
|
|
24
24
|
export let weekdayFormat = void 0;
|
|
25
25
|
export let initialFocus = false;
|
|
26
26
|
export let startValue = void 0;
|
|
27
|
+
export let numberOfMonths = void 0;
|
|
27
28
|
let el = void 0;
|
|
28
29
|
onMount(() => {
|
|
29
30
|
if (!initialFocus || !el)
|
|
@@ -35,7 +36,7 @@ const {
|
|
|
35
36
|
states: {
|
|
36
37
|
value: localValue,
|
|
37
38
|
placeholder: localPlaceholder,
|
|
38
|
-
months,
|
|
39
|
+
months: localMonths,
|
|
39
40
|
weekdays,
|
|
40
41
|
startValue: localStartValue,
|
|
41
42
|
endValue
|
|
@@ -58,6 +59,7 @@ const {
|
|
|
58
59
|
fixedWeeks,
|
|
59
60
|
calendarLabel,
|
|
60
61
|
weekdayFormat,
|
|
62
|
+
numberOfMonths,
|
|
61
63
|
onPlaceholderChange: ({ next }) => {
|
|
62
64
|
if (placeholder !== next) {
|
|
63
65
|
onPlaceholderChange?.(next);
|
|
@@ -109,18 +111,23 @@ $:
|
|
|
109
111
|
updateOption("calendarLabel", calendarLabel);
|
|
110
112
|
$:
|
|
111
113
|
updateOption("weekdayFormat", weekdayFormat);
|
|
114
|
+
$:
|
|
115
|
+
updateOption("numberOfMonths", numberOfMonths);
|
|
112
116
|
const attrs = getAttrs("root");
|
|
113
117
|
const dispatch = createDispatcher();
|
|
114
118
|
$:
|
|
115
119
|
builder = $calendar;
|
|
116
120
|
$:
|
|
117
121
|
Object.assign(builder, attrs);
|
|
122
|
+
let months = $localMonths;
|
|
123
|
+
$:
|
|
124
|
+
months = $localMonths;
|
|
118
125
|
</script>
|
|
119
126
|
|
|
120
127
|
{#if asChild}
|
|
121
128
|
<slot
|
|
122
129
|
{builder}
|
|
123
|
-
|
|
130
|
+
{months}
|
|
124
131
|
weekdays={$weekdays}
|
|
125
132
|
startValue={$localStartValue}
|
|
126
133
|
endValue={$endValue}
|
|
@@ -134,7 +141,7 @@ $:
|
|
|
134
141
|
>
|
|
135
142
|
<slot
|
|
136
143
|
{builder}
|
|
137
|
-
|
|
144
|
+
{months}
|
|
138
145
|
weekdays={$weekdays}
|
|
139
146
|
startValue={$localStartValue}
|
|
140
147
|
endValue={$endValue}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { type Month } from "@melt-ui/svelte";
|
|
2
3
|
import type { Events, Props } from "../types.js";
|
|
4
|
+
import type { DateValue } from "@internationalized/date";
|
|
3
5
|
declare const __propDef: {
|
|
4
6
|
props: Props;
|
|
5
7
|
slots: {
|
|
@@ -16,10 +18,10 @@ 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
|
-
startValue:
|
|
22
|
-
endValue:
|
|
23
|
+
startValue: DateValue | undefined;
|
|
24
|
+
endValue: DateValue | undefined;
|
|
23
25
|
};
|
|
24
26
|
};
|
|
25
27
|
events: Events;
|
|
@@ -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 {};
|