@pzerelles/headlessui-svelte 2.1.1-next.1 → 2.1.2-next.2
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 +6 -10
- package/dist/button/Button.svelte.d.ts +34 -26
- package/dist/checkbox/Checkbox.svelte +40 -22
- package/dist/checkbox/Checkbox.svelte.d.ts +44 -28
- package/dist/close-button/CloseButton.svelte +5 -4
- package/dist/close-button/CloseButton.svelte.d.ts +36 -13
- package/dist/combobox/Combobox.svelte +2 -2
- package/dist/combobox/Combobox.svelte.d.ts +9 -9
- package/dist/data-interactive/DataInteractive.svelte +41 -0
- package/dist/data-interactive/DataInteractive.svelte.d.ts +39 -0
- package/dist/data-interactive/index.d.ts +1 -0
- package/dist/data-interactive/index.js +1 -0
- package/dist/description/Description.svelte +10 -53
- package/dist/description/Description.svelte.d.ts +15 -32
- package/dist/description/context.svelte.d.ts +17 -0
- package/dist/description/context.svelte.js +51 -0
- package/dist/dialog/Dialog.svelte +51 -0
- package/dist/dialog/Dialog.svelte.d.ts +60 -0
- package/dist/dialog/DialogBackdrop.svelte +39 -0
- package/dist/dialog/DialogBackdrop.svelte.d.ts +38 -0
- package/dist/dialog/DialogPanel.svelte +46 -0
- package/dist/dialog/DialogPanel.svelte.d.ts +40 -0
- package/dist/dialog/DialogTitle.svelte +29 -0
- package/dist/dialog/DialogTitle.svelte.d.ts +34 -0
- package/dist/dialog/InternalDialog.svelte +233 -0
- package/dist/dialog/InternalDialog.svelte.d.ts +42 -0
- package/dist/dialog/context.svelte.d.ts +15 -0
- package/dist/dialog/context.svelte.js +16 -0
- package/dist/dialog/index.d.ts +4 -0
- package/dist/dialog/index.js +4 -0
- package/dist/field/Field.svelte +8 -10
- package/dist/field/Field.svelte.d.ts +21 -17
- package/dist/fieldset/Fieldset.svelte +11 -9
- package/dist/fieldset/Fieldset.svelte.d.ts +21 -17
- package/dist/focus-trap/FocusTrap.svelte +332 -0
- package/dist/focus-trap/FocusTrap.svelte.d.ts +58 -0
- package/dist/hooks/use-controllable.svelte.d.ts +1 -1
- package/dist/hooks/use-controllable.svelte.js +3 -3
- package/dist/hooks/use-escape.svelte.d.ts +5 -0
- package/dist/hooks/use-escape.svelte.js +26 -0
- package/dist/hooks/use-event-listener.svelte.d.ts +6 -0
- package/dist/hooks/use-event-listener.svelte.js +12 -0
- package/dist/hooks/use-inert-others.svelte.d.ts +2 -2
- package/dist/hooks/use-inert-others.svelte.js +3 -3
- package/dist/hooks/use-is-mounted.svelte.d.ts +3 -0
- package/dist/hooks/use-is-mounted.svelte.js +14 -0
- package/dist/hooks/use-is-touch-device.svelte.d.ts +3 -0
- package/dist/hooks/use-is-touch-device.svelte.js +20 -0
- package/dist/hooks/use-root-containers.svelte.d.ts +9 -0
- package/dist/hooks/use-root-containers.svelte.js +50 -0
- package/dist/hooks/use-tab-direction.svelte.d.ts +7 -0
- package/dist/hooks/use-tab-direction.svelte.js +25 -0
- package/dist/hooks/use-transition.svelte.js +14 -13
- package/dist/hooks/use-tree-walker.svelte.d.ts +8 -0
- package/dist/hooks/use-tree-walker.svelte.js +19 -0
- package/dist/hooks/use-watch.svelte.d.ts +4 -0
- package/dist/hooks/use-watch.svelte.js +16 -0
- package/dist/hooks/use-window-event.svelte.d.ts +6 -0
- package/dist/hooks/use-window-event.svelte.js +12 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/input/Input.svelte +59 -0
- package/dist/input/Input.svelte.d.ts +52 -0
- package/dist/input/index.d.ts +1 -0
- package/dist/input/index.js +1 -0
- package/dist/internal/FocusSentinel.svelte.d.ts +4 -1
- package/dist/internal/ForcePortalRoot.svelte +6 -0
- package/dist/internal/ForcePortalRoot.svelte.d.ts +22 -0
- package/dist/internal/FormFields.svelte.d.ts +4 -1
- package/dist/internal/FormResolver.svelte.d.ts +4 -1
- package/dist/internal/Hidden.svelte +5 -9
- package/dist/internal/Hidden.svelte.d.ts +17 -10
- package/dist/internal/HoistFormFields.svelte.d.ts +4 -1
- package/dist/internal/MainTreeProvider.svelte +45 -0
- package/dist/internal/MainTreeProvider.svelte.d.ts +31 -0
- package/dist/internal/Portal.svelte.d.ts +4 -1
- package/dist/internal/close-provider.d.ts +7 -0
- package/dist/internal/close-provider.js +7 -0
- package/dist/internal/floating.svelte.d.ts +13 -8
- package/dist/internal/floating.svelte.js +197 -186
- package/dist/internal/id.d.ts +1 -1
- package/dist/internal/open-closed.d.ts +1 -1
- package/dist/internal/open-closed.js +1 -1
- package/dist/label/Label.svelte +12 -61
- package/dist/label/Label.svelte.d.ts +19 -32
- package/dist/label/context.svelte.d.ts +17 -0
- package/dist/label/context.svelte.js +56 -0
- package/dist/legend/Legend.svelte +4 -3
- package/dist/legend/Legend.svelte.d.ts +33 -15
- package/dist/listbox/Listbox.svelte +6 -9
- package/dist/listbox/Listbox.svelte.d.ts +29 -10
- package/dist/listbox/ListboxButton.svelte +6 -8
- package/dist/listbox/ListboxButton.svelte.d.ts +18 -7
- package/dist/listbox/ListboxOption.svelte +4 -6
- package/dist/listbox/ListboxOption.svelte.d.ts +22 -11
- package/dist/listbox/ListboxOptions.svelte +21 -19
- package/dist/listbox/ListboxOptions.svelte.d.ts +23 -7
- package/dist/listbox/ListboxSelectedOption.svelte +17 -7
- package/dist/listbox/ListboxSelectedOption.svelte.d.ts +23 -13
- package/dist/menu/Menu.svelte +235 -0
- package/dist/menu/Menu.svelte.d.ts +42 -0
- package/dist/menu/MenuButton.svelte +127 -0
- package/dist/menu/MenuButton.svelte.d.ts +52 -0
- package/dist/menu/MenuHeading.svelte +19 -0
- package/dist/menu/MenuHeading.svelte.d.ts +39 -0
- package/dist/menu/MenuItem.svelte +114 -0
- package/dist/menu/MenuItem.svelte.d.ts +49 -0
- package/dist/menu/MenuItems.svelte +244 -0
- package/dist/menu/MenuItems.svelte.d.ts +55 -0
- package/dist/menu/MenuSection.svelte +14 -0
- package/dist/menu/MenuSection.svelte.d.ts +35 -0
- package/dist/menu/MenuSeparator.svelte +9 -0
- package/dist/menu/MenuSeparator.svelte.d.ts +35 -0
- package/dist/menu/context.svelte.d.ts +47 -0
- package/dist/menu/context.svelte.js +21 -0
- package/dist/menu/index.d.ts +7 -0
- package/dist/menu/index.js +7 -0
- package/dist/portal/InternalPortal.svelte +22 -33
- package/dist/portal/InternalPortal.svelte.d.ts +16 -7
- package/dist/portal/Portal.svelte +4 -8
- package/dist/portal/Portal.svelte.d.ts +6 -6
- package/dist/portal/PortalGroup.svelte +5 -6
- package/dist/portal/PortalGroup.svelte.d.ts +16 -7
- package/dist/switch/Switch.svelte +11 -17
- package/dist/switch/Switch.svelte.d.ts +23 -6
- package/dist/switch/SwitchGroup.svelte +7 -8
- package/dist/switch/SwitchGroup.svelte.d.ts +14 -7
- package/dist/tabs/Tab.svelte +9 -14
- package/dist/tabs/Tab.svelte.d.ts +18 -6
- package/dist/tabs/TabGroup.svelte +20 -23
- package/dist/tabs/TabGroup.svelte.d.ts +19 -6
- package/dist/tabs/TabList.svelte +5 -7
- package/dist/tabs/TabList.svelte.d.ts +13 -6
- package/dist/tabs/TabPanel.svelte +30 -32
- package/dist/tabs/TabPanel.svelte.d.ts +19 -6
- package/dist/tabs/TabPanels.svelte +5 -6
- package/dist/tabs/TabPanels.svelte.d.ts +13 -6
- package/dist/transition/InternalTransitionChild.svelte +178 -0
- package/dist/transition/InternalTransitionChild.svelte.d.ts +55 -0
- package/dist/transition/Transition.svelte +89 -0
- package/dist/transition/Transition.svelte.d.ts +42 -0
- package/dist/transition/TransitionChild.svelte +16 -0
- package/dist/transition/TransitionChild.svelte.d.ts +44 -0
- package/dist/transition/context.svelte.d.ts +64 -0
- package/dist/transition/context.svelte.js +120 -0
- package/dist/transition/index.d.ts +2 -0
- package/dist/transition/index.js +2 -0
- package/dist/utils/ElementOrComponent.svelte +26 -0
- package/dist/utils/ElementOrComponent.svelte.d.ts +56 -0
- package/dist/utils/Generic.svelte +44 -0
- package/dist/utils/Generic.svelte.d.ts +35 -0
- package/dist/utils/StableCollection.svelte +1 -1
- package/dist/utils/StableCollection.svelte.d.ts +4 -1
- package/dist/utils/active-element-history.d.ts +1 -0
- package/dist/utils/active-element-history.js +35 -0
- package/dist/utils/alternative-types.d.ts +21 -0
- package/dist/utils/alternative-types.js +1 -0
- package/dist/utils/class-names.d.ts +1 -0
- package/dist/utils/class-names.js +10 -0
- package/dist/utils/focus-management.d.ts +2 -1
- package/dist/utils/focus-management.js +13 -13
- package/dist/utils/on-document-ready.d.ts +1 -0
- package/dist/utils/on-document-ready.js +12 -0
- package/dist/utils/render.d.ts +3 -0
- package/dist/utils/render.js +63 -0
- package/dist/utils/state.d.ts +7 -1
- package/dist/utils/state.js +10 -6
- package/dist/utils/types.d.ts +14 -17
- package/dist/utils/types.js +0 -5
- package/package.json +26 -25
- package/dist/tabs/Button.svelte +0 -65
- package/dist/tabs/Button.svelte.d.ts +0 -39
- package/dist/utils/close.d.ts +0 -2
- package/dist/utils/close.js +0 -3
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { disposables, useDisposables } from "../utils/disposables.js";
|
|
2
2
|
import { once } from "../utils/once.js";
|
|
3
3
|
import { untrack } from "svelte";
|
|
4
|
-
import { useFlags } from "./use-flags.svelte.js";
|
|
5
4
|
/**
|
|
6
5
|
* ```
|
|
7
6
|
* ┌──────┐ │ ┌──────────────┐
|
|
@@ -28,8 +27,8 @@ var TransitionState;
|
|
|
28
27
|
TransitionState[TransitionState["Leave"] = 4] = "Leave";
|
|
29
28
|
})(TransitionState || (TransitionState = {}));
|
|
30
29
|
export function transitionDataAttributes(data) {
|
|
31
|
-
|
|
32
|
-
for (
|
|
30
|
+
const attributes = {};
|
|
31
|
+
for (const key in data) {
|
|
33
32
|
if (data[key] === true) {
|
|
34
33
|
attributes[`data-${key}`] = "";
|
|
35
34
|
}
|
|
@@ -124,6 +123,7 @@ export function useTransition(options) {
|
|
|
124
123
|
});
|
|
125
124
|
}
|
|
126
125
|
$effect(() => {
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
127
127
|
;
|
|
128
128
|
[enabled, show, element, d];
|
|
129
129
|
return untrack(() => retry(enabled, show, element, d));
|
|
@@ -172,14 +172,14 @@ function transition(node, { prepare, run, done, inFlight, }) {
|
|
|
172
172
|
return d.dispose;
|
|
173
173
|
}
|
|
174
174
|
function waitForTransition(node, _done) {
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
const done = once(_done);
|
|
176
|
+
const d = disposables();
|
|
177
177
|
if (!node)
|
|
178
178
|
return d.dispose;
|
|
179
179
|
// Safari returns a comma separated list of values, so let's sort them and take the highest value.
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
180
|
+
const { transitionDuration, transitionDelay } = getComputedStyle(node);
|
|
181
|
+
const [durationMs, delayMs] = [transitionDuration, transitionDelay].map((value) => {
|
|
182
|
+
const [resolvedValue = 0] = value
|
|
183
183
|
.split(",")
|
|
184
184
|
// Remove falsy we can't work with
|
|
185
185
|
.filter(Boolean)
|
|
@@ -188,19 +188,19 @@ function waitForTransition(node, _done) {
|
|
|
188
188
|
.sort((a, z) => z - a);
|
|
189
189
|
return resolvedValue;
|
|
190
190
|
});
|
|
191
|
-
|
|
191
|
+
const totalDuration = durationMs + delayMs;
|
|
192
192
|
if (totalDuration !== 0) {
|
|
193
193
|
if (process.env.NODE_ENV === "test") {
|
|
194
|
-
|
|
194
|
+
const dispose = d.setTimeout(() => {
|
|
195
195
|
done();
|
|
196
196
|
dispose();
|
|
197
197
|
}, totalDuration);
|
|
198
198
|
}
|
|
199
199
|
else {
|
|
200
|
-
|
|
200
|
+
const disposeGroup = d.group((d) => {
|
|
201
201
|
// Mark the transition as done when the timeout is reached. This is a fallback in case the
|
|
202
202
|
// transitionrun event is not fired.
|
|
203
|
-
|
|
203
|
+
const cancelTimeout = d.setTimeout(() => {
|
|
204
204
|
done();
|
|
205
205
|
d.dispose();
|
|
206
206
|
}, totalDuration);
|
|
@@ -241,11 +241,12 @@ function prepareTransition(node, { inFlight, prepare }) {
|
|
|
241
241
|
prepare();
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
|
-
|
|
244
|
+
const previous = node.style.transition;
|
|
245
245
|
// Force cancel current transition
|
|
246
246
|
node.style.transition = "none";
|
|
247
247
|
prepare();
|
|
248
248
|
// Trigger a reflow, flushing the CSS changes
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
249
250
|
node.offsetHeight;
|
|
250
251
|
// Reset the transition to what it was before
|
|
251
252
|
node.style.transition = previous;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type AcceptNode = (node: HTMLElement) => typeof NodeFilter.FILTER_ACCEPT | typeof NodeFilter.FILTER_SKIP | typeof NodeFilter.FILTER_REJECT;
|
|
2
|
+
export declare function useTreeWalker(options: {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
container: HTMLElement | null;
|
|
5
|
+
accept: AcceptNode;
|
|
6
|
+
walk(node: HTMLElement): void;
|
|
7
|
+
}): void;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getOwnerDocument } from "../utils/owner.js";
|
|
2
|
+
export function useTreeWalker(options) {
|
|
3
|
+
const { enabled, container, accept, walk } = $derived(options);
|
|
4
|
+
$effect(() => {
|
|
5
|
+
if (!container)
|
|
6
|
+
return;
|
|
7
|
+
if (!enabled)
|
|
8
|
+
return;
|
|
9
|
+
const ownerDocument = getOwnerDocument(container);
|
|
10
|
+
if (!ownerDocument)
|
|
11
|
+
return;
|
|
12
|
+
const acceptNode = Object.assign((node) => accept(node), { acceptNode: accept });
|
|
13
|
+
const walker = ownerDocument.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, acceptNode,
|
|
14
|
+
// @ts-expect-error This `false` is a simple small fix for older browsers
|
|
15
|
+
false);
|
|
16
|
+
while (walker.nextNode())
|
|
17
|
+
walk(walker.currentNode);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { untrack } from "svelte";
|
|
2
|
+
export function useWatch(options) {
|
|
3
|
+
const { action, dependencies } = $derived(options);
|
|
4
|
+
let track = [];
|
|
5
|
+
$effect(() => {
|
|
6
|
+
let oldValues = untrack(() => [...track]);
|
|
7
|
+
for (let [idx, value] of dependencies.entries()) {
|
|
8
|
+
if (untrack(() => track[idx]) !== value) {
|
|
9
|
+
// At least 1 item changed
|
|
10
|
+
let returnValue = action(dependencies, oldValues);
|
|
11
|
+
track = dependencies;
|
|
12
|
+
return returnValue;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function useWindowEvent(params) {
|
|
2
|
+
let { enabled, type, listener, options } = $derived(params);
|
|
3
|
+
$effect(() => {
|
|
4
|
+
if (!enabled)
|
|
5
|
+
return;
|
|
6
|
+
function handler(event) {
|
|
7
|
+
listener(event);
|
|
8
|
+
}
|
|
9
|
+
window.addEventListener(type, handler, options);
|
|
10
|
+
return () => window.removeEventListener(type, handler, options);
|
|
11
|
+
});
|
|
12
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
export * from "./button/index.js";
|
|
2
2
|
export * from "./checkbox/index.js";
|
|
3
|
+
export * from "./close-button/index.js";
|
|
4
|
+
export * from "./data-interactive/index.js";
|
|
3
5
|
export * from "./description/index.js";
|
|
6
|
+
export * from "./dialog/index.js";
|
|
4
7
|
export * from "./field/index.js";
|
|
5
8
|
export * from "./fieldset/index.js";
|
|
9
|
+
export * from "./input/index.js";
|
|
6
10
|
export * from "./label/index.js";
|
|
7
11
|
export * from "./legend/index.js";
|
|
8
12
|
export * from "./listbox/index.js";
|
|
13
|
+
export * from "./menu/index.js";
|
|
9
14
|
export * from "./switch/index.js";
|
|
10
15
|
export * from "./tabs/index.js";
|
|
16
|
+
export * from "./transition/index.js";
|
|
17
|
+
export * from "./hooks/use-id.js";
|
|
18
|
+
export * from "./utils/types.js";
|
|
19
|
+
export { mergeProps } from "./utils/render.js";
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
export * from "./button/index.js";
|
|
2
2
|
export * from "./checkbox/index.js";
|
|
3
|
+
export * from "./close-button/index.js";
|
|
4
|
+
export * from "./data-interactive/index.js";
|
|
3
5
|
export * from "./description/index.js";
|
|
6
|
+
export * from "./dialog/index.js";
|
|
4
7
|
export * from "./field/index.js";
|
|
5
8
|
export * from "./fieldset/index.js";
|
|
9
|
+
export * from "./input/index.js";
|
|
6
10
|
export * from "./label/index.js";
|
|
7
11
|
export * from "./legend/index.js";
|
|
8
12
|
export * from "./listbox/index.js";
|
|
13
|
+
export * from "./menu/index.js";
|
|
9
14
|
export * from "./switch/index.js";
|
|
10
15
|
export * from "./tabs/index.js";
|
|
16
|
+
export * from "./transition/index.js";
|
|
17
|
+
export * from "./hooks/use-id.js";
|
|
18
|
+
export * from "./utils/types.js";
|
|
19
|
+
export { mergeProps } from "./utils/render.js";
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<script lang="ts" module>const DEFAULT_INPUT_TAG = "input";
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_INPUT_TAG, TValue = string">import { htmlid } from "../utils/id.js";
|
|
5
|
+
import { useDisabled } from "../hooks/use-disabled.js";
|
|
6
|
+
import { useProvidedId } from "../internal/id.js";
|
|
7
|
+
import { useLabelledBy } from "../label/context.svelte.js";
|
|
8
|
+
import { useDescribedBy } from "../description/context.svelte.js";
|
|
9
|
+
import { useHover } from "../hooks/use-hover.svelte.js";
|
|
10
|
+
import { useFocusRing } from "../hooks/use-focus-ring.svelte.js";
|
|
11
|
+
import { mergeProps } from "../utils/render.js";
|
|
12
|
+
import ElementOrComponent from "../utils/ElementOrComponent.svelte";
|
|
13
|
+
const internalId = htmlid();
|
|
14
|
+
const providedId = useProvidedId();
|
|
15
|
+
const providedDisabled = useDisabled();
|
|
16
|
+
let {
|
|
17
|
+
ref = $bindable(),
|
|
18
|
+
value = $bindable(),
|
|
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 { isHovered: hover, hoverProps } = $derived(
|
|
29
|
+
useHover({
|
|
30
|
+
get disabled() {
|
|
31
|
+
return disabled;
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
const { isFocusVisible: focus, focusProps } = $derived(
|
|
36
|
+
useFocusRing({
|
|
37
|
+
get autofocus() {
|
|
38
|
+
return autofocus;
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
);
|
|
42
|
+
const ourProps = $derived(
|
|
43
|
+
mergeProps(
|
|
44
|
+
{
|
|
45
|
+
id,
|
|
46
|
+
"aria-labelledby": labelledBy?.value,
|
|
47
|
+
"aria-describedby": describedBy?.value,
|
|
48
|
+
"aria-invalid": invalid ? "" : void 0,
|
|
49
|
+
disabled: disabled || void 0,
|
|
50
|
+
autofocus
|
|
51
|
+
},
|
|
52
|
+
focusProps,
|
|
53
|
+
hoverProps
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
const slot = $derived({ disabled, invalid, hover, focus, autofocus });
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<ElementOrComponent {ourProps} {theirProps} {slot} defaultTag={DEFAULT_INPUT_TAG} name="Input" bind:ref bind:value />
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ElementType, Props } from "../utils/types.js";
|
|
2
|
+
declare const DEFAULT_INPUT_TAG: "input";
|
|
3
|
+
type InputRenderPropArg = {
|
|
4
|
+
disabled: boolean;
|
|
5
|
+
hover: boolean;
|
|
6
|
+
focus: boolean;
|
|
7
|
+
autofocus: boolean;
|
|
8
|
+
invalid: boolean;
|
|
9
|
+
};
|
|
10
|
+
type InputPropsWeControl = "aria-labelledby" | "aria-describedby";
|
|
11
|
+
export type InputProps<TTag extends ElementType = typeof DEFAULT_INPUT_TAG, TValue = string> = Props<TTag, InputRenderPropArg, InputPropsWeControl, {
|
|
12
|
+
id?: string;
|
|
13
|
+
value?: TValue;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
invalid?: boolean;
|
|
16
|
+
autofocus?: boolean;
|
|
17
|
+
}>;
|
|
18
|
+
declare class __sveltets_Render<TTag extends ElementType = typeof DEFAULT_INPUT_TAG, TValue = string> {
|
|
19
|
+
props(): {
|
|
20
|
+
as?: TTag | undefined;
|
|
21
|
+
value?: TValue | undefined;
|
|
22
|
+
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("as" | "children" | "refName" | "class") | "invalid" | "disabled" | "autofocus" | "value" | "id" | InputPropsWeControl> extends infer T extends keyof import("../utils/types.js").PropsOf<TTag> ? { [P in T]: import("../utils/types.js").PropsOf<TTag>[P]; } : never) & {
|
|
23
|
+
children?: import("../utils/types.js").Children<InputRenderPropArg> | undefined;
|
|
24
|
+
ref?: HTMLElement;
|
|
25
|
+
} & (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) ? {
|
|
26
|
+
class?: import("../utils/types.js").PropsOf<TTag>["class"] | ((bag: InputRenderPropArg) => string) | undefined;
|
|
27
|
+
} : {}) & {
|
|
28
|
+
id?: string;
|
|
29
|
+
value?: TValue | undefined;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
invalid?: boolean;
|
|
32
|
+
autofocus?: boolean;
|
|
33
|
+
};
|
|
34
|
+
events(): {} & {
|
|
35
|
+
[evt: string]: CustomEvent<any>;
|
|
36
|
+
};
|
|
37
|
+
slots(): {};
|
|
38
|
+
bindings(): "ref" | "value";
|
|
39
|
+
exports(): {};
|
|
40
|
+
}
|
|
41
|
+
interface $$IsomorphicComponent {
|
|
42
|
+
new <TTag extends ElementType = typeof DEFAULT_INPUT_TAG, TValue = string>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TTag, TValue>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TTag, TValue>['props']>, ReturnType<__sveltets_Render<TTag, TValue>['events']>, ReturnType<__sveltets_Render<TTag, TValue>['slots']>> & {
|
|
43
|
+
$$bindings?: ReturnType<__sveltets_Render<TTag, TValue>['bindings']>;
|
|
44
|
+
} & ReturnType<__sveltets_Render<TTag, TValue>['exports']>;
|
|
45
|
+
<TTag extends ElementType = typeof DEFAULT_INPUT_TAG, TValue = string>(internal: unknown, props: ReturnType<__sveltets_Render<TTag, TValue>['props']> & {
|
|
46
|
+
$$events?: ReturnType<__sveltets_Render<TTag, TValue>['events']>;
|
|
47
|
+
}): ReturnType<__sveltets_Render<TTag, TValue>['exports']>;
|
|
48
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
49
|
+
}
|
|
50
|
+
declare const Input: $$IsomorphicComponent;
|
|
51
|
+
type Input<TTag extends ElementType = typeof DEFAULT_INPUT_TAG, TValue = string> = InstanceType<typeof Input<TTag, TValue>>;
|
|
52
|
+
export default Input;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Input, type InputProps } from "./Input.svelte";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Input } from "./Input.svelte";
|
|
@@ -5,7 +5,10 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
5
5
|
(internal: unknown, props: Props & {
|
|
6
6
|
$$events?: Events;
|
|
7
7
|
$$slots?: Slots;
|
|
8
|
-
}): Exports
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
9
12
|
z_$$bindings?: Bindings;
|
|
10
13
|
}
|
|
11
14
|
declare const FocusSentinel: $$__sveltets_2_IsomorphicComponent<{
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: Props & {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const ForcePortalRoot: $$__sveltets_2_IsomorphicComponent<{
|
|
16
|
+
force: boolean;
|
|
17
|
+
children: Snippet;
|
|
18
|
+
}, {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
}, {}, {}, "">;
|
|
21
|
+
type ForcePortalRoot = InstanceType<typeof ForcePortalRoot>;
|
|
22
|
+
export default ForcePortalRoot;
|
|
@@ -5,7 +5,10 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
5
5
|
(internal: unknown, props: Props & {
|
|
6
6
|
$$events?: Events;
|
|
7
7
|
$$slots?: Slots;
|
|
8
|
-
}): Exports
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
9
12
|
z_$$bindings?: Bindings;
|
|
10
13
|
}
|
|
11
14
|
declare const FormFields: $$__sveltets_2_IsomorphicComponent<{
|
|
@@ -5,7 +5,10 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
5
5
|
(internal: unknown, props: Props & {
|
|
6
6
|
$$events?: Events;
|
|
7
7
|
$$slots?: Slots;
|
|
8
|
-
}): Exports
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
9
12
|
z_$$bindings?: Bindings;
|
|
10
13
|
}
|
|
11
14
|
declare const FormResolver: $$__sveltets_2_IsomorphicComponent<{
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
<script lang="ts"
|
|
1
|
+
<script lang="ts" module>import ElementOrComponent from "../utils/ElementOrComponent.svelte";
|
|
2
|
+
const DEFAULT_VISUALLY_HIDDEN_TAG = "span";
|
|
3
|
+
export var HiddenFeatures = /* @__PURE__ */ ((HiddenFeatures2) => {
|
|
2
4
|
HiddenFeatures2[HiddenFeatures2["None"] = 1] = "None";
|
|
3
5
|
HiddenFeatures2[HiddenFeatures2["Focusable"] = 2] = "Focusable";
|
|
4
6
|
HiddenFeatures2[HiddenFeatures2["Hidden"] = 4] = "Hidden";
|
|
5
7
|
return HiddenFeatures2;
|
|
6
8
|
})(HiddenFeatures || {});
|
|
7
|
-
const DEFAULT_VISUALLY_HIDDEN_TAG = "div";
|
|
8
9
|
</script>
|
|
9
10
|
|
|
10
|
-
<script lang="ts" generics="TTag extends
|
|
11
|
-
as = DEFAULT_VISUALLY_HIDDEN_TAG,
|
|
12
|
-
ref = $bindable(),
|
|
13
|
-
features = HiddenFeatures.None,
|
|
14
|
-
...theirProps
|
|
15
|
-
} = $props();
|
|
11
|
+
<script lang="ts" generics="TTag extends ElementType = typeof DEFAULT_VISUALLY_HIDDEN_TAG">let { ref = $bindable(), features = HiddenFeatures.None, ...theirProps } = $props();
|
|
16
12
|
let ourProps = {
|
|
17
13
|
"aria-hidden": (features & HiddenFeatures.Focusable) === HiddenFeatures.Focusable ? true : theirProps["aria-hidden"] ?? void 0,
|
|
18
14
|
hidden: (features & HiddenFeatures.Hidden) === HiddenFeatures.Hidden ? true : void 0,
|
|
@@ -33,4 +29,4 @@ let ourProps = {
|
|
|
33
29
|
};
|
|
34
30
|
</script>
|
|
35
31
|
|
|
36
|
-
<
|
|
32
|
+
<ElementOrComponent {ourProps} {theirProps} defaultTag={DEFAULT_VISUALLY_HIDDEN_TAG} name="Hidden" bind:ref />
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { ElementType, Props } from "../utils/types.js";
|
|
2
|
+
declare const DEFAULT_VISUALLY_HIDDEN_TAG: "span";
|
|
3
3
|
export declare enum HiddenFeatures {
|
|
4
4
|
None = 1,
|
|
5
5
|
Focusable = 2,
|
|
6
6
|
Hidden = 4
|
|
7
7
|
}
|
|
8
|
-
declare const DEFAULT_VISUALLY_HIDDEN_TAG: "div";
|
|
9
8
|
type HiddenRenderPropArg = {};
|
|
10
9
|
type HiddenPropsWeControl = never;
|
|
11
|
-
export type HiddenProps<TTag extends
|
|
10
|
+
export type HiddenProps<TTag extends ElementType = typeof DEFAULT_VISUALLY_HIDDEN_TAG> = Props<TTag, HiddenRenderPropArg, HiddenPropsWeControl, {
|
|
12
11
|
features?: HiddenFeatures;
|
|
13
|
-
ref?: HTMLElementType<TTag> | null;
|
|
14
12
|
}>;
|
|
15
|
-
declare class __sveltets_Render<TTag extends
|
|
16
|
-
props():
|
|
13
|
+
declare class __sveltets_Render<TTag extends ElementType = typeof DEFAULT_VISUALLY_HIDDEN_TAG> {
|
|
14
|
+
props(): {
|
|
15
|
+
as?: TTag | undefined;
|
|
16
|
+
} & (Exclude<keyof import("../utils/types.js").PropsOf<TTag>, ("as" | "children" | "refName" | "class") | "features"> extends infer T extends keyof import("../utils/types.js").PropsOf<TTag> ? { [P in T]: import("../utils/types.js").PropsOf<TTag>[P]; } : never) & {
|
|
17
|
+
children?: import("../utils/types.js").Children<HiddenRenderPropArg> | undefined;
|
|
18
|
+
ref?: HTMLElement;
|
|
19
|
+
} & (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) ? {
|
|
20
|
+
class?: import("../utils/types.js").PropsOf<TTag>["class"] | ((bag: HiddenRenderPropArg) => string) | undefined;
|
|
21
|
+
} : {}) & {
|
|
22
|
+
features?: HiddenFeatures;
|
|
23
|
+
};
|
|
17
24
|
events(): {} & {
|
|
18
25
|
[evt: string]: CustomEvent<any>;
|
|
19
26
|
};
|
|
@@ -22,14 +29,14 @@ declare class __sveltets_Render<TTag extends keyof SvelteHTMLElements> {
|
|
|
22
29
|
exports(): {};
|
|
23
30
|
}
|
|
24
31
|
interface $$IsomorphicComponent {
|
|
25
|
-
new <TTag extends
|
|
32
|
+
new <TTag extends ElementType = typeof DEFAULT_VISUALLY_HIDDEN_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']>> & {
|
|
26
33
|
$$bindings?: ReturnType<__sveltets_Render<TTag>['bindings']>;
|
|
27
34
|
} & ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
28
|
-
<TTag extends
|
|
35
|
+
<TTag extends ElementType = typeof DEFAULT_VISUALLY_HIDDEN_TAG>(internal: unknown, props: ReturnType<__sveltets_Render<TTag>['props']> & {
|
|
29
36
|
$$events?: ReturnType<__sveltets_Render<TTag>['events']>;
|
|
30
37
|
}): ReturnType<__sveltets_Render<TTag>['exports']>;
|
|
31
38
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
32
39
|
}
|
|
33
40
|
declare const Hidden: $$IsomorphicComponent;
|
|
34
|
-
type Hidden<TTag extends
|
|
41
|
+
type Hidden<TTag extends ElementType = typeof DEFAULT_VISUALLY_HIDDEN_TAG> = InstanceType<typeof Hidden<TTag>>;
|
|
35
42
|
export default Hidden;
|
|
@@ -6,7 +6,10 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
6
6
|
(internal: unknown, props: Props & {
|
|
7
7
|
$$events?: Events;
|
|
8
8
|
$$slots?: Slots;
|
|
9
|
-
}): Exports
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
10
13
|
z_$$bindings?: Bindings;
|
|
11
14
|
}
|
|
12
15
|
declare const HoistFormFields: $$__sveltets_2_IsomorphicComponent<{
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts" module>import { getContext, onMount } from "svelte";
|
|
2
|
+
export function useMainTreeNode(options = {}) {
|
|
3
|
+
const { fallbackMainTreeNode = null } = $derived(options);
|
|
4
|
+
return getContext("MainTreeContext") ?? {
|
|
5
|
+
get node() {
|
|
6
|
+
return fallbackMainTreeNode;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<script lang="ts">import { setContext } from "svelte";
|
|
13
|
+
import Hidden, { HiddenFeatures } from "./Hidden.svelte";
|
|
14
|
+
import { getOwnerDocument } from "../utils/owner.js";
|
|
15
|
+
let { node, children } = $props();
|
|
16
|
+
let mainTreeNode = $state(null);
|
|
17
|
+
const resolvedMainTreeNode = useMainTreeNode({
|
|
18
|
+
get fallbackMainTreeNode() {
|
|
19
|
+
return node ?? mainTreeNode;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
setContext("MainTreeContext", {
|
|
23
|
+
get node() {
|
|
24
|
+
return resolvedMainTreeNode.node;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
let el = $state();
|
|
28
|
+
onMount(() => {
|
|
29
|
+
if (!el) return;
|
|
30
|
+
for (let container of getOwnerDocument(el)?.querySelectorAll("html > *, body > *") ?? []) {
|
|
31
|
+
if (container === document.body) continue;
|
|
32
|
+
if (container === document.head) continue;
|
|
33
|
+
if (!(container instanceof HTMLElement)) continue;
|
|
34
|
+
if (container?.contains(el)) {
|
|
35
|
+
mainTreeNode = container;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
{#if children}{@render children()}{/if}
|
|
43
|
+
{#if resolvedMainTreeNode === null}
|
|
44
|
+
<Hidden features={HiddenFeatures.Hidden} bind:ref={el} />
|
|
45
|
+
{/if}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
type MainTreeContext = {
|
|
2
|
+
node: HTMLElement | null;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Get the main tree node from context or fallback to the optionally provided node.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useMainTreeNode(options?: {
|
|
8
|
+
fallbackMainTreeNode?: HTMLElement | null;
|
|
9
|
+
}): MainTreeContext;
|
|
10
|
+
import { type Snippet } from "svelte";
|
|
11
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
12
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
13
|
+
$$bindings?: Bindings;
|
|
14
|
+
} & Exports;
|
|
15
|
+
(internal: unknown, props: Props & {
|
|
16
|
+
$$events?: Events;
|
|
17
|
+
$$slots?: Slots;
|
|
18
|
+
}): Exports & {
|
|
19
|
+
$set?: any;
|
|
20
|
+
$on?: any;
|
|
21
|
+
};
|
|
22
|
+
z_$$bindings?: Bindings;
|
|
23
|
+
}
|
|
24
|
+
declare const MainTreeProvider: $$__sveltets_2_IsomorphicComponent<{
|
|
25
|
+
children: Snippet;
|
|
26
|
+
node?: HTMLElement | null;
|
|
27
|
+
}, {
|
|
28
|
+
[evt: string]: CustomEvent<any>;
|
|
29
|
+
}, {}, {}, "">;
|
|
30
|
+
type MainTreeProvider = InstanceType<typeof MainTreeProvider>;
|
|
31
|
+
export default MainTreeProvider;
|
|
@@ -6,7 +6,10 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
|
|
|
6
6
|
(internal: unknown, props: Props & {
|
|
7
7
|
$$events?: Events;
|
|
8
8
|
$$slots?: Slots;
|
|
9
|
-
}): Exports
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
10
13
|
z_$$bindings?: Bindings;
|
|
11
14
|
}
|
|
12
15
|
declare const Portal: $$__sveltets_2_IsomorphicComponent<{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MutableRefObject } from "../utils/ref.svelte.js";
|
|
2
2
|
type Align = "start" | "end";
|
|
3
3
|
type Placement = "top" | "right" | "bottom" | "left";
|
|
4
4
|
type BaseAnchorProps = {
|
|
@@ -30,24 +30,29 @@ export type AnchorPropsWithSelection = false | (`${Placement | "selection"}` | `
|
|
|
30
30
|
to: `${Placement | "selection"}` | `${Placement | "selection"} ${Align}`;
|
|
31
31
|
}>;
|
|
32
32
|
export type InternalFloatingPanelProps = Partial<{
|
|
33
|
-
inner: {
|
|
33
|
+
inner: {
|
|
34
|
+
listRef: MutableRefObject<(HTMLElement | null)[]>;
|
|
35
|
+
index: () => number | null;
|
|
36
|
+
};
|
|
34
37
|
}>;
|
|
35
38
|
type FloatingContext = {
|
|
36
|
-
styles?:
|
|
39
|
+
styles?: string;
|
|
37
40
|
setReference: (reference: HTMLElement | null | undefined) => void;
|
|
38
41
|
setFloating: (floating: HTMLElement | null | undefined) => void;
|
|
39
|
-
getReferenceProps:
|
|
40
|
-
getFloatingProps:
|
|
42
|
+
getReferenceProps: () => Record<string, any>;
|
|
43
|
+
getFloatingProps: () => Record<string, any>;
|
|
41
44
|
slot: Partial<{
|
|
42
45
|
anchor: `${Placement | "selection"}` | `${Placement | "selection"} ${Align}`;
|
|
43
46
|
}>;
|
|
44
47
|
};
|
|
45
48
|
export declare function useResolvedAnchor<T extends AnchorProps | AnchorPropsWithSelection>(anchor?: T): Exclude<T, boolean | string> | null;
|
|
46
49
|
export declare function useFloating(): FloatingContext;
|
|
47
|
-
export declare function useFloatingPanelProps(): (
|
|
48
|
-
"data-anchor": Placement | "top
|
|
50
|
+
export declare function useFloatingPanelProps(): () => Record<string, any> & {
|
|
51
|
+
"data-anchor": Placement | "top end" | "top start" | "right end" | "right start" | "bottom end" | "bottom start" | "left end" | "left start" | "selection" | "selection end" | "selection start" | undefined;
|
|
49
52
|
};
|
|
50
|
-
export declare function useFloatingPanel(
|
|
53
|
+
export declare function useFloatingPanel(options: {
|
|
54
|
+
placement: (AnchorPropsWithSelection & InternalFloatingPanelProps) | null;
|
|
55
|
+
}): {
|
|
51
56
|
readonly setFloating: (floating: HTMLElement | null | undefined) => void;
|
|
52
57
|
readonly style: string | undefined;
|
|
53
58
|
};
|