@pzerelles/headlessui-svelte 2.1.2-next.32 → 2.1.2-next.33
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/button/Button.svelte +8 -9
- package/dist/button/Button.svelte.d.ts +4 -31
- package/dist/checkbox/Checkbox.svelte +14 -11
- package/dist/checkbox/Checkbox.svelte.d.ts +14 -31
- package/dist/close-button/CloseButton.svelte +4 -7
- package/dist/close-button/CloseButton.svelte.d.ts +2 -43
- package/dist/data-interactive/DataInteractive.svelte +5 -19
- package/dist/data-interactive/DataInteractive.svelte.d.ts +7 -29
- package/dist/description/Description.svelte +15 -12
- package/dist/description/Description.svelte.d.ts +7 -27
- package/dist/dialog/Dialog.svelte +34 -32
- package/dist/dialog/Dialog.svelte.d.ts +4 -41
- package/dist/dialog/DialogBackdrop.svelte +10 -10
- package/dist/dialog/DialogBackdrop.svelte.d.ts +4 -28
- package/dist/dialog/DialogPanel.svelte +18 -10
- package/dist/dialog/DialogPanel.svelte.d.ts +4 -29
- package/dist/dialog/DialogTitle.svelte +19 -7
- package/dist/dialog/DialogTitle.svelte.d.ts +6 -26
- package/dist/field/Field.svelte +9 -15
- package/dist/field/Field.svelte.d.ts +4 -29
- package/dist/fieldset/Fieldset.svelte +10 -13
- package/dist/fieldset/Fieldset.svelte.d.ts +5 -30
- package/dist/focus-trap/FocusTrap.svelte +20 -24
- package/dist/focus-trap/FocusTrap.svelte.d.ts +5 -33
- package/dist/hooks/use-inert-others.svelte.js +10 -10
- package/dist/hooks/use-resolve-button-type.svelte.js +0 -1
- package/dist/input/Input.svelte +19 -9
- package/dist/input/Input.svelte.d.ts +13 -26
- package/dist/internal/FocusSentinel.svelte +33 -32
- package/dist/internal/FormResolver.svelte +5 -1
- package/dist/internal/Hidden.svelte +9 -23
- package/dist/internal/Hidden.svelte.d.ts +4 -29
- package/dist/internal/MainTreeProvider.svelte +1 -1
- package/dist/label/Label.svelte +19 -13
- package/dist/label/Label.svelte.d.ts +7 -31
- package/dist/legend/Legend.svelte +20 -6
- package/dist/legend/Legend.svelte.d.ts +4 -3
- package/dist/listbox/Listbox.svelte +6 -17
- package/dist/listbox/Listbox.svelte.d.ts +11 -34
- package/dist/listbox/ListboxButton.svelte +14 -13
- package/dist/listbox/ListboxButton.svelte.d.ts +5 -31
- package/dist/listbox/ListboxOption.svelte +15 -15
- package/dist/listbox/ListboxOption.svelte.d.ts +12 -25
- package/dist/listbox/ListboxOptions.svelte +13 -11
- package/dist/listbox/ListboxOptions.svelte.d.ts +4 -37
- package/dist/listbox/ListboxSelectedOption.svelte +15 -17
- package/dist/listbox/ListboxSelectedOption.svelte.d.ts +8 -32
- package/dist/menu/Menu.svelte +5 -7
- package/dist/menu/Menu.svelte.d.ts +3 -30
- package/dist/menu/MenuButton.svelte +12 -12
- package/dist/menu/MenuButton.svelte.d.ts +4 -33
- package/dist/menu/MenuHeading.svelte +10 -9
- package/dist/menu/MenuHeading.svelte.d.ts +4 -30
- package/dist/menu/MenuItem.svelte +12 -12
- package/dist/menu/MenuItem.svelte.d.ts +5 -31
- package/dist/menu/MenuItems.svelte +12 -13
- package/dist/menu/MenuItems.svelte.d.ts +4 -37
- package/dist/menu/MenuSection.svelte +9 -8
- package/dist/menu/MenuSection.svelte.d.ts +5 -28
- package/dist/menu/MenuSeparator.svelte +9 -7
- package/dist/menu/MenuSeparator.svelte.d.ts +5 -27
- package/dist/popover/Popover.svelte +8 -8
- package/dist/popover/Popover.svelte.d.ts +4 -29
- package/dist/popover/PopoverBackdrop.svelte +15 -12
- package/dist/popover/PopoverBackdrop.svelte.d.ts +6 -33
- package/dist/popover/PopoverButton.svelte +34 -34
- package/dist/popover/PopoverButton.svelte.d.ts +6 -28
- package/dist/popover/PopoverGroup.svelte +14 -13
- package/dist/popover/PopoverGroup.svelte.d.ts +5 -27
- package/dist/popover/PopoverPanel.svelte +46 -41
- package/dist/popover/PopoverPanel.svelte.d.ts +5 -35
- package/dist/popover/index.d.ts +1 -1
- package/dist/portal/InternalPortal.svelte +17 -16
- package/dist/portal/InternalPortal.svelte.d.ts +4 -29
- package/dist/portal/Portal.svelte +7 -6
- package/dist/portal/Portal.svelte.d.ts +2 -18
- package/dist/portal/PortalGroup.svelte +5 -13
- package/dist/portal/PortalGroup.svelte.d.ts +3 -30
- package/dist/select/Select.svelte +10 -9
- package/dist/select/Select.svelte.d.ts +5 -31
- package/dist/switch/Switch.svelte +13 -12
- package/dist/switch/Switch.svelte.d.ts +5 -37
- package/dist/switch/SwitchGroup.svelte +5 -5
- package/dist/switch/SwitchGroup.svelte.d.ts +7 -27
- package/dist/tabs/Tab.svelte +12 -12
- package/dist/tabs/Tab.svelte.d.ts +4 -31
- package/dist/tabs/TabGroup.svelte +8 -8
- package/dist/tabs/TabGroup.svelte.d.ts +4 -33
- package/dist/tabs/TabList.svelte +7 -8
- package/dist/tabs/TabList.svelte.d.ts +5 -27
- package/dist/tabs/TabPanel.svelte +11 -11
- package/dist/tabs/TabPanel.svelte.d.ts +4 -33
- package/dist/tabs/TabPanels.svelte +5 -5
- package/dist/tabs/TabPanels.svelte.d.ts +5 -26
- package/dist/textarea/Textarea.svelte +12 -10
- package/dist/textarea/Textarea.svelte.d.ts +13 -26
- package/dist/transition/InternalTransitionChild.svelte +19 -12
- package/dist/transition/InternalTransitionChild.svelte.d.ts +3 -32
- package/dist/transition/Transition.svelte +12 -21
- package/dist/transition/Transition.svelte.d.ts +3 -35
- package/dist/transition/TransitionChild.svelte +9 -10
- package/dist/transition/TransitionChild.svelte.d.ts +8 -34
- package/dist/transition/context.svelte.js +7 -7
- package/dist/utils/ElementOrComponent.svelte +56 -15
- package/dist/utils/ElementOrComponent.svelte.d.ts +30 -23
- package/dist/utils/state.js +4 -4
- package/dist/utils/types.d.ts +12 -9
- package/package.json +12 -12
- package/dist/combobox/Combobox.svelte +0 -53
- package/dist/combobox/Combobox.svelte.d.ts +0 -50
- package/dist/utils/Generic.svelte +0 -57
- package/dist/utils/Generic.svelte.d.ts +0 -31
- package/dist/utils/alternative-types.d.ts +0 -20
- package/dist/utils/alternative-types.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { Props } from "../utils/types.js"
|
|
3
3
|
|
|
4
4
|
let DEFAULT_SELECT_TAG = "select" as const
|
|
5
5
|
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
}
|
|
14
14
|
type SelectPropsWeControl = "aria-labelledby" | "aria-describedby"
|
|
15
15
|
|
|
16
|
-
export type SelectProps
|
|
17
|
-
|
|
16
|
+
export type SelectProps = Props<
|
|
17
|
+
typeof DEFAULT_SELECT_TAG,
|
|
18
18
|
SelectRenderPropArg,
|
|
19
|
-
SelectPropsWeControl,
|
|
20
19
|
{
|
|
20
|
+
element?: HTMLElement
|
|
21
|
+
id?: string
|
|
21
22
|
disabled?: boolean
|
|
22
23
|
invalid?: boolean
|
|
23
24
|
autofocus?: boolean
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
>
|
|
26
27
|
</script>
|
|
27
28
|
|
|
28
|
-
<script lang="ts"
|
|
29
|
+
<script lang="ts">
|
|
29
30
|
import { useId } from "../hooks/use-id.js"
|
|
30
31
|
import { useProvidedId } from "../utils/id.js"
|
|
31
32
|
import { useDisabled } from "../hooks/use-disabled.js"
|
|
@@ -41,13 +42,13 @@
|
|
|
41
42
|
const providedId = useProvidedId()
|
|
42
43
|
const providedDisabled = useDisabled()
|
|
43
44
|
let {
|
|
44
|
-
|
|
45
|
-
id =
|
|
45
|
+
element = $bindable(),
|
|
46
|
+
id = providedId || `headlessui-select-${internalId}`,
|
|
46
47
|
disabled: theirDisabled = false,
|
|
47
48
|
invalid = false,
|
|
48
49
|
autofocus = false,
|
|
49
50
|
...theirProps
|
|
50
|
-
}:
|
|
51
|
+
}: SelectProps = $props()
|
|
51
52
|
|
|
52
53
|
const disabled = $derived(providedDisabled.current ?? theirDisabled)
|
|
53
54
|
const labelledBy = useLabelledBy()
|
|
@@ -101,4 +102,4 @@
|
|
|
101
102
|
} satisfies SelectRenderPropArg)
|
|
102
103
|
</script>
|
|
103
104
|
|
|
104
|
-
<ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_SELECT_TAG} name="Select" bind:
|
|
105
|
+
<ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_SELECT_TAG} name="Select" bind:element />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Props } from "../utils/types.js";
|
|
2
2
|
declare let DEFAULT_SELECT_TAG: "select";
|
|
3
3
|
type SelectRenderPropArg = {
|
|
4
4
|
disabled: boolean;
|
|
@@ -8,38 +8,12 @@ type SelectRenderPropArg = {
|
|
|
8
8
|
autofocus: boolean;
|
|
9
9
|
invalid: boolean;
|
|
10
10
|
};
|
|
11
|
-
type
|
|
12
|
-
|
|
11
|
+
export type SelectProps = Props<typeof DEFAULT_SELECT_TAG, SelectRenderPropArg, {
|
|
12
|
+
element?: HTMLElement;
|
|
13
|
+
id?: string;
|
|
13
14
|
disabled?: boolean;
|
|
14
15
|
invalid?: boolean;
|
|
15
16
|
autofocus?: boolean;
|
|
16
17
|
}>;
|
|
17
|
-
declare
|
|
18
|
-
props(): {
|
|
19
|
-
as?: TTag | undefined;
|
|
20
|
-
} & (Exclude<keyof PropsOf<TTag>, ("slot" | "as" | "children" | "class" | "ref") | "invalid" | "disabled" | "autofocus" | SelectPropsWeControl> extends infer T extends keyof PropsOf<TTag> ? { [P in T]: PropsOf<TTag>[P]; } : never) & {
|
|
21
|
-
children?: import("svelte").Snippet<[SelectRenderPropArg & {
|
|
22
|
-
props?: Record<string, any>;
|
|
23
|
-
}]> | undefined;
|
|
24
|
-
class?: string | ((bag: SelectRenderPropArg) => string) | null | undefined;
|
|
25
|
-
ref?: HTMLElement;
|
|
26
|
-
} & {
|
|
27
|
-
disabled?: boolean;
|
|
28
|
-
invalid?: boolean;
|
|
29
|
-
autofocus?: boolean;
|
|
30
|
-
};
|
|
31
|
-
events(): {};
|
|
32
|
-
slots(): {};
|
|
33
|
-
bindings(): "ref";
|
|
34
|
-
exports(): {};
|
|
35
|
-
}
|
|
36
|
-
interface $$IsomorphicComponent {
|
|
37
|
-
new <TTag extends ElementType = typeof DEFAULT_SELECT_TAG>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TTag>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TTag>['props']>, ReturnType<__sveltets_Render<TTag>['events']>, ReturnType<__sveltets_Render<TTag>['slots']>> & {
|
|
38
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
39
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
40
|
-
<TTag extends ElementType = typeof DEFAULT_SELECT_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
41
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
42
|
-
}
|
|
43
|
-
declare const Select: $$IsomorphicComponent;
|
|
44
|
-
type Select<TTag extends ElementType = typeof DEFAULT_SELECT_TAG> = InstanceType<typeof Select<TTag>>;
|
|
18
|
+
declare const Select: import("svelte").Component<SelectProps, {}, "element">;
|
|
45
19
|
export default Select;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { Props } from "../utils/types.js"
|
|
3
3
|
|
|
4
4
|
const DEFAULT_SWITCH_TAG = "button" as const
|
|
5
5
|
type SwitchRenderPropArg = {
|
|
@@ -13,11 +13,12 @@
|
|
|
13
13
|
}
|
|
14
14
|
type SwitchPropsWeControl = "aria-checked" | "aria-describedby" | "aria-labelledby" | "role"
|
|
15
15
|
|
|
16
|
-
export type SwitchProps
|
|
17
|
-
|
|
16
|
+
export type SwitchProps = Props<
|
|
17
|
+
typeof DEFAULT_SWITCH_TAG,
|
|
18
18
|
SwitchRenderPropArg,
|
|
19
|
-
SwitchPropsWeControl,
|
|
20
19
|
{
|
|
20
|
+
element?: HTMLElement
|
|
21
|
+
id?: string
|
|
21
22
|
checked?: boolean
|
|
22
23
|
defaultChecked?: boolean
|
|
23
24
|
onchange?(checked: boolean): void
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
>
|
|
32
33
|
</script>
|
|
33
34
|
|
|
34
|
-
<script lang="ts"
|
|
35
|
+
<script lang="ts">
|
|
35
36
|
import { useId } from "../hooks/use-id.js"
|
|
36
37
|
import { useDisabled } from "../hooks/use-disabled.js"
|
|
37
38
|
import { useProvidedId } from "../utils/id.js"
|
|
@@ -53,8 +54,8 @@
|
|
|
53
54
|
const providedId = useProvidedId()
|
|
54
55
|
const providedDisabled = useDisabled()
|
|
55
56
|
let {
|
|
56
|
-
|
|
57
|
-
id =
|
|
57
|
+
element = $bindable(),
|
|
58
|
+
id = providedId || `headlessui-switch-${internalId}`,
|
|
58
59
|
disabled: theirDisabled = false,
|
|
59
60
|
checked: controlledChecked = $bindable(),
|
|
60
61
|
defaultChecked: _defaultChecked,
|
|
@@ -65,11 +66,11 @@
|
|
|
65
66
|
autofocus = false,
|
|
66
67
|
tabIndex,
|
|
67
68
|
...theirProps
|
|
68
|
-
}:
|
|
69
|
+
}: SwitchProps = $props()
|
|
69
70
|
const disabled = $derived(providedDisabled.current ?? theirDisabled)
|
|
70
71
|
const groupContext = getContext<GroupContext>("GroupContext")
|
|
71
72
|
$effect(() => {
|
|
72
|
-
if (groupContext) groupContext.switchElement =
|
|
73
|
+
if (groupContext) groupContext.switchElement = element ?? null
|
|
73
74
|
})
|
|
74
75
|
|
|
75
76
|
const defaultChecked = _defaultChecked
|
|
@@ -152,10 +153,10 @@
|
|
|
152
153
|
|
|
153
154
|
const buttonType = useResolveButtonType({
|
|
154
155
|
get props() {
|
|
155
|
-
return { type: theirProps.type, as:
|
|
156
|
+
return { type: theirProps.type ?? undefined, as: element ? element.tagName.toLowerCase() : DEFAULT_SWITCH_TAG }
|
|
156
157
|
},
|
|
157
158
|
get ref() {
|
|
158
|
-
return { current:
|
|
159
|
+
return { current: element }
|
|
159
160
|
},
|
|
160
161
|
})
|
|
161
162
|
|
|
@@ -197,4 +198,4 @@
|
|
|
197
198
|
/>
|
|
198
199
|
{/if}
|
|
199
200
|
|
|
200
|
-
<ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_SWITCH_TAG} name="Switch" bind:
|
|
201
|
+
<ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_SWITCH_TAG} name="Switch" bind:element />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Props } from "../utils/types.js";
|
|
2
2
|
declare const DEFAULT_SWITCH_TAG: "button";
|
|
3
3
|
type SwitchRenderPropArg = {
|
|
4
4
|
checked: boolean;
|
|
@@ -9,8 +9,9 @@ type SwitchRenderPropArg = {
|
|
|
9
9
|
changing: boolean;
|
|
10
10
|
disabled: boolean;
|
|
11
11
|
};
|
|
12
|
-
type
|
|
13
|
-
|
|
12
|
+
export type SwitchProps = Props<typeof DEFAULT_SWITCH_TAG, SwitchRenderPropArg, {
|
|
13
|
+
element?: HTMLElement;
|
|
14
|
+
id?: string;
|
|
14
15
|
checked?: boolean;
|
|
15
16
|
defaultChecked?: boolean;
|
|
16
17
|
onchange?(checked: boolean): void;
|
|
@@ -21,38 +22,5 @@ export type SwitchProps<TTag extends ElementType = typeof DEFAULT_SWITCH_TAG> =
|
|
|
21
22
|
disabled?: boolean;
|
|
22
23
|
tabIndex?: number;
|
|
23
24
|
}>;
|
|
24
|
-
declare
|
|
25
|
-
props(): {
|
|
26
|
-
as?: TTag | undefined;
|
|
27
|
-
} & (Exclude<keyof PropsOf<TTag>, "form" | ("slot" | "as" | "children" | "class" | "ref") | "disabled" | "autofocus" | "value" | "checked" | "name" | "onchange" | "tabIndex" | "defaultChecked" | SwitchPropsWeControl> extends infer T extends keyof PropsOf<TTag> ? { [P in T]: PropsOf<TTag>[P]; } : never) & {
|
|
28
|
-
children?: import("svelte").Snippet<[SwitchRenderPropArg & {
|
|
29
|
-
props?: Record<string, any>;
|
|
30
|
-
}]> | undefined;
|
|
31
|
-
class?: string | ((bag: SwitchRenderPropArg) => string) | null | undefined;
|
|
32
|
-
ref?: HTMLElement;
|
|
33
|
-
} & {
|
|
34
|
-
checked?: boolean;
|
|
35
|
-
defaultChecked?: boolean;
|
|
36
|
-
onchange?(checked: boolean): void;
|
|
37
|
-
name?: string;
|
|
38
|
-
value?: string;
|
|
39
|
-
form?: string;
|
|
40
|
-
autofocus?: boolean;
|
|
41
|
-
disabled?: boolean;
|
|
42
|
-
tabIndex?: number;
|
|
43
|
-
};
|
|
44
|
-
events(): {};
|
|
45
|
-
slots(): {};
|
|
46
|
-
bindings(): "ref" | "checked";
|
|
47
|
-
exports(): {};
|
|
48
|
-
}
|
|
49
|
-
interface $$IsomorphicComponent {
|
|
50
|
-
new <TTag extends ElementType = typeof DEFAULT_SWITCH_TAG>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TTag>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TTag>['props']>, ReturnType<__sveltets_Render<TTag>['events']>, ReturnType<__sveltets_Render<TTag>['slots']>> & {
|
|
51
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
52
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
53
|
-
<TTag extends ElementType = typeof DEFAULT_SWITCH_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
54
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
55
|
-
}
|
|
56
|
-
declare const Switch: $$IsomorphicComponent;
|
|
57
|
-
type Switch<TTag extends ElementType = typeof DEFAULT_SWITCH_TAG> = InstanceType<typeof Switch<TTag>>;
|
|
25
|
+
declare const Switch: import("svelte").Component<SwitchProps, {}, "element" | "checked">;
|
|
58
26
|
export default Switch;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { PropsAsChild } from "../utils/types.js"
|
|
3
3
|
|
|
4
4
|
const DEFAULT_GROUP_TAG = "svelte:fragment"
|
|
5
5
|
|
|
6
|
-
export type SwitchGroupProps
|
|
6
|
+
export type SwitchGroupProps = PropsAsChild
|
|
7
7
|
|
|
8
8
|
export type GroupContext = {
|
|
9
9
|
switchElement: HTMLElement | null
|
|
10
10
|
}
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
<script lang="ts"
|
|
13
|
+
<script lang="ts">
|
|
14
14
|
import { setContext } from "svelte"
|
|
15
15
|
import { useLabels } from "../label/context.svelte.js"
|
|
16
16
|
import { useDescriptions } from "../description/context.svelte.js"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
})
|
|
46
46
|
|
|
47
|
-
let {
|
|
47
|
+
let { ...theirProps }: SwitchGroupProps = $props()
|
|
48
48
|
</script>
|
|
49
49
|
|
|
50
|
-
<ElementOrComponent {theirProps}
|
|
50
|
+
<ElementOrComponent {theirProps} name="SwitchGroup" />
|
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export type SwitchGroupProps<TTag extends ElementType = typeof DEFAULT_GROUP_TAG> = Props<TTag>;
|
|
1
|
+
import type { PropsAsChild } from "../utils/types.js";
|
|
2
|
+
export type SwitchGroupProps = PropsAsChild;
|
|
4
3
|
export type GroupContext = {
|
|
5
4
|
switchElement: HTMLElement | null;
|
|
6
5
|
};
|
|
7
|
-
declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
props?: Record<string, any>;
|
|
13
|
-
}]> | undefined;
|
|
14
|
-
class?: string | ((bag: {}) => string) | null | undefined;
|
|
15
|
-
ref?: HTMLElement;
|
|
16
|
-
};
|
|
17
|
-
events(): {};
|
|
18
|
-
slots(): {};
|
|
19
|
-
bindings(): "ref";
|
|
20
|
-
exports(): {};
|
|
21
|
-
}
|
|
22
|
-
interface $$IsomorphicComponent {
|
|
23
|
-
new <TTag extends ElementType = typeof DEFAULT_GROUP_TAG>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TTag>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TTag>['props']>, ReturnType<__sveltets_Render<TTag>['events']>, ReturnType<__sveltets_Render<TTag>['slots']>> & {
|
|
24
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
25
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
26
|
-
<TTag extends ElementType = typeof DEFAULT_GROUP_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
27
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
28
|
-
}
|
|
29
|
-
declare const SwitchGroup: $$IsomorphicComponent;
|
|
30
|
-
type SwitchGroup<TTag extends ElementType = typeof DEFAULT_GROUP_TAG> = InstanceType<typeof SwitchGroup<TTag>>;
|
|
6
|
+
declare const SwitchGroup: import("svelte").Component<{
|
|
7
|
+
children?: import("svelte").Snippet<[{
|
|
8
|
+
props?: Record<string, any>;
|
|
9
|
+
}]> | undefined;
|
|
10
|
+
}, {}, "">;
|
|
31
11
|
export default SwitchGroup;
|
package/dist/tabs/Tab.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { Props } from "../utils/types.js"
|
|
3
3
|
|
|
4
4
|
const DEFAULT_TAB_TAG = "button" as const
|
|
5
5
|
type TabRenderPropArg = {
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
}
|
|
13
13
|
type TabPropsWeControl = "aria-controls" | "aria-selected" | "role" | "tabIndex"
|
|
14
14
|
|
|
15
|
-
export type TabProps
|
|
16
|
-
|
|
15
|
+
export type TabProps = Props<
|
|
16
|
+
typeof DEFAULT_TAB_TAG,
|
|
17
17
|
TabRenderPropArg,
|
|
18
|
-
TabPropsWeControl,
|
|
19
18
|
{
|
|
19
|
+
element?: HTMLElement
|
|
20
20
|
id?: string
|
|
21
21
|
autofocus?: boolean
|
|
22
22
|
disabled?: boolean
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
>
|
|
25
25
|
</script>
|
|
26
26
|
|
|
27
|
-
<script lang="ts"
|
|
27
|
+
<script lang="ts">
|
|
28
28
|
import { useId } from "../hooks/use-id.js"
|
|
29
29
|
import { useStableCollectionIndex } from "../utils/StableCollection.svelte"
|
|
30
30
|
import { Focus, focusIn, FocusResult } from "../utils/focus-management.js"
|
|
@@ -43,17 +43,17 @@
|
|
|
43
43
|
|
|
44
44
|
const internalId = useId()
|
|
45
45
|
let {
|
|
46
|
-
|
|
46
|
+
element = $bindable(),
|
|
47
47
|
id = `headlessui-tabs-tab-${internalId}`,
|
|
48
48
|
disabled = false,
|
|
49
49
|
autofocus = false,
|
|
50
50
|
...theirProps
|
|
51
|
-
}:
|
|
51
|
+
}: TabProps = $props()
|
|
52
52
|
|
|
53
53
|
const context = useTabs("Tab")
|
|
54
54
|
const { orientation, activation, selectedIndex, tabs, panels, registerTab, change } = $derived(context)
|
|
55
55
|
|
|
56
|
-
const tabRef = $derived<MutableRefObject<HTMLElement | undefined>>({ current:
|
|
56
|
+
const tabRef = $derived<MutableRefObject<HTMLElement | undefined>>({ current: element })
|
|
57
57
|
|
|
58
58
|
onMount(() => registerTab(tabRef))
|
|
59
59
|
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
const activateUsing = $derived((cb: () => FocusResult) => {
|
|
69
69
|
let result = cb()
|
|
70
70
|
if (result === FocusResult.Success && activation === "auto") {
|
|
71
|
-
let newTab = getOwnerDocument(
|
|
71
|
+
let newTab = getOwnerDocument(element)?.activeElement
|
|
72
72
|
let idx = context.tabs.findIndex((tab) => tab.current === newTab)
|
|
73
73
|
if (idx !== -1) change(idx)
|
|
74
74
|
}
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
if (ready) return
|
|
128
128
|
ready = true
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
element?.focus({ preventScroll: true })
|
|
131
131
|
change(myIndex)
|
|
132
132
|
|
|
133
133
|
microTask(() => {
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
|
|
176
176
|
const resolvedType = useResolveButtonType({
|
|
177
177
|
get props() {
|
|
178
|
-
return { type: theirProps.type, as:
|
|
178
|
+
return { type: theirProps.type ?? undefined, as: element ? element.tagName.toLowerCase() : DEFAULT_TAB_TAG }
|
|
179
179
|
},
|
|
180
180
|
get ref() {
|
|
181
181
|
return tabRef
|
|
@@ -204,4 +204,4 @@
|
|
|
204
204
|
)
|
|
205
205
|
</script>
|
|
206
206
|
|
|
207
|
-
<ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_TAB_TAG} name="Tab" bind:
|
|
207
|
+
<ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_TAB_TAG} name="Tab" bind:element />
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Props } from "../utils/types.js";
|
|
2
2
|
declare const DEFAULT_TAB_TAG: "button";
|
|
3
3
|
type TabRenderPropArg = {
|
|
4
4
|
hover: boolean;
|
|
@@ -8,38 +8,11 @@ type TabRenderPropArg = {
|
|
|
8
8
|
selected: boolean;
|
|
9
9
|
disabled: boolean;
|
|
10
10
|
};
|
|
11
|
-
type
|
|
12
|
-
|
|
11
|
+
export type TabProps = Props<typeof DEFAULT_TAB_TAG, TabRenderPropArg, {
|
|
12
|
+
element?: HTMLElement;
|
|
13
13
|
id?: string;
|
|
14
14
|
autofocus?: boolean;
|
|
15
15
|
disabled?: boolean;
|
|
16
16
|
}>;
|
|
17
|
-
declare
|
|
18
|
-
props(): {
|
|
19
|
-
as?: TTag | undefined;
|
|
20
|
-
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("slot" | "as" | "children" | "class" | "ref") | "disabled" | "autofocus" | "id" | TabPropsWeControl> extends infer T extends keyof import("../utils/types.js").PropsOf<TTag> ? { [P in T]: import("../utils/types.js").PropsOf<TTag>[P]; } : never) & {
|
|
21
|
-
children?: import("svelte").Snippet<[TabRenderPropArg & {
|
|
22
|
-
props?: Record<string, any>;
|
|
23
|
-
}]> | undefined;
|
|
24
|
-
class?: string | ((bag: TabRenderPropArg) => string) | null | undefined;
|
|
25
|
-
ref?: HTMLElement;
|
|
26
|
-
} & {
|
|
27
|
-
id?: string;
|
|
28
|
-
autofocus?: boolean;
|
|
29
|
-
disabled?: boolean;
|
|
30
|
-
};
|
|
31
|
-
events(): {};
|
|
32
|
-
slots(): {};
|
|
33
|
-
bindings(): "ref";
|
|
34
|
-
exports(): {};
|
|
35
|
-
}
|
|
36
|
-
interface $$IsomorphicComponent {
|
|
37
|
-
new <TTag extends ElementType = typeof DEFAULT_TAB_TAG>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TTag>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TTag>['props']>, ReturnType<__sveltets_Render<TTag>['events']>, ReturnType<__sveltets_Render<TTag>['slots']>> & {
|
|
38
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
39
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
40
|
-
<TTag extends ElementType = typeof DEFAULT_TAB_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
41
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
42
|
-
}
|
|
43
|
-
declare const Tab: $$IsomorphicComponent;
|
|
44
|
-
type Tab<TTag extends ElementType = typeof DEFAULT_TAB_TAG> = InstanceType<typeof Tab<TTag>>;
|
|
17
|
+
declare const Tab: import("svelte").Component<TabProps, {}, "element">;
|
|
45
18
|
export default Tab;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { Props } from "../utils/types.js"
|
|
3
3
|
import { sortByDomNode } from "../utils/focus-management.js"
|
|
4
4
|
import FocusSentinel from "../internal/FocusSentinel.svelte"
|
|
5
5
|
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
}
|
|
10
10
|
type TabsPropsWeControl = never
|
|
11
11
|
|
|
12
|
-
export type TabGroupProps
|
|
13
|
-
|
|
12
|
+
export type TabGroupProps = Props<
|
|
13
|
+
typeof DEFAULT_TABS_TAG,
|
|
14
14
|
TabsRenderPropArg,
|
|
15
|
-
TabsPropsWeControl,
|
|
16
15
|
{
|
|
16
|
+
element?: HTMLElement
|
|
17
17
|
defaultIndex?: number
|
|
18
18
|
onchange?: (index: number) => void
|
|
19
19
|
selectedIndex?: number
|
|
@@ -23,21 +23,21 @@
|
|
|
23
23
|
>
|
|
24
24
|
</script>
|
|
25
25
|
|
|
26
|
-
<script lang="ts"
|
|
26
|
+
<script lang="ts">
|
|
27
27
|
import StableCollection from "../utils/StableCollection.svelte"
|
|
28
28
|
import ElementOrComponent from "../utils/ElementOrComponent.svelte"
|
|
29
29
|
import { createTabContext } from "./context.svelte.js"
|
|
30
30
|
import { untrack } from "svelte"
|
|
31
31
|
|
|
32
32
|
let {
|
|
33
|
-
|
|
33
|
+
element = $bindable(),
|
|
34
34
|
defaultIndex = 0,
|
|
35
35
|
vertical = false,
|
|
36
36
|
manual = false,
|
|
37
37
|
onchange,
|
|
38
38
|
selectedIndex = undefined,
|
|
39
39
|
...theirProps
|
|
40
|
-
}:
|
|
40
|
+
}: TabGroupProps = $props()
|
|
41
41
|
const _state = createTabContext({
|
|
42
42
|
get vertical() {
|
|
43
43
|
return vertical
|
|
@@ -104,5 +104,5 @@
|
|
|
104
104
|
}}
|
|
105
105
|
/>
|
|
106
106
|
{/if}
|
|
107
|
-
<ElementOrComponent {theirProps} slots={slot} defaultTag={DEFAULT_TABS_TAG} name="TabGroup" bind:
|
|
107
|
+
<ElementOrComponent {theirProps} slots={slot} defaultTag={DEFAULT_TABS_TAG} name="TabGroup" bind:element />
|
|
108
108
|
</StableCollection>
|
|
@@ -1,44 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Props } from "../utils/types.js";
|
|
2
2
|
declare const DEFAULT_TABS_TAG: "div";
|
|
3
3
|
type TabsRenderPropArg = {
|
|
4
4
|
selectedIndex: number;
|
|
5
5
|
};
|
|
6
|
-
type
|
|
7
|
-
|
|
6
|
+
export type TabGroupProps = Props<typeof DEFAULT_TABS_TAG, TabsRenderPropArg, {
|
|
7
|
+
element?: HTMLElement;
|
|
8
8
|
defaultIndex?: number;
|
|
9
9
|
onchange?: (index: number) => void;
|
|
10
10
|
selectedIndex?: number;
|
|
11
11
|
vertical?: boolean;
|
|
12
12
|
manual?: boolean;
|
|
13
13
|
}>;
|
|
14
|
-
declare
|
|
15
|
-
props(): {
|
|
16
|
-
as?: TTag | undefined;
|
|
17
|
-
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("slot" | "as" | "children" | "class" | "ref") | "onchange" | "manual" | "vertical" | "selectedIndex" | "defaultIndex"> extends infer T extends keyof import("../utils/types.js").PropsOf<TTag> ? { [P in T]: import("../utils/types.js").PropsOf<TTag>[P]; } : never) & {
|
|
18
|
-
children?: import("svelte").Snippet<[TabsRenderPropArg & {
|
|
19
|
-
props?: Record<string, any>;
|
|
20
|
-
}]> | undefined;
|
|
21
|
-
class?: string | ((bag: TabsRenderPropArg) => string) | null | undefined;
|
|
22
|
-
ref?: HTMLElement;
|
|
23
|
-
} & {
|
|
24
|
-
defaultIndex?: number;
|
|
25
|
-
onchange?: (index: number) => void;
|
|
26
|
-
selectedIndex?: number;
|
|
27
|
-
vertical?: boolean;
|
|
28
|
-
manual?: boolean;
|
|
29
|
-
};
|
|
30
|
-
events(): {};
|
|
31
|
-
slots(): {};
|
|
32
|
-
bindings(): "ref";
|
|
33
|
-
exports(): {};
|
|
34
|
-
}
|
|
35
|
-
interface $$IsomorphicComponent {
|
|
36
|
-
new <TTag extends ElementType = typeof DEFAULT_TABS_TAG>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TTag>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TTag>['props']>, ReturnType<__sveltets_Render<TTag>['events']>, ReturnType<__sveltets_Render<TTag>['slots']>> & {
|
|
37
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
38
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
39
|
-
<TTag extends ElementType = typeof DEFAULT_TABS_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
40
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
41
|
-
}
|
|
42
|
-
declare const TabGroup: $$IsomorphicComponent;
|
|
43
|
-
type TabGroup<TTag extends ElementType = typeof DEFAULT_TABS_TAG> = InstanceType<typeof TabGroup<TTag>>;
|
|
14
|
+
declare const TabGroup: import("svelte").Component<TabGroupProps, {}, "element">;
|
|
44
15
|
export default TabGroup;
|
package/dist/tabs/TabList.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { Props } from "../utils/types.js"
|
|
3
3
|
|
|
4
4
|
const DEFAULT_LIST_TAG = "div" as const
|
|
5
5
|
type ListRenderPropArg = {
|
|
@@ -7,17 +7,16 @@
|
|
|
7
7
|
}
|
|
8
8
|
type ListPropsWeControl = "aria-orientation" | "role"
|
|
9
9
|
|
|
10
|
-
export type TabListProps
|
|
11
|
-
|
|
10
|
+
export type TabListProps = Props<
|
|
11
|
+
typeof DEFAULT_LIST_TAG,
|
|
12
12
|
ListRenderPropArg,
|
|
13
|
-
ListPropsWeControl,
|
|
14
13
|
{
|
|
15
|
-
|
|
14
|
+
element?: HTMLElement
|
|
16
15
|
}
|
|
17
16
|
>
|
|
18
17
|
</script>
|
|
19
18
|
|
|
20
|
-
<script lang="ts"
|
|
19
|
+
<script lang="ts">
|
|
21
20
|
import ElementOrComponent from "../utils/ElementOrComponent.svelte"
|
|
22
21
|
import { useTabs } from "./context.svelte.js"
|
|
23
22
|
|
|
@@ -26,11 +25,11 @@
|
|
|
26
25
|
|
|
27
26
|
const slot = $derived({ selectedIndex } satisfies ListRenderPropArg)
|
|
28
27
|
|
|
29
|
-
let {
|
|
28
|
+
let { element = $bindable(), ...theirProps }: TabListProps = $props()
|
|
30
29
|
const ourProps = $derived({
|
|
31
30
|
role: "tablist",
|
|
32
31
|
"aria-orientation": orientation,
|
|
33
32
|
})
|
|
34
33
|
</script>
|
|
35
34
|
|
|
36
|
-
<ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_LIST_TAG} name="TabList" bind:
|
|
35
|
+
<ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_LIST_TAG} name="TabList" bind:element />
|
|
@@ -1,32 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Props } from "../utils/types.js";
|
|
2
2
|
declare const DEFAULT_LIST_TAG: "div";
|
|
3
3
|
type ListRenderPropArg = {
|
|
4
4
|
selectedIndex: number;
|
|
5
5
|
};
|
|
6
|
-
type
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
as?: TTag | undefined;
|
|
11
|
-
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("slot" | "as" | "children" | "class" | "ref") | ListPropsWeControl> extends infer T extends keyof import("../utils/types.js").PropsOf<TTag> ? { [P in T]: import("../utils/types.js").PropsOf<TTag>[P]; } : never) & {
|
|
12
|
-
children?: import("svelte").Snippet<[ListRenderPropArg & {
|
|
13
|
-
props?: Record<string, any>;
|
|
14
|
-
}]> | undefined;
|
|
15
|
-
class?: string | ((bag: ListRenderPropArg) => string) | null | undefined;
|
|
16
|
-
ref?: HTMLElement;
|
|
17
|
-
};
|
|
18
|
-
events(): {};
|
|
19
|
-
slots(): {};
|
|
20
|
-
bindings(): "ref";
|
|
21
|
-
exports(): {};
|
|
22
|
-
}
|
|
23
|
-
interface $$IsomorphicComponent {
|
|
24
|
-
new <TTag extends ElementType = typeof DEFAULT_LIST_TAG>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TTag>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TTag>['props']>, ReturnType<__sveltets_Render<TTag>['events']>, ReturnType<__sveltets_Render<TTag>['slots']>> & {
|
|
25
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
26
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
27
|
-
<TTag extends ElementType = typeof DEFAULT_LIST_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
28
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
29
|
-
}
|
|
30
|
-
declare const TabList: $$IsomorphicComponent;
|
|
31
|
-
type TabList<TTag extends ElementType = typeof DEFAULT_LIST_TAG> = InstanceType<typeof TabList<TTag>>;
|
|
6
|
+
export type TabListProps = Props<typeof DEFAULT_LIST_TAG, ListRenderPropArg, {
|
|
7
|
+
element?: HTMLElement;
|
|
8
|
+
}>;
|
|
9
|
+
declare const TabList: import("svelte").Component<TabListProps, {}, "element">;
|
|
32
10
|
export default TabList;
|