@pzerelles/headlessui-svelte 2.1.2-next.3 → 2.1.2-next.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/button/Button.svelte +84 -54
- package/dist/checkbox/Checkbox.svelte +174 -120
- package/dist/close-button/CloseButton.svelte +12 -6
- package/dist/combobox/Combobox.svelte +50 -3
- package/dist/data-interactive/DataInteractive.svelte +57 -29
- package/dist/description/Description.svelte +32 -21
- package/dist/dialog/Dialog.svelte +69 -34
- package/dist/dialog/DialogBackdrop.svelte +29 -12
- package/dist/dialog/DialogPanel.svelte +49 -26
- package/dist/dialog/DialogTitle.svelte +38 -23
- package/dist/dialog/InternalDialog.svelte +263 -202
- package/dist/field/Field.svelte +49 -26
- package/dist/fieldset/Fieldset.svelte +50 -29
- package/dist/focus-trap/FocusTrap.svelte +419 -290
- package/dist/focus-trap/FocusTrap.svelte.d.ts +2 -14
- package/dist/focus-trap/FocusTrapFeatures.d.ts +14 -0
- package/dist/focus-trap/FocusTrapFeatures.js +15 -0
- package/dist/input/Input.svelte +85 -53
- package/dist/internal/FocusSentinel.svelte +16 -8
- package/dist/internal/ForcePortalRoot.svelte +7 -3
- package/dist/internal/FormFields.svelte +31 -20
- package/dist/internal/FormResolver.svelte +20 -15
- package/dist/internal/Hidden.svelte +44 -27
- package/dist/internal/Hidden.svelte.d.ts +2 -5
- package/dist/internal/HiddenFeatures.d.ts +5 -0
- package/dist/internal/HiddenFeatures.js +9 -0
- package/dist/internal/HoistFormFields.svelte +7 -4
- package/dist/internal/MainTreeProvider.svelte +89 -36
- package/dist/internal/Portal.svelte +18 -14
- package/dist/label/Label.svelte +91 -57
- package/dist/legend/Legend.svelte +18 -3
- package/dist/listbox/Listbox.svelte +588 -409
- package/dist/listbox/Listbox.svelte.d.ts +2 -12
- package/dist/listbox/ListboxButton.svelte +176 -127
- package/dist/listbox/ListboxOption.svelte +166 -125
- package/dist/listbox/ListboxOptions.svelte +340 -244
- package/dist/listbox/ListboxSelectedOption.svelte +38 -15
- package/dist/listbox/ListboxStates.d.ts +12 -0
- package/dist/listbox/ListboxStates.js +15 -0
- package/dist/menu/Menu.svelte +307 -218
- package/dist/menu/MenuButton.svelte +157 -115
- package/dist/menu/MenuHeading.svelte +34 -14
- package/dist/menu/MenuItem.svelte +145 -107
- package/dist/menu/MenuItems.svelte +298 -224
- package/dist/menu/MenuSection.svelte +26 -9
- package/dist/menu/MenuSeparator.svelte +20 -4
- package/dist/portal/InternalPortal.svelte +141 -85
- package/dist/portal/Portal.svelte +5 -2
- package/dist/portal/PortalGroup.svelte +30 -9
- package/dist/switch/Switch.svelte +179 -122
- package/dist/switch/Switch.svelte.d.ts +4 -4
- package/dist/switch/SwitchGroup.svelte +44 -31
- package/dist/tabs/Tab.svelte +195 -143
- package/dist/tabs/TabGroup.svelte +292 -205
- package/dist/tabs/TabList.svelte +31 -11
- package/dist/tabs/TabPanel.svelte +68 -43
- package/dist/tabs/TabPanels.svelte +18 -7
- package/dist/textarea/Textarea.svelte +83 -53
- package/dist/transition/InternalTransitionChild.svelte +259 -170
- package/dist/transition/Transition.svelte +96 -66
- package/dist/transition/TransitionChild.svelte +31 -11
- package/dist/utils/ElementOrComponent.svelte +44 -23
- package/dist/utils/Generic.svelte +29 -17
- package/dist/utils/StableCollection.svelte +54 -36
- package/package.json +10 -10
|
@@ -1,49 +1,74 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { ElementType, Props } from "../utils/types.js"
|
|
3
|
+
|
|
4
|
+
const DEFAULT_PANEL_TAG = "div" as const
|
|
5
|
+
type PanelRenderPropArg = {
|
|
6
|
+
selected: boolean
|
|
7
|
+
focus: boolean
|
|
8
|
+
}
|
|
9
|
+
type PanelPropsWeControl = "role" | "aria-labelledby"
|
|
10
|
+
const PanelRenderFeatures = RenderFeatures.RenderStrategy | RenderFeatures.Static
|
|
11
|
+
|
|
12
|
+
export type TabPanelProps<TTag extends ElementType = typeof DEFAULT_PANEL_TAG> = Props<
|
|
13
|
+
TTag,
|
|
14
|
+
PanelRenderPropArg,
|
|
15
|
+
PanelPropsWeControl,
|
|
16
|
+
PropsForFeatures<typeof PanelRenderFeatures> & { id?: string; tabIndex?: number }
|
|
17
|
+
>
|
|
3
18
|
</script>
|
|
4
19
|
|
|
5
|
-
<script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_PANEL_TAG">
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
<script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_PANEL_TAG">
|
|
21
|
+
import { useId } from "../hooks/use-id.js"
|
|
22
|
+
import { mergeProps, RenderFeatures, type PropsForFeatures } from "../utils/render.js"
|
|
23
|
+
import { useActions, useData } from "./TabGroup.svelte"
|
|
24
|
+
import { useStableCollectionIndex } from "../utils/StableCollection.svelte"
|
|
25
|
+
import { useFocusRing } from "../hooks/use-focus-ring.svelte.js"
|
|
26
|
+
import Hidden from "../internal/Hidden.svelte"
|
|
27
|
+
import type { MutableRefObject } from "../utils/ref.svelte.js"
|
|
28
|
+
import { onMount } from "svelte"
|
|
29
|
+
import ElementOrComponent from "../utils/ElementOrComponent.svelte"
|
|
30
|
+
|
|
31
|
+
const internalId = useId()
|
|
32
|
+
let {
|
|
33
|
+
ref = $bindable(),
|
|
34
|
+
id = `headlessui-tabs-panel-${internalId}`,
|
|
35
|
+
tabIndex = 0,
|
|
36
|
+
...theirProps
|
|
37
|
+
}: { as?: TTag } & TabPanelProps<TTag> = $props()
|
|
38
|
+
const data = useData("Tab.Panel")
|
|
39
|
+
const { selectedIndex, tabs, panels } = $derived(data)
|
|
40
|
+
const actions = useActions("Tab.Panel")
|
|
41
|
+
|
|
42
|
+
const panelRef = $derived<MutableRefObject<HTMLElement | undefined>>({ current: ref })
|
|
43
|
+
|
|
44
|
+
onMount(() => actions.registerPanel(panelRef))
|
|
45
|
+
|
|
46
|
+
const mySSRIndex = useStableCollectionIndex("panels")
|
|
47
|
+
|
|
48
|
+
const myIndex = $derived.by(() => {
|
|
49
|
+
const index = tabs.findIndex((panel) => panel === panelRef)
|
|
50
|
+
return index === -1 ? mySSRIndex : index
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const selected = $derived(myIndex === selectedIndex)
|
|
54
|
+
|
|
55
|
+
const { isFocusVisible: focus, focusProps } = $derived(useFocusRing())
|
|
56
|
+
const slot = $derived({
|
|
57
|
+
selected,
|
|
58
|
+
focus,
|
|
59
|
+
} satisfies PanelRenderPropArg)
|
|
60
|
+
|
|
61
|
+
const ourProps = $derived(
|
|
62
|
+
mergeProps(
|
|
63
|
+
{
|
|
64
|
+
id,
|
|
65
|
+
role: "tabpanel",
|
|
66
|
+
"aria-labelledby": tabs[myIndex]?.current?.id,
|
|
67
|
+
tabIndex: selected ? 0 : -1,
|
|
68
|
+
},
|
|
69
|
+
focusProps
|
|
70
|
+
)
|
|
45
71
|
)
|
|
46
|
-
);
|
|
47
72
|
</script>
|
|
48
73
|
|
|
49
74
|
{#if !selected && (theirProps.unmount ?? true) && !(theirProps.static ?? false)}
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
import
|
|
3
|
-
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import ElementOrComponent from "../utils/ElementOrComponent.svelte"
|
|
3
|
+
import type { ElementType, Props } from "../utils/types.js"
|
|
4
|
+
import { useData } from "./TabGroup.svelte"
|
|
5
|
+
|
|
6
|
+
let DEFAULT_PANELS_TAG = "div" as const
|
|
7
|
+
type PanelsRenderPropArg = {
|
|
8
|
+
selectedIndex: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type TabPanelsProps<TTag extends ElementType = typeof DEFAULT_PANELS_TAG> = Props<TTag, PanelsRenderPropArg>
|
|
4
12
|
</script>
|
|
5
13
|
|
|
6
|
-
<script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_PANELS_TAG">
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
14
|
+
<script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_PANELS_TAG">
|
|
15
|
+
const data = useData("Tab.Panels")
|
|
16
|
+
const { selectedIndex } = $derived(data)
|
|
17
|
+
|
|
18
|
+
const slot = $derived({ selectedIndex } satisfies PanelsRenderPropArg)
|
|
19
|
+
|
|
20
|
+
let { ref = $bindable(), ...theirProps }: { as?: TTag } & TabPanelsProps<TTag> = $props()
|
|
10
21
|
</script>
|
|
11
22
|
|
|
12
23
|
<ElementOrComponent {theirProps} {slot} defaultTag={DEFAULT_PANELS_TAG} name="TabPanel" bind:ref />
|
|
@@ -1,59 +1,89 @@
|
|
|
1
|
-
<script lang="ts" module>
|
|
2
|
-
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { ElementType, Props, PropsOf } from "../utils/types.js"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
id = providedId?.value || `headlessui-input-${internalId}`,
|
|
20
|
-
disabled: theirDisabled = false,
|
|
21
|
-
autofocus = false,
|
|
22
|
-
invalid = false,
|
|
23
|
-
...theirProps
|
|
24
|
-
} = $props();
|
|
25
|
-
const disabled = $derived(providedDisabled?.value ?? theirDisabled);
|
|
26
|
-
const labelledBy = useLabelledBy();
|
|
27
|
-
const describedBy = useDescribedBy();
|
|
28
|
-
const { isFocusVisible: focus, focusProps } = $derived(
|
|
29
|
-
useFocusRing({
|
|
30
|
-
get autofocus() {
|
|
31
|
-
return autofocus;
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
);
|
|
35
|
-
const { isHovered: hover, hoverProps } = $derived(
|
|
36
|
-
useHover({
|
|
37
|
-
get disabled() {
|
|
38
|
-
return disabled;
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
);
|
|
42
|
-
const ourProps = $derived(
|
|
43
|
-
mergeProps(
|
|
4
|
+
const DEFAULT_TEXTAREA_TAG = "textarea" as const
|
|
5
|
+
|
|
6
|
+
type TextareaRenderPropArg = {
|
|
7
|
+
disabled: boolean
|
|
8
|
+
hover: boolean
|
|
9
|
+
focus: boolean
|
|
10
|
+
autofocus: boolean
|
|
11
|
+
invalid: boolean
|
|
12
|
+
}
|
|
13
|
+
type TextareaPropsWeControl = "aria-labelledby" | "aria-describedby"
|
|
14
|
+
|
|
15
|
+
export type TextareaProps<TTag extends ElementType = typeof DEFAULT_TEXTAREA_TAG> = Props<
|
|
16
|
+
TTag,
|
|
17
|
+
TextareaRenderPropArg,
|
|
18
|
+
TextareaPropsWeControl,
|
|
44
19
|
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
20
|
+
disabled?: boolean
|
|
21
|
+
invalid?: boolean
|
|
22
|
+
autoFocus?: boolean
|
|
23
|
+
}
|
|
24
|
+
>
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_TEXTAREA_TAG">
|
|
28
|
+
import { htmlid } from "../utils/id.js"
|
|
29
|
+
import { useDisabled } from "../hooks/use-disabled.js"
|
|
30
|
+
import { useProvidedId } from "../internal/id.js"
|
|
31
|
+
import { useLabelledBy } from "../label/context.svelte.js"
|
|
32
|
+
import { useDescribedBy } from "../description/context.svelte.js"
|
|
33
|
+
import { useHover } from "../hooks/use-hover.svelte.js"
|
|
34
|
+
import { useFocusRing } from "../hooks/use-focus-ring.svelte.js"
|
|
35
|
+
import { mergeProps } from "../utils/render.js"
|
|
36
|
+
import ElementOrComponent from "../utils/ElementOrComponent.svelte"
|
|
37
|
+
|
|
38
|
+
const internalId = htmlid()
|
|
39
|
+
const providedId = useProvidedId()
|
|
40
|
+
const providedDisabled = useDisabled()
|
|
41
|
+
|
|
42
|
+
let {
|
|
43
|
+
ref = $bindable(),
|
|
44
|
+
value = $bindable<PropsOf<TTag>["value"]>(),
|
|
45
|
+
id = (providedId?.value || `headlessui-input-${internalId}`) as PropsOf<TTag>["id"],
|
|
46
|
+
disabled: theirDisabled = false,
|
|
47
|
+
autofocus = false as PropsOf<TTag>["autofocus"],
|
|
48
|
+
invalid = false,
|
|
49
|
+
...theirProps
|
|
50
|
+
}: { as?: TTag } & TextareaProps<TTag> = $props()
|
|
51
|
+
const disabled = $derived(providedDisabled?.value ?? theirDisabled)
|
|
52
|
+
|
|
53
|
+
const labelledBy = useLabelledBy()
|
|
54
|
+
const describedBy = useDescribedBy()
|
|
55
|
+
|
|
56
|
+
const { isFocusVisible: focus, focusProps } = $derived(
|
|
57
|
+
useFocusRing({
|
|
58
|
+
get autofocus() {
|
|
59
|
+
return autofocus
|
|
60
|
+
},
|
|
61
|
+
})
|
|
54
62
|
)
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
const { isHovered: hover, hoverProps } = $derived(
|
|
64
|
+
useHover({
|
|
65
|
+
get disabled() {
|
|
66
|
+
return disabled
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
const ourProps = $derived(
|
|
72
|
+
mergeProps(
|
|
73
|
+
{
|
|
74
|
+
id,
|
|
75
|
+
"aria-labelledby": labelledBy?.value,
|
|
76
|
+
"aria-describedby": describedBy?.value,
|
|
77
|
+
"aria-invalid": invalid ? "" : undefined,
|
|
78
|
+
disabled: disabled || undefined,
|
|
79
|
+
autofocus,
|
|
80
|
+
},
|
|
81
|
+
focusProps,
|
|
82
|
+
hoverProps
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
const slot = $derived({ disabled, invalid, hover, focus, autofocus } satisfies TextareaRenderPropArg)
|
|
57
87
|
</script>
|
|
58
88
|
|
|
59
89
|
<ElementOrComponent
|