@pzerelles/headlessui-svelte 2.1.2-next.32 → 2.1.2-next.34
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 +9 -10
- package/dist/button/Button.svelte.d.ts +5 -32
- package/dist/button/index.d.ts +1 -1
- package/dist/checkbox/Checkbox.svelte +15 -12
- package/dist/checkbox/Checkbox.svelte.d.ts +15 -32
- package/dist/checkbox/index.d.ts +1 -1
- package/dist/close-button/CloseButton.svelte +4 -7
- package/dist/close-button/CloseButton.svelte.d.ts +2 -43
- package/dist/close-button/index.d.ts +1 -0
- package/dist/close-button/index.js +1 -0
- package/dist/data-interactive/DataInteractive.svelte +6 -20
- package/dist/data-interactive/DataInteractive.svelte.d.ts +8 -30
- package/dist/data-interactive/index.d.ts +1 -1
- package/dist/data-interactive/index.js +1 -1
- 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 -11
- package/dist/dialog/DialogBackdrop.svelte.d.ts +5 -29
- package/dist/dialog/DialogPanel.svelte +18 -11
- package/dist/dialog/DialogPanel.svelte.d.ts +5 -30
- package/dist/dialog/DialogTitle.svelte +19 -8
- package/dist/dialog/DialogTitle.svelte.d.ts +7 -27
- package/dist/dialog/context.svelte.js +1 -1
- package/dist/dialog/index.d.ts +4 -4
- package/dist/dialog/index.js +3 -3
- package/dist/field/Field.svelte +10 -18
- package/dist/field/Field.svelte.d.ts +4 -30
- package/dist/fieldset/Fieldset.svelte +11 -15
- package/dist/fieldset/Fieldset.svelte.d.ts +5 -31
- package/dist/focus-trap/FocusTrap.svelte +21 -26
- package/dist/focus-trap/FocusTrap.svelte.d.ts +5 -34
- 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 +20 -10
- package/dist/input/Input.svelte.d.ts +14 -27
- package/dist/input/index.d.ts +1 -1
- package/dist/internal/FocusSentinel.svelte +33 -32
- package/dist/internal/FormResolver.svelte +5 -1
- package/dist/internal/Hidden.svelte +10 -24
- package/dist/internal/Hidden.svelte.d.ts +5 -30
- 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 +7 -19
- package/dist/listbox/Listbox.svelte.d.ts +12 -35
- package/dist/listbox/ListboxButton.svelte +14 -14
- package/dist/listbox/ListboxButton.svelte.d.ts +6 -32
- package/dist/listbox/ListboxOption.svelte +16 -16
- package/dist/listbox/ListboxOption.svelte.d.ts +13 -26
- package/dist/listbox/ListboxOptions.svelte +13 -12
- package/dist/listbox/ListboxOptions.svelte.d.ts +5 -38
- package/dist/listbox/ListboxSelectedOption.svelte +15 -17
- package/dist/listbox/ListboxSelectedOption.svelte.d.ts +8 -32
- package/dist/listbox/index.d.ts +5 -5
- package/dist/listbox/index.js +4 -4
- package/dist/menu/Menu.svelte +6 -8
- package/dist/menu/Menu.svelte.d.ts +4 -31
- package/dist/menu/MenuButton.svelte +13 -13
- package/dist/menu/MenuButton.svelte.d.ts +5 -34
- package/dist/menu/MenuHeading.svelte +12 -11
- package/dist/menu/MenuHeading.svelte.d.ts +4 -31
- package/dist/menu/MenuItem.svelte +13 -13
- package/dist/menu/MenuItem.svelte.d.ts +6 -32
- package/dist/menu/MenuItems.svelte +13 -14
- package/dist/menu/MenuItems.svelte.d.ts +5 -38
- package/dist/menu/MenuSection.svelte +11 -10
- package/dist/menu/MenuSection.svelte.d.ts +5 -29
- package/dist/menu/MenuSeparator.svelte +11 -9
- package/dist/menu/MenuSeparator.svelte.d.ts +5 -28
- package/dist/menu/index.d.ts +4 -4
- package/dist/menu/index.js +1 -1
- package/dist/popover/Popover.svelte +9 -9
- package/dist/popover/Popover.svelte.d.ts +5 -30
- package/dist/popover/PopoverBackdrop.svelte +16 -13
- package/dist/popover/PopoverBackdrop.svelte.d.ts +7 -34
- package/dist/popover/PopoverButton.svelte +34 -34
- package/dist/popover/PopoverButton.svelte.d.ts +6 -28
- package/dist/popover/PopoverGroup.svelte +15 -17
- package/dist/popover/PopoverGroup.svelte.d.ts +5 -28
- package/dist/popover/PopoverPanel.svelte +47 -42
- package/dist/popover/PopoverPanel.svelte.d.ts +6 -36
- package/dist/popover/index.d.ts +4 -4
- package/dist/popover/index.js +3 -3
- package/dist/portal/InternalPortal.svelte +17 -17
- package/dist/portal/InternalPortal.svelte.d.ts +5 -30
- package/dist/portal/Portal.svelte +7 -6
- package/dist/portal/Portal.svelte.d.ts +2 -18
- package/dist/portal/PortalGroup.svelte +6 -14
- package/dist/portal/PortalGroup.svelte.d.ts +4 -31
- package/dist/select/Select.svelte +11 -10
- package/dist/select/Select.svelte.d.ts +6 -32
- package/dist/select/index.d.ts +1 -1
- package/dist/switch/Switch.svelte +14 -13
- package/dist/switch/Switch.svelte.d.ts +6 -38
- package/dist/switch/SwitchGroup.svelte +5 -5
- package/dist/switch/SwitchGroup.svelte.d.ts +7 -27
- package/dist/switch/index.d.ts +1 -1
- package/dist/tabs/Tab.svelte +13 -13
- package/dist/tabs/Tab.svelte.d.ts +5 -32
- package/dist/tabs/TabGroup.svelte +9 -9
- package/dist/tabs/TabGroup.svelte.d.ts +5 -34
- package/dist/tabs/TabList.svelte +8 -9
- package/dist/tabs/TabList.svelte.d.ts +6 -28
- package/dist/tabs/TabPanel.svelte +12 -12
- package/dist/tabs/TabPanel.svelte.d.ts +5 -34
- package/dist/tabs/TabPanels.svelte +6 -6
- package/dist/tabs/TabPanels.svelte.d.ts +6 -27
- package/dist/tabs/index.d.ts +5 -5
- package/dist/tabs/index.js +1 -1
- package/dist/textarea/Textarea.svelte +13 -11
- package/dist/textarea/Textarea.svelte.d.ts +14 -27
- package/dist/textarea/index.d.ts +1 -1
- 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/transition/index.d.ts +2 -2
- package/dist/transition/index.js +1 -1
- 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,47 +1,34 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Props } from "../utils/types.js";
|
|
2
2
|
declare const DEFAULT_TEXTAREA_TAG: "textarea";
|
|
3
|
-
type TextareaRenderPropArg = {
|
|
3
|
+
export type TextareaRenderPropArg = {
|
|
4
4
|
disabled: boolean;
|
|
5
5
|
hover: boolean;
|
|
6
6
|
focus: boolean;
|
|
7
7
|
autofocus: boolean;
|
|
8
8
|
invalid: boolean;
|
|
9
9
|
};
|
|
10
|
-
type
|
|
11
|
-
|
|
10
|
+
export type TextareaProps<TValue = string> = Props<typeof DEFAULT_TEXTAREA_TAG, TextareaRenderPropArg, {
|
|
11
|
+
element?: HTMLElement;
|
|
12
|
+
id?: string;
|
|
12
13
|
value?: TValue;
|
|
13
14
|
disabled?: boolean;
|
|
14
15
|
invalid?: boolean;
|
|
15
16
|
autofocus?: boolean;
|
|
16
17
|
}>;
|
|
17
|
-
declare class __sveltets_Render<
|
|
18
|
-
props():
|
|
19
|
-
as?: TTag | undefined;
|
|
20
|
-
value?: TValue | undefined;
|
|
21
|
-
} & (Exclude<keyof PropsOf<TTag>, ("slot" | "as" | "children" | "class" | "ref") | "invalid" | "disabled" | "autofocus" | "value" | TextareaPropsWeControl> extends infer T extends keyof PropsOf<TTag> ? { [P in T]: PropsOf<TTag>[P]; } : never) & {
|
|
22
|
-
children?: import("svelte").Snippet<[TextareaRenderPropArg & {
|
|
23
|
-
props?: Record<string, any>;
|
|
24
|
-
}]> | undefined;
|
|
25
|
-
class?: string | ((bag: TextareaRenderPropArg) => string) | null | undefined;
|
|
26
|
-
ref?: HTMLElement;
|
|
27
|
-
} & {
|
|
28
|
-
value?: TValue | undefined;
|
|
29
|
-
disabled?: boolean;
|
|
30
|
-
invalid?: boolean;
|
|
31
|
-
autofocus?: boolean;
|
|
32
|
-
};
|
|
18
|
+
declare class __sveltets_Render<TValue = string> {
|
|
19
|
+
props(): TextareaProps<TValue>;
|
|
33
20
|
events(): {};
|
|
34
21
|
slots(): {};
|
|
35
|
-
bindings(): "
|
|
22
|
+
bindings(): "element" | "value";
|
|
36
23
|
exports(): {};
|
|
37
24
|
}
|
|
38
25
|
interface $$IsomorphicComponent {
|
|
39
|
-
new <
|
|
40
|
-
$$bindings?: ReturnType<__sveltets_Render<
|
|
41
|
-
} & ReturnType<__sveltets_Render<
|
|
42
|
-
<
|
|
43
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any
|
|
26
|
+
new <TValue = string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TValue>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TValue>['props']>, ReturnType<__sveltets_Render<TValue>['events']>, ReturnType<__sveltets_Render<TValue>['slots']>> & {
|
|
27
|
+
$$bindings?: ReturnType<__sveltets_Render<TValue>['bindings']>;
|
|
28
|
+
} & ReturnType<__sveltets_Render<TValue>['exports']>;
|
|
29
|
+
<TValue = string>(internal: unknown, props: ReturnType<__sveltets_Render<TValue>['props']> & {}): ReturnType<__sveltets_Render<TValue>['exports']>;
|
|
30
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
44
31
|
}
|
|
45
32
|
declare const Textarea: $$IsomorphicComponent;
|
|
46
|
-
type Textarea<
|
|
33
|
+
type Textarea<TValue = string> = InstanceType<typeof Textarea<TValue>>;
|
|
47
34
|
export default Textarea;
|
package/dist/textarea/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Textarea, type TextareaProps } from "./Textarea.svelte";
|
|
1
|
+
export { default as Textarea, type TextareaProps, type TextareaRenderPropArg as TextareaSlot } from "./Textarea.svelte";
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import { compact, RenderStrategy } from "../utils/render.js"
|
|
3
|
-
import type { ElementType } from "../utils/types.js"
|
|
4
3
|
import { onMount, setContext, untrack } from "svelte"
|
|
5
4
|
import {
|
|
6
5
|
hasChildren,
|
|
@@ -37,22 +36,20 @@
|
|
|
37
36
|
* `Transition` parent, which is a `Fragment`, is not. So we should not forward
|
|
38
37
|
* the ref to the `Fragment`.
|
|
39
38
|
*/
|
|
40
|
-
export function shouldForwardRef
|
|
41
|
-
props: TransitionRootProps<TTag>
|
|
42
|
-
) {
|
|
39
|
+
export function shouldForwardRef(props: TransitionRootProps) {
|
|
43
40
|
return (
|
|
44
41
|
// If we have any of the enter/leave classes
|
|
45
42
|
Boolean(props.enter || props.enterFrom || props.enterTo || props.leave || props.leaveFrom || props.leaveTo) ||
|
|
46
43
|
// If the `as` prop is not a Fragment
|
|
47
|
-
|
|
44
|
+
!props.asChild ||
|
|
48
45
|
// If we have a single child, then we can forward the ref directly
|
|
49
46
|
props.children !== undefined
|
|
50
47
|
)
|
|
51
48
|
}
|
|
52
49
|
</script>
|
|
53
50
|
|
|
54
|
-
<script lang="ts"
|
|
55
|
-
let {
|
|
51
|
+
<script lang="ts">
|
|
52
|
+
let { element = $bindable(), ..._props }: TransitionChildProps = $props()
|
|
56
53
|
const {
|
|
57
54
|
// Whether or not to enable transitions on the current element (by exposing
|
|
58
55
|
// transition data). When set to false, the `Transition` component still
|
|
@@ -78,7 +75,7 @@
|
|
|
78
75
|
} = $derived(_props)
|
|
79
76
|
let containerElement = $state<HTMLElement>()
|
|
80
77
|
let container = $state<{ current: HTMLElement | null }>({ current: null })
|
|
81
|
-
const requiresRef = $derived(shouldForwardRef(_props))
|
|
78
|
+
const requiresRef = $derived(shouldForwardRef(_props as TransitionRootProps))
|
|
82
79
|
|
|
83
80
|
const strategy = $derived((theirProps.unmount ?? true) ? RenderStrategy.Unmount : RenderStrategy.Hidden)
|
|
84
81
|
|
|
@@ -92,8 +89,8 @@
|
|
|
92
89
|
|
|
93
90
|
onMount(() => {
|
|
94
91
|
if (requiresRef) {
|
|
95
|
-
container.current =
|
|
96
|
-
containerElement =
|
|
92
|
+
container.current = element ?? null
|
|
93
|
+
containerElement = element
|
|
97
94
|
}
|
|
98
95
|
|
|
99
96
|
return register(container)
|
|
@@ -224,7 +221,11 @@
|
|
|
224
221
|
classNames(
|
|
225
222
|
// Incoming classes if any
|
|
226
223
|
// all components accept className (but all HTML elements do)
|
|
227
|
-
theirProps.
|
|
224
|
+
theirProps.asChild
|
|
225
|
+
? undefined
|
|
226
|
+
: typeof theirProps.class === "function"
|
|
227
|
+
? theirProps.class({ element })
|
|
228
|
+
: theirProps.class,
|
|
228
229
|
|
|
229
230
|
// Apply these classes immediately
|
|
230
231
|
immediate && enter,
|
|
@@ -264,4 +265,10 @@
|
|
|
264
265
|
setContext<NestingContextValues>("NestingContext", nesting)
|
|
265
266
|
</script>
|
|
266
267
|
|
|
267
|
-
<ElementOrComponent
|
|
268
|
+
<ElementOrComponent
|
|
269
|
+
{ourProps}
|
|
270
|
+
{theirProps}
|
|
271
|
+
defaultTag={DEFAULT_TRANSITION_CHILD_TAG}
|
|
272
|
+
name="TransitionChild"
|
|
273
|
+
bind:element
|
|
274
|
+
/>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { ElementType } from "../utils/types.js";
|
|
2
1
|
import type { TransitionRootProps } from "./Transition.svelte";
|
|
3
|
-
import {
|
|
2
|
+
import { type TransitionChildProps } from "./TransitionChild.svelte";
|
|
4
3
|
/**
|
|
5
4
|
* Check if we should forward the ref to the child element or not. This is to
|
|
6
5
|
* prevent crashes when the `as` prop is a Fragment _and_ the component just acts
|
|
@@ -19,34 +18,6 @@ import { DEFAULT_TRANSITION_CHILD_TAG } from "./TransitionChild.svelte";
|
|
|
19
18
|
* `Transition` parent, which is a `Fragment`, is not. So we should not forward
|
|
20
19
|
* the ref to the `Fragment`.
|
|
21
20
|
*/
|
|
22
|
-
export declare function shouldForwardRef
|
|
23
|
-
declare
|
|
24
|
-
props(): {
|
|
25
|
-
as?: TTag | undefined;
|
|
26
|
-
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("slot" | "as" | "children" | "class" | "ref") | "unmount" | "transition" | keyof import("./context.svelte.js").TransitionClasses | keyof import("./context.svelte.js").TransitionEvents | "appear"> extends infer T extends keyof import("../utils/types.js").PropsOf<TTag> ? { [P in T]: import("../utils/types.js").PropsOf<TTag>[P]; } : never) & {
|
|
27
|
-
children?: import("svelte").Snippet<[HTMLElement & {
|
|
28
|
-
props?: Record<string, any>;
|
|
29
|
-
}]> | undefined;
|
|
30
|
-
class?: string | ((bag: HTMLElement) => string) | null | undefined;
|
|
31
|
-
ref?: HTMLElement;
|
|
32
|
-
} & {
|
|
33
|
-
unmount?: boolean | undefined;
|
|
34
|
-
} & import("./context.svelte.js").TransitionClasses & import("./context.svelte.js").TransitionEvents & {
|
|
35
|
-
transition?: boolean;
|
|
36
|
-
appear?: boolean;
|
|
37
|
-
};
|
|
38
|
-
events(): {};
|
|
39
|
-
slots(): {};
|
|
40
|
-
bindings(): "ref";
|
|
41
|
-
exports(): {};
|
|
42
|
-
}
|
|
43
|
-
interface $$IsomorphicComponent {
|
|
44
|
-
new <TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_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']>> & {
|
|
45
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
46
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
47
|
-
<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
48
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
49
|
-
}
|
|
50
|
-
declare const InternalTransitionChild: $$IsomorphicComponent;
|
|
51
|
-
type InternalTransitionChild<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG> = InstanceType<typeof InternalTransitionChild<TTag>>;
|
|
21
|
+
export declare function shouldForwardRef(props: TransitionRootProps): boolean;
|
|
22
|
+
declare const InternalTransitionChild: import("svelte").Component<TransitionChildProps, {}, "element">;
|
|
52
23
|
export default InternalTransitionChild;
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import { State, useOpenClosed } from "../internal/open-closed.js"
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type TransitionRootProps<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG> =
|
|
12
|
-
TransitionChildProps<TTag> & {
|
|
13
|
-
show?: boolean
|
|
14
|
-
appear?: boolean
|
|
15
|
-
}
|
|
3
|
+
import { setContext, untrack } from "svelte"
|
|
4
|
+
import { type TransitionChildProps, TransitionChildRenderFeatures } from "./TransitionChild.svelte"
|
|
5
|
+
|
|
6
|
+
export type TransitionRootProps = TransitionChildProps & {
|
|
7
|
+
show?: boolean
|
|
8
|
+
appear?: boolean
|
|
9
|
+
}
|
|
16
10
|
</script>
|
|
17
11
|
|
|
18
|
-
<script lang="ts"
|
|
19
|
-
import InternalTransitionChild
|
|
12
|
+
<script lang="ts">
|
|
13
|
+
import InternalTransitionChild from "./InternalTransitionChild.svelte"
|
|
20
14
|
import ElementOrComponent from "../utils/ElementOrComponent.svelte"
|
|
21
15
|
import {
|
|
22
16
|
hasChildren,
|
|
@@ -26,9 +20,8 @@
|
|
|
26
20
|
type TransitionContextValues,
|
|
27
21
|
} from "./context.svelte.js"
|
|
28
22
|
|
|
29
|
-
let {
|
|
23
|
+
let { element = $bindable(), show, ..._props }: TransitionRootProps = $props()
|
|
30
24
|
const { appear = false, unmount = true, ...theirProps } = $derived(_props)
|
|
31
|
-
const requiresRef = shouldForwardRef(_props)
|
|
32
25
|
|
|
33
26
|
const usesOpenClosedState = useOpenClosed()
|
|
34
27
|
|
|
@@ -69,7 +62,7 @@
|
|
|
69
62
|
$effect(() => {
|
|
70
63
|
if (show) {
|
|
71
64
|
_state = TreeStates.Visible
|
|
72
|
-
} else if (!hasChildren(nestingBag) && untrack(() =>
|
|
65
|
+
} else if (!hasChildren(nestingBag) && untrack(() => element)) {
|
|
73
66
|
_state = TreeStates.Hidden
|
|
74
67
|
}
|
|
75
68
|
})
|
|
@@ -98,12 +91,10 @@
|
|
|
98
91
|
return initial
|
|
99
92
|
},
|
|
100
93
|
})
|
|
101
|
-
|
|
102
|
-
const InternalChild = InternalTransitionChild<any>
|
|
103
94
|
</script>
|
|
104
95
|
|
|
105
96
|
{#snippet children()}
|
|
106
|
-
<
|
|
97
|
+
<InternalTransitionChild bind:element {...sharedProps} {...theirProps} {beforeEnter} {beforeLeave} />
|
|
107
98
|
{/snippet}
|
|
108
99
|
|
|
109
100
|
<ElementOrComponent
|
|
@@ -1,39 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export type TransitionRootProps<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG> = TransitionChildProps<TTag> & {
|
|
1
|
+
import { type TransitionChildProps } from "./TransitionChild.svelte";
|
|
2
|
+
export type TransitionRootProps = TransitionChildProps & {
|
|
4
3
|
show?: boolean;
|
|
5
4
|
appear?: boolean;
|
|
6
5
|
};
|
|
7
|
-
declare
|
|
8
|
-
props(): {
|
|
9
|
-
as?: TTag | undefined;
|
|
10
|
-
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("slot" | "as" | "children" | "class" | "ref") | "unmount" | "transition" | keyof import("./context.svelte.js").TransitionClasses | keyof import("./context.svelte.js").TransitionEvents | "appear"> extends infer T extends keyof import("../utils/types.js").PropsOf<TTag> ? { [P in T]: import("../utils/types.js").PropsOf<TTag>[P]; } : never) & {
|
|
11
|
-
children?: import("svelte").Snippet<[HTMLElement & {
|
|
12
|
-
props?: Record<string, any>;
|
|
13
|
-
}]> | undefined;
|
|
14
|
-
class?: string | ((bag: HTMLElement) => string) | null | undefined;
|
|
15
|
-
ref?: HTMLElement;
|
|
16
|
-
} & {
|
|
17
|
-
unmount?: boolean | undefined;
|
|
18
|
-
} & import("./context.svelte.js").TransitionClasses & import("./context.svelte.js").TransitionEvents & {
|
|
19
|
-
transition?: boolean;
|
|
20
|
-
appear?: boolean;
|
|
21
|
-
} & {
|
|
22
|
-
show?: boolean;
|
|
23
|
-
appear?: boolean;
|
|
24
|
-
};
|
|
25
|
-
events(): {};
|
|
26
|
-
slots(): {};
|
|
27
|
-
bindings(): "ref";
|
|
28
|
-
exports(): {};
|
|
29
|
-
}
|
|
30
|
-
interface $$IsomorphicComponent {
|
|
31
|
-
new <TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_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']>> & {
|
|
32
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
33
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
34
|
-
<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
35
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
36
|
-
}
|
|
37
|
-
declare const Transition: $$IsomorphicComponent;
|
|
38
|
-
type Transition<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG> = InstanceType<typeof Transition<TTag>>;
|
|
6
|
+
declare const Transition: import("svelte").Component<TransitionRootProps, {}, "element">;
|
|
39
7
|
export default Transition;
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type {
|
|
2
|
+
import type { Props } from "../utils/types.js"
|
|
3
3
|
import { RenderFeatures, type PropsForFeatures } from "../utils/render.js"
|
|
4
4
|
import type { TransitionEvents, TransitionClasses } from "./context.svelte.js"
|
|
5
5
|
|
|
6
6
|
type TransitionChildPropsWeControl = never
|
|
7
7
|
|
|
8
|
-
export type TransitionChildProps
|
|
9
|
-
|
|
8
|
+
export type TransitionChildProps = Props<
|
|
9
|
+
typeof DEFAULT_TRANSITION_CHILD_TAG,
|
|
10
10
|
TransitionChildRenderPropArg,
|
|
11
|
-
TransitionChildPropsWeControl,
|
|
12
11
|
PropsForFeatures<typeof TransitionChildRenderFeatures> &
|
|
13
12
|
TransitionClasses &
|
|
14
|
-
TransitionEvents & { transition?: boolean; appear?: boolean }
|
|
13
|
+
TransitionEvents & { transition?: boolean; appear?: boolean; element?: HTMLElement }
|
|
15
14
|
>
|
|
16
15
|
|
|
17
|
-
export const DEFAULT_TRANSITION_CHILD_TAG = "
|
|
18
|
-
export type TransitionChildRenderPropArg = HTMLElement
|
|
16
|
+
export const DEFAULT_TRANSITION_CHILD_TAG = "div"
|
|
17
|
+
export type TransitionChildRenderPropArg = { element?: HTMLElement }
|
|
19
18
|
export const TransitionChildRenderFeatures = RenderFeatures.RenderStrategy
|
|
20
19
|
</script>
|
|
21
20
|
|
|
22
|
-
<script lang="ts"
|
|
21
|
+
<script lang="ts">
|
|
23
22
|
import { useOpenClosed } from "../internal/open-closed.js"
|
|
24
23
|
import { getContext } from "svelte"
|
|
25
24
|
import InternalTransitionChild from "./InternalTransitionChild.svelte"
|
|
@@ -28,9 +27,9 @@
|
|
|
28
27
|
const hasTransitionContext = !!getContext("TransitionContext")
|
|
29
28
|
const hasOpenClosedContext = useOpenClosed() !== null
|
|
30
29
|
|
|
31
|
-
let {
|
|
30
|
+
let { element = $bindable(), ...props }: TransitionChildProps = $props()
|
|
32
31
|
|
|
33
32
|
const TransitionRootOrChild = !hasTransitionContext && hasOpenClosedContext ? Transition : InternalTransitionChild
|
|
34
33
|
</script>
|
|
35
34
|
|
|
36
|
-
<TransitionRootOrChild bind:
|
|
35
|
+
<TransitionRootOrChild bind:element {...props} />
|
|
@@ -1,41 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Props } from "../utils/types.js";
|
|
2
2
|
import { RenderFeatures, type PropsForFeatures } from "../utils/render.js";
|
|
3
3
|
import type { TransitionEvents, TransitionClasses } from "./context.svelte.js";
|
|
4
|
-
type
|
|
5
|
-
export type TransitionChildProps<TTag extends ElementType> = Props<TTag, TransitionChildRenderPropArg, TransitionChildPropsWeControl, PropsForFeatures<typeof TransitionChildRenderFeatures> & TransitionClasses & TransitionEvents & {
|
|
4
|
+
export type TransitionChildProps = Props<typeof DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderPropArg, PropsForFeatures<typeof TransitionChildRenderFeatures> & TransitionClasses & TransitionEvents & {
|
|
6
5
|
transition?: boolean;
|
|
7
6
|
appear?: boolean;
|
|
7
|
+
element?: HTMLElement;
|
|
8
8
|
}>;
|
|
9
|
-
export declare const DEFAULT_TRANSITION_CHILD_TAG = "
|
|
10
|
-
export type TransitionChildRenderPropArg =
|
|
9
|
+
export declare const DEFAULT_TRANSITION_CHILD_TAG = "div";
|
|
10
|
+
export type TransitionChildRenderPropArg = {
|
|
11
|
+
element?: HTMLElement;
|
|
12
|
+
};
|
|
11
13
|
export declare const TransitionChildRenderFeatures = RenderFeatures.RenderStrategy;
|
|
12
|
-
declare
|
|
13
|
-
props(): {
|
|
14
|
-
as?: TTag | undefined;
|
|
15
|
-
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("slot" | "as" | "children" | "class" | "ref") | "unmount" | "transition" | keyof TransitionClasses | keyof TransitionEvents | "appear"> extends infer T extends keyof import("../utils/types.js").PropsOf<TTag> ? { [P in T]: import("../utils/types.js").PropsOf<TTag>[P]; } : never) & {
|
|
16
|
-
children?: import("svelte").Snippet<[HTMLElement & {
|
|
17
|
-
props?: Record<string, any>;
|
|
18
|
-
}]> | undefined;
|
|
19
|
-
class?: string | ((bag: HTMLElement) => string) | null | undefined;
|
|
20
|
-
ref?: HTMLElement;
|
|
21
|
-
} & {
|
|
22
|
-
unmount?: boolean | undefined;
|
|
23
|
-
} & TransitionClasses & TransitionEvents & {
|
|
24
|
-
transition?: boolean;
|
|
25
|
-
appear?: boolean;
|
|
26
|
-
};
|
|
27
|
-
events(): {};
|
|
28
|
-
slots(): {};
|
|
29
|
-
bindings(): "ref";
|
|
30
|
-
exports(): {};
|
|
31
|
-
}
|
|
32
|
-
interface $$IsomorphicComponent {
|
|
33
|
-
new <TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_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']>> & {
|
|
34
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
35
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
36
|
-
<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
37
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
38
|
-
}
|
|
39
|
-
declare const TransitionChild: $$IsomorphicComponent;
|
|
40
|
-
type TransitionChild<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG> = InstanceType<typeof TransitionChild<TTag>>;
|
|
14
|
+
declare const TransitionChild: import("svelte").Component<TransitionChildProps, {}, "element">;
|
|
41
15
|
export default TransitionChild;
|
|
@@ -16,7 +16,7 @@ export function useTransitionContext() {
|
|
|
16
16
|
return context;
|
|
17
17
|
}
|
|
18
18
|
export function useParentNesting() {
|
|
19
|
-
|
|
19
|
+
const context = getContext("NestingContext");
|
|
20
20
|
if (!context) {
|
|
21
21
|
throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");
|
|
22
22
|
}
|
|
@@ -29,7 +29,7 @@ export function hasChildren(bag) {
|
|
|
29
29
|
}
|
|
30
30
|
export function useNesting(options) {
|
|
31
31
|
const { done, parent } = $derived(options);
|
|
32
|
-
|
|
32
|
+
const transitionableChildren = $state([]);
|
|
33
33
|
const mounted = useIsMounted();
|
|
34
34
|
const d = useDisposables();
|
|
35
35
|
const unregister = (container, strategy = RenderStrategy.Hidden) => {
|
|
@@ -60,13 +60,13 @@ export function useNesting(options) {
|
|
|
60
60
|
}
|
|
61
61
|
return () => unregister(container, RenderStrategy.Unmount);
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
const todos = $state([]);
|
|
64
64
|
let wait = $state(Promise.resolve());
|
|
65
|
-
|
|
65
|
+
const chains = $state({
|
|
66
66
|
enter: [],
|
|
67
67
|
leave: [],
|
|
68
68
|
});
|
|
69
|
-
|
|
69
|
+
const onStart = (container, direction, cb) => {
|
|
70
70
|
// Clear out all existing todos
|
|
71
71
|
todos.splice(0);
|
|
72
72
|
// Remove all existing promises for the current container from the parent because we can
|
|
@@ -85,7 +85,7 @@ export function useNesting(options) {
|
|
|
85
85
|
parent?.chains[direction].push([
|
|
86
86
|
container,
|
|
87
87
|
new Promise((resolve) => {
|
|
88
|
-
Promise.all(chains[direction].map(([
|
|
88
|
+
Promise.all(chains[direction].map(([, promise]) => promise)).then(() => resolve());
|
|
89
89
|
}),
|
|
90
90
|
]);
|
|
91
91
|
if (direction === "enter") {
|
|
@@ -96,7 +96,7 @@ export function useNesting(options) {
|
|
|
96
96
|
}
|
|
97
97
|
};
|
|
98
98
|
const onStop = (_container, direction, cb) => {
|
|
99
|
-
Promise.all(chains[direction].splice(0).map(([
|
|
99
|
+
Promise.all(chains[direction].splice(0).map(([, promise]) => promise)) // Wait for my children
|
|
100
100
|
.then(() => {
|
|
101
101
|
todos.shift()?.(); // I'm ready
|
|
102
102
|
})
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as Transition, type TransitionRootProps } from "./Transition.svelte";
|
|
2
|
-
export { default as TransitionChild, type TransitionChildProps } from "./TransitionChild.svelte";
|
|
1
|
+
export { default as Transition, type TransitionRootProps as TransitionProps } from "./Transition.svelte";
|
|
2
|
+
export { default as TransitionChild, type TransitionChildProps, type TransitionChildRenderPropArg as TransitionChildSlot, type TransitionChildRenderPropArg as TransitionSlot, } from "./TransitionChild.svelte";
|
package/dist/transition/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { default as Transition } from "./Transition.svelte";
|
|
2
|
-
export { default as TransitionChild } from "./TransitionChild.svelte";
|
|
2
|
+
export { default as TransitionChild, } from "./TransitionChild.svelte";
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
<script
|
|
2
|
-
|
|
3
|
-
generics="TFeature extends RenderFeatures, TTag extends ElementType, TSlot extends Record<string, any>, TValue"
|
|
4
|
-
>
|
|
5
|
-
import type { ElementType, Props } from "./types.js"
|
|
1
|
+
<script lang="ts" generics="TFeature extends RenderFeatures, TSlot extends Record<string, any>, TValue">
|
|
2
|
+
import type { Props } from "./types.js"
|
|
6
3
|
import { mergePropsAdvanced, RenderFeatures, type PropsForFeatures } from "./render.js"
|
|
7
|
-
import
|
|
4
|
+
import { stateFromSlot } from "./state.js"
|
|
8
5
|
|
|
9
6
|
let {
|
|
10
7
|
ourProps,
|
|
@@ -15,35 +12,79 @@
|
|
|
15
12
|
features,
|
|
16
13
|
visible = true,
|
|
17
14
|
name,
|
|
18
|
-
|
|
15
|
+
element = $bindable(),
|
|
19
16
|
value = $bindable(),
|
|
20
17
|
checked = $bindable(),
|
|
21
18
|
}: {
|
|
22
19
|
ourProps?: Expand<Props<any, TSlot> & PropsForFeatures<TFeature>>
|
|
23
|
-
theirProps: Expand<
|
|
20
|
+
theirProps: Expand<Props<any, TSlot, any>>
|
|
24
21
|
slot?: TSlot
|
|
25
22
|
slots?: TSlot
|
|
26
|
-
defaultTag
|
|
23
|
+
defaultTag?: string
|
|
27
24
|
features?: TFeature
|
|
28
25
|
visible?: boolean
|
|
29
26
|
name: string
|
|
30
27
|
ref?: HTMLElement
|
|
28
|
+
element?: HTMLElement
|
|
31
29
|
value?: TValue
|
|
32
30
|
checked?: boolean
|
|
33
31
|
} = $props()
|
|
34
32
|
|
|
35
33
|
const featureFlags = $derived(features ?? RenderFeatures.None)
|
|
36
|
-
|
|
34
|
+
let {
|
|
35
|
+
as,
|
|
36
|
+
static: isStatic = false,
|
|
37
|
+
unmount = true,
|
|
38
|
+
children,
|
|
39
|
+
asChild,
|
|
40
|
+
class: className,
|
|
41
|
+
...rest
|
|
42
|
+
} = $derived(mergePropsAdvanced(theirProps, ourProps ?? {}))
|
|
37
43
|
const render = $derived(
|
|
38
44
|
visible ||
|
|
39
45
|
(featureFlags & RenderFeatures.Static && isStatic) ||
|
|
40
46
|
(featureFlags & RenderFeatures.RenderStrategy && !unmount)
|
|
41
47
|
)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
: {}
|
|
48
|
+
|
|
49
|
+
const resolvedClass: string | undefined = $derived(
|
|
50
|
+
typeof className === "function" ? className(slot) : (className ?? undefined)
|
|
46
51
|
)
|
|
52
|
+
|
|
53
|
+
const _props = $derived.by(() => {
|
|
54
|
+
// Allow for className to be a function with the slot as the contents
|
|
55
|
+
if ("class" in rest && rest.class && typeof rest.class === "function") {
|
|
56
|
+
rest.class = rest.className(slot)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Drop `aria-labelledby` if it only references the current element. If the `aria-labelledby`
|
|
60
|
+
// references itself but also another element then we can keep it.
|
|
61
|
+
if (rest["aria-labelledby"] && rest["aria-labelledby"] === rest.id) {
|
|
62
|
+
rest["aria-labelledby"] = undefined
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const hiddenProps =
|
|
66
|
+
!visible && !(featureFlags & RenderFeatures.Static) && featureFlags & RenderFeatures.RenderStrategy && !unmount
|
|
67
|
+
? { hidden: true, style: "display: none;" }
|
|
68
|
+
: {}
|
|
69
|
+
|
|
70
|
+
return { ...rest, ...(resolvedClass ? { class: resolvedClass } : {}), ...hiddenProps, ...stateFromSlot(slot) }
|
|
71
|
+
})
|
|
47
72
|
</script>
|
|
48
73
|
|
|
49
|
-
{#if render}
|
|
74
|
+
{#if render}
|
|
75
|
+
{#if asChild || !defaultTag}
|
|
76
|
+
{@render children?.({ ...slot, props: _props })}
|
|
77
|
+
{:else if defaultTag === "select"}
|
|
78
|
+
<select {..._props} bind:this={element} bind:value>{@render children?.(slot)}</select>
|
|
79
|
+
{:else if defaultTag === "input" && (_props as Record<string, any>).type === "checkbox"}
|
|
80
|
+
<input type="checkbox" {..._props} bind:this={element} bind:checked />
|
|
81
|
+
{:else if defaultTag === "input"}
|
|
82
|
+
<input {..._props} bind:this={element} bind:value />
|
|
83
|
+
{:else if defaultTag === "textarea"}
|
|
84
|
+
<textarea {..._props} bind:this={element} bind:value></textarea>
|
|
85
|
+
{:else if children}
|
|
86
|
+
<svelte:element this={defaultTag} {..._props} bind:this={element}>{@render children(slot)}</svelte:element>
|
|
87
|
+
{:else}
|
|
88
|
+
<svelte:element this={defaultTag} {..._props} bind:this={element} />
|
|
89
|
+
{/if}
|
|
90
|
+
{/if}
|