bits-ui 0.8.3 → 0.8.5
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/accordion/components/Accordion.svelte.d.ts +2 -2
- package/dist/bits/accordion/components/AccordionContent.svelte.d.ts +1 -1
- package/dist/bits/accordion/components/AccordionHeader.svelte.d.ts +1 -1
- package/dist/bits/accordion/components/AccordionItem.svelte.d.ts +1 -1
- package/dist/bits/accordion/components/AccordionTrigger.svelte.d.ts +1 -1
- package/dist/bits/alert-dialog/components/AlertDialog.svelte.d.ts +1 -1
- package/dist/bits/alert-dialog/components/AlertDialogAction.svelte.d.ts +1 -1
- package/dist/bits/alert-dialog/components/AlertDialogCancel.svelte.d.ts +1 -1
- package/dist/bits/alert-dialog/components/AlertDialogContent.svelte.d.ts +1 -1
- package/dist/bits/alert-dialog/components/AlertDialogDescription.svelte.d.ts +1 -1
- package/dist/bits/alert-dialog/components/AlertDialogOverlay.svelte.d.ts +1 -1
- package/dist/bits/alert-dialog/components/AlertDialogPortal.svelte.d.ts +1 -1
- package/dist/bits/alert-dialog/components/AlertDialogTitle.svelte.d.ts +1 -1
- package/dist/bits/alert-dialog/components/AlertDialogTrigger.svelte.d.ts +1 -1
- package/dist/bits/aspect-ratio/components/AspectRatio.svelte.d.ts +1 -1
- package/dist/bits/avatar/components/Avatar.svelte.d.ts +1 -1
- package/dist/bits/avatar/components/AvatarFallback.svelte.d.ts +1 -1
- package/dist/bits/avatar/components/AvatarImage.svelte.d.ts +1 -1
- package/dist/bits/button/components/Button.svelte +1 -1
- package/dist/bits/button/components/Button.svelte.d.ts +4 -4
- package/dist/bits/checkbox/components/Checkbox.svelte +1 -1
- package/dist/bits/checkbox/components/Checkbox.svelte.d.ts +2 -2
- package/dist/bits/checkbox/components/CheckboxIndicator.svelte.d.ts +1 -1
- package/dist/bits/checkbox/components/CheckboxInput.svelte +5 -5
- package/dist/bits/checkbox/components/CheckboxInput.svelte.d.ts +1 -237
- package/dist/bits/collapsible/components/Collapsible.svelte.d.ts +2 -2
- package/dist/bits/collapsible/components/CollapsibleContent.svelte.d.ts +1 -1
- package/dist/bits/collapsible/components/CollapsibleTrigger.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenu.svelte +3 -2
- package/dist/bits/context-menu/components/ContextMenu.svelte.d.ts +7 -2
- package/dist/bits/context-menu/components/ContextMenuArrow.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuCheckboxIndicator.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuCheckboxItem.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuContent.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuGroup.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuItem.svelte +1 -1
- package/dist/bits/context-menu/components/ContextMenuItem.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuLabel.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuRadioGroup.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuRadioItem.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuSeparator.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuSub.svelte +2 -2
- package/dist/bits/context-menu/components/ContextMenuSub.svelte.d.ts +8 -1
- package/dist/bits/context-menu/components/ContextMenuSubContent.svelte.d.ts +2 -1
- package/dist/bits/context-menu/components/ContextMenuSubTrigger.svelte +1 -1
- package/dist/bits/context-menu/components/ContextMenuSubTrigger.svelte.d.ts +1 -1
- package/dist/bits/context-menu/components/ContextMenuTrigger.svelte.d.ts +1 -3
- package/dist/bits/context-menu/ctx.d.ts +30 -6
- package/dist/bits/dialog/components/Dialog.svelte.d.ts +1 -1
- package/dist/bits/dialog/components/DialogClose.svelte.d.ts +1 -1
- package/dist/bits/dialog/components/DialogContent.svelte.d.ts +1 -1
- package/dist/bits/dialog/components/DialogDescription.svelte.d.ts +1 -1
- package/dist/bits/dialog/components/DialogOverlay.svelte.d.ts +1 -1
- package/dist/bits/dialog/components/DialogPortal.svelte.d.ts +1 -1
- package/dist/bits/dialog/components/DialogTitle.svelte.d.ts +1 -1
- package/dist/bits/dialog/components/DialogTrigger.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenu.svelte +3 -2
- package/dist/bits/dropdown-menu/components/DropdownMenu.svelte.d.ts +7 -2
- package/dist/bits/dropdown-menu/components/DropdownMenuArrow.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuCheckboxIndicator.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuCheckboxItem.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuContent.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuGroup.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuItem.svelte +3 -4
- package/dist/bits/dropdown-menu/components/DropdownMenuItem.svelte.d.ts +8 -2
- package/dist/bits/dropdown-menu/components/DropdownMenuLabel.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuRadioGroup.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuRadioItem.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuSeparator.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuSub.svelte +2 -2
- package/dist/bits/dropdown-menu/components/DropdownMenuSub.svelte.d.ts +8 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuSubContent.svelte.d.ts +2 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuSubTrigger.svelte +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuSubTrigger.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/components/DropdownMenuTrigger.svelte.d.ts +1 -1
- package/dist/bits/dropdown-menu/ctx.d.ts +30 -4
- package/dist/bits/label/components/Label.svelte.d.ts +1 -1
- package/dist/bits/link-preview/components/LinkPreview.svelte.d.ts +1 -1
- package/dist/bits/link-preview/components/LinkPreviewArrow.svelte.d.ts +1 -1
- package/dist/bits/link-preview/components/LinkPreviewContent.svelte.d.ts +1 -1
- package/dist/bits/link-preview/components/LinkPreviewTrigger.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/Menubar.svelte +4 -3
- package/dist/bits/menubar/components/Menubar.svelte.d.ts +4 -1
- package/dist/bits/menubar/components/MenubarArrow.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarCheckboxIndicator.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarCheckboxItem.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarContent.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarGroup.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarItem.svelte +1 -1
- package/dist/bits/menubar/components/MenubarItem.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarLabel.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarMenu.svelte +3 -2
- package/dist/bits/menubar/components/MenubarMenu.svelte.d.ts +6 -2
- package/dist/bits/menubar/components/MenubarRadioGroup.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarRadioItem.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarSeparator.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarSub.svelte +2 -2
- package/dist/bits/menubar/components/MenubarSub.svelte.d.ts +8 -1
- package/dist/bits/menubar/components/MenubarSubContent.svelte.d.ts +2 -1
- package/dist/bits/menubar/components/MenubarSubTrigger.svelte +1 -1
- package/dist/bits/menubar/components/MenubarSubTrigger.svelte.d.ts +1 -1
- package/dist/bits/menubar/components/MenubarTrigger.svelte.d.ts +1 -1
- package/dist/bits/menubar/ctx.d.ts +43 -10
- package/dist/bits/popover/components/Popover.svelte.d.ts +1 -1
- package/dist/bits/popover/components/PopoverArrow.svelte.d.ts +1 -1
- package/dist/bits/popover/components/PopoverClose.svelte.d.ts +1 -1
- package/dist/bits/popover/components/PopoverContent.svelte.d.ts +1 -1
- package/dist/bits/popover/components/PopoverTrigger.svelte.d.ts +1 -1
- package/dist/bits/progress/components/Progress.svelte.d.ts +1 -1
- package/dist/bits/radio-group/components/RadioGroup.svelte.d.ts +1 -1
- package/dist/bits/radio-group/components/RadioGroupInput.svelte.d.ts +1 -1
- package/dist/bits/radio-group/components/RadioGroupItem.svelte.d.ts +1 -1
- package/dist/bits/select/components/Select.svelte.d.ts +1 -1
- package/dist/bits/select/components/SelectArrow.svelte.d.ts +1 -1
- package/dist/bits/select/components/SelectContent.svelte.d.ts +1 -1
- package/dist/bits/select/components/SelectGroup.svelte.d.ts +1 -1
- package/dist/bits/select/components/SelectInput.svelte +3 -2
- package/dist/bits/select/components/SelectInput.svelte.d.ts +1 -1
- package/dist/bits/select/components/SelectItem.svelte.d.ts +1 -1
- package/dist/bits/select/components/SelectLabel.svelte.d.ts +1 -1
- package/dist/bits/select/components/SelectTrigger.svelte.d.ts +1 -1
- package/dist/bits/select/components/SelectValue.svelte.d.ts +1 -1
- package/dist/bits/separator/components/Separator.svelte.d.ts +1 -1
- package/dist/bits/slider/components/Slider.svelte +3 -3
- package/dist/bits/slider/components/Slider.svelte.d.ts +2 -1
- package/dist/bits/slider/components/SliderInput.svelte.d.ts +5 -5
- package/dist/bits/slider/components/SliderRange.svelte.d.ts +1 -1
- package/dist/bits/slider/components/SliderThumb.svelte.d.ts +1 -1
- package/dist/bits/slider/components/SliderTick.svelte +16 -0
- package/dist/bits/{toggle/components/ToggleInput.svelte.d.ts → slider/components/SliderTick.svelte.d.ts} +132 -148
- package/dist/bits/slider/ctx.d.ts +1 -1
- package/dist/bits/slider/ctx.js +1 -1
- package/dist/bits/slider/index.d.ts +2 -1
- package/dist/bits/slider/index.js +3 -2
- package/dist/bits/slider/types.d.ts +2 -1
- package/dist/bits/switch/components/Switch.svelte +12 -1
- package/dist/bits/switch/components/Switch.svelte.d.ts +7 -3
- package/dist/bits/switch/components/SwitchInput.svelte +14 -4
- package/dist/bits/switch/components/SwitchInput.svelte.d.ts +1 -1
- package/dist/bits/switch/components/SwitchThumb.svelte.d.ts +1 -1
- package/dist/bits/switch/types.d.ts +10 -0
- package/dist/bits/tabs/components/Tabs.svelte.d.ts +1 -1
- package/dist/bits/tabs/components/TabsContent.svelte.d.ts +1 -1
- package/dist/bits/tabs/components/TabsList.svelte.d.ts +1 -1
- package/dist/bits/tabs/components/TabsTrigger.svelte.d.ts +1 -1
- package/dist/bits/toggle/components/Toggle.svelte.d.ts +1 -1
- package/dist/bits/toggle/index.d.ts +1 -2
- package/dist/bits/toggle/index.js +2 -3
- package/dist/bits/toggle/types.d.ts +2 -3
- package/dist/bits/tooltip/components/Tooltip.svelte.d.ts +1 -1
- package/dist/bits/tooltip/components/TooltipArrow.svelte.d.ts +1 -1
- package/dist/bits/tooltip/components/TooltipContent.svelte.d.ts +1 -1
- package/dist/bits/tooltip/components/TooltipTrigger.svelte.d.ts +1 -1
- package/dist/internal/attrs.d.ts +9 -0
- package/dist/internal/attrs.js +12 -0
- package/dist/internal/id.d.ts +1 -0
- package/dist/internal/id.js +4 -0
- package/dist/internal/index.d.ts +9 -2
- package/dist/internal/index.js +9 -2
- package/dist/internal/kbd.d.ts +35 -0
- package/dist/internal/kbd.js +35 -0
- package/dist/internal/object.d.ts +1 -0
- package/dist/internal/object.js +10 -0
- package/dist/internal/sleep.d.ts +1 -0
- package/dist/internal/sleep.js +3 -0
- package/dist/internal/style.d.ts +3 -0
- package/dist/internal/style.js +27 -0
- package/dist/internal/transition.d.ts +11 -0
- package/dist/internal/transition.js +55 -0
- package/dist/internal/updater.d.ts +5 -0
- package/dist/internal/updater.js +10 -0
- package/package.json +14 -8
- package/dist/bits/toggle/components/ToggleInput.svelte +0 -8
- package/dist/internal/helpers.d.ts +0 -37
- package/dist/internal/helpers.js +0 -132
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CreateToggleProps } from "@melt-ui/svelte";
|
|
2
2
|
import type { AsChild, Expand, OmitPressed, OnChangeFn } from "../../internal/index.js";
|
|
3
|
-
import type { HTMLButtonAttributes
|
|
3
|
+
import type { HTMLButtonAttributes } from "svelte/elements";
|
|
4
4
|
import type { CustomEventHandler } from "../../index.js";
|
|
5
5
|
type Props = Expand<OmitPressed<CreateToggleProps> & {
|
|
6
6
|
pressed?: boolean;
|
|
@@ -10,5 +10,4 @@ type Events<T extends Element = HTMLButtonElement> = {
|
|
|
10
10
|
click: CustomEventHandler<MouseEvent, T>;
|
|
11
11
|
keydown: CustomEventHandler<KeyboardEvent, T>;
|
|
12
12
|
};
|
|
13
|
-
type
|
|
14
|
-
export type { Props, InputProps, Props as ToggleProps, InputProps as ToggleInputProps, Events, Events as ToggleEvents };
|
|
13
|
+
export type { Props, Props as ToggleProps, Events, Events as ToggleEvents };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
-
forceVisible?: boolean | undefined;
|
|
5
4
|
closeOnEscape?: boolean | undefined;
|
|
6
5
|
positioning?: import("@melt-ui/svelte/internal/actions").FloatingConfig | undefined;
|
|
7
6
|
arrowSize?: number | undefined;
|
|
8
7
|
openDelay?: number | undefined;
|
|
9
8
|
closeDelay?: number | undefined;
|
|
9
|
+
forceVisible?: boolean | undefined;
|
|
10
10
|
group?: string | boolean | undefined;
|
|
11
11
|
portal?: string | HTMLElement | null | undefined;
|
|
12
12
|
closeOnPointerDown?: boolean | undefined;
|
|
@@ -62,7 +62,7 @@ declare const __propDef: {
|
|
|
62
62
|
'data-sveltekit-replacestate'?: true | "" | "off" | null | undefined;
|
|
63
63
|
'aria-activedescendant'?: string | null | undefined;
|
|
64
64
|
'aria-atomic'?: import("svelte/elements.js").Booleanish | null | undefined;
|
|
65
|
-
'aria-autocomplete'?: "
|
|
65
|
+
'aria-autocomplete'?: "none" | "list" | "inline" | "both" | null | undefined;
|
|
66
66
|
'aria-busy'?: import("svelte/elements.js").Booleanish | null | undefined;
|
|
67
67
|
'aria-checked'?: boolean | "false" | "true" | "mixed" | null | undefined;
|
|
68
68
|
'aria-colcount'?: number | null | undefined;
|
|
@@ -70,7 +70,7 @@ declare class __sveltets_Render<T extends Transition, In extends Transition, Out
|
|
|
70
70
|
'data-sveltekit-replacestate'?: true | "" | "off" | null | undefined;
|
|
71
71
|
'aria-activedescendant'?: string | null | undefined;
|
|
72
72
|
'aria-atomic'?: import("svelte/elements.js").Booleanish | null | undefined;
|
|
73
|
-
'aria-autocomplete'?: "
|
|
73
|
+
'aria-autocomplete'?: "none" | "list" | "inline" | "both" | null | undefined;
|
|
74
74
|
'aria-busy'?: import("svelte/elements.js").Booleanish | null | undefined;
|
|
75
75
|
'aria-checked'?: boolean | "false" | "true" | "mixed" | null | undefined;
|
|
76
76
|
'aria-colcount'?: number | null | undefined;
|
|
@@ -72,7 +72,7 @@ declare const __propDef: {
|
|
|
72
72
|
'data-sveltekit-replacestate'?: true | "" | "off" | null | undefined;
|
|
73
73
|
'aria-activedescendant'?: string | null | undefined;
|
|
74
74
|
'aria-atomic'?: import("svelte/elements.js").Booleanish | null | undefined;
|
|
75
|
-
'aria-autocomplete'?: "
|
|
75
|
+
'aria-autocomplete'?: "none" | "list" | "inline" | "both" | null | undefined;
|
|
76
76
|
'aria-busy'?: import("svelte/elements.js").Booleanish | null | undefined;
|
|
77
77
|
'aria-checked'?: boolean | "false" | "true" | "mixed" | null | undefined;
|
|
78
78
|
'aria-colcount'?: number | null | undefined;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Bit } from "@/content/api-reference/index.js";
|
|
2
|
+
export declare function createBitAttrs<T extends readonly string[]>(bit: Bit, parts: T): (part: T[number]) => Record<string, string>;
|
|
3
|
+
export declare function disabledAttrs(disabled: boolean): {
|
|
4
|
+
"aria-disabled": boolean;
|
|
5
|
+
"data-disabled": string;
|
|
6
|
+
} | {
|
|
7
|
+
"aria-disabled"?: undefined;
|
|
8
|
+
"data-disabled"?: undefined;
|
|
9
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function createBitAttrs(bit, parts) {
|
|
2
|
+
const attrs = {};
|
|
3
|
+
parts.forEach((part) => {
|
|
4
|
+
attrs[part] = {
|
|
5
|
+
[`data-bits-${bit}-${part}`]: ""
|
|
6
|
+
};
|
|
7
|
+
});
|
|
8
|
+
return (part) => attrs[part];
|
|
9
|
+
}
|
|
10
|
+
export function disabledAttrs(disabled) {
|
|
11
|
+
return disabled ? { "aria-disabled": true, "data-disabled": "" } : {};
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function generateId(): string;
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
export * from "./attrs.js";
|
|
2
|
+
export * from "./events.js";
|
|
3
|
+
export * from "./id.js";
|
|
1
4
|
export * from "./is.js";
|
|
2
|
-
export * from "./
|
|
5
|
+
export * from "./kbd.js";
|
|
6
|
+
export * from "./object.js";
|
|
7
|
+
export * from "./sleep.js";
|
|
8
|
+
export * from "./style.js";
|
|
9
|
+
export * from "./transition.js";
|
|
3
10
|
export * from "./types.js";
|
|
4
|
-
export * from "./
|
|
11
|
+
export * from "./updater.js";
|
package/dist/internal/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
export * from "./attrs.js";
|
|
2
|
+
export * from "./events.js";
|
|
3
|
+
export * from "./id.js";
|
|
1
4
|
export * from "./is.js";
|
|
2
|
-
export * from "./
|
|
5
|
+
export * from "./kbd.js";
|
|
6
|
+
export * from "./object.js";
|
|
7
|
+
export * from "./sleep.js";
|
|
8
|
+
export * from "./style.js";
|
|
9
|
+
export * from "./transition.js";
|
|
3
10
|
export * from "./types.js";
|
|
4
|
-
export * from "./
|
|
11
|
+
export * from "./updater.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const kbd: {
|
|
2
|
+
ALT: string;
|
|
3
|
+
ARROW_DOWN: string;
|
|
4
|
+
ARROW_LEFT: string;
|
|
5
|
+
ARROW_RIGHT: string;
|
|
6
|
+
ARROW_UP: string;
|
|
7
|
+
BACKSPACE: string;
|
|
8
|
+
CAPS_LOCK: string;
|
|
9
|
+
CONTROL: string;
|
|
10
|
+
DELETE: string;
|
|
11
|
+
END: string;
|
|
12
|
+
ENTER: string;
|
|
13
|
+
ESCAPE: string;
|
|
14
|
+
F1: string;
|
|
15
|
+
F10: string;
|
|
16
|
+
F11: string;
|
|
17
|
+
F12: string;
|
|
18
|
+
F2: string;
|
|
19
|
+
F3: string;
|
|
20
|
+
F4: string;
|
|
21
|
+
F5: string;
|
|
22
|
+
F6: string;
|
|
23
|
+
F7: string;
|
|
24
|
+
F8: string;
|
|
25
|
+
F9: string;
|
|
26
|
+
HOME: string;
|
|
27
|
+
META: string;
|
|
28
|
+
PAGE_DOWN: string;
|
|
29
|
+
PAGE_UP: string;
|
|
30
|
+
SHIFT: string;
|
|
31
|
+
SPACE: string;
|
|
32
|
+
TAB: string;
|
|
33
|
+
CTRL: string;
|
|
34
|
+
ASTERISK: string;
|
|
35
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const kbd = {
|
|
2
|
+
ALT: "Alt",
|
|
3
|
+
ARROW_DOWN: "ArrowDown",
|
|
4
|
+
ARROW_LEFT: "ArrowLeft",
|
|
5
|
+
ARROW_RIGHT: "ArrowRight",
|
|
6
|
+
ARROW_UP: "ArrowUp",
|
|
7
|
+
BACKSPACE: "Backspace",
|
|
8
|
+
CAPS_LOCK: "CapsLock",
|
|
9
|
+
CONTROL: "Control",
|
|
10
|
+
DELETE: "Delete",
|
|
11
|
+
END: "End",
|
|
12
|
+
ENTER: "Enter",
|
|
13
|
+
ESCAPE: "Escape",
|
|
14
|
+
F1: "F1",
|
|
15
|
+
F10: "F10",
|
|
16
|
+
F11: "F11",
|
|
17
|
+
F12: "F12",
|
|
18
|
+
F2: "F2",
|
|
19
|
+
F3: "F3",
|
|
20
|
+
F4: "F4",
|
|
21
|
+
F5: "F5",
|
|
22
|
+
F6: "F6",
|
|
23
|
+
F7: "F7",
|
|
24
|
+
F8: "F8",
|
|
25
|
+
F9: "F9",
|
|
26
|
+
HOME: "Home",
|
|
27
|
+
META: "Meta",
|
|
28
|
+
PAGE_DOWN: "PageDown",
|
|
29
|
+
PAGE_UP: "PageUp",
|
|
30
|
+
SHIFT: "Shift",
|
|
31
|
+
SPACE: " ",
|
|
32
|
+
TAB: "Tab",
|
|
33
|
+
CTRL: "Control",
|
|
34
|
+
ASTERISK: "*"
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function removeUndefined<T extends object>(obj: T): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sleep(ms: number): Promise<unknown>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function styleToString(style) {
|
|
2
|
+
return Object.keys(style).reduce((str, key) => {
|
|
3
|
+
if (style[key] === undefined)
|
|
4
|
+
return str;
|
|
5
|
+
return str + `${key}:${style[key]};`;
|
|
6
|
+
}, "");
|
|
7
|
+
}
|
|
8
|
+
export const srOnlyStyles = styleToString({
|
|
9
|
+
position: "absolute",
|
|
10
|
+
width: "1px",
|
|
11
|
+
height: "1px",
|
|
12
|
+
padding: "0",
|
|
13
|
+
margin: "-1px",
|
|
14
|
+
overflow: "hidden",
|
|
15
|
+
clip: "rect(0, 0, 0, 0)",
|
|
16
|
+
whiteSpace: "nowrap",
|
|
17
|
+
borderWidth: "0"
|
|
18
|
+
});
|
|
19
|
+
export const hiddenInputStyles = styleToString({
|
|
20
|
+
position: "absolute",
|
|
21
|
+
width: "25px",
|
|
22
|
+
height: "25px",
|
|
23
|
+
opacity: "0",
|
|
24
|
+
margin: "0px",
|
|
25
|
+
pointerEvents: "none",
|
|
26
|
+
transform: "translateX(-100%)"
|
|
27
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Transition, TransitionParams, TransitionTimesStore } from "./index.js";
|
|
2
|
+
type TransitionsObj<T extends Transition = Transition, In extends Transition = Transition, Out extends Transition = Transition> = {
|
|
3
|
+
transition?: T;
|
|
4
|
+
transitionConfig?: TransitionParams<T>;
|
|
5
|
+
inTransition?: In;
|
|
6
|
+
inTransitionConfig?: TransitionParams<In>;
|
|
7
|
+
outTransition?: Out;
|
|
8
|
+
outTransitionConfig?: TransitionParams<Out>;
|
|
9
|
+
};
|
|
10
|
+
export declare function setTransitionTimes(transitionTimes: TransitionTimesStore, transitionsObj: TransitionsObj): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isBrowser } from "./index.js";
|
|
2
|
+
export function setTransitionTimes(transitionTimes, transitionsObj) {
|
|
3
|
+
if (!isBrowser)
|
|
4
|
+
return;
|
|
5
|
+
const { transition, transitionConfig, inTransition, inTransitionConfig, outTransition, outTransitionConfig } = transitionsObj;
|
|
6
|
+
if (transition) {
|
|
7
|
+
if (transitionConfig) {
|
|
8
|
+
const { delay, duration } = transition(document.body, transitionConfig);
|
|
9
|
+
const time = calcTime(delay, duration);
|
|
10
|
+
transitionTimes.set({
|
|
11
|
+
in: time,
|
|
12
|
+
out: time
|
|
13
|
+
});
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const { delay, duration } = transition(document.body);
|
|
17
|
+
const time = calcTime(delay, duration);
|
|
18
|
+
transitionTimes.set({
|
|
19
|
+
in: time,
|
|
20
|
+
out: time
|
|
21
|
+
});
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
let inTime = 0;
|
|
25
|
+
let outTime = 0;
|
|
26
|
+
if (inTransition) {
|
|
27
|
+
if (inTransitionConfig) {
|
|
28
|
+
const { delay, duration } = inTransition(document.body, inTransitionConfig);
|
|
29
|
+
inTime = calcTime(delay, duration);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const { delay, duration } = inTransition(document.body);
|
|
33
|
+
inTime = calcTime(delay, duration);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (outTransition) {
|
|
37
|
+
if (outTransitionConfig) {
|
|
38
|
+
const { delay, duration } = outTransition(document.body, outTransitionConfig);
|
|
39
|
+
outTime = calcTime(delay, duration);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const { delay, duration } = outTransition(document.body);
|
|
43
|
+
outTime = calcTime(delay, duration);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
transitionTimes.set({
|
|
47
|
+
in: inTime,
|
|
48
|
+
out: outTime
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function calcTime(delay, duration) {
|
|
52
|
+
const numDelay = delay ?? 0;
|
|
53
|
+
const numDuration = duration ?? 0;
|
|
54
|
+
return numDelay + numDuration;
|
|
55
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
import type { Writable } from "svelte/store";
|
|
3
|
+
type Options = Record<string, Writable<unknown>>;
|
|
4
|
+
export declare function getOptionUpdater(options: Options): <K extends string, V extends unknown>(key: K, value: V | undefined) => void;
|
|
5
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bits-ui",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.5",
|
|
4
4
|
"license": "MIT",
|
|
5
|
+
"repository": "github:huntabyte/bits-ui",
|
|
5
6
|
"scripts": {
|
|
6
7
|
"dev": "concurrently \"pnpm:dev:content\" \"pnpm:dev:svelte\"",
|
|
7
8
|
"dev:content": "contentlayer dev",
|
|
@@ -12,13 +13,11 @@
|
|
|
12
13
|
"preview": "vite preview",
|
|
13
14
|
"package": "svelte-kit sync && svelte-package && publint",
|
|
14
15
|
"prepublishOnly": "pnpm run package",
|
|
15
|
-
"test": "pnpm run test:integration && pnpm run test:unit",
|
|
16
16
|
"check": "pnpm build:content && svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
17
17
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
|
18
18
|
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
|
19
19
|
"format": "prettier --plugin-search-dir . --write .",
|
|
20
|
-
"test
|
|
21
|
-
"test:unit": "vitest",
|
|
20
|
+
"test": "vitest",
|
|
22
21
|
"release": "changeset publish",
|
|
23
22
|
"changeset": "changeset"
|
|
24
23
|
},
|
|
@@ -44,6 +43,12 @@
|
|
|
44
43
|
"@sveltejs/package": "^2.2.2",
|
|
45
44
|
"@svitejs/changesets-changelog-github-compact": "^1.1.0",
|
|
46
45
|
"@tailwindcss/typography": "^0.5.10",
|
|
46
|
+
"@testing-library/dom": "^9.3.1",
|
|
47
|
+
"@testing-library/jest-dom": "^5.17.0",
|
|
48
|
+
"@testing-library/svelte": "^4.0.3",
|
|
49
|
+
"@testing-library/user-event": "^14.4.3",
|
|
50
|
+
"@types/jest-axe": "^3.5.5",
|
|
51
|
+
"@types/testing-library__jest-dom": "^5.14.9",
|
|
47
52
|
"@typescript-eslint/eslint-plugin": "^6.8.0",
|
|
48
53
|
"@typescript-eslint/parser": "^6.8.0",
|
|
49
54
|
"autoprefixer": "^10.4.16",
|
|
@@ -55,6 +60,8 @@
|
|
|
55
60
|
"eslint-plugin-svelte": "^2.34.0",
|
|
56
61
|
"esm-env": "^1.0.0",
|
|
57
62
|
"hast-util-to-html": "^9.0.0",
|
|
63
|
+
"jest-axe": "^8.0.0",
|
|
64
|
+
"jsdom": "^22.1.0",
|
|
58
65
|
"lucide-svelte": "^0.268.0",
|
|
59
66
|
"phosphor-svelte": "^1.3.0",
|
|
60
67
|
"postcss": "^8.4.31",
|
|
@@ -65,8 +72,8 @@
|
|
|
65
72
|
"radix-icons-svelte": "^1.2.1",
|
|
66
73
|
"rehype-pretty-code": "^0.10.0",
|
|
67
74
|
"remark-gfm": "^4.0.0",
|
|
75
|
+
"resize-observer-polyfill": "^1.5.1",
|
|
68
76
|
"shiki": "^0.14.5",
|
|
69
|
-
"shikiji": "^0.6.10",
|
|
70
77
|
"svelte": "^4.2.2",
|
|
71
78
|
"svelte-check": "^3.5.2",
|
|
72
79
|
"svelte-sequential-preprocessor": "^2.0.1",
|
|
@@ -74,19 +81,18 @@
|
|
|
74
81
|
"tailwind-merge": "^1.14.0",
|
|
75
82
|
"tailwind-variants": "^0.1.14",
|
|
76
83
|
"tailwindcss": "^3.3.3",
|
|
77
|
-
"tailwindcss-animate": "^1.0.7",
|
|
78
84
|
"tslib": "^2.6.2",
|
|
79
85
|
"typescript": "^5.2.2",
|
|
80
86
|
"unist-builder": "^4.0.0",
|
|
81
87
|
"unist-util-visit": "^5.0.0",
|
|
82
88
|
"vite": "^4.5.0",
|
|
83
|
-
"vitest": "
|
|
89
|
+
"vitest": "0.33.0"
|
|
84
90
|
},
|
|
85
91
|
"svelte": "./dist/index.js",
|
|
86
92
|
"types": "./dist/index.d.ts",
|
|
87
93
|
"type": "module",
|
|
88
94
|
"dependencies": {
|
|
89
|
-
"@melt-ui/svelte": "0.57.
|
|
95
|
+
"@melt-ui/svelte": "0.57.2",
|
|
90
96
|
"nanoid": "^5.0.2"
|
|
91
97
|
},
|
|
92
98
|
"peerDependencies": {
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/// <reference types="svelte" />
|
|
2
|
-
import type { Writable } from "svelte/store";
|
|
3
|
-
import type { Builder, Transition, TransitionParams, TransitionTimesStore } from "./types.js";
|
|
4
|
-
import type { Bit } from "@/content/api-reference/index.js";
|
|
5
|
-
export declare function noop(): void;
|
|
6
|
-
export declare function generateId(): string;
|
|
7
|
-
export declare function removeUndefined<T extends object>(obj: T): T;
|
|
8
|
-
type Options = Record<string, Writable<unknown>>;
|
|
9
|
-
export declare function getOptionUpdater(options: Options): <K extends string, V extends unknown>(key: K, value: V | undefined) => void;
|
|
10
|
-
type BuilderActionsParams = {
|
|
11
|
-
builders: Builder[];
|
|
12
|
-
};
|
|
13
|
-
type BuilderActionsReturn = {
|
|
14
|
-
destroy: () => void;
|
|
15
|
-
};
|
|
16
|
-
export declare function builderActions(node: HTMLElement, params: BuilderActionsParams): BuilderActionsReturn;
|
|
17
|
-
export declare function getAttrs(builders: Builder[]): Record<string, unknown>;
|
|
18
|
-
export declare function disabledAttrs(disabled: boolean): {
|
|
19
|
-
"aria-disabled": boolean;
|
|
20
|
-
"data-disabled": string;
|
|
21
|
-
} | {
|
|
22
|
-
"aria-disabled"?: undefined;
|
|
23
|
-
"data-disabled"?: undefined;
|
|
24
|
-
};
|
|
25
|
-
export declare function sleep(ms: number): Promise<unknown>;
|
|
26
|
-
export declare function styleToString(style: Record<string, number | string | undefined>): string;
|
|
27
|
-
type TransitionsObj<T extends Transition = Transition, In extends Transition = Transition, Out extends Transition = Transition> = {
|
|
28
|
-
transition?: T;
|
|
29
|
-
transitionConfig?: TransitionParams<T>;
|
|
30
|
-
inTransition?: In;
|
|
31
|
-
inTransitionConfig?: TransitionParams<In>;
|
|
32
|
-
outTransition?: Out;
|
|
33
|
-
outTransitionConfig?: TransitionParams<Out>;
|
|
34
|
-
};
|
|
35
|
-
export declare function setTransitionTimes(transitionTimes: TransitionTimesStore, transitionsObj: TransitionsObj): void;
|
|
36
|
-
export declare function createBitAttrs<T extends readonly string[]>(bit: Bit, parts: T): (part: T[number]) => Record<string, string>;
|
|
37
|
-
export {};
|
package/dist/internal/helpers.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { nanoid } from "nanoid/non-secure";
|
|
2
|
-
import { isBrowser } from "./is.js";
|
|
3
|
-
export function noop() {
|
|
4
|
-
// do nothing
|
|
5
|
-
}
|
|
6
|
-
export function generateId() {
|
|
7
|
-
return nanoid(10);
|
|
8
|
-
}
|
|
9
|
-
export function removeUndefined(obj) {
|
|
10
|
-
const result = {};
|
|
11
|
-
for (const key in obj) {
|
|
12
|
-
const value = obj[key];
|
|
13
|
-
if (value !== undefined) {
|
|
14
|
-
result[key] = value;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
}
|
|
19
|
-
export function getOptionUpdater(options) {
|
|
20
|
-
return function (key, value) {
|
|
21
|
-
if (value === undefined)
|
|
22
|
-
return;
|
|
23
|
-
const store = options[key];
|
|
24
|
-
store.set(value);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export function builderActions(node, params) {
|
|
28
|
-
const unsubs = [];
|
|
29
|
-
params.builders.forEach((builder) => {
|
|
30
|
-
const act = builder.action(node);
|
|
31
|
-
if (act) {
|
|
32
|
-
unsubs.push(act);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return {
|
|
36
|
-
destroy: () => {
|
|
37
|
-
unsubs.forEach((unsub) => {
|
|
38
|
-
if (unsub.destroy) {
|
|
39
|
-
unsub.destroy();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export function getAttrs(builders) {
|
|
46
|
-
const attrs = {};
|
|
47
|
-
builders.forEach((builder) => {
|
|
48
|
-
Object.keys(builder).forEach((key) => {
|
|
49
|
-
if (key !== "action") {
|
|
50
|
-
attrs[key] = builder[key];
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
return attrs;
|
|
55
|
-
}
|
|
56
|
-
export function disabledAttrs(disabled) {
|
|
57
|
-
return disabled ? { "aria-disabled": true, "data-disabled": "" } : {};
|
|
58
|
-
}
|
|
59
|
-
export function sleep(ms) {
|
|
60
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
61
|
-
}
|
|
62
|
-
export function styleToString(style) {
|
|
63
|
-
return Object.keys(style).reduce((str, key) => {
|
|
64
|
-
if (style[key] === undefined)
|
|
65
|
-
return str;
|
|
66
|
-
return str + `${key}:${style[key]};`;
|
|
67
|
-
}, "");
|
|
68
|
-
}
|
|
69
|
-
export function setTransitionTimes(transitionTimes, transitionsObj) {
|
|
70
|
-
if (!isBrowser)
|
|
71
|
-
return;
|
|
72
|
-
const { transition, transitionConfig, inTransition, inTransitionConfig, outTransition, outTransitionConfig } = transitionsObj;
|
|
73
|
-
if (transition) {
|
|
74
|
-
if (transitionConfig) {
|
|
75
|
-
const { delay, duration } = transition(document.body, transitionConfig);
|
|
76
|
-
const time = calcTime(delay, duration);
|
|
77
|
-
transitionTimes.set({
|
|
78
|
-
in: time,
|
|
79
|
-
out: time
|
|
80
|
-
});
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
const { delay, duration } = transition(document.body);
|
|
84
|
-
const time = calcTime(delay, duration);
|
|
85
|
-
transitionTimes.set({
|
|
86
|
-
in: time,
|
|
87
|
-
out: time
|
|
88
|
-
});
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
let inTime = 0;
|
|
92
|
-
let outTime = 0;
|
|
93
|
-
if (inTransition) {
|
|
94
|
-
if (inTransitionConfig) {
|
|
95
|
-
const { delay, duration } = inTransition(document.body, inTransitionConfig);
|
|
96
|
-
inTime = calcTime(delay, duration);
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
const { delay, duration } = inTransition(document.body);
|
|
100
|
-
inTime = calcTime(delay, duration);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (outTransition) {
|
|
104
|
-
if (outTransitionConfig) {
|
|
105
|
-
const { delay, duration } = outTransition(document.body, outTransitionConfig);
|
|
106
|
-
outTime = calcTime(delay, duration);
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
const { delay, duration } = outTransition(document.body);
|
|
110
|
-
outTime = calcTime(delay, duration);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
transitionTimes.set({
|
|
114
|
-
in: inTime,
|
|
115
|
-
out: outTime
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function calcTime(delay, duration) {
|
|
119
|
-
const numDelay = delay ?? 0;
|
|
120
|
-
const numDuration = duration ?? 0;
|
|
121
|
-
return numDelay + numDuration;
|
|
122
|
-
}
|
|
123
|
-
export function createBitAttrs(bit, parts) {
|
|
124
|
-
const attrs = {};
|
|
125
|
-
parts.forEach((part) => {
|
|
126
|
-
attrs[part] = {
|
|
127
|
-
[`data-bits-${bit}-${part}`]: ""
|
|
128
|
-
};
|
|
129
|
-
});
|
|
130
|
-
// return a getter that given a part returns the attrs for that part
|
|
131
|
-
return (part) => attrs[part];
|
|
132
|
-
}
|