@pzerelles/headlessui-svelte 2.1.2-next.5 → 2.1.2-next.51
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 +16 -19
- package/dist/button/Button.svelte.d.ts +8 -36
- package/dist/button/index.d.ts +1 -1
- package/dist/button/index.js +1 -1
- package/dist/checkbox/Checkbox.svelte +31 -27
- package/dist/checkbox/Checkbox.svelte.d.ts +17 -38
- package/dist/checkbox/index.d.ts +1 -1
- package/dist/checkbox/index.js +1 -1
- package/dist/close-button/CloseButton.svelte +4 -7
- package/dist/close-button/CloseButton.svelte.d.ts +3 -46
- package/dist/close-button/index.d.ts +1 -0
- package/dist/close-button/index.js +1 -0
- package/dist/data-interactive/DataInteractive.svelte +6 -22
- package/dist/data-interactive/DataInteractive.svelte.d.ts +9 -34
- package/dist/data-interactive/index.d.ts +1 -1
- package/dist/data-interactive/index.js +1 -1
- package/dist/description/Description.svelte +29 -24
- package/dist/description/Description.svelte.d.ts +9 -30
- package/dist/description/context.svelte.js +14 -16
- package/dist/description/index.d.ts +1 -1
- package/dist/dialog/Dialog.svelte +315 -31
- package/dist/dialog/Dialog.svelte.d.ts +7 -45
- package/dist/dialog/DialogBackdrop.svelte +11 -14
- package/dist/dialog/DialogBackdrop.svelte.d.ts +8 -33
- package/dist/dialog/DialogPanel.svelte +23 -19
- package/dist/dialog/DialogPanel.svelte.d.ts +8 -34
- package/dist/dialog/DialogTitle.svelte +17 -8
- package/dist/dialog/DialogTitle.svelte.d.ts +9 -30
- package/dist/dialog/context.svelte.js +2 -2
- package/dist/dialog/index.d.ts +4 -4
- package/dist/dialog/index.js +4 -4
- package/dist/disclosure/Disclosure.svelte +61 -0
- package/dist/disclosure/Disclosure.svelte.d.ts +14 -0
- package/dist/disclosure/DisclosureButton.svelte +191 -0
- package/dist/disclosure/DisclosureButton.svelte.d.ts +19 -0
- package/dist/disclosure/DisclosurePanel.svelte +96 -0
- package/dist/disclosure/DisclosurePanel.svelte.d.ts +16 -0
- package/dist/disclosure/context.svelte.d.ts +32 -0
- package/dist/disclosure/context.svelte.js +94 -0
- package/dist/disclosure/index.d.ts +3 -0
- package/dist/disclosure/index.js +3 -0
- package/dist/field/Field.svelte +27 -26
- package/dist/field/Field.svelte.d.ts +7 -34
- package/dist/field/index.d.ts +1 -1
- package/dist/fieldset/Fieldset.svelte +21 -20
- package/dist/fieldset/Fieldset.svelte.d.ts +8 -35
- package/dist/fieldset/index.d.ts +1 -1
- package/dist/focus-trap/FocusTrap.svelte +29 -36
- package/dist/focus-trap/FocusTrap.svelte.d.ts +8 -38
- package/dist/hooks/use-controllable.svelte.js +3 -2
- package/dist/hooks/use-did-element-move.svelte.js +5 -10
- package/dist/hooks/use-disabled.d.ts +6 -1
- package/dist/hooks/use-disabled.js +10 -5
- package/dist/hooks/use-element-size.svelte.js +1 -1
- package/dist/hooks/use-event-listener.svelte.d.ts +1 -1
- package/dist/hooks/use-event-listener.svelte.js +3 -1
- package/dist/hooks/use-focus-ring.svelte.js +1 -1
- package/dist/hooks/use-inert-others.svelte.js +10 -10
- package/dist/hooks/use-is-top-layer.svelte.js +2 -2
- package/dist/hooks/use-resolve-button-type.svelte.js +0 -1
- package/dist/hooks/use-root-containers.svelte.d.ts +2 -2
- package/dist/hooks/use-root-containers.svelte.js +5 -5
- package/dist/hooks/use-tab-direction.svelte.js +1 -1
- package/dist/hooks/use-transition.svelte.js +29 -4
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/input/Input.svelte +28 -21
- package/dist/input/Input.svelte.d.ts +16 -33
- package/dist/input/index.d.ts +1 -1
- package/dist/input/index.js +1 -1
- package/dist/internal/FloatingProvider.svelte +17 -0
- package/dist/internal/FloatingProvider.svelte.d.ts +8 -0
- package/dist/internal/FocusSentinel.svelte +33 -32
- package/dist/internal/FocusSentinel.svelte.d.ts +4 -18
- package/dist/internal/ForcePortalRoot.svelte.d.ts +4 -18
- package/dist/internal/FormFields.svelte +18 -13
- package/dist/internal/FormFields.svelte.d.ts +4 -18
- package/dist/internal/FormFieldsProvider.svelte +17 -0
- package/dist/internal/FormFieldsProvider.svelte.d.ts +7 -0
- package/dist/internal/FormResolver.svelte +6 -2
- package/dist/internal/FormResolver.svelte.d.ts +4 -18
- package/dist/internal/Hidden.svelte +10 -10
- package/dist/internal/Hidden.svelte.d.ts +6 -33
- package/dist/internal/MainTreeProvider.svelte +1 -1
- package/dist/internal/MainTreeProvider.svelte.d.ts +4 -18
- package/dist/internal/Portal.svelte.d.ts +4 -18
- package/dist/internal/floating-provider.svelte.d.ts +3 -0
- package/dist/internal/floating-provider.svelte.js +206 -0
- package/dist/internal/floating.svelte.d.ts +46 -22
- package/dist/internal/floating.svelte.js +90 -272
- package/dist/internal/form-fields.svelte.d.ts +10 -0
- package/dist/internal/form-fields.svelte.js +23 -0
- package/dist/internal/frozen.svelte.js +1 -1
- package/dist/label/Label.svelte +17 -13
- package/dist/label/Label.svelte.d.ts +8 -33
- package/dist/label/context.svelte.js +1 -1
- package/dist/label/index.d.ts +1 -1
- package/dist/legend/Legend.svelte +22 -15
- package/dist/legend/Legend.svelte.d.ts +10 -34
- package/dist/listbox/Listbox.svelte +79 -151
- package/dist/listbox/Listbox.svelte.d.ts +16 -91
- package/dist/listbox/ListboxButton.svelte +31 -29
- package/dist/listbox/ListboxButton.svelte.d.ts +8 -38
- package/dist/listbox/ListboxOption.svelte +40 -27
- package/dist/listbox/ListboxOption.svelte.d.ts +16 -32
- package/dist/listbox/ListboxOptions.svelte +126 -72
- package/dist/listbox/ListboxOptions.svelte.d.ts +8 -43
- package/dist/listbox/ListboxSelectedOption.svelte +24 -26
- package/dist/listbox/ListboxSelectedOption.svelte.d.ts +14 -39
- package/dist/listbox/context.svelte.d.ts +76 -0
- package/dist/listbox/context.svelte.js +36 -0
- package/dist/listbox/index.d.ts +5 -5
- package/dist/listbox/index.js +4 -4
- package/dist/menu/Menu.svelte +22 -266
- package/dist/menu/Menu.svelte.d.ts +7 -37
- package/dist/menu/MenuButton.svelte +29 -24
- package/dist/menu/MenuButton.svelte.d.ts +8 -39
- package/dist/menu/MenuHeading.svelte +12 -16
- package/dist/menu/MenuHeading.svelte.d.ts +7 -36
- package/dist/menu/MenuItem.svelte +18 -23
- package/dist/menu/MenuItem.svelte.d.ts +9 -39
- package/dist/menu/MenuItems.svelte +33 -34
- package/dist/menu/MenuItems.svelte.d.ts +8 -43
- package/dist/menu/MenuSection.svelte +9 -12
- package/dist/menu/MenuSection.svelte.d.ts +7 -33
- package/dist/menu/MenuSeparator.svelte +9 -12
- package/dist/menu/MenuSeparator.svelte.d.ts +7 -33
- package/dist/menu/context.svelte.d.ts +2 -1
- package/dist/menu/context.svelte.js +212 -2
- package/dist/menu/index.d.ts +7 -7
- package/dist/menu/index.js +3 -3
- package/dist/popover/Popover.svelte +228 -0
- package/dist/popover/Popover.svelte.d.ts +15 -0
- package/dist/popover/PopoverBackdrop.svelte +83 -0
- package/dist/popover/PopoverBackdrop.svelte.d.ts +17 -0
- package/dist/popover/PopoverButton.svelte +324 -0
- package/dist/popover/PopoverButton.svelte.d.ts +21 -0
- package/dist/popover/PopoverGroup.svelte +66 -0
- package/dist/popover/PopoverGroup.svelte.d.ts +9 -0
- package/dist/popover/PopoverPanel.svelte +359 -0
- package/dist/popover/PopoverPanel.svelte.d.ts +22 -0
- package/dist/popover/context.svelte.d.ts +51 -0
- package/dist/popover/context.svelte.js +108 -0
- package/dist/popover/index.d.ts +5 -0
- package/dist/popover/index.js +5 -0
- package/dist/portal/InternalPortal.svelte +17 -17
- package/dist/portal/InternalPortal.svelte.d.ts +6 -33
- package/dist/portal/Portal.svelte +7 -6
- package/dist/portal/Portal.svelte.d.ts +3 -22
- package/dist/portal/PortalGroup.svelte +6 -14
- package/dist/portal/PortalGroup.svelte.d.ts +5 -34
- package/dist/radio-group/Radio.svelte +142 -0
- package/dist/radio-group/Radio.svelte.d.ts +35 -0
- package/dist/radio-group/RadioGroup.svelte +222 -0
- package/dist/radio-group/RadioGroup.svelte.d.ts +34 -0
- package/dist/radio-group/RadioOption.svelte +145 -0
- package/dist/radio-group/RadioOption.svelte.d.ts +37 -0
- package/dist/radio-group/contest.svelte.d.ts +30 -0
- package/dist/radio-group/contest.svelte.js +40 -0
- package/dist/radio-group/index.d.ts +3 -0
- package/dist/radio-group/index.js +3 -0
- package/dist/select/Select.svelte +112 -0
- package/dist/select/Select.svelte.d.ts +21 -0
- package/dist/select/index.d.ts +1 -0
- package/dist/select/index.js +1 -0
- package/dist/switch/Switch.svelte +27 -28
- package/dist/switch/Switch.svelte.d.ts +9 -42
- package/dist/switch/SwitchGroup.svelte +5 -5
- package/dist/switch/SwitchGroup.svelte.d.ts +8 -30
- package/dist/switch/index.d.ts +1 -1
- package/dist/switch/index.js +1 -1
- package/dist/tabs/Tab.svelte +28 -31
- package/dist/tabs/Tab.svelte.d.ts +8 -36
- package/dist/tabs/TabGroup.svelte +42 -264
- package/dist/tabs/TabGroup.svelte.d.ts +7 -57
- package/dist/tabs/TabList.svelte +13 -16
- package/dist/tabs/TabList.svelte.d.ts +8 -31
- package/dist/tabs/TabPanel.svelte +20 -20
- package/dist/tabs/TabPanel.svelte.d.ts +8 -38
- package/dist/tabs/TabPanels.svelte +11 -9
- package/dist/tabs/TabPanels.svelte.d.ts +8 -30
- package/dist/tabs/context.svelte.d.ts +31 -0
- package/dist/tabs/context.svelte.js +134 -0
- package/dist/tabs/index.d.ts +5 -5
- package/dist/tabs/index.js +4 -4
- package/dist/textarea/Textarea.svelte +24 -20
- package/dist/textarea/Textarea.svelte.d.ts +18 -30
- package/dist/textarea/index.d.ts +1 -1
- package/dist/textarea/index.js +1 -1
- package/dist/transition/InternalTransitionChild.svelte +36 -22
- package/dist/transition/InternalTransitionChild.svelte.d.ts +6 -37
- package/dist/transition/Transition.svelte +16 -17
- package/dist/transition/Transition.svelte.d.ts +8 -38
- package/dist/transition/TransitionChild.svelte +13 -12
- package/dist/transition/TransitionChild.svelte.d.ts +11 -38
- package/dist/transition/context.svelte.js +11 -11
- package/dist/transition/index.d.ts +2 -2
- package/dist/transition/index.js +2 -2
- package/dist/utils/DisabledProvider.svelte +10 -0
- package/dist/utils/DisabledProvider.svelte.d.ts +8 -0
- package/dist/utils/ElementOrComponent.svelte +58 -17
- package/dist/utils/ElementOrComponent.svelte.d.ts +19 -30
- package/dist/utils/StableCollection.svelte.d.ts +4 -18
- package/dist/utils/floating-ui/svelte/components/FloatingNode.svelte +32 -0
- package/dist/utils/floating-ui/svelte/components/FloatingNode.svelte.d.ts +8 -0
- package/dist/utils/floating-ui/svelte/components/FloatingTree.svelte +94 -0
- package/dist/utils/floating-ui/svelte/components/FloatingTree.svelte.d.ts +26 -0
- package/dist/utils/floating-ui/svelte/hooks/useFloating.svelte.d.ts +6 -0
- package/dist/utils/floating-ui/svelte/hooks/useFloating.svelte.js +158 -0
- package/dist/utils/floating-ui/svelte/hooks/useFloatingRootContext.svelte.d.ts +11 -0
- package/dist/utils/floating-ui/svelte/hooks/useFloatingRootContext.svelte.js +53 -0
- package/dist/utils/floating-ui/svelte/hooks/useId.svelte.d.ts +9 -0
- package/dist/utils/floating-ui/svelte/hooks/useId.svelte.js +28 -0
- package/dist/utils/floating-ui/svelte/hooks/useInteractions.svelte.d.ts +23 -0
- package/dist/utils/floating-ui/svelte/hooks/useInteractions.svelte.js +72 -0
- package/dist/utils/floating-ui/svelte/index.d.ts +5 -0
- package/dist/utils/floating-ui/svelte/index.js +5 -0
- package/dist/utils/floating-ui/svelte/inner.svelte.d.ts +83 -0
- package/dist/utils/floating-ui/svelte/inner.svelte.js +178 -0
- package/dist/utils/floating-ui/svelte/types.d.ts +114 -0
- package/dist/utils/floating-ui/svelte/utils/createPubSub.d.ts +5 -0
- package/dist/utils/floating-ui/svelte/utils/createPubSub.js +14 -0
- package/dist/utils/floating-ui/svelte/utils/getFloatingFocusElement.d.ts +2 -0
- package/dist/utils/floating-ui/svelte/utils/getFloatingFocusElement.js +13 -0
- package/dist/utils/floating-ui/svelte/utils/log.d.ts +2 -0
- package/dist/utils/floating-ui/svelte/utils/log.js +19 -0
- package/dist/utils/floating-ui/svelte/utils.d.ts +19 -0
- package/dist/utils/floating-ui/svelte/utils.js +136 -0
- package/dist/utils/floating-ui/svelte-dom/arrow.d.ts +22 -0
- package/dist/utils/floating-ui/svelte-dom/arrow.js +29 -0
- package/dist/utils/floating-ui/svelte-dom/index.d.ts +2 -0
- package/dist/utils/floating-ui/svelte-dom/index.js +2 -0
- package/dist/utils/floating-ui/svelte-dom/types.d.ts +80 -0
- package/dist/utils/floating-ui/svelte-dom/types.js +3 -0
- package/dist/utils/floating-ui/svelte-dom/useFloating.svelte.d.ts +6 -0
- package/dist/utils/floating-ui/svelte-dom/useFloating.svelte.js +183 -0
- package/dist/utils/floating-ui/svelte-dom/utils/deepEqual.d.ts +1 -0
- package/dist/utils/floating-ui/svelte-dom/utils/deepEqual.js +50 -0
- package/dist/utils/floating-ui/svelte-dom/utils/getDPR.d.ts +1 -0
- package/dist/utils/floating-ui/svelte-dom/utils/getDPR.js +7 -0
- package/dist/utils/floating-ui/svelte-dom/utils/roundByDPR.d.ts +1 -0
- package/dist/utils/floating-ui/svelte-dom/utils/roundByDPR.js +5 -0
- package/dist/utils/floating-ui/svelte-dom/utils/useLatestRef.d.ts +4 -0
- package/dist/utils/floating-ui/svelte-dom/utils/useLatestRef.js +7 -0
- package/dist/utils/id.d.ts +1 -1
- package/dist/utils/id.js +1 -1
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/state.js +4 -4
- package/dist/utils/style.d.ts +2 -0
- package/dist/utils/style.js +6 -0
- package/dist/utils/types.d.ts +13 -19
- package/package.json +54 -53
- package/dist/combobox/Combobox.svelte +0 -53
- package/dist/combobox/Combobox.svelte.d.ts +0 -50
- package/dist/dialog/InternalDialog.svelte +0 -294
- package/dist/dialog/InternalDialog.svelte.d.ts +0 -42
- package/dist/internal/HoistFormFields.svelte +0 -14
- package/dist/internal/HoistFormFields.svelte.d.ts +0 -21
- package/dist/internal/id.d.ts +0 -8
- package/dist/internal/id.js +0 -11
- package/dist/listbox/ListboxStates.d.ts +0 -12
- package/dist/listbox/ListboxStates.js +0 -15
- package/dist/utils/Generic.svelte +0 -56
- package/dist/utils/Generic.svelte.d.ts +0 -35
- package/dist/utils/alternative-types.d.ts +0 -21
- /package/dist/utils/{alternative-types.js → floating-ui/svelte/types.js} +0 -0
|
@@ -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,
|
|
@@ -28,8 +27,8 @@
|
|
|
28
27
|
*
|
|
29
28
|
* ```tsx
|
|
30
29
|
* <Transition show={true}>
|
|
31
|
-
* <
|
|
32
|
-
* <
|
|
30
|
+
* <TransitionChild enter="duration-100"><div>Child 1</div></TransitionChild>
|
|
31
|
+
* <TransitionChild enter="duration-200"><div>Child 2</div></TransitionChild>
|
|
33
32
|
* </Transition>
|
|
34
33
|
* ```
|
|
35
34
|
*
|
|
@@ -37,22 +36,26 @@
|
|
|
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
|
-
Boolean(
|
|
42
|
+
Boolean(
|
|
43
|
+
props.enter ||
|
|
44
|
+
props.enterFrom ||
|
|
45
|
+
props.enterTo ||
|
|
46
|
+
props.leave ||
|
|
47
|
+
props.leaveFrom ||
|
|
48
|
+
props.leaveTo ||
|
|
49
|
+
props.class
|
|
50
|
+
) ||
|
|
46
51
|
// If the `as` prop is not a Fragment
|
|
47
|
-
|
|
48
|
-
// If we have a single child, then we can forward the ref directly
|
|
49
|
-
props.children !== undefined
|
|
52
|
+
props.asChild
|
|
50
53
|
)
|
|
51
54
|
}
|
|
52
55
|
</script>
|
|
53
56
|
|
|
54
|
-
<script lang="ts"
|
|
55
|
-
let {
|
|
57
|
+
<script lang="ts">
|
|
58
|
+
let { element = $bindable(), ..._props }: TransitionChildProps = $props()
|
|
56
59
|
const {
|
|
57
60
|
// Whether or not to enable transitions on the current element (by exposing
|
|
58
61
|
// transition data). When set to false, the `Transition` component still
|
|
@@ -78,7 +81,7 @@
|
|
|
78
81
|
} = $derived(_props)
|
|
79
82
|
let containerElement = $state<HTMLElement>()
|
|
80
83
|
let container = $state<{ current: HTMLElement | null }>({ current: null })
|
|
81
|
-
const requiresRef = $derived(shouldForwardRef(_props))
|
|
84
|
+
const requiresRef = $derived(shouldForwardRef(_props as TransitionRootProps))
|
|
82
85
|
|
|
83
86
|
const strategy = $derived((theirProps.unmount ?? true) ? RenderStrategy.Unmount : RenderStrategy.Hidden)
|
|
84
87
|
|
|
@@ -91,9 +94,9 @@
|
|
|
91
94
|
const { register, unregister } = $derived(parentNesting)
|
|
92
95
|
|
|
93
96
|
onMount(() => {
|
|
94
|
-
if (requiresRef) {
|
|
95
|
-
container.current =
|
|
96
|
-
containerElement =
|
|
97
|
+
if (requiresRef || element) {
|
|
98
|
+
container.current = element ?? null
|
|
99
|
+
containerElement = element
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
return register(container)
|
|
@@ -118,10 +121,10 @@
|
|
|
118
121
|
//[state, container, register, unregister, show, strategy]
|
|
119
122
|
|
|
120
123
|
$effect(() => {
|
|
121
|
-
if (!requiresRef) return
|
|
124
|
+
if (!requiresRef && !element) return
|
|
122
125
|
|
|
123
126
|
if (_state === TreeStates.Visible && container.current === null) {
|
|
124
|
-
throw new Error("Did you forget to passthrough the
|
|
127
|
+
throw new Error("Did you forget to passthrough the actual DOM node as `element`?")
|
|
125
128
|
}
|
|
126
129
|
})
|
|
127
130
|
|
|
@@ -174,7 +177,7 @@
|
|
|
174
177
|
}
|
|
175
178
|
|
|
176
179
|
$effect(() => {
|
|
177
|
-
if (requiresRef && transition) return
|
|
180
|
+
if ((requiresRef || element) && transition) return
|
|
178
181
|
|
|
179
182
|
// When we don't transition, then we can complete the transition
|
|
180
183
|
// immediately.
|
|
@@ -188,7 +191,7 @@
|
|
|
188
191
|
if (!transition) return false
|
|
189
192
|
|
|
190
193
|
// If we don't require a ref, then we can't transition.
|
|
191
|
-
if (!requiresRef) return false
|
|
194
|
+
if (!requiresRef && !element) return false
|
|
192
195
|
|
|
193
196
|
// If the server handoff isn't completed yet, we can't transition.
|
|
194
197
|
//if (!ready) return false
|
|
@@ -224,7 +227,11 @@
|
|
|
224
227
|
classNames(
|
|
225
228
|
// Incoming classes if any
|
|
226
229
|
// all components accept className (but all HTML elements do)
|
|
227
|
-
theirProps.
|
|
230
|
+
theirProps.asChild || !requiresRef
|
|
231
|
+
? undefined
|
|
232
|
+
: typeof theirProps.class === "function"
|
|
233
|
+
? theirProps.class({ element })
|
|
234
|
+
: theirProps.class,
|
|
228
235
|
|
|
229
236
|
// Apply these classes immediately
|
|
230
237
|
immediate && enter,
|
|
@@ -244,6 +251,7 @@
|
|
|
244
251
|
!transitionData.transition && show && entered
|
|
245
252
|
)?.trim() || undefined, // If `class` is an empty string, we can omit it
|
|
246
253
|
...transitionDataAttributes(transitionData),
|
|
254
|
+
...(!theirProps.asChild && !requiresRef ? { asChild: true } : {}),
|
|
247
255
|
})
|
|
248
256
|
)
|
|
249
257
|
|
|
@@ -264,4 +272,10 @@
|
|
|
264
272
|
setContext<NestingContextValues>("NestingContext", nesting)
|
|
265
273
|
</script>
|
|
266
274
|
|
|
267
|
-
<ElementOrComponent
|
|
275
|
+
<ElementOrComponent
|
|
276
|
+
{ourProps}
|
|
277
|
+
{theirProps}
|
|
278
|
+
defaultTag={DEFAULT_TRANSITION_CHILD_TAG}
|
|
279
|
+
name="TransitionChild"
|
|
280
|
+
bind:element
|
|
281
|
+
/>
|
|
@@ -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
|
|
@@ -10,8 +9,8 @@ import { DEFAULT_TRANSITION_CHILD_TAG } from "./TransitionChild.svelte";
|
|
|
10
9
|
*
|
|
11
10
|
* ```tsx
|
|
12
11
|
* <Transition show={true}>
|
|
13
|
-
* <
|
|
14
|
-
* <
|
|
12
|
+
* <TransitionChild enter="duration-100"><div>Child 1</div></TransitionChild>
|
|
13
|
+
* <TransitionChild enter="duration-200"><div>Child 2</div></TransitionChild>
|
|
15
14
|
* </Transition>
|
|
16
15
|
* ```
|
|
17
16
|
*
|
|
@@ -19,37 +18,7 @@ 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
|
-
|
|
25
|
-
as?: TTag | undefined;
|
|
26
|
-
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("as" | "children" | "refName" | "class") | "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("../utils/types.js").Children<HTMLElement> | undefined;
|
|
28
|
-
ref?: HTMLElement;
|
|
29
|
-
} & (true extends (import("../utils/types.js").PropsOf<TTag> extends infer T_1 ? T_1 extends import("../utils/types.js").PropsOf<TTag> ? T_1 extends never ? never : "class" extends infer T_2 ? T_2 extends "class" ? T_2 extends keyof T_1 ? true : never : never : never : never : never) ? {
|
|
30
|
-
class?: import("../utils/types.js").PropsOf<TTag>["class"] | ((bag: HTMLElement) => string) | undefined;
|
|
31
|
-
} : {}) & {
|
|
32
|
-
unmount?: boolean | undefined;
|
|
33
|
-
} & import("./context.svelte.js").TransitionClasses & import("./context.svelte.js").TransitionEvents & {
|
|
34
|
-
transition?: boolean;
|
|
35
|
-
appear?: boolean;
|
|
36
|
-
};
|
|
37
|
-
events(): {} & {
|
|
38
|
-
[evt: string]: CustomEvent<any>;
|
|
39
|
-
};
|
|
40
|
-
slots(): {};
|
|
41
|
-
bindings(): "ref";
|
|
42
|
-
exports(): {};
|
|
43
|
-
}
|
|
44
|
-
interface $$IsomorphicComponent {
|
|
45
|
-
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']>> & {
|
|
46
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
47
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
48
|
-
<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {
|
|
49
|
-
$$events?: ReturnType<__sveltets_Render<TTag>['events']>;
|
|
50
|
-
}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
51
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
52
|
-
}
|
|
53
|
-
declare const InternalTransitionChild: $$IsomorphicComponent;
|
|
54
|
-
type InternalTransitionChild<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG> = InstanceType<typeof InternalTransitionChild<TTag>>;
|
|
21
|
+
export declare function shouldForwardRef(props: TransitionRootProps): boolean | undefined;
|
|
22
|
+
declare const InternalTransitionChild: import("svelte").Component<TransitionChildProps, {}, "element">;
|
|
23
|
+
type InternalTransitionChild = ReturnType<typeof InternalTransitionChild>;
|
|
55
24
|
export default InternalTransitionChild;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
2
|
import { State, useOpenClosed } from "../internal/open-closed.js"
|
|
3
|
-
import
|
|
4
|
-
import { setContext, untrack, type Component } from "svelte"
|
|
3
|
+
import { setContext, untrack } from "svelte"
|
|
5
4
|
import {
|
|
5
|
+
type TransitionChildOwnProps,
|
|
6
6
|
type TransitionChildProps,
|
|
7
|
-
DEFAULT_TRANSITION_CHILD_TAG,
|
|
8
7
|
TransitionChildRenderFeatures,
|
|
9
8
|
} from "./TransitionChild.svelte"
|
|
10
9
|
|
|
11
|
-
export type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
export type TransitionRootOwnProps = TransitionChildOwnProps & {
|
|
11
|
+
show?: boolean
|
|
12
|
+
appear?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type TransitionRootProps = TransitionChildProps & {
|
|
16
|
+
show?: boolean
|
|
17
|
+
appear?: boolean
|
|
18
|
+
}
|
|
16
19
|
</script>
|
|
17
20
|
|
|
18
|
-
<script lang="ts"
|
|
19
|
-
import InternalTransitionChild
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import InternalTransitionChild from "./InternalTransitionChild.svelte"
|
|
20
23
|
import ElementOrComponent from "../utils/ElementOrComponent.svelte"
|
|
21
24
|
import {
|
|
22
25
|
hasChildren,
|
|
@@ -26,9 +29,8 @@
|
|
|
26
29
|
type TransitionContextValues,
|
|
27
30
|
} from "./context.svelte.js"
|
|
28
31
|
|
|
29
|
-
let {
|
|
32
|
+
let { element = $bindable(), show, ..._props }: TransitionRootProps = $props()
|
|
30
33
|
const { appear = false, unmount = true, ...theirProps } = $derived(_props)
|
|
31
|
-
const requiresRef = shouldForwardRef(_props)
|
|
32
34
|
|
|
33
35
|
const usesOpenClosedState = useOpenClosed()
|
|
34
36
|
|
|
@@ -69,7 +71,7 @@
|
|
|
69
71
|
$effect(() => {
|
|
70
72
|
if (show) {
|
|
71
73
|
_state = TreeStates.Visible
|
|
72
|
-
} else if (!hasChildren(nestingBag) && untrack(() =>
|
|
74
|
+
} else if (!hasChildren(nestingBag) && untrack(() => element)) {
|
|
73
75
|
_state = TreeStates.Hidden
|
|
74
76
|
}
|
|
75
77
|
})
|
|
@@ -98,12 +100,10 @@
|
|
|
98
100
|
return initial
|
|
99
101
|
},
|
|
100
102
|
})
|
|
101
|
-
|
|
102
|
-
const InternalChild = InternalTransitionChild as Component<TransitionChildProps<TTag>, any>
|
|
103
103
|
</script>
|
|
104
104
|
|
|
105
105
|
{#snippet children()}
|
|
106
|
-
<
|
|
106
|
+
<InternalTransitionChild bind:element {...sharedProps} {...theirProps} {beforeEnter} {beforeLeave} />
|
|
107
107
|
{/snippet}
|
|
108
108
|
|
|
109
109
|
<ElementOrComponent
|
|
@@ -112,7 +112,6 @@
|
|
|
112
112
|
children,
|
|
113
113
|
}}
|
|
114
114
|
theirProps={{}}
|
|
115
|
-
defaultTag={"svelte:fragment"}
|
|
116
115
|
features={TransitionChildRenderFeatures}
|
|
117
116
|
visible={_state === TreeStates.Visible}
|
|
118
117
|
name="Transition"
|
|
@@ -1,42 +1,12 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
export type TransitionRootProps<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG> = TransitionChildProps<TTag> & {
|
|
1
|
+
import { type TransitionChildOwnProps, type TransitionChildProps } from "./TransitionChild.svelte";
|
|
2
|
+
export type TransitionRootOwnProps = TransitionChildOwnProps & {
|
|
4
3
|
show?: boolean;
|
|
5
4
|
appear?: boolean;
|
|
6
5
|
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} & (true extends (import("../utils/types.js").PropsOf<TTag> extends infer T_1 ? T_1 extends import("../utils/types.js").PropsOf<TTag> ? T_1 extends never ? never : "class" extends infer T_2 ? T_2 extends "class" ? T_2 extends keyof T_1 ? true : never : never : never : never : never) ? {
|
|
14
|
-
class?: import("../utils/types.js").PropsOf<TTag>["class"] | ((bag: HTMLElement) => string) | undefined;
|
|
15
|
-
} : {}) & {
|
|
16
|
-
unmount?: boolean | undefined;
|
|
17
|
-
} & import("./context.svelte.js").TransitionClasses & import("./context.svelte.js").TransitionEvents & {
|
|
18
|
-
transition?: boolean;
|
|
19
|
-
appear?: boolean;
|
|
20
|
-
} & {
|
|
21
|
-
show?: boolean;
|
|
22
|
-
appear?: boolean;
|
|
23
|
-
};
|
|
24
|
-
events(): {} & {
|
|
25
|
-
[evt: string]: CustomEvent<any>;
|
|
26
|
-
};
|
|
27
|
-
slots(): {};
|
|
28
|
-
bindings(): "ref";
|
|
29
|
-
exports(): {};
|
|
30
|
-
}
|
|
31
|
-
interface $$IsomorphicComponent {
|
|
32
|
-
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']>> & {
|
|
33
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
34
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
35
|
-
<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {
|
|
36
|
-
$$events?: ReturnType<__sveltets_Render<TTag>['events']>;
|
|
37
|
-
}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
38
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
39
|
-
}
|
|
40
|
-
declare const Transition: $$IsomorphicComponent;
|
|
41
|
-
type Transition<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG> = InstanceType<typeof Transition<TTag>>;
|
|
6
|
+
export type TransitionRootProps = TransitionChildProps & {
|
|
7
|
+
show?: boolean;
|
|
8
|
+
appear?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const Transition: import("svelte").Component<TransitionRootProps, {}, "element">;
|
|
11
|
+
type Transition = ReturnType<typeof Transition>;
|
|
42
12
|
export default Transition;
|
|
@@ -1,25 +1,26 @@
|
|
|
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
|
|
9
|
-
|
|
8
|
+
export type TransitionChildOwnProps = PropsForFeatures<typeof TransitionChildRenderFeatures> &
|
|
9
|
+
TransitionClasses &
|
|
10
|
+
TransitionEvents & { transition?: boolean; appear?: boolean; element?: HTMLElement }
|
|
11
|
+
|
|
12
|
+
export type TransitionChildProps = Props<
|
|
13
|
+
typeof DEFAULT_TRANSITION_CHILD_TAG,
|
|
10
14
|
TransitionChildRenderPropArg,
|
|
11
|
-
|
|
12
|
-
PropsForFeatures<typeof TransitionChildRenderFeatures> &
|
|
13
|
-
TransitionClasses &
|
|
14
|
-
TransitionEvents & { transition?: boolean; appear?: boolean }
|
|
15
|
+
TransitionChildOwnProps
|
|
15
16
|
>
|
|
16
17
|
|
|
17
|
-
export const DEFAULT_TRANSITION_CHILD_TAG = "
|
|
18
|
-
export type TransitionChildRenderPropArg = HTMLElement
|
|
18
|
+
export const DEFAULT_TRANSITION_CHILD_TAG = "div"
|
|
19
|
+
export type TransitionChildRenderPropArg = { element?: HTMLElement }
|
|
19
20
|
export const TransitionChildRenderFeatures = RenderFeatures.RenderStrategy
|
|
20
21
|
</script>
|
|
21
22
|
|
|
22
|
-
<script lang="ts"
|
|
23
|
+
<script lang="ts">
|
|
23
24
|
import { useOpenClosed } from "../internal/open-closed.js"
|
|
24
25
|
import { getContext } from "svelte"
|
|
25
26
|
import InternalTransitionChild from "./InternalTransitionChild.svelte"
|
|
@@ -28,9 +29,9 @@
|
|
|
28
29
|
const hasTransitionContext = !!getContext("TransitionContext")
|
|
29
30
|
const hasOpenClosedContext = useOpenClosed() !== null
|
|
30
31
|
|
|
31
|
-
let {
|
|
32
|
+
let { element = $bindable(), ...props }: TransitionChildProps = $props()
|
|
32
33
|
|
|
33
34
|
const TransitionRootOrChild = !hasTransitionContext && hasOpenClosedContext ? Transition : InternalTransitionChild
|
|
34
35
|
</script>
|
|
35
36
|
|
|
36
|
-
<TransitionRootOrChild bind:
|
|
37
|
+
<TransitionRootOrChild bind:element {...props} />
|
|
@@ -1,44 +1,17 @@
|
|
|
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 TransitionChildOwnProps = PropsForFeatures<typeof TransitionChildRenderFeatures> & TransitionClasses & TransitionEvents & {
|
|
6
5
|
transition?: boolean;
|
|
7
6
|
appear?: boolean;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export type
|
|
7
|
+
element?: HTMLElement;
|
|
8
|
+
};
|
|
9
|
+
export type TransitionChildProps = Props<typeof DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderPropArg, TransitionChildOwnProps>;
|
|
10
|
+
export declare const DEFAULT_TRANSITION_CHILD_TAG = "div";
|
|
11
|
+
export type TransitionChildRenderPropArg = {
|
|
12
|
+
element?: HTMLElement;
|
|
13
|
+
};
|
|
11
14
|
export declare const TransitionChildRenderFeatures = RenderFeatures.RenderStrategy;
|
|
12
|
-
declare
|
|
13
|
-
|
|
14
|
-
as?: TTag | undefined;
|
|
15
|
-
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("as" | "children" | "refName" | "class") | "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("../utils/types.js").Children<HTMLElement> | undefined;
|
|
17
|
-
ref?: HTMLElement;
|
|
18
|
-
} & (true extends (import("../utils/types.js").PropsOf<TTag> extends infer T_1 ? T_1 extends import("../utils/types.js").PropsOf<TTag> ? T_1 extends never ? never : "class" extends infer T_2 ? T_2 extends "class" ? T_2 extends keyof T_1 ? true : never : never : never : never : never) ? {
|
|
19
|
-
class?: import("../utils/types.js").PropsOf<TTag>["class"] | ((bag: HTMLElement) => string) | undefined;
|
|
20
|
-
} : {}) & {
|
|
21
|
-
unmount?: boolean | undefined;
|
|
22
|
-
} & TransitionClasses & TransitionEvents & {
|
|
23
|
-
transition?: boolean;
|
|
24
|
-
appear?: boolean;
|
|
25
|
-
};
|
|
26
|
-
events(): {} & {
|
|
27
|
-
[evt: string]: CustomEvent<any>;
|
|
28
|
-
};
|
|
29
|
-
slots(): {};
|
|
30
|
-
bindings(): "ref";
|
|
31
|
-
exports(): {};
|
|
32
|
-
}
|
|
33
|
-
interface $$IsomorphicComponent {
|
|
34
|
-
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']>> & {
|
|
35
|
-
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
36
|
-
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
37
|
-
<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {
|
|
38
|
-
$$events?: ReturnType<__sveltets_Render<TTag>['events']>;
|
|
39
|
-
}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
40
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
41
|
-
}
|
|
42
|
-
declare const TransitionChild: $$IsomorphicComponent;
|
|
43
|
-
type TransitionChild<TTag extends ElementType = typeof DEFAULT_TRANSITION_CHILD_TAG> = InstanceType<typeof TransitionChild<TTag>>;
|
|
15
|
+
declare const TransitionChild: import("svelte").Component<TransitionChildProps, {}, "element">;
|
|
16
|
+
type TransitionChild = ReturnType<typeof TransitionChild>;
|
|
44
17
|
export default TransitionChild;
|
|
@@ -10,15 +10,15 @@ export var TreeStates;
|
|
|
10
10
|
})(TreeStates || (TreeStates = {}));
|
|
11
11
|
export function useTransitionContext() {
|
|
12
12
|
const context = getContext("TransitionContext");
|
|
13
|
-
if (context
|
|
14
|
-
throw new Error("A <
|
|
13
|
+
if (!context) {
|
|
14
|
+
throw new Error("A <TransitionChild /> is used but it is missing a parent <Transition /> or <Transition.Root />.");
|
|
15
15
|
}
|
|
16
16
|
return context;
|
|
17
17
|
}
|
|
18
18
|
export function useParentNesting() {
|
|
19
|
-
|
|
20
|
-
if (context
|
|
21
|
-
throw new Error("A <
|
|
19
|
+
const context = getContext("NestingContext");
|
|
20
|
+
if (!context) {
|
|
21
|
+
throw new Error("A <TransitionChild /> is used but it is missing a parent <Transition /> or <Transition.Root />.");
|
|
22
22
|
}
|
|
23
23
|
return context;
|
|
24
24
|
}
|
|
@@ -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, type TransitionRootOwnProps as TransitionOwnProps, } from "./Transition.svelte";
|
|
2
|
+
export { default as TransitionChild, type TransitionChildProps, type TransitionChildRenderPropArg as TransitionChildSlot, type TransitionChildRenderPropArg as TransitionSlot, type TransitionChildOwnProps, } from "./TransitionChild.svelte";
|
package/dist/transition/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as Transition } from "./Transition.svelte";
|
|
2
|
-
export { default as TransitionChild } from "./TransitionChild.svelte";
|
|
1
|
+
export { default as Transition, } from "./Transition.svelte";
|
|
2
|
+
export { default as TransitionChild, } from "./TransitionChild.svelte";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { provideDisabled } from "../hooks/use-disabled.js"
|
|
3
|
+
import type { Snippet } from "svelte"
|
|
4
|
+
|
|
5
|
+
const { disabled, children }: { disabled?: boolean; children?: Snippet } = $props()
|
|
6
|
+
|
|
7
|
+
provideDisabled(() => disabled ?? false)
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
{@render children?.()}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
children?: Snippet;
|
|
5
|
+
};
|
|
6
|
+
declare const DisabledProvider: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
7
|
+
type DisabledProvider = ReturnType<typeof DisabledProvider>;
|
|
8
|
+
export default DisabledProvider;
|
|
@@ -1,47 +1,88 @@
|
|
|
1
|
-
<script lang="ts" generics="TFeature extends RenderFeatures,
|
|
2
|
-
import type {
|
|
3
|
-
import { mergePropsAdvanced, RenderFeatures,
|
|
4
|
-
import
|
|
5
|
-
import type { ComponentProps } from "svelte"
|
|
1
|
+
<script lang="ts" generics="TFeature extends RenderFeatures, TSlot extends Record<string, any>, TValue">
|
|
2
|
+
import type { Props } from "./types.js"
|
|
3
|
+
import { mergePropsAdvanced, RenderFeatures, type PropsForFeatures } from "./render.js"
|
|
4
|
+
import { stateFromSlot } from "./state.js"
|
|
6
5
|
|
|
7
6
|
let {
|
|
8
7
|
ourProps,
|
|
9
8
|
theirProps,
|
|
10
|
-
slots,
|
|
11
|
-
slot = slots,
|
|
9
|
+
slots: slot,
|
|
12
10
|
defaultTag,
|
|
13
11
|
features,
|
|
14
12
|
visible = true,
|
|
15
13
|
name,
|
|
16
|
-
|
|
14
|
+
element = $bindable(),
|
|
17
15
|
value = $bindable(),
|
|
18
16
|
checked = $bindable(),
|
|
19
17
|
}: {
|
|
20
18
|
ourProps?: Expand<Props<any, TSlot> & PropsForFeatures<TFeature>>
|
|
21
|
-
theirProps: Expand<
|
|
22
|
-
slot?: TSlot
|
|
19
|
+
theirProps: Expand<Props<any, TSlot, any>>
|
|
23
20
|
slots?: TSlot
|
|
24
|
-
defaultTag
|
|
21
|
+
defaultTag?: string
|
|
25
22
|
features?: TFeature
|
|
26
23
|
visible?: boolean
|
|
27
24
|
name: string
|
|
28
25
|
ref?: HTMLElement
|
|
26
|
+
element?: HTMLElement
|
|
29
27
|
value?: TValue
|
|
30
28
|
checked?: boolean
|
|
31
29
|
} = $props()
|
|
32
30
|
|
|
33
31
|
const featureFlags = $derived(features ?? RenderFeatures.None)
|
|
34
|
-
|
|
32
|
+
let {
|
|
33
|
+
as,
|
|
34
|
+
static: isStatic = false,
|
|
35
|
+
unmount = true,
|
|
36
|
+
children,
|
|
37
|
+
asChild,
|
|
38
|
+
class: className,
|
|
39
|
+
...rest
|
|
40
|
+
} = $derived(mergePropsAdvanced(theirProps, ourProps ?? {}))
|
|
35
41
|
const render = $derived(
|
|
36
42
|
visible ||
|
|
37
43
|
(featureFlags & RenderFeatures.Static && isStatic) ||
|
|
38
44
|
(featureFlags & RenderFeatures.RenderStrategy && !unmount)
|
|
39
45
|
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
: {}
|
|
46
|
+
|
|
47
|
+
const resolvedClass: string | undefined = $derived(
|
|
48
|
+
typeof className === "function" ? className(slot) : (className ?? undefined)
|
|
44
49
|
)
|
|
50
|
+
|
|
51
|
+
const _props = $derived.by(() => {
|
|
52
|
+
// Allow for className to be a function with the slot as the contents
|
|
53
|
+
if ("class" in rest && rest.class && typeof rest.class === "function") {
|
|
54
|
+
rest.class = rest.className(slot)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Drop `aria-labelledby` if it only references the current element. If the `aria-labelledby`
|
|
58
|
+
// references itself but also another element then we can keep it.
|
|
59
|
+
if (rest["aria-labelledby"] && rest["aria-labelledby"] === rest.id) {
|
|
60
|
+
rest["aria-labelledby"] = undefined
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const hiddenProps =
|
|
64
|
+
!visible && !(featureFlags & RenderFeatures.Static) && featureFlags & RenderFeatures.RenderStrategy && !unmount
|
|
65
|
+
? { hidden: true, style: "display: none;" }
|
|
66
|
+
: {}
|
|
67
|
+
|
|
68
|
+
return { ...rest, ...(resolvedClass ? { class: resolvedClass } : {}), ...hiddenProps, ...stateFromSlot(slot) }
|
|
69
|
+
})
|
|
45
70
|
</script>
|
|
46
71
|
|
|
47
|
-
{#if render}
|
|
72
|
+
{#if render}
|
|
73
|
+
{#if asChild || !defaultTag}
|
|
74
|
+
{@render children?.({ ...slot, props: _props })}
|
|
75
|
+
{:else if defaultTag === "select"}
|
|
76
|
+
<select {..._props} bind:this={element} bind:value>{@render children?.(slot)}</select>
|
|
77
|
+
{:else if defaultTag === "input" && (_props as Record<string, any>).type === "checkbox"}
|
|
78
|
+
<input type="checkbox" {..._props} bind:this={element} bind:checked />
|
|
79
|
+
{:else if defaultTag === "input"}
|
|
80
|
+
<input {..._props} bind:this={element} bind:value />
|
|
81
|
+
{:else if defaultTag === "textarea"}
|
|
82
|
+
<textarea {..._props} bind:this={element} bind:value></textarea>
|
|
83
|
+
{:else if children}
|
|
84
|
+
<svelte:element this={defaultTag} {..._props} bind:this={element}>{@render children(slot)}</svelte:element>
|
|
85
|
+
{:else}
|
|
86
|
+
<svelte:element this={defaultTag} {..._props} bind:this={element} />
|
|
87
|
+
{/if}
|
|
88
|
+
{/if}
|